learnship 2.0.11 → 2.1.1

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 (79) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/.cursor-plugin/plugin.json +2 -2
  3. package/README.md +59 -14
  4. package/SKILL.md +24 -2
  5. package/agents/learnship-doc-writer.md +63 -0
  6. package/agents/learnship-security-auditor.md +67 -0
  7. package/bin/install.js +2 -0
  8. package/commands/learnship/discuss-phase.md +1 -1
  9. package/commands/learnship/docs-update.md +22 -0
  10. package/commands/learnship/execute-phase.md +2 -6
  11. package/commands/learnship/extract-learnings.md +22 -0
  12. package/commands/learnship/forensics.md +21 -0
  13. package/commands/learnship/help.md +2 -1
  14. package/commands/learnship/ideate.md +1 -1
  15. package/commands/learnship/milestone-summary.md +22 -0
  16. package/commands/learnship/note.md +22 -0
  17. package/commands/learnship/plan-phase.md +0 -1
  18. package/commands/learnship/quick.md +1 -5
  19. package/commands/learnship/secure-phase.md +23 -0
  20. package/commands/learnship/session-report.md +21 -0
  21. package/commands/learnship/undo.md +22 -0
  22. package/commands/learnship/verify-work.md +1 -1
  23. package/cursor-rules/learnship.mdc +12 -2
  24. package/gemini-extension.json +2 -2
  25. package/hooks/session-start +12 -1
  26. package/learnship/agents/doc-writer.md +63 -0
  27. package/learnship/agents/security-auditor.md +67 -0
  28. package/learnship/references/common-bug-patterns.md +92 -0
  29. package/learnship/references/context-budget.md +49 -0
  30. package/learnship/references/domain-probes.md +133 -0
  31. package/learnship/references/gates.md +72 -0
  32. package/learnship/references/planning-config.md +99 -9
  33. package/learnship/references/thinking-models.md +61 -0
  34. package/learnship/references/universal-anti-patterns.md +51 -0
  35. package/learnship/templates/agents.md +3 -0
  36. package/learnship/templates/context.md +207 -32
  37. package/learnship/templates/discussion-log.md +49 -0
  38. package/learnship/templates/security.md +61 -0
  39. package/learnship/templates/ui-spec.md +107 -0
  40. package/learnship/workflows/complete-milestone.md +4 -5
  41. package/learnship/workflows/compound.md +2 -0
  42. package/learnship/workflows/debug.md +2 -0
  43. package/learnship/workflows/discuss-phase.md +73 -15
  44. package/learnship/workflows/docs-update.md +144 -0
  45. package/learnship/workflows/execute-phase.md +35 -6
  46. package/learnship/workflows/extract-learnings.md +161 -0
  47. package/learnship/workflows/forensics.md +118 -0
  48. package/learnship/workflows/help.md +20 -2
  49. package/learnship/workflows/ideate.md +63 -4
  50. package/learnship/workflows/ls.md +1 -1
  51. package/learnship/workflows/milestone-summary.md +150 -0
  52. package/learnship/workflows/new-project.md +78 -8
  53. package/learnship/workflows/next.md +1 -1
  54. package/learnship/workflows/note.md +110 -0
  55. package/learnship/workflows/pause-work.md +2 -0
  56. package/learnship/workflows/plan-phase.md +17 -2
  57. package/learnship/workflows/quick.md +28 -8
  58. package/learnship/workflows/review.md +1 -0
  59. package/learnship/workflows/secure-phase.md +147 -0
  60. package/learnship/workflows/session-report.md +133 -0
  61. package/learnship/workflows/settings.md +40 -46
  62. package/learnship/workflows/ship.md +2 -0
  63. package/learnship/workflows/undo.md +151 -0
  64. package/learnship/workflows/verify-work.md +36 -4
  65. package/package.json +1 -1
  66. package/references/common-bug-patterns.md +92 -0
  67. package/references/context-budget.md +49 -0
  68. package/references/domain-probes.md +133 -0
  69. package/references/gates.md +72 -0
  70. package/references/planning-config.md +139 -0
  71. package/references/solution-schema.md +159 -0
  72. package/references/thinking-models.md +61 -0
  73. package/references/universal-anti-patterns.md +51 -0
  74. package/templates/agents.md +80 -7
  75. package/templates/config.json +28 -3
  76. package/templates/context.md +207 -32
  77. package/templates/discussion-log.md +49 -0
  78. package/templates/security.md +61 -0
  79. package/templates/ui-spec.md +107 -0
