wtf-p 0.4.0 → 0.5.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 (175) hide show
  1. package/README.md +146 -226
  2. package/bin/commands/doctor.js +88 -2
  3. package/bin/commands/install-logic.js +121 -26
  4. package/bin/commands/status.js +22 -4
  5. package/bin/commands/update.js +5 -4
  6. package/bin/install.js +66 -26
  7. package/bin/lib/checkpoint.js +183 -0
  8. package/bin/lib/context-primer.js +214 -0
  9. package/bin/lib/manifest.js +62 -2
  10. package/bin/lib/utils.js +22 -1
  11. package/bin/uninstall.js +270 -111
  12. package/core/write-the-f-paper/references/agent-model-matrix.md +62 -0
  13. package/core/write-the-f-paper/references/checkpoints.md +160 -9
  14. package/core/write-the-f-paper/references/context-fidelity.md +153 -0
  15. package/core/write-the-f-paper/references/deviation-rules.md +150 -0
  16. package/core/write-the-f-paper/references/git-integration.md +80 -0
  17. package/core/write-the-f-paper/references/orchestrator-pattern.md +167 -0
  18. package/core/write-the-f-paper/references/planning-config.md +135 -0
  19. package/core/write-the-f-paper/references/ui-brand.md +186 -0
  20. package/core/write-the-f-paper/templates/UAT.md +80 -0
  21. package/core/write-the-f-paper/templates/base-prefs.yaml +42 -0
  22. package/core/write-the-f-paper/templates/config.json +31 -5
  23. package/core/write-the-f-paper/workflows/create-outline.wcn.md +1 -1
  24. package/core/write-the-f-paper/workflows/execute-outline.md +163 -0
  25. package/core/write-the-f-paper/workflows/execute-outline.wcn.md +73 -0
  26. package/core/write-the-f-paper/workflows/execute-section.wcn.md +141 -169
  27. package/core/write-the-f-paper/workflows/plan-section.wcn.md +96 -103
  28. package/core/write-the-f-paper/workflows/research-gap.md +27 -3
  29. package/core/write-the-f-paper/workflows/research-gap.wcn.md +18 -1
  30. package/core/write-the-f-paper/workflows/verify-work.md +251 -0
  31. package/core/write-the-f-paper/workflows/verify-work.wcn.md +74 -0
  32. package/package.json +19 -7
  33. package/vendors/claude/.claude-plugin/plugin.json +2 -2
  34. package/vendors/claude/agents/wtfp/argument-verifier.md +189 -0
  35. package/vendors/claude/agents/wtfp/citation-expert.md +1 -1
  36. package/vendors/claude/agents/wtfp/citation-formatter.md +1 -1
  37. package/vendors/claude/agents/wtfp/coherence-checker.md +167 -0
  38. package/vendors/claude/agents/wtfp/outliner.md +259 -0
  39. package/vendors/claude/agents/wtfp/plan-checker.md +249 -0
  40. package/vendors/claude/agents/wtfp/prose-polisher.md +166 -0
  41. package/vendors/claude/agents/wtfp/research-synthesizer.md +215 -0
  42. package/vendors/claude/agents/wtfp/section-planner.md +364 -0
  43. package/vendors/claude/agents/wtfp/section-reviewer.md +182 -0
  44. package/vendors/claude/agents/wtfp/section-writer.md +312 -0
  45. package/vendors/claude/commands/wtfp/add-todo.md +108 -0
  46. package/vendors/claude/commands/wtfp/analyze-bib.md +58 -236
  47. package/vendors/claude/commands/wtfp/audit-milestone.md +286 -0
  48. package/vendors/claude/commands/wtfp/check-refs.md +60 -133
  49. package/vendors/claude/commands/wtfp/check-todos.md +152 -0
  50. package/vendors/claude/commands/wtfp/checkpoint.md +105 -0
  51. package/vendors/claude/commands/wtfp/contribute.md +1 -1
  52. package/vendors/claude/commands/wtfp/create-outline.md +109 -195
  53. package/vendors/claude/commands/wtfp/create-poster.md +1 -1
  54. package/vendors/claude/commands/wtfp/create-slides.md +1 -1
  55. package/vendors/claude/commands/wtfp/discuss-section.md +1 -1
  56. package/vendors/claude/commands/wtfp/execute-outline.md +257 -0
  57. package/vendors/claude/commands/wtfp/export-latex.md +1 -1
  58. package/vendors/claude/commands/wtfp/help.md +174 -280
  59. package/vendors/claude/commands/wtfp/insert-section.md +1 -1
  60. package/vendors/claude/commands/wtfp/list-assumptions.md +1 -1
  61. package/vendors/claude/commands/wtfp/map-project.md +35 -124
  62. package/vendors/claude/commands/wtfp/new-paper.md +85 -320
  63. package/vendors/claude/commands/wtfp/pause-writing.md +1 -1
  64. package/vendors/claude/commands/wtfp/plan-milestone-gaps.md +255 -0
  65. package/vendors/claude/commands/wtfp/plan-revision.md +1 -1
  66. package/vendors/claude/commands/wtfp/plan-section.md +165 -190
  67. package/vendors/claude/commands/wtfp/polish-prose.md +66 -118
  68. package/vendors/claude/commands/wtfp/progress.md +82 -254
  69. package/vendors/claude/commands/wtfp/quick.md +107 -0
  70. package/vendors/claude/commands/wtfp/remove-section.md +1 -1
  71. package/vendors/claude/commands/wtfp/report-bug.md +1 -1
  72. package/vendors/claude/commands/wtfp/request-feature.md +1 -1
  73. package/vendors/claude/commands/wtfp/research-gap.md +138 -150
  74. package/vendors/claude/commands/wtfp/resume-writing.md +1 -1
  75. package/vendors/claude/commands/wtfp/review-section.md +55 -333
  76. package/vendors/claude/commands/wtfp/settings.md +197 -0
  77. package/vendors/claude/commands/wtfp/submit-milestone.md +248 -99
  78. package/vendors/claude/commands/wtfp/update.md +112 -0
  79. package/vendors/claude/commands/wtfp/verify-work.md +254 -0
  80. package/vendors/claude/commands/wtfp/write-section.md +144 -180
  81. package/vendors/gemini/agents/wtfp/argument-verifier.md +184 -0
  82. package/vendors/gemini/agents/wtfp/citation-expert.md +41 -0
  83. package/vendors/gemini/agents/wtfp/citation-formatter.md +38 -0
  84. package/vendors/gemini/agents/wtfp/coherence-checker.md +162 -0
  85. package/vendors/gemini/agents/wtfp/outliner.md +252 -0
  86. package/vendors/gemini/agents/wtfp/plan-checker.md +244 -0
  87. package/vendors/gemini/agents/wtfp/prose-polisher.md +158 -0
  88. package/vendors/gemini/agents/wtfp/research-synthesizer.md +205 -0
  89. package/vendors/gemini/agents/wtfp/section-planner.md +355 -0
  90. package/vendors/gemini/agents/wtfp/section-reviewer.md +175 -0
  91. package/vendors/gemini/agents/wtfp/section-writer.md +304 -0
  92. package/vendors/gemini/commands/wtfp/add-todo.toml +102 -0
  93. package/vendors/gemini/commands/wtfp/analyze-bib.toml +126 -0
  94. package/vendors/gemini/commands/wtfp/audit-milestone.toml +278 -0
  95. package/vendors/gemini/commands/wtfp/check-refs.toml +123 -0
  96. package/vendors/gemini/commands/wtfp/check-todos.toml +145 -0
  97. package/vendors/gemini/commands/wtfp/checkpoint.toml +96 -0
  98. package/vendors/gemini/commands/wtfp/contribute.toml +269 -0
  99. package/vendors/gemini/commands/wtfp/create-outline.toml +180 -0
  100. package/vendors/gemini/commands/wtfp/create-poster.toml +36 -0
  101. package/vendors/gemini/commands/wtfp/create-slides.toml +35 -0
  102. package/vendors/gemini/commands/wtfp/discuss-section.toml +62 -0
  103. package/vendors/gemini/commands/wtfp/execute-outline.toml +247 -0
  104. package/vendors/gemini/commands/wtfp/export-latex.toml +209 -0
  105. package/vendors/gemini/commands/wtfp/help.toml +184 -0
  106. package/vendors/gemini/commands/wtfp/insert-section.toml +123 -0
  107. package/vendors/gemini/commands/wtfp/list-assumptions.toml +104 -0
  108. package/vendors/gemini/commands/wtfp/map-project.toml +99 -0
  109. package/vendors/gemini/commands/wtfp/new-paper.toml +160 -0
  110. package/vendors/gemini/commands/wtfp/pause-writing.toml +140 -0
  111. package/vendors/gemini/commands/wtfp/plan-milestone-gaps.toml +249 -0
  112. package/vendors/gemini/commands/wtfp/plan-revision.toml +171 -0
  113. package/vendors/gemini/commands/wtfp/plan-section.toml +212 -0
  114. package/vendors/gemini/commands/wtfp/polish-prose.toml +114 -0
  115. package/vendors/gemini/commands/wtfp/progress.toml +145 -0
  116. package/vendors/gemini/commands/wtfp/quick.toml +96 -0
  117. package/vendors/gemini/commands/wtfp/remove-section.toml +140 -0
  118. package/vendors/gemini/commands/wtfp/report-bug.toml +126 -0
  119. package/vendors/gemini/commands/wtfp/request-feature.toml +155 -0
  120. package/vendors/gemini/commands/wtfp/research-gap.toml +214 -0
  121. package/vendors/gemini/commands/wtfp/resume-writing.toml +136 -0
  122. package/vendors/gemini/commands/wtfp/review-section.toml +121 -0
  123. package/vendors/gemini/commands/wtfp/settings.toml +191 -0
  124. package/vendors/gemini/commands/wtfp/submit-milestone.toml +351 -0
  125. package/vendors/gemini/commands/wtfp/update.toml +107 -0
  126. package/vendors/gemini/commands/wtfp/verify-work.toml +245 -0
  127. package/vendors/gemini/commands/wtfp/write-section.toml +228 -0
  128. package/vendors/opencode/agents/wtfp/argument-verifier.md +184 -0
  129. package/vendors/opencode/agents/wtfp/citation-expert.md +41 -0
  130. package/vendors/opencode/agents/wtfp/citation-formatter.md +38 -0
  131. package/vendors/opencode/agents/wtfp/coherence-checker.md +162 -0
  132. package/vendors/opencode/agents/wtfp/outliner.md +252 -0
  133. package/vendors/opencode/agents/wtfp/plan-checker.md +244 -0
  134. package/vendors/opencode/agents/wtfp/prose-polisher.md +158 -0
  135. package/vendors/opencode/agents/wtfp/research-synthesizer.md +205 -0
  136. package/vendors/opencode/agents/wtfp/section-planner.md +355 -0
  137. package/vendors/opencode/agents/wtfp/section-reviewer.md +175 -0
  138. package/vendors/opencode/agents/wtfp/section-writer.md +304 -0
  139. package/vendors/opencode/commands/wtfp/add-todo.md +103 -0
  140. package/vendors/opencode/commands/wtfp/analyze-bib.md +127 -0
  141. package/vendors/opencode/commands/wtfp/audit-milestone.md +279 -0
  142. package/vendors/opencode/commands/wtfp/check-refs.md +124 -0
  143. package/vendors/opencode/commands/wtfp/check-todos.md +146 -0
  144. package/vendors/opencode/commands/wtfp/checkpoint.md +97 -0
  145. package/vendors/opencode/commands/wtfp/contribute.md +266 -0
  146. package/vendors/opencode/commands/wtfp/create-outline.md +181 -0
  147. package/vendors/opencode/commands/wtfp/create-poster.md +37 -0
  148. package/vendors/opencode/commands/wtfp/create-slides.md +36 -0
  149. package/vendors/opencode/commands/wtfp/discuss-section.md +63 -0
  150. package/vendors/opencode/commands/wtfp/execute-outline.md +248 -0
  151. package/vendors/opencode/commands/wtfp/export-latex.md +210 -0
  152. package/vendors/opencode/commands/wtfp/help.md +185 -0
  153. package/vendors/opencode/commands/wtfp/insert-section.md +124 -0
  154. package/vendors/opencode/commands/wtfp/list-assumptions.md +105 -0
  155. package/vendors/opencode/commands/wtfp/map-project.md +100 -0
  156. package/vendors/opencode/commands/wtfp/new-paper.md +161 -0
  157. package/vendors/opencode/commands/wtfp/pause-writing.md +141 -0
  158. package/vendors/opencode/commands/wtfp/plan-milestone-gaps.md +250 -0
  159. package/vendors/opencode/commands/wtfp/plan-revision.md +174 -0
  160. package/vendors/opencode/commands/wtfp/plan-section.md +214 -0
  161. package/vendors/opencode/commands/wtfp/polish-prose.md +115 -0
  162. package/vendors/opencode/commands/wtfp/progress.md +146 -0
  163. package/vendors/opencode/commands/wtfp/quick.md +97 -0
  164. package/vendors/opencode/commands/wtfp/remove-section.md +141 -0
  165. package/vendors/opencode/commands/wtfp/report-bug.md +127 -0
  166. package/vendors/opencode/commands/wtfp/request-feature.md +156 -0
  167. package/vendors/opencode/commands/wtfp/research-gap.md +215 -0
  168. package/vendors/opencode/commands/wtfp/resume-writing.md +137 -0
  169. package/vendors/opencode/commands/wtfp/review-section.md +123 -0
  170. package/vendors/opencode/commands/wtfp/settings.md +192 -0
  171. package/vendors/opencode/commands/wtfp/submit-milestone.md +352 -0
  172. package/vendors/opencode/commands/wtfp/update.md +108 -0
  173. package/vendors/opencode/commands/wtfp/verify-work.md +246 -0
  174. package/vendors/opencode/commands/wtfp/write-section.md +228 -0
  175. package/vendors/claude/agents/wtfp/citation-retriever.md +0 -31
