@melihmucuk/pi-crew 1.0.13 → 1.0.15

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.
Files changed (77) hide show
  1. package/README.md +19 -18
  2. package/agents/code-reviewer.md +52 -104
  3. package/agents/oracle.md +26 -52
  4. package/agents/planner.md +7 -7
  5. package/agents/quality-reviewer.md +90 -131
  6. package/agents/scout.md +3 -2
  7. package/agents/worker.md +8 -2
  8. package/extension/agent-discovery.ts +791 -0
  9. package/extension/bootstrap-session.ts +131 -0
  10. package/extension/index.ts +63 -0
  11. package/extension/integration/register-renderers.ts +77 -0
  12. package/extension/integration/register-tools.ts +39 -0
  13. package/extension/integration/tool-presentation.ts +50 -0
  14. package/extension/integration/tools/crew-abort.ts +126 -0
  15. package/extension/integration/tools/crew-done.ts +46 -0
  16. package/extension/integration/tools/crew-list.ts +92 -0
  17. package/extension/integration/tools/crew-respond.ts +59 -0
  18. package/extension/integration/tools/crew-spawn.ts +87 -0
  19. package/extension/integration/tools/tool-deps.ts +16 -0
  20. package/extension/integration.ts +13 -0
  21. package/extension/runtime/crew-runtime.ts +426 -0
  22. package/extension/runtime/delivery-coordinator.ts +131 -0
  23. package/extension/runtime/overflow-recovery.ts +211 -0
  24. package/extension/runtime/subagent-registry.ts +78 -0
  25. package/extension/runtime/subagent-state.ts +59 -0
  26. package/extension/status-widget.ts +107 -0
  27. package/extension/subagent-messages.ts +124 -0
  28. package/extension/tool-registry.ts +19 -0
  29. package/package.json +14 -14
  30. package/prompts/pi-crew-plan.md +46 -37
  31. package/prompts/pi-crew-review.md +3 -1
  32. package/skills/pi-crew/SKILL.md +129 -0
  33. package/dist/agent-discovery.d.ts +0 -29
  34. package/dist/agent-discovery.js +0 -527
  35. package/dist/bootstrap-session.d.ts +0 -21
  36. package/dist/bootstrap-session.js +0 -74
  37. package/dist/index.d.ts +0 -2
  38. package/dist/index.js +0 -46
  39. package/dist/integration/register-command.d.ts +0 -3
  40. package/dist/integration/register-command.js +0 -51
  41. package/dist/integration/register-renderers.d.ts +0 -2
  42. package/dist/integration/register-renderers.js +0 -59
  43. package/dist/integration/register-tools.d.ts +0 -3
  44. package/dist/integration/register-tools.js +0 -25
  45. package/dist/integration/tool-presentation.d.ts +0 -27
  46. package/dist/integration/tool-presentation.js +0 -29
  47. package/dist/integration/tools/crew-abort.d.ts +0 -2
  48. package/dist/integration/tools/crew-abort.js +0 -79
  49. package/dist/integration/tools/crew-done.d.ts +0 -2
  50. package/dist/integration/tools/crew-done.js +0 -28
  51. package/dist/integration/tools/crew-list.d.ts +0 -2
  52. package/dist/integration/tools/crew-list.js +0 -74
  53. package/dist/integration/tools/crew-respond.d.ts +0 -2
  54. package/dist/integration/tools/crew-respond.js +0 -32
  55. package/dist/integration/tools/crew-spawn.d.ts +0 -2
  56. package/dist/integration/tools/crew-spawn.js +0 -48
  57. package/dist/integration/tools/tool-deps.d.ts +0 -9
  58. package/dist/integration/tools/tool-deps.js +0 -1
  59. package/dist/integration.d.ts +0 -3
  60. package/dist/integration.js +0 -8
  61. package/dist/runtime/crew-runtime.d.ts +0 -62
  62. package/dist/runtime/crew-runtime.js +0 -285
  63. package/dist/runtime/delivery-coordinator.d.ts +0 -26
  64. package/dist/runtime/delivery-coordinator.js +0 -86
  65. package/dist/runtime/overflow-recovery.d.ts +0 -3
  66. package/dist/runtime/overflow-recovery.js +0 -155
  67. package/dist/runtime/subagent-registry.d.ts +0 -14
  68. package/dist/runtime/subagent-registry.js +0 -58
  69. package/dist/runtime/subagent-state.d.ts +0 -35
  70. package/dist/runtime/subagent-state.js +0 -32
  71. package/dist/status-widget.d.ts +0 -3
  72. package/dist/status-widget.js +0 -84
  73. package/dist/subagent-messages.d.ts +0 -37
  74. package/dist/subagent-messages.js +0 -68
  75. package/dist/tool-registry.d.ts +0 -5
  76. package/dist/tool-registry.js +0 -13
  77. package/docs/architecture.md +0 -187