@@ -8,9 +8,15 @@ Create executable plans for a roadmap phase. Default flow: Research → Plan →
8
8
 
9
9
  On platforms with subagent support (Claude Code, OpenCode, Codex), each stage spawns a dedicated specialist agent with its own full context budget. On all other platforms, all stages run sequentially in the same context.
10
10
 
11
- **Usage:** `plan-phase [N]` — optionally add `--skip-research` or `--skip-verify`
11
+ **Usage:** `plan-phase [N]` — optionally add `--skip-research`, `--skip-verify`, or `--research` (force re-research)
12
12
 
13
- > **Platform note:** Read `parallelization` from `.planning/config.json`. When `true`, researcher/planner/checker each run as a spawned subagent. When `false` (default), all stages run inline using agent persona files.
13
+ **Flags:**
14
+ - `--skip-research` — skip the research stage even if enabled in config
15
+ - `--skip-verify` — skip the plan verification stage
16
+ - `--research` — force re-research even if RESEARCH.md already exists
17
+ - `--gaps` — plan only for gaps found during verification
18
+
19
+ > **Platform note:** Read `parallelization` from `.planning/config.json`. When enabled, researcher/planner/checker each run as a spawned subagent. When `false` (default), all stages run inline using agent persona files.
14
20
 
15
21
  ## Step 1: Initialize
16
22
 
@@ -23,6 +29,15 @@ Read config:
23
29
  cat .planning/config.json
24
30
  ```
25
31
 
32
+ Read TDD mode:
33
+ ```bash
34
+ TDD_MODE=$(node -e "try{const c=JSON.parse(require('fs').readFileSync('.planning/config.json','utf8'));process.stdout.write(String((c.workflow||{}).tdd_mode||false));}catch(e){process.stdout.write('false');}" 2>/dev/null || echo 'false')
35
+ ```
36
+
37
+ When `TDD_MODE` is `true`, instruct the planner to apply `type: tdd` to eligible tasks — the executor will use the red-green-refactor cycle for those tasks.
38
+
39
+ **Context window scaling:** Check `context_window` in config (default: 200000). At >= 500000, include the 3 most recent prior phase CONTEXT.md and SUMMARY.md files in the planner's context. At < 500000, include only frontmatter from prior phases.
40
+
26
41
  Create the phase directory if it doesn't exist:
27
42
  ```bash
28
43
  node -e "require('fs').mkdirSync('.planning/phases/[padded_phase]-[phase_slug]',{recursive:true})"
@@ -10,9 +10,11 @@ Execute small, ad-hoc tasks with full agentic guarantees: atomic commits, STATE.
10
10
 
11
11
  **Flags:**
12
12
  - `--discuss` — lightweight discussion phase before planning (surfaces gray areas)
13
- - `--full` — adds plan-checking and post-execution verification
13
+ - `--research` — spawns a focused research agent before planning (investigates approaches, libraries, pitfalls)
14
+ - `--validate` — enables plan-checking (max 2 iterations) and post-execution verification
15
+ - `--full` — enables all of the above: discussion + research + plan-checking + verification
14
16
 
15
- **Composable:** `quick --discuss --full "add dark mode toggle"` gives discussion + plan-checking + verification.
17
+ **Composable:** Granular flags compose freely. `quick --discuss --research --validate` = `--full`.
16
18
 
17
19
  ## Step 1: Get Task Description
18
20
 
@@ -113,6 +115,23 @@ Write `CONTEXT.md` to the task directory:
113
115
  </specifics>