@@ -0,0 +1,254 @@
1
+ ---
2
+ name: wtfp:verify-work
3
+ description: Test a written section against its plan, one check at a time
4
+ argument-hint: "[section-number]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Write
9
+ - Glob
10
+ - Grep
11
+ - AskUserQuestion
12
+ ---
13
+
14
+ <execution_context>
15
+ @~/.claude/write-the-f-paper/workflows/verify-work.md
16
+ @~/.claude/write-the-f-paper/references/ui-brand.md
17
+ </execution_context>
18
+
19
+ <objective>
20
+ Conversational verification of a written section. Presents one test at a time.
21
+ Persists state in UAT.md that survives /clear.
22
+
23
+ **Orchestrator role:** Load UAT.md (or create from PLAN.md + argument-map),
24
+ present next pending test, record result, update UAT.md, route on completion.
25
+
26
+ **Why no subagent:** Verification is a conversation loop, not a creative task.
27
+ The orchestrator reads artifacts, extracts tests, and guides the user through
28
+ each one. State persists via UAT.md file reads/writes.
29
+ </objective>
30
+
31
+ <context>
32
+ Section: $ARGUMENTS (section number or name)
33
+ </context>
34
+
35
+ <process>
36
+
37
+ ## 1. Validate Environment
38
+
39
+ ```bash
40
+ [ ! -f ".planning/PROJECT.md" ] && echo "ERROR: No project initialized. Run /wtfp:new-paper first." && exit 1
41
+ ```
42
+
43
+ Resolve section from $ARGUMENTS:
44
+ - If numeric (e.g., "3"): find `.planning/sections/03-*`
45
+ - If name (e.g., "methods"): find `.planning/sections/*-methods*`
46
+
47
+ ```bash
48
+ SECTION_DIR=$(ls -d .planning/sections/${SECTION}-* 2>/dev/null | head -1)
49
+ [ -z "$SECTION_DIR" ] && echo "ERROR: Section '$ARGUMENTS' not found in .planning/sections/" && exit 1
50
+ ```
51
+
52
+ Verify section was written (SUMMARY.md exists):
53
+
54
+ ```bash
55
+ ls "$SECTION_DIR"/*-SUMMARY.md 2>/dev/null
56
+ ```
57
+
58
+ If no SUMMARY.md:
59
+ ```
60
+ Section has not been written yet. Cannot verify unwritten content.
61
+
62
+ Write it first: /wtfp:write-section [plan-path]
63
+ ```
64
+
65
+ ## 2. Load or Resume UAT
66
+
67
+ ```bash
68
+ UAT_PATH="$SECTION_DIR/UAT.md"
69
+ ```
70
+
71
+ **If UAT.md exists (resuming):**
72
+
73
+ Read UAT.md. Count tests by status:
74
+ - Total tests
75
+ - Passed (result: pass)
76
+ - Skipped (result: skip)
77
+ - Issues (result: issue)
78
+ - Pending (result: pending)
79
+
80
+ Report:
81
+ ```
82
+ Resuming verification for Section [X]: [Name]
83
+ [completed]/[total] tests evaluated ([pending] remaining)
84
+ ```
85
+
86
+ Find the first test with `result: pending` and proceed to step 3.
87
+
88
+ **If UAT.md does not exist (starting fresh):**
89
+
90
+ Derive tests from two sources:
91
+
92
+ **Source 1: PLAN.md success criteria**
93
+ ```bash
94
+ cat "$SECTION_DIR"/*-PLAN.md
95
+ ```
96
+ Extract each `- [ ]` item from `<success_criteria>`. Each becomes a test tagged `[plan]`.
97
+
98
+ **Source 2: Argument-map claims**
99
+ ```bash
100
+ cat .planning/structure/argument-map.md 2>/dev/null
101
+ ```
102
+ Find claims assigned to this section. Each becomes a test tagged `[argument-map]`.
103
+
104
+ Write UAT.md:
105
+
106
+ ```yaml
107
+ ---
108
+ status: testing
109
+ section: [section-dir-name]
110
+ started: [ISO timestamp]
111
+ last_test: 0
112
+ ---
113
+ ```
114
+
115
+ Followed by `## Tests` with all derived tests (numbered, pending), `## Summary` with initial counts, empty `## Gaps`.
116
+
117
+ Report:
118
+ ```
119
+ Starting verification for Section [X]: [Name]
120
+ [total] tests derived ([plan-count] from plan, [map-count] from argument-map)
121
+ ```
122
+
123
+ ## 3. Present Next Test
124
+
125
+ Find the next test with `result: pending`.
126
+
127
+ Display using branded checkpoint box:
128
+
129
+ ```
130
+ ════════════════════════════════════════
131
+ VERIFICATION: Test {N} of {total}
132
+ ════════════════════════════════════════
133
+
134
+ Source: {[plan] or [argument-map]}
135
+
136
+ {The criterion or claim being verified}
137
+
138
+ Check: Does this section satisfy the above?
139
+ ════════════════════════════════════════
140
+ ```
141
+
142
+ Use AskUserQuestion:
143
+ - header: "Verification"
144
+ - question: "[The criterion or claim text]"
145
+ - options:
146
+ - "Pass - meets criteria"
147
+ - "Skip - not applicable"
148
+ - "Issue - describe the problem"
149
+
150
+ ## 4. Record and Continue
151
+
152
+ Update UAT.md with the result:
153
+ - Set `result:` to pass, skip, or issue
154
+ - Set `reason:` to user explanation (empty for pass/skip unless user elaborated)
155
+ - Update `last_test` in frontmatter
156
+
157
+ **If "Issue" selected:**
158
+
159
+ Ask for the problem description (user already selected "Issue" so get details):
160
+
161
+ Then ask for severity:
162
+
163
+ Use AskUserQuestion:
164
+ - header: "Severity"
165
+ - question: "How severe is this issue?"
166
+ - options:
167
+ - "Major - undermines argument, must fix"
168
+ - "Minor - weakens but doesn't invalidate"
169
+ - "Cosmetic - polish issue, fix during final pass"
170
+
171
+ Add to `## Gaps` section:
172
+ ```markdown
173
+ - claim: "[criterion or claim text]"
174
+ status: issue
175
+ reason: "[user's description]"
176
+ severity: [major|minor|cosmetic]
177
+ ```
178
+
179
+ **Write UAT.md to disk** after each result (persistence).
180
+
181
+ **If more pending tests:** Return to step 3.
182
+
183
+ **If all tests evaluated:** Proceed to step 5.
184
+
185
+ ## 5. Route on Completion
186
+
187
+ Set `status: complete` in UAT.md frontmatter. Calculate final counts.
188
+
189
+ **If no issues (all pass/skip):**
190
+
191
+ ```
192
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
193
+ WTF-P ► VERIFICATION PASSED
194
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
195
+
196
+ Section [X]: [Name]
197
+ Tests: [passed] passed, [skipped] skipped, 0 issues
198
+
199
+ ───────────────────────────────────────────
200
+
201
+ ## ▶ Next Up
202
+
203
+ **Check progress** — see overall paper status
204
+
205
+ `/wtfp:progress`
206
+
207
+ <sub>`/clear` first → fresh context window</sub>
208
+
209
+ ───────────────────────────────────────────
210
+ ```
211
+
212
+ **If issues found:**
213
+
214
+ ```
215
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
216
+ WTF-P ► VERIFICATION: ISSUES FOUND
217
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
218
+
219
+ Section [X]: [Name]
220
+ Tests: [passed] passed, [issues] issues, [skipped] skipped
221
+
222
+ ## Gap Summary
223
+
224
+ | # | Claim/Criterion | Severity | Reason |
225
+ |---|-----------------|----------|--------|
226
+ | 1 | [text] | major | [reason] |
227
+ | 2 | [text] | minor | [reason] |
228
+
229
+ ───────────────────────────────────────────
230
+
231
+ ## ▶ Next Up
232
+
233
+ **Plan revision** — create fix plan for identified issues
234
+
235
+ `/wtfp:plan-revision [section]`
236
+
237
+ <sub>`/clear` first → fresh context window</sub>
238
+
239
+ ───────────────────────────────────────────
240
+ ```
241
+
242
+ </process>
243
+
244
+ <success_criteria>
245
+ - [ ] Section resolved from arguments
246
+ - [ ] SUMMARY.md validated (section was written)
247
+ - [ ] Tests derived from PLAN.md success_criteria AND argument-map.md claims
248
+ - [ ] UAT.md created or resumed
249
+ - [ ] Each test presented one at a time
250
+ - [ ] Results recorded with persistence (survives /clear)
251
+ - [ ] Issues classified by severity
252
+ - [ ] Routes to plan-revision when issues found
253
+ - [ ] Routes to progress when verification passes
254
+ </success_criteria>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: wtfp:write-section
3
- description: Execute a PLAN.md to write section content
3
+ description: Write a section by executing its plan
4
4
  argument-hint: "[path-to-PLAN.md]"
