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.
Files changed (275) hide show
  1. package/.claude-plugin/README.md +26 -0
  2. package/.claude-plugin/marketplace.json +24 -0
  3. package/.claude-plugin/plugin.json +24 -0
  4. package/LICENSE +21 -0
  5. package/README.ja-JP.md +834 -0
  6. package/README.ko-KR.md +823 -0
  7. package/README.md +806 -0
  8. package/README.pt-BR.md +452 -0
  9. package/README.zh-CN.md +800 -0
  10. package/agents/cap-architect.md +269 -0
  11. package/agents/cap-brainstormer.md +207 -0
  12. package/agents/cap-curator.md +276 -0
  13. package/agents/cap-debugger.md +365 -0
  14. package/agents/cap-designer.md +246 -0
  15. package/agents/cap-historian.md +464 -0
  16. package/agents/cap-migrator.md +291 -0
  17. package/agents/cap-prototyper.md +197 -0
  18. package/agents/cap-validator.md +308 -0
  19. package/bin/install.js +5433 -0
  20. package/cap/bin/cap-tools.cjs +853 -0
  21. package/cap/bin/lib/arc-scanner.cjs +344 -0
  22. package/cap/bin/lib/cap-affinity-engine.cjs +862 -0
  23. package/cap/bin/lib/cap-anchor.cjs +228 -0
  24. package/cap/bin/lib/cap-annotation-writer.cjs +340 -0
  25. package/cap/bin/lib/cap-checkpoint.cjs +434 -0
  26. package/cap/bin/lib/cap-cluster-detect.cjs +945 -0
  27. package/cap/bin/lib/cap-cluster-display.cjs +52 -0
  28. package/cap/bin/lib/cap-cluster-format.cjs +245 -0
  29. package/cap/bin/lib/cap-cluster-helpers.cjs +295 -0
  30. package/cap/bin/lib/cap-cluster-io.cjs +212 -0
  31. package/cap/bin/lib/cap-completeness.cjs +540 -0
  32. package/cap/bin/lib/cap-deps.cjs +583 -0
  33. package/cap/bin/lib/cap-design-families.cjs +332 -0
  34. package/cap/bin/lib/cap-design.cjs +966 -0
  35. package/cap/bin/lib/cap-divergence-detector.cjs +400 -0
  36. package/cap/bin/lib/cap-doctor.cjs +752 -0
  37. package/cap/bin/lib/cap-feature-map-internals.cjs +19 -0
  38. package/cap/bin/lib/cap-feature-map-migrate.cjs +335 -0
  39. package/cap/bin/lib/cap-feature-map-monorepo.cjs +885 -0
  40. package/cap/bin/lib/cap-feature-map-shard.cjs +315 -0
  41. package/cap/bin/lib/cap-feature-map.cjs +1943 -0
  42. package/cap/bin/lib/cap-fitness-score.cjs +1075 -0
  43. package/cap/bin/lib/cap-impact-analysis.cjs +652 -0
  44. package/cap/bin/lib/cap-learn-review.cjs +1072 -0
  45. package/cap/bin/lib/cap-learning-signals.cjs +627 -0
  46. package/cap/bin/lib/cap-loader.cjs +227 -0
  47. package/cap/bin/lib/cap-logger.cjs +57 -0
  48. package/cap/bin/lib/cap-memory-bridge.cjs +764 -0
  49. package/cap/bin/lib/cap-memory-confidence.cjs +452 -0
  50. package/cap/bin/lib/cap-memory-dir.cjs +987 -0
  51. package/cap/bin/lib/cap-memory-engine.cjs +698 -0
  52. package/cap/bin/lib/cap-memory-extends.cjs +398 -0
  53. package/cap/bin/lib/cap-memory-graph.cjs +790 -0
  54. package/cap/bin/lib/cap-memory-migrate.cjs +2015 -0
  55. package/cap/bin/lib/cap-memory-pin.cjs +183 -0
  56. package/cap/bin/lib/cap-memory-platform.cjs +490 -0
  57. package/cap/bin/lib/cap-memory-prune.cjs +707 -0
  58. package/cap/bin/lib/cap-memory-schema.cjs +812 -0
  59. package/cap/bin/lib/cap-migrate-tags.cjs +309 -0
  60. package/cap/bin/lib/cap-migrate.cjs +540 -0
  61. package/cap/bin/lib/cap-pattern-apply.cjs +1203 -0
  62. package/cap/bin/lib/cap-pattern-pipeline.cjs +1034 -0
  63. package/cap/bin/lib/cap-plugin-manifest.cjs +80 -0
  64. package/cap/bin/lib/cap-realtime-affinity.cjs +399 -0
  65. package/cap/bin/lib/cap-reconcile.cjs +570 -0
  66. package/cap/bin/lib/cap-research-gate.cjs +218 -0
  67. package/cap/bin/lib/cap-scope-filter.cjs +402 -0
  68. package/cap/bin/lib/cap-semantic-pipeline.cjs +1038 -0
  69. package/cap/bin/lib/cap-session-extract.cjs +987 -0
  70. package/cap/bin/lib/cap-session.cjs +445 -0
  71. package/cap/bin/lib/cap-snapshot-linkage.cjs +963 -0
  72. package/cap/bin/lib/cap-stack-docs.cjs +646 -0
  73. package/cap/bin/lib/cap-tag-observer.cjs +371 -0
  74. package/cap/bin/lib/cap-tag-scanner.cjs +1766 -0
  75. package/cap/bin/lib/cap-telemetry.cjs +466 -0
  76. package/cap/bin/lib/cap-test-audit.cjs +1438 -0
  77. package/cap/bin/lib/cap-thread-migrator.cjs +307 -0
  78. package/cap/bin/lib/cap-thread-synthesis.cjs +545 -0
  79. package/cap/bin/lib/cap-thread-tracker.cjs +519 -0
  80. package/cap/bin/lib/cap-trace.cjs +399 -0
  81. package/cap/bin/lib/cap-trust-mode.cjs +336 -0
  82. package/cap/bin/lib/cap-ui-design-editor.cjs +642 -0
  83. package/cap/bin/lib/cap-ui-mind-map.cjs +712 -0
  84. package/cap/bin/lib/cap-ui-thread-nav.cjs +693 -0
  85. package/cap/bin/lib/cap-ui.cjs +1245 -0
  86. package/cap/bin/lib/cap-upgrade.cjs +1028 -0
  87. package/cap/bin/lib/cli/arg-helpers.cjs +49 -0
  88. package/cap/bin/lib/cli/frontmatter-router.cjs +31 -0
  89. package/cap/bin/lib/cli/init-router.cjs +68 -0
  90. package/cap/bin/lib/cli/phase-router.cjs +102 -0
  91. package/cap/bin/lib/cli/state-router.cjs +61 -0
  92. package/cap/bin/lib/cli/template-router.cjs +37 -0
  93. package/cap/bin/lib/cli/uat-router.cjs +29 -0
  94. package/cap/bin/lib/cli/validation-router.cjs +26 -0
  95. package/cap/bin/lib/cli/verification-router.cjs +31 -0
  96. package/cap/bin/lib/cli/workstream-router.cjs +39 -0
  97. package/cap/bin/lib/commands.cjs +961 -0
  98. package/cap/bin/lib/config.cjs +467 -0
  99. package/cap/bin/lib/convention-reader.cjs +258 -0
  100. package/cap/bin/lib/core.cjs +1241 -0
  101. package/cap/bin/lib/feature-aggregator.cjs +423 -0
  102. package/cap/bin/lib/frontmatter.cjs +337 -0
  103. package/cap/bin/lib/init.cjs +1443 -0
  104. package/cap/bin/lib/manifest-generator.cjs +383 -0
  105. package/cap/bin/lib/milestone.cjs +253 -0
  106. package/cap/bin/lib/model-profiles.cjs +69 -0
  107. package/cap/bin/lib/monorepo-context.cjs +226 -0
  108. package/cap/bin/lib/monorepo-migrator.cjs +509 -0
  109. package/cap/bin/lib/phase.cjs +889 -0
  110. package/cap/bin/lib/profile-output.cjs +989 -0
  111. package/cap/bin/lib/profile-pipeline.cjs +540 -0
  112. package/cap/bin/lib/roadmap.cjs +330 -0
  113. package/cap/bin/lib/security.cjs +394 -0
  114. package/cap/bin/lib/session-manager.cjs +292 -0
  115. package/cap/bin/lib/skeleton-generator.cjs +179 -0
  116. package/cap/bin/lib/state.cjs +1032 -0
  117. package/cap/bin/lib/template.cjs +231 -0
  118. package/cap/bin/lib/test-detector.cjs +62 -0
  119. package/cap/bin/lib/uat.cjs +283 -0
  120. package/cap/bin/lib/verify.cjs +889 -0
  121. package/cap/bin/lib/workspace-detector.cjs +371 -0
  122. package/cap/bin/lib/workstream.cjs +492 -0
  123. package/cap/commands/gsd/workstreams.md +63 -0
  124. package/cap/references/arc-standard.md +315 -0
  125. package/cap/references/cap-agent-architecture.md +101 -0
  126. package/cap/references/cap-gitignore-template +9 -0
  127. package/cap/references/cap-zero-deps.md +158 -0
  128. package/cap/references/checkpoints.md +778 -0
  129. package/cap/references/continuation-format.md +249 -0
  130. package/cap/references/contract-test-templates.md +312 -0
  131. package/cap/references/feature-map-template.md +25 -0
  132. package/cap/references/git-integration.md +295 -0
  133. package/cap/references/git-planning-commit.md +38 -0
  134. package/cap/references/model-profiles.md +174 -0
  135. package/cap/references/phase-numbering.md +126 -0
  136. package/cap/references/planning-config.md +202 -0
  137. package/cap/references/property-test-templates.md +316 -0
  138. package/cap/references/security-test-templates.md +347 -0
  139. package/cap/references/session-template.json +8 -0
  140. package/cap/references/tdd.md +263 -0
  141. package/cap/references/user-profiling.md +681 -0
  142. package/cap/references/verification-patterns.md +612 -0
  143. package/cap/templates/UAT.md +265 -0
  144. package/cap/templates/claude-md.md +175 -0
  145. package/cap/templates/codebase/architecture.md +255 -0
  146. package/cap/templates/codebase/concerns.md +310 -0
  147. package/cap/templates/codebase/conventions.md +307 -0
  148. package/cap/templates/codebase/integrations.md +280 -0
  149. package/cap/templates/codebase/stack.md +186 -0
  150. package/cap/templates/codebase/structure.md +285 -0
  151. package/cap/templates/codebase/testing.md +480 -0
  152. package/cap/templates/config.json +44 -0
  153. package/cap/templates/context.md +352 -0
  154. package/cap/templates/continue-here.md +78 -0
  155. package/cap/templates/copilot-instructions.md +7 -0
  156. package/cap/templates/debug-subagent-prompt.md +91 -0
  157. package/cap/templates/discussion-log.md +63 -0
  158. package/cap/templates/milestone-archive.md +123 -0
  159. package/cap/templates/milestone.md +115 -0
  160. package/cap/templates/phase-prompt.md +610 -0
  161. package/cap/templates/planner-subagent-prompt.md +117 -0
  162. package/cap/templates/project.md +186 -0
  163. package/cap/templates/requirements.md +231 -0
  164. package/cap/templates/research-project/ARCHITECTURE.md +204 -0
  165. package/cap/templates/research-project/FEATURES.md +147 -0
  166. package/cap/templates/research-project/PITFALLS.md +200 -0
  167. package/cap/templates/research-project/STACK.md +120 -0
  168. package/cap/templates/research-project/SUMMARY.md +170 -0
  169. package/cap/templates/research.md +552 -0
  170. package/cap/templates/roadmap.md +202 -0
  171. package/cap/templates/state.md +176 -0
  172. package/cap/templates/summary.md +364 -0
  173. package/cap/templates/user-preferences.md +498 -0
  174. package/cap/templates/verification-report.md +322 -0
  175. package/cap/workflows/add-phase.md +112 -0
  176. package/cap/workflows/add-tests.md +351 -0
  177. package/cap/workflows/add-todo.md +158 -0
  178. package/cap/workflows/audit-milestone.md +340 -0
  179. package/cap/workflows/audit-uat.md +109 -0
  180. package/cap/workflows/autonomous.md +891 -0
  181. package/cap/workflows/check-todos.md +177 -0
  182. package/cap/workflows/cleanup.md +152 -0
  183. package/cap/workflows/complete-milestone.md +767 -0
  184. package/cap/workflows/diagnose-issues.md +231 -0
  185. package/cap/workflows/discovery-phase.md +289 -0
  186. package/cap/workflows/discuss-phase-assumptions.md +653 -0
  187. package/cap/workflows/discuss-phase.md +1049 -0
  188. package/cap/workflows/do.md +104 -0
  189. package/cap/workflows/execute-phase.md +846 -0
  190. package/cap/workflows/execute-plan.md +514 -0
  191. package/cap/workflows/fast.md +105 -0
  192. package/cap/workflows/forensics.md +265 -0
  193. package/cap/workflows/health.md +181 -0
  194. package/cap/workflows/help.md +660 -0
  195. package/cap/workflows/insert-phase.md +130 -0
  196. package/cap/workflows/list-phase-assumptions.md +178 -0
  197. package/cap/workflows/list-workspaces.md +56 -0
  198. package/cap/workflows/manager.md +362 -0
  199. package/cap/workflows/map-codebase.md +377 -0
  200. package/cap/workflows/milestone-summary.md +223 -0
  201. package/cap/workflows/new-milestone.md +486 -0
  202. package/cap/workflows/new-project.md +1250 -0
  203. package/cap/workflows/new-workspace.md +237 -0
  204. package/cap/workflows/next.md +97 -0
  205. package/cap/workflows/node-repair.md +92 -0
  206. package/cap/workflows/note.md +156 -0
  207. package/cap/workflows/pause-work.md +176 -0
  208. package/cap/workflows/plan-milestone-gaps.md +273 -0
  209. package/cap/workflows/plan-phase.md +857 -0
  210. package/cap/workflows/plant-seed.md +169 -0
  211. package/cap/workflows/pr-branch.md +129 -0
  212. package/cap/workflows/profile-user.md +449 -0
  213. package/cap/workflows/progress.md +507 -0
  214. package/cap/workflows/quick.md +757 -0
  215. package/cap/workflows/remove-phase.md +155 -0
  216. package/cap/workflows/remove-workspace.md +90 -0
  217. package/cap/workflows/research-phase.md +82 -0
  218. package/cap/workflows/resume-project.md +326 -0
  219. package/cap/workflows/review.md +228 -0
  220. package/cap/workflows/session-report.md +146 -0
  221. package/cap/workflows/settings.md +283 -0
  222. package/cap/workflows/ship.md +228 -0
  223. package/cap/workflows/stats.md +60 -0
  224. package/cap/workflows/transition.md +671 -0
  225. package/cap/workflows/ui-phase.md +298 -0
  226. package/cap/workflows/ui-review.md +161 -0
  227. package/cap/workflows/update.md +323 -0
  228. package/cap/workflows/validate-phase.md +170 -0
  229. package/cap/workflows/verify-phase.md +254 -0
  230. package/cap/workflows/verify-work.md +637 -0
  231. package/commands/cap/annotate.md +165 -0
  232. package/commands/cap/brainstorm.md +393 -0
  233. package/commands/cap/checkpoint.md +106 -0
  234. package/commands/cap/completeness.md +94 -0
  235. package/commands/cap/continue.md +72 -0
  236. package/commands/cap/debug.md +588 -0
  237. package/commands/cap/deps.md +169 -0
  238. package/commands/cap/design.md +479 -0
  239. package/commands/cap/init.md +354 -0
  240. package/commands/cap/iterate.md +249 -0
  241. package/commands/cap/learn.md +459 -0
  242. package/commands/cap/memory.md +275 -0
  243. package/commands/cap/migrate-feature-map.md +91 -0
  244. package/commands/cap/migrate-memory.md +108 -0
  245. package/commands/cap/migrate-tags.md +91 -0
  246. package/commands/cap/migrate.md +131 -0
  247. package/commands/cap/prototype.md +510 -0
  248. package/commands/cap/reconcile.md +121 -0
  249. package/commands/cap/review.md +360 -0
  250. package/commands/cap/save.md +72 -0
  251. package/commands/cap/scan.md +404 -0
  252. package/commands/cap/start.md +356 -0
  253. package/commands/cap/status.md +118 -0
  254. package/commands/cap/test-audit.md +262 -0
  255. package/commands/cap/test.md +394 -0
  256. package/commands/cap/trace.md +133 -0
  257. package/commands/cap/ui.md +167 -0
  258. package/hooks/dist/cap-check-update.js +115 -0
  259. package/hooks/dist/cap-context-monitor.js +185 -0
  260. package/hooks/dist/cap-learn-review-hook.js +114 -0
  261. package/hooks/dist/cap-learning-hook.js +192 -0
  262. package/hooks/dist/cap-memory.js +299 -0
  263. package/hooks/dist/cap-prompt-guard.js +97 -0
  264. package/hooks/dist/cap-statusline.js +157 -0
  265. package/hooks/dist/cap-tag-observer.js +115 -0
  266. package/hooks/dist/cap-version-check.js +112 -0
  267. package/hooks/dist/cap-workflow-guard.js +175 -0
  268. package/hooks/hooks.json +55 -0
  269. package/package.json +58 -0
  270. package/scripts/base64-scan.sh +262 -0
  271. package/scripts/build-hooks.js +93 -0
  272. package/scripts/cap-removal-checklist.md +202 -0
  273. package/scripts/prompt-injection-scan.sh +199 -0
  274. package/scripts/run-tests.cjs +181 -0
  275. package/scripts/secret-scan.sh +227 -0