114
116
  ```
115
117
 
118
+ ## Step 3b: Research Phase (only with `--research` or `--full`)
119
+
120
+ **Skip if neither `--research` nor `--full` flag is present.**
121
+
122
+ ```
123
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
124
+ learnship ► RESEARCHING: [DESCRIPTION]
125
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
126
+ ```
127
+
128
+ Using `@./agents/researcher.md` as your research persona, do a focused research pass on the task:
129
+ - What libraries or approaches are relevant?
130
+ - What pitfalls should the implementation avoid?
131
+ - Are there existing patterns in the codebase to follow?
132
+
133
+ Write a brief `${NEXT_NUM}-RESEARCH.md` (max 50 lines) to the task directory. This feeds into the planner.
134
+
116
135
  ## Step 4: Create Plan
117
136
 
118
137
  Using `@./agents/planner.md` as your planning persona, read:
@@ -128,16 +147,17 @@ Each task needs:
128
147
  - `<verify>` — how to confirm it worked
129
148
  - `<done>` — observable completion criteria
130
149
 
131
- If `--full`: also include `must_haves` in plan frontmatter (truths, artifacts, key_links).
150
+ If `--validate` or `--full`: also include `must_haves` in plan frontmatter (truths, artifacts, key_links).
151
+ If `--research` or `--full`: also read the RESEARCH.md from step 3b.
132
152
 
133
153
  Verify plan was created (substitute actual NEXT_NUM and SLUG values):
134
154
  ```bash
135
155
  node -e "const fs=require('fs'); console.log(fs.existsSync('.planning/quick/NEXT_NUM-SLUG/NEXT_NUM-PLAN.md') ? 'OK' : 'MISSING')"
136
156
  ```
137
157
 
138
- ## Step 5: Plan Check (only with `--full`)
158
+ ## Step 5: Plan Check (only with `--validate` or `--full`)
139
159
 
140
- **Skip if `--full` flag is not present.**
160
+ **Skip if neither `--validate` nor `--full` flag is present.**
141
161
 
142
162
  ```
143
163
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -187,9 +207,9 @@ After all tasks complete, write `${NEXT_NUM}-SUMMARY.md`:
187
207
  [commit hash]
188
208
  ```
189
209
 
190
- ## Step 7: Verify Results (only with `--full`)
210
+ ## Step 7: Verify Results (only with `--validate` or `--full`)
191
211
 
192
- **Skip if `--full` flag is not present.**
212
+ **Skip if neither `--validate` nor `--full` flag is present.**
193
213
 
194
214
  ```
195
215
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -235,7 +255,7 @@ Display completion:
235
255
  Quick Task [NEXT_NUM]: [DESCRIPTION]
236
256
 
237
257
  Summary: .planning/quick/[NEXT_NUM]-[SLUG]/[NEXT_NUM]-SUMMARY.md
238
- [If --full: Verification: [status]]
258
+ [If --validate/--full: Verification: [status]]
239
259
  Commit: [hash]
240
260
 
241
261
  💡 Solved something notable? `/compound` — capture the solution while context is fresh
@@ -198,6 +198,7 @@ git commit -m "fix([scope]): [description from finding]"
198
198
 
199
199
  ```
200
200
  ▶ Next steps:
201
+ - /secure-phase [N] — STRIDE security verification before shipping
201
202
  - /ship — run the ship pipeline (test → lint → commit → push → PR)
202
203
  - /compound — capture any notable patterns from the review
203
204
  ```