5
5
  allowed-tools:
6
6
  - Read
@@ -9,265 +9,229 @@ allowed-tools:
9
9
  - Edit
10
10
  - Glob
11
11
  - Grep
12
- - AskUserQuestion
13
12
  - Task
13
+ - AskUserQuestion
14
14
  ---
15
15
 
16
+ <execution_context>
17
+ @~/.claude/write-the-f-paper/workflows/execute-section.md
18
+ @~/.claude/write-the-f-paper/references/git-integration.md
19
+ </execution_context>
20
+
16
21
  <objective>
17
22
  Execute a PLAN.md file to write section content.
18
23
 
19
- Takes the path to a PLAN.md file and executes its tasks sequentially, writing the actual paper content.
24
+ **Orchestrator role:** Validate plan, resolve model profile, read context files, spawn section-writer agent, optionally run argument-verifier post-write, route based on verification, present results.
20
25
 
21
- Creates SUMMARY.md documenting what was written and updates STATE.md with progress.
26
+ **Why subagents:** Writing burns context fast. Fresh agent gets peak prose quality. Verification in fresh context catches what writer missed.
22
27
  </objective>
23
28
 
24
- <execution_context>
25
- @~/.claude/write-the-f-paper/workflows/execute-section.md
26
- @~/.claude/write-the-f-paper/templates/summary.md
27
- @~/.claude/write-the-f-paper/references/git-integration.md
28
- </execution_context>
29
+ <context>
30
+ Plan path: $ARGUMENTS (path to a PLAN.md file)
31
+ </context>
29
32
 