@@ -0,0 +1,356 @@
1
+ ---
2
+ name: cap:start
3
+ description: Initialize a CAP session -- restore previous session state, detect project context, and get working immediately.
4
+ allowed-tools:
5
+ - Bash
6
+ - Read
7
+ - Write
8
+ - AskUserQuestion
9
+ ---
10
+
11
+ <!-- @cap-context CAP v2.0 start command -- session initialization at the start of a new conversation. Restores .cap/SESSION.json state, detects workspace type, and presents current Feature Map status. -->
12
+ <!-- @cap-decision Start reads SESSION.json to restore context from previous conversation. This is critical for cross-conversation continuity since Claude Code conversations are stateless. -->
13
+ <!-- @cap-decision Start auto-runs /cap:init if .cap/ directory does not exist -- first-time users get bootstrapped automatically. -->
14
+
15
+ <objective>
16
+ Initialize a CAP session at the start of a new conversation:
17
+ 1. Check if .cap/ exists -- if not, auto-initialize
18
+ 2. Auto-detect project info from package.json and directory structure
19
+ 3. Load .cap/SESSION.json for previous session state
20
+ 4. List features from FEATURE-MAP.md for user selection
21
+ 5. Present current status and suggest next action
22
+
23
+ No arguments needed -- always runs the same flow.
24
+ </objective>
25
+
26
+ <context>
27
+ $ARGUMENTS
28
+
29
+ @.cap/SESSION.json
30
+ @FEATURE-MAP.md
31
+ </context>
32
+
33
+ <process>
34
+
35
+ ## Step 1: Check for .cap/ directory and auto-initialize
36
+
37
+ <!-- @cap-todo(ref:AC-34) /cap:start shall initialize a session by setting the active feature in SESSION.json and restoring context from the Feature Map. -->
38
+
39
+ ```bash
40
+ test -d .cap && echo "initialized" || echo "not_initialized"
41
+ ```
42
+
43
+ **If not initialized:**
44
+
45
+ Log: "First run detected. Initializing .cap/ directory..."
46
+
47
+ ```bash
48
+ node -e "
49
+ const session = require('./cap/bin/lib/cap-session.cjs');
50
+ session.initCapDirectory(process.cwd());
51
+ console.log('initialized');
52
+ "
53
+ ```
54
+
55
+ Check if FEATURE-MAP.md exists:
56
+
57
+ ```bash
58
+ test -f FEATURE-MAP.md && echo "exists" || echo "missing"
59
+ ```
60
+
61
+ If FEATURE-MAP.md does not exist, generate the template:
62
+
63
+ ```bash
64
+ node -e "
65
+ const fm = require('./cap/bin/lib/cap-feature-map.cjs');
66
+ const fs = require('node:fs');
67
+ const path = require('node:path');
68
+ const template = fm.generateTemplate();
69
+ fs.writeFileSync(path.join(process.cwd(), 'FEATURE-MAP.md'), template, 'utf8');
70
+ console.log('FEATURE-MAP.md created');
71
+ "
72
+ ```
73
+
74
+ Log: "Created .cap/ directory and FEATURE-MAP.md"
75
+
76
+ ## Step 1b: Detect monorepo and handle app scoping
77
+
78
+ ```bash
79
+ node -e "
80
+ const session = require('./cap/bin/lib/cap-session.cjs');
81
+ const s = session.loadSession(process.cwd());
82
+ const mono = session.listApps(process.cwd());
83
+ console.log(JSON.stringify({ isMonorepo: mono.isMonorepo, apps: mono.apps, activeApp: s.activeApp }));
84
+ "
85
+ ```
86
+
87
+ Store as `mono_info`.
88
+
89
+ **If monorepo and no activeApp in session:**
90
+
91
+ Log: "Monorepo detected with {N} apps. Select an app to scope your session."
92
+
93
+ List apps:
94
+ ```
95
+ Available apps:
96
+ {For each app:}
97
+ {index}. {app}
98
+ {End for}
99
+ 0. (root) -- Work at monorepo root level
100
+ ```
101
+
102
+ Use AskUserQuestion:
103
+ > "Select an app to focus on (enter number or path, e.g., 'apps/flow'), or '0' for root-level work:"
104
+
105
+ Process response and set active app:
106
+
107
+ ```bash
108
+ node -e "
109
+ const session = require('./cap/bin/lib/cap-session.cjs');
110
+ const selected = process.argv[1] === 'null' ? null : process.argv[1];
111
+ session.setActiveApp(process.cwd(), selected);
112
+ console.log('Active app set to: ' + (selected || '(root)'));
113
+ " '<SELECTED_APP_PATH_OR_NULL>'
114
+ ```
115
+
116
+ **If monorepo and activeApp is set:**
117
+
118
+ Log: "Monorepo session restored. Active app: {activeApp}"
119
+ Continue with existing activeApp. User can switch later with `/cap:start --app=<name>`.
120
+
121
+ **If not a monorepo:**
122
+
123
+ Continue with single-repo behavior (no app scoping).
124
+
125
+ **For all subsequent steps:** When reading/writing FEATURE-MAP.md, use the activeApp path.
126
+ The effective FEATURE-MAP.md location is:
127
+ - Monorepo with activeApp: `{projectRoot}/{activeApp}/FEATURE-MAP.md`
128
+ - Monorepo without activeApp (root): `{projectRoot}/FEATURE-MAP.md`
129
+ - Single repo: `{projectRoot}/FEATURE-MAP.md`
130
+
131
+ ## Step 2: Auto-detect project context
132
+
133
+ <!-- @cap-todo(ref:AC-35) /cap:start shall auto-scope to the project by deriving project information from actual code (package.json, directory structure) rather than asking questions. -->
134
+
135
+ Detect project info from the filesystem -- no questions asked:
136
+
137
+ ```bash
138
+ node -e "
139
+ const fs = require('node:fs');
140
+ const path = require('node:path');
141
+ const cwd = process.cwd();
142
+ const info = { name: path.basename(cwd), language: 'unknown', framework: 'unknown', testFramework: 'unknown' };
143
+
144
+ // Read package.json if available
145
+ const pkgPath = path.join(cwd, 'package.json');
146
+ if (fs.existsSync(pkgPath)) {
147
+ try {
148
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
149
+ info.name = pkg.name || info.name;
150
+ info.language = 'javascript';
151
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
152
+ if (allDeps.typescript) info.language = 'typescript';
153
+ if (allDeps.react) info.framework = 'react';
154
+ if (allDeps.next) info.framework = 'next.js';
155
+ if (allDeps.express) info.framework = 'express';
156
+ if (allDeps.vitest) info.testFramework = 'vitest';
157
+ else if (allDeps.jest) info.testFramework = 'jest';
158
+ else if (pkg.scripts && pkg.scripts.test && pkg.scripts.test.includes('node --test')) info.testFramework = 'node:test';
159
+ } catch (e) {}
160
+ }
161
+
162
+ // Check for Python
163
+ if (fs.existsSync(path.join(cwd, 'requirements.txt')) || fs.existsSync(path.join(cwd, 'pyproject.toml'))) {
164
+ info.language = 'python';
165
+ if (fs.existsSync(path.join(cwd, 'pyproject.toml'))) {
166
+ const content = fs.readFileSync(path.join(cwd, 'pyproject.toml'), 'utf8');
167
+ if (content.includes('django')) info.framework = 'django';
168
+ if (content.includes('fastapi')) info.framework = 'fastapi';
169
+ if (content.includes('pytest')) info.testFramework = 'pytest';
170
+ }
171
+ }
172
+
173
+ // Check for Go
174
+ if (fs.existsSync(path.join(cwd, 'go.mod'))) {
175
+ info.language = 'go';
176
+ info.testFramework = 'go test';
177
+ }
178
+
179
+ // Check for Rust
180
+ if (fs.existsSync(path.join(cwd, 'Cargo.toml'))) {
181
+ info.language = 'rust';
182
+ info.testFramework = 'cargo test';
183
+ }
184
+
185
+ console.log(JSON.stringify(info));
186
+ "
187
+ ```
188
+
189
+ Store as `project_info`.
190
+
191
+ ## Step 3: Load session state
192
+
193
+ ```bash
194
+ node -e "
195
+ const session = require('./cap/bin/lib/cap-session.cjs');
196
+ const s = session.loadSession(process.cwd());
197
+ console.log(JSON.stringify(s));
198
+ "
199
+ ```
200
+
201
+ Store as `session`.
202
+
203
+ ## Step 4: Load Feature Map and present features
204
+
205
+ ```bash
206
+ node -e "
207
+ const fm = require('./cap/bin/lib/cap-feature-map.cjs');
208
+ // @cap-todo(ac:F-081/AC-4 iter:2) Migrated to {safe: true} opt-in to preserve CLI on duplicate-ID FEATURE-MAP.
209
+ // @cap-decision(F-081/iter2) Warn on parseError; continue with partial map for read-only display.
210
+ const featureMap = fm.readFeatureMap(process.cwd(), undefined, { safe: true });
211
+ if (featureMap && featureMap.parseError) {
212
+ console.warn('cap: start — duplicate feature ID detected, summary uses partial map: ' + String(featureMap.parseError.message).trim());
213
+ }
214
+ const status = fm.getStatus(featureMap);
215
+ console.log(JSON.stringify({
216
+ features: featureMap.features.map(f => ({ id: f.id, title: f.title, state: f.state, acCount: f.acs.length })),
217
+ ...status
218
+ }));
219
+ "
220
+ ```
221
+
222
+ Store as `fm_data`.
223
+
224
+ ## Step 5: Present session context and select active feature
225
+
226
+ Display session restoration:
227
+
228
+ ```
229
+ === CAP Session Start ===
230
+
231
+ Project: {project_info.name} ({project_info.language} / {project_info.framework})
232
+ Test framework: {project_info.testFramework}
233
+
234
+ {If session.activeFeature:}
235
+ Previous session:
236
+ Active feature: {session.activeFeature}
237
+ Last step: {session.step}
238
+ Last command: {session.lastCommand}
239
+
240
+ {End if}
241
+
242
+ Features ({fm_data.totalFeatures} total):
243
+ planned: {count}
244
+ prototyped: {count}
245
+ tested: {count}
246
+ shipped: {count}
247
+ ```
248
+
249
+ **If features exist, list them and ask user to select:**
250
+
251
+ ```
252
+ Available features:
253
+ {For each feature:}
254
+ {feature.id}: {feature.title} [{feature.state}] ({feature.acCount} ACs)
255
+ ```
256
+
257
+ If `session.activeFeature` is set, offer to continue:
258
+
259
+ Use AskUserQuestion:
260
+ > "Continue working on {session.activeFeature} ({title})? Or enter a feature ID to switch (e.g., F-001). Type 'none' to work without a focused feature."
261
+
262
+ If no active feature:
263
+
264
+ Use AskUserQuestion:
265
+ > "Select a feature to focus on (enter feature ID, e.g., F-001), or type 'none' to skip."
266
+
267
+ **Process user response:**
268
+ - If a valid feature ID: set as active feature
269
+ - If `none` or `skip`: proceed without active feature
270
+ - If continuing previous: keep existing active feature
271
+
272
+ ```bash
273
+ node -e "
274
+ const session = require('./cap/bin/lib/cap-session.cjs');
275
+ session.startSession(process.cwd(), '{selected_feature_id}', 'start');
276
+ console.log('Session updated');
277
+ "
278
+ ```
279
+
280
+ ## Step 5b: Passively check realtime affinity for selected feature
281
+
282
+ <!-- @cap-todo(ac:F-040/AC-4) /cap:start passively checks realtime affinity and surfaces urgent/notify threads relevant to the selected feature before session work begins -->
283
+
284
+ If an active feature was selected, check for related threads via realtime affinity:
285
+
286
+ ```bash
287
+ node -e "
288
+ const realtimeAffinity = require('./cap/bin/lib/cap-realtime-affinity.cjs');
289
+ const clusterDisplay = require('./cap/bin/lib/cap-cluster-display.cjs');
290
+ const tracker = require('./cap/bin/lib/cap-thread-tracker.cjs');
291
+
292
+ try {
293
+ // Find threads related to the active feature
294
+ const threads = tracker.listThreads(process.cwd());
295
+ const activeThread = threads.find(t => t.featureIds && t.featureIds.includes('{selected_feature_id}'));
296
+
297
+ if (activeThread) {
298
+ const fullThread = tracker.loadThread(process.cwd(), activeThread.id);
299
+ const notifications = realtimeAffinity.onSessionStart(process.cwd(), fullThread);
300
+ const output = clusterDisplay.formatRealtimeNotifications(notifications);
301
+ if (output) console.log(output);
302
+ else console.log('');
303
+ } else {
304
+ console.log('');
305
+ }
306
+ } catch (e) {
307
+ console.log('');
308
+ }
309
+ "
310
+ ```
311
+
312
+ If output is non-empty, display it before suggesting next action:
313
+
314
+ ```
315
+ {realtime_affinity_output}
316
+ ```
317
+
318
+ ## Step 5c: Surface Claude-native auto-memory bridge (F-080)
319
+
320
+ <!-- @cap-feature(feature:F-080) /cap:start surfaces Claude-native auto-memory entries relevant to the active feature. Runtime-only; bridge is a read-only consumer of ~/.claude/projects/<slug>/memory/. -->
321
+ <!-- @cap-todo(ac:F-080/AC-4) /cap:start displays "Claude-native erinnert: <bullets>" when bridge data is available. -->
322
+ <!-- @cap-todo(ac:F-080/AC-3) Silent skip when ~/.claude/projects/<slug>/memory/ is missing or unreadable — no warn, no error. -->
323
+
324
+ ```bash
325
+ node -e "
326
+ const bridge = require('./cap/bin/lib/cap-memory-bridge.cjs');
327
+ const session = require('./cap/bin/lib/cap-session.cjs');
328
+ try {
329
+ const s = session.loadSession(process.cwd());
330
+ const active = (s && typeof s.activeFeature === 'string' && s.activeFeature.length > 0) ? s.activeFeature : null;
331
+ const surface = bridge.surfaceForFeature(process.cwd(), active);
332
+ const formatted = bridge.formatSurface(surface);
333
+ if (formatted) console.log(formatted);
334
+ } catch (_e) {
335
+ // Silent skip — F-080/AC-3 contract.
336
+ }
337
+ "
338
+ ```
339
+
340
+ If output is non-empty, display it before the next-action suggestion. If empty, omit entirely (no header line).
341
+
342
+ ## Step 6: Suggest next action
343
+
344
+ Based on current state, suggest:
345
+
346
+ - If no features: "No features found. Run /cap:brainstorm to discover features."
347
+ - If active feature is `planned`: "Run /cap:prototype to build initial code for {feature}."
348
+ - If active feature is `prototyped`: "Run /cap:iterate to refine, or /cap:test to write tests."
349
+ - If active feature is `tested`: "Run /cap:review to verify {feature}."
350
+ - If active feature is `shipped`: "All done with {feature}. Select a different feature or run /cap:brainstorm."
351
+
352
+ ```
353
+ Session started. Suggested next: {action}
354
+ ```
355
+
356
+ </process>
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: cap:status
3
+ description: Show project status derived from Feature Map -- thin wrapper that spawns cap-curator (MODE: STATUS or DRIFT) for the dashboard, drift report, or completeness audit.
4
+ argument-hint: "[--features NAME] [--verbose] [--drift] [--completeness]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Task
9
+ - Glob
10
+ - Grep
11
+ ---
12
+
13
+ <!-- @cap-context CAP v3 status command -- thin multi-mode wrapper. The dashboard logic (feature states, AC totals, tag coverage, token telemetry, neural memory, design-usage, suggested-next) lives in cap-curator MODE: STATUS. Drift detection lives in cap-curator MODE: DRIFT. Completeness scoring (F-048 opt-in) stays inline because the output format `formatFeatureBreakdown` is user-facing and was not migrated into cap-validator MODE: AUDIT (which uses `formatCompletenessReport`). -->
14
+ <!-- @cap-decision Wrapper, not orchestrator. Status.md was 327 lines duplicating logic now consolidated in cap-curator. The wrapper only parses flags, dispatches the right mode, and surfaces backwards-compat fast-paths (--drift, --completeness). -->
15
+ <!-- @cap-decision --completeness stays inline (calls formatFeatureBreakdown directly) to preserve the per-feature N/4 breakdown output. cap-validator MODE: AUDIT renders the longer formatCompletenessReport — distinct surface, distinct command (/cap:completeness). -->
16
+ <!-- @cap-decision Status remains read-only -- wrapper never mutates Feature Map or session. cap-curator's read-only contract is non-negotiable. -->
17
+ <!-- @cap-feature(feature:F-042) /cap:status --drift surfaces feature/AC status mismatches via cap-curator MODE: DRIFT (detectDrift + formatDriftReport). -->
18
+
19
+ <objective>
20
+ Presents a compact project status dashboard derived from FEATURE-MAP.md, SESSION.json, and a live tag scan. All rendering is delegated to cap-curator (read-only agent) — this command is a thin dispatcher.
21
+
22
+ **Arguments:**
23
+ - `--features NAME` — show status for specific features only (comma-separated). Forwarded to cap-curator.
24
+ - `--verbose` — include per-AC + Design-Usage breakdown via cap-trace.formatDesignUsage. Forwarded to cap-curator.
25
+ - `--drift` — fast-path: cap-curator MODE: DRIFT. Exit code 0 if consistent, 1 if drift exists (CI-friendly).
26
+ - `--completeness` — F-048 opt-in: per-feature 4-point Completeness Score breakdown. Inline fast-path (preserves `formatFeatureBreakdown` output verbatim).
27
+ </objective>
28
+
29
+ <context>
30
+ $ARGUMENTS
31
+
32
+ @FEATURE-MAP.md
33
+ @.cap/SESSION.json
34
+ </context>
35
+
36
+ <process>
37
+
38
+ ## Step 0: Parse flags
39
+
40
+ Inspect `$ARGUMENTS` for:
41
+ - `--completeness` → run Step 1 (inline fast-path), STOP.
42
+ - `--drift` → run Step 2 (cap-curator MODE: DRIFT), STOP.
43
+ - Otherwise → run Step 3 (cap-curator MODE: STATUS) with `--features NAME` and `--verbose` forwarded as-is.
44
+
45
+ ## Step 1: Completeness fast-path (--completeness, F-048)
46
+
47
+ <!-- @cap-todo(ac:F-048/AC-2) /cap:status --completeness shall show per-feature N/4 scores. -->
48
+
49
+ ```bash
50
+ node -e "
51
+ const comp = require('./cap/bin/lib/cap-completeness.cjs');
52
+ const cfg = comp.loadCompletenessConfig(process.cwd());
53
+ if (!cfg.enabled) {
54
+ console.error('F-048 (completeness score) is opt-in and not enabled for this project.');
55
+ console.error('To enable: add { \"completenessScore\": { \"enabled\": true } } to .cap/config.json');
56
+ process.exit(2);
57
+ }
58
+ const ctx = comp.buildContext(process.cwd());
59
+ const scores = comp.scoreAllFeatures(ctx);
60
+ console.log(comp.formatFeatureBreakdown(scores));
61
+ "
62
+ ```
63
+
64
+ Display verbatim, then **stop**. (For the longer markdown audit suitable for PR attachment, see `/cap:completeness`.)
65
+
66
+ ## Step 2: Drift fast-path (--drift)
67
+
68
+ <!-- @cap-todo(ac:F-042/AC-6) /cap:status --drift surfaces mismatched feature/AC states for the entire Feature Map. Exit code 0 if no drift, 1 if drift exists (CI-friendly). -->
69
+
70
+ Spawn `cap-curator` via Task tool with this prompt:
71
+
72
+ ```
73
+ **MODE: DRIFT**
74
+
75
+ $ARGUMENTS
76
+
77
+ Render the drift report verbatim from `fm.formatDriftReport(fm.detectDrift(root))`.
78
+ Exit code is CI-meaningful: 0 = consistent, 1 = drift.
79
+ Append the read-only footer pointing at /cap:reconcile.
80
+ ```
81
+
82
+ Display the agent's output verbatim, then **stop**.
83
+
84
+ ## Step 3: Status dashboard (default)
85
+
86
+ <!-- @cap-todo(ref:AC-31) /cap:status shall display the current session state from SESSION.json (active feature, current step, session duration). -->
87
+ <!-- @cap-todo(ref:AC-32) /cap:status shall display a summary of FEATURE-MAP.md (count of features per state). -->
88
+ <!-- @cap-todo(ref:AC-33) /cap:status shall display tag coverage statistics (files with tags vs. total source files). -->
89
+ <!-- @cap-todo(ac:F-061/AC-3) /cap:status shall display current session token consumption and LLM budget remaining capacity. -->
90
+ <!-- @cap-todo(ac:F-080/AC-4) /cap:status displays Claude-native bridge surface when bridge data is available. -->
91
+ <!-- @cap-todo(ac:F-040/AC-3) /cap:status surfaces Neural Memory section (cluster count, dormant nodes, highest-affinity pair, last clustering timestamp). -->
92
+ <!-- @cap-todo(ac:F-063/AC-5) /cap:status --verbose displays the feature's Design-Usage list inline via cap-trace.formatDesignUsage. -->
93
+
94
+ Spawn `cap-curator` via Task tool with this prompt:
95
+
96
+ ```
97
+ **MODE: STATUS**
98
+
99
+ $ARGUMENTS
100
+
101
+ Render the compact dashboard:
102
+ - Session block: activeFeature, step, durationMinutes, lastCommand + token telemetry line (cap-telemetry.formatSessionStatusLine).
103
+ - Claude-native bridge surface (cap-memory-bridge.formatSurface) — silent skip if empty.
104
+ - Features by state (planned/prototyped/tested/shipped) + AC totals (total/implemented/tested/reviewed).
105
+ - Tag coverage (filesWithTags/totalFiles, totalTags grouped by @cap-feature/@cap-todo/@cap-risk/@cap-decision).
106
+ - Last scan timestamp.
107
+ - Neural Memory block (cap-cluster-display.loadAndFormatStatus).
108
+ - If --verbose: per-feature ACs + file count + dependencies + Design-Usage line via cap-trace.formatDesignUsage(feature, parseDesignIds(DESIGN.md)).
109
+ - Suggested-next hint based on session/feature state and tag coverage.
110
+
111
+ Read-only: never write FEATURE-MAP, SESSION, memory, or code. Output to stdout only.
112
+ ```
113
+
114
+ The agent renders the full `=== CAP Status ===` dashboard verbatim, including the suggested-next line. Display its output as-is.
115
+
116
+ </process>
117
+ </content>
118
+ </invoke>