@@ -0,0 +1,147 @@
1
+ ---
2
+ description: Per-phase security verification — STRIDE threat register, mitigation check, SECURITY.md generation
3
+ ---
4
+
5
+ # Secure Phase
6
+
7
+ Verify threat mitigations for a completed phase. Reads PLAN.md threat data if present, analyzes the codebase for security concerns, classifies threats, and generates a per-phase SECURITY.md using `@./templates/security.md`.
8
+
9
+ **Usage:** `secure-phase [N]`
10
+
11
+ **Sequencing:** Run after `execute-phase [N]` and before or alongside `verify-work [N]`.
12
+
13
+ ## Step 1: Initialize
14
+
15
+ Read `.planning/config.json` for `workflow.security_enforcement` (defaults to `true`).
16
+
17
+ If `security_enforcement` is `false`: exit with "Security enforcement disabled. Enable via `/settings`."
18
+
19
+ Find the phase directory and verify it has been executed (SUMMARY.md exists):
20
+
21
+ ```bash
22
+ ls ".planning/phases/[padded_phase]-[phase_slug]/"*-SUMMARY.md 2>/dev/null
23
+ ```
24
+
25
+ If no SUMMARY.md: "Phase [N] not executed yet. Run `execute-phase [N]` first."
26
+
27
+ Display:
28
+ ```
29
+ learnship > SECURE PHASE [N]: [name]
30
+ ```
31
+
32
+ ## Step 2: Discovery
33
+
34
+ ### 2a. Read Phase Artifacts
35
+
36
+ Read all PLAN.md files for this phase. Look for `<threat_model>` blocks or security-related task descriptions (auth, encryption, input validation, access control, etc.).
37
+
38
+ ### 2b. Read Summary Threat Flags
39
+
40
+ Read SUMMARY.md files. Look for any security-related notes, deviations, or flags.
41
+
42
+ ### 2c. Analyze Codebase
43
+
44
+ Scan files modified in this phase for common security patterns:
45
+
46
+ ```bash
47
+ git log --name-only --format="" --grep="([padded_phase]" | sort -u
48
+ ```
49
+
50
+ For each file, check for:
51
+ - Input validation (or lack thereof)
52
+ - Authentication/authorization checks
53
+ - Sensitive data handling (secrets, PII, tokens)
54
+ - SQL/command injection vectors
55
+ - Hardcoded credentials
56
+ - Insecure defaults
57
+
58
+ ## Step 3: Build Threat Register
59
+
60
+ For each identified concern, create a threat entry:
61
+
62
+ | Field | Value |
63
+ |-------|-------|
64
+ | Threat ID | T-{phase}-{NN} |
65
+ | Category | STRIDE category (Spoofing/Tampering/Repudiation/Info Disclosure/DoS/Elevation) |
66
+ | Component | Which file or module |
67
+ | Disposition | mitigate / accept / transfer |
68
+ | Status | open / closed |
69
+
70
+ Classify each threat:
71
+ - **CLOSED** — mitigation found in code OR accepted risk documented OR transferred to third-party
72
+ - **OPEN** — none of the above
73
+
74
+ ## Step 4: Present Threat Plan
75
+
76
+ If all threats are CLOSED: skip to Step 6.
77
+
78
+ If open threats exist, present them:
79
+
80
+ ```
81
+ Open Threats ([N]):
82
+
83
+ | ID | Category | Component | Description |
84
+ |----|----------|-----------|-------------|
85
+ | T-03-01 | Info Disclosure | api/auth.ts | JWT secret in environment without validation |
86
+
87
+ Options:
88
+ 1. Verify all open threats — investigate and resolve
89
+ 2. Accept all open — document as accepted risks
90
+ 3. Review individually — decide per threat
91
+ ```
92
+
93
+ Wait for user response.
94
+
95
+ ## Step 5: Resolve Open Threats
96
+
97
+ For option 1 (verify all): Using `@./agents/verifier.md`, check each open threat against the codebase. Update status based on findings.
98
+
99
+ For option 2 (accept all): Add each to the Accepted Risks Log with user's rationale.
100
+
101
+ For option 3 (individual): Present each threat one at a time with options: Verify / Accept / Skip.
102
+
103
+ ## Step 6: Write SECURITY.md
104
+
105
+ Write `.planning/phases/[padded_phase]-[phase_slug]/[padded_phase]-SECURITY.md` using `@./templates/security.md`:
106
+
107
+ - Fill in trust boundaries from the analysis
108
+ - Fill in the complete threat register
109
+ - Fill in accepted risks log
110
+ - Fill in audit trail
111
+ - Update frontmatter: `threats_open` count, `status` (draft/verified)
112
+
113
+ If `threats_open` is 0: set `status: verified`.
114
+
115
+ Commit:
116
+ ```bash
117
+ git add ".planning/phases/[padded_phase]-[phase_slug]/[padded_phase]-SECURITY.md"
118
+ git commit -m "security([padded_phase]): phase security verification"
119
+ ```
120
+
121
+ ## Step 7: Report
122
+
123
+ ```
124
+ learnship > SECURE PHASE [N] COMPLETE
125
+
126
+ Threats found: [total]
127
+ Closed: [N] | Accepted: [N] | Open: [N]
128
+
129
+ Status: [verified / needs attention]
130
+ Report: [path to SECURITY.md]
131
+ ```
132
+
133
+ If open threats remain: warn that the phase has unresolved security concerns.
134
+
135
+ ---
136
+
137
+ ## Learning Checkpoint
138
+
139
+ Read `learning_mode` from `.planning/config.json`.
140
+
141
+ **If `auto`:**
142
+
143
+ > **Learning moment:** Security verification surfaces patterns worth internalizing:
144
+ >
145
+ > `@agentic-learning learn [security topic]` — Active retrieval on the security concepts encountered. STRIDE categories, common vulnerability patterns, and mitigation strategies build lasting defensive instincts.
146
+
147
+ **If `manual`:** Add quietly: *"Tip: `@agentic-learning learn [topic]` to deepen security knowledge from this verification."*
@@ -0,0 +1,133 @@
1
+ ---
2
+ description: Generate a post-session summary with work performed, outcomes, and estimated resource usage
3
+ ---
4
+
5
+ # Session Report
6
+
7
+ Generate a post-session summary capturing work performed, outcomes achieved, and git activity. Writes a report to `.planning/reports/` for human review and stakeholder sharing.
8
+
9
+ **Usage:** `session-report`
10
+
11
+ ## Step 1: Gather Session Data
12
+
13
+ Collect data from available sources:
14
+
15
+ ### 1a. Git Activity
16
+
17
+ ```bash
18
+ git log --oneline --since="24 hours ago" --no-merges 2>/dev/null || echo "No recent commits"
19
+
20
+ git diff --stat HEAD~10 HEAD 2>/dev/null | tail -1 || echo "No diff available"
21
+
22
+ git log --format="%ai" --since="24 hours ago" 2>/dev/null | head -1
23
+ git log --format="%ai" --since="24 hours ago" 2>/dev/null | tail -1
24
+ ```
25
+
26
+ ### 1b. Planning State
27
+
28
+ Read `.planning/STATE.md` to get:
29
+ - Current milestone and phase
30
+ - Progress percentage
31
+ - Active blockers
32
+ - Recent decisions
33
+
34
+ Read `.planning/ROADMAP.md` to get milestone name and phase goals.
35
+
36
+ ### 1c. Phase Artifacts
37
+
38
+ ```bash
39
+ find .planning/phases -name "*-SUMMARY.md" -newer .planning/STATE.md 2>/dev/null
40
+ find .planning/phases -name "*-UAT.md" -newer .planning/STATE.md 2>/dev/null
41
+ find .planning/phases -name "*-VERIFICATION.md" -newer .planning/STATE.md 2>/dev/null
42
+ ```
43
+
44
+ ### 1d. Previous Reports
45
+
46
+ ```bash
47
+ ls -la .planning/reports/SESSION_REPORT*.md 2>/dev/null || echo "No previous reports"
48
+ ```
49
+
50
+ ## Step 2: Generate Report
51
+
52
+ ```bash
53
+ node -e "require('fs').mkdirSync('.planning/reports',{recursive:true})"
54
+ ```
55
+
56
+ Write `.planning/reports/SESSION-[YYYYMMDD].md`:
57
+
58
+ ```markdown
59
+ # Session Report
60
+
61
+ **Generated:** [timestamp]
62
+ **Project:** [from PROJECT.md title or directory name]
63
+ **Milestone:** [N] — [milestone name]
64
+
65
+ ---
66
+
67
+ ## Session Summary
68
+
69
+ **Duration:** [estimated from first to last commit timestamp, or "Single session"]
70
+ **Phase Progress:** [from STATE.md]
71
+ **Plans Executed:** [count of summaries written this session]
72
+ **Commits Made:** [count from git log]
73
+
74
+ ## Work Performed
75
+
76
+ | Phase | Plans | Status | Key Deliverables |
77
+ |-------|-------|--------|-----------------|
78
+ | [N] | [IDs] | [complete/partial] | [what was built] |
79
+
80
+ ## Decisions Made
81
+
82
+ [Decisions captured during this session, from STATE.md or DECISIONS.md changes]
83
+
84
+ ## Issues Encountered
85
+
86
+ [Any blockers, bugs, or deviations noted in SUMMARYs]
87
+
88
+ ## Files Changed
89
+
90
+ [Top 10 most-changed files from git diff --stat]
91
+
92
+ ---
93
+
94
+ ## Next Steps
95
+
96
+ [What STATE.md says is next]
97
+
98
+ ---
99
+
100
+ *Generated by learnship session-report*
101
+ ```
102
+
103
+ ## Step 3: Commit and Present
104
+
105
+ ```bash
106
+ git add .planning/reports/
107
+ git commit -m "docs: session report [date]"
108
+ ```
109
+
110
+ ```
111
+ learnship > SESSION REPORT COMPLETE
112
+
113
+ Report: .planning/reports/SESSION-[date].md
114
+ Duration: [estimate]
115
+ Commits: [N]
116
+ Plans completed: [M]
117
+
118
+ Share this report with stakeholders or use it for team standups.
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Learning Checkpoint
124
+
125
+ Read `learning_mode` from `.planning/config.json`.
126
+
127
+ **If `auto`:**
128
+
129
+ > **Learning moment:** End of session is a natural reflection point:
130
+ >
131
+ > `@agentic-learning reflect` — What was the most valuable thing accomplished this session? What would you do differently? Structured reflection at session boundaries builds compounding insight.
132
+
133
+ **If `manual`:** Add quietly: *"Tip: `@agentic-learning reflect` to consolidate lessons from this session."*
@@ -18,11 +18,10 @@ If missing, create from template:
18
18
  ```bash
