pi-soul 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,8 @@ Write your soul once in markdown, and pi-soul injects it into the system prompt
6
6
 
7
7
  ## Install
8
8
 
9
+ Requires pi 0.86.0 or later.
10
+
9
11
  ```bash
10
12
  # from npm
11
13
  pi install npm:pi-soul
@@ -56,7 +58,7 @@ With this soul, every new pi session reasons, communicates, and codes like that
56
58
 
57
59
  ## How it works
58
60
 
59
- A single TypeScript extension listens for pi's `before_agent_start` event and appends your soul to the system prompt under a `# Your Soul` section. No build step, no runtime dependencies — pi loads the TypeScript source directly.
61
+ A single TypeScript extension listens for pi's `before_agent_start` event and adds your soul to the system prompt as a `<soul>` section. Pi records the section in the session. When you edit your soul or run `/soul off`, pi appends the change to the conversation instead of rewriting the system prompt, so models that accept mid-conversation system messages keep their prompt cache. No build step, no runtime dependencies — pi loads the TypeScript source directly.
60
62
 
61
63
  ## License
62
64
 
@@ -2,7 +2,7 @@
2
2
  * pi-soul — give your pi agent a soul.
3
3
  *
4
4
  * A "soul" is a persistent persona/profile written in markdown. When present,
5
- * it is appended to the system prompt on every turn so the agent's output is
5
+ * it is added to the system prompt as a <soul> section so the agent's output is
6
6
  * tailored to it in every session.
7
7
  *
8
8
  * Soul resolution (checked fresh on each agent start):
@@ -86,22 +86,19 @@ export default function soulExtension(pi: ExtensionAPI) {
86
86
  updateStatus(ctx);
87
87
  });
88
88
 
89
- // Inject the soul into the system prompt on every turn.
89
+ // Add the soul as its own prompt section rather than returning `systemPrompt`.
90
+ // Pi records sections in the session and sends a later edit or /soul off as an
91
+ // update. A returned `systemPrompt` replaces the whole prompt on every change
92
+ // and never reaches the session file.
90
93
  pi.on("before_agent_start", async (event, ctx) => {
91
94
  if (!enabled) return undefined;
92
95
  const soul = resolveSoul(ctx);
93
96
  if (!soul) return undefined;
94
- return {
95
- systemPrompt: `${event.systemPrompt}
96
-
97
- # Your Soul
98
-
99
- The user has given you the following soul — a persona and profile you must
97
+ event.systemPromptOptions.sections.soul = `The user has given you the following soul — a persona and profile you must
100
98
  embody. Let it shape your reasoning, tone, and output in every response,
101
99
  while still completing every task correctly and accurately.
102
100
 
103
- ${soul.content}`,
104
- };
101
+ ${soul.content}`;
105
102
  });
106
103
 
107
104
  pi.registerCommand("soul", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-soul",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Give your pi agent a soul — a persistent persona that tailors every session.",
5
5
  "keywords": [
6
6
  "pi-package",