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:
Mario Zechner 2026-01-08 19:54:34 +01:00
parent 0774db2e5a
commit 17cb328ca1
10 changed files with 65 additions and 27 deletions

View file

@ -61,7 +61,7 @@ export default function claudeRulesExtension(pi: ExtensionAPI) {
});
// Append available rules to system prompt
pi.on("before_agent_start", async () => {
pi.on("before_agent_start", async (event) => {
if (ruleFiles.length === 0) {
return;
}
@ -69,7 +69,10 @@ export default function claudeRulesExtension(pi: ExtensionAPI) {
const rulesList = ruleFiles.map((f) => `- .claude/rules/${f}`).join("\n");
return {
systemPromptAppend: `
systemPrompt:
event.systemPrompt +
`
## Project Rules
The following project rules are available in .claude/rules/: