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
package/README.md
ADDED
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
# CAP Pro
|
|
2
|
+
|
|
3
|
+
> Build first. Plan from code. Ship with confidence.
|
|
4
|
+
|
|
5
|
+
**CAP Pro** is a developer framework for AI-assisted coding that follows the Code-First principle: instead of writing requirements documents before touching code, you build a prototype, annotate it with lightweight tags, and let the framework derive your project plan from what you actually built.
|
|
6
|
+
|
|
7
|
+
Works with **Claude Code, Gemini CLI, Codex, Copilot, Cursor, Windsurf, OpenCode, and Antigravity** — 8 runtimes from a single install.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
brainstorm --> prototype --> iterate --> test --> review
|
|
11
|
+
| | | | |
|
|
12
|
+
FEATURE-MAP @cap-tags scan+fix green=done ship
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
> **Heads-up — version reset (May 2026):** the npm package was renamed from `code-as-plan` to **`cap-pro`** and the version was reset to **`1.0.0`**. The CLI command (`cap`), slash commands (`/cap:*`), tags (`@cap-*`) and project artefacts are unchanged. The installer auto-cleans legacy `code-as-plan@7.x` files. See [`CHANGELOG.md`](CHANGELOG.md#100---2026-05-10--cap-pro-10-rebrand--reset) for details.
|
|
16
|
+
|
|
17
|
+
> **Full documentation**: [https://dwall-sys.github.io/code-as-plan](https://dwall-sys.github.io/code-as-plan) — features, workflow, multi-user handoff, roadmap.
|
|
18
|
+
> **Daily workflow guide**: [`docs/USAGE-GUIDE.md`](docs/USAGE-GUIDE.md).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## The Problem
|
|
23
|
+
|
|
24
|
+
Traditional AI coding frameworks follow a plan-heavy workflow:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
discuss -> requirements -> plan -> execute -> verify -> review (9+ steps with sub-steps)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This produces a stack of planning artifacts -- ROADMAP.md, REQUIREMENTS.md, STATE.md, VERIFICATION.md, MILESTONES.md -- that drift from reality the moment code changes. You spend more time maintaining documents than building software.
|
|
31
|
+
|
|
32
|
+
Tests should be verification. Git tags should be milestones. Code should be the plan.
|
|
33
|
+
|
|
34
|
+
CAP eliminates accidental complexity by making code the single source of truth.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## How CAP Is Different
|
|
39
|
+
|
|
40
|
+
| Traditional frameworks | CAP |
|
|
41
|
+
|------------------------|-----|
|
|
42
|
+
| 9+ step workflow | 5 steps: brainstorm, prototype, iterate, test, review |
|
|
43
|
+
| 8+ mandatory tags/annotations | 2 mandatory tags: `@cap-feature`, `@cap-todo` |
|
|
44
|
+
| Manually maintained ROADMAP.md | FEATURE-MAP.md auto-derived from code + brainstorm |
|
|
45
|
+
| Separate VERIFICATION.md | Green tests = verified |
|
|
46
|
+
| MILESTONES.md with status tracking | Git tags = milestones |
|
|
47
|
+
| Runtime dependencies | Zero runtime dependencies (pure Node.js built-ins) |
|
|
48
|
+
| Single AI runtime | Multi-runtime: Claude Code, Gemini, Codex, Copilot, Cursor, Windsurf, OpenCode, Antigravity |
|
|
49
|
+
| Flat project scoping | Per-app monorepo scoping with independent Feature Maps |
|
|
50
|
+
| Stale library documentation | Context7 integration for always-current docs |
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
**Via npx (primary):**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx cap-pro@latest
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Via Claude Code plugin marketplace:**
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
/plugin install cap-pro
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Both paths coexist. The plugin and npm slug are `cap-pro`; the CLI binary, slash commands and tags all stay `cap` / `/cap:*` / `@cap-*`. See [`docs/setup-and-upgrade.md`](docs/setup-and-upgrade.md) for environment-health checks (formerly `/cap:doctor`).
|
|
69
|
+
|
|
70
|
+
> If you previously installed `code-as-plan@7.x` or earlier, the CAP Pro installer detects it and offers to clean up legacy agent/command/hook files automatically before installing — no duplicate `cap-*` files post-install.
|
|
71
|
+
|
|
72
|
+
### Runtime flags
|
|
73
|
+
|
|
74
|
+
Install for a specific AI coding tool:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx cap-pro@latest --claude
|
|
78
|
+
npx cap-pro@latest --gemini
|
|
79
|
+
npx cap-pro@latest --codex
|
|
80
|
+
npx cap-pro@latest --copilot
|
|
81
|
+
npx cap-pro@latest --cursor
|
|
82
|
+
npx cap-pro@latest --windsurf
|
|
83
|
+
npx cap-pro@latest --all # install for all runtimes
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Scope
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx cap-pro@latest --local # current project only (default)
|
|
90
|
+
npx cap-pro@latest --global # all projects
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Quick Start
|
|
96
|
+
|
|
97
|
+
### 1. Initialize your project
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
/cap:init
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Creates `.cap/` directory and an empty `FEATURE-MAP.md`. For existing codebases, runs brownfield analysis to detect what you already have.
|
|
104
|
+
|
|
105
|
+
### 2. Brainstorm features
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
/cap:brainstorm
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Interactive conversation that produces Feature Map entries with acceptance criteria, feature grouping, and dependency analysis. No PRD documents -- results go directly into FEATURE-MAP.md.
|
|
112
|
+
|
|
113
|
+
### 3. Build a prototype
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
/cap:prototype
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Reads your Feature Map, confirms acceptance criteria, and builds annotated code. Every function and module gets `@cap-feature` tags linking it back to the Feature Map.
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
// @cap-feature F-001 User authentication
|
|
123
|
+
// @cap-todo Add refresh token rotation (risk: token replay attacks)
|
|
124
|
+
function authenticateUser(credentials) {
|
|
125
|
+
// implementation
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 4. Iterate until done
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
/cap:iterate
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Scans code for tags, identifies Feature Map gaps, builds missing pieces, re-scans. Repeat until all acceptance criteria are satisfied.
|
|
136
|
+
|
|
137
|
+
### 5. Test and review
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
/cap:test # writes tests against Feature Map acceptance criteria
|
|
141
|
+
/cap:review # two-stage review: spec compliance, then code quality
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Green tests mean verified. No separate verification document.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Architecture
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
+-------------------------------------------------------------------+
|
|
152
|
+
| Developer Workflow |
|
|
153
|
+
| |
|
|
154
|
+
| /cap:brainstorm -> /cap:prototype -> /cap:iterate |
|
|
155
|
+
| | | | |
|
|
156
|
+
| v v v |
|
|
157
|
+
| +-----------+ +---------------+ +-------------+ |
|
|
158
|
+
| | Feature | | Annotated | | Tag Scanner | |
|
|
159
|
+
| | Map (MD) |<--->| Source Code |---->| (regex) | |
|
|
160
|
+
| +-----------+ +---------------+ +------+------+ |
|
|
161
|
+
| ^ | | |
|
|
162
|
+
| | v v |
|
|
163
|
+
| +---------- @cap-feature F-001 ----------+ |
|
|
164
|
+
| @cap-todo ... |
|
|
165
|
+
| |
|
|
166
|
+
| /cap:test -> Green tests = verified |
|
|
167
|
+
| /cap:test-audit -> Mutation score + trust score |
|
|
168
|
+
| /cap:review -> Stage 1 (ACs) + Stage 2 (quality) |
|
|
169
|
+
| + Stage 3 (manual checklist) |
|
|
170
|
+
| git tag v1.0 -> Milestone complete |
|
|
171
|
+
+-------------------------------------------------------------------+
|
|
172
|
+
| Agents |
|
|
173
|
+
| cap-brainstormer | cap-prototyper | cap-validator |
|
|
174
|
+
| cap-debugger |
|
|
175
|
+
+-------------------------------------------------------------------+
|
|
176
|
+
| Infrastructure |
|
|
177
|
+
| Node.js built-ins only | Zero runtime deps | Provenance-signed |
|
|
178
|
+
+-------------------------------------------------------------------+
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Commands
|
|
184
|
+
|
|
185
|
+
| Command | Description |
|
|
186
|
+
|---------|-------------|
|
|
187
|
+
| `/cap:init` | Initialize CAP project -- creates `.cap/`, FEATURE-MAP.md, detects stack via Context7 |
|
|
188
|
+
| `/cap:brainstorm` | Interactive feature discovery that produces Feature Map entries with acceptance criteria |
|
|
189
|
+
| `/cap:prototype` | Build annotated code scaffold from Feature Map (supports `--architecture` and `--annotate` modes) |
|
|
190
|
+
| `/cap:iterate` | Scan, identify gaps, build, re-scan -- repeat until acceptance criteria are met |
|
|
191
|
+
| `/cap:test` | Write runnable tests against Feature Map acceptance criteria using RED-GREEN discipline |
|
|
192
|
+
| `/cap:review` | Two-stage review: Stage 1 checks Feature Map compliance, Stage 2 checks code quality |
|
|
193
|
+
| `/cap:debug` | Systematic debugging with persistent state across context resets |
|
|
194
|
+
| `/cap:scan` | Scan codebase for `@cap-feature` and `@cap-todo` tags, update Feature Map |
|
|
195
|
+
| `/cap:status` | Show project status derived from Feature Map -- completion, coverage, open risks |
|
|
196
|
+
| `/cap:start` | Initialize session -- restore previous state, detect project context (use `--app=<name>` for monorepo app switch) |
|
|
197
|
+
| `/cap:annotate` | Retroactively add `@cap-feature` and `@cap-todo` tags to existing code |
|
|
198
|
+
| `/cap:migrate` | Migrate from GSD Code-First v1.x to CAP v2.0 (supports `--rescope` for per-app Feature Maps) |
|
|
199
|
+
| `/cap:test-audit` | Test quality analysis: assertion density, coverage, mutation score, spot-check guide, trust score |
|
|
200
|
+
| `/cap:save` | Save current session context to snapshot file for cross-session continuity |
|
|
201
|
+
| `/cap:continue` | Restore a saved context snapshot |
|
|
202
|
+
| `/cap:memory` | Project memory management -- `init`, `status` (includes cluster overview), `pin`, `unpin`, `prune` subcommands |
|
|
203
|
+
| `/cap:checkpoint` | Advisory breakpoint detector — nudges `/compact` at natural workflow boundaries, chains `/cap:save` |
|
|
204
|
+
| `/cap:reconcile` | One-shot drift reconciliation — propose AC promotions and feature-state corrections |
|
|
205
|
+
| `/cap:deps` | Infer feature dependencies from source imports, diff against FEATURE-MAP DEPENDS_ON |
|
|
206
|
+
| `/cap:trace` | Print the call graph for a single acceptance criterion across all contributing files |
|
|
207
|
+
| `/cap:completeness` | Markdown audit of the Implementation Completeness Score (4 signals per AC) |
|
|
208
|
+
| `/cap:migrate-tags` | Migrate fragmented `@cap-feature` / `@cap-todo(ac:…)` tags to unified `@cap` anchor blocks |
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Tag System
|
|
213
|
+
|
|
214
|
+
CAP uses inline code annotations to link source code to the Feature Map. Two tags are mandatory. Two more are optional for richer tracking.
|
|
215
|
+
|
|
216
|
+
### Mandatory tags
|
|
217
|
+
|
|
218
|
+
#### @cap-feature
|
|
219
|
+
|
|
220
|
+
Links code to a Feature Map entry.
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
// @cap-feature F-001 User authentication
|
|
224
|
+
function login(email, password) { ... }
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```python
|
|
228
|
+
# @cap-feature F-003 Data export pipeline
|
|
229
|
+
def export_to_csv(dataset):
|
|
230
|
+
...
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Every function, module, or component that implements a feature gets this tag. The tag scanner uses these to calculate Feature Map completion.
|
|
234
|
+
|
|
235
|
+
#### @cap-todo
|
|
236
|
+
|
|
237
|
+
Marks work items, open questions, and known gaps.
|
|
238
|
+
|
|
239
|
+
```javascript
|
|
240
|
+
// @cap-todo Implement rate limiting for login endpoint
|
|
241
|
+
// @cap-todo(risk: brute force attacks) Add account lockout after 5 failures
|
|
242
|
+
// @cap-todo(decision: chose bcrypt over argon2 -- wider ecosystem support)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Subtypes `risk:` and `decision:` let you capture architectural decisions and known risks inline, right where they matter.
|
|
246
|
+
|
|
247
|
+
### Optional tags
|
|
248
|
+
|
|
249
|
+
#### @cap-risk
|
|
250
|
+
|
|
251
|
+
Standalone risk annotation when the risk is not tied to a specific todo.
|
|
252
|
+
|
|
253
|
+
```javascript
|
|
254
|
+
// @cap-risk Memory usage grows linearly with connected WebSocket clients
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### @cap-decision
|
|
258
|
+
|
|
259
|
+
Standalone architectural decision record.
|
|
260
|
+
|
|
261
|
+
```javascript
|
|
262
|
+
// @cap-decision Use SQLite over PostgreSQL -- single-node deployment, no ops overhead
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### That is the entire tag system
|
|
266
|
+
|
|
267
|
+
Two mandatory tags. Two optional tags. Compare this to frameworks that require 8+ annotation types with mandatory metadata fields. Simplicity is the point.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Feature Map
|
|
272
|
+
|
|
273
|
+
`FEATURE-MAP.md` is the single source of truth for project status. It is auto-generated from two inputs:
|
|
274
|
+
|
|
275
|
+
1. **Brainstorm output** -- feature definitions and acceptance criteria
|
|
276
|
+
2. **Tag scan results** -- `@cap-feature` and `@cap-todo` counts from source code
|
|
277
|
+
|
|
278
|
+
You never edit FEATURE-MAP.md manually. Run `/cap:scan` or `/cap:iterate` to regenerate it.
|
|
279
|
+
|
|
280
|
+
```markdown
|
|
281
|
+
## F-001 User Authentication
|
|
282
|
+
Status: IN PROGRESS (3/5 ACs met)
|
|
283
|
+
Tags: 12 @cap-feature, 4 @cap-todo
|
|
284
|
+
Files: src/auth/login.js, src/auth/session.js, src/auth/middleware.js
|
|
285
|
+
|
|
286
|
+
### Acceptance Criteria
|
|
287
|
+
- [x] Users can log in with email and password
|
|
288
|
+
- [x] JWT tokens issued on successful login
|
|
289
|
+
- [x] Invalid credentials return 401
|
|
290
|
+
- [ ] Refresh token rotation
|
|
291
|
+
- [ ] Account lockout after failed attempts
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Monorepo Support
|
|
297
|
+
|
|
298
|
+
CAP auto-detects monorepo tooling and scopes all commands to the active app.
|
|
299
|
+
|
|
300
|
+
### Supported workspace managers
|
|
301
|
+
|
|
302
|
+
- npm workspaces (`package.json` workspaces field)
|
|
303
|
+
- pnpm workspaces (`pnpm-workspace.yaml`)
|
|
304
|
+
- Yarn workspaces
|
|
305
|
+
- NX (`nx.json`)
|
|
306
|
+
- Lerna (`lerna.json`)
|
|
307
|
+
|
|
308
|
+
### How it works
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
/cap:init # detects monorepo, creates per-app .cap/ directories
|
|
312
|
+
/cap:start --app=<name> # select active app (lists workspace packages with tag counts)
|
|
313
|
+
/cap:prototype # scopes to active app only
|
|
314
|
+
/cap:scan # scans active app + shared packages
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Each app gets its own `FEATURE-MAP.md`. Shared packages are scanned and included as lightweight dependency context -- exports and types only, not full source.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Agents
|
|
322
|
+
|
|
323
|
+
CAP ships four core micro-workflow agents (plus optional macro-workflow agents introduced in `iteration/cap-pro-1`). You do not invoke them directly -- commands spawn them as needed.
|
|
324
|
+
|
|
325
|
+
| Agent | Spawned by | Purpose |
|
|
326
|
+
|-------|-----------|---------|
|
|
327
|
+
| `cap-brainstormer` | `/cap:brainstorm` | Guides feature discovery conversation, produces Feature Map entries |
|
|
328
|
+
| `cap-prototyper` | `/cap:prototype`, `/cap:iterate`, `/cap:annotate` | Builds annotated code. Four modes: PROTOTYPE, ITERATE, ARCHITECTURE, ANNOTATE |
|
|
329
|
+
| `cap-validator` | `/cap:test`, `/cap:review`, `/cap:completeness` | Three modes: TEST (RED-GREEN), REVIEW (Stage 1+2), AUDIT (F-048 completeness) |
|
|
330
|
+
| `cap-debugger` | `/cap:debug` | Systematic debugging with persistent state across context window resets |
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Test Quality Infrastructure
|
|
335
|
+
|
|
336
|
+
CAP goes beyond "tests are green" with a 6-level trust model:
|
|
337
|
+
|
|
338
|
+
### /cap:test -- AI-generated tests
|
|
339
|
+
|
|
340
|
+
The `cap-validator` agent (test mode) writes tests with an adversarial mindset ("how do I break this?") and includes specialized templates for:
|
|
341
|
+
|
|
342
|
+
- **Security tests** -- RLS policies, auth bypass, input sanitization, data leakage
|
|
343
|
+
- **Contract tests** -- API schema validation between monorepo services
|
|
344
|
+
- **Property-based tests** -- fast-check templates for business logic invariants
|
|
345
|
+
|
|
346
|
+
### /cap:test-audit -- verify the tests themselves
|
|
347
|
+
|
|
348
|
+
Because "tests are green" is not the same as "tests are trustworthy":
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
Test Audit — apps/booking
|
|
352
|
+
=========================
|
|
353
|
+
|
|
354
|
+
ASSERTIONS: 142 total, 0 empty tests
|
|
355
|
+
COVERAGE: 73% lines, 68% branches
|
|
356
|
+
MUTATION SCORE: 8/10 caught (80%)
|
|
357
|
+
|
|
358
|
+
SPOT-CHECK GUIDE (for human review):
|
|
359
|
+
1. auth.test.ts:42 — "rejects expired token"
|
|
360
|
+
Break: Delete token check in auth.ts:18
|
|
361
|
+
Expected: Test turns RED
|
|
362
|
+
[ ] Verified [ ] Suspect
|
|
363
|
+
|
|
364
|
+
ANTI-PATTERNS: 3 weak assertions flagged
|
|
365
|
+
TRUST SCORE: 87/100
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**Mutation testing** is the strongest automated check: the engine introduces deliberate bugs (flip `===` to `!==`, negate conditions, remove returns) and verifies the tests catch them. A mutation score above 80% means your tests are genuinely testing behavior.
|
|
369
|
+
|
|
370
|
+
**Spot-checks** guide human reviewers to the 3 most critical tests. Five minutes of human attention at the right places provides more confidence than reading every test file.
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Migration from GSD
|
|
375
|
+
|
|
376
|
+
If you have an existing GSD Code-First v1.x project:
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
/cap:migrate --dry-run # preview what would change (safe)
|
|
380
|
+
/cap:migrate --tags-only # convert @gsd-* tags to @cap-* only
|
|
381
|
+
/cap:migrate # full migration: tags + artifacts + session
|
|
382
|
+
/cap:migrate --rescope # split root Feature Map into per-app Feature Maps (monorepo)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Tag conversion:
|
|
386
|
+
|
|
387
|
+
| GSD tag | CAP equivalent |
|
|
388
|
+
|---------|---------------|
|
|
389
|
+
| `@gsd-feature` | `@cap-feature` |
|
|
390
|
+
| `@gsd-todo` | `@cap-todo` |
|
|
391
|
+
| `@gsd-risk` | `@cap-todo risk:` |
|
|
392
|
+
| `@gsd-decision` | `@cap-todo decision:` |
|
|
393
|
+
| `@gsd-context` | Plain comment (tag removed) |
|
|
394
|
+
| `@gsd-status` | Removed (status lives in Feature Map) |
|
|
395
|
+
| `@gsd-depends` | Removed (derived from import graph) |
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Why Prototype-Driven Development
|
|
400
|
+
|
|
401
|
+
CAP implements Prototype-Driven Development -- a methodology designed for AI-assisted engineering. It is different from TDD and Spec-Driven Development in a fundamental way.
|
|
402
|
+
|
|
403
|
+
### The problem with older approaches
|
|
404
|
+
|
|
405
|
+
**TDD** says: write the test first, then the code. But developers often don't know what to test until they've built something. The test becomes a guess that gets rewritten alongside the code.
|
|
406
|
+
|
|
407
|
+
**Spec-Driven** says: write the specification first, then build against it. But specifications written before building are based on assumptions, not knowledge. They drift the moment code reveals what the problem actually is.
|
|
408
|
+
|
|
409
|
+
Both approaches were designed for a world where building is expensive. When writing code takes hours or days, it makes sense to plan first and build later. You want to get it right the first time because iteration is costly.
|
|
410
|
+
|
|
411
|
+
### AI changes the economics
|
|
412
|
+
|
|
413
|
+
When AI builds a working prototype in minutes instead of hours, the calculation flips:
|
|
414
|
+
|
|
415
|
+
| | Human alone | Human + AI (CAP) |
|
|
416
|
+
|---|---|---|
|
|
417
|
+
| Cost of a prototype | Hours | Minutes |
|
|
418
|
+
| Cost of throwing it away | Painful | Trivial |
|
|
419
|
+
| Cost of a wrong spec | Days of wasted work | One conversation to correct |
|
|
420
|
+
| When you discover missing requirements | After building (too late) | While looking at the prototype |
|
|
421
|
+
|
|
422
|
+
Building is no longer expensive. Specifying incorrectly is. This makes "build first, then understand" more rational than "understand first, then build."
|
|
423
|
+
|
|
424
|
+
### How CAP uses this
|
|
425
|
+
|
|
426
|
+
```
|
|
427
|
+
TDD: Test --> Code --> Refactor
|
|
428
|
+
Spec-Driven: Spec --> Code --> Verify
|
|
429
|
+
CAP: Idea --> Prototype --> Spec emerges --> Test --> Verify
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
The specification is not an input -- it is an output. You start with an idea (brainstorm), build a prototype (fast, cheap), and the specification crystallizes from what you actually built:
|
|
433
|
+
|
|
434
|
+
- Feature Map entries emerge from brainstorming
|
|
435
|
+
- `@cap-feature` tags emerge from implementation
|
|
436
|
+
- `@cap-todo risk:` and `decision:` annotations emerge from coding experience
|
|
437
|
+
- Acceptance criteria get refined as you see what works and what doesn't
|
|
438
|
+
|
|
439
|
+
### Why this helps humans learn, not just ship faster
|
|
440
|
+
|
|
441
|
+
**1. The prototype is a mirror.** When you look at running code and say "that's wrong," you just discovered a requirement you couldn't have written upfront. The brainstorm-prototype-iterate loop is a requirement discovery machine.
|
|
442
|
+
|
|
443
|
+
**2. Fewer false assumptions.** In spec-driven workflows, teams commit to assumptions before verifying them. In CAP, you verify assumptions by building -- because building is cheap. "Does this booking flow make sense?" is answered by looking at it, not by reading a document.
|
|
444
|
+
|
|
445
|
+
**3. Better communication.** Showing a colleague a working prototype ("look, this is how booking works") communicates more in 30 seconds than a spec document communicates in 30 pages.
|
|
446
|
+
|
|
447
|
+
**4. Less waste.** Studies show 30-50% of upfront specifications describe features that change before they ship. Prototype-Driven avoids this by only formalizing what survives iteration.
|
|
448
|
+
|
|
449
|
+
**5. Deeper understanding.** When the AI builds and you review, you engage with the problem at a concrete level. You're not reading abstractions -- you're reading code, testing flows, catching edge cases. This builds genuine understanding that no spec document provides.
|
|
450
|
+
|
|
451
|
+
### What CAP takes from TDD and Spec-Driven
|
|
452
|
+
|
|
453
|
+
CAP is not opposed to testing or specifications. It reorders when they happen:
|
|
454
|
+
|
|
455
|
+
From **TDD**: RED-GREEN test discipline, mutation testing, tests as verification (not documents). But tests come after the prototype, not before.
|
|
456
|
+
|
|
457
|
+
From **Spec-Driven**: Acceptance criteria as contracts (Feature Map ACs), traceability (tags link code to features), review against spec (Stage 1). But the spec emerges from building, it is not written in isolation.
|
|
458
|
+
|
|
459
|
+
### In one sentence
|
|
460
|
+
|
|
461
|
+
> TDD and Spec-Driven optimize for executing a known plan correctly. CAP optimizes for discovering the right plan -- by building, observing, learning, and correcting.
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
## Farley's Principles in CAP
|
|
466
|
+
|
|
467
|
+
CAP is aligned with Dave Farley's "Modern Software Engineering":
|
|
468
|
+
|
|
469
|
+
**Optimize for learning.** Build a prototype to discover what you do not know. Iterate based on what the code tells you, not what a requirements document predicted.
|
|
470
|
+
|
|
471
|
+
**Manage complexity.** Planning artifacts that duplicate what code already expresses are accidental complexity. Eliminate them. Keep one source of truth.
|
|
472
|
+
|
|
473
|
+
**Work in small steps.** The brainstorm-prototype-iterate loop is deliberately short. Each iteration produces working, tested, annotated code -- not documents about code.
|
|
474
|
+
|
|
475
|
+
**Get fast feedback.** Green tests are verification. Tag scans are progress tracking. Git tags are milestones. Every feedback mechanism is derived from artifacts you already produce.
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## Security
|
|
480
|
+
|
|
481
|
+
**Zero runtime dependencies.** CAP uses only Node.js built-in modules. No third-party code runs in your project at runtime. This eliminates supply chain attack surface from transitive dependencies.
|
|
482
|
+
|
|
483
|
+
**Provenance attestation.** Every npm release is signed via GitHub Actions OIDC, proving the package was built from the public source repository. Verify with:
|
|
484
|
+
|
|
485
|
+
```bash
|
|
486
|
+
npm audit signatures
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Safe CI pipeline.** Packages are published exclusively through GitHub Actions with `npm ci --ignore-scripts` -- lockfile-pinned dependencies, no post-install script execution.
|
|
490
|
+
|
|
491
|
+
**Verify your install.**
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
npm view cap-pro dist.attestations # check provenance exists
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## Context7 Integration
|
|
500
|
+
|
|
501
|
+
CAP integrates with Context7 to fetch current library documentation during development. When you run `/cap:init`, CAP detects your project dependencies and pulls relevant documentation into `.cap/stack-docs/` so agents always have accurate, up-to-date API references -- not stale training data. To refresh manually, invoke Context7 directly:
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
npx ctx7@latest library <name> "<question>" # resolve library ID
|
|
505
|
+
npx ctx7@latest docs /<org>/<project> "<question>" > .cap/stack-docs/<name>.md
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## Project Memory System
|
|
511
|
+
|
|
512
|
+
CAP v3.0 introduces a persistent project memory that accumulates knowledge across sessions, developers, and brainstorm conversations. Unlike traditional session logs, CAP memory follows the Code-First principle: **code tags are the primary source**, session data provides only edit frequency metrics.
|
|
513
|
+
|
|
514
|
+
### How it works
|
|
515
|
+
|
|
516
|
+
```
|
|
517
|
+
Code Tags Session JSONL Files
|
|
518
|
+
@cap-decision ... (edit frequency only)
|
|
519
|
+
@cap-todo risk: ... |
|
|
520
|
+
@cap-risk ... v
|
|
521
|
+
| +-------------+
|
|
522
|
+
v | Hotspot |
|
|
523
|
+
+----------------+ | Detection |
|
|
524
|
+
| Memory Engine | +------+------+
|
|
525
|
+
| (code-first) | |
|
|
526
|
+
+-------+--------+ |
|
|
527
|
+
| |
|
|
528
|
+
+----------+---------------+
|
|
529
|
+
|
|
|
530
|
+
v
|
|
531
|
+
+--------+--------+
|
|
532
|
+
| Memory Graph |
|
|
533
|
+
| .cap/memory/ |
|
|
534
|
+
| graph.json |
|
|
535
|
+
+--------+--------+
|
|
536
|
+
|
|
|
537
|
+
+-------------+-------------+
|
|
538
|
+
| | |
|
|
539
|
+
v v v
|
|
540
|
+
decisions.md hotspots.md pitfalls.md (human-readable views)
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### Three data sources
|
|
544
|
+
|
|
545
|
+
**1. Code tags (primary, zero noise)**
|
|
546
|
+
|
|
547
|
+
```javascript
|
|
548
|
+
// @cap-decision Use SQLite over PostgreSQL -- single-node deployment, no ops overhead
|
|
549
|
+
// @cap-todo risk: Connection pool exhaustion under load
|
|
550
|
+
// @cap-risk Regex YAML parsing breaks on complex YAML features
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
These are explicit developer annotations -- 100% signal, no heuristic extraction needed.
|
|
554
|
+
|
|
555
|
+
**2. Session hotspots (edit frequency)**
|
|
556
|
+
|
|
557
|
+
Which files keep getting changed, across how many sessions? Hotspots help new team members understand where the action is.
|
|
558
|
+
|
|
559
|
+
```
|
|
560
|
+
| File | Sessions | Edits |
|
|
561
|
+
|-------------------------------|----------|-------|
|
|
562
|
+
| packages/auth/callback.ts | 6 | 29 |
|
|
563
|
+
| packages/auth/middleware.ts | 5 | 24 |
|
|
564
|
+
| apps/hub/AuthContext.tsx | 3 | 5 |
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
**3. Conversation threads (brainstorm memory)**
|
|
568
|
+
|
|
569
|
+
When you brainstorm with CAP, the conversation is persisted as a named thread in `.cap/memory/threads/`. When you return to the same topic days later, CAP detects the connection and offers to resume, merge, or branch the discussion.
|
|
570
|
+
|
|
571
|
+
### Conversation threading
|
|
572
|
+
|
|
573
|
+
Brainstorm conversations naturally branch into tangents. Humans track these threads effortlessly; AI assistants lose them when the session ends. CAP solves this with persistent thread tracking:
|
|
574
|
+
|
|
575
|
+
```
|
|
576
|
+
Session 1: "We need auth for the booking system"
|
|
577
|
+
-> Thread created: thr-a1b2c3 (Auth Architecture)
|
|
578
|
+
-> Features: F-AUTH, F-SSO
|
|
579
|
+
-> Decisions: Supabase over Firebase, cookie-based SSO
|
|
580
|
+
|
|
581
|
+
Session 2 (next day): "Remember the auth discussion? I have a new idea..."
|
|
582
|
+
-> CAP detects: 85% keyword overlap with thr-a1b2c3
|
|
583
|
+
-> Shows: "Found prior thread: Auth Architecture (2 days ago)"
|
|
584
|
+
-> Proposes: merge | supersede | branch | resume
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
**Four reconnection strategies:**
|
|
588
|
+
|
|
589
|
+
| Strategy | When to use |
|
|
590
|
+
|----------|-------------|
|
|
591
|
+
| **Resume** | Continue where you left off |
|
|
592
|
+
| **Merge** | Integrate new ideas into old thread, combine ACs |
|
|
593
|
+
| **Supersede** | New idea replaces old approach entirely |
|
|
594
|
+
| **Branch** | Both approaches coexist as alternatives |
|
|
595
|
+
|
|
596
|
+
### Impact analysis
|
|
597
|
+
|
|
598
|
+
When you propose a new feature during brainstorming, CAP automatically checks for overlap with existing features:
|
|
599
|
+
|
|
600
|
+
- Compares acceptance criteria for semantic similarity
|
|
601
|
+
- Traces full dependency chains (A depends on B depends on C -- changing B surfaces impact on A and C)
|
|
602
|
+
- Detects circular dependency risks
|
|
603
|
+
- Proposes concrete resolutions: merge ACs, split features, adjust dependencies
|
|
604
|
+
|
|
605
|
+
All proposals are advisory -- CAP never modifies the Feature Map without explicit approval.
|
|
606
|
+
|
|
607
|
+
### Memory graph
|
|
608
|
+
|
|
609
|
+
Under the hood, all memory is stored as a connected graph (`.cap/memory/graph.json`):
|
|
610
|
+
|
|
611
|
+
- **6 node types:** feature, thread, decision, pitfall, pattern, hotspot
|
|
612
|
+
- **6 edge types:** depends_on, supersedes, conflicts_with, branched_from, informed_by, relates_to
|
|
613
|
+
- **Temporal queries:** "What changed between last Tuesday and today?"
|
|
614
|
+
- **Traversal queries:** "Show all decisions that informed F-005 within 2 hops"
|
|
615
|
+
|
|
616
|
+
The flat markdown files (`decisions.md`, `hotspots.md`, `pitfalls.md`, `patterns.md`) are generated views from the graph -- human-readable and git-diffable.
|
|
617
|
+
|
|
618
|
+
### Multi-developer workflow
|
|
619
|
+
|
|
620
|
+
Memory is git-tracked. When multiple developers work on the same project:
|
|
621
|
+
|
|
622
|
+
```
|
|
623
|
+
Developer A: /cap:memory init -> .cap/memory/ generated -> commit + push
|
|
624
|
+
Developer B: git pull -> has A's memory
|
|
625
|
+
/cap:memory init -> MERGES with A's data (anchor-ID dedup)
|
|
626
|
+
commit + push -> combined team memory
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
Both developers' decisions, hotspots, and threads are accumulated into a shared project memory that grows over time.
|
|
630
|
+
|
|
631
|
+
### Commands
|
|
632
|
+
|
|
633
|
+
```bash
|
|
634
|
+
/cap:memory init # bootstrap memory from all sessions + code tags (one-time)
|
|
635
|
+
/cap:memory # incremental update (runs automatically after each session)
|
|
636
|
+
/cap:memory status # show memory summary (entries per category, last run)
|
|
637
|
+
/cap:memory pin # mark a pitfall as permanent (immune to aging)
|
|
638
|
+
/cap:memory unpin # remove permanent mark
|
|
639
|
+
/cap:memory prune # decay stale entries, archive low-confidence, purge raw logs (default dry-run)
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Confidence, evidence, decay (v4.1)
|
|
643
|
+
|
|
644
|
+
Every memory entry now carries two additive fields that track epistemic state over time:
|
|
645
|
+
|
|
646
|
+
- **`confidence`** (0.0 – 1.0) — starts at 0.5 on first observation
|
|
647
|
+
- **`evidence_count`** — starts at 1, increments on re-observation
|
|
648
|
+
|
|
649
|
+
**Re-observation bump.** When the same content (Jaccard ≥ 0.8 on word tokens) appears again: `confidence += 0.1` (capped at 0.95), `evidence_count += 1`. The same decision tagged three times across three sessions lands at `confidence: 0.8, evidence: 4` — visible, auditable, and resistant to LLM noise.
|
|
650
|
+
|
|
651
|
+
**Contradiction damp.** A counter-entry in the same category with overlapping files and asymmetric negation drops the prior entry's confidence by 0.2 (floored at 0.0) without incrementing evidence. Both entries stay on disk — contradicting observations are logged, not silenced.
|
|
652
|
+
|
|
653
|
+
**Dimmed rendering.** Entries with `confidence < 0.3` render as blockquotes prefixed with `*(low confidence)*` so reviewers immediately see what the framework is unsure about.
|
|
654
|
+
|
|
655
|
+
**Time-based decay.** Entries untouched for >90 days lose 0.05 confidence per additional 30 days. Entries that fall below `confidence: 0.2` **and** are older than 180 days are archived to `.cap/memory/archive/YYYY-MM.md` — not deleted. Pinned entries (`/cap:memory pin`) bypass both decay and archive.
|
|
656
|
+
|
|
657
|
+
**Raw-log retention.** Hook-observed tag events older than 30 days are hard-deleted from `.cap/memory/raw/` on the next `prune --apply`.
|
|
658
|
+
|
|
659
|
+
```bash
|
|
660
|
+
/cap:memory prune # dry-run: show what would decay, archive, purge
|
|
661
|
+
/cap:memory prune --apply # commit the changes
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### Hook-based tag observation (v4.1)
|
|
665
|
+
|
|
666
|
+
A PostToolUse hook watches every Edit/Write/MultiEdit/NotebookEdit. When the set of `@cap-feature` / `@cap-todo` tags in the edited file changes, a JSONL event is appended to `.cap/memory/raw/tag-events-YYYY-MM-DD.jsonl`:
|
|
667
|
+
|
|
668
|
+
```json
|
|
669
|
+
{"timestamp":"2026-04-21T10:03:15Z","tool":"Edit","file":"/abs/path/auth.ts","added":["@cap-todo(ac:F-054/AC-1)"],"removed":[]}
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
The aggregator picks these up on the next `/cap:memory` run. Net effect: your memory stays current without any deliberate capture step — a tag added in a commit is observed by the next session.
|
|
673
|
+
|
|
674
|
+
The hook never blocks the editor (skip via `CAP_SKIP_TAG_OBSERVER=1`).
|
|
675
|
+
|
|
676
|
+
---
|
|
677
|
+
|
|
678
|
+
## Neural Memory Clustering
|
|
679
|
+
|
|
680
|
+
CAP v4.0 introduces intelligent clustering on top of the memory graph. Instead of isolated nodes, threads now form **semantic neighborhoods** -- groups of related conversations that CAP detects, labels, and surfaces automatically.
|
|
681
|
+
|
|
682
|
+
### How it works
|
|
683
|
+
|
|
684
|
+
```
|
|
685
|
+
Conversation Threads Affinity Engine Clusters
|
|
686
|
+
┌──────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
|
687
|
+
│ Auth Refactor │───────>│ 8 signal types │──────>│ auth · session │
|
|
688
|
+
│ Cookie SSO │───────>│ composite score │──────>│ · cookies │
|
|
689
|
+
│ Session Store │───────>│ gradient UX band │ │ (3 threads) │
|
|
690
|
+
└──────────────┘ └──────────────────┘ └─────────────────┘
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
**8 affinity signals** are scored and combined:
|
|
694
|
+
- Feature ID overlap, shared files, keyword similarity, temporal proximity
|
|
695
|
+
- Concept drift, dependency chain, author overlap, edit pattern
|
|
696
|
+
|
|
697
|
+
**Gradient UX bands** control how related threads are surfaced:
|
|
698
|
+
|
|
699
|
+
| Band | Score | Behavior |
|
|
700
|
+
|------|-------|----------|
|
|
701
|
+
| Urgent | > 0.8 | Full context block with shared concepts |
|
|
702
|
+
| Notify | 0.5 - 0.8 | One-line mention before session starts |
|
|
703
|
+
| Silent | 0.3 - 0.5 | Stored for queries, not shown proactively |
|
|
704
|
+
| Discard | < 0.3 | Dropped entirely |
|
|
705
|
+
|
|
706
|
+
### Automatic surfacing
|
|
707
|
+
|
|
708
|
+
When you run `/cap:start` or `/cap:brainstorm`, CAP passively checks affinity against your selected feature and surfaces related prior threads. No manual lookup required -- relevant context finds you.
|
|
709
|
+
|
|
710
|
+
### Cluster inspection
|
|
711
|
+
|
|
712
|
+
```bash
|
|
713
|
+
/cap:memory status # includes cluster overview (labels, member counts, affinity scores)
|
|
714
|
+
/cap:status # includes Neural Memory section (cluster count, dormant nodes, highest pair)
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
### Initializing Neural Memory Clustering
|
|
718
|
+
|
|
719
|
+
The clustering system works on top of the memory graph and conversation threads. It runs on-the-fly -- no separate clustering step needed. But the prerequisites must exist:
|
|
720
|
+
|
|
721
|
+
```bash
|
|
722
|
+
# Step 1: Initialize CAP (creates .cap/, detects stack)
|
|
723
|
+
/cap:init
|
|
724
|
+
|
|
725
|
+
# Step 2: Bootstrap the memory graph from code tags
|
|
726
|
+
/cap:memory init
|
|
727
|
+
# This creates .cap/memory/graph.json with nodes from @cap-decision,
|
|
728
|
+
# @cap-todo risk:, and session hotspots
|
|
729
|
+
|
|
730
|
+
# Step 3: Create conversation threads via brainstorming
|
|
731
|
+
/cap:brainstorm
|
|
732
|
+
# Each brainstorm session creates a thread in .cap/memory/threads/
|
|
733
|
+
# Threads are the input for affinity scoring and clustering
|
|
734
|
+
|
|
735
|
+
# Step 4: Clustering activates automatically
|
|
736
|
+
# After 2+ threads exist, /cap:memory status surfaces detected clusters
|
|
737
|
+
/cap:memory status
|
|
738
|
+
# /cap:status shows the Neural Memory section
|
|
739
|
+
# /cap:start and /cap:brainstorm surface related threads passively
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
**For existing projects with no threads yet:**
|
|
743
|
+
|
|
744
|
+
If you have an existing codebase with `@cap-decision` and `@cap-todo` tags but no brainstorm threads, the clustering system has nothing to cluster. Threads are created by:
|
|
745
|
+
|
|
746
|
+
1. Running `/cap:brainstorm` (creates a thread per session)
|
|
747
|
+
2. Running `/cap:init` with `--migrate` (migrates past sessions to threads)
|
|
748
|
+
3. Manual thread creation is not needed -- just use CAP normally and threads accumulate
|
|
749
|
+
|
|
750
|
+
**For monorepos:** Threads are stored at the root level (`.cap/memory/threads/`), not per-app. This means clustering works across apps -- a thread about auth in `apps/booking` can cluster with a thread about SSO in `apps/hub`.
|
|
751
|
+
|
|
752
|
+
**Minimum for clustering:** 2 threads with overlapping keywords, shared features, or shared files. With fewer than 2 threads, `/cap:memory status` shows "No clusters detected."
|
|
753
|
+
|
|
754
|
+
### The complete memory evolution
|
|
755
|
+
|
|
756
|
+
```
|
|
757
|
+
v2.x Extract — decisions, pitfalls, hotspots from code tags and sessions
|
|
758
|
+
v3.x Connect — memory graph with typed nodes, edges, temporal queries, thread tracking
|
|
759
|
+
v4.0 Cluster — automatic clustering, multi-signal affinity, intelligent recall
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
---
|
|
763
|
+
|
|
764
|
+
## Getting Started with an Existing Project
|
|
765
|
+
|
|
766
|
+
CAP works with both greenfield and brownfield codebases. Here is how to initialize an existing project -- including monorepos:
|
|
767
|
+
|
|
768
|
+
### Single repository
|
|
769
|
+
|
|
770
|
+
```bash
|
|
771
|
+
npx cap-pro@latest # install CAP Pro
|
|
772
|
+
/cap:init # detects stack, creates .cap/, runs brownfield analysis
|
|
773
|
+
/cap:brainstorm # discover features from existing code
|
|
774
|
+
/cap:annotate # retroactively tag existing code with @cap-feature / @cap-todo
|
|
775
|
+
/cap:memory init # bootstrap memory from code tags and sessions
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
### Monorepo (NX, Turbo, pnpm, npm workspaces)
|
|
779
|
+
|
|
780
|
+
```bash
|
|
781
|
+
npx cap-pro@latest # install CAP Pro (auto-detects monorepo)
|
|
782
|
+
/cap:init # creates root .cap/, detects all workspace apps
|
|
783
|
+
/cap:start --app=booking # select which app to focus on (e.g., apps/booking)
|
|
784
|
+
/cap:brainstorm # discover features for the active app
|
|
785
|
+
/cap:annotate # tag existing code in active app
|
|
786
|
+
/cap:memory init # bootstrap memory (scans all apps)
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
Each app gets its own `FEATURE-MAP.md`. Shared packages are scanned as dependency context. Switch between apps with `/cap:start --app=<name>` at any time.
|
|
790
|
+
|
|
791
|
+
### What /cap:init does for existing codebases
|
|
792
|
+
|
|
793
|
+
1. **Stack detection** -- reads `package.json`, `pyproject.toml`, `go.mod`, etc. to identify language, framework, and test framework
|
|
794
|
+
2. **Brownfield analysis** -- scans existing source files to estimate project size and complexity
|
|
795
|
+
3. **Monorepo detection** -- checks for `nx.json`, `pnpm-workspace.yaml`, `lerna.json`, npm workspaces
|
|
796
|
+
4. **Context7 docs** -- fetches current library documentation for detected dependencies
|
|
797
|
+
5. **Memory bootstrap** -- builds the memory graph from existing code tags and session history
|
|
798
|
+
6. **Thread migration** -- migrates past brainstorm sessions to conversation threads (one-time)
|
|
799
|
+
|
|
800
|
+
After `/cap:init`, run `/cap:annotate` to retroactively tag your existing code. This is the fastest way to bring an existing codebase into the CAP workflow.
|
|
801
|
+
|
|
802
|
+
---
|
|
803
|
+
|
|
804
|
+
## License
|
|
805
|
+
|
|
806
|
+
MIT
|