30
33
  <process>
31
34
 
32
- <step name="verify">
33
- **Verify plan exists:**
35
+ ## 1. Validate Environment and Resolve Model Profile
34
36
 
35
37
  ```bash
36
38
  [ ! -f "$ARGUMENTS" ] && echo "ERROR: Plan not found at $ARGUMENTS" && exit 1
39
+ ls .planning/ 2>/dev/null
37
40
  ```
38
41
 
39
- Check plan hasn't already been executed (SUMMARY.md exists):
42
+ **Resolve model profile:**
40
43
  ```bash
41
- SUMMARY_PATH="${ARGUMENTS/PLAN.md/SUMMARY.md}"
42
- [ -f "$SUMMARY_PATH" ] && echo "WARNING: This plan already has a SUMMARY.md. Re-executing will overwrite."
44
+ MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
43
45
  ```
44
46
 
45
- </step>
47
+ **Model lookup table:**
46
48
 
47
- <step name="load">
48
- **Load plan and all context:**
49
+ | Agent | quality | balanced | budget |
50
+ |-------|---------|----------|--------|
51
+ | section-writer | opus | sonnet | sonnet |
52
+ | argument-verifier | sonnet | sonnet | haiku |
49
53
 
50
- 1. Read the PLAN.md file specified in $ARGUMENTS
51
- 2. Parse the frontmatter (section, plan, mode, word_target)
52
- 3. Load all @context files referenced in the plan
53
- 4. Read PROJECT.md for core argument
54
- 5. Read argument-map.md for relevant claims
55
- 6. Read any prior section content for continuity
56
- </step>
57
-
58
- <step name="mode_setup">
59
- **Configure for writing mode:**
60
-
61
- Based on `mode` from plan frontmatter:
54
+ **Resolve gate and safety flags:**
55
+ ```bash
56
+ # Gate: confirm_write — skip confirmation if false
57
+ GATE_CONFIRM_WRITE=$(cat .planning/config.json 2>/dev/null | grep -o '"confirm_write"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
62
58
 
63
- **Co-Author Mode:**
64
- - Claude writes draft prose
65
- - User refines afterward
66
- - Output: Full draft text
59
+ # Safety: always_confirm_destructive — force confirmation for destructive ops
60
+ SAFETY_DESTRUCTIVE=$(cat .planning/config.json 2>/dev/null | grep -o '"always_confirm_destructive"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
61
+ ```
67
62
 
68
- **Scaffold Mode:**
69
- - Claude creates detailed outline with key points
70
- - User fills in actual prose
71
- - Output: Structured outline for each paragraph
63
+ Check for existing SUMMARY.md:
64
+ ```bash
65
+ SUMMARY_PATH="${ARGUMENTS/PLAN.md/SUMMARY.md}"
66
+ [ -f "$SUMMARY_PATH" ] && echo "WARNING: SUMMARY.md exists. Re-executing will overwrite."
67
+ ```
72
68
 
73
- **Reviewer Mode:**
74
- - Prompt user to write section
75
- - Claude provides feedback after each chunk
76
- - Output: User's text + Claude's comments
69
+ ## 2. Read Context Files
77
70
 
78
- </step>
71
+ ```bash
72
+ PLAN_CONTENT=$(cat "$ARGUMENTS")
73
+ STATE_CONTENT=$(cat .planning/STATE.md)
74
+ PROJECT_CONTENT=$(cat .planning/PROJECT.md)
75
+ ARGMAP_CONTENT=$(cat .planning/structure/argument-map.md 2>/dev/null)
76
+
77
+ # Derive section dir from plan path
78
+ SECTION_DIR=$(dirname "$ARGUMENTS")
79
+ CONTEXT_CONTENT=$(cat "${SECTION_DIR}"/*-CONTEXT.md 2>/dev/null)
80
+ PRIOR_CONTENT=$(cat paper/*.md 2>/dev/null | head -500)
81
+ ```
79
82
 
