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