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,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:annotate
|
|
3
|
+
description: "Retroactively annotate existing code with @cap-feature and @cap-todo tags. Invokes cap-prototyper in ANNOTATE mode."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Write
|
|
7
|
+
- Edit
|
|
8
|
+
- Bash
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Task
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<!-- @cap-context CAP v2.0 annotate command -- invokes cap-prototyper in annotate mode to add @cap-feature tags to existing unannotated code. Primary entry point after brownfield init. -->
|
|
15
|
+
<!-- @cap-decision Annotate is a thin command wrapper over cap-prototyper ANNOTATE mode. This avoids a separate agent and keeps all code generation/modification in one agent with mode dispatch. -->
|
|
16
|
+
<!-- @cap-decision Annotate targets a specific directory or defaults to project root src/. Scoped annotation prevents overwhelming the user with changes across the entire codebase at once. -->
|
|
17
|
+
|
|
18
|
+
<!-- @cap-todo(ref:AC-89) /cap:annotate shall invoke cap-prototyper in annotate mode -->
|
|
19
|
+
|
|
20
|
+
<objective>
|
|
21
|
+
Add @cap-feature and @cap-todo tags to existing unannotated code by invoking cap-prototyper in ANNOTATE mode. This is the recommended next step after brownfield /cap:init.
|
|
22
|
+
|
|
23
|
+
**Arguments:**
|
|
24
|
+
- `[path]` -- directory or file to annotate (defaults to `src/` or project root)
|
|
25
|
+
- `--feature F-NNN` -- scope annotation to a specific Feature Map entry
|
|
26
|
+
- `--dry-run` -- preview annotations without writing files
|
|
27
|
+
|
|
28
|
+
**Requires:** FEATURE-MAP.md must exist (run /cap:init first).
|
|
29
|
+
</objective>
|
|
30
|
+
|
|
31
|
+
<context>
|
|
32
|
+
$ARGUMENTS
|
|
33
|
+
|
|
34
|
+
@FEATURE-MAP.md
|
|
35
|
+
</context>
|
|
36
|
+
|
|
37
|
+
<process>
|
|
38
|
+
|
|
39
|
+
## Step 1: Validate prerequisites
|
|
40
|
+
|
|
41
|
+
Check that CAP is initialized:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
test -d .cap && echo "CAP_INITIALIZED" || echo "NOT_INITIALIZED"
|
|
45
|
+
test -f FEATURE-MAP.md && echo "FEATURE_MAP_EXISTS" || echo "NO_FEATURE_MAP"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If not initialized, abort with: "CAP is not initialized. Run /cap:init first."
|
|
49
|
+
|
|
50
|
+
## Step 2: Parse arguments
|
|
51
|
+
|
|
52
|
+
- Extract `path` from positional argument (default: `src/` if exists, else `.`)
|
|
53
|
+
- Extract `--feature` flag if present
|
|
54
|
+
- Extract `--dry-run` flag if present
|
|
55
|
+
|
|
56
|
+
## Step 3: Load context for annotate mode
|
|
57
|
+
|
|
58
|
+
Read FEATURE-MAP.md to understand available features and ACs.
|
|
59
|
+
|
|
60
|
+
Check for existing tags in target path:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
node -e "
|
|
64
|
+
const scanner = require('./cap/bin/lib/cap-tag-scanner.cjs');
|
|
65
|
+
const tags = scanner.scanDirectory(process.cwd());
|
|
66
|
+
const groups = scanner.groupByFeature(tags);
|
|
67
|
+
console.log(JSON.stringify({
|
|
68
|
+
totalTags: tags.length,
|
|
69
|
+
features: Object.keys(groups),
|
|
70
|
+
filesWithTags: new Set(tags.map(t => t.file)).size
|
|
71
|
+
}));
|
|
72
|
+
"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Load stack docs if available:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
ls .cap/stack-docs/*.md 2>/dev/null | head -10 || echo "no stack docs"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Step 4: Invoke cap-prototyper in ANNOTATE mode
|
|
82
|
+
|
|
83
|
+
Use the Task tool to spawn cap-prototyper with ANNOTATE mode:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
Task("cap-prototyper", "
|
|
87
|
+
**MODE: ANNOTATE**
|
|
88
|
+
|
|
89
|
+
**Target path:** {resolved_path}
|
|
90
|
+
**Feature scope:** {feature_id or 'all'}
|
|
91
|
+
**Dry run:** {dry_run}
|
|
92
|
+
|
|
93
|
+
**FEATURE-MAP.md content:**
|
|
94
|
+
{feature_map_content}
|
|
95
|
+
|
|
96
|
+
**Existing tags found:**
|
|
97
|
+
{existing_tag_summary}
|
|
98
|
+
|
|
99
|
+
**Stack docs available:**
|
|
100
|
+
{stack_docs_list}
|
|
101
|
+
|
|
102
|
+
**Instructions:**
|
|
103
|
+
1. Scan {target_path} for source files without @cap-feature tags
|
|
104
|
+
2. Read each unannotated file and identify significant functions, classes, modules
|
|
105
|
+
3. Match code to Feature Map entries based on purpose and file paths
|
|
106
|
+
4. Use the Edit tool to add @cap-feature tags WITHOUT changing code logic
|
|
107
|
+
5. Add @cap-todo tags for any unfinished work discovered during annotation
|
|
108
|
+
6. {If dry_run: 'OUTPUT the proposed changes but do NOT write files'}
|
|
109
|
+
")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Step 5: Run scan after annotation
|
|
113
|
+
|
|
114
|
+
After the prototyper completes, run a scan to update Feature Map:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
node -e "
|
|
118
|
+
const scanner = require('./cap/bin/lib/cap-tag-scanner.cjs');
|
|
119
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
120
|
+
const tags = scanner.scanDirectory(process.cwd());
|
|
121
|
+
const updated = fm.enrichFromTags(process.cwd(), tags);
|
|
122
|
+
console.log(JSON.stringify({
|
|
123
|
+
totalTags: tags.length,
|
|
124
|
+
featuresWithFiles: updated.features.filter(f => f.files.length > 0).length,
|
|
125
|
+
totalFileRefs: updated.features.reduce((sum, f) => sum + f.files.length, 0)
|
|
126
|
+
}));
|
|
127
|
+
"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Step 6: Report results
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
cap:annotate complete.
|
|
134
|
+
|
|
135
|
+
Files annotated: {N}
|
|
136
|
+
Tags added: {N}
|
|
137
|
+
@cap-feature: {N}
|
|
138
|
+
@cap-todo: {N}
|
|
139
|
+
@cap-risk: {N}
|
|
140
|
+
@cap-decision:{N}
|
|
141
|
+
|
|
142
|
+
Feature Map updated:
|
|
143
|
+
Features with file refs: {N}
|
|
144
|
+
Total file references: {N}
|
|
145
|
+
|
|
146
|
+
Next steps:
|
|
147
|
+
/cap:scan -- verify tag coverage
|
|
148
|
+
/cap:prototype -- build out features that need implementation
|
|
149
|
+
/cap:status -- view project dashboard
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Step 7: Update session
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
node -e "
|
|
156
|
+
const session = require('./cap/bin/lib/cap-session.cjs');
|
|
157
|
+
session.updateSession(process.cwd(), {
|
|
158
|
+
lastCommand: '/cap:annotate',
|
|
159
|
+
lastCommandTimestamp: new Date().toISOString(),
|
|
160
|
+
step: 'annotated'
|
|
161
|
+
});
|
|
162
|
+
"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
</process>
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:brainstorm
|
|
3
|
+
description: Interactive feature discovery — produces FEATURE-MAP.md entries (acceptance criteria, dependencies, feature grouping) from a structured conversation. TRIGGER when the user wants to plan a new feature, says "let's add X / build Y / we need a feature for Z", describes a problem without concrete ACs yet, references a Feature ID that doesn't exist in FEATURE-MAP.md, or asks "what should we build next". DO NOT trigger for refining an existing feature (use cap:iterate) or bug fixes (use cap:debug). Spawns cap-brainstormer agent.
|
|
4
|
+
argument-hint: "[--resume] [--multi]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Bash
|
|
10
|
+
- Task
|
|
11
|
+
- Glob
|
|
12
|
+
- Grep
|
|
13
|
+
- AskUserQuestion
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<!-- @cap-context CAP v2.0 brainstorm command -- orchestrates conversational feature discovery. Spawns cap-brainstormer agent, receives structured Feature Map entries, writes to FEATURE-MAP.md after user approval. -->
|
|
17
|
+
<!-- @cap-decision Writes directly to FEATURE-MAP.md (not PRD files). Feature Map is the single source of truth in CAP. PRDs are an intermediate artifact that CAP eliminates. -->
|
|
18
|
+
<!-- @cap-decision Command layer owns all file I/O -- agent is stateless. Proven pattern from GSD brainstorm.md. -->
|
|
19
|
+
<!-- @cap-constraint No Feature Map entries are written without explicit user approval -- confirmation gate is mandatory -->
|
|
20
|
+
|
|
21
|
+
<objective>
|
|
22
|
+
Spawns the `cap-brainstormer` agent to have a structured conversation about what needs to be built. The agent returns structured Feature Map entries. This command presents the entries for user confirmation, then writes to FEATURE-MAP.md.
|
|
23
|
+
|
|
24
|
+
<!-- @cap-todo(ref:AC-36) /cap:brainstorm shall invoke the cap-brainstormer agent for conversational feature discovery. -->
|
|
25
|
+
|
|
26
|
+
**Arguments:**
|
|
27
|
+
- `--resume` -- resume a previous brainstorm session using .cap/SESSION.json context
|
|
28
|
+
- `--multi` -- hint that the project has multiple independent feature areas
|
|
29
|
+
|
|
30
|
+
**Key guarantee:** No Feature Map entries are written until the user explicitly approves.
|
|
31
|
+
</objective>
|
|
32
|
+
|
|
33
|
+
<context>
|
|
34
|
+
$ARGUMENTS
|
|
35
|
+
|
|
36
|
+
@FEATURE-MAP.md
|
|
37
|
+
@.cap/SESSION.json
|
|
38
|
+
</context>
|
|
39
|
+
|
|
40
|
+
<process>
|
|
41
|
+
|
|
42
|
+
## Step 0: Parse flags
|
|
43
|
+
|
|
44
|
+
Check `$ARGUMENTS` for:
|
|
45
|
+
- `--resume` -- if present, set `resume_mode = true`
|
|
46
|
+
- `--multi` -- if present, set `multi_mode = true`
|
|
47
|
+
|
|
48
|
+
Log: "cap:brainstorm | resume: {resume_mode} | multi: {multi_mode}"
|
|
49
|
+
|
|
50
|
+
## Step 1: Load existing Feature Map and session state
|
|
51
|
+
|
|
52
|
+
Read FEATURE-MAP.md:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
node -e "
|
|
56
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
57
|
+
// @cap-todo(ac:F-081/AC-4 iter:2) Migrated to {safe: true} opt-in to preserve CLI on duplicate-ID FEATURE-MAP.
|
|
58
|
+
// @cap-decision(F-081/iter2) Warn on parseError; continue with partial map for read-only display.
|
|
59
|
+
const featureMap = fm.readFeatureMap(process.cwd(), undefined, { safe: true });
|
|
60
|
+
if (featureMap && featureMap.parseError) {
|
|
61
|
+
console.warn('cap: brainstorm — duplicate feature ID detected, existing-features list uses partial map: ' + String(featureMap.parseError.message).trim());
|
|
62
|
+
}
|
|
63
|
+
console.log(JSON.stringify({
|
|
64
|
+
featureCount: featureMap.features.length,
|
|
65
|
+
existingIds: featureMap.features.map(f => f.id),
|
|
66
|
+
existingTitles: featureMap.features.map(f => f.title)
|
|
67
|
+
}));
|
|
68
|
+
"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Store as `existing_features`.
|
|
72
|
+
|
|
73
|
+
If `resume_mode`:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
node -e "
|
|
77
|
+
const session = require('./cap/bin/lib/cap-session.cjs');
|
|
78
|
+
const s = session.loadSession(process.cwd());
|
|
79
|
+
console.log(JSON.stringify(s));
|
|
80
|
+
"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Store as `session_context`.
|
|
84
|
+
|
|
85
|
+
## Step 1b: Check for prior brainstorm threads
|
|
86
|
+
|
|
87
|
+
Check if the user's topic has been explored before. This gives the brainstormer context about prior discussions.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
node -e "
|
|
91
|
+
const tracker = require('./cap/bin/lib/cap-thread-tracker.cjs');
|
|
92
|
+
const threads = tracker.listThreads(process.cwd());
|
|
93
|
+
console.log(JSON.stringify({ threadCount: threads.length, threads: threads.slice(0, 10) }));
|
|
94
|
+
"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Store as `prior_threads`.
|
|
98
|
+
|
|
99
|
+
If `resume_mode` and `session_context.activeThread`:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
node -e "
|
|
103
|
+
const tracker = require('./cap/bin/lib/cap-thread-tracker.cjs');
|
|
104
|
+
const thread = tracker.loadThread(process.cwd(), '{session_context.activeThread}');
|
|
105
|
+
console.log(JSON.stringify(thread));
|
|
106
|
+
"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Store as `resume_thread`. This is the thread from the previous brainstorm session to continue.
|
|
110
|
+
|
|
111
|
+
If `prior_threads.threadCount > 0` and NOT `resume_mode`:
|
|
112
|
+
- Display prior threads briefly:
|
|
113
|
+
```
|
|
114
|
+
Found {threadCount} prior brainstorm thread(s):
|
|
115
|
+
{For each thread:}
|
|
116
|
+
- {thread.name} ({thread.timestamp}) — features: {thread.featureIds.join(', ') || 'none'}
|
|
117
|
+
{End for}
|
|
118
|
+
```
|
|
119
|
+
- The brainstormer agent will receive this context and can reference prior threads during conversation.
|
|
120
|
+
|
|
121
|
+
## Step 1c: Passively check thread affinity before brainstorm
|
|
122
|
+
|
|
123
|
+
<!-- @cap-todo(ac:F-040/AC-5) /cap:brainstorm passively checks thread affinity at session start and presents relevant prior threads (notify band and above) before beginning discovery questions -->
|
|
124
|
+
|
|
125
|
+
If prior threads exist, check realtime affinity to surface relevant ones:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
node -e "
|
|
129
|
+
const realtimeAffinity = require('./cap/bin/lib/cap-realtime-affinity.cjs');
|
|
130
|
+
const clusterDisplay = require('./cap/bin/lib/cap-cluster-display.cjs');
|
|
131
|
+
const tracker = require('./cap/bin/lib/cap-thread-tracker.cjs');
|
|
132
|
+
const session = require('./cap/bin/lib/cap-session.cjs');
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
const threads = tracker.listThreads(process.cwd());
|
|
136
|
+
if (threads.length > 0) {
|
|
137
|
+
const s = session.loadSession(process.cwd());
|
|
138
|
+
// Use the most recent thread as reference point for affinity detection
|
|
139
|
+
const latestThread = threads[0];
|
|
140
|
+
const fullThread = tracker.loadThread(process.cwd(), latestThread.id);
|
|
141
|
+
if (fullThread) {
|
|
142
|
+
const notifications = realtimeAffinity.onSessionStart(process.cwd(), fullThread);
|
|
143
|
+
const output = clusterDisplay.formatRealtimeNotifications(notifications);
|
|
144
|
+
if (output) console.log(output);
|
|
145
|
+
else console.log('');
|
|
146
|
+
} else {
|
|
147
|
+
console.log('');
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
console.log('');
|
|
151
|
+
}
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.log('');
|
|
154
|
+
}
|
|
155
|
+
"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
If output is non-empty, display it before spawning the brainstormer:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
{thread_affinity_output}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This gives the user awareness of related prior discussions before beginning a new brainstorm.
|
|
165
|
+
|
|
166
|
+
## Step 2: Spawn cap-brainstormer agent
|
|
167
|
+
|
|
168
|
+
<!-- @cap-todo(ref:AC-37) cap-brainstormer shall produce structured PRD output with numbered acceptance criteria. -->
|
|
169
|
+
<!-- @cap-todo(ref:AC-39) cap-brainstormer shall assign feature IDs in sequential format (F-001, F-002, ...). -->
|
|
170
|
+
|
|
171
|
+
Spawn `cap-brainstormer` via the Task tool with the following context:
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
$ARGUMENTS
|
|
175
|
+
|
|
176
|
+
**Session context:**
|
|
177
|
+
Resume mode: {resume_mode}
|
|
178
|
+
Multi-feature hint: {multi_mode}
|
|
179
|
+
Existing features: {existing_features.featureCount} features already in FEATURE-MAP.md
|
|
180
|
+
Existing IDs: {existing_features.existingIds}
|
|
181
|
+
Next available ID: F-{padded next number}
|
|
182
|
+
|
|
183
|
+
{If resume_mode and resume_thread:}
|
|
184
|
+
**Resuming prior thread:**
|
|
185
|
+
Thread ID: {resume_thread.id}
|
|
186
|
+
Thread name: {resume_thread.name}
|
|
187
|
+
Problem statement: {resume_thread.problemStatement}
|
|
188
|
+
Solution shape: {resume_thread.solutionShape}
|
|
189
|
+
Boundary decisions: {resume_thread.boundaryDecisions}
|
|
190
|
+
Prior feature IDs: {resume_thread.featureIds}
|
|
191
|
+
{End if}
|
|
192
|
+
|
|
193
|
+
{If prior_threads.threadCount > 0 and NOT resume_mode:}
|
|
194
|
+
**Prior brainstorm threads (for reference):**
|
|
195
|
+
{For each thread in prior_threads.threads:}
|
|
196
|
+
- {thread.name} ({thread.timestamp}) — keywords: {thread.keywords.slice(0,8).join(', ')} — features: {thread.featureIds.join(', ') || 'none'}
|
|
197
|
+
{End for}
|
|
198
|
+
NOTE: If the user's topic overlaps with a prior thread, reference it. Ask if they want to continue that line of thinking or explore something new.
|
|
199
|
+
{End if}
|
|
200
|
+
|
|
201
|
+
{If resume_mode and session_context and NOT resume_thread:}
|
|
202
|
+
**Previous session context (no thread found):**
|
|
203
|
+
Active feature: {session_context.activeFeature}
|
|
204
|
+
Last step: {session_context.step}
|
|
205
|
+
Last command: {session_context.lastCommand}
|
|
206
|
+
{End if}
|
|
207
|
+
|
|
208
|
+
**Instructions:**
|
|
209
|
+
1. Have a conversational exchange with the user to understand what needs to be built
|
|
210
|
+
2. Ask targeted questions ONE AT A TIME -- do not present a list of questions
|
|
211
|
+
3. After sufficient understanding, cluster features into logical groups
|
|
212
|
+
4. Surface dependencies between feature groups
|
|
213
|
+
5. For each feature, draft numbered acceptance criteria in imperative form
|
|
214
|
+
6. Assign feature IDs:
|
|
215
|
+
- For single-app projects: sequential `F-NNN` starting from {next available ID}
|
|
216
|
+
- For monorepo projects (apps/* or workspace packages > 1): prefer descriptive `F-<App>-<Slug>` IDs (e.g., `F-Hub-Spotlight-Carousel`). Detect monorepo: presence of `apps/` directory or `package.json:workspaces`. Both formats may coexist.
|
|
217
|
+
7. Return the feature entries in the exact structured format below
|
|
218
|
+
|
|
219
|
+
**Return format (delimited):**
|
|
220
|
+
|
|
221
|
+
=== BRAINSTORM OUTPUT ===
|
|
222
|
+
FEATURE_COUNT: N
|
|
223
|
+
|
|
224
|
+
=== FEATURE: F-NNN ===
|
|
225
|
+
TITLE: {verb+object title}
|
|
226
|
+
GROUP: {logical group name}
|
|
227
|
+
DEPENDS_ON: {comma-separated F-IDs or "none"}
|
|
228
|
+
AC-1: {imperative description}
|
|
229
|
+
AC-2: {imperative description}
|
|
230
|
+
...
|
|
231
|
+
=== END FEATURE ===
|
|
232
|
+
|
|
233
|
+
{Repeat for each feature}
|
|
234
|
+
|
|
235
|
+
=== DECISIONS ===
|
|
236
|
+
- {decision 1}
|
|
237
|
+
- {decision 2}
|
|
238
|
+
=== END DECISIONS ===
|
|
239
|
+
|
|
240
|
+
=== END BRAINSTORM OUTPUT ===
|
|
241
|
+
|
|
242
|
+
Do NOT write any files -- return structured output only.
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Wait for `cap-brainstormer` to complete.
|
|
246
|
+
|
|
247
|
+
**Parse the agent output:**
|
|
248
|
+
|
|
249
|
+
1. Extract between `=== BRAINSTORM OUTPUT ===` and `=== END BRAINSTORM OUTPUT ===`
|
|
250
|
+
2. Parse `FEATURE_COUNT:` line
|
|
251
|
+
3. For each `=== FEATURE: F-NNN ===` block, extract: TITLE, GROUP, DEPENDS_ON, and all AC-N lines
|
|
252
|
+
4. Extract decisions from `=== DECISIONS ===` block
|
|
253
|
+
5. Build Feature objects:
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
{
|
|
257
|
+
id: "F-NNN",
|
|
258
|
+
title: "extracted title",
|
|
259
|
+
state: "planned",
|
|
260
|
+
acs: [{ id: "AC-1", description: "...", status: "pending" }, ...],
|
|
261
|
+
files: [],
|
|
262
|
+
dependencies: ["F-NNN", ...],
|
|
263
|
+
metadata: { group: "group name" }
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Step 3: Present features for user approval
|
|
268
|
+
|
|
269
|
+
<!-- @cap-todo(ref:AC-38) cap-brainstormer shall write discovered features directly to FEATURE-MAP.md with state planned. -->
|
|
270
|
+
<!-- @cap-todo(ref:AC-40) cap-brainstormer output shall be directly consumable by /cap:prototype without manual translation. -->
|
|
271
|
+
|
|
272
|
+
Display the parsed features:
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
Brainstorm complete. {feature_count} features discovered:
|
|
276
|
+
|
|
277
|
+
{For each feature:}
|
|
278
|
+
{feature.id}: {feature.title} [{feature.state}]
|
|
279
|
+
Group: {group}
|
|
280
|
+
Dependencies: {deps or "none"}
|
|
281
|
+
Acceptance criteria:
|
|
282
|
+
AC-1: {description}
|
|
283
|
+
AC-2: {description}
|
|
284
|
+
...
|
|
285
|
+
{End for}
|
|
286
|
+
|
|
287
|
+
Decisions made:
|
|
288
|
+
{For each decision:}
|
|
289
|
+
- {decision}
|
|
290
|
+
{End for}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Use AskUserQuestion:
|
|
294
|
+
> "Review the {feature_count} features above. Approve writing to FEATURE-MAP.md? [yes / provide corrections / restart]"
|
|
295
|
+
|
|
296
|
+
- If `yes`, `y`, or `approve`: proceed to Step 4
|
|
297
|
+
- If corrections: Re-spawn `cap-brainstormer` with original context + `**Corrections from user:** {user text}`. Re-parse and re-display. Loop back to approval gate.
|
|
298
|
+
- If `restart`: Clear all parsed data. Go back to Step 2 with fresh Task() call.
|
|
299
|
+
|
|
300
|
+
**IMPORTANT:** No code path reaches Step 4 without explicit user approval.
|
|
301
|
+
|
|
302
|
+
## Step 4: Write approved features to FEATURE-MAP.md
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
node -e "
|
|
306
|
+
const fm = require('./cap/bin/lib/cap-feature-map.cjs');
|
|
307
|
+
// @cap-todo(ac:F-081/AC-4 iter:2) Migrated to {safe: true} opt-in to preserve CLI on duplicate-ID FEATURE-MAP.
|
|
308
|
+
// @cap-decision(F-081/iter2) Bail on parseError — do not persist partial enrichment (write-back path).
|
|
309
|
+
const featureMap = fm.readFeatureMap(process.cwd(), undefined, { safe: true });
|
|
310
|
+
if (featureMap && featureMap.parseError) {
|
|
311
|
+
console.error('cap: brainstorm write aborted — duplicate feature ID detected: ' + String(featureMap.parseError.message).trim());
|
|
312
|
+
process.exit(2);
|
|
313
|
+
}
|
|
314
|
+
const newFeatures = {JSON.stringify(parsed_features)};
|
|
315
|
+
const updated = fm.addFeatures(featureMap, newFeatures);
|
|
316
|
+
fm.writeFeatureMap(process.cwd(), updated);
|
|
317
|
+
console.log('Written ' + newFeatures.length + ' features to FEATURE-MAP.md');
|
|
318
|
+
"
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Step 5: Persist brainstorm thread
|
|
322
|
+
|
|
323
|
+
Save this brainstorm session as a conversation thread. This enables future sessions to reference prior discussions.
|
|
324
|
+
|
|
325
|
+
Build the thread from the brainstorm results:
|
|
326
|
+
- `problemStatement`: The user's initial problem or topic (from the conversation)
|
|
327
|
+
- `solutionShape`: The high-level approach that emerged
|
|
328
|
+
- `boundaryDecisions`: Key scope decisions from the `=== DECISIONS ===` block
|
|
329
|
+
- `featureIds`: The IDs of features written to the Feature Map
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
node -e "
|
|
333
|
+
const tracker = require('./cap/bin/lib/cap-thread-tracker.cjs');
|
|
334
|
+
const resumeThreadId = '{resume_thread?.id || null}';
|
|
335
|
+
const parentThread = resumeThreadId !== 'null' ? tracker.loadThread(process.cwd(), resumeThreadId) : null;
|
|
336
|
+
|
|
337
|
+
const threadParams = {
|
|
338
|
+
problemStatement: '{problem_statement from conversation}',
|
|
339
|
+
solutionShape: '{solution_shape from conversation}',
|
|
340
|
+
boundaryDecisions: {JSON.stringify(decisions_from_brainstorm)},
|
|
341
|
+
featureIds: {JSON.stringify(feature_ids_written)},
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
let thread;
|
|
345
|
+
if (parentThread) {
|
|
346
|
+
// Branching from resumed thread
|
|
347
|
+
thread = tracker.branchThread(parentThread, {
|
|
348
|
+
...threadParams,
|
|
349
|
+
divergencePoint: 'Continued from prior session'
|
|
350
|
+
});
|
|
351
|
+
} else {
|
|
352
|
+
thread = tracker.createThread(threadParams);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
tracker.persistThread(process.cwd(), thread);
|
|
356
|
+
console.log(JSON.stringify({ threadId: thread.id, threadName: thread.name }));
|
|
357
|
+
"
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Store as `persisted_thread`.
|
|
361
|
+
|
|
362
|
+
## Step 5b: Update session state
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
node -e "
|
|
366
|
+
const session = require('./cap/bin/lib/cap-session.cjs');
|
|
367
|
+
session.updateSession(process.cwd(), {
|
|
368
|
+
lastCommand: '/cap:brainstorm',
|
|
369
|
+
lastCommandTimestamp: new Date().toISOString(),
|
|
370
|
+
step: 'brainstorm-complete',
|
|
371
|
+
activeThread: '{persisted_thread.threadId}'
|
|
372
|
+
});
|
|
373
|
+
"
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Step 6: Final report
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
cap:brainstorm complete.
|
|
380
|
+
|
|
381
|
+
Features written to FEATURE-MAP.md: {feature_count}
|
|
382
|
+
{For each feature: feature.id: feature.title}
|
|
383
|
+
|
|
384
|
+
Decisions recorded: {decision_count}
|
|
385
|
+
Thread saved: {persisted_thread.threadName} ({persisted_thread.threadId})
|
|
386
|
+
|
|
387
|
+
Next steps:
|
|
388
|
+
- Run /cap:start to select a feature to work on
|
|
389
|
+
- Run /cap:prototype --features {first_feature_id} to build initial code
|
|
390
|
+
- Run /cap:brainstorm --resume to continue this thread later
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
</process>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:checkpoint
|
|
3
|
+
description: Advisory checkpoint detection — nudges /compact at natural breakpoints, saves a labeled snapshot via cap-historian before the context fills up.
|
|
4
|
+
argument-hint: ""
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Task
|
|
7
|
+
- Bash
|
|
8
|
+
- Read
|
|
9
|
+
- Write
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<!-- @cap-feature(feature:F-057) Checkpoint Command for Strategic Compact -->
|
|
13
|
+
<!-- @cap-todo(ac:F-057/AC-1) /cap:checkpoint ist aufrufbar — this file registers the slash command. -->
|
|
14
|
+
<!-- @cap-todo(ac:F-057/AC-2) Command prueft SESSION.json (step-Transitions, AC-Status-Updates) und FEATURE-MAP-Diff seit letzter Checkpoint-Zeit auf logische Breakpoints. Delegated to cap-checkpoint.analyzeAndApply(). -->
|
|
15
|
+
<!-- @cap-todo(ac:F-057/AC-3) Bei erkanntem Breakpoint gibt Command Empfehlung aus: "Jetzt /compact, weil {konkreter Grund}". -->
|
|
16
|
+
<!-- @cap-todo(ac:F-057/AC-4) Bei erkanntem Breakpoint wird vor der Empfehlung implizit ein Snapshot mit Label `checkpoint-{feature_id}` angelegt. -->
|
|
17
|
+
<!-- @cap-decision Breakpoint-Heuristik bleibt in cap-checkpoint.cjs (analyzeAndApply). Die Save-Aktion wurde von "/cap:save chained" auf "Task() → cap-historian MODE: SAVE" umgestellt — gleiches Outcome (Snapshot in .cap/snapshots/), zusätzlich JSONL-Index-Eintrag. -->
|
|
18
|
+
<!-- @cap-todo(ac:F-057/AC-6) /cap:checkpoint bleibt advisory: KEIN Auto-/compact, KEIN --force-Flag. User entscheidet. -->
|
|
19
|
+
<!-- @cap-todo(ac:F-057/AC-5) Kein Breakpoint erkannt -> Message "Kein natürlicher Kontextbruch erkannt.", keine weitere Action. -->
|
|
20
|
+
|
|
21
|
+
<objective>
|
|
22
|
+
Detect natural breakpoints in the CAP workflow and nudge the user toward `/compact` before auto-compact degrades context quality. When a breakpoint is detected, the command first writes a `checkpoint-{feature_id}` snapshot via the cap-historian agent.
|
|
23
|
+
|
|
24
|
+
**Purely advisory.** Never runs `/compact` itself. No `--force` flag. The user decides.
|
|
25
|
+
</objective>
|
|
26
|
+
|
|
27
|
+
<process>
|
|
28
|
+
|
|
29
|
+
## Step 1: Analyze and persist breakpoint state
|
|
30
|
+
|
|
31
|
+
`analyzeAndApply` reads SESSION.json and FEATURE-MAP.md, computes the plan, and — if a breakpoint was detected — persists `lastCheckpointAt` + `lastCheckpointSnapshot` in a single Node call (closes the TOCTOU window).
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
node -e "
|
|
35
|
+
const capCheckpoint = require('./cap/bin/lib/cap-checkpoint.cjs');
|
|
36
|
+
const result = capCheckpoint.analyzeAndApply(process.cwd());
|
|
37
|
+
console.log(JSON.stringify(result, null, 2));
|
|
38
|
+
"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Output shape:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
{
|
|
45
|
+
"breakpoint": { "kind": "...", "featureId": "F-057", "reason": "..." } | null,
|
|
46
|
+
"plan": {
|
|
47
|
+
"shouldSave": true | false,
|
|
48
|
+
"saveLabel": "checkpoint-F-057" | null,
|
|
49
|
+
"message": "Jetzt /compact, weil ..." | "Kein natürlicher Kontextbruch erkannt."
|
|
50
|
+
},
|
|
51
|
+
"currentSnapshot": { "featureStates": {...}, "acStatuses": {...} },
|
|
52
|
+
"persisted": true | false
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Step 2: Branch on breakpoint
|
|
57
|
+
|
|
58
|
+
**If `plan.breakpoint` is null:**
|
|
59
|
+
|
|
60
|
+
Print verbatim and stop:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Kein natürlicher Kontextbruch erkannt.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
(AC-5)
|
|
67
|
+
|
|
68
|
+
**If `plan.breakpoint` is non-null:** continue. Checkpoint state is already persisted (AC-4).
|
|
69
|
+
|
|
70
|
+
## Step 3: Save snapshot via cap-historian
|
|
71
|
+
|
|
72
|
+
Spawn `cap-historian` in SAVE mode with `plan.saveLabel` as the snapshot name:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
**MODE: SAVE**
|
|
76
|
+
|
|
77
|
+
{plan.saveLabel}
|
|
78
|
+
|
|
79
|
+
Save the current session as a checkpoint snapshot. Use the active feature for
|
|
80
|
+
linkage (default behavior — no --unassigned, no --platform). Reuse
|
|
81
|
+
cap-snapshot-linkage.cjs and cap-session-extract.cjs.
|
|
82
|
+
|
|
83
|
+
Return `=== HISTORIAN SAVE RESULTS ===` verbatim.
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Wait for cap-historian to complete.
|
|
87
|
+
|
|
88
|
+
## Step 4: Print recommendation
|
|
89
|
+
|
|
90
|
+
Print `plan.message` verbatim:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
Jetzt /compact, weil {konkreter Grund}.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Step 5: Advisory boundary
|
|
97
|
+
|
|
98
|
+
Do NOT invoke `/compact`. The only side effects of this command are:
|
|
99
|
+
|
|
100
|
+
1. The checkpoint snapshot written by cap-historian (Step 3).
|
|
101
|
+
2. `lastCheckpointAt` + `lastCheckpointSnapshot` updated in SESSION.json (Step 1).
|
|
102
|
+
3. The recommendation printed to the user (Step 4).
|
|
103
|
+
|
|
104
|
+
If the user wants to compact, they run `/compact` themselves.
|
|
105
|
+
|
|
106
|
+
</process>
|