mindforge-cc 11.7.1 → 11.8.1

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 (91) 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 -3
  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 -3
  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 +57 -60
  47. package/.mindforge/dynamic-workflows/index.json +730 -59
  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 +43 -0
  71. package/MINDFORGE.md +2 -2
  72. package/README.md +42 -5
  73. package/RELEASENOTES.md +36 -0
  74. package/SECURITY.md +9 -0
  75. package/bin/autonomous/auto-runner.js +8 -2
  76. package/bin/autonomous/dependency-dag.js +1 -1
  77. package/bin/browser/session-manager.js +3 -1
  78. package/bin/governance/ztai-manager.js +6 -0
  79. package/bin/memory/eis-client.js +6 -2
  80. package/bin/spawn-agent.js +10 -7
  81. package/bin/sre/sli-verifier.js +9 -1
  82. package/bin/workflows/workflow-runner.js +18 -2
  83. package/docs/commands-reference.md +40 -14
  84. package/docs/getting-started.md +13 -1
  85. package/docs/sdk-reference.md +13 -1
  86. package/docs/troubleshooting.md +9 -0
  87. package/docs/user-guide.md +20 -1
  88. package/package.json +1 -1
  89. package/.agent/mindforge/wf-deep-research.md +0 -32
  90. package/.claude/commands/mindforge/wf-deep-research.md +0 -32
  91. package/.mindforge/dynamic-workflows/scripts/deep-research.js +0 -151
