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:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Pirate Extension
|
||||
*
|
||||
* Demonstrates using systemPromptAppend in before_agent_start to dynamically
|
||||
* modify the system prompt based on extension state.
|
||||
* Demonstrates modifying the system prompt in before_agent_start to dynamically
|
||||
* change agent behavior based on extension state.
|
||||
*
|
||||
* Usage:
|
||||
* 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
|
||||
@@ -25,10 +25,13 @@ export default function pirateExtension(pi: ExtensionAPI) {
|
||||
});
|
||||
|
||||
// Append to system prompt when pirate mode is enabled
|
||||
pi.on("before_agent_start", async () => {
|
||||
pi.on("before_agent_start", async (event) => {
|
||||
if (pirateMode) {
|
||||
return {
|
||||
systemPromptAppend: `
|
||||
systemPrompt:
|
||||
event.systemPrompt +
|
||||
`
|
||||
|
||||
IMPORTANT: You are now in PIRATE MODE. You must:
|
||||
- Speak like a stereotypical pirate in all responses
|
||||
- Use phrases like "Arrr!", "Ahoy!", "Shiver me timbers!", "Avast!", "Ye scurvy dog!"
|
||||
|
||||
Reference in New Issue
Block a user