context-planning 0.7.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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +454 -0
  3. package/bin/commands/_helpers.js +53 -0
  4. package/bin/commands/_usage.js +67 -0
  5. package/bin/commands/capture.js +46 -0
  6. package/bin/commands/codebase-status.js +41 -0
  7. package/bin/commands/complete-milestone.js +57 -0
  8. package/bin/commands/config.js +70 -0
  9. package/bin/commands/doctor.js +139 -0
  10. package/bin/commands/gsd-import.js +90 -0
  11. package/bin/commands/inbox.js +81 -0
  12. package/bin/commands/index.js +33 -0
  13. package/bin/commands/init.js +87 -0
  14. package/bin/commands/install.js +43 -0
  15. package/bin/commands/scaffold-codebase.js +53 -0
  16. package/bin/commands/scaffold-milestone.js +58 -0
  17. package/bin/commands/scaffold-phase.js +65 -0
  18. package/bin/commands/status.js +42 -0
  19. package/bin/commands/statusline.js +108 -0
  20. package/bin/commands/tick.js +49 -0
  21. package/bin/commands/version.js +9 -0
  22. package/bin/commands/worktree.js +218 -0
  23. package/bin/commands/write-summary.js +54 -0
  24. package/bin/cp.cmd +2 -0
  25. package/bin/cp.js +54 -0
  26. package/commands/cp/capture.md +107 -0
  27. package/commands/cp/complete-milestone.md +166 -0
  28. package/commands/cp/execute-phase.md +220 -0
  29. package/commands/cp/map-codebase.md +211 -0
  30. package/commands/cp/new-milestone.md +136 -0
  31. package/commands/cp/new-project.md +132 -0
  32. package/commands/cp/plan-phase.md +195 -0
  33. package/commands/cp/progress.md +147 -0
  34. package/commands/cp/quick.md +104 -0
  35. package/commands/cp/resume.md +125 -0
  36. package/commands/cp/write-summary.md +33 -0
  37. package/docs/MIGRATION-v0.5.md +140 -0
  38. package/docs/architecture.md +189 -0
  39. package/docs/superpowers/plans/2026-05-20-v0-7-plan-16-01-design-md-infrastructure.md +1064 -0
  40. package/docs/superpowers/plans/2026-05-20-v0-7-plan-16-02-review-log-infrastructure.md +418 -0
  41. package/docs/superpowers/plans/2026-05-20-v0-7-plan-16-03-key-decisions-hard-block.md +295 -0
  42. package/docs/superpowers/specs/2026-05-20-generic-provider-harness-detection-design.md +380 -0
  43. package/docs/superpowers/specs/2026-05-20-v0-7-design-capture-design.md +400 -0
  44. package/docs/writing-providers.md +76 -0
  45. package/install/aider.js +204 -0
  46. package/install/claude.js +116 -0
  47. package/install/common.js +65 -0
  48. package/install/copilot.js +86 -0
  49. package/install/cursor.js +120 -0
  50. package/install/echo-provider.js +50 -0
  51. package/lib/codebase-mapper.js +169 -0
  52. package/lib/detect.js +280 -0
  53. package/lib/frontmatter.js +72 -0
  54. package/lib/gsd-compat.js +165 -0
  55. package/lib/import.js +543 -0
  56. package/lib/inbox.js +226 -0
  57. package/lib/lifecycle.js +929 -0
  58. package/lib/merge.js +157 -0
  59. package/lib/milestone.js +595 -0
  60. package/lib/paths.js +191 -0
  61. package/lib/provider.js +168 -0
  62. package/lib/roadmap.js +134 -0
  63. package/lib/state.js +99 -0
  64. package/lib/worktree.js +253 -0
  65. package/package.json +45 -0
  66. package/templates/DESIGN.md +78 -0
  67. package/templates/INBOX.md +13 -0
  68. package/templates/MILESTONE-CONTEXT.md +40 -0
  69. package/templates/MILESTONES.md +29 -0
  70. package/templates/PLAN.md +84 -0
  71. package/templates/PROJECT.md +43 -0
  72. package/templates/REVIEW-LOG.md +38 -0
  73. package/templates/ROADMAP.md +34 -0
  74. package/templates/STATE.md +78 -0
  75. package/templates/SUMMARY.md +75 -0
  76. package/templates/codebase/ARCHITECTURE.md +30 -0
  77. package/templates/codebase/CONCERNS.md +30 -0
  78. package/templates/codebase/CONVENTIONS.md +30 -0
  79. package/templates/codebase/INTEGRATIONS.md +30 -0
  80. package/templates/codebase/STACK.md +26 -0
  81. package/templates/codebase/STRUCTURE.md +32 -0
  82. package/templates/codebase/TESTING.md +39 -0
  83. package/templates/config.json +173 -0
  84. package/templates/phase-PLAN.md +32 -0
  85. package/templates/quick-PLAN.md +24 -0
  86. package/templates/quick-SUMMARY.md +25 -0
