@selesai/code 0.5.29 → 0.6.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 +24 -0
- package/README.md +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +18 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/system-prompt.test.d.ts +2 -0
- package/dist/core/system-prompt.test.d.ts.map +1 -0
- package/dist/core/system-prompt.test.js +89 -0
- package/dist/core/system-prompt.test.js.map +1 -0
- package/dist/defaults/models.json +13 -45
- package/dist/defaults/settings.json +1 -2
- package/dist/extensions/copy-turn.test.ts +131 -0
- package/dist/extensions/copy-turn.ts +6 -1
- package/dist/extensions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/dist/extensions/package.json +0 -1
- package/dist/extensions/pi-subagents/CHANGELOG.md +3 -0
- package/dist/extensions/pi-subagents/README.md +27 -32
- package/dist/extensions/pi-subagents/agents/architect.md +4 -4
- package/dist/extensions/pi-subagents/agents/builder.md +5 -4
- package/dist/extensions/pi-subagents/agents/commentator.md +3 -2
- package/dist/extensions/pi-subagents/agents/explorer.md +3 -2
- package/dist/extensions/pi-subagents/agents/recapper.md +3 -2
- package/dist/extensions/pi-subagents/agents/researcher.md +4 -3
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +2 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +10 -9
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +12 -11
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +10 -11
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +56 -9
- package/dist/extensions/pi-subagents/src/agents/task-aware-routing.ts +125 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +1 -1
- package/dist/extensions/pi-subagents/src/extension/index.ts +5 -1
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +2 -2
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +24 -7
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +23 -5
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +27 -1
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +64 -6
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +16 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +72 -18
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +19 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +127 -31
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +4 -6
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +63 -9
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +41 -2
- package/dist/extensions/pi-subagents/src/shared/utils.ts +29 -1
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +5 -1
- package/dist/extensions/pi-subagents/src/tui/render.ts +28 -6
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +111 -6
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +74 -43
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +36 -21
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +5 -3
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +20 -8
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +14 -7
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +81 -5
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +49 -10
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +18 -2
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +70 -6
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +161 -1
- package/dist/extensions/pi-subagents/test/unit/builtin-agent-documentation.test.ts +63 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +6 -1
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +29 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +2 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +12 -0
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +91 -1
- package/dist/extensions/pi-subagents/test/unit/task-aware-routing.test.ts +213 -0
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +23 -1
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +60 -9
- package/dist/skills/ponytail/SKILL.md +1 -3
- package/docs/plans/subagent-delegation/phase-0-correctness.md +265 -0
- package/docs/plans/subagent-delegation/phase-1-behavioral-contract.md +486 -0
- package/docs/plans/subagent-delegation/phase-2-context-controls.md +282 -0
- package/docs/plans/subagent-delegation/phase-3-advisory-routing.md +362 -0
- package/docs/plans/subagent-delegation/phase-4-optional-enforcement.md +381 -0
- package/package.json +2 -2
- package/dist/extensions/caveman/caveman-instructions.cjs +0 -11
- package/dist/extensions/caveman/index.js +0 -118
- package/dist/extensions/caveman/package.json +0 -8
- package/dist/extensions/caveman/test/extension.test.js +0 -203
- package/dist/extensions/caveman/test/helpers.test.js +0 -58
- package/dist/skills/caveman/SKILL.md +0 -50
|
@@ -9,8 +9,10 @@ import {
|
|
|
9
9
|
buildSubagentToolDescription,
|
|
10
10
|
COMPACT_SUBAGENT_TOOL_DESCRIPTION,
|
|
11
11
|
FULL_SUBAGENT_TOOL_DESCRIPTION,
|
|
12
|
+
SUBAGENT_PARENT_ROUTING_GUIDANCE,
|
|
12
13
|
SUBAGENT_SAFETY_GUIDANCE,
|
|
13
14
|
} from "../../src/extension/tool-description.ts";
|
|
15
|
+
import { BUILTIN_AGENT_NAMES } from "../../src/agents/agents.ts";
|
|
14
16
|
import { SUBAGENT_CHILD_ENV, SUBAGENT_FANOUT_CHILD_ENV } from "../../src/runs/shared/pi-args.ts";
|
|
15
17
|
|
|
16
18
|
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
@@ -31,9 +33,12 @@ describe("registered subagent tool description", () => {
|
|
|
31
33
|
it("keeps full mode safe and free of hardcoded builtin agent names", () => {
|
|
32
34
|
const description = buildSubagentToolDescription();
|
|
33
35
|
|
|
34
|
-
for (const builtinName of
|
|
36
|
+
for (const builtinName of BUILTIN_AGENT_NAMES) {
|
|
35
37
|
assert.doesNotMatch(description, new RegExp(`\\b${builtinName}\\b`));
|
|
36
38
|
}
|
|
39
|
+
for (const legacyName of ["scout", "worker", "planner"]) {
|
|
40
|
+
assert.doesNotMatch(description, new RegExp(`\\b${legacyName}\\b`));
|
|
41
|
+
}
|
|
37
42
|
assert.match(description, /^To delegate work, call with \{ agent, task \}, \{ tasks \}, or \{ chain \}; omit action\./i);
|
|
38
43
|
assert.match(description, /Use action only for management\/control actions listed below/i);
|
|
39
44
|
assert.match(description, /use \{ action: "list" \} to inspect configured agents\/chains/i);
|
|
@@ -50,6 +55,11 @@ describe("registered subagent tool description", () => {
|
|
|
50
55
|
assert.doesNotMatch(description, /only for foreground runs/i);
|
|
51
56
|
assert.doesNotMatch(description, /omit for async\/background runs/i);
|
|
52
57
|
assert.match(description, /SAFETY-CRITICAL SUBAGENT GUIDANCE/);
|
|
58
|
+
assert.match(description, /PARENT-ONLY SUBAGENT ROUTING/);
|
|
59
|
+
assert.match(description, /call \{ action: "list" \} and select only an executable entry using its current role, context, and tool metadata/i);
|
|
60
|
+
assert.match(description, /Keep tiny targeted reads and simple answers local/i);
|
|
61
|
+
assert.match(description, /broad local investigation, external research, and mutation\/implementation work/i);
|
|
62
|
+
assert.match(description, /parent remains the decision-maker and normally the sole writer/i);
|
|
53
63
|
assert.match(description, /Do not sleep or poll status just to wait/i);
|
|
54
64
|
assert.match(description, /use subagent_wait/i);
|
|
55
65
|
assert.match(description, /interactive session.*normally return control/i);
|
|
@@ -62,6 +72,10 @@ describe("registered subagent tool description", () => {
|
|
|
62
72
|
assert.match(description, /action: "steer"/);
|
|
63
73
|
assert.match(description, /schedule-list/);
|
|
64
74
|
assert.match(description, /action: "eject"/);
|
|
75
|
+
assert.match(description, /action: "eject", agent: "agent-name"/);
|
|
76
|
+
assert.match(description, /action: "disable", agent: "agent-name"/);
|
|
77
|
+
assert.match(description, /action: "enable", agent: "agent-name"/);
|
|
78
|
+
assert.match(description, /action: "reset", agent: "agent-name"/);
|
|
65
79
|
assert.match(description, /action: "disable"/);
|
|
66
80
|
assert.match(description, /action: "grant-spawn-budget"/);
|
|
67
81
|
assert.match(description, /root interactive parent/i);
|
|
@@ -97,6 +111,14 @@ describe("registered subagent tool description", () => {
|
|
|
97
111
|
assert.match(description, /PARALLEL/);
|
|
98
112
|
assert.match(description, /CHAIN/);
|
|
99
113
|
assert.match(description, /action without execution fields/i);
|
|
114
|
+
assert.match(description, /Parent-only routing/);
|
|
115
|
+
assert.match(description, /select only an executable entry using its current role, context, and tool metadata/i);
|
|
116
|
+
assert.match(description, /Keep tiny targeted reads and simple answers local/i);
|
|
117
|
+
assert.match(description, /broad local investigation, external research, and mutation\/implementation work/i);
|
|
118
|
+
assert.match(description, /parent remains the decision-maker and normally the sole writer/i);
|
|
119
|
+
for (const builtinName of BUILTIN_AGENT_NAMES) {
|
|
120
|
+
assert.doesNotMatch(description, new RegExp(`\\b${builtinName}\\b`));
|
|
121
|
+
}
|
|
100
122
|
assert.match(description, /subagent_wait/i);
|
|
101
123
|
assert.match(description, /interactive session.*normally return control/i);
|
|
102
124
|
assert.match(description, /Non-interactive runs.*auto-drain current-session work at agent_end/i);
|
|
@@ -127,6 +149,15 @@ describe("registered subagent tool description", () => {
|
|
|
127
149
|
assert.match(description, /count:/);
|
|
128
150
|
});
|
|
129
151
|
|
|
152
|
+
it("documents task-aware list advice as explicit-only in both modes", () => {
|
|
153
|
+
for (const description of [FULL_SUBAGENT_TOOL_DESCRIPTION, COMPACT_SUBAGENT_TOOL_DESCRIPTION]) {
|
|
154
|
+
assert.match(description, /\{ action: "list", task: "\.\.\." \}/);
|
|
155
|
+
assert.match(description, /advisory/i);
|
|
156
|
+
assert.match(description, /never launches/i);
|
|
157
|
+
assert.match(description, /explicitly call subagent|execute the recommended agent explicitly/i);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
130
161
|
it("renders a custom project description with placeholders and mandatory safety guidance", () => {
|
|
131
162
|
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-project-"));
|
|
132
163
|
const agentDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-agent-"));
|
|
@@ -148,6 +179,8 @@ describe("registered subagent tool description", () => {
|
|
|
148
179
|
assert.match(description, new RegExp(escapeRegex(agentDir)));
|
|
149
180
|
assert.match(description, new RegExp(escapeRegex(projectConfigDir)));
|
|
150
181
|
assert.match(description, /SAFETY-CRITICAL SUBAGENT GUIDANCE/);
|
|
182
|
+
assert.match(description, /PARENT-ONLY SUBAGENT ROUTING/);
|
|
183
|
+
assert.match(description, /select only an executable entry using its current role, context, and tool metadata/i);
|
|
151
184
|
assert.equal(warnings.length, 0);
|
|
152
185
|
});
|
|
153
186
|
|
|
@@ -213,7 +246,7 @@ describe("registered subagent tool description", () => {
|
|
|
213
246
|
assert.ok(warnings.some((message) => message.includes("Ignoring invalid toolDescriptionMode")));
|
|
214
247
|
});
|
|
215
248
|
|
|
216
|
-
function
|
|
249
|
+
function readRegisteredTool(agentDir: string): { description: string; promptGuidelines?: string[] } {
|
|
217
250
|
const script = String.raw`
|
|
218
251
|
import registerSubagentExtension from "./src/extension/index.ts";
|
|
219
252
|
const events = { on() { return () => {}; }, emit() {} };
|
|
@@ -234,7 +267,10 @@ describe("registered subagent tool description", () => {
|
|
|
234
267
|
});
|
|
235
268
|
registerSubagentExtension(fakePi);
|
|
236
269
|
if (!registeredTool) throw new Error("tool not registered");
|
|
237
|
-
process.stdout.write(JSON.stringify(
|
|
270
|
+
process.stdout.write(JSON.stringify({
|
|
271
|
+
description: registeredTool.description,
|
|
272
|
+
promptGuidelines: registeredTool.promptGuidelines ?? null,
|
|
273
|
+
}));
|
|
238
274
|
`;
|
|
239
275
|
const output = execFileSync(
|
|
240
276
|
process.execPath,
|
|
@@ -248,7 +284,7 @@ describe("registered subagent tool description", () => {
|
|
|
248
284
|
],
|
|
249
285
|
{ cwd: projectRoot, env: parentToolEnv(agentDir), encoding: "utf-8" },
|
|
250
286
|
);
|
|
251
|
-
return JSON.parse(output) as string;
|
|
287
|
+
return JSON.parse(output) as { description: string; promptGuidelines?: string[] };
|
|
252
288
|
}
|
|
253
289
|
|
|
254
290
|
function writeExtensionConfig(agentDir: string, config: Record<string, unknown>): void {
|
|
@@ -259,25 +295,40 @@ describe("registered subagent tool description", () => {
|
|
|
259
295
|
|
|
260
296
|
it("registers full, compact, custom, and fallback descriptions from extension config", () => {
|
|
261
297
|
const defaultAgentDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-default-"));
|
|
262
|
-
assert.equal(
|
|
298
|
+
assert.equal(readRegisteredTool(defaultAgentDir).description, FULL_SUBAGENT_TOOL_DESCRIPTION);
|
|
263
299
|
|
|
264
300
|
const compactAgentDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-compact-"));
|
|
265
301
|
writeExtensionConfig(compactAgentDir, { toolDescriptionMode: "compact" });
|
|
266
|
-
assert.equal(
|
|
302
|
+
assert.equal(readRegisteredTool(compactAgentDir).description, COMPACT_SUBAGENT_TOOL_DESCRIPTION);
|
|
267
303
|
|
|
268
304
|
const customAgentDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-custom-"));
|
|
269
305
|
writeExtensionConfig(customAgentDir, { toolDescriptionMode: "custom" });
|
|
270
306
|
fs.writeFileSync(path.join(customAgentDir, "subagent-tool-description.md"), "Registered custom description.", "utf-8");
|
|
271
|
-
const customDescription =
|
|
307
|
+
const customDescription = readRegisteredTool(customAgentDir).description;
|
|
272
308
|
assert.match(customDescription, /Registered custom description/);
|
|
273
309
|
assert.match(customDescription, /SAFETY-CRITICAL SUBAGENT GUIDANCE/);
|
|
274
310
|
|
|
275
311
|
const missingCustomAgentDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-missing-"));
|
|
276
312
|
writeExtensionConfig(missingCustomAgentDir, { toolDescriptionMode: "custom" });
|
|
277
|
-
assert.equal(
|
|
313
|
+
assert.equal(readRegisteredTool(missingCustomAgentDir).description, FULL_SUBAGENT_TOOL_DESCRIPTION);
|
|
278
314
|
|
|
279
315
|
const invalidAgentDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-invalid-"));
|
|
280
316
|
writeExtensionConfig(invalidAgentDir, { toolDescriptionMode: "tiny" });
|
|
281
|
-
assert.equal(
|
|
317
|
+
assert.equal(readRegisteredTool(invalidAgentDir).description, FULL_SUBAGENT_TOOL_DESCRIPTION);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it("registers parent-only routing guidance as promptGuidelines on the parent tool", () => {
|
|
321
|
+
const defaultAgentDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-tool-desc-guidelines-"));
|
|
322
|
+
const registered = readRegisteredTool(defaultAgentDir);
|
|
323
|
+
|
|
324
|
+
assert.ok(Array.isArray(registered.promptGuidelines), "parent subagent tool must expose promptGuidelines");
|
|
325
|
+
assert.equal(registered.promptGuidelines!.length, 1);
|
|
326
|
+
assert.equal(registered.promptGuidelines![0], SUBAGENT_PARENT_ROUTING_GUIDANCE);
|
|
327
|
+
assert.doesNotMatch(SUBAGENT_PARENT_ROUTING_GUIDANCE, new RegExp(BUILTIN_AGENT_NAMES.join("|")));
|
|
328
|
+
assert.match(SUBAGENT_PARENT_ROUTING_GUIDANCE, /\{ action: "list" \}/);
|
|
329
|
+
assert.match(SUBAGENT_PARENT_ROUTING_GUIDANCE, /executable entry/i);
|
|
330
|
+
assert.match(SUBAGENT_PARENT_ROUTING_GUIDANCE, /tiny targeted reads and simple answers local/i);
|
|
331
|
+
assert.match(SUBAGENT_PARENT_ROUTING_GUIDANCE, /broad local investigation, external research, and mutation\/implementation work/i);
|
|
332
|
+
assert.match(SUBAGENT_PARENT_ROUTING_GUIDANCE, /decision-maker and normally the sole writer/i);
|
|
282
333
|
});
|
|
283
334
|
});
|
|
@@ -111,8 +111,6 @@ test, YAGNI applies to tests too.
|
|
|
111
111
|
|
|
112
112
|
## Boundaries
|
|
113
113
|
|
|
114
|
-
Ponytail governs what you build, not how you talk
|
|
115
|
-
terse prose). "stop ponytail" / "normal mode": revert. Level persists until
|
|
116
|
-
changed or session end.
|
|
114
|
+
Ponytail governs what you build, not how you talk. "stop ponytail" / "normal mode": revert. Level persists until changed or session end.
|
|
117
115
|
|
|
118
116
|
The shortest path to done is the right path.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# Phase 0 Plan — Correctness Cleanup Before Delegation Changes
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
Correct stale bundled-agent documentation and impossible builtin-agent contracts without changing intended delegation policy. Keep current runtime defaults authoritative: only `architect` and `recapper` fork by default; the other four builtins are fresh-context.
|
|
6
|
+
|
|
7
|
+
## Non-goals
|
|
8
|
+
|
|
9
|
+
- Do not redesign delegation behavior, context policy, model routing, or orchestration.
|
|
10
|
+
- Do not grant `commentator` write tools.
|
|
11
|
+
- Do not make `researcher` portable by adding new extension/package dependencies.
|
|
12
|
+
- Do not alter user settings, user-home skills, `.selesai/`, `.pi-subagents/`, or unrelated dirty changes.
|
|
13
|
+
- Do not run `npm run build`: it cleans `dist/` and can destroy unrelated dirty generated artifacts.
|
|
14
|
+
|
|
15
|
+
## Review findings
|
|
16
|
+
|
|
17
|
+
- **High — stale/mangled role docs:** `src/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md:14,176-192,269` and `README.md:105-116,407` duplicate roles, omit `recapper`, and contain a false self-alias.
|
|
18
|
+
- **High — context contradiction:** `constraints-and-recipes.md:8-9,106,141` and `execution-controls.md:363,369-376` claim `builder`/`commentator` fork by default; their frontmatter declares `fresh`.
|
|
19
|
+
- **High — stale discovery paths:** `execution-controls.md:9-22` and additional README discovery/settings text describe `.pi`, although runtime discovers `.selesai` and legacy `.agents`.
|
|
20
|
+
- **Medium — impossible/unsafe role contracts:** `agents/architect.md:38` tells a child without `question` or `subagent` access to use them; `agents/builder.md:7,21` requires bridge-only `contact_supervisor`; `agents/researcher.md:4` misclassifies MCP tools as builtin tools.
|
|
21
|
+
- **Medium — output/tool-description drift:** role tables say read-only agents write output files and that `commentator` can receive edit/write tools from an explicit fix pass. Neither is true.
|
|
22
|
+
|
|
23
|
+
## Discovery and baseline preservation
|
|
24
|
+
|
|
25
|
+
1. From repository root, run:
|
|
26
|
+
```bash
|
|
27
|
+
git status --short
|
|
28
|
+
git diff --check
|
|
29
|
+
git diff -- src/extensions/pi-subagents dist/extensions/pi-subagents
|
|
30
|
+
```
|
|
31
|
+
2. Record every pre-existing dirty path and hunk. Treat them as owned by another change.
|
|
32
|
+
3. Before touching an affected `dist/extensions/pi-subagents/**` file, inspect its existing diff. If it is already dirty, manually merge only the Phase 0 documentation/agent hunk; never reset, checkout, clean, or overwrite unrelated content.
|
|
33
|
+
4. Confirm these runtime facts before editing:
|
|
34
|
+
- `src/extensions/pi-subagents/src/agents/agents.ts`: `BUILTIN_AGENT_NAMES` is exactly `architect`, `builder`, `commentator`, `explorer`, `recapper`, `researcher`; discovery uses `.selesai/agents` plus legacy `.agents`.
|
|
35
|
+
- `src/extensions/pi-subagents/agents/*.md`: only `architect` and `recapper` have `defaultContext: fork`.
|
|
36
|
+
- `src/extensions/pi-subagents/src/intercom/intercom-bridge.ts:applyIntercomBridgeToAgent`: bridge tools are appended only when the bridge is active.
|
|
37
|
+
- `src/extensions/pi-subagents/src/runs/shared/pi-args.ts:resolvePiLaunchToolPlan` and `tool-availability.ts`: `tools` is a strict allowlist and `mcp:` values become direct MCP selections.
|
|
38
|
+
|
|
39
|
+
## Files and ownership
|
|
40
|
+
|
|
41
|
+
### Source files to modify
|
|
42
|
+
|
|
43
|
+
| File | Ownership / required change |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `src/extensions/pi-subagents/agents/architect.md` | Builtin planner’s executable prompt; remove unavailable-tool instructions. |
|
|
46
|
+
| `src/extensions/pi-subagents/agents/builder.md` | Builtin writer’s declared tool contract and escalation instruction. |
|
|
47
|
+
| `src/extensions/pi-subagents/agents/researcher.md` | Builtin researcher’s MCP-tool declaration. |
|
|
48
|
+
| `src/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md` | Canonical parent-skill role routing/table guidance. |
|
|
49
|
+
| `src/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md` | Canonical default-context/workflow guidance. |
|
|
50
|
+
| `src/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md` | Canonical discovery, context, and commentator-workflow guidance. |
|
|
51
|
+
| `src/extensions/pi-subagents/README.md` | Public package documentation for builtin roles, paths, and defaults. |
|
|
52
|
+
| `src/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts` | Existing runtime-discovery test seam for builtin frontmatter. |
|
|
53
|
+
| `src/extensions/pi-subagents/test/unit/builtin-agent-documentation.test.ts` (new) | Narrow regression test for six unique builtin roles in both public role tables. |
|
|
54
|
+
|
|
55
|
+
### Generated package mirrors to synchronize
|
|
56
|
+
|
|
57
|
+
Mirror only corresponding changed source assets into:
|
|
58
|
+
|
|
59
|
+
- `dist/extensions/pi-subagents/agents/architect.md`
|
|
60
|
+
- `dist/extensions/pi-subagents/agents/builder.md`
|
|
61
|
+
- `dist/extensions/pi-subagents/agents/researcher.md`
|
|
62
|
+
- `dist/extensions/pi-subagents/README.md`
|
|
63
|
+
- `dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md`
|
|
64
|
+
- `dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md`
|
|
65
|
+
- `dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md`
|
|
66
|
+
|
|
67
|
+
Do **not** modify runtime TypeScript, user settings, skill installations, or unrelated `dist` output.
|
|
68
|
+
|
|
69
|
+
## Ordered implementation tasks
|
|
70
|
+
|
|
71
|
+
### 1. Correct impossible builtin-agent instructions
|
|
72
|
+
|
|
73
|
+
1. In `agents/architect.md`, replace the sentence that says the architect should use an explorer agent and a “questions tool.”
|
|
74
|
+
- New instruction: inspect the repository directly with its available read/search tools.
|
|
75
|
+
- For unresolved user-owned decisions, require the architect to list them explicitly in the returned plan rather than trying to ask questions or launch a child.
|
|
76
|
+
- Do not add `question`, `interview`, `subagent`, or `contact_supervisor` to architect’s allowlist.
|
|
77
|
+
|
|
78
|
+
2. In `agents/builder.md`:
|
|
79
|
+
- Remove `contact_supervisor` from the static `tools:` frontmatter list.
|
|
80
|
+
- Replace the unconditional instruction to call it with a conditional rule:
|
|
81
|
+
- when injected bridge instructions make `contact_supervisor` available, use it for unapproved decisions and wait;
|
|
82
|
+
- otherwise stop, do not guess, and report the exact blocking decision.
|
|
83
|
+
- Keep all existing core writer tools and the single-writer role unchanged.
|
|
84
|
+
|
|
85
|
+
3. In `agents/researcher.md`, prefix `grep_app_search` and `grep_app_fetch` with `mcp:` in `tools:`.
|
|
86
|
+
- Preserve `read` and `web_explore`.
|
|
87
|
+
- Do not add `extensions` or `subagentOnlyExtensions`; that would introduce a separate dependency/policy decision.
|
|
88
|
+
|
|
89
|
+
### 2. Repair role, output, capability, and specialty documentation
|
|
90
|
+
|
|
91
|
+
1. In `prompting-and-roles.md`:
|
|
92
|
+
- Change “use `explorer` or `explorer`” to one `explorer`.
|
|
93
|
+
- Replace the malformed Builtin Agents table with exactly one row for each canonical builtin:
|
|
94
|
+
`architect`, `builder`, `commentator`, `explorer`, `recapper`, `researcher`.
|
|
95
|
+
- Describe outputs as final responses/artifacts only when caller-configured output persistence is used; never claim read-only agents write project files such as `context.md`, `plan.md`, or `research.md`.
|
|
96
|
+
- Describe `commentator` as review-only and `builder` as the writer. Remove the claim that a fix pass automatically grants commentator `edit`/`write`.
|
|
97
|
+
- Include `recapper` as the fork-context handoff specialist.
|
|
98
|
+
- Replace the false strict-isolation statement with: explicit `tools` is an allowlist, but ambient extension discovery remains possible unless `extensions`, `subagentOnlyExtensions`, or a capability ceiling constrains it; naming a tool alone does not load its provider.
|
|
99
|
+
- Remove duplicate `builder` in model-tier examples; use real builtins only.
|
|
100
|
+
|
|
101
|
+
2. In `README.md`:
|
|
102
|
+
- Replace “Builtin agents in plain English” with the same six unique roles and accurate specialties.
|
|
103
|
+
- Update the rule of thumb to use `recapper` for a clean current-state handoff, rather than repeating `commentator`.
|
|
104
|
+
- Remove stale claims that `commentator` is an alias or can make small fixes, and remove obsolete researcher tool names/install guidance.
|
|
105
|
+
- Correct `.pi` project path/root references to `.selesai`, retaining `.agents` only where runtime actually supports legacy discovery.
|
|
106
|
+
- State the true context defaults: `architect` and `recapper` fork; `builder`, `commentator`, `explorer`, and `researcher` are fresh.
|
|
107
|
+
- Remove duplicate/nonexistent “lightweight builder” examples from model-tier text.
|
|
108
|
+
|
|
109
|
+
### 3. Align context and discovery references with runtime
|
|
110
|
+
|
|
111
|
+
1. In `constraints-and-recipes.md`:
|
|
112
|
+
- Replace all duplicated context-default lists with the actual six-agent split.
|
|
113
|
+
- Change builder guidance from “defaults to fork; pass fresh” to “defaults to fresh; pass fork only when inherited parent context is intentionally required.”
|
|
114
|
+
- Correct duplicate `explorer` references in Fable/clarify workflow prose.
|
|
115
|
+
- Keep explicit fresh-context review guidance unchanged.
|
|
116
|
+
|
|
117
|
+
2. In `execution-controls.md`:
|
|
118
|
+
- Replace canonical `.pi/agents` and `.pi/chains` paths with `.selesai/agents` and `.selesai/chains`.
|
|
119
|
+
- State that `.agents` is legacy agent discovery only; do not invent legacy chain discovery.
|
|
120
|
+
- Replace nearest-root `.pi` wording with `.selesai` or `.agents`.
|
|
121
|
+
- Rewrite the commentator workflow to show fresh context as the default and an explicit `context: "fork"` only when a branched advisory thread is intended.
|
|
122
|
+
- Correct builder example prose to state that builder is fresh by default and fork is explicit.
|
|
123
|
+
- Keep the bridge-injection caveat for `contact_supervisor`; it is accurate once the builder prompt becomes conditional.
|
|
124
|
+
|
|
125
|
+
### 4. Add focused regression coverage
|
|
126
|
+
|
|
127
|
+
1. Extend `agent-frontmatter.test.ts`:
|
|
128
|
+
- Replace the partial fork assertion with a complete expected map for all six builtins:
|
|
129
|
+
- `architect`, `recapper` → `fork`
|
|
130
|
+
- `builder`, `commentator`, `explorer`, `researcher` → `fresh`
|
|
131
|
+
- Assert builder’s static builtin tools do not include `contact_supervisor`.
|
|
132
|
+
- Assert researcher discovery produces:
|
|
133
|
+
- builtin tools: `read`, `web_explore`
|
|
134
|
+
- `mcpDirectTools`: `grep_app_search`, `grep_app_fetch`.
|
|
135
|
+
|
|
136
|
+
2. Add `builtin-agent-documentation.test.ts`:
|
|
137
|
+
- Read source `README.md` and `skills/pi-subagents/references/prompting-and-roles.md`.
|
|
138
|
+
- Extract the first-column agent names from each respective builtin-role table.
|
|
139
|
+
- Assert each table has exactly the six names in `BUILTIN_AGENT_NAMES`, with no duplicates and no aliases.
|
|
140
|
+
- Do not test generated `dist` here; generated-copy equality is verified in Task 5.
|
|
141
|
+
|
|
142
|
+
### 5. Synchronize package copies safely
|
|
143
|
+
|
|
144
|
+
1. After source tests pass, copy or manually merge only the listed changed source asset files into their matching `dist/extensions/pi-subagents/` paths.
|
|
145
|
+
2. Do not run root `npm run build`.
|
|
146
|
+
3. Do not run broad `npm run copy-assets` if it would overwrite pre-existing dirty generated files.
|
|
147
|
+
4. Verify every changed source asset is byte-identical to its matching `dist` copy:
|
|
148
|
+
```bash
|
|
149
|
+
cmp -s src/extensions/pi-subagents/README.md dist/extensions/pi-subagents/README.md
|
|
150
|
+
# Repeat for each changed agents/ and skills/ asset listed above.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Decisions requiring approval (do not implement in Phase 0)
|
|
154
|
+
|
|
155
|
+
1. **Change builtin context defaults rather than docs:**
|
|
156
|
+
Recommended Phase 0 action is docs-only alignment with current frontmatter/tests. Changing `builder` or `commentator` to fork would be a delegation-policy change and belongs in a later phase.
|
|
157
|
+
|
|
158
|
+
2. **Give `commentator` edit/write capability:**
|
|
159
|
+
Recommended Phase 0 action is to remove stale documentation only. If fix-pass reviewers should edit, explicitly redesign its frontmatter, acceptance semantics, single-writer guarantees, and tests later.
|
|
160
|
+
|
|
161
|
+
3. **Make researcher tool providers self-contained:**
|
|
162
|
+
Prefixing the grep.app tools as MCP tools is a correctness fix. Adding a web-agent extension path or packaging/configuring a grep.app provider is dependency/routing work and needs approval.
|
|
163
|
+
|
|
164
|
+
## Verification
|
|
165
|
+
|
|
166
|
+
### Commands
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
cd src/extensions/pi-subagents
|
|
170
|
+
node --experimental-strip-types --test \
|
|
171
|
+
test/unit/agent-frontmatter.test.ts \
|
|
172
|
+
test/unit/builtin-agent-documentation.test.ts
|
|
173
|
+
|
|
174
|
+
npm run test:unit
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
From repository root:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
git diff --check
|
|
181
|
+
git diff -- src/extensions/pi-subagents dist/extensions/pi-subagents
|
|
182
|
+
cmp -s src/extensions/pi-subagents/README.md dist/extensions/pi-subagents/README.md
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Repeat `cmp -s` for every changed mirrored asset.
|
|
186
|
+
|
|
187
|
+
### Success cases
|
|
188
|
+
|
|
189
|
+
- Discovery returns exactly six builtins with documented specialties.
|
|
190
|
+
- Only architect and recapper resolve to fork context without an explicit run context.
|
|
191
|
+
- Builder launches without requiring bridge-only tools when the bridge is inactive.
|
|
192
|
+
- Builder still receives `contact_supervisor` when the bridge is active.
|
|
193
|
+
- Researcher’s grep.app tools are parsed into `mcpDirectTools`.
|
|
194
|
+
- Both role tables list all six roles exactly once.
|
|
195
|
+
- Source and `dist` copies are identical for every changed package asset.
|
|
196
|
+
|
|
197
|
+
### Failure cases
|
|
198
|
+
|
|
199
|
+
- Missing MCP/provider registration still fails with the existing clear missing-tool diagnostic.
|
|
200
|
+
- A builder blocked without a bridge does not guess or attempt an unavailable tool.
|
|
201
|
+
- A forked run without a persisted parent session continues to fail as documented.
|
|
202
|
+
|
|
203
|
+
### Regression checks
|
|
204
|
+
|
|
205
|
+
- Explicit `context: "fresh"` and `context: "fork"` overrides retain precedence.
|
|
206
|
+
- `commentator` remains read-only.
|
|
207
|
+
- `architect`, `explorer`, `recapper`, and `researcher` remain non-writing.
|
|
208
|
+
- Legacy `.agents` agent discovery remains supported.
|
|
209
|
+
- Existing user model overrides and user-home skills remain untouched.
|
|
210
|
+
|
|
211
|
+
## Compatibility, dependencies, risks, rollback
|
|
212
|
+
|
|
213
|
+
- **Compatibility:** This preserves existing intended frontmatter behavior; only malformed tool routing and bridge-inactive builder startup are corrected.
|
|
214
|
+
- **Dependencies:** existing Node test runtime with `--experimental-strip-types`; no new npm packages.
|
|
215
|
+
- **Risks:** manually generated `dist` copies can conflict with current dirty artifacts; preserve/merge baseline hunks instead of regenerating broad output.
|
|
216
|
+
- **Rollback:** revert only the Phase 0 source, test, and matching `dist` hunks. Do not revert baseline dirty hunks recorded before work began.
|
|
217
|
+
|
|
218
|
+
```acceptance-report
|
|
219
|
+
{
|
|
220
|
+
"criteriaSatisfied": [
|
|
221
|
+
{
|
|
222
|
+
"id": "criterion-1",
|
|
223
|
+
"status": "satisfied",
|
|
224
|
+
"evidence": "Concrete findings and planned fixes identify exact source paths, generated mirror paths, severity, runtime ownership, test seams, and residual risks."
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
"changedFiles": [],
|
|
228
|
+
"testsAddedOrUpdated": [],
|
|
229
|
+
"commandsRun": [
|
|
230
|
+
{
|
|
231
|
+
"command": "read/grep inspection of recon, builtin agent markdown, runtime discovery/tool planning code, package scripts, README, skill references, and unit tests",
|
|
232
|
+
"result": "passed",
|
|
233
|
+
"summary": "Verified Phase 0 ownership, current defaults, strict tool behavior, bridge injection, test runner, and generated-asset copy mechanism."
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"command": "git status --short / git diff",
|
|
237
|
+
"result": "not-run",
|
|
238
|
+
"summary": "No shell tool is available in this planning session; the plan requires a baseline dirty-diff capture before implementation."
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"validationOutput": [
|
|
242
|
+
"BUILTIN_AGENT_NAMES contains architect, builder, commentator, explorer, recapper, and researcher.",
|
|
243
|
+
"Only architect and recapper currently declare defaultContext: fork.",
|
|
244
|
+
"Builder statically requires contact_supervisor even though the bridge appends it only when active.",
|
|
245
|
+
"Researcher currently declares grep.app tools without the parser-required mcp: prefix.",
|
|
246
|
+
"Root copy-assets copies src/extensions into dist/extensions, while root build cleans dist and is unsafe for preserving existing dirty generated output."
|
|
247
|
+
],
|
|
248
|
+
"residualRisks": [
|
|
249
|
+
"Current dirty artifacts and unrelated edits were not inspectable through git in this session; implementation must baseline and preserve them.",
|
|
250
|
+
"Researcher still depends on host MCP/web extension availability after the prefix correction.",
|
|
251
|
+
"Changing context defaults or granting commentator write capability requires separate product/architecture approval."
|
|
252
|
+
],
|
|
253
|
+
"noStagedFiles": false,
|
|
254
|
+
"diffSummary": "No implementation was performed; this artifact is an implementation-ready Phase 0 plan.",
|
|
255
|
+
"reviewFindings": [
|
|
256
|
+
"high: skills/pi-subagents/references/prompting-and-roles.md and README.md contain duplicated/missing builtin roles and false output/capability descriptions.",
|
|
257
|
+
"high: constraints-and-recipes.md and execution-controls.md contradict builtin defaultContext frontmatter.",
|
|
258
|
+
"high: execution-controls.md and README.md contain stale .pi project discovery/root claims despite .selesai runtime configuration.",
|
|
259
|
+
"medium: agents/architect.md, agents/builder.md, and agents/researcher.md contain impossible or incorrectly routed tool instructions."
|
|
260
|
+
],
|
|
261
|
+
"manualNotes": "Phase 0 is intentionally limited to correctness cleanup and synchronization. Policy-level delegation behavior changes are explicitly deferred."
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
⧉ copy assistant: /cp e225dd
|