mindforge-cc 11.5.1 → 11.7.0
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/.agent/mindforge/skill-tdd.md +53 -0
- package/.agent/mindforge/skills-index.md +118 -0
- package/.agent/mindforge/systematic-debug.md +60 -0
- package/.agent/mindforge/wf-catalog.md +37 -0
- package/.agent/mindforge/wf-code-audit.md +31 -0
- package/.agent/mindforge/wf-competitive-analysis.md +31 -0
- package/.agent/mindforge/wf-deep-research.md +32 -0
- package/.agent/mindforge/wf-feature-planner.md +31 -0
- package/.agent/mindforge/wf-incident-response.md +31 -0
- package/.agent/mindforge/wf-onboard-codebase.md +31 -0
- package/.agent/mindforge/wf-perf-optimize.md +31 -0
- package/.agent/mindforge/wf-pr-review.md +31 -0
- package/.agent/mindforge/wf-refactor-plan.md +31 -0
- package/.agent/mindforge/wf-release-prep.md +31 -0
- package/.agent/mindforge/wf-tdd-sprint.md +31 -0
- package/.agent/mindforge/wf-tech-evaluation.md +31 -0
- package/.agent/skills/1password-skill/SKILL.md +156 -0
- package/.agent/skills/1password-skill/references/cli-examples.md +31 -0
- package/.agent/skills/1password-skill/references/get-started.md +21 -0
- package/.agent/skills/article-illustrator/SKILL.md +199 -0
- package/.agent/skills/article-illustrator/references/prompt-construction.md +426 -0
- package/.agent/skills/article-illustrator/references/style-presets.md +80 -0
- package/.agent/skills/article-illustrator/references/styles.md +224 -0
- package/.agent/skills/article-illustrator/references/usage.md +50 -0
- package/.agent/skills/article-illustrator/references/workflow.md +332 -0
- package/.agent/skills/arxiv/SKILL.md +275 -0
- package/.agent/skills/blogwatcher/SKILL.md +130 -0
- package/.agent/skills/code-wiki/SKILL.md +438 -0
- package/.agent/skills/code-wiki/templates/README.md +31 -0
- package/.agent/skills/code-wiki/templates/architecture.md +30 -0
- package/.agent/skills/code-wiki/templates/getting-started.md +47 -0
- package/.agent/skills/code-wiki/templates/module.md +38 -0
- package/.agent/skills/codebase-inspection/SKILL.md +109 -0
- package/.agent/skills/comic-creator/SKILL.md +240 -0
- package/.agent/skills/comic-creator/references/analysis-framework.md +176 -0
- package/.agent/skills/comic-creator/references/auto-selection.md +71 -0
- package/.agent/skills/comic-creator/references/base-prompt.md +98 -0
- package/.agent/skills/comic-creator/references/character-template.md +180 -0
- package/.agent/skills/comic-creator/references/ohmsha-guide.md +85 -0
- package/.agent/skills/comic-creator/references/partial-workflows.md +106 -0
- package/.agent/skills/comic-creator/references/storyboard-template.md +143 -0
- package/.agent/skills/comic-creator/references/workflow.md +401 -0
- package/.agent/skills/concept-diagrams/SKILL.md +355 -0
- package/.agent/skills/concept-diagrams/references/dashboard-patterns.md +43 -0
- package/.agent/skills/concept-diagrams/references/infrastructure-patterns.md +144 -0
- package/.agent/skills/concept-diagrams/references/physical-shape-cookbook.md +42 -0
- package/.agent/skills/creative-ideation/SKILL.md +144 -0
- package/.agent/skills/creative-ideation/references/full-prompt-library.md +110 -0
- package/.agent/skills/devops-cli/SKILL.md +149 -0
- package/.agent/skills/devops-cli/references/app-discovery.md +112 -0
- package/.agent/skills/devops-cli/references/authentication.md +59 -0
- package/.agent/skills/devops-cli/references/cli-reference.md +104 -0
- package/.agent/skills/devops-cli/references/running-apps.md +171 -0
- package/.agent/skills/devops-watchers/SKILL.md +103 -0
- package/.agent/skills/docker-management/SKILL.md +273 -0
- package/.agent/skills/domain-intel/SKILL.md +96 -0
- package/.agent/skills/duckduckgo-search/SKILL.md +230 -0
- package/.agent/skills/github-auth/SKILL.md +240 -0
- package/.agent/skills/github-code-review/SKILL.md +474 -0
- package/.agent/skills/github-code-review/references/review-output-template.md +74 -0
- package/.agent/skills/github-issues/SKILL.md +363 -0
- package/.agent/skills/github-issues/templates/bug-report.md +35 -0
- package/.agent/skills/github-issues/templates/feature-request.md +31 -0
- package/.agent/skills/github-pr-workflow/SKILL.md +360 -0
- package/.agent/skills/github-pr-workflow/references/ci-troubleshooting.md +183 -0
- package/.agent/skills/github-pr-workflow/references/conventional-commits.md +71 -0
- package/.agent/skills/github-pr-workflow/templates/pr-body-bugfix.md +35 -0
- package/.agent/skills/github-pr-workflow/templates/pr-body-feature.md +33 -0
- package/.agent/skills/github-repo-management/SKILL.md +509 -0
- package/.agent/skills/github-repo-management/references/github-api-cheatsheet.md +161 -0
- package/.agent/skills/godmode/SKILL.md +396 -0
- package/.agent/skills/godmode/references/jailbreak-templates.md +128 -0
- package/.agent/skills/godmode/references/refusal-detection.md +142 -0
- package/.agent/skills/hyperframes/SKILL.md +182 -0
- package/.agent/skills/hyperframes/references/cli.md +185 -0
- package/.agent/skills/hyperframes/references/composition.md +129 -0
- package/.agent/skills/hyperframes/references/features.md +289 -0
- package/.agent/skills/hyperframes/references/gsap.md +136 -0
- package/.agent/skills/hyperframes/references/troubleshooting.md +137 -0
- package/.agent/skills/hyperframes/references/website-to-video.md +145 -0
- package/.agent/skills/jupyter-live-kernel/SKILL.md +160 -0
- package/.agent/skills/kanban-orchestrator/SKILL.md +209 -0
- package/.agent/skills/kanban-worker/SKILL.md +188 -0
- package/.agent/skills/llm-wiki/SKILL.md +499 -0
- package/.agent/skills/meme-generation/SKILL.md +122 -0
- package/.agent/skills/node-inspect-debugger/SKILL.md +312 -0
- package/.agent/skills/obsidian/SKILL.md +60 -0
- package/.agent/skills/osint-investigation/SKILL.md +269 -0
- package/.agent/skills/osint-investigation/templates/source-template.md +59 -0
- package/.agent/skills/oss-forensics/SKILL.md +422 -0
- package/.agent/skills/oss-forensics/references/evidence-types.md +89 -0
- package/.agent/skills/oss-forensics/references/github-archive-guide.md +184 -0
- package/.agent/skills/oss-forensics/references/investigation-templates.md +131 -0
- package/.agent/skills/oss-forensics/references/recovery-techniques.md +164 -0
- package/.agent/skills/oss-forensics/templates/forensic-report.md +151 -0
- package/.agent/skills/oss-forensics/templates/malicious-package-report.md +43 -0
- package/.agent/skills/parallel-cli/SKILL.md +384 -0
- package/.agent/skills/pinggy-tunnel/SKILL.md +302 -0
- package/.agent/skills/pixel-art/SKILL.md +209 -0
- package/.agent/skills/pixel-art/references/palettes.md +49 -0
- package/.agent/skills/plan/SKILL.md +331 -0
- package/.agent/skills/polymarket/SKILL.md +75 -0
- package/.agent/skills/polymarket/references/api-endpoints.md +220 -0
- package/.agent/skills/python-debugpy/SKILL.md +368 -0
- package/.agent/skills/requesting-code-review/SKILL.md +273 -0
- package/.agent/skills/research-paper-writing/SKILL.md +2367 -0
- package/.agent/skills/research-paper-writing/references/autoreason-methodology.md +394 -0
- package/.agent/skills/research-paper-writing/references/checklists.md +434 -0
- package/.agent/skills/research-paper-writing/references/citation-workflow.md +563 -0
- package/.agent/skills/research-paper-writing/references/experiment-patterns.md +728 -0
- package/.agent/skills/research-paper-writing/references/human-evaluation.md +476 -0
- package/.agent/skills/research-paper-writing/references/paper-types.md +481 -0
- package/.agent/skills/research-paper-writing/references/reviewer-guidelines.md +433 -0
- package/.agent/skills/research-paper-writing/references/sources.md +191 -0
- package/.agent/skills/research-paper-writing/references/writing-guide.md +474 -0
- package/.agent/skills/research-paper-writing/templates/README.md +251 -0
- package/.agent/skills/rest-graphql-debug/SKILL.md +507 -0
- package/.agent/skills/s6-container-supervision/SKILL.md +171 -0
- package/.agent/skills/scrapling/SKILL.md +328 -0
- package/.agent/skills/sherlock/SKILL.md +186 -0
- package/.agent/skills/simplify-code/SKILL.md +168 -0
- package/.agent/skills/skill-authoring/SKILL.md +158 -0
- package/.agent/skills/spike/SKILL.md +190 -0
- package/.agent/skills/subagent-driven-development/SKILL.md +345 -0
- package/.agent/skills/subagent-driven-development/references/context-budget-discipline.md +53 -0
- package/.agent/skills/subagent-driven-development/references/gates-taxonomy.md +93 -0
- package/.agent/skills/systematic-debugging/SKILL.md +360 -0
- package/.agent/skills/test-driven-development/SKILL.md +336 -0
- package/.agent/skills/video-orchestrator/SKILL.md +194 -0
- package/.agent/skills/video-orchestrator/references/examples.md +227 -0
- package/.agent/skills/video-orchestrator/references/intake.md +166 -0
- package/.agent/skills/video-orchestrator/references/kanban-setup.md +278 -0
- package/.agent/skills/video-orchestrator/references/monitoring.md +180 -0
- package/.agent/skills/video-orchestrator/references/role-archetypes.md +298 -0
- package/.agent/skills/video-orchestrator/references/tool-matrix.md +317 -0
- package/.agent/skills/web-pentest/SKILL.md +332 -0
- package/.agent/skills/web-pentest/references/bypass-techniques.md +133 -0
- package/.agent/skills/web-pentest/references/exploitation-techniques.md +204 -0
- package/.agent/skills/web-pentest/references/scope-enforcement.md +110 -0
- package/.agent/skills/web-pentest/references/vuln-taxonomy.md +81 -0
- package/.agent/skills/web-pentest/templates/authorization.md +69 -0
- package/.agent/skills/web-pentest/templates/pentest-report.md +178 -0
- package/.claude/commands/mindforge/skill-tdd.md +53 -0
- package/.claude/commands/mindforge/skills-index.md +118 -0
- package/.claude/commands/mindforge/systematic-debug.md +60 -0
- package/.claude/commands/mindforge/wf-catalog.md +37 -0
- package/.claude/commands/mindforge/wf-code-audit.md +31 -0
- package/.claude/commands/mindforge/wf-competitive-analysis.md +31 -0
- package/.claude/commands/mindforge/wf-deep-research.md +32 -0
- package/.claude/commands/mindforge/wf-feature-planner.md +31 -0
- package/.claude/commands/mindforge/wf-incident-response.md +31 -0
- package/.claude/commands/mindforge/wf-onboard-codebase.md +31 -0
- package/.claude/commands/mindforge/wf-perf-optimize.md +31 -0
- package/.claude/commands/mindforge/wf-pr-review.md +31 -0
- package/.claude/commands/mindforge/wf-refactor-plan.md +31 -0
- package/.claude/commands/mindforge/wf-release-prep.md +31 -0
- package/.claude/commands/mindforge/wf-tdd-sprint.md +31 -0
- package/.claude/commands/mindforge/wf-tech-evaluation.md +31 -0
- package/.mindforge/config.json +2 -2
- package/.mindforge/dynamic-workflows/REGISTRY.md +65 -0
- package/.mindforge/dynamic-workflows/index.json +171 -0
- package/.mindforge/dynamic-workflows/scripts/code-audit.js +103 -0
- package/.mindforge/dynamic-workflows/scripts/competitive-analysis.js +85 -0
- package/.mindforge/dynamic-workflows/scripts/deep-research.js +151 -0
- package/.mindforge/dynamic-workflows/scripts/feature-planner.js +104 -0
- package/.mindforge/dynamic-workflows/scripts/incident-response.js +106 -0
- package/.mindforge/dynamic-workflows/scripts/onboard-codebase.js +102 -0
- package/.mindforge/dynamic-workflows/scripts/perf-optimize.js +128 -0
- package/.mindforge/dynamic-workflows/scripts/pr-review.js +87 -0
- package/.mindforge/dynamic-workflows/scripts/refactor-plan.js +121 -0
- package/.mindforge/dynamic-workflows/scripts/release-prep.js +102 -0
- package/.mindforge/dynamic-workflows/scripts/tdd-sprint.js +103 -0
- package/.mindforge/dynamic-workflows/scripts/tech-evaluation.js +72 -0
- package/.mindforge/memory/sync-manifest.json +1 -1
- package/.mindforge/skills/arxiv/SKILL.md +294 -0
- package/.mindforge/skills/blogwatcher/SKILL.md +147 -0
- package/.mindforge/skills/code-wiki/SKILL.md +457 -0
- package/.mindforge/skills/codebase-inspection/SKILL.md +126 -0
- package/.mindforge/skills/concept-diagrams/SKILL.md +373 -0
- package/.mindforge/skills/creative-ideation/SKILL.md +162 -0
- package/.mindforge/skills/domain-intel/SKILL.md +116 -0
- package/.mindforge/skills/duckduckgo-search/SKILL.md +249 -0
- package/.mindforge/skills/github-code-review/SKILL.md +493 -0
- package/.mindforge/skills/github-issues/SKILL.md +382 -0
- package/.mindforge/skills/github-pr-workflow/SKILL.md +379 -0
- package/.mindforge/skills/jupyter-live-kernel/SKILL.md +179 -0
- package/.mindforge/skills/kanban-orchestrator/SKILL.md +227 -0
- package/.mindforge/skills/kanban-worker/SKILL.md +206 -0
- package/.mindforge/skills/meme-generation/SKILL.md +141 -0
- package/.mindforge/skills/obsidian/SKILL.md +80 -0
- package/.mindforge/skills/osint-investigation/SKILL.md +288 -0
- package/.mindforge/skills/oss-forensics/SKILL.md +421 -0
- package/.mindforge/skills/pixel-art/SKILL.md +228 -0
- package/.mindforge/skills/plan/SKILL.md +350 -0
- package/.mindforge/skills/requesting-code-review/SKILL.md +292 -0
- package/.mindforge/skills/research-paper-writing/SKILL.md +2384 -0
- package/.mindforge/skills/scrapling/SKILL.md +345 -0
- package/.mindforge/skills/sherlock/SKILL.md +203 -0
- package/.mindforge/skills/simplify-code/SKILL.md +187 -0
- package/.mindforge/skills/spike/SKILL.md +209 -0
- package/.mindforge/skills/subagent-driven-development/SKILL.md +364 -0
- package/.mindforge/skills/systematic-debugging/SKILL.md +379 -0
- package/.mindforge/skills/test-driven-development/SKILL.md +355 -0
- package/.mindforge/skills/web-pentest/SKILL.md +327 -0
- package/CHANGELOG.md +71 -0
- package/MINDFORGE.md +2 -2
- package/README.md +72 -3
- package/RELEASENOTES.md +109 -0
- package/bin/installer-core.js +6 -2
- package/bin/mindforge-cli.js +7 -0
- package/bin/workflows/workflow-runner.js +110 -0
- package/docs/commands-reference.md +25 -0
- package/docs/getting-started.md +42 -5
- package/package.json +2 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'deep-research',
|
|
3
|
+
description: 'Fan-out web research with adversarial claim verification and cited synthesis',
|
|
4
|
+
whenToUse: 'When you need a deep, multi-source, fact-checked research report on any topic',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Scope', detail: 'Decompose question into 5 search angles' },
|
|
7
|
+
{ title: 'Search', detail: '5 parallel web search agents, one per angle' },
|
|
8
|
+
{ title: 'Fetch', detail: 'Dedup URLs, fetch top 15 sources, extract falsifiable claims' },
|
|
9
|
+
{ title: 'Verify', detail: '3-vote adversarial verification per claim (need 2/3 to kill)' },
|
|
10
|
+
{ title: 'Synthesize', detail: 'Merge semantic dupes, rank by confidence, cite sources' },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
15
|
+
const ANGLES_SCHEMA = {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
angles: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
items: { type: 'object', properties: { label: { type: 'string' }, query: { type: 'string' } }, required: ['label', 'query'] },
|
|
21
|
+
minItems: 5, maxItems: 5,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ['angles'],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const SEARCH_SCHEMA = {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
results: {
|
|
31
|
+
type: 'array',
|
|
32
|
+
items: { type: 'object', properties: { title: { type: 'string' }, url: { type: 'string' }, snippet: { type: 'string' } }, required: ['title', 'url', 'snippet'] },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ['results'],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const CLAIMS_SCHEMA = {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
claims: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: { type: 'object', properties: { claim: { type: 'string' }, source: { type: 'string' }, evidence: { type: 'string' } }, required: ['claim', 'source', 'evidence'] },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ['claims'],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const VERDICT_SCHEMA = {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: { refuted: { type: 'boolean' }, reason: { type: 'string' } },
|
|
52
|
+
required: ['refuted', 'reason'],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const SYNTH_SCHEMA = {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
summary: { type: 'string' },
|
|
59
|
+
findings: {
|
|
60
|
+
type: 'array',
|
|
61
|
+
items: { type: 'object', properties: { claim: { type: 'string' }, confidence: { type: 'string' }, sources: { type: 'array', items: { type: 'string' } }, evidence: { type: 'string' } }, required: ['claim', 'confidence', 'sources', 'evidence'] },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ['summary', 'findings'],
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const question = args || 'No question provided — please pass your research question as args.';
|
|
68
|
+
|
|
69
|
+
phase('Scope');
|
|
70
|
+
log(`Q: ${question.slice(0, 60)}…`);
|
|
71
|
+
const scoped = await agent(
|
|
72
|
+
`Decompose this research question into exactly 5 independent search angles. Each angle should approach the topic from a different perspective (e.g., implementation, theory, examples, trade-offs, contrarian view). Question: "${question}"`,
|
|
73
|
+
{ schema: ANGLES_SCHEMA, label: 'decompose' }
|
|
74
|
+
);
|
|
75
|
+
const angles = scoped.angles;
|
|
76
|
+
log(`Decomposed into ${angles.length} angles: ${angles.map(a => a.label).join(', ')}`);
|
|
77
|
+
|
|
78
|
+
phase('Search');
|
|
79
|
+
const searchResults = await parallel(
|
|
80
|
+
angles.map(angle => () => agent(
|
|
81
|
+
`Web search for: "${angle.query}". Return the top 6 most relevant results with title, URL, and a brief snippet explaining why each is relevant to: "${angle.query}"`,
|
|
82
|
+
{ schema: SEARCH_SCHEMA, label: angle.label }
|
|
83
|
+
))
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
phase('Fetch');
|
|
87
|
+
const allUrls = new Map();
|
|
88
|
+
for (const res of searchResults.filter(Boolean)) {
|
|
89
|
+
for (const r of res.results) {
|
|
90
|
+
if (!allUrls.has(r.url)) allUrls.set(r.url, r);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const uniqueUrls = [...allUrls.values()].slice(0, 15);
|
|
94
|
+
log(`Fetched ${searchResults.filter(Boolean).length * 6} results → ${uniqueUrls.length} unique sources → extracting claims`);
|
|
95
|
+
|
|
96
|
+
const claimBatches = await parallel(
|
|
97
|
+
uniqueUrls.map(src => () => agent(
|
|
98
|
+
`Read this source and extract up to 5 specific, falsifiable factual claims from it. Only extract claims that are directly relevant to: "${question}". Source URL: ${src.url}\nSnippet: ${src.snippet}`,
|
|
99
|
+
{ schema: CLAIMS_SCHEMA, label: `claims:${src.url.slice(8, 40)}` }
|
|
100
|
+
))
|
|
101
|
+
);
|
|
102
|
+
const allClaims = claimBatches.filter(Boolean).flatMap(b => b.claims).slice(0, 25);
|
|
103
|
+
log(`Extracted ${allClaims.length} claims → verifying top 25`);
|
|
104
|
+
|
|
105
|
+
phase('Verify');
|
|
106
|
+
const verified = await parallel(
|
|
107
|
+
allClaims.map(c => () =>
|
|
108
|
+
parallel([
|
|
109
|
+
() => agent(`Try to REFUTE this claim. Default to refuted=true if uncertain or unverifiable. Claim: "${c.claim}"`, { schema: VERDICT_SCHEMA, label: `verify-1:${c.claim.slice(0, 30)}` }),
|
|
110
|
+
() => agent(`Adversarially challenge this claim from a different angle. Default to refuted=true if you cannot confirm it. Claim: "${c.claim}"`, { schema: VERDICT_SCHEMA, label: `verify-2:${c.claim.slice(0, 30)}` }),
|
|
111
|
+
() => agent(`As a skeptical fact-checker, evaluate this claim. Default to refuted=true if evidence is weak. Claim: "${c.claim}"`, { schema: VERDICT_SCHEMA, label: `verify-3:${c.claim.slice(0, 30)}` }),
|
|
112
|
+
]).then(votes => {
|
|
113
|
+
const refutes = votes.filter(Boolean).filter(v => v.refuted).length;
|
|
114
|
+
return { ...c, survives: refutes <= 1, votes: `${3 - refutes}-${refutes}` };
|
|
115
|
+
})
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
const confirmed = verified.filter(Boolean).filter(c => c.survives);
|
|
119
|
+
const killed = verified.filter(Boolean).filter(c => !c.survives);
|
|
120
|
+
log(`Verify done: ${allClaims.length} claims → ${confirmed.length} confirmed, ${killed.length} killed`);
|
|
121
|
+
|
|
122
|
+
phase('Synthesize');
|
|
123
|
+
const synthesis = await agent(
|
|
124
|
+
`Synthesize these verified research findings into a comprehensive report answering: "${question}"
|
|
125
|
+
|
|
126
|
+
Confirmed findings (${confirmed.length}):
|
|
127
|
+
${confirmed.map((c, i) => `${i + 1}. [${c.votes}] ${c.claim} (source: ${c.source})`).join('\n')}
|
|
128
|
+
|
|
129
|
+
Killed findings (${killed.length}):
|
|
130
|
+
${killed.map(c => `- [${c.votes}] ${c.claim}`).join('\n')}
|
|
131
|
+
|
|
132
|
+
Produce a clear summary and a ranked findings list. For each finding, state the claim, confidence level (high/medium/low), sources, and evidence.`,
|
|
133
|
+
{ schema: SYNTH_SCHEMA, label: 'synthesize' }
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
question,
|
|
138
|
+
summary: synthesis.summary,
|
|
139
|
+
findings: synthesis.findings,
|
|
140
|
+
refuted: killed.map(c => ({ claim: c.claim, vote: c.votes, source: c.source })),
|
|
141
|
+
sources: uniqueUrls.map(u => u.url),
|
|
142
|
+
stats: {
|
|
143
|
+
angles: angles.length,
|
|
144
|
+
sourcesFetched: uniqueUrls.length,
|
|
145
|
+
claimsExtracted: allClaims.length,
|
|
146
|
+
claimsVerified: allClaims.length,
|
|
147
|
+
confirmed: confirmed.length,
|
|
148
|
+
killed: killed.length,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'feature-planner',
|
|
3
|
+
description: 'Sequential pipeline: brief → PRD → architecture → user stories',
|
|
4
|
+
whenToUse: 'When starting a new feature and need a complete specification before coding',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Brief', detail: 'Clarify goals, users, success criteria' },
|
|
7
|
+
{ title: 'PRD', detail: 'Generate product requirements document' },
|
|
8
|
+
{ title: 'Architecture', detail: 'Design technical architecture and data flow' },
|
|
9
|
+
{ title: 'Stories', detail: 'Break into implementation user stories' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const BRIEF_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
featureName: { type: 'string' },
|
|
18
|
+
problem: { type: 'string' },
|
|
19
|
+
targetUsers: { type: 'string' },
|
|
20
|
+
successCriteria: { type: 'array', items: { type: 'string' } },
|
|
21
|
+
outOfScope: { type: 'array', items: { type: 'string' } },
|
|
22
|
+
},
|
|
23
|
+
required: ['featureName', 'problem', 'targetUsers', 'successCriteria', 'outOfScope'],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const PRD_SCHEMA = {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
overview: { type: 'string' },
|
|
30
|
+
requirements: { type: 'array', items: { type: 'object', properties: { id: { type: 'string' }, type: { type: 'string' }, description: { type: 'string' }, priority: { type: 'string' } }, required: ['id', 'type', 'description', 'priority'] } },
|
|
31
|
+
nonFunctional: { type: 'array', items: { type: 'string' } },
|
|
32
|
+
acceptanceCriteria: { type: 'array', items: { type: 'string' } },
|
|
33
|
+
},
|
|
34
|
+
required: ['overview', 'requirements', 'nonFunctional', 'acceptanceCriteria'],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const ARCH_SCHEMA = {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
approach: { type: 'string' },
|
|
41
|
+
components: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, responsibility: { type: 'string' } }, required: ['name', 'responsibility'] } },
|
|
42
|
+
dataFlow: { type: 'string' },
|
|
43
|
+
newFiles: { type: 'array', items: { type: 'string' } },
|
|
44
|
+
modifiedFiles: { type: 'array', items: { type: 'string' } },
|
|
45
|
+
risks: { type: 'array', items: { type: 'string' } },
|
|
46
|
+
},
|
|
47
|
+
required: ['approach', 'components', 'dataFlow', 'newFiles', 'modifiedFiles', 'risks'],
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const STORIES_SCHEMA = {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
stories: {
|
|
54
|
+
type: 'array',
|
|
55
|
+
items: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
id: { type: 'string' },
|
|
59
|
+
title: { type: 'string' },
|
|
60
|
+
asA: { type: 'string' },
|
|
61
|
+
iWant: { type: 'string' },
|
|
62
|
+
soThat: { type: 'string' },
|
|
63
|
+
acceptanceCriteria: { type: 'array', items: { type: 'string' } },
|
|
64
|
+
estimate: { type: 'string' },
|
|
65
|
+
},
|
|
66
|
+
required: ['id', 'title', 'asA', 'iWant', 'soThat', 'acceptanceCriteria', 'estimate'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
required: ['stories'],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const feature = args || 'No feature described — pass your feature description as args.';
|
|
74
|
+
|
|
75
|
+
phase('Brief');
|
|
76
|
+
log(`Feature: ${feature.slice(0, 60)}`);
|
|
77
|
+
const brief = await agent(
|
|
78
|
+
`Create a feature brief for: "${feature}". Clarify the core problem, target users, measurable success criteria, and explicit out-of-scope items.`,
|
|
79
|
+
{ schema: BRIEF_SCHEMA, label: 'brief' }
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
phase('PRD');
|
|
83
|
+
const briefText = `Feature: ${brief.featureName}\nProblem: ${brief.problem}\nUsers: ${brief.targetUsers}\nSuccess: ${brief.successCriteria.join(', ')}`;
|
|
84
|
+
const prd = await agent(
|
|
85
|
+
`Write a product requirements document for this feature:\n${briefText}\n\nInclude functional requirements (must/should/could), non-functional requirements, and acceptance criteria.`,
|
|
86
|
+
{ schema: PRD_SCHEMA, label: 'prd' }
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
phase('Architecture');
|
|
90
|
+
const reqSummary = prd.requirements.slice(0, 8).map(r => `${r.id} [${r.priority}]: ${r.description}`).join('\n');
|
|
91
|
+
const arch = await agent(
|
|
92
|
+
`Design the technical architecture for this feature:\nBrief: ${briefText}\nRequirements:\n${reqSummary}\n\nIdentify the implementation approach, components, data flow, files to create/modify, and key risks.`,
|
|
93
|
+
{ schema: ARCH_SCHEMA, label: 'architecture' }
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
phase('Stories');
|
|
97
|
+
const archSummary = `Approach: ${arch.approach}\nNew files: ${arch.newFiles.join(', ')}\nModified: ${arch.modifiedFiles.join(', ')}`;
|
|
98
|
+
const stories = await agent(
|
|
99
|
+
`Break this feature into user stories:\nBrief: ${briefText}\nArchitecture: ${archSummary}\n\nWrite stories in "As a [user], I want [goal], so that [benefit]" format with acceptance criteria and t-shirt size estimates (XS/S/M/L/XL).`,
|
|
100
|
+
{ schema: STORIES_SCHEMA, label: 'stories' }
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
return { feature, brief, prd, architecture: arch, stories: stories.stories };
|
|
104
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'incident-response',
|
|
3
|
+
description: 'Parallel investigation across logs, metrics, traces, and code → mitigation → RCA → postmortem',
|
|
4
|
+
whenToUse: 'When responding to a production incident or unexpected system failure',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Alert', detail: 'Characterize the incident: impact, scope, timeline' },
|
|
7
|
+
{ title: 'Investigate', detail: '4 parallel agents: logs / metrics / traces / code changes' },
|
|
8
|
+
{ title: 'Mitigate', detail: 'Identify and apply immediate mitigation steps' },
|
|
9
|
+
{ title: 'RCA', detail: 'Root cause analysis and postmortem document' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const CHARACTERIZE_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
incidentTitle: { type: 'string' },
|
|
18
|
+
severity: { type: 'string', enum: ['P0', 'P1', 'P2', 'P3'] },
|
|
19
|
+
impactDescription: { type: 'string' },
|
|
20
|
+
affectedSystems: { type: 'array', items: { type: 'string' } },
|
|
21
|
+
startTime: { type: 'string' },
|
|
22
|
+
symptoms: { type: 'array', items: { type: 'string' } },
|
|
23
|
+
hypothesis: { type: 'string' },
|
|
24
|
+
},
|
|
25
|
+
required: ['incidentTitle', 'severity', 'impactDescription', 'affectedSystems', 'symptoms', 'hypothesis'],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const INVESTIGATE_SCHEMA = {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
angle: { type: 'string' },
|
|
32
|
+
findings: { type: 'array', items: { type: 'string' } },
|
|
33
|
+
suspectedCause: { type: 'string' },
|
|
34
|
+
confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
|
|
35
|
+
},
|
|
36
|
+
required: ['angle', 'findings', 'suspectedCause', 'confidence'],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const MITIGATE_SCHEMA = {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
immediateActions: { type: 'array', items: { type: 'object', properties: { action: { type: 'string' }, command: { type: 'string' }, risk: { type: 'string' } }, required: ['action', 'risk'] } },
|
|
43
|
+
estimatedRecoveryTime: { type: 'string' },
|
|
44
|
+
rollbackSteps: { type: 'array', items: { type: 'string' } },
|
|
45
|
+
},
|
|
46
|
+
required: ['immediateActions', 'estimatedRecoveryTime', 'rollbackSteps'],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const POSTMORTEM_SCHEMA = {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
rootCause: { type: 'string' },
|
|
53
|
+
timeline: { type: 'array', items: { type: 'object', properties: { time: { type: 'string' }, event: { type: 'string' } }, required: ['time', 'event'] } },
|
|
54
|
+
contributingFactors: { type: 'array', items: { type: 'string' } },
|
|
55
|
+
actionItems: { type: 'array', items: { type: 'object', properties: { action: { type: 'string' }, owner: { type: 'string' }, priority: { type: 'string' } }, required: ['action', 'owner', 'priority'] } },
|
|
56
|
+
lessonsLearned: { type: 'array', items: { type: 'string' } },
|
|
57
|
+
},
|
|
58
|
+
required: ['rootCause', 'timeline', 'contributingFactors', 'actionItems', 'lessonsLearned'],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const incident = args || 'No incident description provided — pass your incident description, symptoms, and affected systems as args.';
|
|
62
|
+
|
|
63
|
+
phase('Alert');
|
|
64
|
+
log(`Incident: ${incident.slice(0, 80)}`);
|
|
65
|
+
const characterization = await agent(
|
|
66
|
+
`Characterize this production incident: "${incident}"\n\nDetermine severity (P0=total outage, P1=major degradation, P2=partial impact, P3=minor), list affected systems, symptoms, and your initial hypothesis about the root cause.`,
|
|
67
|
+
{ schema: CHARACTERIZE_SCHEMA, label: 'characterize' }
|
|
68
|
+
);
|
|
69
|
+
log(`[${characterization.severity}] ${characterization.incidentTitle} — ${characterization.symptoms.length} symptoms identified`);
|
|
70
|
+
|
|
71
|
+
phase('Investigate');
|
|
72
|
+
const context = `Incident: ${characterization.incidentTitle}\nHypothesis: ${characterization.hypothesis}\nSystems: ${characterization.affectedSystems.join(', ')}`;
|
|
73
|
+
|
|
74
|
+
const INVESTIGATION_ANGLES = [
|
|
75
|
+
{ label: 'logs', prompt: `Investigate this incident from the LOGS angle: ${context}\n\nWhat log patterns, error messages, or anomalies would you look for? What do recent application/system logs likely show? What would confirm or refute the hypothesis?` },
|
|
76
|
+
{ label: 'metrics', prompt: `Investigate this incident from the METRICS angle: ${context}\n\nWhat metrics (CPU, memory, latency, error rates, throughput) would spike or drop? What dashboards to check? What thresholds were likely crossed?` },
|
|
77
|
+
{ label: 'traces', prompt: `Investigate this incident from the DISTRIBUTED TRACES angle: ${context}\n\nWhat trace patterns would reveal the failure point? Which service calls would show elevated latency or errors? What would a flame graph show?` },
|
|
78
|
+
{ label: 'code', prompt: `Investigate this incident from the RECENT CODE CHANGES angle: ${context}\n\nWhat types of recent deployments, config changes, or dependency updates could cause this? What specific code patterns are suspect? What git history to examine?` },
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
const investigations = await parallel(
|
|
82
|
+
INVESTIGATION_ANGLES.map(a => () => agent(a.prompt, { schema: INVESTIGATE_SCHEMA, label: `investigate:${a.label}`, phase: 'Investigate' }))
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
phase('Mitigate');
|
|
86
|
+
const investigationSummary = investigations.filter(Boolean).map(i => `[${i.angle}] ${i.suspectedCause} (${i.confidence} confidence): ${i.findings.slice(0, 2).join(', ')}`).join('\n');
|
|
87
|
+
const mitigation = await agent(
|
|
88
|
+
`Based on these investigation findings, identify IMMEDIATE mitigation actions:\n${investigationSummary}\n\nPrioritize actions that restore service quickly. Include rollback steps and estimate recovery time.`,
|
|
89
|
+
{ schema: MITIGATE_SCHEMA, label: 'mitigate' }
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
phase('RCA');
|
|
93
|
+
const allContext = `Incident: ${characterization.incidentTitle}\nInvestigations:\n${investigationSummary}\nMitigation: ${mitigation.immediateActions.map(a => a.action).join(', ')}`;
|
|
94
|
+
const postmortem = await agent(
|
|
95
|
+
`Write a blameless postmortem for this incident:\n${allContext}\n\nIdentify the root cause, create a timeline, list contributing factors, define concrete action items (with owners and priority), and extract lessons learned.`,
|
|
96
|
+
{ schema: POSTMORTEM_SCHEMA, label: 'postmortem' }
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
incident,
|
|
101
|
+
characterization,
|
|
102
|
+
investigations: investigations.filter(Boolean),
|
|
103
|
+
mitigation,
|
|
104
|
+
postmortem,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'onboard-codebase',
|
|
3
|
+
description: 'Map structure → domain analysis → architecture → generate guided tour and onboarding docs',
|
|
4
|
+
whenToUse: 'When joining a new codebase or onboarding a team member to an existing repo',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Map', detail: 'Discover file structure, languages, entry points' },
|
|
7
|
+
{ title: 'Domain', detail: 'Identify business domains and core abstractions' },
|
|
8
|
+
{ title: 'Architecture', detail: 'Map layers, data flow, and key patterns' },
|
|
9
|
+
{ title: 'Tour', detail: 'Generate guided tour and onboarding documentation' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const MAP_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
primaryLanguage: { type: 'string' },
|
|
18
|
+
secondaryLanguages: { type: 'array', items: { type: 'string' } },
|
|
19
|
+
frameworks: { type: 'array', items: { type: 'string' } },
|
|
20
|
+
entryPoints: { type: 'array', items: { type: 'string' } },
|
|
21
|
+
testingFrameworks: { type: 'array', items: { type: 'string' } },
|
|
22
|
+
totalFiles: { type: 'string' },
|
|
23
|
+
keyDirectories: { type: 'array', items: { type: 'object', properties: { path: { type: 'string' }, purpose: { type: 'string' } }, required: ['path', 'purpose'] } },
|
|
24
|
+
},
|
|
25
|
+
required: ['primaryLanguage', 'frameworks', 'entryPoints', 'keyDirectories'],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const DOMAIN_SCHEMA = {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
domains: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, description: { type: 'string' }, keyFiles: { type: 'array', items: { type: 'string' } } }, required: ['name', 'description', 'keyFiles'] } },
|
|
32
|
+
coreAbstractions: { type: 'array', items: { type: 'string' } },
|
|
33
|
+
businessPurpose: { type: 'string' },
|
|
34
|
+
},
|
|
35
|
+
required: ['domains', 'coreAbstractions', 'businessPurpose'],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const ARCH_SCHEMA = {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
architectureStyle: { type: 'string' },
|
|
42
|
+
layers: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, responsibility: { type: 'string' } }, required: ['name', 'responsibility'] } },
|
|
43
|
+
dataFlow: { type: 'string' },
|
|
44
|
+
keyPatterns: { type: 'array', items: { type: 'string' } },
|
|
45
|
+
externalDependencies: { type: 'array', items: { type: 'string' } },
|
|
46
|
+
gotchas: { type: 'array', items: { type: 'string' } },
|
|
47
|
+
},
|
|
48
|
+
required: ['architectureStyle', 'layers', 'dataFlow', 'keyPatterns', 'gotchas'],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const TOUR_SCHEMA = {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
quickStart: { type: 'string' },
|
|
55
|
+
tourSteps: { type: 'array', items: { type: 'object', properties: { step: { type: 'number' }, title: { type: 'string' }, file: { type: 'string' }, explanation: { type: 'string' } }, required: ['step', 'title', 'explanation'] } },
|
|
56
|
+
keyConventions: { type: 'array', items: { type: 'string' } },
|
|
57
|
+
whereToStartCoding: { type: 'string' },
|
|
58
|
+
commonPitfalls: { type: 'array', items: { type: 'string' } },
|
|
59
|
+
},
|
|
60
|
+
required: ['quickStart', 'tourSteps', 'keyConventions', 'whereToStartCoding', 'commonPitfalls'],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const repo = args || 'current repository (run from repo root)';
|
|
64
|
+
|
|
65
|
+
phase('Map');
|
|
66
|
+
log(`Mapping: ${repo}`);
|
|
67
|
+
const map = await agent(
|
|
68
|
+
`Map the structure of this codebase: "${repo}"\n\nIdentify: primary language, frameworks, entry points (main files, index, CLI), test frameworks, and the purpose of each top-level directory. Be specific — list actual file paths.`,
|
|
69
|
+
{ schema: MAP_SCHEMA, label: 'map' }
|
|
70
|
+
);
|
|
71
|
+
log(`${map.primaryLanguage} codebase, ${map.frameworks.join('+')} — ${map.keyDirectories.length} key directories`);
|
|
72
|
+
|
|
73
|
+
phase('Domain');
|
|
74
|
+
const mapSummary = `Stack: ${map.primaryLanguage} + ${map.frameworks.join(', ')}\nDirs: ${map.keyDirectories.map(d => `${d.path} (${d.purpose})`).join(', ')}`;
|
|
75
|
+
const domain = await agent(
|
|
76
|
+
`Identify the business domains and core abstractions in: "${repo}"\n${mapSummary}\n\nWhat problem does this software solve? What are the main domain concepts? What are the key abstractions (models, services, controllers, etc.)?`,
|
|
77
|
+
{ schema: DOMAIN_SCHEMA, label: 'domain' }
|
|
78
|
+
);
|
|
79
|
+
log(`${domain.domains.length} domains: ${domain.domains.map(d => d.name).join(', ')}`);
|
|
80
|
+
|
|
81
|
+
phase('Architecture');
|
|
82
|
+
const domainSummary = `Purpose: ${domain.businessPurpose}\nDomains: ${domain.domains.map(d => d.name).join(', ')}\nAbstractions: ${domain.coreAbstractions.join(', ')}`;
|
|
83
|
+
const arch = await agent(
|
|
84
|
+
`Map the technical architecture of: "${repo}"\n${domainSummary}\n\nWhat architecture style (MVC, layered, event-driven, microservices)? What are the layers? How does data flow? What key patterns and gotchas should a new developer know?`,
|
|
85
|
+
{ schema: ARCH_SCHEMA, label: 'architecture' }
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
phase('Tour');
|
|
89
|
+
const archSummary = `Style: ${arch.architectureStyle}\nLayers: ${arch.layers.map(l => l.name).join(' → ')}\nPatterns: ${arch.keyPatterns.join(', ')}`;
|
|
90
|
+
const tour = await agent(
|
|
91
|
+
`Create an onboarding tour for: "${repo}"\n${mapSummary}\n${domainSummary}\n${archSummary}\n\nWrite a quick start, a 5-10 step guided tour through the most important files (in learning order), key conventions to follow, where to start making changes, and common pitfalls to avoid.`,
|
|
92
|
+
{ schema: TOUR_SCHEMA, label: 'tour' }
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
repo,
|
|
97
|
+
map,
|
|
98
|
+
domain,
|
|
99
|
+
architecture: arch,
|
|
100
|
+
tour,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'perf-optimize',
|
|
3
|
+
description: 'Profile → parallel bottleneck hunt across DB/network/CPU/memory → prioritized fix plan',
|
|
4
|
+
whenToUse: 'When an application is slow and you need to find and fix performance bottlenecks',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Profile', detail: 'Establish baseline metrics and identify slow paths' },
|
|
7
|
+
{ title: 'Identify', detail: '4 parallel agents: DB queries / network / CPU / memory' },
|
|
8
|
+
{ title: 'Plan', detail: 'Prioritize fixes by impact-to-effort ratio' },
|
|
9
|
+
{ title: 'Benchmark', detail: 'Define verification benchmarks for each fix' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const PROFILE_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
slowestPaths: { type: 'array', items: { type: 'object', properties: { path: { type: 'string' }, currentLatency: { type: 'string' }, target: { type: 'string' } }, required: ['path', 'currentLatency'] } },
|
|
18
|
+
bottleneckHypothesis: { type: 'string' },
|
|
19
|
+
profilingCommands: { type: 'array', items: { type: 'string' } },
|
|
20
|
+
},
|
|
21
|
+
required: ['slowestPaths', 'bottleneckHypothesis', 'profilingCommands'],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const BOTTLENECK_SCHEMA = {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
dimension: { type: 'string' },
|
|
28
|
+
issues: {
|
|
29
|
+
type: 'array',
|
|
30
|
+
items: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
description: { type: 'string' },
|
|
34
|
+
location: { type: 'string' },
|
|
35
|
+
impact: { type: 'string', enum: ['high', 'medium', 'low'] },
|
|
36
|
+
fix: { type: 'string' },
|
|
37
|
+
effort: { type: 'string', enum: ['low', 'medium', 'high'] },
|
|
38
|
+
},
|
|
39
|
+
required: ['description', 'impact', 'fix', 'effort'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: ['dimension', 'issues'],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const FIX_PLAN_SCHEMA = {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
prioritized: {
|
|
50
|
+
type: 'array',
|
|
51
|
+
items: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
rank: { type: 'number' },
|
|
55
|
+
fix: { type: 'string' },
|
|
56
|
+
dimension: { type: 'string' },
|
|
57
|
+
expectedImprovement: { type: 'string' },
|
|
58
|
+
effort: { type: 'string' },
|
|
59
|
+
implementation: { type: 'string' },
|
|
60
|
+
},
|
|
61
|
+
required: ['rank', 'fix', 'expectedImprovement', 'effort', 'implementation'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
totalEstimate: { type: 'string' },
|
|
65
|
+
quickWins: { type: 'array', items: { type: 'string' } },
|
|
66
|
+
},
|
|
67
|
+
required: ['prioritized', 'totalEstimate', 'quickWins'],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const BENCHMARK_SCHEMA = {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
baselineTests: { type: 'array', items: { type: 'string' } },
|
|
74
|
+
successCriteria: { type: 'array', items: { type: 'object', properties: { fix: { type: 'string' }, metric: { type: 'string' }, target: { type: 'string' } }, required: ['fix', 'metric', 'target'] } },
|
|
75
|
+
monitoringSetup: { type: 'array', items: { type: 'string' } },
|
|
76
|
+
},
|
|
77
|
+
required: ['baselineTests', 'successCriteria', 'monitoringSetup'],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const target = args || 'current application (run from repo root)';
|
|
81
|
+
|
|
82
|
+
phase('Profile');
|
|
83
|
+
log(`Profiling: ${target}`);
|
|
84
|
+
const profile = await agent(
|
|
85
|
+
`Identify the slowest code paths and performance bottleneck hypothesis for: "${target}"\n\nWhat are the likely slow endpoints/functions? What profiling commands should be run? What is your initial bottleneck hypothesis?`,
|
|
86
|
+
{ schema: PROFILE_SCHEMA, label: 'profile' }
|
|
87
|
+
);
|
|
88
|
+
log(`${profile.slowestPaths.length} slow paths identified, hypothesis: ${profile.bottleneckHypothesis.slice(0, 80)}`);
|
|
89
|
+
|
|
90
|
+
phase('Identify');
|
|
91
|
+
const context = `Target: ${target}\nSlow paths: ${profile.slowestPaths.map(p => p.path).join(', ')}\nHypothesis: ${profile.bottleneckHypothesis}`;
|
|
92
|
+
|
|
93
|
+
const DIMENSIONS = [
|
|
94
|
+
{ label: 'db', prompt: `Hunt for DATABASE performance bottlenecks in: ${context}\n\nLook for: N+1 queries, missing indexes, full table scans, unoptimized JOINs, missing query caching, connection pool exhaustion, slow aggregate queries.` },
|
|
95
|
+
{ label: 'network', prompt: `Hunt for NETWORK performance bottlenecks in: ${context}\n\nLook for: missing HTTP caching, no CDN, uncompressed responses, chatty APIs (many small requests), missing connection pooling, DNS lookups in hot paths, synchronous external calls.` },
|
|
96
|
+
{ label: 'cpu', prompt: `Hunt for CPU/COMPUTE performance bottlenecks in: ${context}\n\nLook for: inefficient algorithms (O(n²) where O(n log n) exists), regex in hot paths, JSON serialization overhead, cryptographic operations in request path, missing memoization.` },
|
|
97
|
+
{ label: 'memory', prompt: `Hunt for MEMORY performance bottlenecks in: ${context}\n\nLook for: memory leaks, unbounded caches, large object retention, excessive GC pressure, buffer accumulation, object pool exhaustion, unnecessary data loading.` },
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
const bottlenecks = await parallel(
|
|
101
|
+
DIMENSIONS.map(d => () => agent(d.prompt, { schema: BOTTLENECK_SCHEMA, label: `identify:${d.label}`, phase: 'Identify' }))
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
phase('Plan');
|
|
105
|
+
const allIssues = bottlenecks.filter(Boolean).flatMap(b => b.issues.map(i => ({ ...i, dimension: b.dimension })));
|
|
106
|
+
log(`${allIssues.length} bottlenecks found across ${bottlenecks.filter(Boolean).length} dimensions`);
|
|
107
|
+
const issueList = allIssues.slice(0, 20).map(i => `[${i.dimension}][${i.impact}/${i.effort}] ${i.description} → ${i.fix}`).join('\n');
|
|
108
|
+
const fixPlan = await agent(
|
|
109
|
+
`Prioritize this performance fix backlog by impact-to-effort ratio:\n${issueList}\n\nRank by: high impact + low effort first. List quick wins (can implement in <1 hour) separately. Include implementation guidance for each.`,
|
|
110
|
+
{ schema: FIX_PLAN_SCHEMA, label: 'plan' }
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
phase('Benchmark');
|
|
114
|
+
const topFixes = fixPlan.prioritized.slice(0, 5).map(f => `${f.rank}. ${f.fix} (expected: ${f.expectedImprovement})`).join('\n');
|
|
115
|
+
const benchmarks = await agent(
|
|
116
|
+
`Define performance benchmarks for verifying these fixes:\n${topFixes}\n\nFor each fix, specify: the baseline test to run before, the success metric (P95 latency, throughput, memory), and the target value. Include monitoring setup recommendations.`,
|
|
117
|
+
{ schema: BENCHMARK_SCHEMA, label: 'benchmark' }
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
target,
|
|
122
|
+
profile,
|
|
123
|
+
bottlenecks: bottlenecks.filter(Boolean),
|
|
124
|
+
fixPlan,
|
|
125
|
+
benchmarks,
|
|
126
|
+
stats: { totalIssues: allIssues.length, quickWins: fixPlan.quickWins.length },
|
|
127
|
+
};
|
|
128
|
+
}
|