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.
Files changed (78) hide show
  1. package/.agent/mindforge/wf-accessibility-audit.md +31 -0
  2. package/.agent/mindforge/wf-ai-model-eval.md +31 -0
  3. package/.agent/mindforge/wf-api-contract-test.md +31 -0
  4. package/.agent/mindforge/wf-api-migration.md +31 -0
  5. package/.agent/mindforge/wf-architecture-modernization.md +32 -0
  6. package/.agent/mindforge/wf-catalog.md +25 -2
  7. package/.agent/mindforge/wf-code-explainer.md +31 -0
  8. package/.agent/mindforge/wf-competitive-teardown.md +31 -0
  9. package/.agent/mindforge/wf-cost-analysis.md +31 -0
  10. package/.agent/mindforge/wf-data-pipeline-validate.md +31 -0
  11. package/.agent/mindforge/wf-database-migration.md +31 -0
  12. package/.agent/mindforge/wf-debug-detective.md +32 -0
  13. package/.agent/mindforge/wf-dependency-health.md +31 -0
  14. package/.agent/mindforge/wf-design-system-audit.md +31 -0
  15. package/.agent/mindforge/wf-documentation-gen.md +31 -0
  16. package/.agent/mindforge/wf-multi-repo-sync.md +31 -0
  17. package/.agent/mindforge/wf-mutation-testing.md +31 -0
  18. package/.agent/mindforge/wf-security-hardening.md +32 -0
  19. package/.agent/mindforge/wf-security-threat-model.md +31 -0
  20. package/.agent/mindforge/wf-test-coverage-gap.md +31 -0
  21. package/.agent/mindforge/wf-ux-heuristic-audit.md +31 -0
  22. package/.agent/mindforge/wf-writer-reviewer.md +30 -0
  23. package/.claude/commands/mindforge/wf-accessibility-audit.md +31 -0
  24. package/.claude/commands/mindforge/wf-ai-model-eval.md +31 -0
  25. package/.claude/commands/mindforge/wf-api-contract-test.md +31 -0
  26. package/.claude/commands/mindforge/wf-api-migration.md +31 -0
  27. package/.claude/commands/mindforge/wf-architecture-modernization.md +32 -0
  28. package/.claude/commands/mindforge/wf-catalog.md +25 -2
  29. package/.claude/commands/mindforge/wf-code-explainer.md +31 -0
  30. package/.claude/commands/mindforge/wf-competitive-teardown.md +31 -0
  31. package/.claude/commands/mindforge/wf-cost-analysis.md +31 -0
  32. package/.claude/commands/mindforge/wf-data-pipeline-validate.md +31 -0
  33. package/.claude/commands/mindforge/wf-database-migration.md +31 -0
  34. package/.claude/commands/mindforge/wf-debug-detective.md +32 -0
  35. package/.claude/commands/mindforge/wf-dependency-health.md +31 -0
  36. package/.claude/commands/mindforge/wf-design-system-audit.md +31 -0
  37. package/.claude/commands/mindforge/wf-documentation-gen.md +31 -0
  38. package/.claude/commands/mindforge/wf-multi-repo-sync.md +31 -0
  39. package/.claude/commands/mindforge/wf-mutation-testing.md +31 -0
  40. package/.claude/commands/mindforge/wf-security-hardening.md +32 -0
  41. package/.claude/commands/mindforge/wf-security-threat-model.md +31 -0
  42. package/.claude/commands/mindforge/wf-test-coverage-gap.md +31 -0
  43. package/.claude/commands/mindforge/wf-ux-heuristic-audit.md +31 -0
  44. package/.claude/commands/mindforge/wf-writer-reviewer.md +30 -0
  45. package/.mindforge/config.json +2 -2
  46. package/.mindforge/dynamic-workflows/REGISTRY.md +58 -60
  47. package/.mindforge/dynamic-workflows/index.json +296 -0
  48. package/.mindforge/dynamic-workflows/scripts/accessibility-audit.js +119 -0
  49. package/.mindforge/dynamic-workflows/scripts/ai-model-eval.js +82 -0
  50. package/.mindforge/dynamic-workflows/scripts/api-contract-test.js +114 -0
  51. package/.mindforge/dynamic-workflows/scripts/api-migration.js +156 -0
  52. package/.mindforge/dynamic-workflows/scripts/architecture-modernization.js +111 -0
  53. package/.mindforge/dynamic-workflows/scripts/code-explainer.js +138 -0
  54. package/.mindforge/dynamic-workflows/scripts/competitive-teardown.js +142 -0
  55. package/.mindforge/dynamic-workflows/scripts/cost-analysis.js +107 -0
  56. package/.mindforge/dynamic-workflows/scripts/data-pipeline-validate.js +69 -0
  57. package/.mindforge/dynamic-workflows/scripts/database-migration.js +113 -0
  58. package/.mindforge/dynamic-workflows/scripts/debug-detective.js +124 -0
  59. package/.mindforge/dynamic-workflows/scripts/dependency-health.js +110 -0
  60. package/.mindforge/dynamic-workflows/scripts/design-system-audit.js +115 -0
  61. package/.mindforge/dynamic-workflows/scripts/documentation-gen.js +91 -0
  62. package/.mindforge/dynamic-workflows/scripts/multi-repo-sync.js +63 -0
  63. package/.mindforge/dynamic-workflows/scripts/mutation-testing.js +148 -0
  64. package/.mindforge/dynamic-workflows/scripts/security-hardening.js +154 -0
  65. package/.mindforge/dynamic-workflows/scripts/security-threat-model.js +159 -0
  66. package/.mindforge/dynamic-workflows/scripts/test-coverage-gap.js +95 -0
  67. package/.mindforge/dynamic-workflows/scripts/ux-heuristic-audit.js +122 -0
  68. package/.mindforge/dynamic-workflows/scripts/writer-reviewer.js +85 -0
  69. package/.mindforge/memory/sync-manifest.json +1 -1
  70. package/CHANGELOG.md +17 -0
  71. package/MINDFORGE.md +2 -2
  72. package/README.md +26 -4
  73. package/RELEASENOTES.md +36 -0
  74. package/bin/workflows/workflow-runner.js +18 -2
  75. package/docs/commands-reference.md +40 -14
  76. package/docs/getting-started.md +13 -1
  77. package/docs/user-guide.md +20 -1
  78. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ export const meta = {
2
+ name: 'accessibility-audit',
3
+ description: 'WCAG 2.2 parallel per-criterion audit → 3-vote adversarial verify failures → remediation spec',
4
+ whenToUse: 'When auditing a UI for WCAG 2.2 compliance before launch, legal review, or accessibility certification',
5
+ phases: [
6
+ { title: 'Scope', detail: 'Define target UI and map components/pages to audit' },
7
+ { title: 'Audit', detail: '6 parallel WCAG principle auditors (Perceivable/Operable/Understandable/Robust + ARIA + Keyboard)' },
8
+ { title: 'Verify', detail: '3-vote adversarial verification of all Level A and AA failures' },
9
+ { title: 'Spec', detail: 'Remediation spec with exact ARIA attributes, HTML fixes, and WCAG references' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const AUDIT_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ principle: { type: 'string' },
18
+ issues: {
19
+ type: 'array',
20
+ items: {
21
+ type: 'object',
22
+ properties: {
23
+ wcagCriterion: { type: 'string' },
24
+ level: { type: 'string', enum: ['A', 'AA', 'AAA'] },
25
+ severity: { type: 'string', enum: ['blocker', 'critical', 'major', 'minor'] },
26
+ component: { type: 'string' },
27
+ description: { type: 'string' },
28
+ fix: { type: 'string' },
29
+ },
30
+ required: ['wcagCriterion', 'level', 'severity', 'description', 'fix'],
31
+ },
32
+ },
33
+ },
34
+ required: ['principle', 'issues'],
35
+ };
36
+
37
+ const VERDICT_SCHEMA = {
38
+ type: 'object',
39
+ properties: {
40
+ isRealIssue: { type: 'boolean' },
41
+ affectsRealUsers: { type: 'boolean' },
42
+ reason: { type: 'string' },
43
+ },
44
+ required: ['isRealIssue', 'affectsRealUsers', 'reason'],
45
+ };
46
+
47
+ const REMEDIATION_SCHEMA = {
48
+ type: 'object',
49
+ properties: {
50
+ summary: { type: 'string' },
51
+ wcagLevel: { type: 'string', enum: ['Level A non-compliant', 'Level AA non-compliant', 'Level AA compliant', 'Level AAA compliant'] },
52
+ criticalFixes: {
53
+ type: 'array',
54
+ items: {
55
+ type: 'object',
56
+ properties: {
57
+ issue: { type: 'string' },
58
+ wcagRef: { type: 'string' },
59
+ fix: { type: 'string' },
60
+ codeExample: { type: 'string' },
61
+ },
62
+ required: ['issue', 'wcagRef', 'fix', 'codeExample'],
63
+ },
64
+ },
65
+ },
66
+ required: ['summary', 'wcagLevel', 'criticalFixes'],
67
+ };
68
+
69
+ const target = args || 'current UI codebase (run from repo root)';
70
+
71
+ phase('Scope');
72
+ log(`Accessibility audit target: ${target}`);
73
+
74
+ const AUDITORS = [
75
+ { label: 'perceivable', prompt: `Audit WCAG 2.2 Perceivable criteria for: "${target}". Check: 1.1.1 Non-text content (alt text), 1.2.x captions/transcripts, 1.3.x info/structure (semantic HTML, labels), 1.4.x distinguishable (contrast ratio ≥4.5:1, resize text, no reliance on color alone). List every failure with WCAG criterion, level (A/AA/AAA), severity, and exact fix.` },
76
+ { label: 'operable', prompt: `Audit WCAG 2.2 Operable criteria for: "${target}". Check: 2.1.x keyboard accessible (all functionality via keyboard, no traps), 2.2.x enough time (no time limits, pause/stop/hide), 2.3.x seizures (no flashing ≥3Hz), 2.4.x navigable (skip links, page titles, focus order, link purpose), 2.5.x input modalities (touch target ≥24×24px). List every failure with criterion, level, and fix.` },
77
+ { label: 'understandable', prompt: `Audit WCAG 2.2 Understandable criteria for: "${target}". Check: 3.1.x readable (lang attribute, unusual words), 3.2.x predictable (no context changes on focus, consistent navigation), 3.3.x input assistance (error identification, labels/instructions, error suggestion, error prevention). List every failure with criterion, level, and fix.` },
78
+ { label: 'robust', prompt: `Audit WCAG 2.2 Robust criteria for: "${target}". Check: 4.1.2 Name/Role/Value (all UI components have accessible name, role, state/value), 4.1.3 Status messages (announced to AT without focus). Also check for valid, parseable HTML. List every failure with criterion, level, and fix.` },
79
+ { label: 'aria', prompt: `Audit ARIA usage for: "${target}". Check: roles match actual element behavior, required aria-* properties present, aria-labelledby/describedby IDs exist, no aria-hidden on interactive elements, no redundant role+element, proper live region usage. List every failure with fix showing correct ARIA attributes.` },
80
+ { label: 'keyboard', prompt: `Audit keyboard navigation for: "${target}". Check: tab order is logical, visible focus indicator present (not just outline:none), modals trap focus and release on close, custom widgets (accordions, tabs, dropdowns, sliders) follow ARIA authoring practices keyboard patterns, no keyboard traps. List every failure with fix.` },
81
+ ];
82
+
83
+ phase('Audit');
84
+ const audits = await parallel(
85
+ AUDITORS.map(a => () => agent(a.prompt, { schema: AUDIT_SCHEMA, label: `audit:${a.label}`, phase: 'Audit' }))
86
+ );
87
+
88
+ phase('Verify');
89
+ const allIssues = audits.filter(Boolean).flatMap(a => (a.issues || []).map(i => ({ ...i, principle: a.principle })));
90
+ const levelAandAA = allIssues.filter(i => i.level === 'A' || i.level === 'AA');
91
+ log(`${allIssues.length} total issues, ${levelAandAA.length} Level A/AA → 3-vote verify`);
92
+
93
+ const verified = await parallel(
94
+ levelAandAA.map(issue => () =>
95
+ parallel([
96
+ () => agent(`Is this WCAG ${issue.level} accessibility issue real, or a false positive? Try to REFUTE it. Issue: "${issue.description}" (${issue.wcagCriterion}). Default isRealIssue=false only if clearly not applicable.`, { schema: VERDICT_SCHEMA, label: `v1:${issue.wcagCriterion}`, phase: 'Verify' }),
97
+ () => agent(`Would a real assistive technology user (screen reader, keyboard-only, low-vision) actually encounter this issue? Issue: "${issue.description}" (${issue.wcagCriterion}). Be specific about which user group is affected.`, { schema: VERDICT_SCHEMA, label: `v2:${issue.wcagCriterion}`, phase: 'Verify' }),
98
+ () => agent(`Is the WCAG criterion reference accurate for this issue? "${issue.description}" cited as ${issue.wcagCriterion} Level ${issue.level}. Confirm or correct the WCAG reference.`, { schema: VERDICT_SCHEMA, label: `v3:${issue.wcagCriterion}`, phase: 'Verify' }),
99
+ ]).then(votes => {
100
+ if (!votes) return { ...issue, confirmed: false };
101
+ const confirmed = votes.filter(Boolean).filter(v => v.isRealIssue).length;
102
+ return { ...issue, confirmed: confirmed >= 2 };
103
+ })
104
+ )
105
+ );
106
+
107
+ const confirmedIssues = verified.filter(Boolean).filter(i => i.confirmed);
108
+ log(`${confirmedIssues.length}/${levelAandAA.length} Level A/AA issues confirmed`);
109
+
110
+ phase('Spec');
111
+ const issueSummary = confirmedIssues.slice(0, 15).map(i => `[${i.level}/${i.severity}] ${i.wcagCriterion}: ${i.description} → Fix: ${i.fix}`).join('\n');
112
+ const remediation = await agent(
113
+ `Create an accessibility remediation spec for: "${target}"\n\nConfirmed WCAG issues:\n${issueSummary}\n\nFor each critical/blocker issue provide: WCAG reference, exact fix description, and a code example (HTML/ARIA/CSS) showing the corrected implementation. Determine the overall WCAG compliance level.`,
114
+ { schema: REMEDIATION_SCHEMA, label: 'remediation-spec' }
115
+ );
116
+ if (!remediation) { return { target, confirmedIssues, error: 'remediation-agent-null', stats: { total: allIssues.length, levelAAFailures: levelAandAA.length, confirmed: confirmedIssues.length } }; }
117
+
118
+ return { target, audits: audits.filter(Boolean), confirmedIssues, remediation, stats: { total: allIssues.length, levelAAFailures: levelAandAA.length, confirmed: confirmedIssues.length } };
119
+ }
@@ -0,0 +1,82 @@
1
+ export const meta = {
2
+ name: 'ai-model-eval',
3
+ description: '4-parallel model benchmark agents → scoring matrix → cost/performance recommendation',
4
+ whenToUse: 'When choosing between AI models or providers for a use case — benchmark quality, speed, and cost simultaneously',
5
+ phases: [
6
+ { title: 'Scope', detail: 'Define evaluation criteria and test prompts for the use case' },
7
+ { title: 'Benchmark', detail: '4 parallel model evaluators (quality / reasoning / speed / cost)' },
8
+ { title: 'Score', detail: 'Scoring matrix across all dimensions' },
9
+ { title: 'Recommend', detail: 'Ranked recommendation with break-even cost analysis' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const CRITERIA_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ useCase: { type: 'string' },
18
+ testPrompts: { type: 'array', items: { type: 'string' } },
19
+ priorities: { type: 'array', items: { type: 'string' } },
20
+ modelsToEvaluate: { type: 'array', items: { type: 'string' } },
21
+ },
22
+ required: ['useCase', 'testPrompts', 'priorities', 'modelsToEvaluate'],
23
+ };
24
+
25
+ const EVAL_SCHEMA = {
26
+ type: 'object',
27
+ properties: {
28
+ dimension: { type: 'string' },
29
+ scores: { type: 'array', items: { type: 'object', properties: { model: { type: 'string' }, score: { type: 'number' }, notes: { type: 'string' } }, required: ['model', 'score'] } },
30
+ },
31
+ required: ['dimension', 'scores'],
32
+ };
33
+
34
+ const RECOMMENDATION_SCHEMA = {
35
+ type: 'object',
36
+ properties: {
37
+ winner: { type: 'string' },
38
+ rationale: { type: 'string' },
39
+ ranking: { type: 'array', items: { type: 'object', properties: { model: { type: 'string' }, totalScore: { type: 'number' }, bestFor: { type: 'string' } }, required: ['model', 'totalScore', 'bestFor'] } },
40
+ costNote: { type: 'string' },
41
+ },
42
+ required: ['winner', 'rationale', 'ranking'],
43
+ };
44
+
45
+ const useCase = args || 'general purpose AI assistant for coding tasks';
46
+
47
+ phase('Scope');
48
+ const criteria = await agent(`Define evaluation criteria and test prompts for this AI model use case: "${useCase}". Create 3-5 representative test prompts that reflect the actual workload. List evaluation priorities (quality/speed/cost/context-length/reasoning) in order of importance. Suggest which models to evaluate (e.g., claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5, gpt-4o, gemini-2.0-flash).`, { schema: CRITERIA_SCHEMA, label: 'scope' });
49
+ if (!criteria) { return { useCase, error: 'criteria-agent-null' }; }
50
+ log(`Evaluating ${criteria.modelsToEvaluate.length} models on ${criteria.priorities.length} dimensions`);
51
+
52
+ phase('Benchmark');
53
+ const DIMENSIONS = [
54
+ { label: 'quality', prompt: `Evaluate OUTPUT QUALITY of these models for: "${useCase}". Test prompts: ${criteria.testPrompts.slice(0, 3).join(' | ')}. Models: ${criteria.modelsToEvaluate.join(', ')}. Score each 0-100 for accuracy, completeness, and usefulness. Base scores on published benchmarks (MMLU, HumanEval, SWE-bench, coding evals) and known model capabilities.` },
55
+ { label: 'reasoning', prompt: `Evaluate REASONING CAPABILITY of these models for: "${useCase}". Models: ${criteria.modelsToEvaluate.join(', ')}. Score 0-100 for multi-step reasoning, code understanding, logical deduction. Reference published benchmarks (MATH, BBH, ARC).` },
56
+ { label: 'speed-latency', prompt: `Evaluate SPEED AND LATENCY of these models: ${criteria.modelsToEvaluate.join(', ')}. Score 0-100 (100=fastest). Include: typical time-to-first-token, output tokens/second, and whether the model supports streaming. Reference publicly available benchmarks and known provider SLAs.` },
57
+ { label: 'cost-efficiency', prompt: `Evaluate COST EFFICIENCY of these models for: "${useCase}" with typical usage of ~1000 input tokens and ~500 output tokens per call. Models: ${criteria.modelsToEvaluate.join(', ')}. Score 0-100 (100=cheapest). Include: price per 1M input/output tokens from official pricing pages, estimated monthly cost at 100K calls/month.` },
58
+ ];
59
+
60
+ const evals = await parallel(
61
+ DIMENSIONS.map(d => () => agent(d.prompt, { schema: EVAL_SCHEMA, label: `eval:${d.label}`, phase: 'Benchmark' }))
62
+ );
63
+
64
+ phase('Score');
65
+ const validEvals = evals.filter(Boolean);
66
+ const modelScores = {};
67
+ criteria.modelsToEvaluate.forEach(model => {
68
+ modelScores[model] = validEvals.reduce((sum, e) => {
69
+ const s = (e.scores || []).find(sc => sc.model === model);
70
+ return sum + (s ? s.score : 0);
71
+ }, 0);
72
+ });
73
+ const sorted = Object.entries(modelScores).sort((a, b) => b[1] - a[1]);
74
+ if (sorted.length > 0) log(`Scoring complete — top model: ${sorted[0][0]}`);
75
+
76
+ phase('Recommend');
77
+ const scoreText = Object.entries(modelScores).sort((a, b) => b[1] - a[1]).map(([m, s]) => `${m}: ${s} total`).join(', ');
78
+ const recommendation = await agent(`Provide a model recommendation for: "${useCase}"\n\nScores: ${scoreText}\n\nPriorities: ${criteria.priorities.join(' > ')}\n\nRank all models, declare the winner with rationale, note the best model for each specific priority, and include a cost note for the top 2 models.`, { schema: RECOMMENDATION_SCHEMA, label: 'recommend' });
79
+ if (!recommendation) { return { useCase, criteria, evals: validEvals, modelScores, error: 'recommendation-agent-null' }; }
80
+
81
+ return { useCase, criteria, evals: validEvals, modelScores, recommendation };
82
+ }
@@ -0,0 +1,114 @@
1
+ export const meta = {
2
+ name: 'api-contract-test',
3
+ description: 'Writer/Reviewer pattern: spec reader vs implementation reader → contract violation report',
4
+ whenToUse: 'When validating that an API implementation matches its OpenAPI/GraphQL/Protobuf spec',
5
+ phases: [
6
+ { title: 'ReadSpec', detail: 'Parse the API specification (OpenAPI/GraphQL/Protobuf/docs)' },
7
+ { title: 'ReadImpl', detail: 'Read the actual implementation in a fresh context' },
8
+ { title: 'Diff', detail: 'Cross-reference spec contracts vs implementation' },
9
+ { title: 'Report', detail: 'Violation report with severity and fix instructions' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const SPEC_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ apiName: { type: 'string' },
18
+ endpoints: {
19
+ type: 'array',
20
+ items: {
21
+ type: 'object',
22
+ properties: {
23
+ method: { type: 'string' },
24
+ path: { type: 'string' },
25
+ requestSchema: { type: 'string' },
26
+ responseSchema: { type: 'string' },
27
+ authRequired: { type: 'boolean' },
28
+ errorCodes: { type: 'array', items: { type: 'string' } },
29
+ },
30
+ required: ['method', 'path', 'responseSchema'],
31
+ },
32
+ },
33
+ },
34
+ required: ['apiName', 'endpoints'],
35
+ };
36
+
37
+ const IMPL_SCHEMA = {
38
+ type: 'object',
39
+ properties: {
40
+ implementedEndpoints: {
41
+ type: 'array',
42
+ items: {
43
+ type: 'object',
44
+ properties: {
45
+ method: { type: 'string' },
46
+ path: { type: 'string' },
47
+ actualRequestHandling: { type: 'string' },
48
+ actualResponseShape: { type: 'string' },
49
+ authImplemented: { type: 'boolean' },
50
+ },
51
+ required: ['method', 'path', 'actualResponseShape'],
52
+ },
53
+ },
54
+ },
55
+ required: ['implementedEndpoints'],
56
+ };
57
+
58
+ const VIOLATION_SCHEMA = {
59
+ type: 'object',
60
+ properties: {
61
+ violations: {
62
+ type: 'array',
63
+ items: {
64
+ type: 'object',
65
+ properties: {
66
+ endpoint: { type: 'string' },
67
+ severity: { type: 'string', enum: ['breaking', 'non-breaking', 'warning'] },
68
+ type: { type: 'string' },
69
+ specSays: { type: 'string' },
70
+ implDoes: { type: 'string' },
71
+ fix: { type: 'string' },
72
+ },
73
+ required: ['endpoint', 'severity', 'type', 'specSays', 'implDoes', 'fix'],
74
+ },
75
+ },
76
+ summary: { type: 'string' },
77
+ breakingCount: { type: 'number' },
78
+ compatible: { type: 'boolean' },
79
+ },
80
+ required: ['violations', 'summary', 'breakingCount', 'compatible'],
81
+ };
82
+
83
+ const target = args || 'current API (provide spec file path and implementation path as args)';
84
+
85
+ phase('ReadSpec');
86
+ log(`Reading API spec from: ${target}`);
87
+ const spec = await agent(
88
+ `Read and extract the complete API contract from the spec file(s) in: "${target}". Look for OpenAPI/Swagger YAML, GraphQL schema files, Protobuf files, or API documentation. Extract every endpoint with its method, path, request/response schema, auth requirements, and error codes.`,
89
+ { schema: SPEC_SCHEMA, label: 'read-spec' }
90
+ );
91
+ if (!spec) { log('Warning: agent returned null for spec, skipping'); return { target, error: 'agent-null' }; }
92
+ log(`Spec: ${spec.apiName} — ${spec.endpoints.length} endpoints`);
93
+
94
+ phase('ReadImpl');
95
+ const impl = await agent(
96
+ `Read the actual API IMPLEMENTATION in: "${target}". Look for route handlers, controllers, resolvers, or gRPC handlers. For each endpoint extract the actual request handling logic, response shape being returned, and whether auth is checked. Do NOT read the spec — only the implementation code.`,
97
+ { schema: IMPL_SCHEMA, label: 'read-impl' }
98
+ );
99
+ if (!impl) { log('Warning: agent returned null for impl, skipping'); return { target, error: 'agent-null' }; }
100
+ log(`Implementation: ${impl.implementedEndpoints.length} endpoints found`);
101
+
102
+ phase('Diff');
103
+ const specText = spec.endpoints.map(e => `${e.method} ${e.path}: response=${e.responseSchema}, auth=${e.authRequired}, errors=${(e.errorCodes || []).join(',')}`).join('\n');
104
+ const implText = impl.implementedEndpoints.map(e => `${e.method} ${e.path}: response=${e.actualResponseShape}, auth=${e.authImplemented}`).join('\n');
105
+
106
+ phase('Report');
107
+ const report = await agent(
108
+ `Compare the API specification against the implementation and identify contract violations.\n\nSPEC:\n${specText}\n\nIMPLEMENTATION:\n${implText}\n\nFor each violation: classify as breaking (response shape/auth differs) or non-breaking (extra fields, missing optional), state what the spec says vs what the impl does, and provide the exact fix.`,
109
+ { schema: VIOLATION_SCHEMA, label: 'violations' }
110
+ );
111
+ if (!report) { return { target, spec, impl, error: 'report-agent-null' }; }
112
+
113
+ return { target, spec, impl, report };
114
+ }
@@ -0,0 +1,156 @@
1
+ export const meta = {
2
+ name: 'api-migration',
3
+ description: 'Breaking change detection → versioning strategy → migration guide → compatibility matrix',
4
+ whenToUse: 'When planning or documenting an API version migration — detect breaking changes and generate consumer migration guidance',
5
+ phases: [
6
+ { title: 'Detect', detail: 'Detect breaking vs non-breaking changes between old and new API versions' },
7
+ { title: 'Version', detail: 'Propose versioning strategy: semver, URL versioning, or header versioning' },
8
+ { title: 'Guide', detail: 'Generate migration guide for API consumers' },
9
+ { title: 'Matrix', detail: 'Compatibility matrix: which client versions work with which API versions' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const CHANGES_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ apiName: { type: 'string' },
18
+ oldVersion: { type: 'string' },
19
+ newVersion: { type: 'string' },
20
+ breakingChanges: {
21
+ type: 'array',
22
+ items: {
23
+ type: 'object',
24
+ properties: {
25
+ endpoint: { type: 'string' },
26
+ changeType: { type: 'string', enum: ['removed-endpoint', 'renamed-field', 'changed-type', 'removed-field', 'changed-auth', 'changed-status-code', 'changed-behavior'] },
27
+ description: { type: 'string' },
28
+ impactedClients: { type: 'string' },
29
+ },
30
+ required: ['endpoint', 'changeType', 'description'],
31
+ },
32
+ },
33
+ nonBreakingChanges: {
34
+ type: 'array',
35
+ items: {
36
+ type: 'object',
37
+ properties: {
38
+ endpoint: { type: 'string' },
39
+ changeType: { type: 'string', enum: ['added-endpoint', 'added-optional-field', 'added-header', 'performance-improvement', 'deprecation-notice'] },
40
+ description: { type: 'string' },
41
+ },
42
+ required: ['endpoint', 'changeType', 'description'],
43
+ },
44
+ },
45
+ },
46
+ required: ['apiName', 'breakingChanges', 'nonBreakingChanges'],
47
+ };
48
+
49
+ const VERSIONING_SCHEMA = {
50
+ type: 'object',
51
+ properties: {
52
+ strategy: { type: 'string', enum: ['url-versioning', 'header-versioning', 'semver-package', 'content-negotiation'] },
53
+ rationale: { type: 'string' },
54
+ versionIdentifier: { type: 'string' },
55
+ deprecationPolicy: { type: 'string' },
56
+ sunsetTimeline: { type: 'string' },
57
+ },
58
+ required: ['strategy', 'rationale', 'versionIdentifier', 'deprecationPolicy'],
59
+ };
60
+
61
+ const GUIDE_SCHEMA = {
62
+ type: 'object',
63
+ properties: {
64
+ summary: { type: 'string' },
65
+ migrationSteps: {
66
+ type: 'array',
67
+ items: {
68
+ type: 'object',
69
+ properties: {
70
+ step: { type: 'number' },
71
+ title: { type: 'string' },
72
+ description: { type: 'string' },
73
+ codeExample: { type: 'string' },
74
+ requiredBy: { type: 'string' },
75
+ },
76
+ required: ['step', 'title', 'description'],
77
+ },
78
+ },
79
+ searchAndReplace: {
80
+ type: 'array',
81
+ items: {
82
+ type: 'object',
83
+ properties: {
84
+ find: { type: 'string' },
85
+ replaceWith: { type: 'string' },
86
+ context: { type: 'string' },
87
+ },
88
+ required: ['find', 'replaceWith'],
89
+ },
90
+ },
91
+ },
92
+ required: ['summary', 'migrationSteps'],
93
+ };
94
+
95
+ const MATRIX_SCHEMA = {
96
+ type: 'object',
97
+ properties: {
98
+ matrix: {
99
+ type: 'array',
100
+ items: {
101
+ type: 'object',
102
+ properties: {
103
+ clientVersion: { type: 'string' },
104
+ apiV1Compatible: { type: 'boolean' },
105
+ apiV2Compatible: { type: 'boolean' },
106
+ migrationRequired: { type: 'boolean' },
107
+ notes: { type: 'string' },
108
+ },
109
+ required: ['clientVersion', 'apiV1Compatible', 'apiV2Compatible', 'migrationRequired'],
110
+ },
111
+ },
112
+ supportEndsDate: { type: 'string' },
113
+ recommendation: { type: 'string' },
114
+ },
115
+ required: ['matrix', 'recommendation'],
116
+ };
117
+
118
+ const target = args || 'current API (provide old/new version paths or describe the changes in args)';
119
+
120
+ phase('Detect');
121
+ log(`Detecting API changes in: ${target}`);
122
+ const changes = await agent(
123
+ `Analyze the API changes in: "${target}". Compare old vs new API versions. Classify each change as: BREAKING (removed endpoints, renamed/removed fields, changed types, auth changes, status code changes) or NON-BREAKING (added endpoints, added optional fields, performance improvements, deprecation notices). Include the old and new version identifiers.`,
124
+ { schema: CHANGES_SCHEMA, label: 'detect-changes' }
125
+ );
126
+ if (!changes) { log('Warning: agent returned null for changes, skipping'); return { target, error: 'agent-null' }; }
127
+ log(`API: ${changes.apiName} — ${changes.breakingChanges.length} breaking, ${changes.nonBreakingChanges.length} non-breaking changes`);
128
+
129
+ phase('Version');
130
+ const breakingSummary = changes.breakingChanges.map(c => `${c.endpoint}: ${c.changeType} — ${c.description}`).join('\n');
131
+ const versioning = await agent(
132
+ `Propose a versioning strategy for: "${changes.apiName}" migrating from ${changes.oldVersion || 'v1'} to ${changes.newVersion || 'v2'}.\n\nBreaking changes:\n${breakingSummary}\n\nRecommend: URL versioning (/v1, /v2), header versioning (API-Version: 2), or semver package versioning. Include: rationale, deprecation policy, and sunset timeline for the old version.`,
133
+ { schema: VERSIONING_SCHEMA, label: 'versioning' }
134
+ );
135
+ if (!versioning) { log('Warning: agent returned null for versioning, skipping'); return { target, changes, error: 'agent-null' }; }
136
+ log(`Strategy: ${versioning.strategy} — sunset: ${versioning.sunsetTimeline}`);
137
+
138
+ phase('Guide');
139
+ const guide = await agent(
140
+ `Write a migration guide for consumers of: "${changes.apiName}" upgrading from ${changes.oldVersion || 'v1'} to ${changes.newVersion || 'v2'}.\n\nBreaking changes:\n${breakingSummary}\n\nVersioning: ${versioning.strategy} (${versioning.versionIdentifier})\n\nProvide: (1) executive summary of what changed and why, (2) numbered migration steps in order, each with description and code example, (3) search-and-replace patterns for automated migration (what to find and replace in client code).`,
141
+ { schema: GUIDE_SCHEMA, label: 'guide' }
142
+ );
143
+ if (!guide) { log('Warning: agent returned null for guide, skipping'); return { target, changes, versioning, error: 'agent-null' }; }
144
+ log(`Migration guide: ${guide.migrationSteps.length} steps`);
145
+
146
+ phase('Matrix');
147
+ const allChanges = [...changes.breakingChanges, ...changes.nonBreakingChanges];
148
+ const changeSummary = allChanges.slice(0, 10).map(c => `${c.endpoint}: ${c.changeType}`).join(', ');
149
+ const matrix = await agent(
150
+ `Create a compatibility matrix for: "${changes.apiName}"\n\nChanges: ${changeSummary}\n\nVersioning: ${versioning.strategy}\nDeprecation policy: ${versioning.deprecationPolicy}\n\nFor typical client version groups (very-old, old, current, new), show compatibility with each API version and whether migration is required. Include support end date and overall recommendation.`,
151
+ { schema: MATRIX_SCHEMA, label: 'matrix' }
152
+ );
153
+ if (!matrix) { return { target, changes, versioning, guide, error: 'matrix-agent-null' }; }
154
+
155
+ return { target, changes, versioning, guide, matrix };
156
+ }
@@ -0,0 +1,111 @@
1
+ export const meta = {
2
+ name: 'architecture-modernization',
3
+ description: 'Legacy architecture map → target design → migration sequencing → risk gates',
4
+ whenToUse: 'When planning a major architecture overhaul: monolith-to-services, framework upgrade, or platform migration',
5
+ phases: [
6
+ { title: 'Map', detail: 'Map current architecture: components, dependencies, coupling, pain points' },
7
+ { title: 'Design', detail: '3 parallel target architecture proposals with trade-off analysis' },
8
+ { title: 'Select', detail: 'Judge panel selects best design, synthesizes hybrid' },
9
+ { title: 'Sequence', detail: 'Migration sequencing with risk gates and rollback checkpoints' },
10
+ { title: 'Roadmap', detail: 'Sprint-by-sprint modernization roadmap' },
11
+ ],
12
+ };
13
+
14
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
15
+ const MAP_SCHEMA = {
16
+ type: 'object',
17
+ properties: {
18
+ components: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, responsibility: { type: 'string' }, coupling: { type: 'string', enum: ['tight', 'loose', 'very-tight'] }, painPoints: { type: 'array', items: { type: 'string' } } }, required: ['name', 'responsibility', 'coupling'] } },
19
+ primaryPainPoints: { type: 'array', items: { type: 'string' } },
20
+ technicalDebt: { type: 'array', items: { type: 'string' } },
21
+ },
22
+ required: ['components', 'primaryPainPoints', 'technicalDebt'],
23
+ };
24
+
25
+ const DESIGN_SCHEMA = {
26
+ type: 'object',
27
+ properties: {
28
+ name: { type: 'string' },
29
+ approach: { type: 'string' },
30
+ components: { type: 'array', items: { type: 'string' } },
31
+ pros: { type: 'array', items: { type: 'string' } },
32
+ cons: { type: 'array', items: { type: 'string' } },
33
+ migrationComplexity: { type: 'string', enum: ['low', 'medium', 'high', 'very-high'] },
34
+ timeEstimate: { type: 'string' },
35
+ },
36
+ required: ['name', 'approach', 'pros', 'cons', 'migrationComplexity'],
37
+ };
38
+
39
+ const VERDICT_SCHEMA = {
40
+ type: 'object',
41
+ properties: {
42
+ winner: { type: 'string' },
43
+ rationale: { type: 'string' },
44
+ hybridAdjustments: { type: 'array', items: { type: 'string' } },
45
+ targetArchDescription: { type: 'string' },
46
+ },
47
+ required: ['winner', 'rationale', 'targetArchDescription'],
48
+ };
49
+
50
+ const ROADMAP_SCHEMA = {
51
+ type: 'object',
52
+ properties: {
53
+ phases: {
54
+ type: 'array',
55
+ items: {
56
+ type: 'object',
57
+ properties: {
58
+ phaseNum: { type: 'number' },
59
+ name: { type: 'string' },
60
+ work: { type: 'array', items: { type: 'string' } },
61
+ riskGates: { type: 'array', items: { type: 'string' } },
62
+ rollbackCheckpoint: { type: 'string' },
63
+ durationWeeks: { type: 'number' },
64
+ },
65
+ required: ['phaseNum', 'name', 'work', 'riskGates', 'rollbackCheckpoint'],
66
+ },
67
+ },
68
+ totalDurationWeeks: { type: 'number' },
69
+ criticalDependencies: { type: 'array', items: { type: 'string' } },
70
+ },
71
+ required: ['phases', 'totalDurationWeeks'],
72
+ };
73
+
74
+ const target = args || 'current codebase (describe your modernization goal in args)';
75
+
76
+ phase('Map');
77
+ log(`Mapping current architecture for: ${target}`);
78
+ const archMap = await agent(
79
+ `Map the current architecture of: "${target}". Identify all major components, their responsibilities, coupling levels (tight/loose), and pain points. List the primary architectural pain points and technical debt items that motivate modernization.`,
80
+ { schema: MAP_SCHEMA, label: 'arch-map' }
81
+ );
82
+ if (!archMap) { log('Warning: agent returned null for archMap, skipping'); return { target, error: 'agent-null' }; }
83
+ log(`Found ${archMap.components.length} components, ${archMap.primaryPainPoints.length} pain points`);
84
+
85
+ phase('Design');
86
+ const mapContext = `Current architecture: ${archMap.components.map(c => `${c.name}(${c.coupling} coupling)`).join(', ')}\nPain points: ${archMap.primaryPainPoints.join(', ')}`;
87
+ const designs = await parallel([
88
+ () => agent(`Design a CONSERVATIVE modernization architecture for: "${target}". ${mapContext}. Propose incremental improvements with minimal disruption — strangler fig pattern, adapter layers, gradual extraction. Optimize for low migration risk.`, { schema: DESIGN_SCHEMA, label: 'design-conservative', phase: 'Design' }),
89
+ () => agent(`Design an AGGRESSIVE modernization architecture for: "${target}". ${mapContext}. Propose a modern target state — microservices, event-driven, serverless, or modern monolith. Optimize for long-term maintainability.`, { schema: DESIGN_SCHEMA, label: 'design-aggressive', phase: 'Design' }),
90
+ () => agent(`Design a PRAGMATIC modernization architecture for: "${target}". ${mapContext}. Balance risk vs benefit — modular monolith, domain-driven boundaries, selective extraction of high-value services. Optimize for team productivity.`, { schema: DESIGN_SCHEMA, label: 'design-pragmatic', phase: 'Design' }),
91
+ ]);
92
+
93
+ phase('Select');
94
+ const designsText = designs.filter(Boolean).map(d => `Option: ${d.name}\nApproach: ${d.approach}\nPros: ${d.pros.join(', ')}\nCons: ${d.cons.join(', ')}\nComplexity: ${d.migrationComplexity}\nTime: ${d.timeEstimate}`).join('\n\n');
95
+ const verdict = await agent(
96
+ `Select the best modernization architecture for: "${target}"\n\nThree options:\n${designsText}\n\nChoose the winner based on: migration risk, team capability, business continuity, long-term value. Suggest hybrid adjustments that take the best elements from runners-up. Describe the final target architecture.`,
97
+ { schema: VERDICT_SCHEMA, label: 'design-select' }
98
+ );
99
+ if (!verdict) { log('Warning: agent returned null for verdict, skipping'); return { target, archMap, designs: designs.filter(Boolean), error: 'agent-null' }; }
100
+ log(`Selected: ${verdict.winner} — ${verdict.rationale.slice(0, 80)}`);
101
+
102
+ phase('Roadmap');
103
+ phase('Sequence');
104
+ const roadmap = await agent(
105
+ `Create a phased migration roadmap for: "${target}"\n\nTarget architecture: ${verdict.targetArchDescription}\n\nCurrent pain points: ${archMap.primaryPainPoints.join(', ')}\n\nSequence the work into migration phases with: specific work items, risk gates (conditions that must be true before proceeding), rollback checkpoints, and duration estimates. Ensure each phase is independently deployable.`,
106
+ { schema: ROADMAP_SCHEMA, label: 'sequence' }
107
+ );
108
+ if (!roadmap) { return { target, archMap, designs: designs.filter(Boolean), verdict, error: 'roadmap-agent-null' }; }
109
+
110
+ return { target, archMap, designs: designs.filter(Boolean), verdict, roadmap };
111
+ }