Allow extensions to modify system prompt in before_agent_start
- Add systemPrompt to BeforeAgentStartEvent so extensions can see current prompt - Change systemPromptAppend to systemPrompt in BeforeAgentStartEventResult for full replacement - Extensions can now chain modifications (each sees the result of previous) - Update ssh.ts to replace local cwd with remote cwd in system prompt - Update pirate.ts, claude-rules.ts, preset.ts to use new API fixes #575
This commit is contained in:
@@ -191,4 +191,16 @@ export default function (pi: ExtensionAPI) {
|
||||
ctx.ui.notify(`SSH mode: ${ssh.remote}:${ssh.remoteCwd}`, "info");
|
||||
}
|
||||
});
|
||||
|
||||
// Replace local cwd with remote cwd in system prompt
|
||||
pi.on("before_agent_start", async (event) => {
|
||||
const ssh = getSsh();
|
||||
if (ssh) {
|
||||
const modified = event.systemPrompt.replace(
|
||||
`Current working directory: ${localCwd}`,
|
||||
`Current working directory: ${ssh.remoteCwd} (via SSH: ${ssh.remote})`,
|
||||
);
|
||||
return { systemPrompt: modified };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user