cap-pro 1.0.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/.claude-plugin/README.md +26 -0
- package/.claude-plugin/marketplace.json +24 -0
- package/.claude-plugin/plugin.json +24 -0
- package/LICENSE +21 -0
- package/README.ja-JP.md +834 -0
- package/README.ko-KR.md +823 -0
- package/README.md +806 -0
- package/README.pt-BR.md +452 -0
- package/README.zh-CN.md +800 -0
- package/agents/cap-architect.md +269 -0
- package/agents/cap-brainstormer.md +207 -0
- package/agents/cap-curator.md +276 -0
- package/agents/cap-debugger.md +365 -0
- package/agents/cap-designer.md +246 -0
- package/agents/cap-historian.md +464 -0
- package/agents/cap-migrator.md +291 -0
- package/agents/cap-prototyper.md +197 -0
- package/agents/cap-validator.md +308 -0
- package/bin/install.js +5433 -0
- package/cap/bin/cap-tools.cjs +853 -0
- package/cap/bin/lib/arc-scanner.cjs +344 -0
- package/cap/bin/lib/cap-affinity-engine.cjs +862 -0
- package/cap/bin/lib/cap-anchor.cjs +228 -0
- package/cap/bin/lib/cap-annotation-writer.cjs +340 -0
- package/cap/bin/lib/cap-checkpoint.cjs +434 -0
- package/cap/bin/lib/cap-cluster-detect.cjs +945 -0
- package/cap/bin/lib/cap-cluster-display.cjs +52 -0
- package/cap/bin/lib/cap-cluster-format.cjs +245 -0
- package/cap/bin/lib/cap-cluster-helpers.cjs +295 -0
- package/cap/bin/lib/cap-cluster-io.cjs +212 -0
- package/cap/bin/lib/cap-completeness.cjs +540 -0
- package/cap/bin/lib/cap-deps.cjs +583 -0
- package/cap/bin/lib/cap-design-families.cjs +332 -0
- package/cap/bin/lib/cap-design.cjs +966 -0
- package/cap/bin/lib/cap-divergence-detector.cjs +400 -0
- package/cap/bin/lib/cap-doctor.cjs +752 -0
- package/cap/bin/lib/cap-feature-map-internals.cjs +19 -0
- package/cap/bin/lib/cap-feature-map-migrate.cjs +335 -0
- package/cap/bin/lib/cap-feature-map-monorepo.cjs +885 -0
- package/cap/bin/lib/cap-feature-map-shard.cjs +315 -0
- package/cap/bin/lib/cap-feature-map.cjs +1943 -0
- package/cap/bin/lib/cap-fitness-score.cjs +1075 -0
- package/cap/bin/lib/cap-impact-analysis.cjs +652 -0
- package/cap/bin/lib/cap-learn-review.cjs +1072 -0
- package/cap/bin/lib/cap-learning-signals.cjs +627 -0
- package/cap/bin/lib/cap-loader.cjs +227 -0
- package/cap/bin/lib/cap-logger.cjs +57 -0
- package/cap/bin/lib/cap-memory-bridge.cjs +764 -0
- package/cap/bin/lib/cap-memory-confidence.cjs +452 -0
- package/cap/bin/lib/cap-memory-dir.cjs +987 -0
- package/cap/bin/lib/cap-memory-engine.cjs +698 -0
- package/cap/bin/lib/cap-memory-extends.cjs +398 -0
- package/cap/bin/lib/cap-memory-graph.cjs +790 -0
- package/cap/bin/lib/cap-memory-migrate.cjs +2015 -0
- package/cap/bin/lib/cap-memory-pin.cjs +183 -0
- package/cap/bin/lib/cap-memory-platform.cjs +490 -0
- package/cap/bin/lib/cap-memory-prune.cjs +707 -0
- package/cap/bin/lib/cap-memory-schema.cjs +812 -0
- package/cap/bin/lib/cap-migrate-tags.cjs +309 -0
- package/cap/bin/lib/cap-migrate.cjs +540 -0
- package/cap/bin/lib/cap-pattern-apply.cjs +1203 -0
- package/cap/bin/lib/cap-pattern-pipeline.cjs +1034 -0
- package/cap/bin/lib/cap-plugin-manifest.cjs +80 -0
- package/cap/bin/lib/cap-realtime-affinity.cjs +399 -0
- package/cap/bin/lib/cap-reconcile.cjs +570 -0
- package/cap/bin/lib/cap-research-gate.cjs +218 -0
- package/cap/bin/lib/cap-scope-filter.cjs +402 -0
- package/cap/bin/lib/cap-semantic-pipeline.cjs +1038 -0
- package/cap/bin/lib/cap-session-extract.cjs +987 -0
- package/cap/bin/lib/cap-session.cjs +445 -0
- package/cap/bin/lib/cap-snapshot-linkage.cjs +963 -0
- package/cap/bin/lib/cap-stack-docs.cjs +646 -0
- package/cap/bin/lib/cap-tag-observer.cjs +371 -0
- package/cap/bin/lib/cap-tag-scanner.cjs +1766 -0
- package/cap/bin/lib/cap-telemetry.cjs +466 -0
- package/cap/bin/lib/cap-test-audit.cjs +1438 -0
- package/cap/bin/lib/cap-thread-migrator.cjs +307 -0
- package/cap/bin/lib/cap-thread-synthesis.cjs +545 -0
- package/cap/bin/lib/cap-thread-tracker.cjs +519 -0
- package/cap/bin/lib/cap-trace.cjs +399 -0
- package/cap/bin/lib/cap-trust-mode.cjs +336 -0
- package/cap/bin/lib/cap-ui-design-editor.cjs +642 -0
- package/cap/bin/lib/cap-ui-mind-map.cjs +712 -0
- package/cap/bin/lib/cap-ui-thread-nav.cjs +693 -0
- package/cap/bin/lib/cap-ui.cjs +1245 -0
- package/cap/bin/lib/cap-upgrade.cjs +1028 -0
- package/cap/bin/lib/cli/arg-helpers.cjs +49 -0
- package/cap/bin/lib/cli/frontmatter-router.cjs +31 -0
- package/cap/bin/lib/cli/init-router.cjs +68 -0
- package/cap/bin/lib/cli/phase-router.cjs +102 -0
- package/cap/bin/lib/cli/state-router.cjs +61 -0
- package/cap/bin/lib/cli/template-router.cjs +37 -0
- package/cap/bin/lib/cli/uat-router.cjs +29 -0
- package/cap/bin/lib/cli/validation-router.cjs +26 -0
- package/cap/bin/lib/cli/verification-router.cjs +31 -0
- package/cap/bin/lib/cli/workstream-router.cjs +39 -0
- package/cap/bin/lib/commands.cjs +961 -0
- package/cap/bin/lib/config.cjs +467 -0
- package/cap/bin/lib/convention-reader.cjs +258 -0
- package/cap/bin/lib/core.cjs +1241 -0
- package/cap/bin/lib/feature-aggregator.cjs +423 -0
- package/cap/bin/lib/frontmatter.cjs +337 -0
- package/cap/bin/lib/init.cjs +1443 -0
- package/cap/bin/lib/manifest-generator.cjs +383 -0
- package/cap/bin/lib/milestone.cjs +253 -0
- package/cap/bin/lib/model-profiles.cjs +69 -0
- package/cap/bin/lib/monorepo-context.cjs +226 -0
- package/cap/bin/lib/monorepo-migrator.cjs +509 -0
- package/cap/bin/lib/phase.cjs +889 -0
- package/cap/bin/lib/profile-output.cjs +989 -0
- package/cap/bin/lib/profile-pipeline.cjs +540 -0
- package/cap/bin/lib/roadmap.cjs +330 -0
- package/cap/bin/lib/security.cjs +394 -0
- package/cap/bin/lib/session-manager.cjs +292 -0
- package/cap/bin/lib/skeleton-generator.cjs +179 -0
- package/cap/bin/lib/state.cjs +1032 -0
- package/cap/bin/lib/template.cjs +231 -0
- package/cap/bin/lib/test-detector.cjs +62 -0
- package/cap/bin/lib/uat.cjs +283 -0
- package/cap/bin/lib/verify.cjs +889 -0
- package/cap/bin/lib/workspace-detector.cjs +371 -0
- package/cap/bin/lib/workstream.cjs +492 -0
- package/cap/commands/gsd/workstreams.md +63 -0
- package/cap/references/arc-standard.md +315 -0
- package/cap/references/cap-agent-architecture.md +101 -0
- package/cap/references/cap-gitignore-template +9 -0
- package/cap/references/cap-zero-deps.md +158 -0
- package/cap/references/checkpoints.md +778 -0
- package/cap/references/continuation-format.md +249 -0
- package/cap/references/contract-test-templates.md +312 -0
- package/cap/references/feature-map-template.md +25 -0
- package/cap/references/git-integration.md +295 -0
- package/cap/references/git-planning-commit.md +38 -0
- package/cap/references/model-profiles.md +174 -0
- package/cap/references/phase-numbering.md +126 -0
- package/cap/references/planning-config.md +202 -0
- package/cap/references/property-test-templates.md +316 -0
- package/cap/references/security-test-templates.md +347 -0
- package/cap/references/session-template.json +8 -0
- package/cap/references/tdd.md +263 -0
- package/cap/references/user-profiling.md +681 -0
- package/cap/references/verification-patterns.md +612 -0
- package/cap/templates/UAT.md +265 -0
- package/cap/templates/claude-md.md +175 -0
- package/cap/templates/codebase/architecture.md +255 -0
- package/cap/templates/codebase/concerns.md +310 -0
- package/cap/templates/codebase/conventions.md +307 -0
- package/cap/templates/codebase/integrations.md +280 -0
- package/cap/templates/codebase/stack.md +186 -0
- package/cap/templates/codebase/structure.md +285 -0
- package/cap/templates/codebase/testing.md +480 -0
- package/cap/templates/config.json +44 -0
- package/cap/templates/context.md +352 -0
- package/cap/templates/continue-here.md +78 -0
- package/cap/templates/copilot-instructions.md +7 -0
- package/cap/templates/debug-subagent-prompt.md +91 -0
- package/cap/templates/discussion-log.md +63 -0
- package/cap/templates/milestone-archive.md +123 -0
- package/cap/templates/milestone.md +115 -0
- package/cap/templates/phase-prompt.md +610 -0
- package/cap/templates/planner-subagent-prompt.md +117 -0
- package/cap/templates/project.md +186 -0
- package/cap/templates/requirements.md +231 -0
- package/cap/templates/research-project/ARCHITECTURE.md +204 -0
- package/cap/templates/research-project/FEATURES.md +147 -0
- package/cap/templates/research-project/PITFALLS.md +200 -0
- package/cap/templates/research-project/STACK.md +120 -0
- package/cap/templates/research-project/SUMMARY.md +170 -0
- package/cap/templates/research.md +552 -0
- package/cap/templates/roadmap.md +202 -0
- package/cap/templates/state.md +176 -0
- package/cap/templates/summary.md +364 -0
- package/cap/templates/user-preferences.md +498 -0
- package/cap/templates/verification-report.md +322 -0
- package/cap/workflows/add-phase.md +112 -0
- package/cap/workflows/add-tests.md +351 -0
- package/cap/workflows/add-todo.md +158 -0
- package/cap/workflows/audit-milestone.md +340 -0
- package/cap/workflows/audit-uat.md +109 -0
- package/cap/workflows/autonomous.md +891 -0
- package/cap/workflows/check-todos.md +177 -0
- package/cap/workflows/cleanup.md +152 -0
- package/cap/workflows/complete-milestone.md +767 -0
- package/cap/workflows/diagnose-issues.md +231 -0
- package/cap/workflows/discovery-phase.md +289 -0
- package/cap/workflows/discuss-phase-assumptions.md +653 -0
- package/cap/workflows/discuss-phase.md +1049 -0
- package/cap/workflows/do.md +104 -0
- package/cap/workflows/execute-phase.md +846 -0
- package/cap/workflows/execute-plan.md +514 -0
- package/cap/workflows/fast.md +105 -0
- package/cap/workflows/forensics.md +265 -0
- package/cap/workflows/health.md +181 -0
- package/cap/workflows/help.md +660 -0
- package/cap/workflows/insert-phase.md +130 -0
- package/cap/workflows/list-phase-assumptions.md +178 -0
- package/cap/workflows/list-workspaces.md +56 -0
- package/cap/workflows/manager.md +362 -0
- package/cap/workflows/map-codebase.md +377 -0
- package/cap/workflows/milestone-summary.md +223 -0
- package/cap/workflows/new-milestone.md +486 -0
- package/cap/workflows/new-project.md +1250 -0
- package/cap/workflows/new-workspace.md +237 -0
- package/cap/workflows/next.md +97 -0
- package/cap/workflows/node-repair.md +92 -0
- package/cap/workflows/note.md +156 -0
- package/cap/workflows/pause-work.md +176 -0
- package/cap/workflows/plan-milestone-gaps.md +273 -0
- package/cap/workflows/plan-phase.md +857 -0
- package/cap/workflows/plant-seed.md +169 -0
- package/cap/workflows/pr-branch.md +129 -0
- package/cap/workflows/profile-user.md +449 -0
- package/cap/workflows/progress.md +507 -0
- package/cap/workflows/quick.md +757 -0
- package/cap/workflows/remove-phase.md +155 -0
- package/cap/workflows/remove-workspace.md +90 -0
- package/cap/workflows/research-phase.md +82 -0
- package/cap/workflows/resume-project.md +326 -0
- package/cap/workflows/review.md +228 -0
- package/cap/workflows/session-report.md +146 -0
- package/cap/workflows/settings.md +283 -0
- package/cap/workflows/ship.md +228 -0
- package/cap/workflows/stats.md +60 -0
- package/cap/workflows/transition.md +671 -0
- package/cap/workflows/ui-phase.md +298 -0
- package/cap/workflows/ui-review.md +161 -0
- package/cap/workflows/update.md +323 -0
- package/cap/workflows/validate-phase.md +170 -0
- package/cap/workflows/verify-phase.md +254 -0
- package/cap/workflows/verify-work.md +637 -0
- package/commands/cap/annotate.md +165 -0
- package/commands/cap/brainstorm.md +393 -0
- package/commands/cap/checkpoint.md +106 -0
- package/commands/cap/completeness.md +94 -0
- package/commands/cap/continue.md +72 -0
- package/commands/cap/debug.md +588 -0
- package/commands/cap/deps.md +169 -0
- package/commands/cap/design.md +479 -0
- package/commands/cap/init.md +354 -0
- package/commands/cap/iterate.md +249 -0
- package/commands/cap/learn.md +459 -0
- package/commands/cap/memory.md +275 -0
- package/commands/cap/migrate-feature-map.md +91 -0
- package/commands/cap/migrate-memory.md +108 -0
- package/commands/cap/migrate-tags.md +91 -0
- package/commands/cap/migrate.md +131 -0
- package/commands/cap/prototype.md +510 -0
- package/commands/cap/reconcile.md +121 -0
- package/commands/cap/review.md +360 -0
- package/commands/cap/save.md +72 -0
- package/commands/cap/scan.md +404 -0
- package/commands/cap/start.md +356 -0
- package/commands/cap/status.md +118 -0
- package/commands/cap/test-audit.md +262 -0
- package/commands/cap/test.md +394 -0
- package/commands/cap/trace.md +133 -0
- package/commands/cap/ui.md +167 -0
- package/hooks/dist/cap-check-update.js +115 -0
- package/hooks/dist/cap-context-monitor.js +185 -0
- package/hooks/dist/cap-learn-review-hook.js +114 -0
- package/hooks/dist/cap-learning-hook.js +192 -0
- package/hooks/dist/cap-memory.js +299 -0
- package/hooks/dist/cap-prompt-guard.js +97 -0
- package/hooks/dist/cap-statusline.js +157 -0
- package/hooks/dist/cap-tag-observer.js +115 -0
- package/hooks/dist/cap-version-check.js +112 -0
- package/hooks/dist/cap-workflow-guard.js +175 -0
- package/hooks/hooks.json +55 -0
- package/package.json +58 -0
- package/scripts/base64-scan.sh +262 -0
- package/scripts/build-hooks.js +93 -0
- package/scripts/cap-removal-checklist.md +202 -0
- package/scripts/prompt-injection-scan.sh +199 -0
- package/scripts/run-tests.cjs +181 -0
- package/scripts/secret-scan.sh +227 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:deps
|
|
3
|
+
description: "Infer feature dependencies from source imports, diff against FEATURE-MAP DEPENDS_ON, optionally apply or render a Mermaid graph. --design DT-NNN shows feature impact for a design token (F-063)."
|
|
4
|
+
argument-hint: "[--auto-fix] [--graph] [--remove-extraneous] [--json] [--design DT-NNN|DC-NNN]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<!-- @cap-context CAP v3 opt-in dependency inference command (F-049). Reads code + FEATURE-MAP, writes only with explicit --auto-fix. -->
|
|
12
|
+
<!-- @cap-decision Default mode is read-only diff. Writes require --auto-fix AND an interactive confirmation step. --graph is always side-effect-free. -->
|
|
13
|
+
<!-- @cap-feature(feature:F-049, primary:true) /cap:deps orchestrator surfaces cap-deps.cjs functions to the user. -->
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Surface F-049's dependency-inference pipeline:
|
|
17
|
+
|
|
18
|
+
- Scan tagged source files for `require`/`import` statements
|
|
19
|
+
- Resolve each to a feature ID via the tag scanner
|
|
20
|
+
- Diff the inferred dependency set against `**Depends on:**` lines in FEATURE-MAP.md
|
|
21
|
+
- Optionally apply the diff (writes FEATURE-MAP.md) or render a Mermaid graph
|
|
22
|
+
|
|
23
|
+
**Flags:**
|
|
24
|
+
- `--auto-fix` — write inferred `**Depends on:**` lines back to FEATURE-MAP.md. Requires a confirmation prompt.
|
|
25
|
+
- `--remove-extraneous` — when applying, also remove declared deps not found by the scanner (default: only add missing).
|
|
26
|
+
- `--graph` — emit a Mermaid flowchart of the feature dependency graph. Side-effect-free.
|
|
27
|
+
- `--json` — emit raw diff JSON instead of formatted report.
|
|
28
|
+
</objective>
|
|
29
|
+
|
|
30
|
+
<context>
|
|
31
|
+
$ARGUMENTS
|
|
32
|
+
</context>
|
|
33
|
+
|
|
34
|
+
<process>
|
|
35
|
+
|
|
36
|
+
## Step 0a: Design-ID impact fast-path (F-063 --design DT-NNN / DC-NNN)
|
|
37
|
+
|
|
38
|
+
<!-- @cap-todo(ac:F-063/AC-6) /cap:deps --design DT-NNN prints every feature whose usesDesign includes the ID. -->
|
|
39
|
+
<!-- @cap-decision Fast-path bypasses the F-049 opt-in gate — design impact is read-only, reads FEATURE-MAP.md only, no tag scanning. -->
|
|
40
|
+
|
|
41
|
+
If `$ARGUMENTS` contains `--design <ID>`, short-circuit the rest of the command:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
node -e "
|
|
45
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
46
|
+
const deps = require('./cap/bin/lib/cap-deps.cjs');
|
|
47
|
+
const designId = process.argv[1];
|
|
48
|
+
if (!/^(DT-\\d{3,}|DC-\\d{3,})$/.test(designId)) {
|
|
49
|
+
console.error('Invalid --design ID. Expected DT-NNN or DC-NNN.');
|
|
50
|
+
process.exit(2);
|
|
51
|
+
}
|
|
52
|
+
// @cap-todo(ac:F-081/AC-4 iter:2) Migrated to {safe: true} opt-in to preserve CLI on duplicate-ID FEATURE-MAP.
|
|
53
|
+
// @cap-decision(F-081/iter2) Warn on parseError; continue with partial map for read-only display.
|
|
54
|
+
const map = fm.readFeatureMap(process.cwd(), undefined, { safe: true });
|
|
55
|
+
if (map && map.parseError) {
|
|
56
|
+
console.warn('cap: deps --design — duplicate feature ID detected, report uses partial map: ' + String(map.parseError.message).trim());
|
|
57
|
+
}
|
|
58
|
+
const using = deps.findFeaturesUsingDesignId(map, designId);
|
|
59
|
+
console.log(deps.formatDesignImpactReport(designId, using));
|
|
60
|
+
" '<DESIGN_ID>'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Display the output verbatim, then stop.
|
|
64
|
+
|
|
65
|
+
## Step 0: Check opt-in config
|
|
66
|
+
|
|
67
|
+
F-049 is opt-in. Verify `.cap/config.json` has `autoDepsInference.enabled === true` before doing any work:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
node -e "
|
|
71
|
+
const deps = require('./cap/bin/lib/cap-deps.cjs');
|
|
72
|
+
const cfg = deps.loadDepsConfig(process.cwd());
|
|
73
|
+
if (!cfg.enabled) {
|
|
74
|
+
console.error('F-049 (auto dependency inference) is opt-in and not enabled for this project.');
|
|
75
|
+
console.error('To enable: add { \"autoDepsInference\": { \"enabled\": true } } to .cap/config.json');
|
|
76
|
+
process.exit(2);
|
|
77
|
+
}
|
|
78
|
+
console.log('enabled=' + cfg.enabled);
|
|
79
|
+
"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
If exit code 2, stop and show the message verbatim.
|
|
83
|
+
|
|
84
|
+
## Step 1: Parse flags
|
|
85
|
+
|
|
86
|
+
Read `$ARGUMENTS`. Extract booleans:
|
|
87
|
+
- `--auto-fix` → `autoFix`
|
|
88
|
+
- `--remove-extraneous` → `removeExtraneous`
|
|
89
|
+
- `--graph` → `renderGraph`
|
|
90
|
+
- `--json` → `jsonOutput`
|
|
91
|
+
|
|
92
|
+
## Step 2: Run inference + diff
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
node -e "
|
|
96
|
+
const scanner = require('./cap/bin/lib/cap-tag-scanner.cjs');
|
|
97
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
98
|
+
const deps = require('./cap/bin/lib/cap-deps.cjs');
|
|
99
|
+
|
|
100
|
+
const root = process.cwd();
|
|
101
|
+
const tags = scanner.scanDirectory(root);
|
|
102
|
+
// @cap-todo(ac:F-081/AC-4 iter:2) Migrated to {safe: true} opt-in to preserve CLI on duplicate-ID FEATURE-MAP.
|
|
103
|
+
// @cap-decision(F-081/iter2) Warn on parseError; continue with partial map for read-only display.
|
|
104
|
+
const featureMap = fm.readFeatureMap(root, undefined, { safe: true });
|
|
105
|
+
if (featureMap && featureMap.parseError) {
|
|
106
|
+
console.warn('cap: deps — duplicate feature ID detected, diff uses partial map: ' + String(featureMap.parseError.message).trim());
|
|
107
|
+
}
|
|
108
|
+
const inferred = deps.inferFeatureDeps(tags, root);
|
|
109
|
+
const diff = deps.diffDeclaredVsInferred(featureMap, inferred);
|
|
110
|
+
|
|
111
|
+
const json = process.argv[1] === 'true';
|
|
112
|
+
const graph = process.argv[2] === 'true';
|
|
113
|
+
|
|
114
|
+
if (json) {
|
|
115
|
+
console.log(JSON.stringify({ diff, inferred }, null, 2));
|
|
116
|
+
} else if (graph) {
|
|
117
|
+
console.log(deps.renderMermaidGraph(featureMap, inferred));
|
|
118
|
+
} else {
|
|
119
|
+
console.log(deps.formatDiffReport(diff));
|
|
120
|
+
}
|
|
121
|
+
" '<JSON>' '<GRAPH>'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Display output verbatim.
|
|
125
|
+
|
|
126
|
+
If `--graph` or `--json`, stop here — read-only modes do not prompt or write.
|
|
127
|
+
|
|
128
|
+
## Step 3: Apply diff (only with --auto-fix)
|
|
129
|
+
|
|
130
|
+
If `autoFix` is true and any diff row has `missing.length > 0` or (when `removeExtraneous`) `extraneous.length > 0`:
|
|
131
|
+
|
|
132
|
+
Show the diff report again and prompt the user explicitly:
|
|
133
|
+
|
|
134
|
+
> "Apply the inferred dependencies to FEATURE-MAP.md? (yes/no)"
|
|
135
|
+
|
|
136
|
+
On `yes`:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
node -e "
|
|
140
|
+
const scanner = require('./cap/bin/lib/cap-tag-scanner.cjs');
|
|
141
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
142
|
+
const deps = require('./cap/bin/lib/cap-deps.cjs');
|
|
143
|
+
|
|
144
|
+
const root = process.cwd();
|
|
145
|
+
const tags = scanner.scanDirectory(root);
|
|
146
|
+
// @cap-todo(ac:F-081/AC-4 iter:2) Migrated to {safe: true} opt-in to preserve CLI on duplicate-ID FEATURE-MAP.
|
|
147
|
+
// @cap-decision(F-081/iter2) Warn on parseError; continue with partial map for read-only display.
|
|
148
|
+
const featureMap = fm.readFeatureMap(root, undefined, { safe: true });
|
|
149
|
+
if (featureMap && featureMap.parseError) {
|
|
150
|
+
console.warn('cap: deps --auto-fix — duplicate feature ID detected, diff uses partial map: ' + String(featureMap.parseError.message).trim());
|
|
151
|
+
}
|
|
152
|
+
const inferred = deps.inferFeatureDeps(tags, root);
|
|
153
|
+
const diff = deps.diffDeclaredVsInferred(featureMap, inferred);
|
|
154
|
+
const removeExtraneous = process.argv[1] === 'true';
|
|
155
|
+
const result = deps.applyInferredDeps(root, diff, { removeExtraneous });
|
|
156
|
+
console.log('Updated: ' + result.updated.length + ' features');
|
|
157
|
+
for (const f of result.updated) console.log(' ' + f);
|
|
158
|
+
" '<REMOVE_EXTRANEOUS>'
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
On `no`: print "Aborted — FEATURE-MAP.md unchanged." and stop.
|
|
162
|
+
|
|
163
|
+
## Step 4: Suggest next action
|
|
164
|
+
|
|
165
|
+
- If diff was empty → "Dependency graph is consistent. Next time a feature imports another module, re-run /cap:deps to check for drift."
|
|
166
|
+
- If diff applied → "Re-run /cap:review to verify the FEATURE-MAP changes, or `git diff FEATURE-MAP.md` to inspect."
|
|
167
|
+
- If `--graph` → "Paste the Mermaid block into a markdown preview to visualize the dependency flow."
|
|
168
|
+
|
|
169
|
+
</process>
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:design
|
|
3
|
+
description: Design system bootstrap. Runs a 3-question aesthetic wizard (--new), extends DESIGN.md (--extend), scopes design usage to a feature (--scope F-NNN), or reviews DESIGN.md against Anti-Slop rules (--review). Spawns cap-designer agent. Deterministic, idempotent.
|
|
4
|
+
argument-hint: "[--new | --extend | --scope F-NNN | --review]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Bash
|
|
10
|
+
- Task
|
|
11
|
+
- AskUserQuestion
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<!-- @cap-context CAP F-062 /cap:design command -- orchestrates DESIGN.md creation and extension. Spawns cap-designer agent for the conversational wizard, then calls cap-design.cjs to produce the deterministic DESIGN.md. -->
|
|
15
|
+
<!-- @cap-decision Command layer owns ALL file I/O. Agent returns wizard answers only. Mirrors the /cap:brainstorm pattern. -->
|
|
16
|
+
<!-- @cap-decision Mapping from answers to family is deterministic (cap-design.cjs FAMILY_MAP) so AC-7 idempotence holds regardless of LLM nondeterminism. -->
|
|
17
|
+
<!-- @cap-constraint No DESIGN.md writes without explicit user approval on --new. --extend requires confirmation before merge. -->
|
|
18
|
+
|
|
19
|
+
<!-- @cap-feature(feature:F-062) cap:design Core — DESIGN.md + Aesthetic Picker -->
|
|
20
|
+
<!-- @cap-feature(feature:F-063) cap:design --scope — Feature-scoped design usage dialog -->
|
|
21
|
+
<!-- @cap-feature(feature:F-064) cap:design --review — Anti-Slop-Check (read-only review of DESIGN.md) -->
|
|
22
|
+
|
|
23
|
+
<objective>
|
|
24
|
+
<!-- @cap-todo(ac:F-062/AC-1) /cap:design --new spawns cap-designer for greenfield design setup -->
|
|
25
|
+
<!-- @cap-todo(ac:F-063/AC-4) /cap:design --scope F-NNN spawns cap-designer in scope-mode: agent asks which tokens/components F-NNN uses, updates uses-design in FEATURE-MAP.md, and creates missing DT/DC entries in DESIGN.md. -->
|
|
26
|
+
<!-- @cap-todo(ac:F-064/AC-1) /cap:design --review spawns cap-designer in review-mode to check DESIGN.md against Anti-Slop rules -->
|
|
27
|
+
|
|
28
|
+
Spawns `cap-designer` in one of four modes:
|
|
29
|
+
- `--new` — run the 3-question aesthetic wizard, write DESIGN.md.
|
|
30
|
+
- `--extend` — append tokens/components to existing DESIGN.md (no overwrite).
|
|
31
|
+
- `--scope F-NNN` — feature-scoped dialog: record which DT/DC IDs the feature uses in FEATURE-MAP.md.
|
|
32
|
+
- `--review` — read-only Anti-Slop check. Writes report to `.cap/DESIGN-REVIEW.md`. DESIGN.md is never modified.
|
|
33
|
+
|
|
34
|
+
**Flags:**
|
|
35
|
+
- `--new` — fresh DESIGN.md via wizard (refuses to overwrite an existing DESIGN.md without explicit confirm).
|
|
36
|
+
- `--extend` — append tokens/components to an existing DESIGN.md (does not overwrite existing entries).
|
|
37
|
+
- `--scope F-NNN` — opens a focused dialog, writes `**Uses design:**` line to FEATURE-MAP.md, creates any missing DT/DC entries in DESIGN.md.
|
|
38
|
+
- `--review` — read-only review. Loads DESIGN.md + optional `.cap/design-rules.md`, runs rule checks, writes `.cap/DESIGN-REVIEW.md`. Never touches DESIGN.md.
|
|
39
|
+
|
|
40
|
+
**Key guarantees:**
|
|
41
|
+
- Idempotent: same wizard answers produce a byte-identical DESIGN.md (AC-7).
|
|
42
|
+
- Append-only on `--extend`: existing entries are never overwritten (AC-5).
|
|
43
|
+
- Anti-Slop constraints surfaced in every generated DESIGN.md (AC-6).
|
|
44
|
+
- Stable-ID guarantee (F-063/D4): once a DT-NNN / DC-NNN is assigned, it is never renumbered.
|
|
45
|
+
- Review is read-only (F-064/AC-3): no writes to DESIGN.md.
|
|
46
|
+
- Review is idempotent (F-064/AC-5): same DESIGN.md + same rules → byte-identical report.
|
|
47
|
+
|
|
48
|
+
</objective>
|
|
49
|
+
|
|
50
|
+
<context>
|
|
51
|
+
$ARGUMENTS
|
|
52
|
+
|
|
53
|
+
@DESIGN.md
|
|
54
|
+
@FEATURE-MAP.md
|
|
55
|
+
</context>
|
|
56
|
+
|
|
57
|
+
<process>
|
|
58
|
+
|
|
59
|
+
## Step 0: Parse flags
|
|
60
|
+
|
|
61
|
+
<!-- @cap-todo(ac:F-064/AC-1) --review flag dispatches to Step 1c fast-path (review flow) -->
|
|
62
|
+
|
|
63
|
+
Check `$ARGUMENTS` for:
|
|
64
|
+
- `--new` -- set `mode = "new"`
|
|
65
|
+
- `--extend` -- set `mode = "extend"`
|
|
66
|
+
- `--scope F-NNN` -- set `mode = "scope"` and capture `scope_feature_id` (must match `F-\d{3}`)
|
|
67
|
+
- `--review` -- set `mode = "review"`
|
|
68
|
+
|
|
69
|
+
If none of the flags is present, default to `--new` but prompt for confirmation if DESIGN.md already exists (see Step 1).
|
|
70
|
+
|
|
71
|
+
Log: `cap:design | mode: {mode}`{ " | feature: " + scope_feature_id if mode === 'scope' }
|
|
72
|
+
|
|
73
|
+
## Step 1: Check existing DESIGN.md
|
|
74
|
+
|
|
75
|
+
<!-- @cap-todo(ac:F-062/AC-4) DESIGN.md lives at project root next to FEATURE-MAP.md, versioned via git -->
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
node -e "
|
|
79
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
80
|
+
const content = d.readDesignMd(process.cwd());
|
|
81
|
+
console.log(JSON.stringify({ exists: content !== null, length: content ? content.length : 0 }));
|
|
82
|
+
"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Store as `design_state`.
|
|
86
|
+
|
|
87
|
+
Behavior by mode:
|
|
88
|
+
|
|
89
|
+
- `mode === "new"` AND `design_state.exists === true`:
|
|
90
|
+
Use AskUserQuestion: `"DESIGN.md already exists ({design_state.length} bytes). Overwrite with fresh wizard output? [yes / cancel / switch to --extend]"`
|
|
91
|
+
- `yes` — continue (the idempotence guarantee means rerunning with same answers is a no-op anyway).
|
|
92
|
+
- `switch to --extend` — set `mode = "extend"` and continue.
|
|
93
|
+
- otherwise — abort with message `"cap:design cancelled. No changes made."`.
|
|
94
|
+
|
|
95
|
+
- `mode === "extend"` AND `design_state.exists === false`:
|
|
96
|
+
Abort: `"No DESIGN.md found to extend. Run /cap:design --new first."`
|
|
97
|
+
|
|
98
|
+
- `mode === "scope"` AND `design_state.exists === false`:
|
|
99
|
+
Abort: `"No DESIGN.md found. Run /cap:design --new first, then /cap:design --scope F-NNN."`
|
|
100
|
+
|
|
101
|
+
- `mode === "review"` AND `design_state.exists === false`:
|
|
102
|
+
Abort: `"No DESIGN.md found to review. Run /cap:design --new first."`
|
|
103
|
+
|
|
104
|
+
## Step 1b: Scope-mode fast-path (F-063)
|
|
105
|
+
|
|
106
|
+
<!-- @cap-todo(ac:F-063/AC-4) --scope F-NNN opens a focused dialog: which tokens/components does F-NNN use? -->
|
|
107
|
+
|
|
108
|
+
If `mode === "scope"`, run the scope flow and skip Steps 2-4.
|
|
109
|
+
|
|
110
|
+
### 1b.1 Validate the feature ID
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
node -e "
|
|
114
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
115
|
+
const fid = process.argv[1];
|
|
116
|
+
if (!/^F-\\d{3}$/.test(fid)) {
|
|
117
|
+
console.error('Invalid feature ID. Expected format F-NNN.');
|
|
118
|
+
process.exit(2);
|
|
119
|
+
}
|
|
120
|
+
// @cap-todo(ac:F-081/AC-4 iter:2) Migrated to {safe: true} opt-in to preserve CLI on duplicate-ID FEATURE-MAP.
|
|
121
|
+
// @cap-decision(F-081/iter2) Warn on parseError; continue with partial map for read-only display.
|
|
122
|
+
const map = fm.readFeatureMap(process.cwd(), undefined, { safe: true });
|
|
123
|
+
if (map && map.parseError) {
|
|
124
|
+
console.warn('cap: design --scope — duplicate feature ID detected, lookup uses partial map: ' + String(map.parseError.message).trim());
|
|
125
|
+
}
|
|
126
|
+
const f = map.features.find(x => x.id === fid);
|
|
127
|
+
if (!f) {
|
|
128
|
+
console.error('Feature ' + fid + ' not found in FEATURE-MAP.md.');
|
|
129
|
+
process.exit(3);
|
|
130
|
+
}
|
|
131
|
+
console.log(JSON.stringify({ id: f.id, title: f.title, state: f.state, usesDesign: f.usesDesign || [] }));
|
|
132
|
+
" '<FEATURE_ID>'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Store as `scope_feature`.
|
|
136
|
+
|
|
137
|
+
### 1b.2 Parse existing DESIGN.md IDs
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
node -e "
|
|
141
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
142
|
+
const md = d.readDesignMd(process.cwd());
|
|
143
|
+
const ids = d.parseDesignIds(md || '');
|
|
144
|
+
console.log(JSON.stringify({
|
|
145
|
+
tokens: Object.values(ids.byToken).map(t => ({ id: t.id, key: t.key })),
|
|
146
|
+
components: Object.values(ids.byComponent).map(c => ({ id: c.id, name: c.name })),
|
|
147
|
+
}));
|
|
148
|
+
"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Store as `design_catalog`.
|
|
152
|
+
|
|
153
|
+
### 1b.3 Spawn cap-designer in scope mode
|
|
154
|
+
|
|
155
|
+
Spawn `cap-designer` via Task with:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
**Mode:** scope
|
|
159
|
+
**Feature:** {scope_feature.id} — {scope_feature.title}
|
|
160
|
+
**Currently declared uses-design:** {scope_feature.usesDesign.join(', ') or '(none)'}
|
|
161
|
+
**Available tokens:** {design_catalog.tokens map as "DT-001 primary", ...}
|
|
162
|
+
**Available components:** {design_catalog.components map as "DC-001 Button", ...}
|
|
163
|
+
|
|
164
|
+
**Instructions (scope mode):**
|
|
165
|
+
- Ask which tokens the feature uses. Offer the existing DT list as options plus "add new".
|
|
166
|
+
- Ask which components the feature uses. Offer the existing DC list plus "add new".
|
|
167
|
+
- For each "add new", collect name + (for tokens: hex value; for components: variants + states).
|
|
168
|
+
- Do NOT write files. Return structured output.
|
|
169
|
+
|
|
170
|
+
**Return format:**
|
|
171
|
+
|
|
172
|
+
=== SCOPE OUTPUT ===
|
|
173
|
+
FEATURE_ID: F-NNN
|
|
174
|
+
USES_DESIGN: DT-001, DC-001, ...
|
|
175
|
+
NEW_TOKENS: {JSON object of name -> hex, or {}}
|
|
176
|
+
NEW_COMPONENTS: {JSON object of name -> {variants, states}, or {}}
|
|
177
|
+
=== END SCOPE OUTPUT ===
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Parse the returned block. Store `uses_design`, `new_tokens`, `new_components`.
|
|
181
|
+
|
|
182
|
+
### 1b.4 Append new DT/DC entries to DESIGN.md (if any)
|
|
183
|
+
|
|
184
|
+
If `new_tokens` or `new_components` is non-empty, extend DESIGN.md with IDs enabled:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
node -e "
|
|
188
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
189
|
+
const existing = d.readDesignMd(process.cwd());
|
|
190
|
+
const adds = { colors: {NEW_TOKENS}, components: {NEW_COMPONENTS} };
|
|
191
|
+
const merged = d.extendDesignMd(existing, adds, { withIds: true });
|
|
192
|
+
if (merged !== existing) {
|
|
193
|
+
d.writeDesignMd(process.cwd(), merged);
|
|
194
|
+
console.log('DESIGN.md extended with new tokens/components (IDs assigned).');
|
|
195
|
+
} else {
|
|
196
|
+
console.log('No new tokens/components to add.');
|
|
197
|
+
}
|
|
198
|
+
"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Then re-parse DESIGN.md to capture the IDs of the freshly added entries and append them to `uses_design`.
|
|
202
|
+
|
|
203
|
+
### 1b.5 Write `**Uses design:**` line to FEATURE-MAP.md
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
node -e "
|
|
207
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
208
|
+
const ids = JSON.parse(process.argv[2]);
|
|
209
|
+
const ok = fm.setFeatureUsesDesign(process.cwd(), process.argv[1], ids);
|
|
210
|
+
console.log(ok ? 'FEATURE-MAP.md updated.' : 'Feature not found — no write.');
|
|
211
|
+
" '<FEATURE_ID>' '<USES_DESIGN_JSON_ARRAY>'
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 1b.6 Final report
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
cap:design --scope complete.
|
|
218
|
+
|
|
219
|
+
Feature: {scope_feature.id} — {scope_feature.title}
|
|
220
|
+
Uses design: {uses_design.join(', ') or '(none)'}
|
|
221
|
+
New DT entries: {list}
|
|
222
|
+
New DC entries: {list}
|
|
223
|
+
|
|
224
|
+
Next steps:
|
|
225
|
+
- Add @cap-design-token(id:DT-NNN) / @cap-design-component(id:DC-NNN) tags in the feature's source files
|
|
226
|
+
- Run /cap:scan to auto-populate uses-design from tags
|
|
227
|
+
- Run /cap:deps --design DT-NNN to see impact
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Stop here. Do not run Steps 2-4.
|
|
231
|
+
|
|
232
|
+
## Step 1c: Review-mode fast-path (F-064)
|
|
233
|
+
|
|
234
|
+
<!-- @cap-todo(ac:F-064/AC-1) --review spawns cap-designer in review mode; command layer runs deterministic review engine -->
|
|
235
|
+
<!-- @cap-todo(ac:F-064/AC-3) Review is read-only — DESIGN.md is NEVER modified -->
|
|
236
|
+
<!-- @cap-todo(ac:F-064/AC-4) Rules loaded from .cap/design-rules.md if present, else DEFAULT_DESIGN_RULES -->
|
|
237
|
+
<!-- @cap-todo(ac:F-064/AC-5) Review is idempotent: same DESIGN.md + same rules → byte-identical report -->
|
|
238
|
+
|
|
239
|
+
If `mode === "review"`, run the review flow and skip Steps 2-4.
|
|
240
|
+
|
|
241
|
+
### 1c.1 Load DESIGN.md + optional rules
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
node -e "
|
|
245
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
246
|
+
const md = d.readDesignMd(process.cwd());
|
|
247
|
+
const rulesMd = d.readDesignRules(process.cwd());
|
|
248
|
+
const rules = d.parseDesignRules(rulesMd);
|
|
249
|
+
console.log(JSON.stringify({
|
|
250
|
+
hasDesign: md !== null,
|
|
251
|
+
designLength: md ? md.length : 0,
|
|
252
|
+
hasCustomRules: rulesMd !== null,
|
|
253
|
+
ruleCount: rules.length,
|
|
254
|
+
ruleNames: rules.map(r => r.name),
|
|
255
|
+
}));
|
|
256
|
+
"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Store as `review_input`.
|
|
260
|
+
|
|
261
|
+
### 1c.2 Spawn cap-designer in review mode
|
|
262
|
+
|
|
263
|
+
<!-- @cap-decision(F-064) Agent runs in review mode but the actual rule evaluation happens in the pure library function.
|
|
264
|
+
The agent's job is to ACKNOWLEDGE the review, state what was checked, and optionally narrate findings in natural language.
|
|
265
|
+
The authoritative violations list comes from `reviewDesign()` — we do not trust LLM enumeration for determinism (AC-5). -->
|
|
266
|
+
|
|
267
|
+
Spawn `cap-designer` via Task with:
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
**Mode:** review
|
|
271
|
+
**DESIGN.md length:** {review_input.designLength} bytes
|
|
272
|
+
**Rules source:** {review_input.hasCustomRules ? '.cap/design-rules.md' : 'DEFAULT_DESIGN_RULES (built-in)'}
|
|
273
|
+
**Rule count:** {review_input.ruleCount}
|
|
274
|
+
**Rule names:** {review_input.ruleNames.join(', ')}
|
|
275
|
+
|
|
276
|
+
**Instructions (review mode):**
|
|
277
|
+
- You are running a READ-ONLY Anti-Slop check. DO NOT suggest arbitrary aesthetic improvements.
|
|
278
|
+
- DO NOT write any files. DO NOT modify DESIGN.md.
|
|
279
|
+
- Acknowledge the review and state which rules are being applied.
|
|
280
|
+
- Flag ONLY rule violations — not taste preferences.
|
|
281
|
+
- The actual violations list is produced by the deterministic library function `reviewDesign()`.
|
|
282
|
+
Your role is to narrate context, not enumerate violations.
|
|
283
|
+
|
|
284
|
+
**Return format:**
|
|
285
|
+
|
|
286
|
+
=== REVIEW OUTPUT ===
|
|
287
|
+
MODE: review
|
|
288
|
+
ACKNOWLEDGED: yes
|
|
289
|
+
NOTES: {optional one-line note, or blank}
|
|
290
|
+
=== END REVIEW OUTPUT ===
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Parse the returned block. `ACKNOWLEDGED` must be `yes` to proceed.
|
|
294
|
+
|
|
295
|
+
### 1c.3 Run the deterministic review engine
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
node -e "
|
|
299
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
300
|
+
const md = d.readDesignMd(process.cwd());
|
|
301
|
+
const rulesMd = d.readDesignRules(process.cwd());
|
|
302
|
+
const rules = d.parseDesignRules(rulesMd);
|
|
303
|
+
const violations = d.reviewDesign(md, rules);
|
|
304
|
+
const report = d.formatReviewReport(violations);
|
|
305
|
+
d.writeDesignReview(process.cwd(), report);
|
|
306
|
+
console.log(JSON.stringify({
|
|
307
|
+
violationCount: violations.length,
|
|
308
|
+
bySeverity: violations.reduce((a, v) => { a[v.severity] = (a[v.severity] || 0) + 1; return a; }, {}),
|
|
309
|
+
reportPath: '.cap/DESIGN-REVIEW.md',
|
|
310
|
+
}));
|
|
311
|
+
"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Store as `review_result`.
|
|
315
|
+
|
|
316
|
+
### 1c.4 Final report
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
cap:design --review complete.
|
|
320
|
+
|
|
321
|
+
Rules source: {review_input.hasCustomRules ? '.cap/design-rules.md' : 'DEFAULT_DESIGN_RULES (built-in)'}
|
|
322
|
+
Rules applied: {review_input.ruleCount}
|
|
323
|
+
Violations: {review_result.violationCount}
|
|
324
|
+
errors: {review_result.bySeverity.error || 0}
|
|
325
|
+
warnings: {review_result.bySeverity.warning || 0}
|
|
326
|
+
info: {review_result.bySeverity.info || 0}
|
|
327
|
+
Report written: .cap/DESIGN-REVIEW.md (read-only output, DESIGN.md unchanged)
|
|
328
|
+
|
|
329
|
+
Next steps:
|
|
330
|
+
- Inspect .cap/DESIGN-REVIEW.md
|
|
331
|
+
- Fix violations by editing DESIGN.md or re-running /cap:design --extend
|
|
332
|
+
- Customize rules via .cap/design-rules.md (optional)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Stop here. Do not run Steps 2-4.
|
|
336
|
+
|
|
337
|
+
## Step 2: Spawn cap-designer agent
|
|
338
|
+
|
|
339
|
+
<!-- @cap-todo(ac:F-062/AC-2) cap-designer runs the 3-question wizard and maps to one of 9 families -->
|
|
340
|
+
|
|
341
|
+
Spawn `cap-designer` via the Task tool with the following context:
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
$ARGUMENTS
|
|
345
|
+
|
|
346
|
+
**Mode:** {mode}
|
|
347
|
+
**Existing DESIGN.md:** {design_state.exists ? "yes (will be extended / overwritten per mode)" : "no"}
|
|
348
|
+
|
|
349
|
+
**Instructions:**
|
|
350
|
+
- If mode is `new`, run the 3-question wizard (read-heavy vs scan-heavy; user type; courage factor). Ask ONE question at a time via AskUserQuestion.
|
|
351
|
+
- If mode is `extend`, ask what to add (color-token or component or both) and collect the structured additions.
|
|
352
|
+
- Do NOT write any files. Return the structured output block exactly as specified in your agent prompt.
|
|
353
|
+
- Respect the Anti-Slop constraint block from your prompt.
|
|
354
|
+
|
|
355
|
+
**Return format (delimited, one of):**
|
|
356
|
+
|
|
357
|
+
For --new:
|
|
358
|
+
=== DESIGN OUTPUT ===
|
|
359
|
+
MODE: new
|
|
360
|
+
READ_HEAVY: {read-heavy|scan-heavy}
|
|
361
|
+
USER_TYPE: {consumer|professional|developer}
|
|
362
|
+
COURAGE_FACTOR: {safe|balanced|bold}
|
|
363
|
+
=== END DESIGN OUTPUT ===
|
|
364
|
+
|
|
365
|
+
For --extend:
|
|
366
|
+
=== DESIGN OUTPUT ===
|
|
367
|
+
MODE: extend
|
|
368
|
+
COLORS: {JSON object or {}}
|
|
369
|
+
COMPONENTS: {JSON object or {}}
|
|
370
|
+
=== END DESIGN OUTPUT ===
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Wait for the agent to complete. Parse the output between `=== DESIGN OUTPUT ===` and `=== END DESIGN OUTPUT ===`.
|
|
374
|
+
|
|
375
|
+
## Step 3a: For --new, resolve family and preview DESIGN.md
|
|
376
|
+
|
|
377
|
+
<!-- @cap-todo(ac:F-062/AC-3) DESIGN.md contains Aesthetic Family, Tokens, Components (Button + Card), Anti-Patterns -->
|
|
378
|
+
<!-- @cap-todo(ac:F-062/AC-7) Deterministic: same answers -> byte-identical output -->
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
node -e "
|
|
382
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
383
|
+
const family = d.mapAnswersToFamily('{READ_HEAVY}', '{USER_TYPE}', '{COURAGE_FACTOR}');
|
|
384
|
+
const md = d.buildDesignMd({ family });
|
|
385
|
+
process.stdout.write(JSON.stringify({ familyKey: family.key, familyName: family.name, content: md }));
|
|
386
|
+
"
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Store as `preview`.
|
|
390
|
+
|
|
391
|
+
Display:
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
Resolved aesthetic family: {preview.familyName} ({preview.familyKey})
|
|
395
|
+
|
|
396
|
+
--- DESIGN.md preview ---
|
|
397
|
+
{preview.content}
|
|
398
|
+
--- end preview ---
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Use AskUserQuestion:
|
|
402
|
+
> "Write this DESIGN.md to project root? [yes / restart wizard / cancel]"
|
|
403
|
+
|
|
404
|
+
- `yes` — proceed to Step 4.
|
|
405
|
+
- `restart wizard` — loop back to Step 2.
|
|
406
|
+
- `cancel` — abort: `"cap:design cancelled. No file written."`
|
|
407
|
+
|
|
408
|
+
## Step 3b: For --extend, preview merge and confirm
|
|
409
|
+
|
|
410
|
+
<!-- @cap-todo(ac:F-062/AC-5) --extend appends without overwriting existing entries -->
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
node -e "
|
|
414
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
415
|
+
const existing = d.readDesignMd(process.cwd());
|
|
416
|
+
const additions = { colors: {COLORS}, components: {COMPONENTS} };
|
|
417
|
+
const merged = d.extendDesignMd(existing, additions);
|
|
418
|
+
process.stdout.write(JSON.stringify({ changed: merged !== existing, content: merged }));
|
|
419
|
+
"
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Store as `merge`.
|
|
423
|
+
|
|
424
|
+
If `merge.changed === false`:
|
|
425
|
+
Abort: `"Nothing new to add. Existing entries were kept unchanged."`
|
|
426
|
+
|
|
427
|
+
Display the diff summary (new lines only):
|
|
428
|
+
|
|
429
|
+
```
|
|
430
|
+
Additions:
|
|
431
|
+
{list of new color tokens added}
|
|
432
|
+
{list of new components added}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Use AskUserQuestion:
|
|
436
|
+
> "Merge these additions into DESIGN.md? [yes / cancel]"
|
|
437
|
+
|
|
438
|
+
- `yes` — proceed to Step 4.
|
|
439
|
+
- `cancel` — abort.
|
|
440
|
+
|
|
441
|
+
## Step 4: Write DESIGN.md
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
node -e "
|
|
445
|
+
const d = require('./cap/bin/lib/cap-design.cjs');
|
|
446
|
+
d.writeDesignMd(process.cwd(), {JSON.stringify(content_to_write)});
|
|
447
|
+
console.log('DESIGN.md written at project root.');
|
|
448
|
+
"
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
## Step 5: Update session state
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
node -e "
|
|
455
|
+
const session = require('./cap/bin/lib/cap-session.cjs');
|
|
456
|
+
session.updateSession(process.cwd(), {
|
|
457
|
+
lastCommand: '/cap:design',
|
|
458
|
+
lastCommandTimestamp: new Date().toISOString(),
|
|
459
|
+
step: 'design-{mode}-complete'
|
|
460
|
+
});
|
|
461
|
+
"
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
## Step 6: Final report
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
cap:design complete.
|
|
468
|
+
|
|
469
|
+
Mode: {mode}
|
|
470
|
+
DESIGN.md: {new file / extended with N additions}
|
|
471
|
+
Aesthetic family: {family.name} ({family.key}) (only if mode === new)
|
|
472
|
+
|
|
473
|
+
Next steps:
|
|
474
|
+
- Commit DESIGN.md alongside FEATURE-MAP.md
|
|
475
|
+
- Run /cap:design --extend later to add more tokens/components
|
|
476
|
+
- F-063 (pending) will add DT-NNN / DC-NNN IDs and feature traceability
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
</process>
|