19
19
  cp templates/config.json .planning/config.json 2>/dev/null || cat > .planning/config.json << 'EOF'
20
20
  {
21
- "mode": "yolo",
21
+ "mode": "interactive",
22
22
  "granularity": "standard",
23
23
  "model_profile": "balanced",
24
24
  "learning_mode": "auto",
25
- "parallelization": false,
26
25
  "test_first": false,
27
26
  "planning": {
28
27
  "commit_docs": true,
@@ -35,7 +34,30 @@ cp templates/config.json .planning/config.json 2>/dev/null || cat > .planning/co
35
34
  "verifier": true,
36
35
  "validation": true,
37
36
  "review": true,
38
- "solutions_search": true
37
+ "solutions_search": true,
38
+ "security_enforcement": true,
39
+ "discuss_mode": "discuss",
40
+ "tdd_mode": false
41
+ },
42
+ "parallelization": {
43
+ "enabled": false,
44
+ "plan_level": true,
45
+ "task_level": false,
46
+ "max_concurrent_agents": 5,
47
+ "min_plans_for_parallel": 2
48
+ },
49
+ "gates": {
50
+ "confirm_project": true,
51
+ "confirm_phases": true,
52
+ "confirm_roadmap": true,
53
+ "confirm_plan": true,
54
+ "execute_next_plan": true,
55
+ "issues_review": true,
56
+ "confirm_transition": true
57
+ },
58
+ "safety": {
59
+ "always_confirm_destructive": true,
60
+ "always_confirm_external_services": true
39
61
  },
40
62
  "review": {
41
63
  "auto_after_verify": false
@@ -45,6 +67,9 @@ cp templates/config.json .planning/config.json 2>/dev/null || cat > .planning/co
45
67
  "conventional_commits": true,
46
68
  "pr_template": true
47
69
  },
70
+ "hooks": {
71
+ "context_warnings": true
72
+ },
48
73
  "git": {
49
74
  "branching_strategy": "none",
50
75
  "phase_branch_template": "phase-{phase}-{slug}",
@@ -84,12 +109,16 @@ Current configuration:
84
109
  [9] Test validation: [on/off]
85
110
  [10] Review workflow: [on/off]
86
111
  [11] Solutions search: [on/off]
87
- [12] Auto-review after verify: [on/off]
88
- [13] Ship: auto-test: [on/off]
89
- [14] Ship: conventional commits: [on/off]
90
- [15] Ship: PR template: [on/off]
91
- [16] Git branching: [current] (none | phase | milestone)
92
- [17] Commit docs: [on/off]
112
+ [12] Security enforcement: [on/off]
113
+ [13] Auto-review after verify: [on/off]
114
+ [14] Ship: auto-test: [on/off]
115
+ [15] Ship: conventional commits: [on/off]
116
+ [16] Ship: PR template: [on/off]
117
+ [17] Parallelization: [on/off] (max agents: [N])
118
+ [18] Git branching: [current] (none | phase | milestone)
119
+ [19] Commit docs: [on/off]
120
+ [20] Safety: confirm destructive: [on/off]
121
+ [21] Context warnings: [on/off]
93
122
 
94
123
  Enter a number to change a setting, or 'done' to save.
95
124
  ```
@@ -222,45 +251,10 @@ Current: [current]. New value? (on/off)
222
251
 
223
252
  ## Step 5: Save Config
224
253
 
225
- After user types "done", write the updated config:
254
+ After user types "done", read the current config, apply all changes, and write the complete updated JSON. Preserve any fields not shown in the menu (gates, hooks, etc.) — never drop fields the user didn't modify.
226
255
 
227
256
  ```bash
228
- cat > .planning/config.json << EOF
229
- {
230
- "mode": "[value]",
231
- "granularity": "[value]",
232
- "model_profile": "[value]",
233
- "learning_mode": "[value]",
234
- "parallelization": [true/false],
235
- "test_first": [true/false],
236
- "planning": {
237
- "commit_docs": [true/false],
238
- "commit_mode": "[auto/manual]",
239
- "search_gitignored": false
240
- },
241
- "workflow": {
242
- "research": [true/false],
243
- "plan_check": [true/false],
244
- "verifier": [true/false],
245
- "validation": [true/false],
246
- "review": [true/false],
247
- "solutions_search": [true/false]
248
- },
249
- "review": {
250
- "auto_after_verify": [true/false]
251
- },
252
- "ship": {
253
- "auto_test": [true/false],
254
- "conventional_commits": [true/false],
255
- "pr_template": [true/false]
256
- },
257
- "git": {
258
- "branching_strategy": "[value]",
259
- "phase_branch_template": "phase-{phase}-{slug}",
260
- "milestone_branch_template": "{milestone}-{slug}"
261
- }
262
- }
263
- EOF
257
+ node -e "const fs=require('fs');const c=JSON.parse(fs.readFileSync('.planning/config.json','utf8'));/* apply changes to c */;fs.writeFileSync('.planning/config.json',JSON.stringify(c,null,2)+'\n');"
264
258
  ```
265
259
 
266
260
  ## Step 6: Commit
@@ -187,6 +187,8 @@ or patterns while context is fresh.
187
187
  ▶ Next steps:
188
188
  - Review the PR and request reviews
189
189
  - /compound — capture learnings from this work
190
+ - /session-report — generate a session summary for stakeholders
191
+ - /extract-learnings [N] — capture decisions, lessons, patterns from this phase
190
192
  ```
191
193
 
192
194
  ---
@@ -0,0 +1,151 @@
1
+ ---
2
+ description: Safe git revert for phase or plan commits — preserves history, checks dependencies
3
+ ---
4
+
5
+ # Undo
6
+
7
+ Safe git revert workflow. Rolls back phase or plan commits using git revert (NEVER git reset) to preserve history. Includes dependency checks and a confirmation gate.
8
+
9
+ **Usage:**
10
+ - `undo --last N` — show last N commits for interactive selection
11
+ - `undo --phase NN` — revert all commits for phase NN
12
+ - `undo --plan NN-MM` — revert all commits for plan NN-MM
13
+
14
+ ## Step 1: Parse Arguments
15
+
16
+ Parse for the undo mode:
17
+
18
+ - `--last N` — MODE=last, COUNT=N (default 10 if N missing)
19
+ - `--phase NN` — MODE=phase, TARGET_PHASE=NN
20
+ - `--plan NN-MM` — MODE=plan, TARGET_PLAN=NN-MM
21
+
22
+ If no valid argument, display usage and exit.
23
+
24
+ ## Step 2: Gather Commits
25
+
26
+ **MODE=last:**
27
+
28
+ ```bash
29
+ git log --oneline --no-merges -${COUNT}
30
+ ```
31
+
32
+ Filter for conventional commits matching `type(scope): message` pattern. Display numbered list. Ask user to select which commits to revert (numbers or "all").
33
+
34
+ **MODE=phase:**
35
+
36
+ ```bash
37
+ git log --oneline --no-merges --all --grep="(${TARGET_PHASE})" | head -30
38
+ git log --oneline --no-merges --all --grep="phase-${TARGET_PHASE}" | head -30
39
+ ```
40
+
41
+ Collect all commits whose scope references the target phase.
42
+
43
+ **MODE=plan:**
44
+
45
+ ```bash
46
+ git log --oneline --no-merges --all --grep="(${TARGET_PLAN})" | head -20
47
+ ```
48
+
49
+ Collect all commits whose scope references the target plan.
50
+
51
+ If no commits found: "No commits found for [target]. Check the phase/plan number."
52
+
53
+ ## Step 3: Dependency Check
54
+
55
+ For each commit to be reverted, check if later commits depend on the files it modified:
56
+
57
+ ```bash
58
+ for COMMIT in $COMMITS; do
59
+ FILES=$(git diff-tree --no-commit-id --name-only -r $COMMIT)
60
+ for FILE in $FILES; do
61
+ LATER=$(git log --oneline ${COMMIT}..HEAD -- "$FILE" | head -5)
62
+ if [ -n "$LATER" ]; then
63
+ echo "WARNING: $FILE was modified in later commits:"
64
+ echo "$LATER"
65
+ fi
66
+ done
67
+ done
68
+ ```
69
+
70
+ If dependencies found, warn:
71
+ ```
72
+ WARNING: These commits have downstream dependencies.
73
+ Reverting may break later work. Files affected:
74
+
75
+ - [file]: modified in [N] later commits
76
+
77
+ Proceed anyway? [Yes, revert] / [No, cancel]
78
+ ```
79
+
80
+ ## Step 4: Confirmation Gate
81
+
82
+ Display the revert plan:
83
+ ```
84
+ Commits to revert ([N] total):
85
+
86
+ [hash] [message]
87
+ [hash] [message]
88
+
89
+ This will create [N] new revert commits preserving full history.
90
+
91
+ [Confirm revert] / [Cancel]
92
+ ```
93
+
94
+ Wait for explicit confirmation.
95
+
96
+ ## Step 5: Execute Revert
97
+
98
+ For each commit in reverse chronological order:
99
+
100
+ ```bash
101
+ git revert --no-commit [hash]
102
+ ```
103
+
104
+ After all reverts staged:
105
+
106
+ ```bash
107
+ git commit -m "revert([scope]): undo [description]
108
+
109
+ Reverted commits:
110
+ - [hash]: [message]
111
+ - [hash]: [message]"
112
+ ```
113
+
114
+ ## Step 6: Update State
115
+
116
+ If `.planning/STATE.md` exists, add a note about the revert:
117
+
118
+ ```markdown
119
+ ### Revert Log
120
+ - [date]: Reverted [N] commits for [target] — [reason if provided]
121
+ ```
122
+
123
+ ```bash
124
+ git add .planning/STATE.md
125
+ git commit -m "docs(state): record revert"
126
+ ```
127
+
128
+ ## Step 7: Report
129
+
130
+ ```
131
+ learnship > UNDO COMPLETE
132
+
133
+ Reverted [N] commits for [target].
134
+ New revert commit: [hash]
135
+
136
+ All original commits preserved in history.
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Learning Checkpoint
142
+
143
+ Read `learning_mode` from `.planning/config.json`.
144
+
145
+ **If `auto`:**
146
+
147
+ > **Learning moment:** Needing to undo is a signal worth examining:
148
+ >
149
+ > `@agentic-learning either-or` — What led to needing the undo? Was it a plan deficiency, an execution error, or a changed requirement? Log the reasoning so the pattern is visible next time.
150
+
151
+ **If `manual`:** Add quietly: *"Tip: `@agentic-learning either-or` to log why the undo was needed."*