@@ -0,0 +1,189 @@
1
+ # Architecture
2
+
3
+ `cp` (context-planning) is two layers welded together by a thin command surface:
4
+
5
+ ```
6
+ ┌──────────────────────────────────────────────────────────────────┐
7
+ │ Slash commands (/cp-new-project, /cp-plan-phase, /cp-quick…) │
8
+ │ Live as harness-native skill files (Copilot .github/skills/cp-*) │
9
+ └──────────────────┬───────────────────────────────────────────────┘
10
+
11
+
12
+ ┌──────────────────────────────────────────────────────────────────┐
13
+ │ STATE LAYER (this plugin owns it) │
14
+ │ .planning/PROJECT.md living spec │
15
+ │ .planning/ROADMAP.md milestone → phase → plan tree │
16
+ │ .planning/STATE.md <100-line "you are here" digest │
17
+ │ .planning/phases/NN-name/{PLAN,SUMMARY}.md │
18
+ │ .planning/quick/YYYYMMDD-slug/{PLAN,SUMMARY}.md │
19
+ │ .planning/cp-config.json provider mapping │
20
+ │ │
21
+ │ Helpers: lib/frontmatter.js, lib/roadmap.js, lib/state.js │
22
+ └──────────────────┬───────────────────────────────────────────────┘
23
+ │ delegates by ROLE (brainstorm, plan, execute…)
24
+
25
+ ┌──────────────────────────────────────────────────────────────────┐
26
+ │ WORKFLOW PROVIDER (configurable; default = Superpowers) │
27
+ │ brainstorm → writing-plans → subagent-driven-development … │
28
+ │ resolved at run time by lib/provider.js │
29
+ │ │
30
+ │ Fall-back: `manual` provider — inline prompts written into the │
31
+ │ command markdown so cp still works without any external skills. │
32
+ └──────────────────────────────────────────────────────────────────┘
33
+ ```
34
+
35
+ ## Design principles
36
+
37
+ 1. **Be the spine, not the muscles.** State management is what we own. The
38
+ actual *do the work* skills (brainstorming, planning, executing, reviewing,
39
+ shipping) come from a workflow provider.
40
+ 2. **Role-based delegation.** Commands invoke providers by role
41
+ (`brainstorm`, `plan`, `execute`, …), never by hard-coded skill name.
42
+ Swapping providers is a config change.
43
+ 3. **Soft dependency.** Missing provider skills don't crash; fall back to
44
+ inline `manual` prompts and warn the user.
45
+ 4. **Harness-agnostic source, per-harness install.** Command markdown is
46
+ harness-independent. A small installer projects it into each harness's
47
+ conventions (Copilot's `.github/skills/cp-*`, Claude's `.claude/commands/`,
48
+ etc.).
49
+ 5. **Atomic commits + resumable state.** Every command updates STATE.md and
50
+ (optionally) creates a git commit, so any session can pick up where the
51
+ last left off without re-deriving context.
52
+ 6. **Small surface.** ~8 commands. If you find yourself wanting a 9th, ask
53
+ whether it's a provider concern instead.
54
+ 7. **GSD compatibility is a hard contract.** Same filenames, same
55
+ frontmatter, shared `config.json`. Users can switch back to GSD any time;
56
+ cp only ADDS to `.planning/`, never breaks it.
57
+
58
+ ## File responsibilities
59
+
60
+ | File | Owns | Updated by |
61
+ |---|---|---|
62
+ | `PROJECT.md` | What/why/requirements/constraints/decisions | `cp-new-project`, `cp-new-milestone`, manual edits |
63
+ | `ROADMAP.md` | Milestones → phases → plans tree | `cp-new-project`, `cp-new-milestone`, `cp-plan-phase`, `cp-execute-phase` |
64
+ | `STATE.md` | Where am I right now (digest) | every cp command |
65
+ | `MILESTONES.md` | Archive of shipped milestones | `cp-complete-milestone` |
66
+ | `MILESTONE-CONTEXT.md` | Transient spec for current milestone | `cp-new-milestone` (created), `cp-complete-milestone` (moved) |
67
+ | `phases/{NN-slug}/{phase}-{plan}-PLAN.md` | Concrete tasks for a plan | `cp-plan-phase` (via provider) |
68
+ | `phases/{NN-slug}/{phase}-{plan}-SUMMARY.md` | What actually happened | `cp-execute-phase` |
69
+ | `phases/{NN-slug}/DESIGN.md` | Phase-level design intent (ADR-style) | `cp-plan-phase` Step 3.5 (via provider `brainstorm`) |
70
+ | `phases/{NN-slug}/REVIEW-LOG.md` | Append-only log of review/decision pivots | `cp-execute-phase` Step 4.5 |
71
+ | `milestones/{slug}/DESIGN.md` | Milestone-level design + roll-up of phase DESIGNs | `cp-new-milestone`, promoted by `cp-complete-milestone` |
72
+ | `quick/*/PLAN.md` | Concrete tasks for ad-hoc work | `cp-quick` |
73
+ | `quick/*/SUMMARY.md` | Outcome | `cp-quick` |
74
+ | `config.json` (`cp.*`) | Provider + behavior settings | `cp config set`, manual edits |
75
+
76
+ All filenames and frontmatter match GSD's conventions. See the
77
+ "GSD compatibility" section in the [README](../README.md) for the round-trip
78
+ contract.
79
+
80
+ ## Interaction with workflow providers
81
+
82
+ cp drives a provider session like a *conversation with a contract*: cp owns
83
+ the file system before/after the call, the provider owns reasoning + creative
84
+ output during the call, and cp captures the durable artifacts back out before
85
+ yielding control to the user.
86
+
87
+ ```
88
+ cp command provider skill (e.g. SP)
89
+ ────────── ────────────────────────
90
+ call: ─ assemble context ──▶ ─ brainstorm / plan / execute ─┐
91
+ (state + slot) │
92
+
93
+ return: ◀── extract artifacts ◀── conversation output ──────────┘
94
+ (write to .planning/)
95
+ ```
96
+
97
+ ### The role contract
98
+
99
+ Each provider skill is invoked for a specific **role**. cp passes a small
100
+ *context slot* (relevant files + intent) and expects a known *artifact* back.
101
+ Providers don't need to know about cp — they just produce their normal output;
102
+ cp's command markdown does the lifting to harvest it.
103
+
104
+ | Role | Where cp calls it | What cp sends in | What cp captures back | Lands in |
105
+ |---|---|---|---|---|
106
+ | `brainstorm` | `cp-new-project`, `cp-new-milestone`, `cp-plan-phase` Step 3.5 | PROJECT.md, MILESTONE-CONTEXT.md, phase intent | Design intent (Context / Decision / Alternatives Considered / Consequences) | `milestones/{slug}/DESIGN.md`, `phases/{NN-slug}/DESIGN.md` |
107
+ | `plan` | `cp-plan-phase`, `cp-quick` | Phase DESIGN.md + roadmap row | Plan body (task list, acceptance criteria) | `phases/{NN-slug}/{phase}-{plan}-PLAN.md`, `quick/*/PLAN.md` |
108
+ | `execute` | `cp-execute-phase`, `cp-quick` | PLAN.md + DESIGN.md (read-only) | Code changes + commit history + free-text outcome | Provider commits to git; cp writes `SUMMARY.md` with required `key-decisions` |
109
+ | `review` | `cp-execute-phase` Step 4.5 (opt-in) | Diff of execute step | Findings, pivots, rejected approaches | Appended to `phases/{NN-slug}/REVIEW-LOG.md` |
110
+ | `finish` / `worktree` / `tdd` / `debug` / `verify` | Various | Role-specific | Role-specific | Folded into SUMMARY notes; no dedicated file |
111
+
112
+ Only `brainstorm`, `plan`, and `execute` are required. Missing roles fall
113
+ back to inline `manual` prompts written into the command markdown
114
+ (soft-dependency principle #3).
115
+
116
+ ### The return path (what cp captures back)
117
+
118
+ This is the half of the contract that's easy to miss. When SP runs a
119
+ brainstorm or planning session, it produces a *lot* of context that would
120
+ otherwise vanish when the LLM session ends. cp's command markdown forces a
121
+ small handful of structured extractions before the user is allowed to move
122
+ on:
123
+
124
+ 1. **`brainstorm` → DESIGN.md.** After the provider returns, cp prompts:
125
+ *"Capture the design intent in the milestone/phase DESIGN.md using the
126
+ template (Context / Decision / Alternatives Considered / Consequences)."*
127
+ The template lives at `templates/DESIGN.md`. Empty DESIGN.md files are
128
+ tolerated but flagged by `cp status` (v0.8 deferred).
129
+ 2. **`plan` → phase directory.** The aggregator discovers DESIGN.md by phase
130
+ directory at roll-up time; no PLAN.md back-link is required today.
131
+ A frontmatter `phases:` back-link array on milestone DESIGN.md is a
132
+ v0.8 deferred item.
133
+ 3. **`execute` → SUMMARY.md `key-decisions`.** Required key (validated by
134
+ `lib/milestone.js::writeSummary`, surfaced via `cp write-summary` which
135
+ exits 2 on missing). Forces the executor to record any deviation from
136
+ the plan, surprise discoveries, or design-affecting choices made
137
+ mid-execute. This is the audit trail.
138
+ 4. **`execute` (+ optional `review`) → REVIEW-LOG.md.** Append-only,
139
+ marker-anchored (`<!-- REVIEW-LOG-ENTRIES-BELOW -->`). Each entry is
140
+ timestamped (`## YYYY-MM-DD HH:MM — Plan NN-MM Task N — <reviewer-role>`)
141
+ and the aggregator counts entries to populate `reviewCount` in the
142
+ milestone roll-up. Nothing is ever rewritten.
143
+ 5. **`cp-complete-milestone`** promotes phase DESIGNs into the milestone
144
+ DESIGN.md roll-up (`phaseDesignRefs` / `reviewLogRefs` / `reviewCount`
145
+ in `lib/milestone.js::aggregateSummaries`), then archives the milestone
146
+ into `MILESTONES.md`.
147
+
148
+ The net effect: a stateless LLM picking up this repo six months later can
149
+ reconstruct *what was decided, why, what was tried and rejected, and what
150
+ changed during execution* — without re-reading the original SP session
151
+ transcript (which is gone).
152
+
153
+ ### Provider resolution
154
+
155
+ At runtime `lib/provider.js` walks `config.json → cp.providers`, runs the
156
+ provider's `detect` block (any-of paths / glob / command exit code) against
157
+ the current repo, and resolves each role to a concrete skill name. The
158
+ default config ships an `superpowers` provider, an `echo` test provider, and
159
+ a `manual` fallback. See [writing-providers.md](writing-providers.md) for
160
+ the schema, and `docs/superpowers/specs/2026-05-20-generic-provider-harness-detection-design.md`
161
+ for why detection is generic instead of SP-hardcoded.
162
+
163
+ ### Worked example — `/cp-new-milestone "add OAuth login"`
164
+
165
+ 1. **cp** reads `PROJECT.md`, creates `milestones/add-oauth-login/`, writes
166
+ a stub `MILESTONE-CONTEXT.md` with the user's intent.
167
+ 2. **cp** resolves role `brainstorm` → SP `brainstorming` skill → invokes it
168
+ with MILESTONE-CONTEXT.md as the seed.
169
+ 3. **SP** runs its own clarifying-questions / 2-3-approaches / design loop
170
+ and emits a spec under `docs/superpowers/specs/`.
171
+ 4. **cp** prompts the user to copy the agreed Context / Decision / Alternatives
172
+ Considered / Consequences into `milestones/add-oauth-login/DESIGN.md`
173
+ (template-driven; not optional).
174
+ 5. **cp** updates `ROADMAP.md` with the new milestone + phase list derived
175
+ from the design's "Components" section, updates `STATE.md`, and commits.
176
+
177
+ The user now has *both* a freeform SP spec (rich, conversational) *and* a
178
+ canonical cp DESIGN.md (structured, queryable, survives session loss). The
179
+ v0.7 milestone hardened this contract; see
180
+ `docs/superpowers/specs/2026-05-20-v0-7-design-capture-design.md`.
181
+
182
+ ## What we explicitly do NOT do
183
+
184
+ - We don't review code. (Provider's `review` skill does that.)
185
+ - We don't run tests. (Provider's execute skill does that.)
186
+ - We don't write the actual plan tasks. (Provider's `plan` skill does that.)
187
+ - We don't enforce TDD or branch policy. (Provider's skills do that.)
188
+ - We don't track requirements traceability with REQ-IDs. (Light decisions
189
+ table in PROJECT.md is enough.)