80
- <step name="execute_tasks">
81
- **Execute each task in the plan:**
83
+ ## 3. Gate Check: Confirm Before Writing
82
84
 
83
- For each `<task>` in `<tasks>`:
85
+ **If GATE_CONFIRM_WRITE is "true" (default) OR SAFETY_DESTRUCTIVE is "true" and SUMMARY.md exists (re-execution is destructive):**
86
+ Present plan summary to user via AskUserQuestion and wait for confirmation before proceeding.
84
87
 
85
- 1. Read the task requirements (action, target, verify)
86
- 2. Based on mode:
87
- - **Co-Author:** Write the draft content
88
- - **Scaffold:** Create detailed outline
89
- - **Reviewer:** Prompt user to write, then critique
90
- 3. Verify the output meets task criteria
91
- 4. Track word count
92
- 5. Commit after each task (if substantive)
88
+ **If GATE_CONFIRM_WRITE is "false" AND (SAFETY_DESTRUCTIVE is "false" OR no existing SUMMARY.md):**
89
+ Skip confirmation and proceed directly to writing.
93
90
 
94
- **Per-task commit:**
95
- ```bash
96
- git add paper/[section].md # or wherever content lives
97
- git commit -m "$(cat <<'EOF'
98
- write(XX-YY): [task description]
91
+ ## 4. Spawn wtfp-section-writer Agent
99
92
 
100
- [Word count] words for [section]
101
- EOF
102
- )"
93
+ ```
94
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
95
+ WTF-P ► WRITING SECTION
96
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
103
97
  ```
104
98
 
105
- </step>
99
+ Fill prompt with inlined content and spawn:
106
100
 
107
- <step name="deviation_rules">
108
- **Handle deviations during writing:**
101
+ ```
102
+ Task(
103
+ prompt="First, read ~/.claude/agents/wtfp/section-writer.md for your role and instructions.\n\n" + filled_writing_prompt,
104
+ subagent_type="general-purpose",
105
+ model="{writer_model}",
106
+ description="Write Section {X}"
107
+ )
108
+ ```
109
109
 
110
- | Type | Action |
111
- |------|--------|
112
- | Citation needed but not in sources | Flag, continue, note in SUMMARY |
113
- | Argument weak | Note in SUMMARY for revision |
114
- | Word count significantly off | Note in SUMMARY, suggest adjustment |
115
- | Logical gap discovered | Note in SUMMARY, may need ISSUES.md |
116
- | Better structure found | Implement if minor, note if major |
110
+ Writing prompt includes: `<plan>` with full PLAN.md content, `<project_context>` with PROJECT + STATE + argument-map, `<user_decisions>` with CONTEXT_CONTENT, `<prior_content>` with existing paper content for continuity.
117
111
 
118
- **Auto-fix:**
119
- - Minor prose improvements
120
- - Citation format fixes
121
- - Paragraph flow improvements
112
+ ## 5. Handle Writer Return
122
113
 
123
- **Log for later:**
124
- - Missing citations (add to sources/literature.md gap list)
125
- - Argument weaknesses (ISSUES.md)
126
- - Structure suggestions beyond plan scope
127
- </step>
114
+ **`## WRITING COMPLETE`:** Proceed to verification check.
128
115
 