@@ -0,0 +1,124 @@
1
+ export const meta = {
2
+ name: 'debug-detective',
3
+ description: '4-hypothesis parallel investigation → evidence gathering → scientific RCA',
4
+ whenToUse: 'When debugging a hard-to-reproduce bug, production issue, or mysterious failure with unclear root cause',
5
+ phases: [
6
+ { title: 'Intake', detail: 'Document symptoms, context, and reproduction steps' },
7
+ { title: 'Hypothesize', detail: '4 parallel hypothesis agents from different angles' },
8
+ { title: 'Evidence', detail: 'Parallel evidence gathering per hypothesis' },
9
+ { title: 'RCA', detail: 'Scientific root cause analysis from evidence' },
10
+ { title: 'Fix', detail: 'Targeted fix plan with regression test spec' },
11
+ ],
12
+ };
13
+
14
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
15
+ const INTAKE_SCHEMA = {
16
+ type: 'object',
17
+ properties: {
18
+ bugSummary: { type: 'string' },
19
+ symptoms: { type: 'array', items: { type: 'string' } },
20
+ reproducible: { type: 'boolean' },
21
+ affectedComponents: { type: 'array', items: { type: 'string' } },
22
+ recentChanges: { type: 'array', items: { type: 'string' } },
23
+ environment: { type: 'string' },
24
+ },
25
+ required: ['bugSummary', 'symptoms', 'affectedComponents'],
26
+ };
27
+
28
+ const HYPOTHESIS_SCHEMA = {
29
+ type: 'object',
30
+ properties: {
31
+ angle: { type: 'string' },
32
+ hypothesis: { type: 'string' },
33
+ reasoning: { type: 'string' },
34
+ evidenceNeeded: { type: 'array', items: { type: 'string' } },
35
+ probability: { type: 'string', enum: ['high', 'medium', 'low'] },
36
+ },
37
+ required: ['angle', 'hypothesis', 'reasoning', 'evidenceNeeded', 'probability'],
38
+ };
39
+
40
+ const EVIDENCE_SCHEMA = {
41
+ type: 'object',
42
+ properties: {
43
+ hypothesis: { type: 'string' },
44
+ supportingEvidence: { type: 'array', items: { type: 'string' } },
45
+ refutingEvidence: { type: 'array', items: { type: 'string' } },
46
+ verdict: { type: 'string', enum: ['strongly-supported', 'weakly-supported', 'inconclusive', 'refuted'] },
47
+ confidence: { type: 'number' },
48
+ },
49
+ required: ['hypothesis', 'supportingEvidence', 'refutingEvidence', 'verdict', 'confidence'],
50
+ };
51
+
52
+ const RCA_SCHEMA = {
53
+ type: 'object',
54
+ properties: {
55
+ rootCause: { type: 'string' },
56
+ causalChain: { type: 'array', items: { type: 'string' } },
57
+ contributingFactors: { type: 'array', items: { type: 'string' } },
58
+ whyNowExplanation: { type: 'string' },
59
+ confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
60
+ },
61
+ required: ['rootCause', 'causalChain', 'confidence'],
62
+ };
63
+
64
+ const FIX_SCHEMA = {
65
+ type: 'object',
66
+ properties: {
67
+ fixDescription: { type: 'string' },
68
+ filestoChange: { type: 'array', items: { type: 'string' } },
69
+ implementationSteps: { type: 'array', items: { type: 'string' } },
70
+ regressionTestSpec: { type: 'string' },
71
+ riskOfFix: { type: 'string', enum: ['low', 'medium', 'high'] },
72
+ },
73
+ required: ['fixDescription', 'implementationSteps', 'regressionTestSpec'],
74
+ };
75
+
76
+ const bugReport = args || 'No bug report provided — describe the bug, symptoms, and context in args.';
77
+
78
+ phase('Intake');
79
+ log(`Analyzing bug report: ${bugReport.slice(0, 80)}`);
80
+ const intake = await agent(
81
+ `Analyze this bug report and extract structured information: "${bugReport}"\n\nIdentify: bug summary, specific symptoms observed, whether reproducible, affected components/files, any recent changes that might be related, and environment (prod/staging/dev, OS, browser, etc.).`,
82
+ { schema: INTAKE_SCHEMA, label: 'intake' }
83
+ );
84
+ if (!intake) { log('Warning: agent returned null for intake, skipping'); return { bugReport, error: 'agent-null' }; }
85
+ log(`Bug: ${intake.bugSummary} | Affects: ${intake.affectedComponents.join(', ')}`);
86
+
87
+ phase('Hypothesize');
88
+ const context = `Bug: ${intake.bugSummary}\nSymptoms: ${intake.symptoms.join(', ')}\nAffected: ${intake.affectedComponents.join(', ')}\nRecent changes: ${(intake.recentChanges || []).join(', ')}`;
89
+ const hypotheses = await parallel([
90
+ () => agent(`Generate a hypothesis from a CODE perspective for this bug: ${context}\n\nFocus on: logic errors, off-by-one, null/undefined handling, async/await issues, type coercion. What specific code defect could cause these symptoms?`, { schema: HYPOTHESIS_SCHEMA, label: 'hypothesis-code', phase: 'Hypothesize' }),
91
+ () => agent(`Generate a hypothesis from a STATE/DATA perspective for this bug: ${context}\n\nFocus on: database state corruption, stale cache, race condition, shared mutable state, session/cookie issues. What data or state problem could cause these symptoms?`, { schema: HYPOTHESIS_SCHEMA, label: 'hypothesis-state', phase: 'Hypothesize' }),
92
+ () => agent(`Generate a hypothesis from an INTEGRATION/ENVIRONMENT perspective for this bug: ${context}\n\nFocus on: API contract mismatch, network timeout, environment variable, dependency version conflict, OS/browser differences. What external factor could cause these symptoms?`, { schema: HYPOTHESIS_SCHEMA, label: 'hypothesis-integration', phase: 'Hypothesize' }),
93
+ () => agent(`Generate a hypothesis from a REGRESSION perspective for this bug: ${context}\n\nFocus on: what recent change (deploy, config, dependency update) most likely introduced this. Which commit or change is the prime suspect?`, { schema: HYPOTHESIS_SCHEMA, label: 'hypothesis-regression', phase: 'Hypothesize' }),
94
+ ]);
95
+
96
+ phase('Evidence');
97
+ const validHypotheses = hypotheses.filter(Boolean);
98
+ log(`${validHypotheses.length} hypotheses — gathering evidence in parallel`);
99
+
100
+ const evidence = await parallel(
101
+ validHypotheses.map(h => () => agent(
102
+ `Gather evidence for or against this hypothesis about the bug "${intake.bugSummary}":\n\nHypothesis: ${h.hypothesis}\nEvidence needed: ${h.evidenceNeeded.join(', ')}\n\nLook in the codebase for: ${h.evidenceNeeded.join(', ')}. Report what you find that supports OR refutes this hypothesis. Rate your verdict.`,
103
+ { schema: EVIDENCE_SCHEMA, label: `evidence:${h.angle.slice(0, 20)}`, phase: 'Evidence' }
104
+ ))
105
+ );
106
+
107
+ phase('RCA');
108
+ const evidenceSummary = evidence.filter(Boolean).map(e => `${e.hypothesis}: ${e.verdict} (${e.confidence}%) — supports: [${e.supportingEvidence.slice(0, 2).join(', ')}] refutes: [${e.refutingEvidence.slice(0, 1).join(', ')}]`).join('\n');
109
+ const rca = await agent(
110
+ `Perform a scientific root cause analysis for: "${intake.bugSummary}"\n\nEvidence summary:\n${evidenceSummary}\n\nIdentify the root cause (the specific defect that, if fixed, would prevent the bug), the causal chain (how root cause leads to symptoms), contributing factors, and why it appeared now. Rate your confidence.`,
111
+ { schema: RCA_SCHEMA, label: 'rca' }
112
+ );
113
+ if (!rca) { log('Warning: agent returned null for rca, skipping'); return { bugReport, intake, hypotheses: validHypotheses, evidence: evidence.filter(Boolean), error: 'agent-null' }; }
114
+ log(`RCA: ${rca.rootCause.slice(0, 80)} (confidence: ${rca.confidence})`);
115
+
116
+ phase('Fix');
117
+ const fix = await agent(
118
+ `Design a targeted fix for this bug.\n\nRoot cause: ${rca.rootCause}\nCausal chain: ${rca.causalChain.join(' → ')}\nAffected components: ${intake.affectedComponents.join(', ')}\n\nProvide: exact fix description, which files to change, step-by-step implementation, a regression test specification that would catch this bug if reintroduced, and risk assessment of the fix.`,
119
+ { schema: FIX_SCHEMA, label: 'fix' }
120
+ );
121
+ if (!fix) { log('Warning: agent returned null for fix, skipping'); return { bugReport, intake, hypotheses: validHypotheses, evidence: evidence.filter(Boolean), rca, error: 'agent-null' }; }
122
+
123
+ return { bugReport, intake, hypotheses: validHypotheses, evidence: evidence.filter(Boolean), rca, fix };
124
+ }
@@ -0,0 +1,110 @@
1
+ export const meta = {
2
+ name: 'dependency-health',
3
+ description: 'Parallel per-dependency audit (CVEs / licenses / staleness / maintenance) → risk matrix',
4
+ whenToUse: 'When auditing dependencies before a release, security review, or due diligence',
5
+ phases: [
6
+ { title: 'Inventory', detail: 'Extract full dependency tree from package manifests' },
7
+ { title: 'Audit', detail: 'Parallel audit per batch: CVEs, license risk, staleness, maintenance status' },
8
+ { title: 'RiskMatrix', detail: 'Consolidate into risk matrix with severity tiers' },
9
+ { title: 'Action', detail: 'Prioritized upgrade / replace / accept recommendations' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const INVENTORY_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ dependencies: {
18
+ type: 'array',
19
+ items: {
20
+ type: 'object',
21
+ properties: {
22
+ name: { type: 'string' },
23
+ version: { type: 'string' },
24
+ type: { type: 'string', enum: ['prod', 'dev', 'peer', 'optional'] },
25
+ },
26
+ required: ['name', 'version', 'type'],
27
+ },
28
+ },
29
+ packageManager: { type: 'string' },
30
+ },
31
+ required: ['dependencies', 'packageManager'],
32
+ };
33
+
34
+ const BATCH_SCHEMA = {
35
+ type: 'object',
36
+ properties: {
37
+ audits: {
38
+ type: 'array',
39
+ items: {
40
+ type: 'object',
41
+ properties: {
42
+ name: { type: 'string' },
43
+ cveRisk: { type: 'string', enum: ['critical', 'high', 'medium', 'low', 'none'] },
44
+ licenseRisk: { type: 'string', enum: ['copyleft', 'permissive', 'unknown', 'proprietary'] },
45
+ staleness: { type: 'string', enum: ['current', 'minor-behind', 'major-behind', 'abandoned'] },
46
+ maintenanceStatus: { type: 'string', enum: ['active', 'slow', 'stale', 'archived', 'unknown'] },
47
+ recommendation: { type: 'string', enum: ['upgrade', 'replace', 'accept', 'remove'] },
48
+ notes: { type: 'string' },
49
+ },
50
+ required: ['name', 'cveRisk', 'licenseRisk', 'staleness', 'maintenanceStatus', 'recommendation'],
51
+ },
52
+ },
53
+ },
54
+ required: ['audits'],
55
+ };
56
+
57
+ const ACTION_SCHEMA = {
58
+ type: 'object',
59
+ properties: {
60
+ summary: { type: 'string' },
61
+ immediateUpgrades: { type: 'array', items: { type: 'string' } },
62
+ replaceWithAlternatives: { type: 'array', items: { type: 'object', properties: { current: { type: 'string' }, replacement: { type: 'string' }, reason: { type: 'string' } }, required: ['current', 'replacement', 'reason'] } },
63
+ acceptableRisks: { type: 'array', items: { type: 'string' } },
64
+ licenseIssues: { type: 'array', items: { type: 'string' } },
65
+ },
66
+ required: ['summary', 'immediateUpgrades', 'replaceWithAlternatives', 'acceptableRisks'],
67
+ };
68
+
69
+ const target = args || 'current project (run from repo root)';
70
+
71
+ phase('Inventory');
72
+ log(`Inventorying dependencies in: ${target}`);
73
+ const inventory = await agent(
74
+ `Extract the complete dependency list from package manifests in: "${target}". Look for package.json, requirements.txt, Pipfile, go.mod, Gemfile, Cargo.toml, or similar. List each dependency with its current version and type (prod/dev/peer/optional). Identify the package manager used.`,
75
+ { schema: INVENTORY_SCHEMA, label: 'inventory' }
76
+ );
77
+ if (!inventory) { return { target, error: 'inventory-agent-null' }; }
78
+ const allDeps = inventory.dependencies || [];
79
+ log(`Found ${allDeps.length} dependencies (${inventory.packageManager})`);
80
+
81
+ const BATCH_SIZE = 10;
82
+ const batches = [];
83
+ for (let i = 0; i < allDeps.length; i += BATCH_SIZE) {
84
+ batches.push(allDeps.slice(i, i + BATCH_SIZE));
85
+ }
86
+ log(`Auditing in ${batches.length} batches of up to ${BATCH_SIZE}`);
87
+
88
+ phase('Audit');
89
+ const batchResults = await parallel(
90
+ batches.map((batch, idx) => () => agent(
91
+ `Audit these dependencies for security and health: ${batch.map(d => `${d.name}@${d.version}`).join(', ')}. For each: (1) known CVEs or security advisories, (2) license type (MIT/Apache/GPL/etc.), (3) staleness (how far behind latest), (4) maintenance status (active/slow/stale/archived). Provide upgrade/replace/accept/remove recommendation.`,
92
+ { schema: BATCH_SCHEMA, label: `audit-batch-${idx}`, phase: 'Audit' }
93
+ ))
94
+ );
95
+
96
+ phase('RiskMatrix');
97
+ const allAudits = batchResults.filter(Boolean).flatMap(b => b.audits || []);
98
+ const critical = allAudits.filter(a => a.cveRisk === 'critical' || a.cveRisk === 'high');
99
+ const licenseIssues = allAudits.filter(a => a.licenseRisk === 'copyleft' || a.licenseRisk === 'unknown');
100
+ log(`${critical.length} high/critical CVE risks, ${licenseIssues.length} license issues`);
101
+
102
+ phase('Action');
103
+ const matrixText = allAudits.filter(a => a.cveRisk !== 'none' || a.recommendation !== 'accept').slice(0, 20).map(a => `${a.name}: CVE=${a.cveRisk}, license=${a.licenseRisk}, staleness=${a.staleness}, status=${a.maintenanceStatus} → ${a.recommendation}`).join('\n');
104
+ const actions = await agent(
105
+ `Create a dependency action plan for: "${target}"\n\nRisk matrix:\n${matrixText}\n\nPrioritize: (1) immediate upgrades for critical CVEs, (2) replacements for abandoned/high-risk deps, (3) acceptable-risk accepts, (4) license issues to resolve. For replacements, suggest specific alternative packages.`,
106
+ { schema: ACTION_SCHEMA, label: 'action-plan' }
107
+ );
108
+
109
+ return { target, inventory, audits: allAudits, actions, stats: { total: allDeps.length, criticalCVE: critical.length, licenseIssues: licenseIssues.length } };
110
+ }
@@ -0,0 +1,115 @@
1
+ export const meta = {
2
+ name: 'design-system-audit',
3
+ description: '5 parallel dimension auditors (spacing/color/typography/icons/a11y) → consistency score',
4
+ whenToUse: 'When auditing a UI codebase for design system consistency before a design review, refactor, or component library update',
5
+ phases: [
6
+ { title: 'Inventory', detail: 'Discover design tokens, component files, and styling approach' },
7
+ { title: 'Audit', detail: '5 parallel dimension auditors: spacing, color, typography, icons, accessibility' },
8
+ { title: 'Score', detail: 'Aggregate consistency scores per dimension and overall' },
9
+ { title: 'Report', detail: 'Design system health report with specific violation fixes' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const INVENTORY_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ stylingApproach: { type: 'string' },
18
+ tokenFiles: { type: 'array', items: { type: 'string' } },
19
+ componentFiles: { type: 'array', items: { type: 'string' } },
20
+ designSystem: { type: 'string' },
21
+ },
22
+ required: ['stylingApproach', 'componentFiles'],
23
+ };
24
+
25
+ const DIM_SCHEMA = {
26
+ type: 'object',
27
+ properties: {
28
+ dimension: { type: 'string' },
29
+ score: { type: 'number' },
30
+ violations: {
31
+ type: 'array',
32
+ items: {
33
+ type: 'object',
34
+ properties: {
35
+ file: { type: 'string' },
36
+ severity: { type: 'string', enum: ['critical', 'high', 'medium', 'low'] },
37
+ description: { type: 'string' },
38
+ fix: { type: 'string' },
39
+ },
40
+ required: ['severity', 'description', 'fix'],
41
+ },
42
+ },
43
+ positives: { type: 'array', items: { type: 'string' } },
44
+ },
45
+ required: ['dimension', 'score', 'violations'],
46
+ };
47
+
48
+ const REPORT_SCHEMA = {
49
+ type: 'object',
50
+ properties: {
51
+ overallScore: { type: 'number' },
52
+ summary: { type: 'string' },
53
+ dimensionScores: {
54
+ type: 'array',
55
+ items: {
56
+ type: 'object',
57
+ properties: {
58
+ dimension: { type: 'string' },
59
+ score: { type: 'number' },
60
+ topIssue: { type: 'string' },
61
+ },
62
+ required: ['dimension', 'score', 'topIssue'],
63
+ },
64
+ },
65
+ topFixes: { type: 'array', items: { type: 'string' } },
66
+ tokenizationGaps: { type: 'array', items: { type: 'string' } },
67
+ },
68
+ required: ['overallScore', 'summary', 'dimensionScores', 'topFixes'],
69
+ };
70
+
71
+ const target = args || 'current codebase (run from repo root)';
72
+
73
+ phase('Inventory');
74
+ log(`Design system audit target: ${target}`);
75
+ const inventory = await agent(
76
+ `Inventory the design system foundations of: "${target}". Identify: (1) styling approach (CSS modules, Tailwind, styled-components, CSS-in-JS, etc.), (2) design token files (variables, theme files, constants), (3) component files (UI components, primitives), (4) which design system library is used if any (shadcn, MUI, Chakra, etc.).`,
77
+ { schema: INVENTORY_SCHEMA, label: 'inventory' }
78
+ );
79
+ if (!inventory) { log('Warning: agent returned null for inventory, skipping'); return { target, error: 'agent-null' }; }
80
+ log(`Styling: ${inventory.stylingApproach}, ${inventory.componentFiles.length} component files`);
81
+
82
+ phase('Audit');
83
+ const ctx = `Styling: ${inventory.stylingApproach}. Design system: ${inventory.designSystem || 'custom'}. Token files: ${(inventory.tokenFiles || []).join(', ')}`;
84
+
85
+ const DIMENSIONS = [
86
+ { label: 'spacing', prompt: `Audit SPACING CONSISTENCY in: "${target}". ${ctx}. Check: Are spacing values taken from a defined scale (4px/8px/16px etc.)? Are there magic numbers (arbitrary pixel values)? Is padding/margin/gap consistent for similar components? Are layout spacings reusing tokens? Score 0-100 (100=perfectly consistent) and list all violations with fixes.` },
87
+ { label: 'color', prompt: `Audit COLOR USAGE in: "${target}". ${ctx}. Check: Are colors from the defined palette/tokens only? Are there hardcoded hex values that bypass tokens? Is color used for meaning (red=error, green=success) consistently? Are brand colors consistent? Score 0-100 and list all violations.` },
88
+ { label: 'typography', prompt: `Audit TYPOGRAPHY SCALE in: "${target}". ${ctx}. Check: Are font sizes from a defined type scale? Are font weights consistent for similar hierarchy levels? Are line-heights defined? Is the heading hierarchy (h1>h2>h3) visually consistent? Score 0-100 and list violations.` },
89
+ { label: 'icons', prompt: `Audit ICON CONSISTENCY in: "${target}". ${ctx}. Check: Is a single icon library used consistently? Are icon sizes consistent for the same context (nav icons vs inline icons)? Are icon meanings consistent (same icon for same action everywhere)? Are there mixed icon styles (outline vs filled)? Score 0-100 and list violations.` },
90
+ { label: 'accessibility', prompt: `Audit ACCESSIBILITY in the design system of: "${target}". ${ctx}. Check: Do color combinations meet WCAG AA contrast ratio (4.5:1 for normal text, 3:1 for large)? Are interactive elements at least 44x44px touch targets? Are focus states visible? Are disabled states visually distinct? Score 0-100 and list violations.` },
91
+ ];
92
+
93
+ const auditResults = await parallel(
94
+ DIMENSIONS.map(d => () => agent(d.prompt, { schema: DIM_SCHEMA, label: `audit:${d.label}`, phase: 'Audit' }))
95
+ );
96
+
97
+ phase('Score');
98
+ const validAudits = auditResults.filter(Boolean);
99
+ const avgScore = validAudits.length > 0
100
+ ? Math.round(validAudits.reduce((sum, a) => sum + (a.score || 0), 0) / validAudits.length)
101
+ : 0;
102
+ log(`Dimension scores: ${validAudits.map(a => `${a.dimension}=${a.score}`).join(', ')} | Overall: ${avgScore}`);
103
+
104
+ phase('Report');
105
+ const dimSummary = validAudits.map(a => `${a.dimension}: ${a.score}/100, top issue: ${(a.violations[0] || {}).description || 'none'}`).join('\n');
106
+ const allViolations = validAudits.flatMap(a => a.violations.map(v => `[${a.dimension}/${v.severity}] ${v.description}`)).slice(0, 15).join('\n');
107
+
108
+ const report = await agent(
109
+ `Generate a design system health report for: "${target}"\n\nDimension scores:\n${dimSummary}\n\nTop violations:\n${allViolations}\n\nOverall consistency score: ${avgScore}/100\n\nProvide: executive summary, dimension score table with top issue each, top 5 priority fixes, and which values should be tokenized but aren't.`,
110
+ { schema: REPORT_SCHEMA, label: 'report' }
111
+ );
112
+ if (!report) { return { target, inventory, audits: validAudits, error: 'report-agent-null' }; }
113
+
114
+ return { target, inventory, audits: validAudits, report };
115
+ }
@@ -0,0 +1,91 @@
1
+ export const meta = {
2
+ name: 'documentation-gen',
3
+ description: 'Parallel per-file doc generation → style normalization → publish-ready documentation',
4
+ whenToUse: 'When generating or refreshing documentation for a codebase, API, or module',
5
+ phases: [
6
+ { title: 'Scope', detail: 'Discover files needing documentation' },
7
+ { title: 'Generate', detail: 'Parallel doc generation per file/module' },
8
+ { title: 'Normalize', detail: 'Style consistency pass across all generated docs' },
9
+ { title: 'Publish', detail: 'Assemble README, API reference, and changelog entries' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const FILE_LIST_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ files: {
18
+ type: 'array',
19
+ items: {
20
+ type: 'object',
21
+ properties: {
22
+ path: { type: 'string' },
23
+ type: { type: 'string', enum: ['module', 'class', 'function', 'api-route', 'config', 'util'] },
24
+ priority: { type: 'string', enum: ['high', 'medium', 'low'] },
25
+ currentDocStatus: { type: 'string', enum: ['none', 'partial', 'outdated', 'current'] },
26
+ },
27
+ required: ['path', 'type', 'priority', 'currentDocStatus'],
28
+ },
29
+ },
30
+ },
31
+ required: ['files'],
32
+ };
33
+
34
+ const DOC_SCHEMA = {
35
+ type: 'object',
36
+ properties: {
37
+ path: { type: 'string' },
38
+ summary: { type: 'string' },
39
+ description: { type: 'string' },
40
+ parameters: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, type: { type: 'string' }, description: { type: 'string' }, required: { type: 'boolean' } }, required: ['name', 'type', 'description'] } },
41
+ returns: { type: 'string' },
42
+ examples: { type: 'array', items: { type: 'string' } },
43
+ sideEffects: { type: 'array', items: { type: 'string' } },
44
+ },
45
+ required: ['path', 'summary', 'description'],
46
+ };
47
+
48
+ const PUBLISH_SCHEMA = {
49
+ type: 'object',
50
+ properties: {
51
+ readmeSection: { type: 'string' },
52
+ apiReference: { type: 'string' },
53
+ quickStart: { type: 'string' },
54
+ changelogEntries: { type: 'array', items: { type: 'string' } },
55
+ },
56
+ required: ['readmeSection', 'apiReference', 'quickStart'],
57
+ };
58
+
59
+ const target = args || 'current codebase (run from repo root)';
60
+
61
+ phase('Scope');
62
+ log(`Scoping documentation for: ${target}`);
63
+ const fileList = await agent(
64
+ `Discover all files in: "${target}" that need documentation. Focus on: public APIs, exported functions/classes, route handlers, configuration modules. For each file note its type (module/class/function/api-route/config/util), documentation priority (high=public API, medium=internal, low=util), and current doc status (none/partial/outdated/current). Skip test files and auto-generated files.`,
65
+ { schema: FILE_LIST_SCHEMA, label: 'scope' }
66
+ );
67
+
68
+ const highAndMedium = ((fileList || {}).files || []).filter(f => f.priority === 'high' || f.priority === 'medium').slice(0, 15);
69
+ log(`Generating docs for ${highAndMedium.length} priority files`);
70
+
71
+ phase('Generate');
72
+ const docs = await parallel(
73
+ highAndMedium.map(f => () => agent(
74
+ `Generate complete documentation for the file at "${f.path}" in codebase: "${target}". It is a ${f.type}. Write: (1) one-line summary, (2) full description with purpose and usage context, (3) all parameters with types and descriptions, (4) return value description, (5) 1-2 concrete usage examples, (6) any side effects or important caveats.`,
75
+ { schema: DOC_SCHEMA, label: `doc:${f.path.split('/').pop().replace('.', '-')}`, phase: 'Generate' }
76
+ ))
77
+ );
78
+
79
+ phase('Normalize');
80
+ const validDocs = docs.filter(Boolean);
81
+ const docSummaries = validDocs.map(d => `${d.path}: ${d.summary}`).join('\n');
82
+ log(`${validDocs.length} docs generated — normalizing style`);
83
+
84
+ phase('Publish');
85
+ const publish = await agent(
86
+ `Assemble publish-ready documentation for: "${target}"\n\nGenerated docs:\n${docSummaries}\n\nProduce: (1) README API section (markdown table of all public exports with one-line descriptions), (2) full API reference (each entry with params, returns, example), (3) quick-start guide showing the most common 3-5 use cases, (4) CHANGELOG entry lines for newly documented items.`,
87
+ { schema: PUBLISH_SCHEMA, label: 'publish' }
88
+ );
89
+
90
+ return { target, fileList, docs: validDocs, publish };
91
+ }
@@ -0,0 +1,63 @@
1
+ export const meta = {
2
+ name: 'multi-repo-sync',
3
+ description: 'Parallel per-repo audit → cross-repo divergence map → sync plan',
4
+ whenToUse: 'When managing multiple related repos and need to find/fix divergence in shared config, deps, or conventions',
5
+ phases: [
6
+ { title: 'Discover', detail: 'List target repos and their relationships' },
7
+ { title: 'Audit', detail: 'Parallel audit per repo for divergence from the reference' },
8
+ { title: 'DivergenceMap', detail: 'Cross-repo divergence map with severity' },
9
+ { title: 'SyncPlan', detail: 'Prioritized sync plan — what to align and how' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const REPO_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ repos: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, path: { type: 'string' }, role: { type: 'string' } }, required: ['name', 'path'] } },
18
+ referenceRepo: { type: 'string' },
19
+ syncDimensions: { type: 'array', items: { type: 'string' } },
20
+ },
21
+ required: ['repos', 'syncDimensions'],
22
+ };
23
+
24
+ const AUDIT_SCHEMA = {
25
+ type: 'object',
26
+ properties: {
27
+ repo: { type: 'string' },
28
+ divergences: { type: 'array', items: { type: 'object', properties: { dimension: { type: 'string' }, severity: { type: 'string', enum: ['critical', 'high', 'medium', 'low'] }, description: { type: 'string' }, fix: { type: 'string' } }, required: ['dimension', 'severity', 'description', 'fix'] } },
29
+ },
30
+ required: ['repo', 'divergences'],
31
+ };
32
+
33
+ const SYNC_SCHEMA = {
34
+ type: 'object',
35
+ properties: {
36
+ summary: { type: 'string' },
37
+ syncItems: { type: 'array', items: { type: 'object', properties: { repo: { type: 'string' }, dimension: { type: 'string' }, action: { type: 'string' }, priority: { type: 'string', enum: ['p0', 'p1', 'p2'] } }, required: ['repo', 'dimension', 'action', 'priority'] } },
38
+ },
39
+ required: ['summary', 'syncItems'],
40
+ };
41
+
42
+ const target = args || 'current workspace (list repo paths in args, comma-separated)';
43
+
44
+ phase('Discover');
45
+ const discovery = await agent(`Discover all related repositories in: "${target}". List each repo's name, path, and role (primary/service/library/config). Identify the reference/canonical repo (if any) and what dimensions should be synchronized: dependencies, CI config, lint config, code conventions, shared utilities, test patterns.`, { schema: REPO_SCHEMA, label: 'discover' });
46
+ if (!discovery) { return { target, error: 'discovery-agent-null' }; }
47
+ log(`Found ${discovery.repos.length} repos, ${discovery.syncDimensions.length} sync dimensions`);
48
+
49
+ phase('Audit');
50
+ const audits = await parallel(
51
+ discovery.repos.map(r => () => agent(`Audit repo "${r.name}" at "${r.path}" against the reference "${discovery.referenceRepo || 'best practices'}". Check dimensions: ${discovery.syncDimensions.join(', ')}. For each divergence: dimension, severity, what differs, and exact fix.`, { schema: AUDIT_SCHEMA, label: `audit:${r.name}`, phase: 'Audit' }))
52
+ );
53
+
54
+ phase('DivergenceMap');
55
+ const allDivergences = audits.filter(Boolean).flatMap(a => a.divergences.map(d => ({ repo: a.repo, ...d })));
56
+ log(`${allDivergences.length} divergences across ${discovery.repos.length} repos`);
57
+
58
+ phase('SyncPlan');
59
+ const divergenceText = allDivergences.slice(0, 20).map(d => `[${d.severity}] ${d.repo}/${d.dimension}: ${d.description} → ${d.fix}`).join('\n');
60
+ const syncPlan = await agent(`Create a sync plan for: "${target}"\n\nDivergences:\n${divergenceText}\n\nPrioritize by severity and group by dimension for efficient batching. P0=critical/security, P1=high/consistency, P2=medium/nice-to-have.`, { schema: SYNC_SCHEMA, label: 'sync-plan' });
61
+
62
+ return { target, discovery, audits: audits.filter(Boolean), syncPlan };
63
+ }
@@ -0,0 +1,148 @@
1
+ export const meta = {
2
+ name: 'mutation-testing',
3
+ description: 'Mutant generator → parallel kill-test agents → mutation score + survival report',
4
+ whenToUse: 'When assessing test suite quality — finds tests that pass even when code is subtly broken',
5
+ phases: [
6
+ { title: 'Analyze', detail: 'Identify mutable source lines: conditions, operators, return values' },
7
+ { title: 'Mutate', detail: 'Generate 10-15 specific mutation descriptions' },
8
+ { title: 'Kill', detail: 'Parallel kill-test per mutation — would existing tests catch it?' },
9
+ { title: 'Report', detail: 'Mutation score report with killed/survived/timeout breakdown' },
10
+ ],
11
+ };
12
+
13
+ export default async function run({ agent, parallel, pipeline, phase, log, args, budget }) {
14
+ const SOURCE_SCHEMA = {
15
+ type: 'object',
16
+ properties: {
17
+ sourceFiles: { type: 'array', items: { type: 'string' } },
18
+ testFiles: { type: 'array', items: { type: 'string' } },
19
+ mutableLines: {
20
+ type: 'array',
21
+ items: {
22
+ type: 'object',
23
+ properties: {
24
+ file: { type: 'string' },
25
+ lineNumber: { type: 'number' },
26
+ code: { type: 'string' },
27
+ mutationType: { type: 'string', enum: ['condition', 'operator', 'return-value', 'boundary', 'negation', 'constant'] },
28
+ },
29
+ required: ['file', 'code', 'mutationType'],
30
+ },
31
+ },
32
+ },
33
+ required: ['sourceFiles', 'testFiles', 'mutableLines'],
34
+ };
35
+
36
+ const MUTATIONS_SCHEMA = {
37
+ type: 'object',
38
+ properties: {
39
+ mutations: {
40
+ type: 'array',
41
+ items: {
42
+ type: 'object',
43
+ properties: {
44
+ id: { type: 'string' },
45
+ file: { type: 'string' },
46
+ original: { type: 'string' },
47
+ mutated: { type: 'string' },
48
+ mutationType: { type: 'string' },
49
+ description: { type: 'string' },
50
+ },
51
+ required: ['id', 'file', 'original', 'mutated', 'mutationType', 'description'],
52
+ },
53
+ },
54
+ },
55
+ required: ['mutations'],
56
+ };
57
+
58
+ const KILL_SCHEMA = {
59
+ type: 'object',
60
+ properties: {
61
+ mutationId: { type: 'string' },
62
+ status: { type: 'string', enum: ['killed', 'survived', 'timeout', 'equivalent'] },
63
+ killedBy: { type: 'string' },
64
+ reason: { type: 'string' },
65
+ suggestedTest: { type: 'string' },
66
+ },
67
+ required: ['mutationId', 'status', 'reason'],
68
+ };
69
+
70
+ const REPORT_SCHEMA = {
71
+ type: 'object',
72
+ properties: {
73
+ mutationScore: { type: 'number' },
74
+ summary: { type: 'string' },
75
+ killed: { type: 'number' },
76
+ survived: { type: 'number' },
77
+ timeout: { type: 'number' },
78
+ equivalent: { type: 'number' },
79
+ survivorDetails: {
80
+ type: 'array',
81
+ items: {
82
+ type: 'object',
83
+ properties: {
84
+ mutation: { type: 'string' },
85
+ suggestedTest: { type: 'string' },
86
+ },
87
+ required: ['mutation', 'suggestedTest'],
88
+ },
89
+ },
90
+ topWeaknesses: { type: 'array', items: { type: 'string' } },
91
+ },
92
+ required: ['mutationScore', 'summary', 'killed', 'survived', 'topWeaknesses'],
93
+ };
94
+
95
+ const target = args || 'current codebase (run from repo root)';
96
+
97
+ phase('Analyze');
98
+ log(`Analyzing source for mutable lines in: ${target}`);
99
+ const sourceAnalysis = await agent(
100
+ `Analyze the source code in: "${target}" to identify mutable lines for mutation testing. Find: (1) conditional expressions (if/else, ternary, switch), (2) arithmetic/comparison operators (+, -, *, /, >, <, ==, !=), (3) return values in key functions, (4) boundary values (0, -1, +1, null checks), (5) boolean negations. Also identify source files and their test files. List the 15 most testable mutable lines.`,
101
+ { schema: SOURCE_SCHEMA, label: 'analyze' }
102
+ );
103
+ if (!sourceAnalysis) { return { target, error: 'sourceAnalysis-agent-null' }; }
104
+ log(`Found ${sourceAnalysis.mutableLines.length} mutable lines across ${sourceAnalysis.sourceFiles.length} source files`);
105
+
106
+ phase('Mutate');
107
+ const mutableContext = sourceAnalysis.mutableLines.slice(0, 15).map(l => `${l.file}:${l.lineNumber || '?'} [${l.mutationType}] \`${l.code}\``).join('\n');
108
+ const mutationSpec = await agent(
109
+ `Generate 10-15 specific mutations for testing the test suite quality of: "${target}"\n\nMutable lines:\n${mutableContext}\n\nFor each mutation: assign unique ID (M01, M02...), show original code, mutated code, mutation type, and plain-English description of what changed. Focus on mutations that SHOULD be caught by good tests — boundary off-by-ones, condition flips, operator swaps.`,
110
+ { schema: MUTATIONS_SCHEMA, label: 'mutate' }
111
+ );
112
+ if (!mutationSpec) { return { target, sourceAnalysis, error: 'mutationSpec-agent-null' }; }
113
+ log(`Generated ${mutationSpec.mutations.length} mutations`);
114
+
115
+ phase('Kill');
116
+ const killResults = await parallel(
117
+ mutationSpec.mutations.map(m => () => agent(
118
+ `Assess if the existing test suite in: "${target}" would CATCH this mutation.\n\nMutation ${m.id}: In file ${m.file}, changed \`${m.original}\` to \`${m.mutated}\`.\nDescription: ${m.description}\n\nLook at the test files. Would any existing test fail if this mutation were applied? Answer: killed (test would fail), survived (no test catches it), equivalent (mutation doesn't change behavior), or timeout (unclear). If survived, suggest a specific test that would kill it.`,
119
+ { schema: KILL_SCHEMA, label: `kill:${m.id}`, phase: 'Kill' }
120
+ ))
121
+ );
122
+
123
+ phase('Report');
124
+ const killData = killResults.filter(Boolean);
125
+ const killed = killData.filter(r => r.status === 'killed').length;
126
+ const survived = killData.filter(r => r.status === 'survived').length;
127
+ const timeout = killData.filter(r => r.status === 'timeout').length;
128
+ const equivalent = killData.filter(r => r.status === 'equivalent').length;
129
+ const total = killed + survived + timeout;
130
+ const mutationScore = total > 0 ? Math.round((killed / total) * 100) : 0;
131
+
132
+ log(`Mutation score: ${mutationScore}% (${killed} killed, ${survived} survived, ${timeout} timeout)`);
133
+
134
+ const survivorSummary = killData
135
+ .filter(r => r.status === 'survived')
136
+ .map(r => {
137
+ const mutation = mutationSpec.mutations.find(m => m.id === r.mutationId);
138
+ return `${r.mutationId}: ${mutation ? mutation.description : r.mutationId} — suggested test: ${r.suggestedTest || 'none'}`;
139
+ })
140
+ .join('\n');
141
+
142
+ const report = await agent(
143
+ `Write a mutation testing report for: "${target}"\n\nMutation score: ${mutationScore}% (${killed}/${total} killed)\nKilled: ${killed}, Survived: ${survived}, Timeout: ${timeout}, Equivalent: ${equivalent}\n\nSurvivors:\n${survivorSummary || 'none'}\n\nDescribe: overall test suite quality, top weaknesses in test coverage exposed by survivors, specific suggested tests to add, and interpretation of the mutation score.`,
144
+ { schema: REPORT_SCHEMA, label: 'report' }
145
+ );
146
+
147
+ return { target, sourceAnalysis, mutations: mutationSpec.mutations, killResults: killData, report };
148
+ }