pi-maestro-teammate 0.3.0 → 0.4.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/README.md +107 -10
- package/agents/coordinator.md +2 -0
- package/package.json +17 -9
- package/prompts/analysis-analyze-code-patterns.md +53 -0
- package/prompts/analysis-analyze-performance.md +45 -0
- package/prompts/analysis-analyze-technical-document.md +49 -0
- package/prompts/analysis-assess-security-risks.md +45 -0
- package/prompts/analysis-diagnose-bug-root-cause.md +136 -0
- package/prompts/analysis-review-architecture.md +45 -0
- package/prompts/analysis-review-code-quality.md +44 -0
- package/prompts/analysis-trace-code-execution.md +131 -0
- package/prompts/analysis.md +10 -0
- package/prompts/development-debug-runtime-issues.md +71 -0
- package/prompts/development-generate-tests.md +86 -0
- package/prompts/development-implement-component-ui.md +71 -0
- package/prompts/development-implement-feature.md +74 -0
- package/prompts/development-refactor-codebase.md +71 -0
- package/prompts/planning-breakdown-task-steps.md +46 -0
- package/prompts/planning-design-component-spec.md +44 -0
- package/prompts/planning-plan-architecture-design.md +125 -0
- package/prompts/planning-plan-migration-strategy.md +46 -0
- package/prompts/review.md +10 -0
- package/prompts/write.md +10 -0
- package/src/agents/agents.ts +39 -1
- package/src/extension/index.ts +1801 -571
- package/src/extension/schemas.ts +73 -19
- package/src/extension/structured-output.ts +48 -0
- package/src/models/model-catalog.ts +57 -0
- package/src/models/model-routing.ts +167 -0
- package/src/prompts/prompts.ts +143 -0
- package/src/runs/execution.ts +256 -100
- package/src/runs/session-handoff.ts +144 -0
- package/src/shared/types.ts +58 -24
- package/src/tui/attach-overlay.ts +529 -159
- package/src/tui/model-mapping-overlay.ts +97 -0
- package/src/tui/progress-tree.ts +99 -0
- package/src/tui/render.ts +402 -162
package/README.md
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
# pi-teammate
|
|
2
2
|
|
|
3
|
-
> Teammate dispatch tool for [Pi](https://github.com/earendil-works/pi) — unified TaskSpec with DAG variable referencing
|
|
3
|
+
> Teammate dispatch tool for [Pi](https://github.com/earendil-works/pi) — unified TaskSpec with DAG variable referencing + resident agent model
|
|
4
4
|
|
|
5
5
|
Pi extension implementing teammate dispatch with **unified TaskSpec model**. Single agent, parallel fan-out, sequential chains, and arbitrary DAGs all use the same schema — execution order is determined by `{name}` variable references between tasks.
|
|
6
6
|
|
|
7
|
+
## Automatic Model Routing
|
|
8
|
+
|
|
9
|
+
Teammate maps task phases to models authenticated in the current Pi session. Supported task types are `explore`, `analysis`, `debug`, `planning`, `development`, `review`, and `testing`.
|
|
10
|
+
|
|
11
|
+
Open the mapping overlay with `Alt+M` or `/teammate-models`. Project mappings are saved to `.pi/teammate-models.json`; global defaults can be stored in `~/.pi/agent/teammate-models.json`, with project values taking precedence.
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"version": 1,
|
|
16
|
+
"mappings": {
|
|
17
|
+
"explore": "google/gemini-2.5-pro",
|
|
18
|
+
"analysis": "openai/gpt-5",
|
|
19
|
+
"debug": "anthropic/claude-opus-4"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Precedence is task-level `model` → top-level `model` → explicit `taskType` mapping → inferred task type → agent default. Omit `model` to use routing:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"agent": "explorer",
|
|
29
|
+
"taskType": "explore",
|
|
30
|
+
"task": "FIND: auth middleware\nSCOPE: src/auth/",
|
|
31
|
+
"background": false
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
7
35
|
## Quick Start
|
|
8
36
|
|
|
9
37
|
### Single Agent
|
|
@@ -106,11 +134,48 @@ Top-level fields serve as defaults for all tasks:
|
|
|
106
134
|
|
|
107
135
|
**Protocol version gate** — v2 (default) routes results to `caller`; v1 compat routes named agents to `main`. Explicit `reply_to` always wins.
|
|
108
136
|
|
|
137
|
+
## Resident Agent Model
|
|
138
|
+
|
|
139
|
+
Agents don't exit after completing a task. Instead they enter a **sleeping** state and can be woken up for follow-up work.
|
|
140
|
+
|
|
141
|
+
### Lifecycle
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
dispatch → running → turn complete → sleeping → teammate-send → running → ...
|
|
145
|
+
↓
|
|
146
|
+
abort → terminated
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
| Status | Description |
|
|
150
|
+
|--------|-------------|
|
|
151
|
+
| `running` | Agent is actively processing a task |
|
|
152
|
+
| `sleeping` | Turn complete, process alive, waiting for `teammate-send` to wake |
|
|
153
|
+
| `completed` | Agent terminated (via abort or session shutdown) |
|
|
154
|
+
|
|
155
|
+
### How It Works
|
|
156
|
+
|
|
157
|
+
1. Agent completes its turn → `agent_end` event fires
|
|
158
|
+
2. Result is reported to the main session (background notification)
|
|
159
|
+
3. Agent enters **sleeping** state — RPC process stays alive, stdin open
|
|
160
|
+
4. `teammate-send({ to: "name", message: "new task" })` sends a `follow_up` → agent wakes up and processes the new message
|
|
161
|
+
5. `teammate-send({ to: "name", mode: "abort" })` terminates the agent
|
|
162
|
+
|
|
163
|
+
### Active Time Tracking
|
|
164
|
+
|
|
165
|
+
Time spent sleeping is excluded from the displayed duration. `sleepMs` accumulates total sleep time; displayed uptime = wall clock − sleep time.
|
|
166
|
+
|
|
167
|
+
### Agent Fallback
|
|
168
|
+
|
|
169
|
+
Any agent name works — if no `.md` definition file exists, a generic config is used:
|
|
170
|
+
- `tools`: read, grep, find, ls, bash, edit, write (+ teammate proxy tools)
|
|
171
|
+
- `systemPromptMode`: append (inherits pi default system prompt)
|
|
172
|
+
- `inheritProjectContext`: true
|
|
173
|
+
|
|
109
174
|
## TaskSpec Schema
|
|
110
175
|
|
|
111
176
|
```typescript
|
|
112
177
|
interface TaskSpec {
|
|
113
|
-
agent: string; // Agent name (matches agents/*.md
|
|
178
|
+
agent: string; // Agent name (matches agents/*.md, or any name with fallback)
|
|
114
179
|
task?: string; // Task description with {name} variable support
|
|
115
180
|
name?: string; // Identifier for referencing and teammate-send
|
|
116
181
|
model?: string; // Model override
|
|
@@ -171,16 +236,16 @@ The `chain` field is preserved for backward compatibility. It normalizes interna
|
|
|
171
236
|
|
|
172
237
|
## Flat Agent Model
|
|
173
238
|
|
|
174
|
-
All agents are managed by the root process in a single flat `activeRuns` pool, regardless of who requested the spawn. Child agents that call the teammate tool send a proxy request to the root, which spawns the new agent as a peer — not a nested subprocess.
|
|
239
|
+
All agents are managed by the root process in a single flat `activeRuns` pool, regardless of who requested the spawn. Child agents that call the teammate tool send a proxy request to the root via IPC, which spawns the new agent as a peer — not a nested subprocess.
|
|
175
240
|
|
|
176
241
|
### How It Works
|
|
177
242
|
|
|
178
243
|
```
|
|
179
244
|
coordinator calls teammate({ agent: "scout", name: "recon" })
|
|
180
|
-
│
|
|
245
|
+
│ IPC: teammate_proxy_request (process.send)
|
|
181
246
|
▼
|
|
182
247
|
Root spawns scout → registers in root's activeRuns/namedAgents
|
|
183
|
-
│ IPC: teammate_proxy_result
|
|
248
|
+
│ IPC: teammate_proxy_result (child.send)
|
|
184
249
|
▼
|
|
185
250
|
coordinator receives result
|
|
186
251
|
```
|
|
@@ -192,16 +257,18 @@ All agents are flat peers:
|
|
|
192
257
|
|
|
193
258
|
### Child Proxy Tools
|
|
194
259
|
|
|
195
|
-
|
|
196
|
-
1.
|
|
197
|
-
2. Awaits the result via
|
|
260
|
+
Every child process automatically gets proxy versions of all 4 teammate tools (injected into `--tools` whitelist regardless of agent definition). Each proxy:
|
|
261
|
+
1. Sends a `teammate_proxy_request` via Node.js IPC (`process.send()`)
|
|
262
|
+
2. Awaits the result via IPC (`process.on("message")`)
|
|
198
263
|
|
|
199
|
-
The root's
|
|
264
|
+
The root's IPC message listener (`child.on("message")`) intercepts these requests and executes them locally.
|
|
200
265
|
|
|
201
266
|
## Reliability
|
|
202
267
|
|
|
203
268
|
- **Model fallback chain** — primary model → `fallbackModels[]` from agent config → automatic retry
|
|
204
269
|
- **Flat agent pool** — all agents managed by root process; child proxy tools forward spawn requests to root; depth guard (`PI_TEAMMATE_DEPTH`) prevents runaway recursion
|
|
270
|
+
- **Resident lifecycle** — agents sleep after turn completion; process stays alive for follow-up; only killed on explicit abort or session shutdown
|
|
271
|
+
- **IPC disconnect guard** — child proxy resolves all pending requests with error on disconnect (root crash / agent abort)
|
|
205
272
|
- **Windows-safe pi resolution** — `getPiSpawnCommand()` resolves the pi binary via env override, Windows script detection, or PATH
|
|
206
273
|
- **Abort signal** — SIGTERM → 5s grace → SIGKILL
|
|
207
274
|
|
|
@@ -243,7 +310,7 @@ You are a specialized agent. Your system prompt goes here.
|
|
|
243
310
|
## Install
|
|
244
311
|
|
|
245
312
|
```bash
|
|
246
|
-
pi install npm
|
|
313
|
+
pi install npm:pi-maestro-teammate
|
|
247
314
|
# or from local path
|
|
248
315
|
pi install ./pi-teammate
|
|
249
316
|
```
|
|
@@ -262,3 +329,33 @@ pi install ./pi-teammate
|
|
|
262
329
|
## License
|
|
263
330
|
|
|
264
331
|
MIT
|
|
332
|
+
# Agent discovery
|
|
333
|
+
|
|
334
|
+
Agent Markdown files are loaded with project-over-user-over-builtin precedence:
|
|
335
|
+
|
|
336
|
+
1. nearest project `.pi/agents/*.md`
|
|
337
|
+
2. `~/.pi/agent/extensions/teammate/agents/*.md`
|
|
338
|
+
3. this npm package's bundled `agents/*.md`
|
|
339
|
+
|
|
340
|
+
Pi has no native `pi.agents` package manifest field. Builtin teammate agents are
|
|
341
|
+
resolved relative to the installed extension module, so npm, git, global and local
|
|
342
|
+
Pi package installs all use the same package-local `agents/` directory.
|
|
343
|
+
|
|
344
|
+
## Fixed prompt templates
|
|
345
|
+
|
|
346
|
+
`teammate` can load Pi-compatible Markdown prompt templates with `prompt` and
|
|
347
|
+
`promptArgs`. Discovery priority is project `.pi/prompts/*.md`, user
|
|
348
|
+
`~/.pi/agent/prompts/*.md`, then this package's `prompts/*.md`. Template syntax uses
|
|
349
|
+
Pi's `$1`, `$2`, `$@`, `$ARGUMENTS`, `${1:-default}`, and `${@:N:L}` forms. The task
|
|
350
|
+
value is `$1`; `promptArgs` start at `$2`.
|
|
351
|
+
|
|
352
|
+
```json
|
|
353
|
+
{
|
|
354
|
+
"agent": "delegate",
|
|
355
|
+
"prompt": "analysis",
|
|
356
|
+
"task": "Analyze the authentication flow",
|
|
357
|
+
"promptArgs": ["@src/auth/**/*.ts", "file:line evidence"],
|
|
358
|
+
"model": "provider/model",
|
|
359
|
+
"background": true
|
|
360
|
+
}
|
|
361
|
+
```
|
package/agents/coordinator.md
CHANGED
|
@@ -21,4 +21,6 @@ Your approach:
|
|
|
21
21
|
3. Let the execution engine resolve the dependency graph — no need to manually order
|
|
22
22
|
4. Verify results and synthesize a coherent output
|
|
23
23
|
|
|
24
|
+
After an agent completes its turn, it enters sleeping state. Use teammate-send to wake it for follow-up work. Use teammate-list to check agent status (● running / ◉ sleeping). Use teammate-send with mode "abort" to terminate an agent.
|
|
25
|
+
|
|
24
26
|
Be methodical and thorough. Document your reasoning for key decisions. If a step fails, attempt recovery before reporting failure.
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-maestro-teammate",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Pi extension
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Pi extension — teammate agent dispatch with DAG task graphs, RPC messaging, and compact TUI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pi-package",
|
|
8
|
+
"pi-extension",
|
|
8
9
|
"pi",
|
|
9
|
-
"pi-coding-agent",
|
|
10
10
|
"teammate",
|
|
11
11
|
"agents"
|
|
12
12
|
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "node --experimental-transform-types --test \"test/*.test.ts\""
|
|
15
|
+
},
|
|
13
16
|
"files": [
|
|
14
17
|
"src/**/*.ts",
|
|
15
18
|
"agents/",
|
|
19
|
+
"prompts/",
|
|
16
20
|
"README.md"
|
|
17
21
|
],
|
|
18
22
|
"pi": {
|
|
@@ -23,7 +27,8 @@
|
|
|
23
27
|
"peerDependencies": {
|
|
24
28
|
"@earendil-works/pi-agent-core": "*",
|
|
25
29
|
"@earendil-works/pi-ai": "*",
|
|
26
|
-
"@earendil-works/pi-coding-agent": "*"
|
|
30
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
31
|
+
"@earendil-works/pi-tui": "*"
|
|
27
32
|
},
|
|
28
33
|
"peerDependenciesMeta": {
|
|
29
34
|
"@earendil-works/pi-agent-core": {
|
|
@@ -34,15 +39,18 @@
|
|
|
34
39
|
},
|
|
35
40
|
"@earendil-works/pi-coding-agent": {
|
|
36
41
|
"optional": true
|
|
42
|
+
},
|
|
43
|
+
"@earendil-works/pi-tui": {
|
|
44
|
+
"optional": true
|
|
37
45
|
}
|
|
38
46
|
},
|
|
39
47
|
"dependencies": {
|
|
40
|
-
"
|
|
41
|
-
"typebox": "1.1.24"
|
|
48
|
+
"typebox": "^1.1.24"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
44
|
-
"@earendil-works/pi-agent-core": "0.
|
|
45
|
-
"@earendil-works/pi-ai": "0.
|
|
46
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
51
|
+
"@earendil-works/pi-agent-core": "0.80.3",
|
|
52
|
+
"@earendil-works/pi-ai": "0.80.3",
|
|
53
|
+
"@earendil-works/pi-coding-agent": "0.80.3",
|
|
54
|
+
"@earendil-works/pi-tui": "0.80.3"
|
|
47
55
|
}
|
|
48
56
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze implementation patterns, conventions, and anti-patterns
|
|
3
|
+
argument-hint: "<task> [context ...]"
|
|
4
|
+
---
|
|
5
|
+
## Invocation Context
|
|
6
|
+
|
|
7
|
+
Primary task:
|
|
8
|
+
|
|
9
|
+
$1
|
|
10
|
+
|
|
11
|
+
Additional context and arguments:
|
|
12
|
+
|
|
13
|
+
${@:2}
|
|
14
|
+
|
|
15
|
+
Apply the following fixed protocol to the invocation context above.
|
|
16
|
+
|
|
17
|
+
Analyze implementation patterns and code structure.
|
|
18
|
+
|
|
19
|
+
## Planning Required
|
|
20
|
+
Before providing analysis, you MUST:
|
|
21
|
+
1. Review all files in context (not just samples)
|
|
22
|
+
2. Identify patterns with file:line references
|
|
23
|
+
3. Distinguish good patterns from anti-patterns
|
|
24
|
+
4. Apply template requirements
|
|
25
|
+
|
|
26
|
+
## Core Checklist
|
|
27
|
+
- [ ] Analyze ALL files in CONTEXT
|
|
28
|
+
- [ ] Provide file:line references for each pattern
|
|
29
|
+
- [ ] Distinguish good patterns from anti-patterns
|
|
30
|
+
- [ ] Apply RULES template requirements
|
|
31
|
+
|
|
32
|
+
## REQUIRED ANALYSIS
|
|
33
|
+
1. Identify common code patterns and architectural decisions
|
|
34
|
+
2. Extract reusable utilities and shared components
|
|
35
|
+
3. Document existing conventions and coding standards
|
|
36
|
+
4. Assess pattern consistency and identify anti-patterns
|
|
37
|
+
5. Suggest improvements and optimization opportunities
|
|
38
|
+
|
|
39
|
+
## OUTPUT REQUIREMENTS
|
|
40
|
+
- Specific file:line references for all findings
|
|
41
|
+
- Code snippets demonstrating identified patterns
|
|
42
|
+
- Clear recommendations for pattern improvements
|
|
43
|
+
- Standards compliance assessment with priority levels
|
|
44
|
+
|
|
45
|
+
## Verification Checklist
|
|
46
|
+
Before finalizing output, verify:
|
|
47
|
+
- [ ] All CONTEXT files analyzed
|
|
48
|
+
- [ ] Every pattern has code reference (file:line)
|
|
49
|
+
- [ ] Anti-patterns clearly distinguished
|
|
50
|
+
- [ ] Recommendations prioritized by impact
|
|
51
|
+
|
|
52
|
+
## Output Requirements
|
|
53
|
+
Provide actionable insights with concrete implementation guidance.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze performance bottlenecks and optimization opportunities
|
|
3
|
+
argument-hint: "<task> [context ...]"
|
|
4
|
+
---
|
|
5
|
+
## Invocation Context
|
|
6
|
+
|
|
7
|
+
Primary task:
|
|
8
|
+
|
|
9
|
+
$1
|
|
10
|
+
|
|
11
|
+
Additional context and arguments:
|
|
12
|
+
|
|
13
|
+
${@:2}
|
|
14
|
+
|
|
15
|
+
Apply the following fixed protocol to the invocation context above.
|
|
16
|
+
|
|
17
|
+
Analyze performance characteristics and optimization opportunities.
|
|
18
|
+
|
|
19
|
+
## CORE CHECKLIST ⚡
|
|
20
|
+
□ Focus on measurable metrics (e.g., latency, memory, CPU usage)
|
|
21
|
+
□ Provide file:line references for all identified bottlenecks
|
|
22
|
+
□ Distinguish between algorithmic and resource-based issues
|
|
23
|
+
□ Apply RULES template requirements exactly as specified
|
|
24
|
+
|
|
25
|
+
## REQUIRED ANALYSIS
|
|
26
|
+
1. Identify performance bottlenecks and resource usage patterns
|
|
27
|
+
2. Assess algorithm efficiency and data structure choices
|
|
28
|
+
3. Evaluate caching strategies and optimization techniques
|
|
29
|
+
4. Review memory management and resource cleanup
|
|
30
|
+
5. Document performance metrics and improvement opportunities
|
|
31
|
+
|
|
32
|
+
## OUTPUT REQUIREMENTS
|
|
33
|
+
- Performance bottleneck identification with specific file:line locations
|
|
34
|
+
- Algorithm complexity analysis and optimization suggestions
|
|
35
|
+
- Caching pattern documentation and recommendations
|
|
36
|
+
- Memory usage patterns and optimization opportunities
|
|
37
|
+
- Prioritized list of performance improvements
|
|
38
|
+
|
|
39
|
+
## VERIFICATION CHECKLIST ✓
|
|
40
|
+
□ All CONTEXT files analyzed for performance characteristics
|
|
41
|
+
□ Every bottleneck is backed by a code reference (file:line)
|
|
42
|
+
□ Both algorithmic and resource-related issues are covered
|
|
43
|
+
□ Recommendations are prioritized by potential impact
|
|
44
|
+
|
|
45
|
+
Focus: Measurable performance improvements and concrete optimization strategies.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze technical documents with evidence-backed references
|
|
3
|
+
argument-hint: "<task> [context ...]"
|
|
4
|
+
---
|
|
5
|
+
## Invocation Context
|
|
6
|
+
|
|
7
|
+
Primary task:
|
|
8
|
+
|
|
9
|
+
$1
|
|
10
|
+
|
|
11
|
+
Additional context and arguments:
|
|
12
|
+
|
|
13
|
+
${@:2}
|
|
14
|
+
|
|
15
|
+
Apply the following fixed protocol to the invocation context above.
|
|
16
|
+
|
|
17
|
+
Analyze technical documents, research papers, and specifications systematically.
|
|
18
|
+
|
|
19
|
+
## CORE CHECKLIST ⚡
|
|
20
|
+
□ Plan analysis approach before reading (document type, key questions, success criteria)
|
|
21
|
+
□ Provide section/page references for all claims and findings
|
|
22
|
+
□ Distinguish facts from interpretations explicitly
|
|
23
|
+
□ Use precise, direct language - avoid persuasive wording
|
|
24
|
+
□ Apply RULES template requirements exactly as specified
|
|
25
|
+
|
|
26
|
+
## REQUIRED ANALYSIS
|
|
27
|
+
1. Document assessment: type, structure, audience, quality indicators
|
|
28
|
+
2. Content extraction: concepts, specifications, implementation details, constraints
|
|
29
|
+
3. Critical evaluation: strengths, gaps, ambiguities, clarity issues
|
|
30
|
+
4. Self-critique: verify citations, completeness, actionable recommendations
|
|
31
|
+
5. Synthesis: key takeaways, integration points, follow-up questions
|
|
32
|
+
|
|
33
|
+
## OUTPUT REQUIREMENTS
|
|
34
|
+
- Structured analysis with mandatory section/page references
|
|
35
|
+
- Evidence-based findings with specific location citations
|
|
36
|
+
- Clear separation of facts vs. interpretations
|
|
37
|
+
- Actionable recommendations tied to document content
|
|
38
|
+
- Integration points with existing project patterns
|
|
39
|
+
- Identified gaps and ambiguities with impact assessment
|
|
40
|
+
|
|
41
|
+
## VERIFICATION CHECKLIST ✓
|
|
42
|
+
□ Pre-analysis plan documented (3-5 bullet points)
|
|
43
|
+
□ All claims backed by section/page references
|
|
44
|
+
□ Self-critique completed before final output
|
|
45
|
+
□ Language is precise and direct (no persuasive adjectives)
|
|
46
|
+
□ Recommendations are specific and actionable
|
|
47
|
+
□ Output length proportional to document size
|
|
48
|
+
|
|
49
|
+
Focus: Evidence-based insights extraction with pre-planning and self-critique for technical documents.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Assess security risks, attack surfaces, and prioritized mitigations
|
|
3
|
+
argument-hint: "<task> [context ...]"
|
|
4
|
+
---
|
|
5
|
+
## Invocation Context
|
|
6
|
+
|
|
7
|
+
Primary task:
|
|
8
|
+
|
|
9
|
+
$1
|
|
10
|
+
|
|
11
|
+
Additional context and arguments:
|
|
12
|
+
|
|
13
|
+
${@:2}
|
|
14
|
+
|
|
15
|
+
Apply the following fixed protocol to the invocation context above.
|
|
16
|
+
|
|
17
|
+
Analyze security implementation and potential vulnerabilities.
|
|
18
|
+
|
|
19
|
+
## CORE CHECKLIST ⚡
|
|
20
|
+
□ Identify all data entry points and external system interfaces
|
|
21
|
+
□ Provide file:line references for all potential vulnerabilities
|
|
22
|
+
□ Classify risks by severity and type (e.g., OWASP Top 10)
|
|
23
|
+
□ Apply RULES template requirements exactly as specified
|
|
24
|
+
|
|
25
|
+
## REQUIRED ANALYSIS
|
|
26
|
+
1. Identify authentication and authorization mechanisms
|
|
27
|
+
2. Assess input validation and sanitization practices
|
|
28
|
+
3. Review data encryption and secure storage methods
|
|
29
|
+
4. Evaluate API security and access control patterns
|
|
30
|
+
5. Document security risks and compliance considerations
|
|
31
|
+
|
|
32
|
+
## OUTPUT REQUIREMENTS
|
|
33
|
+
- Security vulnerability findings with file:line references
|
|
34
|
+
- Authentication/authorization pattern documentation
|
|
35
|
+
- Input validation examples and identified gaps
|
|
36
|
+
- Encryption usage patterns and recommendations
|
|
37
|
+
- Prioritized remediation plan based on risk level
|
|
38
|
+
|
|
39
|
+
## VERIFICATION CHECKLIST ✓
|
|
40
|
+
□ All CONTEXT files analyzed for security vulnerabilities
|
|
41
|
+
□ Every finding is backed by a code reference (file:line)
|
|
42
|
+
□ Both authentication and data handling are covered
|
|
43
|
+
□ Recommendations include clear, actionable remediation steps
|
|
44
|
+
|
|
45
|
+
Focus: Identifying security gaps and providing actionable remediation steps.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Diagnose bug root causes and propose targeted read-only corrections
|
|
3
|
+
argument-hint: "<task> [context ...]"
|
|
4
|
+
---
|
|
5
|
+
## Invocation Context
|
|
6
|
+
|
|
7
|
+
Primary task:
|
|
8
|
+
|
|
9
|
+
$1
|
|
10
|
+
|
|
11
|
+
Additional context and arguments:
|
|
12
|
+
|
|
13
|
+
${@:2}
|
|
14
|
+
|
|
15
|
+
Apply the following fixed protocol to the invocation context above.
|
|
16
|
+
|
|
17
|
+
# Role & Output Requirements
|
|
18
|
+
|
|
19
|
+
**Role**: Software engineer specializing in bug diagnosis
|
|
20
|
+
**Output Format**: Diagnostic report in Chinese following the specified structure
|
|
21
|
+
**Constraints**: Do NOT write complete code files. Provide diagnostic analysis and targeted correction suggestions only.
|
|
22
|
+
|
|
23
|
+
## Core Capabilities
|
|
24
|
+
- Interpret symptoms from bug reports, stack traces, and logs
|
|
25
|
+
- Trace execution flow to identify root causes
|
|
26
|
+
- Formulate and validate hypotheses about bug origins
|
|
27
|
+
- Design targeted, low-risk corrections
|
|
28
|
+
- Analyze impact on other system components
|
|
29
|
+
|
|
30
|
+
## Analysis Process (Required)
|
|
31
|
+
**Before providing your final diagnosis, you MUST:**
|
|
32
|
+
1. Analyze symptoms and form initial hypothesis
|
|
33
|
+
2. Trace code execution to identify root cause
|
|
34
|
+
3. Design correction strategy
|
|
35
|
+
4. Assess potential impacts and risks
|
|
36
|
+
5. Present structured diagnostic report
|
|
37
|
+
|
|
38
|
+
## Objectives
|
|
39
|
+
1. Identify root cause (not just symptoms)
|
|
40
|
+
2. Propose targeted correction with justification
|
|
41
|
+
3. Assess risks and side effects
|
|
42
|
+
4. Provide verification steps
|
|
43
|
+
|
|
44
|
+
## Input
|
|
45
|
+
- Bug description (observed vs. expected behavior)
|
|
46
|
+
- Code snippets or file locations
|
|
47
|
+
- Logs, stack traces, error messages
|
|
48
|
+
- Reproduction steps (if available)
|
|
49
|
+
|
|
50
|
+
## Output Structure (Required)
|
|
51
|
+
|
|
52
|
+
Output in Chinese using this Markdown structure:
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### 0. 诊断思维链 (Diagnostic Chain-of-Thought)
|
|
57
|
+
Present your analysis process in these steps:
|
|
58
|
+
1. **症状分析**: Summarize error symptoms and technical clues
|
|
59
|
+
2. **初步假设**: Identify suspicious code areas and form initial hypothesis
|
|
60
|
+
3. **根本原因定位**: Trace execution path to pinpoint exact cause
|
|
61
|
+
4. **修复方案设计**: Design targeted, low-risk correction
|
|
62
|
+
5. **影响评估**: Assess side effects and plan verification
|
|
63
|
+
|
|
64
|
+
### **故障诊断与修复建议报告 (Bug Diagnosis & Correction Proposal)**
|
|
65
|
+
|
|
66
|
+
### **第一部分:故障分析报告 (Part 1: Fault Analysis Report)**
|
|
67
|
+
* **1.1 故障现象描述 (Bug Symptom Description):**
|
|
68
|
+
* **观察到的行为 (Observed Behavior):** [清晰、客观地转述用户报告的异常现象或日志中的错误信息。]
|
|
69
|
+
* **预期的行为 (Expected Behavior):** [描述在正常情况下,系统或功能应有的表现。]
|
|
70
|
+
* **1.2 诊断分析过程 (Diagnostic Analysis Process):**
|
|
71
|
+
* **初步假设 (Initial Hypothesis):** [陈述您根据初步信息得出的第一个猜测。例如:初步判断,问题可能出在数据解析环节,因为错误日志显示了格式不匹配。]
|
|
72
|
+
* **根本原因分析 (Root Cause Analysis - RCA):** [**这是报告的核心。** 详细阐述您的逻辑推理过程,说明您是如何从表象追踪到根源的。例如:通过检查 `data_parser.py` 的 `parse_record` 函数,发现当输入记录的某个可选字段缺失时,代码并未处理该 `None` 值,而是直接对其调用了 `strip()` 方法,从而导致了 `AttributeError`。因此,**根本原因**是:**对可能为 None 的变量在未进行空值检查的情况下直接调用了方法**。]
|
|
73
|
+
* **1.3 根本原因摘要 (Root Cause Summary):** [用一句话高度概括 bug 的根本原因。]
|
|
74
|
+
|
|
75
|
+
### **第二部分:涉及文件概览 (Part 2: Involved Files Overview)**
|
|
76
|
+
* **文件列表 (File List):** [列出定位到问题或需要修改的所有相关文件名及路径。示例: `- src/parsers/data_parser.py (根本原因所在,直接修改)`]
|
|
77
|
+
|
|
78
|
+
### **第三部分:详细修复建议 (Part 3: Detailed Correction Plan)**
|
|
79
|
+
---
|
|
80
|
+
*针对每个需要修改的文件进行描述:*
|
|
81
|
+
|
|
82
|
+
**文件: [文件路径或文件名] (File: [File path or filename])**
|
|
83
|
+
|
|
84
|
+
* **1. 定位 (Location):**
|
|
85
|
+
* [清晰说明函数、类、方法或具体的代码区域,并指出大致行号。示例: 函数 `parse_record` 内部,约第 125 行]
|
|
86
|
+
|
|
87
|
+
* **2. 相关问题代码片段 (Relevant Problematic Code Snippet):**
|
|
88
|
+
* [引用导致问题的关键原始代码行,为开发者提供直接上下文。]
|
|
89
|
+
* ```[language]
|
|
90
|
+
// value = record.get(optional_field)
|
|
91
|
+
// processed_value = value.strip() // 此处引发错误
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
* **3. 修复描述与预期逻辑 (Correction Description & Intended Logic):**
|
|
95
|
+
* **建议修复措施 (Proposed Correction):**
|
|
96
|
+
* [用清晰的中文自然语言,描述需要进行的具体修改。例如:在调用 `.strip()` 方法之前,增加一个条件判断,检查 `value` 变量是否不为 `None`。]
|
|
97
|
+
* **修复后逻辑示意 (Corrected Logic Sketch):**
|
|
98
|
+
* [使用简洁的 `diff` 风格或伪代码来直观展示修改。]
|
|
99
|
+
* **示例:**
|
|
100
|
+
```diff
|
|
101
|
+
- processed_value = value.strip()
|
|
102
|
+
+ processed_value = value.strip() if value is not None else None
|
|
103
|
+
```
|
|
104
|
+
*或使用流程图:*
|
|
105
|
+
```
|
|
106
|
+
获取 optional_field ───► [value]
|
|
107
|
+
◊─── IF (value is not None) THEN
|
|
108
|
+
│ └───► value.strip() ───► [processed_value]
|
|
109
|
+
ELSE
|
|
110
|
+
│ └─── (赋值为 None) ───► [processed_value]
|
|
111
|
+
END IF
|
|
112
|
+
... (后续逻辑使用 processed_value) ...
|
|
113
|
+
```
|
|
114
|
+
* **修复理由 (Reason for Correction):** [解释为什么这个修改能解决之前分析出的**根本原因**。例如:此修改确保了只在变量 `value` 存在时才对其进行操作,从而避免了 `AttributeError`,解决了对 None 值的非法调用问题。]
|
|
115
|
+
|
|
116
|
+
* **4. 验证建议与风险提示 (Verification Suggestions & Risk Advisory):**
|
|
117
|
+
* **验证步骤 (Verification Steps):** [提供具体的测试建议来验证修复是否成功,以及是否引入新问题。例如:1. 构造一个optional_field字段存在的测试用例,确认其能被正常处理。2. **构造一个optional_field字段缺失的测试用例,确认程序不再崩溃,且 `processed_value` 为 `None` 或默认值。**]
|
|
118
|
+
* **潜在风险与注意事项 (Potential Risks & Considerations):** [指出此修改可能带来的任何潜在副作用或需要开发者注意的地方。例如:请注意,下游消费 `processed_value` 的代码现在必须能够正确处理 `None` 值。请检查相关调用方是否已做相应处理。]
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
*(对每个需要修改的文件重复上述格式)*
|
|
122
|
+
|
|
123
|
+
## Key Requirements
|
|
124
|
+
1. **Language**: All output in Chinese
|
|
125
|
+
2. **No Code Generation**: Use diff format or pseudo-code only. Do not write complete functions or files
|
|
126
|
+
3. **Focus on Root Cause**: Analysis must be logical and evidence-based
|
|
127
|
+
4. **State Assumptions**: Clearly note any assumptions when information is incomplete
|
|
128
|
+
|
|
129
|
+
## Self-Review Checklist
|
|
130
|
+
Before providing final output, verify:
|
|
131
|
+
- [ ] Diagnostic chain reflects logical debugging process
|
|
132
|
+
- [ ] Root cause analysis is clear and evidence-based
|
|
133
|
+
- [ ] Correction directly addresses root cause (not just symptoms)
|
|
134
|
+
- [ ] Correction is minimal and targeted (not broad refactoring)
|
|
135
|
+
- [ ] Verification steps are actionable
|
|
136
|
+
- [ ] No complete code blocks generated
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review architecture, dependencies, integration points, and trade-offs
|
|
3
|
+
argument-hint: "<task> [context ...]"
|
|
4
|
+
---
|
|
5
|
+
## Invocation Context
|
|
6
|
+
|
|
7
|
+
Primary task:
|
|
8
|
+
|
|
9
|
+
$1
|
|
10
|
+
|
|
11
|
+
Additional context and arguments:
|
|
12
|
+
|
|
13
|
+
${@:2}
|
|
14
|
+
|
|
15
|
+
Apply the following fixed protocol to the invocation context above.
|
|
16
|
+
|
|
17
|
+
Analyze system architecture and design decisions.
|
|
18
|
+
|
|
19
|
+
## CORE CHECKLIST ⚡
|
|
20
|
+
□ Analyze system-wide structure, not just isolated components
|
|
21
|
+
□ Provide file:line references for key architectural elements
|
|
22
|
+
□ Distinguish between intended design and actual implementation
|
|
23
|
+
□ Apply RULES template requirements exactly as specified
|
|
24
|
+
|
|
25
|
+
## REQUIRED ANALYSIS
|
|
26
|
+
1. Identify main architectural patterns and design principles
|
|
27
|
+
2. Map module dependencies and component relationships
|
|
28
|
+
3. Assess integration points and data flow patterns
|
|
29
|
+
4. Evaluate scalability and maintainability aspects
|
|
30
|
+
5. Document architectural trade-offs and design decisions
|
|
31
|
+
|
|
32
|
+
## OUTPUT REQUIREMENTS
|
|
33
|
+
- Architectural diagrams or textual descriptions
|
|
34
|
+
- Dependency mapping with specific file references
|
|
35
|
+
- Integration point documentation with examples
|
|
36
|
+
- Scalability assessment and bottleneck identification
|
|
37
|
+
- Prioritized recommendations for architectural improvement
|
|
38
|
+
|
|
39
|
+
## VERIFICATION CHECKLIST ✓
|
|
40
|
+
□ All major components and their relationships analyzed
|
|
41
|
+
□ Key architectural decisions and trade-offs are documented
|
|
42
|
+
□ Data flow and integration points are clearly mapped
|
|
43
|
+
□ Scalability and maintainability findings are supported by evidence
|
|
44
|
+
|
|
45
|
+
Focus: High-level design patterns and system-wide architectural concerns.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review code quality across correctness, maintainability, and testing
|
|
3
|
+
argument-hint: "<task> [context ...]"
|
|
4
|
+
---
|
|
5
|
+
## Invocation Context
|
|
6
|
+
|
|
7
|
+
Primary task:
|
|
8
|
+
|
|
9
|
+
$1
|
|
10
|
+
|
|
11
|
+
Additional context and arguments:
|
|
12
|
+
|
|
13
|
+
${@:2}
|
|
14
|
+
|
|
15
|
+
Apply the following fixed protocol to the invocation context above.
|
|
16
|
+
|
|
17
|
+
Conduct comprehensive code review and quality assessment.
|
|
18
|
+
|
|
19
|
+
## CORE CHECKLIST ⚡
|
|
20
|
+
□ Review against established coding standards and conventions
|
|
21
|
+
□ Assess logic correctness, including potential edge cases
|
|
22
|
+
□ Evaluate security implications and vulnerability risks
|
|
23
|
+
□ Check for performance bottlenecks and optimization opportunities
|
|
24
|
+
|
|
25
|
+
## REQUIRED ANALYSIS
|
|
26
|
+
1. Review code against established coding standards and conventions
|
|
27
|
+
2. Assess logic correctness and potential edge cases
|
|
28
|
+
3. Evaluate security implications and vulnerability risks
|
|
29
|
+
4. Check performance characteristics and optimization opportunities
|
|
30
|
+
5. Validate test coverage and documentation completeness
|
|
31
|
+
|
|
32
|
+
## OUTPUT REQUIREMENTS
|
|
33
|
+
- Standards compliance assessment with specific violations
|
|
34
|
+
- Logic review findings with potential issue identification
|
|
35
|
+
- Security assessment with vulnerability documentation
|
|
36
|
+
- Performance review with optimization recommendations
|
|
37
|
+
|
|
38
|
+
## VERIFICATION CHECKLIST ✓
|
|
39
|
+
□ Code is assessed against established standards
|
|
40
|
+
□ Logic, including edge cases, is thoroughly reviewed
|
|
41
|
+
□ Security and performance have been evaluated
|
|
42
|
+
□ Test coverage and documentation are validated
|
|
43
|
+
|
|
44
|
+
Focus: Actionable feedback with clear improvement priorities and implementation guidance.
|