@@ -24,9 +24,27 @@ Determine the task from:
24
24
  - additional instructions, if provided
25
25
  - otherwise the current conversation context
26
26
 
27
- If the task is still unclear, ask the user to clarify before proceeding.
27
+ If the task is unclear or additional instructions conflict with the current conversation context in a decision-critical way, ask the user to clarify before proceeding.
28
28
 
29
- Identify any user-provided references that subagents may need, including file paths, images, documents, screenshots, or URLs. Include them explicitly in subagent tasks. Do not assume subagents can access this conversation context unless you pass it along.
29
+ Identify any user-provided references that subagents may need, including file paths, images, documents, screenshots, or URLs.
30
+
31
+ ## Shared Context Contract
32
+
33
+ Build this shared context once and pass it to every scout and to the planner:
34
+
35
+ - the user's task
36
+ - project root
37
+ - additional instructions or constraints
38
+ - relevant user-provided references as paths or URLs plus why they matter
39
+ - explicit scope boundary:
40
+ - what the task requires (in scope)
41
+ - what the task does not require (out of scope)
42
+ - scope assumptions, if any
43
+ - minimal orientation context already gathered
44
+ - relevant language, framework, dependencies, and conventions when known
45
+
46
+ Do not copy full reference contents into subagent prompts.
47
+ Do not assume subagents can access this conversation context unless you pass it along.
30
48
 
31
49
  ## Orientation Context
32
50
 
@@ -38,47 +56,38 @@ Start with:
38
56
  - key config files to identify language, framework, and dependencies
39
57
  - README or AGENTS.md if present
40
58
 
41
- If needed, do lightweight exploration to find the relevant areas:
59
+ If needed, do lightweight exploration to find the relevant areas, limited to at most 3 additional targeted directory browses or searches:
42
60
 
43
61
  - browse directories
44
62
  - read a few lines of entry points or index files
45
63
  - run targeted searches for task-related terms
46
64
 
47
- Stop once you can assign specific scout scopes. Watch for diminishing returns: if the last few files or directories you browsed produced no new insight relevant to scoping, you have enough orientation—proceed to assign scouts.
65
+ Stop once you can assign specific scout scopes, and stop earlier if you already have enough.
48
66
  Do not trace call chains, analyze implementations, or read full files.
49
67
 
50
- ### Scope Extraction
68
+ ## Scope Extraction
51
69
 
52
- Before assigning any scout tasks, extract the scope boundary from the user's task:
53
-
54
- - **What the task requires** (in scope)
55
- - **What the task does NOT require** (out of scope)
56
- - **Scope assumptions** (if any)
70
+ Before assigning any scout tasks, extract the scope boundary from the user's task.
57
71
 
58
72
  Pass this scope boundary explicitly to every scout and to the planner. This gives subagents an explicit contract to check against, rather than having them infer scope from the task description alone.
59
73
 
60
74
  ## Scout Execution
61
75
 
62
- Call `crew_list` first and verify `scout` is available.
76
+ Call `crew_list` first and verify `scout` is available. If `scout` is unavailable, tell the user and stop.
63
77
 
64
- Spawn up to 4 scouts in parallel. Each scout must have a distinct, non-overlapping focus.
78
+ Spawn scouts in parallel using this rule: one focused area means 1 scout; 2-4 independent areas means 1 scout per area; more than 4 areas means choose the 4 highest-risk areas. Each scout must have a distinct, non-overlapping focus.
65
79
 
66
- Each scout task should include:
80
+ After spawning scouts, send one brief status message to the user that scouts have been started and you are waiting for results.
81
+
82
+ Each scout task should include the shared context plus:
67
83
 
