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.
- package/CHANGELOG.md +183 -0
- package/README.md +17 -1
- package/docs/architecture.md +2 -0
- package/docs/bugs/cross-session-notification-leakage.md +82 -0
- package/docs/coding-agent-optimization.md +268 -0
- package/docs/deep-review-report.md +384 -0
- package/docs/distillation/cybersecurity-patterns.md +294 -0
- package/docs/migration-v0.4-v0.5.md +208 -0
- package/docs/optimization-plan.md +642 -0
- package/docs/pi-crew-v0.5.5-audit-fix-plan.md +133 -0
- package/docs/pi-mono-opportunities.md +969 -0
- package/docs/pi-mono-review.md +291 -0
- package/docs/skills/REFERENCE.md +144 -0
- package/package.json +12 -9
- package/skills/artifact-analysis-loop/SKILL.md +302 -0
- package/skills/async-worker-recovery/SKILL.md +19 -1
- package/skills/child-pi-spawning/SKILL.md +19 -6
- package/skills/context-artifact-hygiene/SKILL.md +19 -2
- package/skills/delegation-patterns/SKILL.md +68 -3
- package/skills/detection-pipeline-design/SKILL.md +285 -0
- package/skills/event-log-tracing/SKILL.md +20 -6
- package/skills/git-master/SKILL.md +20 -6
- package/skills/hunting-investigation-loop/SKILL.md +401 -0
- package/skills/incident-playbook-construction/SKILL.md +383 -0
- package/skills/live-agent-lifecycle/SKILL.md +20 -6
- package/skills/mailbox-interactive/SKILL.md +19 -6
- package/skills/model-routing-context/SKILL.md +19 -1
- package/skills/multi-perspective-review/SKILL.md +19 -4
- package/skills/observability-reliability/SKILL.md +19 -2
- package/skills/orchestration/SKILL.md +20 -2
- package/skills/ownership-session-security/SKILL.md +20 -2
- package/skills/pi-extension-lifecycle/SKILL.md +20 -2
- package/skills/post-mortem/SKILL.md +7 -2
- package/skills/read-only-explorer/SKILL.md +20 -6
- package/skills/requirements-to-task-packet/SKILL.md +23 -3
- package/skills/resource-discovery-config/SKILL.md +20 -2
- package/skills/runtime-state-reader/SKILL.md +20 -2
- package/skills/safe-bash/SKILL.md +21 -6
- package/skills/scrutinize/SKILL.md +20 -2
- package/skills/secure-agent-orchestration-review/SKILL.md +29 -2
- package/skills/security-review/SKILL.md +560 -0
- package/skills/state-mutation-locking/SKILL.md +22 -2
- package/skills/systematic-debugging/SKILL.md +8 -6
- package/skills/threat-hypothesis-framework/SKILL.md +175 -0
- package/skills/ui-render-performance/SKILL.md +20 -2
- package/skills/verification-before-done/SKILL.md +17 -2
- package/skills/widget-rendering/SKILL.md +21 -6
- package/skills/workspace-isolation/SKILL.md +20 -6
- package/skills/worktree-isolation/SKILL.md +20 -6
- package/src/agents/agent-config.ts +40 -1
- package/src/benchmark/benchmark-runner.ts +45 -0
- package/src/benchmark/feedback-loop.ts +5 -0
- package/src/config/config.ts +32 -5
- package/src/config/role-tools.ts +82 -0
- package/src/config/suggestions.ts +8 -0
- package/src/config/types.ts +4 -0
- package/src/extension/async-notifier.ts +10 -1
- package/src/extension/crew-cleanup.ts +114 -0
- package/src/extension/cross-extension-rpc.ts +1 -1
- package/src/extension/notification-router.ts +18 -0
- package/src/extension/register.ts +27 -19
- package/src/extension/registration/subagent-tools.ts +1 -1
- package/src/extension/team-tool/anchor.ts +201 -0
- package/src/extension/team-tool/api.ts +2 -1
- package/src/extension/team-tool/auto-summarize.ts +154 -0
- package/src/extension/team-tool/run.ts +42 -7
- package/src/extension/team-tool.ts +44 -2
- package/src/hooks/registry.ts +1 -3
- package/src/observability/event-bus.ts +69 -0
- package/src/observability/event-to-metric.ts +0 -2
- package/src/runtime/anchor-manager.ts +473 -0
- package/src/runtime/async-runner.ts +8 -4
- package/src/runtime/auto-summarize.ts +350 -0
- package/src/runtime/background-runner.ts +10 -3
- package/src/runtime/budget-tracker.ts +354 -0
- package/src/runtime/chain-runner.ts +507 -0
- package/src/runtime/child-pi.ts +123 -35
- package/src/runtime/crash-recovery.ts +5 -4
- package/src/runtime/crew-agent-runtime.ts +1 -0
- package/src/runtime/custom-tools/irc-tool.ts +13 -0
- package/src/runtime/custom-tools/submit-result-tool.ts +3 -2
- package/src/runtime/delivery-coordinator.ts +10 -3
- package/src/runtime/dynamic-script-runner.ts +482 -0
- package/src/runtime/foreground-control.ts +87 -17
- package/src/runtime/handoff-manager.ts +589 -0
- package/src/runtime/hidden-handoff.ts +424 -0
- package/src/runtime/live-agent-manager.ts +20 -4
- package/src/runtime/live-session-runtime.ts +39 -4
- package/src/runtime/manifest-cache.ts +2 -1
- package/src/runtime/model-resolver.ts +16 -4
- package/src/runtime/phase-tracker.ts +373 -0
- package/src/runtime/pi-args.ts +11 -1
- package/src/runtime/pi-json-output.ts +31 -0
- package/src/runtime/pipeline-runner.ts +514 -0
- package/src/runtime/progress-tracker.ts +124 -0
- package/src/runtime/retry-runner.ts +354 -0
- package/src/runtime/sandbox.ts +252 -0
- package/src/runtime/scheduler.ts +7 -2
- package/src/runtime/skill-effectiveness.ts +473 -0
- package/src/runtime/skill-instructions.ts +37 -3
- package/src/runtime/subagent-manager.ts +1 -1
- package/src/runtime/task-graph.ts +11 -1
- package/src/runtime/task-runner.ts +92 -18
- package/src/runtime/team-runner.ts +13 -12
- package/src/runtime/tool-progress.ts +10 -3
- package/src/runtime/verification-gates.ts +367 -0
- package/src/schema/team-tool-schema.ts +37 -0
- package/src/skills/discover-skills.ts +5 -0
- package/src/state/active-run-registry.ts +9 -2
- package/src/state/contracts.ts +9 -0
- package/src/state/crew-init.ts +3 -3
- package/src/state/decision-ledger.ts +98 -55
- package/src/state/event-log-rotation.ts +2 -2
- package/src/state/event-log.ts +144 -10
- package/src/state/hook-instinct-bridge.ts +5 -5
- package/src/state/mailbox.ts +10 -0
- package/src/state/run-cache.ts +18 -8
- package/src/state/state-store.ts +3 -1
- package/src/state/types.ts +4 -0
- package/src/tools/safe-bash-extension.ts +1 -0
- package/src/tools/safe-bash.ts +152 -20
- package/src/types/new-api-types.ts +34 -0
- package/src/ui/agent-management-overlay.ts +5 -1
- package/src/ui/crew-widget.ts +29 -15
- package/src/ui/overlays/mailbox-detail-overlay.ts +13 -2
- package/src/ui/powerbar-publisher.ts +101 -7
- package/src/ui/tool-render.ts +15 -15
- package/src/ui/transcript-cache.ts +13 -0
- package/src/utils/bm25-search.ts +16 -8
- package/src/utils/env-filter.ts +8 -5
- package/src/utils/redaction.ts +169 -15
- package/src/utils/session-utils.ts +52 -0
- package/src/utils/sse-parser.ts +10 -1
- package/src/worktree/cleanup.ts +6 -1
- package/src/worktree/worktree-manager.ts +32 -13
- package/workflows/chain.workflow.md +252 -0
- 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.
|