pi-crew 0.5.2 → 0.5.6

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 (137) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/README.md +17 -1
  3. package/docs/architecture.md +2 -0
  4. package/docs/bugs/cross-session-notification-leakage.md +82 -0
  5. package/docs/coding-agent-optimization.md +268 -0
  6. package/docs/deep-review-report.md +384 -0
  7. package/docs/distillation/cybersecurity-patterns.md +294 -0
  8. package/docs/migration-v0.4-v0.5.md +208 -0
  9. package/docs/optimization-plan.md +642 -0
  10. package/docs/pi-crew-v0.5.5-audit-fix-plan.md +133 -0
  11. package/docs/pi-mono-opportunities.md +969 -0
  12. package/docs/pi-mono-review.md +291 -0
  13. package/docs/skills/REFERENCE.md +144 -0
  14. package/package.json +12 -9
  15. package/skills/artifact-analysis-loop/SKILL.md +302 -0
  16. package/skills/async-worker-recovery/SKILL.md +19 -1
  17. package/skills/child-pi-spawning/SKILL.md +19 -6
  18. package/skills/context-artifact-hygiene/SKILL.md +19 -2
  19. package/skills/delegation-patterns/SKILL.md +68 -3
  20. package/skills/detection-pipeline-design/SKILL.md +285 -0
  21. package/skills/event-log-tracing/SKILL.md +20 -6
  22. package/skills/git-master/SKILL.md +20 -6
  23. package/skills/hunting-investigation-loop/SKILL.md +401 -0
  24. package/skills/incident-playbook-construction/SKILL.md +383 -0
  25. package/skills/live-agent-lifecycle/SKILL.md +20 -6
  26. package/skills/mailbox-interactive/SKILL.md +19 -6
  27. package/skills/model-routing-context/SKILL.md +19 -1
  28. package/skills/multi-perspective-review/SKILL.md +19 -4
  29. package/skills/observability-reliability/SKILL.md +19 -2
  30. package/skills/orchestration/SKILL.md +20 -2
  31. package/skills/ownership-session-security/SKILL.md +20 -2
  32. package/skills/pi-extension-lifecycle/SKILL.md +20 -2
  33. package/skills/post-mortem/SKILL.md +7 -2
  34. package/skills/read-only-explorer/SKILL.md +20 -6
  35. package/skills/requirements-to-task-packet/SKILL.md +23 -3
  36. package/skills/resource-discovery-config/SKILL.md +20 -2
  37. package/skills/runtime-state-reader/SKILL.md +20 -2
  38. package/skills/safe-bash/SKILL.md +21 -6
  39. package/skills/scrutinize/SKILL.md +20 -2
  40. package/skills/secure-agent-orchestration-review/SKILL.md +29 -2
  41. package/skills/security-review/SKILL.md +560 -0
  42. package/skills/state-mutation-locking/SKILL.md +22 -2
  43. package/skills/systematic-debugging/SKILL.md +8 -6
  44. package/skills/threat-hypothesis-framework/SKILL.md +175 -0
  45. package/skills/ui-render-performance/SKILL.md +20 -2
  46. package/skills/verification-before-done/SKILL.md +17 -2
  47. package/skills/widget-rendering/SKILL.md +21 -6
  48. package/skills/workspace-isolation/SKILL.md +20 -6
  49. package/skills/worktree-isolation/SKILL.md +20 -6
  50. package/src/agents/agent-config.ts +40 -1
  51. package/src/benchmark/benchmark-runner.ts +45 -0
  52. package/src/benchmark/feedback-loop.ts +5 -0
  53. package/src/config/config.ts +32 -5
  54. package/src/config/role-tools.ts +82 -0
  55. package/src/config/suggestions.ts +8 -0
  56. package/src/config/types.ts +4 -0
  57. package/src/extension/async-notifier.ts +10 -1
  58. package/src/extension/crew-cleanup.ts +114 -0
  59. package/src/extension/cross-extension-rpc.ts +1 -1
  60. package/src/extension/notification-router.ts +18 -0
  61. package/src/extension/register.ts +27 -19
  62. package/src/extension/registration/subagent-tools.ts +1 -1
  63. package/src/extension/team-tool/anchor.ts +201 -0
  64. package/src/extension/team-tool/api.ts +2 -1
  65. package/src/extension/team-tool/auto-summarize.ts +154 -0
  66. package/src/extension/team-tool/run.ts +42 -7
  67. package/src/extension/team-tool.ts +44 -2
  68. package/src/hooks/registry.ts +1 -3
  69. package/src/observability/event-bus.ts +69 -0
  70. package/src/observability/event-to-metric.ts +0 -2
  71. package/src/runtime/anchor-manager.ts +473 -0
  72. package/src/runtime/async-runner.ts +8 -4
  73. package/src/runtime/auto-summarize.ts +350 -0
  74. package/src/runtime/background-runner.ts +10 -3
  75. package/src/runtime/budget-tracker.ts +354 -0
  76. package/src/runtime/chain-runner.ts +507 -0
  77. package/src/runtime/child-pi.ts +123 -35
  78. package/src/runtime/crash-recovery.ts +5 -4
  79. package/src/runtime/crew-agent-runtime.ts +1 -0
  80. package/src/runtime/custom-tools/irc-tool.ts +13 -0
  81. package/src/runtime/custom-tools/submit-result-tool.ts +3 -2
  82. package/src/runtime/delivery-coordinator.ts +10 -3
  83. package/src/runtime/dynamic-script-runner.ts +482 -0
  84. package/src/runtime/foreground-control.ts +87 -17
  85. package/src/runtime/handoff-manager.ts +589 -0
  86. package/src/runtime/hidden-handoff.ts +424 -0
  87. package/src/runtime/live-agent-manager.ts +20 -4
  88. package/src/runtime/live-session-runtime.ts +39 -4
  89. package/src/runtime/manifest-cache.ts +2 -1
  90. package/src/runtime/model-resolver.ts +16 -4
  91. package/src/runtime/phase-tracker.ts +373 -0
  92. package/src/runtime/pi-args.ts +11 -1
  93. package/src/runtime/pi-json-output.ts +31 -0
  94. package/src/runtime/pipeline-runner.ts +514 -0
  95. package/src/runtime/progress-tracker.ts +124 -0
  96. package/src/runtime/retry-runner.ts +354 -0
  97. package/src/runtime/sandbox.ts +252 -0
  98. package/src/runtime/scheduler.ts +7 -2
  99. package/src/runtime/skill-effectiveness.ts +473 -0
  100. package/src/runtime/skill-instructions.ts +37 -3
  101. package/src/runtime/subagent-manager.ts +1 -1
  102. package/src/runtime/task-graph.ts +11 -1
  103. package/src/runtime/task-runner.ts +92 -18
  104. package/src/runtime/team-runner.ts +13 -12
  105. package/src/runtime/tool-progress.ts +10 -3
  106. package/src/runtime/verification-gates.ts +367 -0
  107. package/src/schema/team-tool-schema.ts +37 -0
  108. package/src/skills/discover-skills.ts +5 -0
  109. package/src/state/active-run-registry.ts +9 -2
  110. package/src/state/contracts.ts +9 -0
  111. package/src/state/crew-init.ts +3 -3
  112. package/src/state/decision-ledger.ts +98 -55
  113. package/src/state/event-log-rotation.ts +2 -2
  114. package/src/state/event-log.ts +144 -10
  115. package/src/state/hook-instinct-bridge.ts +5 -5
  116. package/src/state/mailbox.ts +10 -0
  117. package/src/state/run-cache.ts +18 -8
  118. package/src/state/state-store.ts +3 -1
  119. package/src/state/types.ts +4 -0
  120. package/src/tools/safe-bash-extension.ts +1 -0
  121. package/src/tools/safe-bash.ts +152 -20
  122. package/src/types/new-api-types.ts +34 -0
  123. package/src/ui/agent-management-overlay.ts +5 -1
  124. package/src/ui/crew-widget.ts +29 -15
  125. package/src/ui/overlays/mailbox-detail-overlay.ts +13 -2
  126. package/src/ui/powerbar-publisher.ts +101 -7
  127. package/src/ui/tool-render.ts +15 -15
  128. package/src/ui/transcript-cache.ts +13 -0
  129. package/src/utils/bm25-search.ts +16 -8
  130. package/src/utils/env-filter.ts +8 -5
  131. package/src/utils/redaction.ts +169 -15
  132. package/src/utils/session-utils.ts +52 -0
  133. package/src/utils/sse-parser.ts +10 -1
  134. package/src/worktree/cleanup.ts +6 -1
  135. package/src/worktree/worktree-manager.ts +32 -13
  136. package/workflows/chain.workflow.md +252 -0
  137. package/workflows/pipeline.workflow.md +27 -0