129
- <step name="output_content">
130
- **Write output content:**
116
+ **`## CHECKPOINT REACHED`:** Present to user, get response.
131
117
 
132
- Content goes to `paper/` directory:
133
- - `paper/[section-name].md` - Markdown section content
134
- - Or appended to `paper/paper.md` if single-file format
118
+ **`## WRITING BLOCKED`:** Show blocker, offer options.
135
119
 
136
- Include proper markdown structure:
137
- ```markdown
138
- ## [Section Title]
120
+ ## 6. Goal-Backward Verification (if enabled)
139
121
 
140
- [Content from tasks...]
122
+ ```bash
123
+ WORKFLOW_VERIFIER=$(cat .planning/config.json 2>/dev/null | grep -o '"verifier"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
124
+ ```
141
125
 
142
- ### [Subsection if applicable]
126
+ **If verifier is true:**
143
127
 
144
- [More content...]
128
+ ```bash
129
+ WRITTEN_CONTENT=$(cat paper/*.md 2>/dev/null)
145
130
  ```
146
131
 
147
- Track all files created/modified for SUMMARY.
148
- </step>
132
+ Spawn `wtfp-argument-verifier` with written content + PLAN goals + argument-map.
149
133
 
150
- <step name="summary">
151
- **Create SUMMARY.md:**
134
+ **If VERIFIED:** Proceed to done.
152
135
 
153
- ```markdown
154
- ---
155
- section: XX-name
156
- plan: YY
157
- mode: [co-author/scaffold/reviewer]
158
- word_count: [actual]
159
- word_target: [target]
160
- ---
136
+ **If GAPS_FOUND:** Present gaps to user. Options: fix now, accept, plan revision.
161
137
 
162
- # Section [XX]-[YY] Summary
138
+ **If HUMAN_NEEDED:** Present what needs human review.
163
139
 
164
- ## What Was Written
165
- - [Task 1]: [what was accomplished]
166
- - [Task 2]: [what was accomplished]
167
- - [...]
140
+ ## 6b. Commit with commit_docs Guard
168
141
 
169
- ## Word Count
170
- - Target: [X] words
171
- - Actual: [Y] words
172
- - Variance: [+/- Z]%
142
+ Before any git commit, check commit_docs setting:
173
143
 
174
- ## Files Created/Modified
175
- - paper/[section].md: [description]
144
+ ```bash
145
+ COMMIT_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
146
+ ```
176
147
 
177
- ## Key Points Made
178
- - [Argument 1]
179
- - [Argument 2]
180
- - [...]
148
+ **If commit_docs = "false":**
149
+ - Skip `git add` for any `.planning/` paths
150
+ - Only commit paper content files (e.g., `paper/*.md`)
151
+ - Log: "Skipping planning docs commit (commit_docs: false)"
181
152
 
182
- ## Citations Used
183
- - [citation-key]: [where used]
184
- - [...]
153
+ **If commit_docs = "true" (default):**
154
+ - Include `.planning/` files in commits as normal
185
155
 
186
- ## Decisions Made
187
- | Decision | Rationale |
188
- |----------|-----------|
189
- | [choice] | [why] |
156
+ ## 7. Git Branch Merge (if section branch strategy)
190
157
 
191
- ## Issues Noted
192
- - [Any problems discovered during writing]
193
- - [Gaps that need addressing]
158
+ ```bash
159
+ BRANCH_STRATEGY=$(cat .planning/config.json 2>/dev/null | grep -o '"branching_strategy"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "none")
160
+ CURRENT_BRANCH=$(git branch --show-current 2>/dev/null)
161
+ ```
194
162
 
195
- ## Next Steps
196
- - [What should happen next]
163
+ **If branching_strategy = "section" AND current branch matches `wtfp/section-*`:**
197
164
 
198
- ---
199
- *Written: [timestamp]*
200
- ```
165
+ 1. Read squash_on_merge setting:
166
+ ```bash
167
+ SQUASH=$(cat .planning/config.json 2>/dev/null | grep -o '"squash_on_merge"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "false")
168
+ ```
201
169
 
202
- </step>
170
+ 2. Read base branch stored during plan-section:
171
+ ```bash
172
+ BASE_BRANCH=$(cat .planning/.section_base_branch 2>/dev/null || echo "main")
173
+ ```
203
174
 
204
- <step name="update_state">
205
- **Update STATE.md:**
175
+ 3. Perform merge based on squash setting:
206
176
 
207
- - Update current position
208
- - Add word count to progress
209
- - Note any decisions made
210
- - Log any issues discovered
211
- - Update argument strength assessment
212
- </step>
177
+ **If squash=true:**
178
+ ```bash
179
+ git checkout "$BASE_BRANCH"
180
+ git merge --squash "$CURRENT_BRANCH"
181
+ git commit -m "write(${SECTION}): complete ${SECTION_NAME}"
182
+ ```
213
183
 
214
- <step name="final_commit">
215
- **Final commit:**
184
+ **If squash=false:**
185
+ ```bash
186
+ git checkout "$BASE_BRANCH"
187
+ git merge "$CURRENT_BRANCH" --no-ff -m "merge: section ${SECTION} complete"
188
+ ```
216
189
 
217
- ```bash
218
- git add .planning/sections/XX-name/XX-YY-SUMMARY.md .planning/STATE.md paper/
219
- git commit -m "$(cat <<'EOF'
220
- docs(XX-YY): complete [section name] writing
221
-
222
- [Word count] words written
223
- Mode: [mode]
224
- EOF
225
- )"
226
- ```
190
+ 4. Delete section branch:
191
+ ```bash
192
+ git branch -d "$CURRENT_BRANCH"
193
+ rm -f .planning/.section_base_branch
194
+ ```
227
195
 
228
- </step>
196
+ 5. Log: "Merged section branch: $CURRENT_BRANCH -> $BASE_BRANCH"
229
197
 
230
- <step name="done">
231
- **Present completion:**
198
+ **If branching_strategy = "none" or "submission":** No merge action.
232
199
 
233
- ```
234
- Section written:
200
+ ## 8. Present Final Status
235
201
 
236
- - Content: paper/[section].md ([Y] words)
237
- - Summary: .planning/sections/XX-name/XX-YY-SUMMARY.md
238
- - Progress: [current]/[total] words ([%]%)
202
+ </process>
239
203
 
240
- ## Written
204
+ <offer_next>
241
205
 
242
- [Brief summary of what was written]
206
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
207
+ WTF-P ► SECTION WRITTEN ✓
208
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
243
209
 
244
- ## Issues Noted
210
+ **{Section Name}** — {W} words, mode: {mode}
245
211
 
246
- [Any issues discovered, or "None"]
212
+ Verification: {Verified | Gaps found | Skipped}
247
213
 
248
- ---
214
+ ───────────────────────────────────────────
249
215
 
250
216
  ## ▶ Next Up
251
217
 
252
- [Based on STATE.md - next plan, next section, or review]
218
+ **Review section** — run verification
253
219
 
254
- `/wtfp:[appropriate-command]`
220
+ `/wtfp:review-section {section}`
255
221
 
256
222
  <sub>`/clear` first → fresh context window</sub>
257
223
 
258
- ---
259
- ```
224
+ ───────────────────────────────────────────
260
225
 
261
- </step>
262
-
263
- </process>
226
+ </offer_next>
264
227
 
265
228
  <success_criteria>
266
- - [ ] All tasks in PLAN.md executed
229
+ - [ ] Plan validated and loaded
230
+ - [ ] Section-writer spawned with full context
267
231
  - [ ] Content written to paper/ directory
268
- - [ ] Word count tracked and within tolerance
269
- - [ ] SUMMARY.md created with full documentation
270
- - [ ] STATE.md updated with progress
271
- - [ ] All changes committed to git
272
- - [ ] Next action clearly identified
232
+ - [ ] SUMMARY.md created
233
+ - [ ] STATE.md updated
234
+ - [ ] Argument-verifier spawned (if workflow.verifier enabled)
235
+ - [ ] Verification result handled
236
+ - [ ] User knows next steps
273
237
  </success_criteria>