68
- - the user's task
69
- - project root
70
- - minimal orientation context already gathered
71
- - **explicit scope boundary** (what's in scope and out of scope for this scout)
72
84
  - explicit investigation scope
73
85
  - the specific information to return
74
- - any relevant user-provided references
75
86
  - explicit read-only instruction
87
+ - explicit bash restriction: do not run build, test, install, format, codegen, server start, or any command that writes files or mutates state
76
88
 
77
89
  Keep scout scopes narrow and non-overlapping. A scout that is asked to "investigate the auth system" will explore broadly. A scout that is asked to "find how login tokens are generated and which function validates them" will stay focused. Prefer the latter.
78
90
 
79
- If the task touches one area, one scout may be enough.
80
- If it spans multiple areas, split scouts by area or question.
81
-
82
91
  ## Scout Waiting and Recovery
83
92
 
84
93
  Wait for all spawned scouts to return.
@@ -86,33 +95,26 @@ Do not synthesize partial findings.
86
95
  Do not fabricate scout results.
87
96
  Do not poll repeatedly while waiting; results arrive asynchronously.
88
97
 
89
- If a scout fails or times out, retry once.
98
+ If a scout fails or times out, retry the same task once.
90
99
  If a scout returns without useful findings, reformulate the task and spawn a replacement scout.
91
- If a retried or replacement scout still fails, proceed with the findings you have and note the gap for the planner.
100
+ If a retried or replacement scout still fails or returns without useful findings, proceed with the findings you have and note the gap for the planner.
92
101
 
93
102
  ## Planner Execution
94
103
 
95
- Call `crew_list` first and verify `planner` is available.
104
+ Call `crew_list` first and verify `planner` is available. If `planner` is unavailable, tell the user and stop.
96
105
 
97
- Before spawning the planner:
106
+ Before spawning the planner, perform only mechanical cleanup. Do not add new inferences, risk analysis, or recommendations.
98
107
 
99
108
  - remove duplicate scout findings
100
109
  - drop irrelevant generic observations
101
- - drop findings outside the scope boundary (scouts sometimes drift)
110
+ - drop findings outside the scope boundary except short `Out-of-scope risk/constraint` items that may affect the plan
102
111
  - organize findings by area
103
112
  - preserve specific facts, constraints, paths, interfaces, and conflicts
104
113
  - watch for diminishing returns: if later findings repeat or add no new specifics, you have enough—proceed to the planner rather than processing further
105
114
 
106
- Spawn the planner with:
115
+ Spawn the planner with the shared context plus:
107
116
 
108
- - the user's task
109
- - additional instructions or constraints
110
- - relevant user-provided references
111
- - **explicit scope boundary** (in-scope / out-of-scope as extracted from the task)
112
117
  - processed scout findings
113
- - project root
114
- - language, framework, dependencies
115
- - relevant conventions
116
118
  - any discovery gaps
117
119
 
118
120
  The planner is interactive. It may return:
@@ -127,7 +129,9 @@ Do not rewrite subagent output that is already visible as a steering message.
127
129
 
128
130
  If the planner returns blocking questions:
129
131
  - ask the user to answer them
130
- - relay the user's response with `crew_respond`
132
+ - if the user's answer expands scope, close the planner with `crew_done` and restart the workflow with the expanded scope
133
+ - if the user's answer narrows scope, relay the response with `crew_respond`
134
+ - otherwise relay the user's response with `crew_respond`
131
135
  - wait for the next planner response
132
136
 
133
137
  If the planner returns an implementation plan:
@@ -139,9 +143,13 @@ If the planner returns no plan needed:
139
143
  - close the planner with `crew_done`
140
144
  - briefly tell the user no plan is needed and that the task can be implemented directly
141
145
 
146
+ If the user cancels planning:
147
+ - close the planner with `crew_done`
148
+ - stop
149
+
142
150
  If the user approves the plan:
143
151
  - close the planner with `crew_done`
144
- - confirm that the plan is finalized
152
+ - confirm that the plan is finalized and stop
145
153
 
146
154
  ## Language
147
155
 
@@ -149,9 +157,10 @@ Respond to the user in the same language as the user's request.
149
157
 
150
158
  ## Rules
151
159
 
160
+ - Do not modify files.
152
161
  - Do not investigate deeply yourself; delegate to scouts.
153
162
  - Do not write, modify, or finalize the plan yourself; use the planner.
154
163
  - Never answer planner questions on behalf of the user.
155
164
  - Never fabricate subagent results.
156
165
  - Always wait for explicit user approval before finalizing the plan.
157
- - Do not expand scope beyond what the user asked. If scouts return findings outside the task scope, drop them before passing to the planner.
166
+ - Do not expand scope beyond what the user asked.
@@ -75,14 +75,16 @@ Prepare one short brief for both reviewers including:
75
75
  - short summary per file or file group
76
76
  - additional user instructions
77
77
  - **explicit scope boundary**: what is being reviewed (in scope) and what is not being reviewed (out of scope). For example: "Only the auth module changes are in scope. The unrelated CSS refactor in the same PR is out of scope for this review."
78
+ - **explicit default override**: reviewers must review only the resolved scope in the brief and ignore their own default scope rules if they differ.
78
79
 
79
80
  ## Execution
80
81
 
81
82
  Spawn `code-reviewer` and `quality-reviewer` in parallel.
82
83
 
83
84
  If one reviewer is unavailable or fails to start, report that clearly and continue with the reviewer that is available.
85
+ If a successfully spawned reviewer later returns `error` or `aborted`, report that clearly in the final summary and complete the report using only the reviewer results that completed successfully.
84
86
 
85
- Do not produce a final report until all successfully spawned reviewers have returned a result.
87
+ Do not produce a final report until all successfully spawned reviewers have returned a terminal result (`done`, `error`, or `aborted`).
86
88
  Do not poll or repeatedly check active subagents while waiting; results will be delivered asynchronously.
87
89
 
88
90
  ## Findings Acceptance Gate
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: pi-crew
3
+ description: "MUST be read before using any pi-crew tool: crew_list, crew_spawn, crew_respond, crew_done, or crew_abort. Use for all subagent delegation, async result handling, interactive subagent lifecycle, anti-polling rules, and writing self-contained crew_spawn task briefs."
4
+ ---
5
+
6
+ # Pi Crew
7
+
8
+ Use this skill whenever you coordinate work with `pi-crew` tools. Its primary purpose is to standardize orchestrator behavior while teaching safe use of `crew_*` tools.
9
+
10
+ ## Core protocol
11
+
12
+ 1. Use `crew_list` to discover available subagents before each new spawn decision.
13
+ 2. Choose from the discovered subagents by their current names, descriptions, capabilities, and `interactive` flag. Do not assume any fixed subagent names exist.
14
+ 3. Spawn only when delegation creates clear value: parallel independent work, focused investigation, review, planning, or implementation that can be handled independently by a subagent.
15
+ 4. Do not spawn for tiny tasks, unclear tasks, or work whose required context cannot be summarized safely.
16
+ 5. Do not do the delegated work yourself before spawning or after spawning. Before spawning, gather only the minimum context needed to delegate; you may read enough files or output to create a self-contained task, but do not complete the investigation, review, implementation, or solution yourself. After spawning, ownership transfers to the subagent.
17
+ 6. Results arrive asynchronously as steering messages at any time. As the orchestrator, do not keep calling `crew_list` to check completion, and do not invent or predict subagent results.
18
+
19
+ ## Before spawning
20
+
21
+ Gather only enough context to write a useful task:
22
+
23
+ - user goal and agreed decisions
24
+ - relevant files, symbols, commands, errors, or entry points
25
+ - constraints and non-goals
26
+ - expected output format
27
+ - acceptance criteria
28
+ - verification command, if known
29
+
30
+ Do not fully investigate, implement, review, or solve the delegated task before spawning. That duplicates the subagent's work and creates conflicting conclusions.
31
+
32
+ The subagent cannot access your active session. It cannot see user messages, decisions already made, files you discovered, commands you ran, or conclusions you reached unless you include the necessary information in the task.
33
+
34
+ ## `crew_spawn` task template
35
+
36
+ Write the task as a self-contained brief. The subagent cannot see your current conversation or active session state unless you include the needed context.
37
+
38
+ ```md
39
+ Goal:
40
+
41
+ Context:
42
+
43
+ Relevant files / entry points:
44
+
45
+ Constraints:
46
+
47
+ Non-goals:
48
+
49
+ Acceptance criteria:
50
+
51
+ Expected output:
52
+
53
+ Verification:
54
+ ```
55
+
56
+ Omit sections only when they are genuinely irrelevant.
57
+
58
+ ## Good delegation rules
59
+
60
+ - Include absolute or repo-relative file paths when known.
61
+ - If the finding is a file, reference it by path instead of copying the file contents into the task.
62
+ - Include exact error messages or command output when they matter.
63
+ - State whether the subagent may edit files or should only report findings.
64
+ - State whether the task is exploratory, implementation, review, or verification.
65
+ - For parallel spawns, make tasks independent and non-overlapping.
66
+ - If multiple subagents may touch the same files, serialize the work instead of spawning in parallel.
67
+
68
+ ## Bad patterns
69
+
70
+ Avoid tasks like:
71
+
72
+ ```md
73
+ Fix this.
74
+ ```
75
+
76
+ ```md
77
+ Investigate the bug we discussed.
78
+ ```
79
+
80
+ ```md
81
+ Implement the plan.
82
+ ```
83
+
84
+ These rely on hidden active-session context and produce inconsistent results.
85
+
86
+ Prefer:
87
+
88
+ ```md
89
+ Goal: Investigate why `crew_done` emits duplicate result messages.
90
+ Context: Closing an interactive subagent should dispose the session without sending another result.
91
+ Relevant files: `extension/runtime/crew-runtime.ts`, `extension/integration/tools/crew-done.ts`, `AGENTS.md`.
92
+ Constraints: Do not change tool schemas. Do not edit unrelated lifecycle behavior.
93
+ Expected output: Root cause, minimal fix proposal, and verification command. Do not edit files.
94
+ ```
95
+
96
+ ## Async result handling
97
+
98
+ - After spawning, continue only with unrelated work or end the turn.
99
+ - The subagent runs asynchronously and may answer at any time via a `crew-result` steering message.
100
+ - Wait for the `crew-result` steering message before using the result.
101
+ - If more subagents are still running, wait for each relevant result before combining conclusions.
102
+ - Evaluate results against the task acceptance criteria before using them.
103
+ - If results conflict, are incomplete, or miss acceptance criteria, state that explicitly and use a follow-up or new spawn only when needed.
104
+ - Do not repeatedly call `crew_list` as an orchestrator. Call it again only for a user-requested status snapshot or to discover subagents for a new spawn decision.
105
+
106
+ ## Interactive subagents
107
+
108
+ Interactive subagents stay alive after responding.
109
+
110
+ - Use `crew_respond` to send a follow-up to a waiting interactive subagent.
111
+ - `crew_respond` is fire-and-forget: the next response arrives asynchronously as a steering message.
112
+ - Do not poll after `crew_respond`.
113
+ - Use `crew_done` when the interaction is complete.
114
+ - Do not call `crew_done` if you still need another answer from that subagent.
115
+
116
+ ## Tool safety quick rules
117
+
118
+ - `crew_list`: do use for discovery before a new spawn decision or for a user-requested status snapshot; do not use it for polling completion.
119
+ - `crew_spawn`: do send a self-contained task with constraints, non-goals, expected output, and acceptance criteria; do not rely on hidden active-session context.
120
+ - `crew_respond`: do use only for a waiting interactive subagent when another answer is needed; do not poll afterward.
121
+ - `crew_done`: do use only when a waiting interactive subagent interaction is complete; do not call it if another answer is needed.
122
+ - `crew_abort`: do use only for active subagents owned by your active session when the task is obsolete, wrong, or cancelled; do not abort unrelated work.
123
+
124
+ ## Aborting
125
+
126
+ Use `crew_abort` only for active subagents owned by your active session.
127
+
128
+ - Abort a specific subagent when its task is obsolete or wrong.
129
+ - Abort all owned subagents only when the user requests cancellation or your plan has changed so all delegated work is invalid.
@@ -1,29 +0,0 @@
1
- import type { ThinkingLevel } from "@mariozechner/pi-agent-core";
2
- import { type SupportedToolName } from "./tool-registry.js";
3
- interface ParsedModel {
4
- provider: string;
5
- modelId: string;
6
- }
7
- export interface AgentConfig {
8
- name: string;
9
- description: string;
10
- model?: string;
11
- parsedModel?: ParsedModel;
12
- thinking?: ThinkingLevel;
13
- tools?: SupportedToolName[];
14
- skills?: string[];
15
- compaction?: boolean;
16
- interactive?: boolean;
17
- systemPrompt: string;
18
- filePath: string;
19
- }
20
- export interface AgentDiscoveryWarning {
21
- filePath: string;
22
- message: string;
23
- }
24
- interface AgentDiscoveryResult {
25
- agents: AgentConfig[];
26
- warnings: AgentDiscoveryWarning[];
27
- }
28
- export declare function discoverAgents(cwd?: string): AgentDiscoveryResult;
29
- export {};