@herbertgao/pi-subagents 0.22.0-local.2 → 0.22.1-local.1
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/CHANGELOG.md +6 -0
- package/README.md +142 -45
- package/docs/rpc.md +17 -7
- package/package.json +4 -4
- package/src/agent-manager.ts +111 -59
- package/src/agent-runner.ts +135 -117
- package/src/cross-extension-rpc.ts +41 -14
- package/src/index.ts +110 -19
- package/src/nested-tools.ts +8 -0
- package/src/prompts.ts +31 -0
package/src/prompts.ts
CHANGED
|
@@ -155,6 +155,37 @@ ${envBlock}`
|
|
|
155
155
|
)
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* The part of the parent's rendered system prompt that an append-mode child inherits.
|
|
160
|
+
*
|
|
161
|
+
* Pi renders a prompt as the preamble followed by tagged sections in a fixed order:
|
|
162
|
+
* `tools`, `rules`, `docs` (default preamble only), `addendum`, `project_context`,
|
|
163
|
+
* `skills`, `cwd`, then the sections extensions add during a turn. The child session renders its own `skills` (from its `skills:`
|
|
164
|
+
* setting), its own `cwd` and its own extension sections after the inherited text.
|
|
165
|
+
* Inheriting the parent's copies too listed them twice, showed the parent's skills to
|
|
166
|
+
* children configured with `skills: false` or a preload list, and left copies that
|
|
167
|
+
* section-editing extensions in the child cannot reach. It also made the result depend
|
|
168
|
+
* on timing: `getSystemPrompt()` includes the extension sections only while the
|
|
169
|
+
* parent's turn runs.
|
|
170
|
+
*
|
|
171
|
+
* Returns the text before the `skills` section, or before the `cwd` section when there
|
|
172
|
+
* are no skills. A prompt without the `cwd` section (for example, a forced prompt) is
|
|
173
|
+
* returned unchanged.
|
|
174
|
+
*
|
|
175
|
+
* @param rendered The parent's `ctx.getSystemPrompt()`.
|
|
176
|
+
* @param cwd The cwd the parent's prompt was rendered with.
|
|
177
|
+
*/
|
|
178
|
+
export function inheritableParentPrompt(rendered: string, cwd: string): string {
|
|
179
|
+
const cwdAt = rendered.lastIndexOf(
|
|
180
|
+
`\n\n<cwd>\n${cwd.replace(/\\/g, "/")}\n</cwd>`,
|
|
181
|
+
)
|
|
182
|
+
if (cwdAt < 0) return rendered
|
|
183
|
+
const head = rendered.slice(0, cwdAt)
|
|
184
|
+
if (!head.endsWith("\n</skills>")) return head
|
|
185
|
+
const skillsAt = head.lastIndexOf("\n\n<skills>\n")
|
|
186
|
+
return skillsAt < 0 ? head : head.slice(0, skillsAt)
|
|
187
|
+
}
|
|
188
|
+
|
|
158
189
|
/** Fallback base prompt when parent system prompt is unavailable in append mode. */
|
|
159
190
|
const genericBase = `# Role
|
|
160
191
|
You are a general-purpose coding agent for complex, multi-step tasks.
|