mindforge-cc 11.7.1 → 11.8.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/wf-accessibility-audit.md +31 -0
- package/.agent/mindforge/wf-ai-model-eval.md +31 -0
- package/.agent/mindforge/wf-api-contract-test.md +31 -0
- package/.agent/mindforge/wf-api-migration.md +31 -0
- package/.agent/mindforge/wf-architecture-modernization.md +32 -0
- package/.agent/mindforge/wf-catalog.md +25 -2
- package/.agent/mindforge/wf-code-explainer.md +31 -0
- package/.agent/mindforge/wf-competitive-teardown.md +31 -0
- package/.agent/mindforge/wf-cost-analysis.md +31 -0
- package/.agent/mindforge/wf-data-pipeline-validate.md +31 -0
- package/.agent/mindforge/wf-database-migration.md +31 -0
- package/.agent/mindforge/wf-debug-detective.md +32 -0
- package/.agent/mindforge/wf-dependency-health.md +31 -0
- package/.agent/mindforge/wf-design-system-audit.md +31 -0
- package/.agent/mindforge/wf-documentation-gen.md +31 -0
- package/.agent/mindforge/wf-multi-repo-sync.md +31 -0
- package/.agent/mindforge/wf-mutation-testing.md +31 -0
- package/.agent/mindforge/wf-security-hardening.md +32 -0
- package/.agent/mindforge/wf-security-threat-model.md +31 -0
- package/.agent/mindforge/wf-test-coverage-gap.md +31 -0
- package/.agent/mindforge/wf-ux-heuristic-audit.md +31 -0
- package/.agent/mindforge/wf-writer-reviewer.md +30 -0
- package/.claude/commands/mindforge/wf-accessibility-audit.md +31 -0
- package/.claude/commands/mindforge/wf-ai-model-eval.md +31 -0
- package/.claude/commands/mindforge/wf-api-contract-test.md +31 -0
- package/.claude/commands/mindforge/wf-api-migration.md +31 -0
- package/.claude/commands/mindforge/wf-architecture-modernization.md +32 -0
- package/.claude/commands/mindforge/wf-catalog.md +25 -2
- package/.claude/commands/mindforge/wf-code-explainer.md +31 -0
- package/.claude/commands/mindforge/wf-competitive-teardown.md +31 -0
- package/.claude/commands/mindforge/wf-cost-analysis.md +31 -0
- package/.claude/commands/mindforge/wf-data-pipeline-validate.md +31 -0
- package/.claude/commands/mindforge/wf-database-migration.md +31 -0
- package/.claude/commands/mindforge/wf-debug-detective.md +32 -0
- package/.claude/commands/mindforge/wf-dependency-health.md +31 -0
- package/.claude/commands/mindforge/wf-design-system-audit.md +31 -0
- package/.claude/commands/mindforge/wf-documentation-gen.md +31 -0
- package/.claude/commands/mindforge/wf-multi-repo-sync.md +31 -0
- package/.claude/commands/mindforge/wf-mutation-testing.md +31 -0
- package/.claude/commands/mindforge/wf-security-hardening.md +32 -0
- package/.claude/commands/mindforge/wf-security-threat-model.md +31 -0
- package/.claude/commands/mindforge/wf-test-coverage-gap.md +31 -0
- package/.claude/commands/mindforge/wf-ux-heuristic-audit.md +31 -0
- package/.claude/commands/mindforge/wf-writer-reviewer.md +30 -0
- package/.mindforge/config.json +2 -2
- package/.mindforge/dynamic-workflows/REGISTRY.md +58 -60
- package/.mindforge/dynamic-workflows/index.json +296 -0
- package/.mindforge/dynamic-workflows/scripts/accessibility-audit.js +119 -0
- package/.mindforge/dynamic-workflows/scripts/ai-model-eval.js +82 -0
- package/.mindforge/dynamic-workflows/scripts/api-contract-test.js +114 -0
- package/.mindforge/dynamic-workflows/scripts/api-migration.js +156 -0
- package/.mindforge/dynamic-workflows/scripts/architecture-modernization.js +111 -0
- package/.mindforge/dynamic-workflows/scripts/code-explainer.js +138 -0
- package/.mindforge/dynamic-workflows/scripts/competitive-teardown.js +142 -0
- package/.mindforge/dynamic-workflows/scripts/cost-analysis.js +107 -0
- package/.mindforge/dynamic-workflows/scripts/data-pipeline-validate.js +69 -0
- package/.mindforge/dynamic-workflows/scripts/database-migration.js +113 -0
- package/.mindforge/dynamic-workflows/scripts/debug-detective.js +124 -0
- package/.mindforge/dynamic-workflows/scripts/dependency-health.js +110 -0
- package/.mindforge/dynamic-workflows/scripts/design-system-audit.js +115 -0
- package/.mindforge/dynamic-workflows/scripts/documentation-gen.js +91 -0
- package/.mindforge/dynamic-workflows/scripts/multi-repo-sync.js +63 -0
- package/.mindforge/dynamic-workflows/scripts/mutation-testing.js +148 -0
- package/.mindforge/dynamic-workflows/scripts/security-hardening.js +154 -0
- package/.mindforge/dynamic-workflows/scripts/security-threat-model.js +159 -0
- package/.mindforge/dynamic-workflows/scripts/test-coverage-gap.js +95 -0
- package/.mindforge/dynamic-workflows/scripts/ux-heuristic-audit.js +122 -0
- package/.mindforge/dynamic-workflows/scripts/writer-reviewer.js +85 -0
- package/.mindforge/memory/sync-manifest.json +1 -1
- package/CHANGELOG.md +17 -0
- package/MINDFORGE.md +2 -2
- package/README.md +26 -4
- package/RELEASENOTES.md +36 -0
- package/bin/workflows/workflow-runner.js +18 -2
- package/docs/commands-reference.md +40 -14
- package/docs/getting-started.md +13 -1
- package/docs/user-guide.md +20 -1
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'code-explainer',
|
|
3
|
+
description: 'Structural map → domain extraction → architecture patterns → guided narrative tour for onboarding',
|
|
4
|
+
whenToUse: 'When onboarding a new developer, writing system documentation, or creating a guided tour of an unfamiliar codebase',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Structure', detail: 'Map file structure, entry points, and module boundaries' },
|
|
7
|
+
{ title: 'Domain', detail: 'Extract domain concepts, business logic, and key abstractions' },
|
|
8
|
+
{ title: 'Architecture', detail: 'Identify architectural patterns, data flow, and design decisions' },
|
|
9
|
+
{ title: 'Tour', detail: 'Synthesize a guided narrative tour for a new developer' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const STRUCTURE_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
entryPoints: { type: 'array', items: { type: 'string' } },
|
|
18
|
+
modules: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
items: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
name: { type: 'string' },
|
|
24
|
+
path: { type: 'string' },
|
|
25
|
+
responsibility: { type: 'string' },
|
|
26
|
+
publicApi: { type: 'array', items: { type: 'string' } },
|
|
27
|
+
},
|
|
28
|
+
required: ['name', 'path', 'responsibility'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
keyFiles: { type: 'array', items: { type: 'string' } },
|
|
32
|
+
dependencies: { type: 'array', items: { type: 'string' } },
|
|
33
|
+
},
|
|
34
|
+
required: ['entryPoints', 'modules', 'keyFiles'],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const DOMAIN_SCHEMA = {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
coreConcepts: {
|
|
41
|
+
type: 'array',
|
|
42
|
+
items: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
concept: { type: 'string' },
|
|
46
|
+
definition: { type: 'string' },
|
|
47
|
+
whereImplemented: { type: 'string' },
|
|
48
|
+
},
|
|
49
|
+
required: ['concept', 'definition'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
businessRules: { type: 'array', items: { type: 'string' } },
|
|
53
|
+
dataModels: { type: 'array', items: { type: 'string' } },
|
|
54
|
+
},
|
|
55
|
+
required: ['coreConcepts', 'businessRules'],
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const ARCHITECTURE_SCHEMA = {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
pattern: { type: 'string' },
|
|
62
|
+
dataFlow: { type: 'string' },
|
|
63
|
+
keyDesignDecisions: { type: 'array', items: { type: 'string' } },
|
|
64
|
+
integrationPoints: { type: 'array', items: { type: 'string' } },
|
|
65
|
+
gotchas: { type: 'array', items: { type: 'string' } },
|
|
66
|
+
},
|
|
67
|
+
required: ['pattern', 'dataFlow', 'keyDesignDecisions'],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const TOUR_SCHEMA = {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
summary: { type: 'string' },
|
|
74
|
+
steps: {
|
|
75
|
+
type: 'array',
|
|
76
|
+
items: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
step: { type: 'number' },
|
|
80
|
+
title: { type: 'string' },
|
|
81
|
+
fileOrConcept: { type: 'string' },
|
|
82
|
+
explanation: { type: 'string' },
|
|
83
|
+
whyItMatters: { type: 'string' },
|
|
84
|
+
},
|
|
85
|
+
required: ['step', 'title', 'explanation', 'whyItMatters'],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
firstDayChecklist: { type: 'array', items: { type: 'string' } },
|
|
89
|
+
},
|
|
90
|
+
required: ['summary', 'steps', 'firstDayChecklist'],
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const target = args || 'current codebase (run from repo root)';
|
|
94
|
+
|
|
95
|
+
phase('Structure');
|
|
96
|
+
log(`Mapping code structure for: ${target}`);
|
|
97
|
+
const structure = await agent(
|
|
98
|
+
`Map the file structure of: "${target}". Identify: (1) entry points (main files, index files, CLI entry), (2) all major modules with their path and single-line responsibility, (3) the 5-10 most important files a new developer should read first, (4) key external dependencies. Focus on what's PUBLIC — exported functions, routes, APIs.`,
|
|
99
|
+
{ schema: STRUCTURE_SCHEMA, label: 'structure' }
|
|
100
|
+
);
|
|
101
|
+
if (!structure) { log('Warning: agent returned null for structure, skipping'); return { target, error: 'agent-null' }; }
|
|
102
|
+
log(`Found ${structure.modules.length} modules, ${structure.entryPoints.length} entry points`);
|
|
103
|
+
|
|
104
|
+
phase('Domain');
|
|
105
|
+
const moduleContext = structure.modules.slice(0, 10).map(m => `${m.name} (${m.path}): ${m.responsibility}`).join('\n');
|
|
106
|
+
const domain = await agent(
|
|
107
|
+
`Extract the domain concepts and business logic from: "${target}"\n\nModules:\n${moduleContext}\n\nIdentify: (1) core business concepts and their definitions (what is a "User", "Order", "Pipeline" etc. in THIS codebase), (2) key business rules (what must always be true), (3) the main data models and their relationships. Focus on the WHAT, not the HOW.`,
|
|
108
|
+
{ schema: DOMAIN_SCHEMA, label: 'domain' }
|
|
109
|
+
);
|
|
110
|
+
if (!domain) { log('Warning: agent returned null for domain, skipping'); return { target, structure, error: 'agent-null' }; }
|
|
111
|
+
log(`${domain.coreConcepts.length} core concepts, ${domain.businessRules.length} business rules identified`);
|
|
112
|
+
|
|
113
|
+
phase('Architecture');
|
|
114
|
+
const domainContext = domain.coreConcepts.slice(0, 5).map(c => `${c.concept}: ${c.definition}`).join('\n');
|
|
115
|
+
const arch = await agent(
|
|
116
|
+
`Identify the architectural patterns in: "${target}"\n\nDomain: ${domainContext}\n\nDescribe: (1) the overall architectural pattern (MVC, CQRS, event-driven, layered, etc.), (2) how data flows through the system end-to-end, (3) the top 3-5 key design decisions and WHY they were made, (4) integration points with external systems, (5) gotchas and non-obvious behaviors a new developer must know.`,
|
|
117
|
+
{ schema: ARCHITECTURE_SCHEMA, label: 'architecture' }
|
|
118
|
+
);
|
|
119
|
+
if (!arch) { log('Warning: agent returned null for arch, skipping'); return { target, structure, domain, error: 'agent-null' }; }
|
|
120
|
+
log(`Architecture: ${arch.pattern}`);
|
|
121
|
+
|
|
122
|
+
phase('Tour');
|
|
123
|
+
const tourContext = `
|
|
124
|
+
Structure: ${structure.entryPoints.length} entry points, ${structure.modules.length} modules
|
|
125
|
+
Key files: ${structure.keyFiles.slice(0, 5).join(', ')}
|
|
126
|
+
Pattern: ${arch.pattern}
|
|
127
|
+
Data flow: ${arch.dataFlow}
|
|
128
|
+
Core concepts: ${domain.coreConcepts.slice(0, 4).map(c => c.concept).join(', ')}
|
|
129
|
+
Gotchas: ${(arch.gotchas || []).slice(0, 3).join('; ')}
|
|
130
|
+
`.trim();
|
|
131
|
+
|
|
132
|
+
const tour = await agent(
|
|
133
|
+
`Create a guided narrative tour of: "${target}" for a developer joining the team today.\n\n${tourContext}\n\nWrite 6-10 sequential steps that progressively reveal the codebase. Each step: a clear title, which file/concept to look at, plain-English explanation, and WHY it matters. Start with the entry point, build to the domain, then reveal the architecture. End with a "first day" checklist of things to read and run.`,
|
|
134
|
+
{ schema: TOUR_SCHEMA, label: 'tour' }
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return { target, structure, domain, arch, tour };
|
|
138
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'competitive-teardown',
|
|
3
|
+
description: '5 parallel competitor angle agents → pipeline synthesis into competitive positioning report',
|
|
4
|
+
whenToUse: 'When doing competitive research before a product launch, pricing decision, or strategy review',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Scope', detail: 'Identify competitors and define evaluation framework' },
|
|
7
|
+
{ title: 'Research', detail: '5 parallel competitor angle agents: product/tech/pricing/hiring/community' },
|
|
8
|
+
{ title: 'Analyze', detail: 'Synthesize competitive landscape from all angles' },
|
|
9
|
+
{ title: 'Synthesis', detail: 'Competitive positioning report with differentiation opportunities' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const SCOPE_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
productDescription: { type: 'string' },
|
|
18
|
+
competitors: { type: 'array', items: { type: 'string' } },
|
|
19
|
+
evaluationDimensions: { type: 'array', items: { type: 'string' } },
|
|
20
|
+
targetMarket: { type: 'string' },
|
|
21
|
+
},
|
|
22
|
+
required: ['productDescription', 'competitors', 'targetMarket'],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ANGLE_SCHEMA = {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
angle: { type: 'string' },
|
|
29
|
+
findings: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
items: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
competitor: { type: 'string' },
|
|
35
|
+
insight: { type: 'string' },
|
|
36
|
+
strength: { type: 'string' },
|
|
37
|
+
weakness: { type: 'string' },
|
|
38
|
+
signal: { type: 'string' },
|
|
39
|
+
},
|
|
40
|
+
required: ['competitor', 'insight'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
keyTakeaway: { type: 'string' },
|
|
44
|
+
},
|
|
45
|
+
required: ['angle', 'findings', 'keyTakeaway'],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const ANALYSIS_SCHEMA = {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
competitorProfiles: {
|
|
52
|
+
type: 'array',
|
|
53
|
+
items: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
name: { type: 'string' },
|
|
57
|
+
summary: { type: 'string' },
|
|
58
|
+
keyStrengths: { type: 'array', items: { type: 'string' } },
|
|
59
|
+
keyWeaknesses: { type: 'array', items: { type: 'string' } },
|
|
60
|
+
threatLevel: { type: 'string', enum: ['high', 'medium', 'low'] },
|
|
61
|
+
},
|
|
62
|
+
required: ['name', 'summary', 'keyStrengths', 'keyWeaknesses', 'threatLevel'],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
marketDynamics: { type: 'string' },
|
|
66
|
+
},
|
|
67
|
+
required: ['competitorProfiles', 'marketDynamics'],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const SYNTHESIS_SCHEMA = {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
executiveSummary: { type: 'string' },
|
|
74
|
+
competitivePosition: { type: 'string', enum: ['leader', 'challenger', 'follower', 'nicher'] },
|
|
75
|
+
differentiationOpportunities: {
|
|
76
|
+
type: 'array',
|
|
77
|
+
items: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
opportunity: { type: 'string' },
|
|
81
|
+
dimension: { type: 'string' },
|
|
82
|
+
confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
|
|
83
|
+
actionable: { type: 'string' },
|
|
84
|
+
},
|
|
85
|
+
required: ['opportunity', 'dimension', 'actionable'],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
threatsToWatch: { type: 'array', items: { type: 'string' } },
|
|
89
|
+
strategicRecommendations: { type: 'array', items: { type: 'string' } },
|
|
90
|
+
},
|
|
91
|
+
required: ['executiveSummary', 'competitivePosition', 'differentiationOpportunities', 'strategicRecommendations'],
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const target = args || 'current product (describe your product and list competitors in args)';
|
|
95
|
+
|
|
96
|
+
phase('Scope');
|
|
97
|
+
log(`Competitive teardown for: ${target}`);
|
|
98
|
+
const scope = await agent(
|
|
99
|
+
`Define the competitive landscape for: "${target}". Identify: (1) a concise description of the product/service being analyzed, (2) the top 3-5 direct competitors, (3) key evaluation dimensions for this market, (4) the target market and customer segment. If competitors are not specified in the input, infer them from the product description.`,
|
|
100
|
+
{ schema: SCOPE_SCHEMA, label: 'scope' }
|
|
101
|
+
);
|
|
102
|
+
if (!scope) { log('Warning: agent returned null for scope, skipping'); return { target, error: 'agent-null' }; }
|
|
103
|
+
log(`Analyzing ${scope.competitors.length} competitors: ${scope.competitors.join(', ')}`);
|
|
104
|
+
|
|
105
|
+
const competitorList = scope.competitors.join(', ');
|
|
106
|
+
const productCtx = `Product: ${scope.productDescription} | Market: ${scope.targetMarket}`;
|
|
107
|
+
|
|
108
|
+
phase('Research');
|
|
109
|
+
const ANGLES = [
|
|
110
|
+
{ label: 'product-features', prompt: `Analyze PRODUCT FEATURES AND UX for these competitors in the context of: "${target}". ${productCtx}. Competitors: ${competitorList}. For each: key features, UX quality, product gaps, what users love/hate (based on known reviews/feedback). What are the feature differentiators?` },
|
|
111
|
+
{ label: 'technical-architecture', prompt: `Analyze TECHNICAL ARCHITECTURE AND STACK for: ${competitorList}. Context: "${target}". ${productCtx}. For each: known tech stack, scalability approach, API availability, integration ecosystem, technical moat (patents, proprietary tech, network effects). What technical signals suggest future direction?` },
|
|
112
|
+
{ label: 'pricing-model', prompt: `Analyze PRICING MODELS for: ${competitorList}. Context: "${target}". ${productCtx}. For each: pricing tiers, free/trial offering, enterprise vs SMB focus, pricing transparency, value metric (per seat/usage/feature). What pricing patterns dominate? Where are the gaps?` },
|
|
113
|
+
{ label: 'hiring-signals', prompt: `Analyze HIRING SIGNALS for: ${competitorList}. Context: "${target}". ${productCtx}. For each: recent job postings patterns (what roles they're hiring = what they're building), team growth trajectory, key hires/departures, which teams are expanding. What does hiring signal about product roadmap?` },
|
|
114
|
+
{ label: 'community-ecosystem', prompt: `Analyze COMMUNITY AND ECOSYSTEM for: ${competitorList}. Context: "${target}". ${productCtx}. For each: community size and engagement (GitHub stars, Discord/Slack, forum activity), developer ecosystem (integrations, plugins, APIs), content marketing, thought leadership, NPS signals. Who has the strongest ecosystem moat?` },
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
const angleResults = await parallel(
|
|
118
|
+
ANGLES.map(a => () => agent(a.prompt, { schema: ANGLE_SCHEMA, label: `angle:${a.label}`, phase: 'Research' }))
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
phase('Analyze');
|
|
122
|
+
const validAngles = angleResults.filter(Boolean);
|
|
123
|
+
const angleSummary = validAngles.map(a => `${a.angle}: ${a.keyTakeaway}`).join('\n');
|
|
124
|
+
|
|
125
|
+
const analysis = await agent(
|
|
126
|
+
`Synthesize competitive profiles for: "${target}"\n\nCompetitors: ${competitorList}\n\nAngle summaries:\n${angleSummary}\n\nFor each competitor: 2-sentence summary, top 3 strengths, top 3 weaknesses, and threat level (high/medium/low) to our product. Describe overall market dynamics.`,
|
|
127
|
+
{ schema: ANALYSIS_SCHEMA, label: 'analyze' }
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
if (!analysis) { log('Warning: agent returned null for analysis, skipping'); return { target, error: 'agent-null' }; }
|
|
131
|
+
phase('Synthesis');
|
|
132
|
+
const profileSummary = analysis.competitorProfiles.map(p => `${p.name} (threat=${p.threatLevel}): strengths=[${p.keyStrengths.slice(0, 2).join(', ')}] weaknesses=[${p.keyWeaknesses.slice(0, 2).join(', ')}]`).join('\n');
|
|
133
|
+
|
|
134
|
+
const synthesis = await pipeline([
|
|
135
|
+
() => agent(
|
|
136
|
+
`Create a competitive positioning report for: "${target}"\n\n${productCtx}\n\nCompetitor profiles:\n${profileSummary}\n\nMarket dynamics: ${analysis.marketDynamics}\n\nAngle takeaways:\n${angleSummary}\n\nProvide: executive summary, competitive position (leader/challenger/follower/nicher), top 3-5 differentiation opportunities with confidence and actionable next steps, key threats to monitor, and 3-5 strategic recommendations.`,
|
|
137
|
+
{ schema: SYNTHESIS_SCHEMA, label: 'synthesis' }
|
|
138
|
+
),
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
return { target, scope, angles: validAngles, analysis, synthesis };
|
|
142
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'cost-analysis',
|
|
3
|
+
description: 'Parallel infra/API/query/bundle cost agents → reduction plan with ROI estimates',
|
|
4
|
+
whenToUse: 'When auditing and reducing operational costs across infrastructure, API calls, database, and frontend bundle',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Scope', detail: 'Identify cost centers and establish current baseline' },
|
|
7
|
+
{ title: 'Analyze', detail: '4 parallel cost dimension agents: infra / API / database / bundle' },
|
|
8
|
+
{ title: 'Model', detail: 'Cost model with reduction opportunities and ROI estimates' },
|
|
9
|
+
{ title: 'Plan', detail: 'Prioritized cost reduction plan with implementation steps' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const SCOPE_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
costCenters: { type: 'array', items: { type: 'string' } },
|
|
18
|
+
estimatedMonthlyCost: { type: 'string' },
|
|
19
|
+
primaryTechnology: { type: 'string' },
|
|
20
|
+
},
|
|
21
|
+
required: ['costCenters', 'primaryTechnology'],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const COST_DIM_SCHEMA = {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
dimension: { type: 'string' },
|
|
28
|
+
currentEstimate: { type: 'string' },
|
|
29
|
+
findings: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
items: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
item: { type: 'string' },
|
|
35
|
+
currentCost: { type: 'string' },
|
|
36
|
+
wasteType: { type: 'string', enum: ['over-provisioning', 'idle-resource', 'inefficient-query', 'unused-api', 'large-bundle', 'redundant-call', 'other'] },
|
|
37
|
+
potentialSaving: { type: 'string' },
|
|
38
|
+
fix: { type: 'string' },
|
|
39
|
+
},
|
|
40
|
+
required: ['item', 'wasteType', 'potentialSaving', 'fix'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['dimension', 'findings'],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const PLAN_SCHEMA = {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
summary: { type: 'string' },
|
|
51
|
+
totalEstimatedSaving: { type: 'string' },
|
|
52
|
+
reductionItems: {
|
|
53
|
+
type: 'array',
|
|
54
|
+
items: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
action: { type: 'string' },
|
|
58
|
+
dimension: { type: 'string' },
|
|
59
|
+
monthlySaving: { type: 'string' },
|
|
60
|
+
effort: { type: 'string', enum: ['low', 'medium', 'high'] },
|
|
61
|
+
roi: { type: 'string' },
|
|
62
|
+
priority: { type: 'string', enum: ['p0', 'p1', 'p2'] },
|
|
63
|
+
},
|
|
64
|
+
required: ['action', 'dimension', 'monthlySaving', 'effort', 'priority'],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
required: ['summary', 'totalEstimatedSaving', 'reductionItems'],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const target = args || 'current codebase (run from repo root)';
|
|
72
|
+
|
|
73
|
+
phase('Scope');
|
|
74
|
+
log(`Cost analysis target: ${target}`);
|
|
75
|
+
const scope = await agent(
|
|
76
|
+
`Identify the cost centers and technology stack for: "${target}". What cloud provider, databases, third-party APIs, and frontend framework are used? Estimate the primary monthly cost categories (infra, API calls, database, frontend delivery).`,
|
|
77
|
+
{ schema: SCOPE_SCHEMA, label: 'scope' }
|
|
78
|
+
);
|
|
79
|
+
if (!scope) { log('Warning: agent returned null for scope, skipping'); return { target, error: 'agent-null' }; }
|
|
80
|
+
log(`Cost centers: ${scope.costCenters.join(', ')}`);
|
|
81
|
+
|
|
82
|
+
phase('Analyze');
|
|
83
|
+
const DIMENSIONS = [
|
|
84
|
+
{ label: 'infrastructure', prompt: `Analyze INFRASTRUCTURE costs for: "${target}" (${scope.primaryTechnology}). Look for: over-provisioned compute (instances larger than needed), idle resources (unused databases, VMs, load balancers), storage waste (old snapshots, unused volumes), network egress inefficiencies, cold-start penalties on serverless. Estimate current spend and potential savings per item.` },
|
|
85
|
+
{ label: 'api-costs', prompt: `Analyze THIRD-PARTY API costs for: "${target}". Look for: excessive LLM/AI API calls (missing caching, redundant calls), payment provider fees that could be reduced, over-calling external APIs when local cache would suffice, unused API subscriptions, inefficient batch vs single calls. Estimate current spend and potential savings.` },
|
|
86
|
+
{ label: 'database-query', prompt: `Analyze DATABASE QUERY costs for: "${target}". Look for: N+1 queries (fetching rows in a loop), missing indexes on WHERE/JOIN/ORDER BY columns, SELECT * where only a few columns are needed, unbounded queries without LIMIT, expensive full-table scans, redundant queries that could be cached. Estimate compute cost impact and savings.` },
|
|
87
|
+
{ label: 'bundle-runtime', prompt: `Analyze BUNDLE AND RUNTIME OVERHEAD costs for: "${target}". Look for: large JS bundles (over 500KB) increasing CDN bandwidth costs, unoptimized images (missing WebP, no lazy loading), missing HTTP cache headers causing repeat downloads, unused dependencies inflating bundle size, missing code splitting. Estimate bandwidth/CDN cost impact.` },
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
const dimResults = await parallel(
|
|
91
|
+
DIMENSIONS.map(d => () => agent(d.prompt, { schema: COST_DIM_SCHEMA, label: `cost:${d.label}`, phase: 'Analyze' }))
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
phase('Model');
|
|
95
|
+
const allFindings = dimResults.filter(Boolean).flatMap(d => d.findings.map(f => ({ dimension: d.dimension, ...f })));
|
|
96
|
+
log(`${allFindings.length} cost findings across 4 dimensions`);
|
|
97
|
+
|
|
98
|
+
phase('Plan');
|
|
99
|
+
const findingSummary = allFindings.slice(0, 20).map(f => `[${f.dimension}/${f.wasteType}] ${f.item}: save ${f.potentialSaving} — ${f.fix}`).join('\n');
|
|
100
|
+
const plan = await agent(
|
|
101
|
+
`Create a cost reduction plan for: "${target}"\n\nCost findings:\n${findingSummary}\n\nPrioritize by: P0=quick wins with high savings (low effort, >$500/mo), P1=high savings medium effort, P2=nice-to-have. For each item estimate monthly saving, implementation effort, and ROI timeframe. Calculate total estimated monthly saving.`,
|
|
102
|
+
{ schema: PLAN_SCHEMA, label: 'plan' }
|
|
103
|
+
);
|
|
104
|
+
if (!plan) { return { target, scope, dimResults: dimResults.filter(Boolean), error: 'plan-agent-null' }; }
|
|
105
|
+
|
|
106
|
+
return { target, scope, dimResults: dimResults.filter(Boolean), plan };
|
|
107
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'data-pipeline-validate',
|
|
3
|
+
description: 'Pipeline stage-by-stage validation → data quality gates → anomaly detection report',
|
|
4
|
+
whenToUse: 'When validating a data pipeline for correctness, completeness, and quality before production use',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'Map', detail: 'Map all pipeline stages from source to sink' },
|
|
7
|
+
{ title: 'Validate', detail: 'Parallel validation per stage (schema / completeness / transforms / outputs)' },
|
|
8
|
+
{ title: 'Quality', detail: 'Data quality gate assessment — freshness, completeness, consistency' },
|
|
9
|
+
{ title: 'Report', detail: 'Validation report with stage health scores and fix recommendations' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const PIPELINE_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
stages: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, type: { type: 'string', enum: ['source', 'transform', 'enrich', 'filter', 'aggregate', 'sink'] }, input: { type: 'string' }, output: { type: 'string' } }, required: ['name', 'type'] } },
|
|
18
|
+
pipelineName: { type: 'string' },
|
|
19
|
+
},
|
|
20
|
+
required: ['stages', 'pipelineName'],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const STAGE_SCHEMA = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
stage: { type: 'string' },
|
|
27
|
+
issues: { type: 'array', items: { type: 'object', properties: { severity: { type: 'string', enum: ['critical', 'high', 'medium', 'low'] }, category: { type: 'string' }, description: { type: 'string' }, fix: { type: 'string' } }, required: ['severity', 'category', 'description', 'fix'] } },
|
|
28
|
+
healthScore: { type: 'number' },
|
|
29
|
+
},
|
|
30
|
+
required: ['stage', 'issues', 'healthScore'],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const REPORT_SCHEMA = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
overallHealth: { type: 'string', enum: ['healthy', 'degraded', 'critical', 'failing'] },
|
|
37
|
+
summary: { type: 'string' },
|
|
38
|
+
criticalIssues: { type: 'array', items: { type: 'string' } },
|
|
39
|
+
recommendations: { type: 'array', items: { type: 'string' } },
|
|
40
|
+
},
|
|
41
|
+
required: ['overallHealth', 'summary', 'criticalIssues', 'recommendations'],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const target = args || 'current data pipeline (run from pipeline directory)';
|
|
45
|
+
|
|
46
|
+
phase('Map');
|
|
47
|
+
const pipelineMap = await agent(`Map all stages of the data pipeline in: "${target}". Identify each stage by name, type (source/transform/enrich/filter/aggregate/sink), its input data source, and output. List them in execution order.`, { schema: PIPELINE_SCHEMA, label: 'map' });
|
|
48
|
+
if (!pipelineMap) { log('Warning: agent returned null for pipelineMap, skipping'); return { target, error: 'agent-null' }; }
|
|
49
|
+
log(`Pipeline: ${pipelineMap.pipelineName} — ${pipelineMap.stages.length} stages`);
|
|
50
|
+
|
|
51
|
+
phase('Validate');
|
|
52
|
+
const validations = await parallel(
|
|
53
|
+
pipelineMap.stages.map(s => () => agent(
|
|
54
|
+
`Validate pipeline stage "${s.name}" (${s.type}) in: "${target}". Check: (1) schema validation — correct data types, required fields present, (2) completeness — no unexpected nulls or missing records, (3) transform correctness — business rules applied correctly, (4) output contracts — downstream consumers will receive expected format. Rate each issue critical/high/medium/low.`,
|
|
55
|
+
{ schema: STAGE_SCHEMA, label: `validate:${s.name}`, phase: 'Validate' }
|
|
56
|
+
))
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
phase('Quality');
|
|
60
|
+
const stageScores = validations.filter(Boolean).map(v => `${v.stage}: ${v.healthScore}/100`).join(', ');
|
|
61
|
+
log(`Stage health: ${stageScores}`);
|
|
62
|
+
|
|
63
|
+
phase('Report');
|
|
64
|
+
const issueList = validations.filter(Boolean).flatMap(v => v.issues.map(i => `[${v.stage}/${i.severity}] ${i.description}`)).slice(0, 15);
|
|
65
|
+
const report = await agent(`Create a data pipeline validation report for: "${target}"\n\nStage health scores: ${stageScores}\n\nIssues found:\n${issueList.join('\n')}\n\nDetermine overall pipeline health, list critical issues, and provide prioritized recommendations.`, { schema: REPORT_SCHEMA, label: 'report' });
|
|
66
|
+
if (!report) { return { target, pipelineMap, validations: validations.filter(Boolean), error: 'report-agent-null' }; }
|
|
67
|
+
|
|
68
|
+
return { target, pipelineMap, validations: validations.filter(Boolean), report };
|
|
69
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export const meta = {
|
|
2
|
+
name: 'database-migration',
|
|
3
|
+
description: 'Schema diff → risk analysis → migration scripts → rollback plan',
|
|
4
|
+
whenToUse: 'When planning or reviewing a database schema migration — adding columns, changing types, dropping tables',
|
|
5
|
+
phases: [
|
|
6
|
+
{ title: 'SchemaDiff', detail: 'Parse current and target schema, compute structural diff' },
|
|
7
|
+
{ title: 'RiskAnalysis', detail: 'Assess data loss risk, locking impact, and rollback complexity' },
|
|
8
|
+
{ title: 'Scripts', detail: 'Generate forward migration + rollback scripts' },
|
|
9
|
+
{ title: 'Runbook', detail: 'Step-by-step production runbook with verification checks' },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
|
|
14
|
+
const DIFF_SCHEMA = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
changes: {
|
|
18
|
+
type: 'array',
|
|
19
|
+
items: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
type: { type: 'string', enum: ['add_table', 'drop_table', 'add_column', 'drop_column', 'change_type', 'add_index', 'drop_index', 'add_constraint', 'drop_constraint'] },
|
|
23
|
+
table: { type: 'string' },
|
|
24
|
+
column: { type: 'string' },
|
|
25
|
+
from: { type: 'string' },
|
|
26
|
+
to: { type: 'string' },
|
|
27
|
+
notes: { type: 'string' },
|
|
28
|
+
},
|
|
29
|
+
required: ['type', 'table'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
database: { type: 'string' },
|
|
33
|
+
},
|
|
34
|
+
required: ['changes', 'database'],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const RISK_SCHEMA = {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
overallRisk: { type: 'string', enum: ['critical', 'high', 'medium', 'low'] },
|
|
41
|
+
risks: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
change: { type: 'string' },
|
|
47
|
+
risk: { type: 'string' },
|
|
48
|
+
severity: { type: 'string', enum: ['critical', 'high', 'medium', 'low'] },
|
|
49
|
+
mitigation: { type: 'string' },
|
|
50
|
+
},
|
|
51
|
+
required: ['change', 'risk', 'severity', 'mitigation'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
requiresMaintenanceWindow: { type: 'boolean' },
|
|
55
|
+
estimatedLockDuration: { type: 'string' },
|
|
56
|
+
},
|
|
57
|
+
required: ['overallRisk', 'risks', 'requiresMaintenanceWindow'],
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const SCRIPTS_SCHEMA = {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
forwardMigration: { type: 'string' },
|
|
64
|
+
rollbackMigration: { type: 'string' },
|
|
65
|
+
verificationQueries: { type: 'array', items: { type: 'string' } },
|
|
66
|
+
},
|
|
67
|
+
required: ['forwardMigration', 'rollbackMigration', 'verificationQueries'],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const RUNBOOK_SCHEMA = {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
preChecks: { type: 'array', items: { type: 'string' } },
|
|
74
|
+
steps: { type: 'array', items: { type: 'object', properties: { step: { type: 'number' }, action: { type: 'string' }, command: { type: 'string' }, rollbackIf: { type: 'string' } }, required: ['step', 'action'] } },
|
|
75
|
+
postChecks: { type: 'array', items: { type: 'string' } },
|
|
76
|
+
rollbackProcedure: { type: 'string' },
|
|
77
|
+
},
|
|
78
|
+
required: ['preChecks', 'steps', 'postChecks', 'rollbackProcedure'],
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const target = args || 'current migration files (provide schema diff or migration directory as args)';
|
|
82
|
+
|
|
83
|
+
phase('SchemaDiff');
|
|
84
|
+
log(`Analyzing schema migration for: ${target}`);
|
|
85
|
+
const diff = await agent(
|
|
86
|
+
`Parse the database schema migration in: "${target}". Identify all schema changes: tables added/dropped, columns added/dropped/renamed, type changes, index changes, constraint changes. Identify the database type (PostgreSQL, MySQL, SQLite, etc.).`,
|
|
87
|
+
{ schema: DIFF_SCHEMA, label: 'schema-diff' }
|
|
88
|
+
);
|
|
89
|
+
if (!diff) { log('Warning: agent returned null for diff, skipping'); return { target, error: 'agent-null' }; }
|
|
90
|
+
log(`${diff.changes.length} schema changes in ${diff.database}`);
|
|
91
|
+
|
|
92
|
+
phase('RiskAnalysis');
|
|
93
|
+
const [risks, scripts] = await parallel([
|
|
94
|
+
() => agent(
|
|
95
|
+
`Assess the production risk of this database migration on ${diff.database}: ${diff.changes.map(c => `${c.type} on ${c.table}${c.column ? '.' + c.column : ''}`).join(', ')}. For each change identify: data loss risk, lock duration, rollback complexity. Does this require a maintenance window? What's the overall risk level?`,
|
|
96
|
+
{ schema: RISK_SCHEMA, label: 'risk-analysis', phase: 'RiskAnalysis' }
|
|
97
|
+
),
|
|
98
|
+
() => agent(
|
|
99
|
+
`Generate migration scripts for ${diff.database} with these changes: ${diff.changes.map(c => `${c.type} on ${c.table}`).join(', ')}. Write: (1) forward migration SQL, (2) rollback SQL that fully reverses the changes, (3) verification queries to confirm success. Use safe patterns: IF NOT EXISTS, transactions, backfill before NOT NULL, etc.`,
|
|
100
|
+
{ schema: SCRIPTS_SCHEMA, label: 'scripts', phase: 'RiskAnalysis' }
|
|
101
|
+
),
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
if (!risks) { log('Warning: agent returned null for risks, skipping'); return { target, diff, error: 'agent-null' }; }
|
|
105
|
+
phase('Runbook');
|
|
106
|
+
const runbook = await agent(
|
|
107
|
+
`Create a production deployment runbook for this ${diff.database} migration.\n\nChanges: ${diff.changes.map(c => `${c.type} on ${c.table}`).join(', ')}\nRisk: ${risks.overallRisk} — maintenance window required: ${risks.requiresMaintenanceWindow}\nTop risks: ${risks.risks.slice(0, 3).map(r => r.risk).join(', ')}\n\nInclude: pre-migration checks, numbered execution steps with exact commands and rollback conditions per step, post-migration verification, and complete rollback procedure.`,
|
|
108
|
+
{ schema: RUNBOOK_SCHEMA, label: 'runbook' }
|
|
109
|
+
);
|
|
110
|
+
if (!runbook) { return { target, diff, risks, scripts, error: 'runbook-agent-null' }; }
|
|
111
|
+
|
|
112
|
+
return { target, diff, risks, scripts, runbook };
|
|
113
|
+
}
|