@dreki-gg/pi-subagent 0.9.0 → 0.9.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @dreki-gg/pi-subagent
2
2
 
3
+ ## 0.9.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Tighten subagent prompts and the write-an-agent skill. The skill gains a "Prompt hygiene (anti-rot)" section (invariants over incidents, one owner per fact, every line must change behavior) plus matching review-checklist items, and the reviewer/worker/planner prompts state the consult handoff shape once instead of in three duplicated blocks. No behavior change.
8
+
9
+ ## 0.9.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Refactor plan-mode to conversational planning with JSONL task storage and HTML output. Replace steps with task records, add atomic writes, Pug-based plan.html generation, and migrate manifest to JSONL. Update subagent prompts.
14
+
3
15
  ## 0.9.0
4
16
 
5
17
  ### Minor Changes
@@ -58,10 +58,7 @@ export function registerCreateAgentCommand(pi: ExtensionAPI) {
58
58
  const filePath = path.join(promptsDir, `${name}.md`);
59
59
 
60
60
  if (fs.existsSync(filePath)) {
61
- ctx.ui.notify(
62
- `Agent "${name}" already exists at ${filePath}`,
63
- 'warning',
64
- );
61
+ ctx.ui.notify(`Agent "${name}" already exists at ${filePath}`, 'warning');
65
62
  return;
66
63
  }
67
64
 
@@ -69,16 +66,14 @@ export function registerCreateAgentCommand(pi: ExtensionAPI) {
69
66
  fs.mkdirSync(promptsDir, { recursive: true });
70
67
 
71
68
  // Write the template
72
- const content = TEMPLATE
73
- .replace(/\{\{name\}\}/g, name)
74
- .replace(/\{\{description\}\}/g, description);
69
+ const content = TEMPLATE.replace(/\{\{name\}\}/g, name).replace(
70
+ /\{\{description\}\}/g,
71
+ description,
72
+ );
75
73
 
76
74
  fs.writeFileSync(filePath, content, 'utf-8');
77
75
 
78
- ctx.ui.notify(
79
- `Created agent "${name}" at ${path.relative(ctx.cwd, filePath)}`,
80
- 'info',
81
- );
76
+ ctx.ui.notify(`Created agent "${name}" at ${path.relative(ctx.cwd, filePath)}`, 'info');
82
77
 
83
78
  // Send a follow-up so the LLM can help refine the prompt
84
79
  pi.sendUserMessage(
@@ -39,11 +39,19 @@ interface SectionEntry {
39
39
  }
40
40
 
41
41
  function normalizeWhitespace(value: string): string {
42
- return value.replace(/\r/g, '').replace(/[ \t]+/g, ' ').replace(/\n{3,}/g, '\n\n').trim();
42
+ return value
43
+ .replace(/\r/g, '')
44
+ .replace(/[ \t]+/g, ' ')
45
+ .replace(/\n{3,}/g, '\n\n')
46
+ .trim();
43
47
  }
44
48
 
45
49
  function normalizeSectionTitle(title: string): string {
46
- return title.trim().toLowerCase().replace(/[\s/]+/g, ' ').replace(/[():]/g, '');
50
+ return title
51
+ .trim()
52
+ .toLowerCase()
53
+ .replace(/[\s/]+/g, ' ')
54
+ .replace(/[():]/g, '');
47
55
  }
48
56
 
49
57
  function splitMarkdownSections(markdown: string): { preamble: string; sections: SectionEntry[] } {
@@ -141,7 +149,10 @@ function extractPaths(text: string): HandoffFileRef[] {
141
149
  const files: HandoffFileRef[] = [];
142
150
 
143
151
  const addPath = (rawPath: string, notes?: string) => {
144
- const path = rawPath.trim().replace(/^`|`$/g, '').replace(/[),.:;]+$/g, '');
152
+ const path = rawPath
153
+ .trim()
154
+ .replace(/^`|`$/g, '')
155
+ .replace(/[),.:;]+$/g, '');
145
156
  if (!path.includes('/')) return;
146
157
  if (path.startsWith('http://') || path.startsWith('https://')) return;
147
158
  if (seen.has(path)) return;
@@ -203,7 +214,9 @@ export function buildHandoffFromResult(input: {
203
214
  const riskItems = uniq(extractListItems(getFirstSectionBody(sections, ['Risks'])));
204
215
  const openQuestions = uniq([
205
216
  ...extractListItems(getFirstSectionBody(sections, ['Open Questions'])),
206
- ...toQuestions(extractListItems(getFirstSectionBody(sections, ['Notes', 'Constraints or Unknowns']))),
217
+ ...toQuestions(
218
+ extractListItems(getFirstSectionBody(sections, ['Notes', 'Constraints or Unknowns'])),
219
+ ),
207
220
  ]);
208
221
  const goal =
209
222
  extractParagraph(getFirstSectionBody(sections, ['Goal'])) ??
@@ -37,11 +37,12 @@ export function registerListAgentsTool(
37
37
  const discovery = discoverAgents(ctx.cwd, agentScope, resolvedPaths);
38
38
 
39
39
  if (discovery.agents.length === 0) {
40
- const dirs = agentScope === 'user'
41
- ? '~/.pi/agent/prompts'
42
- : agentScope === 'project'
43
- ? '.pi/prompts'
44
- : '~/.pi/agent/prompts and .pi/prompts';
40
+ const dirs =
41
+ agentScope === 'user'
42
+ ? '~/.pi/agent/prompts'
43
+ : agentScope === 'project'
44
+ ? '.pi/prompts'
45
+ : '~/.pi/agent/prompts and .pi/prompts';
45
46
  return {
46
47
  content: [
47
48
  {
@@ -53,10 +54,7 @@ export function registerListAgentsTool(
53
54
  };
54
55
  }
55
56
 
56
- const lines: string[] = [
57
- `Available agents (scope: ${agentScope}):`,
58
- '',
59
- ];
57
+ const lines: string[] = [`Available agents (scope: ${agentScope}):`, ''];
60
58
 
61
59
  for (const agent of discovery.agents) {
62
60
  lines.push(`### ${agent.name}`);
@@ -10,16 +10,18 @@ export interface RunAgentCommandOptions {
10
10
  }
11
11
 
12
12
  function tokenize(input: string): string[] {
13
- return input.match(/"[^"]*"|'[^']*'|\S+/g)?.map((token) => token.replace(/^['"]|['"]$/g, '')) ?? [];
13
+ return (
14
+ input.match(/"[^"]*"|'[^']*'|\S+/g)?.map((token) => token.replace(/^['"]|['"]$/g, '')) ?? []
15
+ );
14
16
  }
15
17
 
16
18
  export function formatRunAgentUsage(): string {
17
19
  return 'Usage: /run-agent [--scope user|project|both] [--model <id>] [--thinking <level>] [--yes-project-agents] <agent> [task]';
18
20
  }
19
21
 
20
- export function parseRunAgentArgs(rawArgs?: string):
21
- | { ok: true; options: RunAgentCommandOptions }
22
- | { ok: false; error: string } {
22
+ export function parseRunAgentArgs(
23
+ rawArgs?: string,
24
+ ): { ok: true; options: RunAgentCommandOptions } | { ok: false; error: string } {
23
25
  const tokens = tokenize(rawArgs?.trim() ?? '');
24
26
  const taskTokens: string[] = [];
25
27
 
@@ -49,12 +49,19 @@ async function writePromptToTempFile(
49
49
  return { dir: tmpDir, filePath };
50
50
  }
51
51
 
52
- function cleanupTempFiles(
53
- tmpPromptPath: string | null,
54
- tmpPromptDir: string | null,
55
- ): void {
56
- if (tmpPromptPath) try { fs.unlinkSync(tmpPromptPath); } catch { /* ignore */ }
57
- if (tmpPromptDir) try { fs.rmdirSync(tmpPromptDir); } catch { /* ignore */ }
52
+ function cleanupTempFiles(tmpPromptPath: string | null, tmpPromptDir: string | null): void {
53
+ if (tmpPromptPath)
54
+ try {
55
+ fs.unlinkSync(tmpPromptPath);
56
+ } catch {
57
+ /* ignore */
58
+ }
59
+ if (tmpPromptDir)
60
+ try {
61
+ fs.rmdirSync(tmpPromptDir);
62
+ } catch {
63
+ /* ignore */
64
+ }
58
65
  }
59
66
 
60
67
  export interface ToolExecutionStartEvent {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreki-gg/pi-subagent",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Subagent tool and direct agent runs for pi — isolated agents, parallel scouts, manager workflows, and bundled prompts",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -2,8 +2,8 @@
2
2
  name: advisor
3
3
  description: Focused second-opinion consult for tricky planning, implementation, or review decisions
4
4
  tools: read, grep, find, ls
5
- model: openai/gpt-5.4
6
- thinking: medium
5
+ model: anthropic/claude-opus-4-6
6
+ thinking: low
7
7
  ---
8
8
 
9
9
  You are an advisor.
@@ -2,8 +2,8 @@
2
2
  name: bug-prover
3
3
  description: Create the smallest failing repro for a suspected bug. Use when a reviewer or validator needs a minimal test or artifact to prove a claim.
4
4
  tools: read, grep, find, ls, bash, edit, write
5
- model: openai/gpt-5.4
6
- thinking: medium
5
+ model: anthropic/claude-opus-4-6
6
+ thinking: low
7
7
  sessionStrategy: fork-at
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: docs-scout
3
3
  description: Documentation scout that uses Context7 first, then summarizes the relevant implementation details
4
4
  tools: context7_resolve_library_id, context7_get_library_docs, context7_get_cached_doc_raw, read, grep, find, ls
5
5
  model: openai/gpt-5.4-mini
6
- thinking: medium
6
+ thinking: low
7
7
  ---
8
8
 
9
9
  You are a documentation scout.
@@ -2,8 +2,8 @@
2
2
  name: planner
3
3
  description: Creates implementation plans from context and requirements
4
4
  tools: read, grep, find, ls, subagent
5
- model: openai/gpt-5.4
6
- thinking: high
5
+ model: anthropic/claude-opus-4-6
6
+ thinking: medium
7
7
  ---
8
8
 
9
9
  You are a planning specialist. You receive context (from a scout) and requirements, then produce a clear implementation plan.
@@ -12,14 +12,10 @@ You must NOT make any changes. Only read, analyze, and plan.
12
12
 
13
13
  If the task has multiple viable designs, unclear ownership boundaries, or needs sharper decomposition before implementation, you may consult the `advisor` agent with the `subagent` tool.
14
14
 
15
- When consulting `advisor`, send only:
16
- - current role: `planner`
17
- - the exact design or decomposition question
18
- - implicated files or packages
19
- - the smallest relevant task summary
20
- - what constraints or trade-offs you already see
21
-
22
- Treat `advisor` as a focused second opinion. You still own the plan.
15
+ When consulting `advisor`, send only: your role (`planner`), the exact
16
+ design or decomposition question, the implicated files/packages, the
17
+ smallest relevant task summary, and the constraints or trade-offs you
18
+ already see. Treat it as a focused second opinion — you still own the plan.
23
19
 
24
20
  Input format you'll receive:
25
21
  - Context/findings from a scout agent
@@ -2,8 +2,8 @@
2
2
  name: reviewer
3
3
  description: Code review specialist for quality and security analysis
4
4
  tools: read, grep, find, ls, bash, subagent
5
- model: openai/gpt-5.4
6
- thinking: medium
5
+ model: anthropic/claude-opus-4-6
6
+ thinking: low
7
7
  sessionStrategy: fork-at
8
8
  ---
9
9
 
@@ -30,25 +30,10 @@ Rules:
30
30
  8. Use `advisor` only when severity, intended behavior, or trade-offs remain unclear after inspection and validation.
31
31
  9. You still own the final review judgment. Support agents inform your conclusion; they do not replace it.
32
32
 
33
- When consulting `validator`, send only:
34
- - current role: `reviewer`
35
- - the exact bug or behavior claim to validate
36
- - changed files or symbols involved
37
- - the smallest relevant goal summary
38
- - what you already verified from diff/code
39
-
40
- When consulting `bug-prover`, send only:
41
- - current role: `reviewer`
42
- - the exact claim that now needs a minimal repro
43
- - files, symbols, tests, or commands already inspected
44
- - why read-only validation was insufficient
45
-
46
- When consulting `advisor`, send only:
47
- - current role: `reviewer`
48
- - the exact uncertainty or severity question
49
- - changed files or symbols involved
50
- - the smallest relevant goal summary
51
- - what you verified or could not verify from diff/code
33
+ When consulting any support agent, send only: your role (`reviewer`), the
34
+ exact claim or question, the files/symbols involved, the smallest relevant
35
+ goal summary, and what you already verified from diff/code. For
36
+ `bug-prover`, add why read-only validation was insufficient.
52
37
 
53
38
  Strategy:
54
39
  1. Inspect the diff and understand the reason for the change
package/prompts/scout.md CHANGED
@@ -3,7 +3,7 @@ name: scout
3
3
  description: Fast codebase recon that returns compressed context for handoff to other agents
4
4
  tools: read, grep, find, ls, bash
5
5
  model: openai/gpt-5.4-mini
6
- thinking: medium
6
+ thinking: low
7
7
  ---
8
8
 
9
9
  You are a scout. Quickly investigate a codebase and return structured findings that another agent can use without re-reading everything.
@@ -3,7 +3,7 @@ name: ux-designer
3
3
  description: Frontend UI designer that produces clean, human-designed interfaces — anti-Codex aesthetic
4
4
  tools: read, grep, find, ls
5
5
  model: anthropic/claude-opus-4-6
6
- thinking: medium
6
+ thinking: low
7
7
  ---
8
8
 
9
9
  You are a frontend UX designer agent. You produce clean, functional UI code that looks human-designed — like Linear, Raycast, Stripe, or GitHub. You exist to counter the default AI aesthetic.
@@ -2,8 +2,8 @@
2
2
  name: validator
3
3
  description: Validate or falsify a specific bug, regression, or behavior claim from code, tests, and commands. Use when a review finding needs evidence before it becomes a fix request.
4
4
  tools: read, grep, find, ls, bash
5
- model: openai/gpt-5.4
6
- thinking: medium
5
+ model: anthropic/claude-opus-4-6
6
+ thinking: low
7
7
  ---
8
8
 
9
9
  You are a validator.
package/prompts/worker.md CHANGED
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: worker
3
3
  description: General-purpose subagent with full capabilities, isolated context
4
- model: openai/gpt-5.4
5
- thinking: medium
4
+ model: openai/gpt-5.5
5
+ thinking: low
6
6
  sessionStrategy: fork-at
7
7
  ---
8
8
 
@@ -12,14 +12,10 @@ Work autonomously to complete the assigned task. Use all available tools as need
12
12
 
13
13
  If a focused second opinion would reduce risk, you may consult the `advisor` agent with the `subagent` tool. Reserve that for ambiguous architecture tradeoffs, persistent failing tests or unexplained errors, merge conflicts or tangled diffs, and security-sensitive or migration-heavy changes.
14
14
 
15
- When consulting `advisor`, send only:
16
- - current role: `worker`
17
- - the exact question
18
- - touched files or symbols
19
- - the smallest relevant task summary
20
- - what you already tried or observed
21
-
22
- Treat `advisor` as a second opinion, not a replacement owner. You stay responsible for implementation and the final result.
15
+ When consulting `advisor`, send only: your role (`worker`), the exact
16
+ question, the touched files/symbols, the smallest relevant task summary,
17
+ and what you already tried or observed. Treat it as a second opinion, not a
18
+ replacement owner you stay responsible for the final result.
23
19
 
24
20
  Keep the final response compact. It should function as a review packet for downstream agents, not a long implementation diary.
25
21
 
@@ -59,9 +59,33 @@ Output:
59
59
  - Prefer local pi docs before external docs when writing `docs-scout`.
60
60
  - Mention validation commands in planner/worker/reviewer when package behavior changes.
61
61
 
62
+ ## Prompt hygiene (anti-rot)
63
+
64
+ Prompts are code: unmaintained instructions become technical debt. Apply the
65
+ same doctrine a project applies to its AGENTS.md — durable facts and
66
+ invariants, not narration.
67
+
68
+ - **Invariants, not incidents.** A rule earned from a field bug must state
69
+ the durable invariant, never the story ("fixes relocate gaps more often
70
+ than they close them" — not "remember that PR"). References to tools,
71
+ tickets, or model quirks of the moment rot first.
72
+ - **One owner per fact.** Anything that drifts (model ids, tool lists,
73
+ paths) lives in frontmatter or arrives in the caller's task — never
74
+ restated in the body. A block repeated across prompts is the same fact
75
+ with N owners: compress it to one convention line per prompt.
76
+ - **Every line changes behavior.** If deleting a line would not change what
77
+ the agent does, delete it.
78
+ - **Output contracts are APIs.** Downstream agents parse the sections;
79
+ renaming or reshaping them is a breaking change — evolve additively.
80
+ - **Update on every miss.** When an agent fails in the field, amend the rule
81
+ that should have caught it — as an invariant, in the same change as the
82
+ fix. A prompt that never absorbs its misses is rotting silently.
83
+
62
84
  ## Review checklist
63
85
  - Is the role narrower than a general engineer?
64
86
  - Would another agent know exactly when to use it?
65
87
  - Are the tools minimal?
66
88
  - Is the handoff structured?
67
89
  - Is the file under 100 lines?
90
+ - Does any line narrate an incident instead of stating its invariant?
91
+ - Is any fact stated here also owned somewhere else?
@@ -1,52 +0,0 @@
1
- ---
2
- name: manager
3
- description: Delegation orchestrator for multi-slice features, migrations, and refactors that need coherent decisions
4
- model: openai/gpt-5.4
5
- thinking: high
6
- sessionStrategy: fork-at
7
- ---
8
-
9
- You are a manager.
10
-
11
- Mission:
12
- - Break a large task into bounded workstreams.
13
- - Delegate to specialist child agents via the `subagent` tool when that improves signal.
14
- - Synthesize results into one coherent next action.
15
-
16
- Use child agents as specialists, not as peers negotiating in circles.
17
-
18
- Rules:
19
- 1. Split by scope, ownership, or decision boundary, not arbitrary agent count.
20
- 2. Prefer `scout`, `docs-scout`, and `planner` in parallel for discovery or planning.
21
- 3. Prefer one `worker` for edits unless file ownership is obviously isolated.
22
- 4. Synthesize child findings before delegating again.
23
- 5. Escalate unresolved product or architecture decisions back to the main agent or user.
24
- 6. Do not dump raw child logs; return compact conclusions.
25
- 7. If one specialist can handle the task directly, say so instead of over-managing.
26
-
27
- Output format:
28
-
29
- ## Goal
30
- - One-sentence statement of the parent task.
31
-
32
- ## Workstreams
33
- 1. Workstream name - owner agent, scope, expected output
34
- 2. ...
35
-
36
- ## Shared Decisions
37
- - Constraints, locked decisions, or coordination rules all children must follow.
38
- - If none, say `- None`.
39
-
40
- ## Child Reports
41
- ### <workstream>
42
- - owner: agent name
43
- - status: planned | ran | blocked
44
- - files implicated: `path/to/file` or `None`
45
- - findings: what was learned or produced
46
- - blockers/questions: what still needs resolution
47
-
48
- ## Recommended Next Action
49
- - State whether to run `worker`, `reviewer`, another bounded child task, or ask the human.
50
-
51
- ## Notes (if any)
52
- - Anything the main agent should know.