@@ -0,0 +1,252 @@
1
+ # Chain Workflow - Sequential execution with context passing
2
+
3
+ **Source:** `docs/pi-boomerang-integration-plan.md`
4
+ **Syntax:** `step1 -> step2 -> step3`
5
+ **Version:** 1.0.0
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ The Chain workflow enables sequential execution of multiple teams with automatic context passing between steps. Each step receives a handoff summary from the previous step, enabling informed execution without repeating context.
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ # Simple team chain
17
+ pi team run --chain "@research -> @implement -> @review"
18
+
19
+ # With model override
20
+ pi team run --chain "@research -> @implement --model claude-opus-3 -> @review"
21
+
22
+ # With inline goals
23
+ pi team run --chain '"Research AI trends" -> "Analyze findings" -> "Write report"'
24
+
25
+ # Global model override
26
+ pi team run --chain "@step1 -> @step2 -> @step3" --global-model claude-sonnet-4
27
+
28
+ # With timeout
29
+ pi team run --chain "@step1 --timeout 60 -> @step2"
30
+
31
+ # Continue on error
32
+ pi team run --chain "@step1 -> @step2" --continue-on-error
33
+ ```
34
+
35
+ ## Chain Syntax
36
+
37
+ ### Step References
38
+
39
+ | Syntax | Type | Example |
40
+ |--------|------|---------|
41
+ | `@teamName` | Team reference | `@research` |
42
+ | `workflow:name` | Workflow reference | `workflow:build` |
43
+ | `template:name` | Template reference | `template:planning` |
44
+ | `"goal text"` | Inline goal | `"Research AI trends"` |
45
+
46
+ ### Per-Step Overrides
47
+
48
+ | Flag | Description | Example |
49
+ |------|-------------|---------|
50
+ | `--model <model>` | Override model | `--model claude-opus-3` |
51
+ | `--skill <skill>` | Override skill | `--skill coding` |
52
+ | `--thinking <mode>` | Thinking mode | `--thinking deep` |
53
+ | `--timeout <seconds>` | Step timeout | `--timeout 60` |
54
+ | `--continue-on-error` | Continue chain on failure | `--continue-on-error` |
55
+
56
+ ### Global Overrides
57
+
58
+ | Flag | Description | Example |
59
+ |------|-------------|---------|
60
+ | `--global-model <model>` | Apply to all steps | `--global-model sonnet` |
61
+ | `--global-skill <skill>` | Apply to all steps | `--global-skill writing` |
62
+ | `--global-thinking <mode>` | Apply to all steps | `--global-thinking fast` |
63
+ | `--continue-on-error` | Continue on any step failure | `--continue-on-error` |
64
+
65
+ ## Workflow Definition
66
+
67
+ ```yaml
68
+ name: chain
69
+ description: Sequential execution with context passing
70
+ syntax: "step1 -> step2 -> step3"
71
+
72
+ steps:
73
+ - id: chain_executor
74
+ role: chain-executor
75
+ task: |
76
+ Execute the chain: {chain}
77
+
78
+ Each step receives context from previous steps.
79
+ Generate handoff summary after each step.
80
+
81
+ configuration:
82
+ # Chain parser settings
83
+ parser:
84
+ stepSeparator: "->"
85
+ trimWhitespace: true
86
+ validateReferences: true
87
+
88
+ # Handoff settings
89
+ handoff:
90
+ generateBetweenSteps: true
91
+ accumulateContext: true
92
+ maxHandoffHistory: 10
93
+
94
+ # Execution settings
95
+ execution:
96
+ sequential: true
97
+ stopOnFailure: true
98
+ timeoutPerStep: 300000 # 5 minutes
99
+ ```
100
+
101
+ ## Context Passing
102
+
103
+ When running a chain:
104
+
105
+ 1. **Initial context** is passed to the first step
106
+ 2. **Handoff summary** is generated after each step completes
107
+ 3. **Chain history** is appended to context for subsequent steps
108
+
109
+ ### Handoff Summary Structure
110
+
111
+ ```typescript
112
+ interface HandoffSummary {
113
+ taskId: string;
114
+ runId: string;
115
+ timestamp: number;
116
+
117
+ task: string;
118
+ outcome: "success" | "failure" | "partial";
119
+
120
+ filesCreated: string[];
121
+ filesModified: string[];
122
+ filesDeleted: string[];
123
+
124
+ decisions: Decision[];
125
+
126
+ blockers: string[];
127
+ nextSteps: string[];
128
+
129
+ metrics: {
130
+ tokensUsed: number;
131
+ duration: number;
132
+ iterations: number;
133
+ toolsUsed: string[];
134
+ };
135
+
136
+ contextSnapshot: string;
137
+ }
138
+ ```
139
+
140
+ ### Chain History Format
141
+
142
+ ```typescript
143
+ interface ChainHistoryEntry {
144
+ step: string;
145
+ outcome: string;
146
+ filesCreated: string[];
147
+ filesModified: string[];
148
+ decisions: string[];
149
+ nextSteps: string[];
150
+ }
151
+ ```
152
+
153
+ ## Examples
154
+
155
+ ### Research → Implement → Review
156
+
157
+ ```bash
158
+ pi team run \
159
+ --team implementation \
160
+ --workflow chain \
161
+ --chain "@research:gather -> @implement:build -> @review:verify" \
162
+ --goal "Build feature X with research, implementation, and review"
163
+ ```
164
+
165
+ ### Multi-Model Pipeline
166
+
167
+ ```bash
168
+ pi team run \
169
+ --chain "@fast-research --model haiku -> @deep-analysis --model opus -> @summary --model sonnet" \
170
+ --goal "Analyze codebase and produce documentation"
171
+ ```
172
+
173
+ ### Error-Tolerant Pipeline
174
+
175
+ ```bash
176
+ pi team run \
177
+ --chain "@step1 -> @step2 -> @step3" \
178
+ --continue-on-error \
179
+ --goal "Run data pipeline with graceful degradation"
180
+ ```
181
+
182
+ ## Integration Points
183
+
184
+ ### Retry Support
185
+
186
+ Chains can be combined with retry configuration:
187
+
188
+ ```typescript
189
+ interface ChainRetryConfig {
190
+ maxAttempts: number;
191
+ summaryBetweenAttempts: boolean;
192
+ stopOnSuccess: boolean;
193
+ backoffMs?: number;
194
+ }
195
+
196
+ // Example: Retry each step up to 2 times
197
+ const config: ChainRetryConfig = {
198
+ maxAttempts: 2,
199
+ summaryBetweenAttempts: true,
200
+ stopOnSuccess: true,
201
+ backoffMs: 1000,
202
+ };
203
+ ```
204
+
205
+ ### Budget Tracking
206
+
207
+ Chain execution supports budget tracking per step:
208
+
209
+ ```bash
210
+ pi team run \
211
+ --chain "@step1 -> @step2" \
212
+ --budget-total 100000 \
213
+ --budget-warning 80000
214
+ ```
215
+
216
+ ## Event Types
217
+
218
+ | Event | Description |
219
+ |-------|-------------|
220
+ | `chain.started` | Chain execution began |
221
+ | `chain.step_completed` | Step completed successfully |
222
+ | `chain.step_failed` | Step failed |
223
+ | `chain.completed` | All steps completed |
224
+ | `chain.failed` | Chain failed |
225
+
226
+ ## Error Handling
227
+
228
+ ### Default Behavior
229
+
230
+ - Chain stops on first failure
231
+ - Handoff from failed step includes error details
232
+ - Final result includes all attempted steps
233
+
234
+ ### Continue on Error
235
+
236
+ ```bash
237
+ pi team run --chain "@step1 -> @step2" --continue-on-error
238
+ ```
239
+
240
+ - All steps execute regardless of failures
241
+ - Each step receives context from previous (even failed) steps
242
+ - Final result indicates overall success/failure
243
+
244
+ ## Related Features
245
+
246
+ - **HandoffManager** (`src/runtime/handoff-manager.ts`) - Generates structured summaries
247
+ - **RetryRunner** (`src/runtime/retry-runner.ts`) - Retry with accumulated context
248
+ - **BudgetTracker** - Token budget tracking across steps
249
+
250
+ ---
251
+
252
+ *Generated from pi-boomerang integration plan. See `docs/pi-boomerang-integration-plan.md` for full specification.*
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: pipeline
3
+ description: Multi-stage pipeline with automatic fan-out for array inputs
4
+ ---
5
+
6
+ ## Stage 1: Research
7
+ role: explorer
8
+
9
+ Perform initial research on: {goal}. Gather relevant information, identify key concepts, and provide a structured summary.
10
+
11
+ ## Stage 2: Analysis
12
+ role: analyst
13
+ dependsOn: Stage 1
14
+
15
+ Analyze the research findings from Stage 1. Identify patterns, relationships, and insights. Provide structured analysis with supporting evidence.
16
+
17
+ ## Stage 3: Synthesis
18
+ role: analyst
19
+ dependsOn: Stage 2
20
+
21
+ Synthesize the analysis into actionable recommendations. Prioritize findings and provide clear next steps.
22
+
23
+ ## Stage 4: Documentation
24
+ role: writer
25
+ dependsOn: Synthesis
26
+
27
+ Document the complete findings in a clear, well-structured format. Include executive summary, detailed findings, and recommendations.