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,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:memory
|
|
3
|
+
description: "Manage project memory — bootstrap, run pipeline, pin/unpin annotations, view status, migrate to V6."
|
|
4
|
+
argument-hint: "[init|status|pin|unpin|prune|migrate] [--dry-run|--apply]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<!-- @cap-feature(feature:F-030) Memory command — bootstrap, manual trigger, pin/unpin/status management -->
|
|
14
|
+
<!-- @cap-decision /cap:memory init processes ALL sessions for the current project — one-time bootstrap to build initial memory. -->
|
|
15
|
+
<!-- @cap-decision /cap:memory with no args runs incremental only (sessions since last run). -->
|
|
16
|
+
|
|
17
|
+
<objective>
|
|
18
|
+
Manage project memory — bootstrap from existing sessions, run incremental pipeline, or manage annotations.
|
|
19
|
+
|
|
20
|
+
**Subcommands:**
|
|
21
|
+
- `init` — **Bootstrap**: process ALL sessions for this project, build initial memory (run once per project)
|
|
22
|
+
- `(no args)` — run incremental pipeline (only sessions since last run)
|
|
23
|
+
- `status` — show memory summary (annotation counts, stale, pinned, last run)
|
|
24
|
+
- `pin <file> <content-prefix>` — mark a @cap-pitfall as pinned:true
|
|
25
|
+
- `unpin <file> <content-prefix>` — remove pinned:true from annotation
|
|
26
|
+
- `prune [--apply]` — decay stale entries, archive very-stale low-confidence ones, purge old raw-logs (default dry-run)
|
|
27
|
+
- `migrate [--apply] [--interactive=false]` — **F-077**: one-shot migration from V5 monolith files (`decisions.md`, `pitfalls.md`, etc.) to V6 per-feature layout under `.cap/memory/features/`. Default is dry-run; `--apply` requires a confirm prompt unless `--interactive=false` is passed.
|
|
28
|
+
- `--switch-layout=v6` — **F-095**: lightweight V5→V6 layout activation. Reads existing V5 entries, persists `.cap/config.json: { memory: { layout: 'v6' } }`, triggers one `writeMemoryDirectory` call so the V6 dispatch produces per-feature/platform files + Index. No session reprocess. Idempotent (V6→V6 no-op).
|
|
29
|
+
- `--dry-run` — show what would change without writing
|
|
30
|
+
</objective>
|
|
31
|
+
|
|
32
|
+
<process>
|
|
33
|
+
|
|
34
|
+
## Subcommand: init (Bootstrap)
|
|
35
|
+
|
|
36
|
+
One-time full processing of all sessions for this project. Run this when setting up memory for an existing project.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
node "$HOME/.claude/hooks/cap-memory.js" init
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This will:
|
|
43
|
+
1. Find all session JSONL files for the current project directory
|
|
44
|
+
2. Parse every session — extract decisions, pitfalls, patterns, file edit history
|
|
45
|
+
3. Write @cap-history, @cap-pitfall, @cap-pattern annotations into source files
|
|
46
|
+
4. Generate .cap/memory/ directory (decisions.md, hotspots.md, patterns.md, pitfalls.md)
|
|
47
|
+
5. Save timestamp to .cap/memory/.last-run (future hook runs are incremental from here)
|
|
48
|
+
|
|
49
|
+
Display the output to the user. Then show:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
Bootstrap complete.
|
|
53
|
+
|
|
54
|
+
Memory directory: .cap/memory/
|
|
55
|
+
- decisions.md
|
|
56
|
+
- hotspots.md
|
|
57
|
+
- patterns.md
|
|
58
|
+
- pitfalls.md
|
|
59
|
+
|
|
60
|
+
From now on, the Stop hook will run incrementally after each session.
|
|
61
|
+
Run /cap:memory status to see what was accumulated.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Default (no args): Run incremental pipeline
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
node "$HOME/.claude/hooks/cap-memory.js"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Only processes sessions newer than .cap/memory/.last-run timestamp.
|
|
71
|
+
If .last-run doesn't exist, processes all sessions (same as init).
|
|
72
|
+
|
|
73
|
+
<!-- @cap-decision(F-079/iter1) Stage-2 #1 fix: processSnapshots wired into memory-pipeline. -->
|
|
74
|
+
The pipeline also walks `.cap/snapshots/` and updates the `linked_snapshots` auto-block in every
|
|
75
|
+
per-feature / platform memory file the snapshots route to (F-079/AC-4). Re-running the pipeline
|
|
76
|
+
on the same set of snapshots is byte-identical (idempotent contract pinned by F-079 tests).
|
|
77
|
+
|
|
78
|
+
## Subcommand: status
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
node -e "
|
|
82
|
+
const fs = require('node:fs');
|
|
83
|
+
const path = require('node:path');
|
|
84
|
+
const memDir = path.join(process.cwd(), '.cap', 'memory');
|
|
85
|
+
const lastRunPath = path.join(memDir, '.last-run');
|
|
86
|
+
const lastRun = fs.existsSync(lastRunPath) ? fs.readFileSync(lastRunPath, 'utf8').trim() : 'never';
|
|
87
|
+
const categories = ['decisions.md', 'hotspots.md', 'patterns.md', 'pitfalls.md'];
|
|
88
|
+
const stats = { lastRun };
|
|
89
|
+
for (const f of categories) {
|
|
90
|
+
const fp = path.join(memDir, f);
|
|
91
|
+
if (fs.existsSync(fp)) {
|
|
92
|
+
const content = fs.readFileSync(fp, 'utf8');
|
|
93
|
+
const entries = (content.match(/^###/gm) || []).length;
|
|
94
|
+
const pinned = (content.match(/\[pinned\]/g) || []).length;
|
|
95
|
+
const tableRows = (content.match(/^\| \d/gm) || []).length;
|
|
96
|
+
stats[f] = { entries: entries + tableRows, pinned };
|
|
97
|
+
} else {
|
|
98
|
+
stats[f] = { entries: 0, pinned: 0 };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
102
|
+
"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Display as summary table:
|
|
106
|
+
```
|
|
107
|
+
Project Memory Status
|
|
108
|
+
Last run: {timestamp or "never — run /cap:memory init to bootstrap"}
|
|
109
|
+
decisions.md: {N} entries ({P} pinned)
|
|
110
|
+
hotspots.md: {N} entries
|
|
111
|
+
patterns.md: {N} entries
|
|
112
|
+
pitfalls.md: {N} entries ({P} pinned)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Subcommand: pin `<file>` `<content-prefix>`
|
|
116
|
+
|
|
117
|
+
<!-- @cap-todo(ac:F-030/AC-4) /cap:memory pin adds pinned:true to the matching @cap-pitfall annotation. -->
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
node -e "
|
|
121
|
+
const pin = require('./cap/bin/lib/cap-memory-pin.cjs');
|
|
122
|
+
const file = process.argv[1];
|
|
123
|
+
const prefix = process.argv[2];
|
|
124
|
+
const result = pin.pin(file, prefix);
|
|
125
|
+
console.log(pin.formatResult(result));
|
|
126
|
+
process.exit(result.changed || result.status === 'already-pinned' ? 0 : 1);
|
|
127
|
+
" '<FILE>' '<PREFIX>'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Argument usage:
|
|
131
|
+
|
|
132
|
+
- `<file>` — path to the source file that carries the `@cap-pitfall` annotation (absolute or relative to the project root).
|
|
133
|
+
- `<content-prefix>` — a prefix of the pitfall description (case-sensitive). Use enough to disambiguate if multiple pitfalls live in the same file.
|
|
134
|
+
|
|
135
|
+
On `ambiguous` status the command prints the candidate descriptions; rerun with a longer prefix to select one.
|
|
136
|
+
|
|
137
|
+
## Subcommand: unpin `<file>` `<content-prefix>`
|
|
138
|
+
|
|
139
|
+
<!-- @cap-todo(ac:F-030/AC-5) /cap:memory unpin removes pinned:true from the matching annotation. -->
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
node -e "
|
|
143
|
+
const pin = require('./cap/bin/lib/cap-memory-pin.cjs');
|
|
144
|
+
const file = process.argv[1];
|
|
145
|
+
const prefix = process.argv[2];
|
|
146
|
+
const result = pin.unpin(file, prefix);
|
|
147
|
+
console.log(pin.formatResult(result));
|
|
148
|
+
process.exit(result.changed || result.status === 'not-pinned' ? 0 : 1);
|
|
149
|
+
" '<FILE>' '<PREFIX>'
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Same argument semantics as `pin`. An already-unpinned annotation exits 0 with a no-op message.
|
|
153
|
+
|
|
154
|
+
## Subcommand: prune `[--apply] [--gitignored]`
|
|
155
|
+
|
|
156
|
+
<!-- @cap-todo(ac:F-056/AC-1) /cap:memory prune is the F-056 subcommand for decay + archive + raw-log purge. -->
|
|
157
|
+
<!-- @cap-todo(ac:F-056/AC-2) Default is dry-run; --apply is required to mutate files. -->
|
|
158
|
+
<!-- @cap-todo(ac:F-056/AC-6) Prune emits a human report and appends .cap/memory/prune-log.jsonl. -->
|
|
159
|
+
<!-- @cap-todo(ac:F-086/AC-3) --gitignored mode runs the scope-filter pass (gitignored entries + bundle-paths). -->
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
node -e "
|
|
163
|
+
const prune = require('./cap/bin/lib/cap-memory-prune.cjs');
|
|
164
|
+
const args = process.argv.slice(1);
|
|
165
|
+
const applyFlag = args.includes('--apply');
|
|
166
|
+
const gitignoredMode = args.includes('--gitignored');
|
|
167
|
+
if (gitignoredMode) {
|
|
168
|
+
const result = prune.pruneGitignored(process.cwd(), { apply: applyFlag });
|
|
169
|
+
console.log(prune.formatGitignoredReport(result));
|
|
170
|
+
process.exit(result.errors && result.errors.length > 0 ? 1 : 0);
|
|
171
|
+
} else {
|
|
172
|
+
const result = prune.prune(process.cwd(), { apply: applyFlag });
|
|
173
|
+
console.log(prune.formatReport(result));
|
|
174
|
+
process.exit(result.errors && result.errors.length > 0 ? 1 : 0);
|
|
175
|
+
}
|
|
176
|
+
" -- {ARGS}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
What prune does (default mode):
|
|
180
|
+
|
|
181
|
+
- **Decay** (AC-3): entries with `last_seen > 90 days` lose `-0.05` confidence per additional 30 days of inactivity, floored at `0.0`. Pinned entries are never decayed.
|
|
182
|
+
- **Archive** (AC-4): entries with `confidence < 0.2` AND `last_seen > 180 days` move to `.cap/memory/archive/{YYYY-MM}.md` (the archival month, not the entry's own month). Decay runs first — an entry can cross the threshold via decay and get archived in the same run. Pinned entries are never archived.
|
|
183
|
+
- **Purge** (AC-5): raw event logs under `.cap/memory/raw/tag-events-YYYY-MM-DD.jsonl` older than 30 days are hard-deleted.
|
|
184
|
+
- **Report + log** (AC-6): a console report is emitted. On `--apply`, a single JSONL line `{timestamp, dryRun, decayed, archived, purged}` is appended to `.cap/memory/prune-log.jsonl`.
|
|
185
|
+
|
|
186
|
+
What `--gitignored` does (F-086/AC-3):
|
|
187
|
+
|
|
188
|
+
- Runs the **shared scope filter** (`cap-scope-filter.cjs`) against each existing memory entry's referenced files.
|
|
189
|
+
- Removes V5 entries (`decisions.md` / `pitfalls.md` / `patterns.md` / `hotspots.md`) whose ALL related files are now out-of-scope (gitignored, plugin-mirror, build-output bundle).
|
|
190
|
+
- Removes V6 bullet lines (`features/*.md`, `platform/*.md`) whose backtick-wrapped path would be excluded.
|
|
191
|
+
- Useful for projects bootstrapped on a pre-F-085 CAP version that accumulated build-output decisions and bundle-artefact references.
|
|
192
|
+
|
|
193
|
+
Default behaviour is **dry-run** — no files are touched and no prune-log entry is written. Pass `--apply` explicitly to commit the changes. The two modes (`--gitignored` and the default decay/archive flow) cannot be combined; pick one per run.
|
|
194
|
+
|
|
195
|
+
## Subcommand: migrate `[--apply] [--interactive=false]`
|
|
196
|
+
|
|
197
|
+
<!-- @cap-feature(feature:F-077) /cap:memory migrate — V6 per-feature memory migration entry point. -->
|
|
198
|
+
<!-- @cap-todo(ac:F-077/AC-4) Default is dry-run; --apply requires explicit confirm in interactive mode. -->
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
node -e "
|
|
202
|
+
const m = require('./cap/bin/lib/cap-memory-migrate.cjs');
|
|
203
|
+
const args = process.argv.slice(1);
|
|
204
|
+
const apply = args.includes('--apply');
|
|
205
|
+
const interactive = !args.includes('--interactive=false');
|
|
206
|
+
m.migrateMemory(process.cwd(), { apply, interactive }).then(r => {
|
|
207
|
+
if (r.report) {
|
|
208
|
+
console.log('Migration report written to .cap/memory/.archive/');
|
|
209
|
+
console.log(' Total entries:', r.report.counts.total);
|
|
210
|
+
console.log(' Assigned: ', r.report.counts.assigned);
|
|
211
|
+
console.log(' Platform: ', r.report.counts.platform);
|
|
212
|
+
console.log(' Skipped: ', r.report.counts.skipped);
|
|
213
|
+
}
|
|
214
|
+
process.exit(r.exitCode);
|
|
215
|
+
}).catch(e => { console.error('migrate failed:', e.message); process.exit(1); });
|
|
216
|
+
" -- {ARGS}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
What migrate does (one-shot V5 -> V6):
|
|
220
|
+
|
|
221
|
+
1. **Parses** `decisions.md`, `pitfalls.md`, `patterns.md`, `hotspots.md` and (for hotspots fallback) `graph.json`.
|
|
222
|
+
2. **Backs up** the V5 files to `.cap/memory/.archive/<name>-pre-v6-<YYYY-MM-DD>.<ext>` (idempotent on same date).
|
|
223
|
+
3. **Classifies** each entry by priority: tag-metadata (`@cap-decision(feature:F-NNN)`) -> `key_files` path-match -> F-NNN body mention. Confidence >= 0.7 auto-routes; lower = ambiguous.
|
|
224
|
+
4. **Routes** snapshots from `.cap/snapshots/` by frontmatter `feature:` field, then date proximity to FEATURE-MAP transitions, then title keyword.
|
|
225
|
+
5. **Prompts interactively** for ambiguous entries (top-3 candidates + skip + auto-all + quit) when `--apply` is set with default `--interactive=true`.
|
|
226
|
+
6. **Atomically writes** V6 files under `.cap/memory/features/F-NNN-<topic>.md` and `.cap/memory/platform/<topic>.md` (write-temp-then-rename, F-074 pattern).
|
|
227
|
+
7. **Writes a migration report** at `.cap/memory/.archive/migration-report-<YYYY-MM-DD>.md` summarising counts and ambiguity resolutions.
|
|
228
|
+
|
|
229
|
+
Default is **dry-run** -- no files touched. The dry-run output is sent to stderr and lists the planned writes, backup status, and ambiguity counts. Pass `--apply` to execute. Add `--interactive=false` to skip the confirm prompt and auto-resolve every ambiguity to its highest-confidence candidate (CI-friendly).
|
|
230
|
+
|
|
231
|
+
Exit codes: `0` success, `1` errors during apply, `2` user-initiated quit (declined confirm or `q` in ambiguity prompt).
|
|
232
|
+
|
|
233
|
+
After a successful migration, the user commits `.cap/memory/features/`, `.cap/memory/platform/`, and `.cap/memory/.archive/` to git themselves -- the tool deliberately does NOT touch git.
|
|
234
|
+
|
|
235
|
+
## Subcommand: --switch-layout=v6
|
|
236
|
+
|
|
237
|
+
<!-- @cap-feature(feature:F-095) /cap:memory --switch-layout=v6 — lightweight V5→V6 activation. -->
|
|
238
|
+
<!-- @cap-decision(F-095) write-then-rollback statt config-first: writeMemoryDirectory wird zuerst aufgerufen, config.json erst nach success persistiert. Bei error bleiben V5-Files + alte config unverändert. -->
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
node -e "
|
|
242
|
+
const dir = require('./cap/bin/lib/cap-memory-dir.cjs');
|
|
243
|
+
try {
|
|
244
|
+
const r = dir.switchLayout(process.cwd(), 'v6');
|
|
245
|
+
if (r.status === 'noop') {
|
|
246
|
+
console.log('cap-memory: layout already v6 — no changes.');
|
|
247
|
+
} else {
|
|
248
|
+
console.log('cap-memory: switched to v6 layout');
|
|
249
|
+
console.log(' source entries: ', r.sourceEntries);
|
|
250
|
+
console.log(' files written: ', r.written);
|
|
251
|
+
console.log(' config persisted: ', r.configPath);
|
|
252
|
+
console.log(' V5 backups present:', r.archives.length);
|
|
253
|
+
}
|
|
254
|
+
} catch (e) {
|
|
255
|
+
console.error('switch-layout failed:', e.message);
|
|
256
|
+
console.error('config.json not modified, V5 files unchanged.');
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
"
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
What --switch-layout=v6 does:
|
|
263
|
+
|
|
264
|
+
1. **Reads** existing V5 entries from `decisions.md` and `pitfalls.md` via `readMemoryFile()`.
|
|
265
|
+
2. **Calls** `writeMemoryDirectory(projectRoot, entries, { layout: 'v6' })` — V6 dispatch creates `features/F-XXX-<topic>.md`, `platform/<topic>.md`, top-level Index files, and archives V5 monoliths to `.cap/memory/.archive/`.
|
|
266
|
+
3. **Persists** `.cap/config.json: { memory: { layout: 'v6' } }` — only after step 2 succeeds. Existing keys in config.json are preserved.
|
|
267
|
+
4. **Reports** source-entry count, files-written count, config-path, archive-paths.
|
|
268
|
+
|
|
269
|
+
**Idempotency:** If `decisions.md` already has the `(V6 Index)` marker, the call is a no-op (`status: 'noop'`).
|
|
270
|
+
|
|
271
|
+
**Difference vs. `migrate`:** `migrate` is a one-shot **deep migration** (interactive disambiguation prompts, classification reports, snapshot routing, prompt-for-ambiguous). `--switch-layout=v6` is the **lightweight activation step** for projects that already migrated (or are happy with auto-classification). No session reprocess, <1s on typical project size.
|
|
272
|
+
|
|
273
|
+
**Use when:** You have a Bestandsprojekt with V5 monolithic memory, want V6 token-cost-of-read benefits, and don't need the deep migration ceremony. Or after `/cap:memory migrate --apply` if the writeMemoryDirectory dispatch never triggered (e.g. Stop-Hook returns early without new sessions).
|
|
274
|
+
|
|
275
|
+
</process>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:migrate-feature-map
|
|
3
|
+
description: "Shard a monolithic FEATURE-MAP.md into Index + per-feature files (F-089). Spawns cap-migrator (MODE: FEATURE-MAP)."
|
|
4
|
+
argument-hint: "[--apply] [--app=<path>] [--force]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Task
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<!-- @cap-feature(feature:F-089, primary:true) /cap:migrate-feature-map — thin wrapper around cap-migrator (MODE: FEATURE-MAP). -->
|
|
13
|
+
<!-- @cap-decision Wrapper pattern. Byte-lossless extraction (raw bytes, no parse → serialize) and atomic backup + rollback live in cap-migrator. -->
|
|
14
|
+
<!-- @cap-decision Argument compat: --apply, --app=<path>, --force preserved. Dry-run remains the default. -->
|
|
15
|
+
|
|
16
|
+
<objective>
|
|
17
|
+
Shard the monolithic `FEATURE-MAP.md` into the F-089 layout:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
FEATURE-MAP.md ← index file (one line per feature)
|
|
21
|
+
features/F-001.md ← full feature block
|
|
22
|
+
features/F-002.md
|
|
23
|
+
features/F-Hub-Spotlight.md
|
|
24
|
+
...
|
|
25
|
+
FEATURE-MAP.md.backup-pre-F-089 ← byte-identical backup of the original
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Why:** A FEATURE-MAP that grew to 4,000+ lines costs 30–50k tokens for every agent read. Sharded mode makes agents load just the index (~100 chars per feature) plus the active feature's per-feature file — typically a 10–50× token reduction on large projects.
|
|
29
|
+
|
|
30
|
+
The migration is **byte-lossless** for feature blocks (raw extraction). Once migrated, all CAP commands continue to work via the read/write dispatchers — no agent prompts need to change.
|
|
31
|
+
|
|
32
|
+
**Flags (backwards-compatible):**
|
|
33
|
+
- `--apply` — write the migration to disk. Without it, dry-run only.
|
|
34
|
+
- `--app=<path>` — operate on a sub-app's `FEATURE-MAP.md` instead of the root (e.g. `--app=apps/hub`).
|
|
35
|
+
- `--force` — proceed even when the planner flagged duplicate IDs or other issues. NOT recommended for duplicates.
|
|
36
|
+
|
|
37
|
+
**Idempotency:** Re-running on an already-sharded project is a no-op. Backwards-compat: projects without `features/` continue to work in monolithic mode.
|
|
38
|
+
</objective>
|
|
39
|
+
|
|
40
|
+
<context>
|
|
41
|
+
$ARGUMENTS
|
|
42
|
+
</context>
|
|
43
|
+
|
|
44
|
+
<process>
|
|
45
|
+
|
|
46
|
+
## Step 1: Parse flags
|
|
47
|
+
|
|
48
|
+
From `$ARGUMENTS`:
|
|
49
|
+
- `apply = $ARGUMENTS contains "--apply"`
|
|
50
|
+
- `app_path = value after --app=` (or null)
|
|
51
|
+
- `force = $ARGUMENTS contains "--force"`
|
|
52
|
+
|
|
53
|
+
## Step 2: Spawn cap-migrator (MODE: FEATURE-MAP)
|
|
54
|
+
|
|
55
|
+
Use the Task tool to spawn `cap-migrator`. Forward `$ARGUMENTS` verbatim.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
**MODE: FEATURE-MAP**
|
|
59
|
+
|
|
60
|
+
$ARGUMENTS
|
|
61
|
+
|
|
62
|
+
**Flags resolved by /cap:migrate-feature-map:**
|
|
63
|
+
- apply: {apply}
|
|
64
|
+
- app_path: {app_path or root}
|
|
65
|
+
- force: {force}
|
|
66
|
+
|
|
67
|
+
**Pipeline obligations (MODE: FEATURE-MAP):**
|
|
68
|
+
1. Plan via `cap-feature-map-migrate.cjs::planMigration(projectRoot, app_path)`.
|
|
69
|
+
2. Render verbatim using `formatPlan`. Source-mode handling:
|
|
70
|
+
- `missing` — abort, nothing to migrate.
|
|
71
|
+
- `sharded` — already done; emit `=== PLAN-ONLY ===` and exit.
|
|
72
|
+
- `monolithic` — proceed.
|
|
73
|
+
- `monolithic` with skips (duplicate IDs etc.) — surface skips, ask user to resolve OR pass --force to proceed without those features.
|
|
74
|
+
3. If --apply: AskUserQuestion → "Migrate FEATURE-MAP.md to sharded layout? Will write N per-feature files + backup + new index. (yes/no)" — skip the prompt only if --apply was passed AND the plan has zero skips.
|
|
75
|
+
4. On apply success, stage + verify + promote per the shared pipeline. Verify obligations:
|
|
76
|
+
- `readFeatureMap()` loads the same feature count as the planner.
|
|
77
|
+
- Every feature ID in the index has a matching `features/F-<id>.md`.
|
|
78
|
+
- The `FEATURE-MAP.md.backup-pre-F-089` matches the original by byte-length and sha256.
|
|
79
|
+
|
|
80
|
+
**Output contract:** preserve `formatPlan` output verbatim, then append the `=== MIGRATION RESULTS ===` block.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Step 3: Post-apply guidance
|
|
84
|
+
|
|
85
|
+
After a successful apply, point the user to the next step:
|
|
86
|
+
|
|
87
|
+
- "Sharded layout active. Index file: `FEATURE-MAP.md`. Per-feature files: `features/F-*.md`. Backup: `FEATURE-MAP.md.backup-pre-F-089`."
|
|
88
|
+
- "All CAP commands (`/cap:scan`, `/cap:reconcile`, `/cap:status`, etc.) continue to work transparently."
|
|
89
|
+
- "If anything looks wrong, restore via the migrator backup at `.cap/migrations/<tx_id>/backup/` or via: `cp FEATURE-MAP.md.backup-pre-F-089 FEATURE-MAP.md && rm -rf features/`"
|
|
90
|
+
|
|
91
|
+
</process>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:migrate-memory
|
|
3
|
+
description: "Migrate V5 monolithic project memory (.cap/memory/{decisions,pitfalls,patterns,hotspots}.md) to V6 per-feature layout (F-077). Spawns cap-migrator (MODE: MEMORY)."
|
|
4
|
+
argument-hint: "[--apply] [--interactive=false] [--allow-large-diff]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Task
|
|
10
|
+
- AskUserQuestion
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<!-- @cap-feature(feature:F-077, primary:true) /cap:migrate-memory — thin wrapper around cap-migrator (MODE: MEMORY). -->
|
|
14
|
+
<!-- @cap-decision New top-level command (sibling to /cap:migrate-tags and /cap:migrate-feature-map). The legacy `/cap:memory migrate` subcommand remains as an alias for backwards compatibility — both ultimately route through cap-migrator (MODE: MEMORY). -->
|
|
15
|
+
<!-- @cap-decision Argument compat: --apply and --interactive=false mirror the existing /cap:memory migrate flags. --allow-large-diff is added for parity with the other migrators. -->
|
|
16
|
+
|
|
17
|
+
<objective>
|
|
18
|
+
Migrate V5 monolithic project memory to the V6 per-feature layout (F-077).
|
|
19
|
+
|
|
20
|
+
**V5 (legacy):** monolithic `.cap/memory/decisions.md`, `pitfalls.md`, `patterns.md`, `hotspots.md` plus `graph.json`. Detected as V5 when the top-level files lack the `(V6 Index)` marker.
|
|
21
|
+
|
|
22
|
+
**V6 (target):** per-feature files under `.cap/memory/features/F-NNN-<topic>.md`, cross-cutting topics under `.cap/memory/platform/<topic>.md`, ambiguous entries pooled in `.cap/memory/snapshots-unassigned.md`. The top-level `decisions.md` / `pitfalls.md` become thin `(V6 Index)` index tables (`Destination | Count | File`).
|
|
23
|
+
|
|
24
|
+
**Why:** V6 lets agents load only the index plus the active feature's memory file — typically a 10–50× token reduction over reading the full V5 monolith on every Read.
|
|
25
|
+
|
|
26
|
+
This command is a thin wrapper that spawns the `cap-migrator` agent in **MODE: MEMORY**. The agent owns the atomic Plan→Diff→Apply→Verify pipeline with backup + rollback under `.cap/migrations/<id>/`. The agent reuses the existing `cap-memory-migrate.cjs::migrateMemory()` pipeline (classification, snapshot routing, ambiguity prompts) — no logic is reimplemented.
|
|
27
|
+
|
|
28
|
+
**Flags:**
|
|
29
|
+
- `--apply` — execute the migration. Without it, dry-run only (default).
|
|
30
|
+
- `--interactive=false` — auto-resolve every ambiguity to its highest-confidence candidate (CI-friendly). Default is interactive.
|
|
31
|
+
- `--allow-large-diff` — bypass the 100 KB / 500-file safety gate after a clean dry-run review.
|
|
32
|
+
</objective>
|
|
33
|
+
|
|
34
|
+
<context>
|
|
35
|
+
$ARGUMENTS
|
|
36
|
+
</context>
|
|
37
|
+
|
|
38
|
+
<process>
|
|
39
|
+
|
|
40
|
+
## Step 1: Parse flags
|
|
41
|
+
|
|
42
|
+
From `$ARGUMENTS`:
|
|
43
|
+
- `apply = $ARGUMENTS contains "--apply"`
|
|
44
|
+
- `interactive = NOT ($ARGUMENTS contains "--interactive=false")`
|
|
45
|
+
- `allow_large_diff = $ARGUMENTS contains "--allow-large-diff"`
|
|
46
|
+
|
|
47
|
+
## Step 2: Spawn cap-migrator (MODE: MEMORY)
|
|
48
|
+
|
|
49
|
+
Use the Task tool to spawn `cap-migrator`. Forward `$ARGUMENTS` verbatim.
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
**MODE: MEMORY**
|
|
53
|
+
|
|
54
|
+
$ARGUMENTS
|
|
55
|
+
|
|
56
|
+
**Flags resolved by /cap:migrate-memory:**
|
|
57
|
+
- apply: {apply}
|
|
58
|
+
- interactive: {interactive}
|
|
59
|
+
- allow_large_diff: {allow_large_diff}
|
|
60
|
+
|
|
61
|
+
**Pipeline obligations (MODE: MEMORY):**
|
|
62
|
+
1. Detect V5 vs V6 by reading `.cap/memory/decisions.md`. If it already contains `(V6 Index)`, emit `=== PLAN-ONLY ===` (already migrated) and stop.
|
|
63
|
+
2. Plan via `cap-memory-migrate.cjs::planMigration(projectRoot)` (or `migrateMemory(projectRoot, { apply: false, interactive })` for full classification dry-run).
|
|
64
|
+
3. Render the plan with classification counts: total, assigned (per-feature), platform, unassigned, ambiguous-needing-prompt.
|
|
65
|
+
4. If --apply AND interactive: prompt for each ambiguous entry (top-3 candidates + skip + auto-all + quit) using AskUserQuestion. If --interactive=false, auto-resolve all to highest-confidence candidate.
|
|
66
|
+
5. Stage + verify + promote per the shared pipeline. V5 source files are backed up to BOTH `.cap/migrations/<tx_id>/backup/` (migrator) AND `.cap/memory/.archive/<date>/` (memory-pipeline convention).
|
|
67
|
+
6. Stage rewritten top-level `decisions.md` / `pitfalls.md` as `(V6 Index)` index tables.
|
|
68
|
+
7. Stage migration report at `.cap/memory/.archive/migration-report-<date>.md`.
|
|
69
|
+
|
|
70
|
+
**Verify obligations:**
|
|
71
|
+
- Every V5 entry has exactly one V6 destination (no loss, no duplication).
|
|
72
|
+
- Each `(V6 Index)` table count matches the file scan count.
|
|
73
|
+
- All staged Markdown parses without error.
|
|
74
|
+
- On any failure: roll back via `.cap/migrations/<tx_id>/backup/` AND restore from `.cap/memory/.archive/<date>/`.
|
|
75
|
+
|
|
76
|
+
**Output contract:** preserve the `migrateMemory()` report counters (total / assigned / platform / skipped) AND emit the standard `=== MIGRATION RESULTS ===` block.
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Step 3: Post-apply guidance
|
|
80
|
+
|
|
81
|
+
After a successful apply, point the user to the next step:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
V6 layout active.
|
|
85
|
+
|
|
86
|
+
Index files (root): .cap/memory/decisions.md, pitfalls.md ← (V6 Index) tables
|
|
87
|
+
Per-feature memory: .cap/memory/features/F-NNN-<topic>.md
|
|
88
|
+
Platform memory: .cap/memory/platform/<topic>.md
|
|
89
|
+
Migration report: .cap/memory/.archive/migration-report-<date>.md
|
|
90
|
+
Migrator backup: .cap/migrations/<tx_id>/backup/
|
|
91
|
+
|
|
92
|
+
The agent rule at .claude/rules/cap-memory.md auto-detects the (V6 Index) marker
|
|
93
|
+
and reads only the relevant per-feature file. No agent prompts need to change.
|
|
94
|
+
|
|
95
|
+
If anything looks wrong, the rollback paths are preserved in BOTH backup locations.
|
|
96
|
+
Commit .cap/memory/features/, .cap/memory/platform/, and .cap/memory/.archive/ to git when satisfied.
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
If only a dry-run was requested:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Dry-run complete. No files were modified.
|
|
103
|
+
|
|
104
|
+
Run /cap:migrate-memory --apply to execute.
|
|
105
|
+
For CI: /cap:migrate-memory --apply --interactive=false
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
</process>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cap:migrate-tags
|
|
3
|
+
description: "Migrate fragmented @cap-feature / @cap-todo(ac:…) tags to unified @cap anchor blocks (F-047, additive). Spawns cap-migrator (MODE: TAGS)."
|
|
4
|
+
argument-hint: "[--apply] [--json] [--include=<glob>] [--exclude=<glob>] [--allow-large-diff] [--force]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Task
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<!-- @cap-feature(feature:F-047, primary:true) /cap:migrate-tags — thin wrapper around cap-migrator (MODE: TAGS). -->
|
|
13
|
+
<!-- @cap-feature(feature:F-085) Scope-filter (gitignore + plugin-mirror + 500-file safety gate) is enforced by the agent. -->
|
|
14
|
+
<!-- @cap-decision Wrapper pattern. Plan→Diff→Apply→Verify with atomic backup + rollback lives in cap-migrator. -->
|
|
15
|
+
<!-- @cap-decision Argument compat: --apply, --json, --include=, --exclude=, --allow-large-diff, --force are all preserved. Dry-run remains the default. -->
|
|
16
|
+
|
|
17
|
+
<objective>
|
|
18
|
+
Plan and optionally apply the migration from fragmented `@cap-*` tags to the unified anchor block format introduced by F-047.
|
|
19
|
+
|
|
20
|
+
The migration is **additive** — legacy fragmented tags are preserved alongside the new unified block so the two formats can coexist while the ecosystem converts. A future cleanup pass can remove the fragmented tags once the unified block is universal.
|
|
21
|
+
|
|
22
|
+
**Opt-in gate (F-047):** requires `.cap/config.json → unifiedAnchors.enabled = true`. Without it, `--apply` is refused; `--force` permits a dry-run preview only.
|
|
23
|
+
|
|
24
|
+
**Scope (F-085):** the migrator shares `cap-scope-filter.cjs` with `cap-tag-scanner`, skipping by default:
|
|
25
|
+
- everything matched by the project's top-level `.gitignore` (typically `.claude/`, `node_modules/`, `dist/`, `coverage/`, …);
|
|
26
|
+
- agent worktrees under `.claude/worktrees/`;
|
|
27
|
+
- the plugin-self-mirror at `.claude/cap/`;
|
|
28
|
+
- test fixtures under `tests/fixtures/` and `**/fixtures/polyglot/`.
|
|
29
|
+
|
|
30
|
+
A built-in safety gate refuses to apply the migration to more than 500 files in a single run; bypass with `--allow-large-diff` after verifying the dry-run report.
|
|
31
|
+
|
|
32
|
+
**Flags (backwards-compatible):**
|
|
33
|
+
- `--apply` — write the migration to disk after explicit confirmation. Without it, dry-run only.
|
|
34
|
+
- `--json` — emit the structured migration plan as JSON for downstream tools.
|
|
35
|
+
- `--include=<glob>` — restrict the scan to paths matching the pattern (additive, repeatable).
|
|
36
|
+
- `--exclude=<glob>` — additionally skip paths matching the pattern (additive, repeatable).
|
|
37
|
+
- `--allow-large-diff` — permit `--apply` to write more than 500 files.
|
|
38
|
+
- `--force` — ignore the F-047 opt-in gate (dry-run preview only).
|
|
39
|
+
</objective>
|
|
40
|
+
|
|
41
|
+
<context>
|
|
42
|
+
$ARGUMENTS
|
|
43
|
+
</context>
|
|
44
|
+
|
|
45
|
+
<process>
|
|
46
|
+
|
|
47
|
+
## Step 1: Parse flags
|
|
48
|
+
|
|
49
|
+
From `$ARGUMENTS`:
|
|
50
|
+
- `apply`, `json`, `force`, `allow_large_diff` — boolean flags
|
|
51
|
+
- `include`, `exclude` — collected glob lists (repeatable)
|
|
52
|
+
|
|
53
|
+
## Step 2: Spawn cap-migrator (MODE: TAGS)
|
|
54
|
+
|
|
55
|
+
Use the Task tool to spawn `cap-migrator`. Forward `$ARGUMENTS` verbatim.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
**MODE: TAGS**
|
|
59
|
+
|
|
60
|
+
$ARGUMENTS
|
|
61
|
+
|
|
62
|
+
**Flags resolved by /cap:migrate-tags:**
|
|
63
|
+
- apply: {apply}
|
|
64
|
+
- json: {json}
|
|
65
|
+
- force: {force}
|
|
66
|
+
- allow_large_diff: {allow_large_diff}
|
|
67
|
+
- include: {include or none}
|
|
68
|
+
- exclude: {exclude or none}
|
|
69
|
+
|
|
70
|
+
**Pipeline obligations (MODE: TAGS):**
|
|
71
|
+
1. Gate on `.cap/config.json → unifiedAnchors.enabled === true` (F-047 opt-in). On gate-fail without --force, refuse and print:
|
|
72
|
+
"F-047 (unified anchors) is opt-in and not enabled for this project.
|
|
73
|
+
To enable: add { \"unifiedAnchors\": { \"enabled\": true } } to .cap/config.json
|
|
74
|
+
You can still run the migration with --force (dry-run) to preview the diff."
|
|
75
|
+
2. Plan via `cap-migrate-tags.cjs::planProjectMigration` honoring include/exclude globs.
|
|
76
|
+
3. Render the plan with `cap-migrate-tags.cjs::formatMigrationReport`. If --json, emit the plan JSON instead.
|
|
77
|
+
4. If --apply AND gate passed: AskUserQuestion → "Apply the unified-anchor migration to the listed files? (yes/no)" — abort on no.
|
|
78
|
+
5. On yes: stage + verify + promote via the MODE: TAGS pipeline. The 500-file ceiling raises `CAP_MIGRATE_LARGE_DIFF` unless --allow-large-diff.
|
|
79
|
+
6. Legacy fragmented tags MUST be preserved (additive migration).
|
|
80
|
+
|
|
81
|
+
**Output contract:** preserve `cap-migrate-tags.cjs::formatMigrationReport` output verbatim, then append the `=== MIGRATION RESULTS ===` block.
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Step 3: Suggest next action (based on agent results)
|
|
85
|
+
|
|
86
|
+
- If dry-run completed with changes: "Run `/cap:migrate-tags --apply` to persist the anchors. Legacy tags remain in place; a future cleanup pass can remove them."
|
|
87
|
+
- If the F-047 gate blocked the run: "Enable F-047 via `.cap/config.json → unifiedAnchors.enabled=true`, then re-run."
|
|
88
|
+
- If `CAP_MIGRATE_LARGE_DIFF` fired: "Verify the dry-run scope, then re-run with `--allow-large-diff` to override."
|
|
89
|
+
- If nothing to change: "Project is already migrated or has no fragmented tags."
|
|
90
|
+
|
|
91
|
+
</process>
|