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
@@ -9,15 +9,25 @@ Validation: X exists+complete, X+1 exists, X.Y doesn't exist, Y >= 1
9
9
  READ: ~/.claude/write-the-f-paper/templates/section-prompt.md
10
10
  READ: ~/.claude/write-the-f-paper/references/plan-format.md
11
11
  READ: ~/.claude/write-the-f-paper/references/verification-layers.md
12
+ READ: ~/.claude/write-the-f-paper/references/orchestrator-pattern.md
13
+ READ: ~/.claude/write-the-f-paper/references/context-fidelity.md
14
+ READ: ~/.claude/write-the-f-paper/references/agent-model-matrix.md
12
15
  READ: .planning/ROADMAP.md
13
16
  READ: .planning/PROJECT.md
14
17
  LOAD: .planning/structure/argument-map.md, outline.md, narrative-arc.md
15
18
  </required_reading>
16
19
 
17
20
  <purpose>
18
- Create executable section prompt (PLAN.md). PLAN.md IS the prompt Claude executes - not a doc that gets transformed.
21
+ Create executable section prompt (PLAN.md) via thin orchestrator pattern. Orchestrator validates, loads context, resolves model profile, spawns section-planner agent, then runs plan-checker for quality verification. PLAN.md IS the prompt Claude executes - not a doc that gets transformed.
19
22
  </purpose>
20
23
 
24
+ <architecture>
25
+ ORCHESTRATOR: /wtfp:plan-section (this command)
26
+ AGENTS: section-planner (creates PLAN.md), plan-checker (validates PLAN.md)
27
+ PATTERN: Orchestrator loads context → spawns planner → spawns checker → revise loop if needed
28
+ WHY_SUBAGENTS: Fresh context windows for peak quality. Planner gets full project context without orchestrator overhead. Checker validates independently.
29
+ </architecture>
30
+
21
31
  <planning_principles>
22
32
  Argument-first: Every paragraph serves core argument. Plan prose that advances thesis, not filler.
23
33
  Evidence-grounded: Plan where citations go before writing. Claims need sources identified.
@@ -26,7 +36,18 @@ Reader-aware: Plan for target audience. Technical depth, assumed knowledge, expl
26
36
 
27
37
  <process>
28
38
 
29
- [step:load_project_state p=1]
39
+ [step:validate_and_resolve_model p=1]
40
+ RUN: ls .planning/ 2>/dev/null
41
+ RUN: MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
42
+
43
+ MODEL_LOOKUP{agent,quality,balanced,budget}:
44
+ section-planner | opus | opus | sonnet
45
+ plan-checker | sonnet | sonnet | haiku
46
+
47
+ RESOLVE: planner_model, checker_model from MODEL_PROFILE
48
+ [/step]
49
+
50
+ [step:load_project_state]
30
51
  READ: .planning/STATE.md
31
52
  PARSE: current_position, accumulated_decisions, open_questions, argument_strength
32
53
  IF missing+.planning_exists → OFFER reconstruct|continue
@@ -56,14 +77,27 @@ IF decimal → validate: X complete, X+1 exists, X.Y doesn't exist, Y >= 1
56
77
  READ: existing PLAN.md or RESEARCH.md in section dir
57
78
  [/step]
58
79
 
80
+ [step:load_context_md]
81
+ CRITICAL: Load CONTEXT.md early, pass to ALL agents.
82
+
83
+ RUN: SECTION_DIR=$(ls -d .planning/sections/${SECTION}-* 2>/dev/null | head -1)
84
+ RUN: CONTEXT_CONTENT=$(cat "${SECTION_DIR}"/*-CONTEXT.md 2>/dev/null)
85
+
86
+ IF CONTEXT.md exists → store for injection into planner prompt as <user_decisions>
87
+ HONOR: locked decisions, boundaries, vision
88
+ EXCLUDE: deferred ideas
89
+ ALLOW: discretion areas
90
+ IF missing → SUGGEST: /wtfp:discuss-section (simpler) or proceed without
91
+ [/step]
92
+
59
93
  [step:mandatory_literature_check]
60
94
  MANDATORY for sections flagged Research: Likely
61
95
 
62
96
  LIT_LEVEL{level,desc,action}:
63
97
  0-skip | internal content only, no external evidence | skip
64
- 1-quick | single source verify, 2-5 min | quick check, no RESEARCH.md
65
- 2-standard | multiple sources, positioning, 15-30 min | /wtfp:research-gap → RESEARCH.md
66
- 3-deep | core lit review, theoretical framework, 1+ hr | /wtfp:research-gap depth=deep → full RESEARCH.md
98
+ 1-quick | single source verify | quick check, no RESEARCH.md
99
+ 2-standard | multiple sources, positioning | /wtfp:research-gap → RESEARCH.md
100
+ 3-deep | core lit review, theoretical framework | /wtfp:research-gap depth=deep → full RESEARCH.md
67
101
 
68
102
  IF roadmap=Research:Likely → Level 0 not available
69
103
  [/step]
@@ -72,112 +106,70 @@ IF roadmap=Research:Likely → Level 0 not available
72
106
  RUN: for f in .planning/sections/*/*-SUMMARY.md; do sed -n '1,/^---$/p' "$f" | head -30; done
73
107
  PARSE: section, subsection, key-claims, evidence-used, decisions
74
108
 
75
- BUILD context:
76
- - Check logical flow (what claims does this section build on?)
77
- - Check evidence used (what sources already cited?)
78
- - Check decisions (stylistic/structural constraints?)
79
-
80
109
  AUTO-SELECT sections matching:
81
110
  - Immediate prior section
82
111
  - Same argumentative thread
83
112
  - Mentioned in STATE.md as affecting current
84
113
 
85
- EXTRACT from selected:
86
- - Claims established
87
- - Evidence cited (avoid over-citation)
88
- - Patterns established (style, terminology)
89
- - Decisions
90
-
91
- ANSWER before proceeding:
92
- Q1: What claims from previous sections does this build on?
93
- Q2: What sources already cited might be relevant?
94
- Q3: What writing patterns to maintain?
95
- Q4: Does roadmap goal still make sense given context?
114
+ EXTRACT: claims established, evidence cited, patterns, decisions
96
115
  [/step]
97
116
 
98
- [step:gather_section_context]
99
- UNDERSTAND: section_goal, word_budget, existing_drafts, dependencies_met
100
-
101
- RUN: cat .planning/sections/XX-name/${SECTION}-RESEARCH.md 2>/dev/null
102
- RUN: cat .planning/sections/XX-name/${SECTION}-CONTEXT.md 2>/dev/null
103
- RUN: cat .planning/sources/prior-drafts.md 2>/dev/null
104
-
105
- IF RESEARCH.md → USE: sources (cite), key_findings (incorporate), gaps (address), positioning
106
- IF CONTEXT.md → HONOR: vision, essential content, boundaries, user specifics
107
- IF neither → SUGGEST: /wtfp:research-gap (lit-heavy) or /wtfp:discuss-section (simpler)
108
- [/step]
109
-
110
- [step:break_into_tasks]
111
- Decompose section into writing tasks.
112
-
113
- TASK_FIELDS:
114
- - Type: auto | checkpoint:human-verify | checkpoint:decision
115
- - Name: clear, action-oriented
116
- - Paragraphs/Subsections: which part
117
- - Action: draft | revise | cite | strengthen
118
- - Mode: co-author (Claude drafts) | scaffold (Claude outlines) | reviewer (Claude critiques)
119
- - Verify: how to prove done well
120
- - Done: acceptance criteria
121
-
122
- TASKS_BY_SECTION{section → typical_tasks}:
123
- abstract | draft complete, verify elements
124
- intro | hook, context, gap, thesis, roadmap
125
- methods | protocol, measures, analysis approach
126
- results | finding narratives, supporting analyses
127
- discussion | summary, interpretation, limitations, future work, conclusion
128
- related_work | theme syntheses, positioning statement
129
-
130
- MODE_SELECT:
131
- - Procedural content (methods, data) → co-author
132
- - Argument-heavy (discussion, intro) → scaffold | reviewer
133
- - Personal voice (abstract conclusion, thesis) → scaffold + user writing
134
-
135
- CHECKPOINTS: visual/prose verify → human-verify. Voice/framing choices → decision.
117
+ [step:spawn_section_planner]
118
+ EMIT:
119
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
120
+ WTF-P ► PLANNING SECTION {X}
121
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
122
+
123
+ BUILD planner_prompt with inlined content:
124
+ - <planning_context> STATE, ROADMAP, PROJECT, argument-map, outline, RESEARCH, prior summaries
125
+ - <user_decisions> CONTEXT_CONTENT (from CONTEXT.md)
126
+ - <output> target directory path
127
+
128
+ SPAWN:
129
+ Task(
130
+ prompt="First, read ~/.claude/agents/wtfp/section-planner.md for your role and instructions.\n\n" + planner_prompt,
131
+ subagent_type="general-purpose",
132
+ model="{planner_model}",
133
+ description="Plan Section {X}"
134
+ )
135
+
136
+ HANDLE returns:
137
+ "## PLANNING COMPLETE" → proceed to plan-checker
138
+ "## CHECKPOINT REACHED" → present to user, wait
139
+ "## PLANNING BLOCKED" → present blocker, ask user
136
140
  [/step]
137
141
 
138
- [step:estimate_scope]
139
- RUN: cat .planning/config.json 2>/dev/null | grep depth
142
+ [step:spawn_plan_checker]
143
+ IF config.workflow.plan_check=false → SKIP to git_commit
140
144
 
141
- DEPTH{level,plans_per,tasks_per}:
142
- quick | 1-2 | 2-3
143
- standard | 2-4 | 2-3
144
- comprehensive | 3-6 | 2-3
145
+ SPAWN:
146
+ Task(
147
+ prompt="First, read ~/.claude/agents/wtfp/plan-checker.md for your role and instructions.\n\n" + checker_prompt_with_PLAN_content,
148
+ subagent_type="general-purpose",
149
+ model="{checker_model}",
150
+ description="Check Plan {section}-01"
151
+ )
145
152
 
146
- PRINCIPLE: Derive plans from actual writing needs. Depth = how carefully to break down complex sections.
147
- - Comprehensive Discussion = 4 plans (interpretation, limitations, future work, conclusion)
148
- - Comprehensive Abstract = 1 plan (one paragraph)
149
-
150
- ALWAYS_SPLIT if: >3 tasks, multiple threads, complex lit integration
151
- EACH_PLAN must be: 2-3 tasks max, focused on one aspect, independently verifiable
152
- [/step]
153
-
154
- [step:confirm_breakdown]
155
- IF mode=yolo → auto-approve, proceed
156
- IF mode=interactive → present breakdown:
157
- "Section [X] breakdown:
158
- ### Tasks ({section}-01-PLAN.md)
159
- 1. [Task] - [brief] [type] [mode]
160
- 2. [Task] - [brief] [type] [mode]
161
- Does this look right? (yes/adjust/start over)"
162
-
163
- IF adjust → revise
164
- IF start_over → return to gather_section_context
153
+ HANDLE returns:
154
+ "## CHECK PASSED" → proceed to git_commit
155
+ "## ISSUES FOUND" → enter revise loop
165
156
  [/step]
166
157
 
167
- [step:write_section_prompt]
168
- READ: ~/.claude/write-the-f-paper/templates/section-prompt.md
169
-
170
- SINGLE_PLAN → .planning/sections/XX-name/{section}-01-PLAN.md
171
- MULTI_PLAN → {section}-01-PLAN.md, {section}-02-PLAN.md, etc.
172
-
173
- EACH_PLAN includes:
174
- - Frontmatter (section, plan, type, mode)
175
- - Objective (goal, word target, output)
176
- - Execution context (write-section.md, summary template, verification-layers.md)
177
- - Context (@refs: PROJECT, ROADMAP, STATE, structure docs, RESEARCH/CONTEXT, prior summaries, sources)
178
- - Tasks (XML format with types/modes)
179
- - Verification (citation, coherence, rubric checks)
180
- - Success criteria, Output specification
158
+ [step:plan_check_revise_loop]
159
+ IF checker returns ISSUES:
160
+ MAX_REVISIONS: 2
161
+
162
+ LOOP:
163
+ 1. Present issues to user (or auto-fix if minor)
164
+ 2. Re-spawn section-planner with issues as feedback
165
+ 3. Re-spawn plan-checker on revised plan
166
+ 4. IF passed → proceed
167
+ 5. IF max_revisions reached → present remaining issues, ask user
168
+
169
+ ISSUE_CATEGORIES:
170
+ auto-fix | missing citation placeholder, word budget off | planner revises
171
+ user-decision | structural concern, scope question | present to user
172
+ acceptable | style preference, minor suggestion | log and proceed
181
173
  [/step]
182
174
 
183
175
  [step:git_commit]
@@ -190,7 +182,7 @@ EMIT: "Committed: docs(${SECTION}): create section plan"
190
182
  [step:offer_next]
191
183
  EMIT:
192
184
  Section plan created: .planning/sections/XX-name/{section}-01-PLAN.md
193
- [X] tasks defined.
185
+ [X] tasks defined. Plan check: [PASSED/SKIPPED]
194
186
 
195
187
  Next: {section}-01: [Plan Name] - [objective]
196
188
  → /wtfp:write-section .planning/sections/XX-name/{section}-01-PLAN.md
@@ -221,16 +213,17 @@ Tasks = instructions for Claude writing, not editorial board requirements.
221
213
  </anti_patterns>
222
214
 
223
215
  <success_criteria>
216
+ - [ ] Model profile resolved, agent models determined
224
217
  - [ ] STATE.md read, project context absorbed
218
+ - [ ] CONTEXT.md loaded early and passed to ALL agents
225
219
  - [ ] Mandatory literature check completed (Level 0-3)
226
220
  - [ ] Prior sections, sources, structure synthesized
221
+ - [ ] Section-planner agent spawned with full context
227
222
  - [ ] PLAN file(s) exist with XML structure
228
- - [ ] Each plan: Objective, context, tasks, verification, success criteria, output
229
- - [ ] @context references included (STATE, RESEARCH if exist, relevant summaries)
223
+ - [ ] Plan-checker agent validated plan (or skipped per config)
224
+ - [ ] Plan-check-revise loop completed if issues found
230
225
  - [ ] Each plan: 2-3 tasks (~focused scope)
231
226
  - [ ] Each task: Type, Mode, Paragraphs (if applicable), Action, Verify, Done
232
- - [ ] Checkpoints properly structured
233
- - [ ] If RESEARCH.md exists: sources cited in plan, positioning clear
234
227
  - [ ] PLAN file(s) committed to git
235
228
  - [ ] User knows next steps
236
229
  </success_criteria>
@@ -188,17 +188,21 @@ Execute research systematically.
188
188
 
189
189
  **CRITICAL: Source hierarchy**
190
190
 
191
- 1. **User's own sources first:**
191
+ 1. **Context7 MCP first (if available):**
192
+ - Query Context7 for relevant documentation and sources
193
+ - Highest quality, most relevant results
194
+
195
+ 2. **User's own sources second:**
192
196
  - Check .planning/sources/literature.md
193
197
  - Check .planning/sources/prior-drafts.md for cited works
194
198
  - User may have PDFs or notes to reference
195
199
 
196
- 2. **Database search (conceptual):**
200
+ 3. **Official sources/databases third:**
197
201
  - Google Scholar for academic sources
198
202
  - Field-specific databases (PubMed, IEEE, ACL, etc.)
199
203
  - Preprint servers (arXiv, SSRN, bioRxiv)
200
204
 
201
- 3. **WebSearch for recent/emerging work:**
205
+ 4. **WebSearch last (for recent/emerging work):**
202
206
  ```
203
207
  "[topic] research [current_year]"
204
208
  "[topic] systematic review"
@@ -206,6 +210,19 @@ Execute research systematically.
206
210
  "[author name] [topic]" for known experts
207
211
  ```
208
212
 
213
+ **Depth-conditional instructions:**
214
+
215
+ **If depth is "standard":**
216
+ - Target 10-20 relevant sources across categories
217
+ - Focus on most impactful papers for each category
218
+ - Categories are recommended but not all mandatory
219
+
220
+ **If depth is "deep":**
221
+ - Target 20-50 sources
222
+ - Systematically map the field: research groups, venues, citation networks, methodology variants
223
+ - Every category (foundational, recent, competing, gap, methods) is MANDATORY
224
+ - Include intellectual lineage and funding landscape
225
+
209
226
  <research_protocol>
210
227
 
211
228
  **For each research category:**
@@ -290,6 +307,13 @@ Create it: `.planning/sections/${SECTION}-${SLUG}/`
290
307
  **Structure:**
291
308
 
292
309
  ```markdown
310
+ ---
311
+ depth: {quick|standard|deep}
312
+ confidence: {HIGH|MEDIUM|LOW}
313
+ sources_count: {N}
314
+ researched: {YYYY-MM-DD}
315
+ ---
316
+
293
317
  # Literature Research: [Topic/Section]
294
318
 
295
319
  ## Research Summary
@@ -62,13 +62,30 @@ RUN: cat .planning/sections/${SECTION}-*/${SECTION}-CONTEXT.md 2>/dev/null
62
62
  [/step]
63
63
 
64
64
  [step:execute_research]
65
+ **CRITICAL: Source hierarchy**
66
+ 1. Context7 MCP first (if available) → highest quality, most relevant
67
+ 2. User's own sources → .planning/sources/literature.md, prior-drafts.md, PDFs
68
+ 3. Official sources/databases → Google Scholar, PubMed, IEEE, ACL, arXiv, SSRN
69
+ 4. WebSearch last → "[topic] research [year]", "[topic] systematic review"
70
+
71
+ MODE{depth}:
72
+ | standard | 10-20 sources, focus most impactful, categories recommended not mandatory |
73
+ | deep | 20-50 sources, map field systematically, ALL categories MANDATORY, include lineage+funding |
74
+
75
+ Per category: identify 3-5 foundational + 5-10 recent + 2-3 competing + gap evidence.
76
+ Per source: full citation, key findings, relation to work, where to cite.
77
+ Synthesize: group by argument, consensus vs controversy, methodological trends, gap.
78
+ Cross-verify: legitimate academic work, citation counts, recency, confidence level.
65
79
  [/step]
66
80
 
67
81
  [step:quality_check]
68
82
  [/step]
69
83
 
70
84
  [step:write_research]
71
- IF section_directory_doesnt_exist → Create it: `.planning/sections/${SECTION}-${SLU...
85
+ IF section_directory_doesnt_exist → Create it: `.planning/sections/${SECTION}-${SLUG}/`
86
+ Output: `.planning/sections/${SECTION}-${SLUG}/${SECTION}-RESEARCH.md`
87
+ Frontmatter: depth, confidence (HIGH/MEDIUM/LOW), sources_count, researched (YYYY-MM-DD)
88
+ Sections: Research Summary, Key Findings (Foundational/Recent/Competing/Gap/Methods), Synthesis for Writing (Intro/Related Work/Discussion), Full Bibliography, Confidence Assessment.
72
89
  [/step]
73
90
 
74
91
  [step:update_literature_index]
@@ -0,0 +1,251 @@
1
+ <purpose>
2
+ Conversational section acceptance testing. Present tests one at a time derived from
3
+ PLAN.md success criteria and argument-map.md claims. Persist state in UAT.md that
4
+ survives /clear. Route to plan-revision when issues are found.
5
+
6
+ The USER evaluates each test — Claude presents, records, and routes.
7
+ </purpose>
8
+
9
+ <process>
10
+
11
+ <step name="load_state">
12
+ **Load project state and config:**
13
+
14
+ ```bash
15
+ cat .planning/STATE.md 2>/dev/null
16
+ cat .planning/config.json 2>/dev/null
17
+ ```
18
+
19
+ Parse current position, accumulated decisions. Load planning config for commit_docs flag.
20
+
21
+ ```bash
22
+ COMMIT_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
23
+ ```
24
+ </step>
25
+
26
+ <step name="find_section">
27
+ **Resolve section from arguments:**
28
+
29
+ Parse $ARGUMENTS as section number (e.g., "3") or section name (e.g., "methods").
30
+
31
+ ```bash
32
+ # Find section directory
33
+ SECTION_DIR=$(ls -d .planning/sections/${SECTION}-* 2>/dev/null | head -1)
34
+ [ -z "$SECTION_DIR" ] && echo "ERROR: Section not found" && exit 1
35
+ ```
36
+
37
+ **Validate section was written:**
38
+
39
+ ```bash
40
+ ls "$SECTION_DIR"/*-SUMMARY.md 2>/dev/null
41
+ ```
42
+
43
+ If no SUMMARY.md exists, the section has not been written yet. Cannot verify unwritten content.
44
+
45
+ Present error:
46
+ ```
47
+ Section [X] has not been written yet.
48
+
49
+ Write it first: /wtfp:write-section [plan-path]
50
+ ```
51
+ </step>
52
+
53
+ <step name="load_or_create_uat">
54
+ **Check for existing UAT.md:**
55
+
56
+ ```bash
57
+ UAT_PATH="$SECTION_DIR/UAT.md"
58
+ [ -f "$UAT_PATH" ] && echo "EXISTING" || echo "NEW"
59
+ ```
60
+
61
+ **If UAT.md exists (resuming):**
62
+ - Read UAT.md
63
+ - Count total tests, completed tests, pending tests
64
+ - Find next test with `result: pending`
65
+ - Report: "Resuming verification (N/M tests complete)"
66
+
67
+ **If UAT.md does not exist (new verification):**
68
+
69
+ Derive tests from two sources:
70
+
71
+ 1. **PLAN.md success criteria:**
72
+ ```bash
73
+ cat "$SECTION_DIR"/*-PLAN.md
74
+ ```
75
+ Extract each item from `<success_criteria>` section. Each `- [ ]` item becomes a test.
76
+
77
+ 2. **Argument-map claims for this section:**
78
+ ```bash
79
+ cat .planning/structure/argument-map.md 2>/dev/null
80
+ ```
81
+ Find claims mapped to this section number. Each claim becomes a test.
82
+
83
+ **Generate test list:** Combine both sources. Each test gets:
84
+ - Sequential number
85
+ - Source label: `[plan]` or `[argument-map]`
86
+ - The criterion or claim text
87
+ - `result: pending`
88
+ - `reason: ""`
89
+
90
+ **Write UAT.md** using template format:
91
+ ```yaml
92
+ ---
93
+ status: testing
94
+ section: XX-name
95
+ started: [ISO timestamp]
96
+ last_test: 0
97
+ ---
98
+ ```
99
+
100
+ Followed by `## Tests` section with all derived tests, `## Summary` with initial counts, empty `## Gaps` section.
101
+
102
+ Report: "Starting verification (M tests)"
103
+ </step>
104
+
105
+ <step name="present_test">
106
+ **Display current test:**
107
+
108
+ Find next test with `result: pending`.
109
+
110
+ Present using branded checkpoint box:
111
+
112
+ ```
113
+ ════════════════════════════════════════
114
+ VERIFICATION: Test {N} of {total}
115
+ ════════════════════════════════════════
116
+
117
+ Source: {[plan] or [argument-map]}
118
+
119
+ {The criterion or claim being verified}
120
+
121
+ Check: Does this section satisfy the above?
122
+ ════════════════════════════════════════
123
+ ```
124
+
125
+ Use AskUserQuestion:
126
+ - header: "Verification"
127
+ - question: The criterion or claim text
128
+ - options:
129
+ - "Pass - meets criteria"
130
+ - "Skip - not applicable"
131
+ - "Issue - describe the problem"
132
+ </step>
133
+
134
+ <step name="record_result">
135
+ **Write result back to UAT.md:**
136
+
137
+ Update the test entry:
138
+ - Set `result:` to pass, skip, or issue
139
+ - Set `reason:` to user's explanation (if provided)
140
+ - Increment `last_test` in frontmatter
141
+
142
+ **If result is "issue":**
143
+
144
+ Ask follow-up for severity classification:
145
+
146
+ Use AskUserQuestion:
147
+ - header: "Severity"
148
+ - question: "How severe is this issue?"
149
+ - options:
150
+ - "Major - undermines argument, must fix"
151
+ - "Minor - weakens but doesn't invalidate"
152
+ - "Cosmetic - polish issue, fix during final pass"
153
+
154
+ Add entry to `## Gaps` section:
155
+ ```markdown
156
+ - claim: "[criterion or claim text]"
157
+ status: issue
158
+ reason: "[user's description]"
159
+ severity: [major|minor|cosmetic]
160
+ ```
161
+
162
+ Update UAT.md on disk after each result.
163
+ </step>
164
+
165
+ <step name="check_completion">
166
+ **Check if more tests remain:**
167
+
168
+ Count tests with `result: pending`.
169
+
170
+ **If pending > 0:** Loop back to `present_test` step.
171
+
172
+ **If pending == 0:** All tests evaluated.
173
+ - Set `status: complete` in frontmatter
174
+ - Calculate summary counts:
175
+ - total: [count of all tests]
176
+ - passed: [count with result: pass]
177
+ - issues: [count with result: issue]
178
+ - skipped: [count with result: skip]
179
+ - Update `## Summary` section in UAT.md
180
+ </step>
181
+
182
+ <step name="route_on_completion">
183
+ **Route based on results:**
184
+
185
+ **If no issues found (all pass or skip):**
186
+
187
+ ```
188
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
189
+ WTF-P ► VERIFICATION PASSED
190
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
191
+
192
+ Section [X]: [Name]
193
+ Tests: [passed] passed, [skipped] skipped, 0 issues
194
+
195
+ ───────────────────────────────────────────
196
+
197
+ ## ▶ Next Up
198
+
199
+ **Check progress** — see overall paper status
200
+
201
+ `/wtfp:progress`
202
+
203
+ <sub>`/clear` first → fresh context window</sub>
204
+
205
+ ───────────────────────────────────────────
206
+ ```
207
+
208
+ **If issues found:**
209
+
210
+ ```
211
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
212
+ WTF-P ► VERIFICATION: ISSUES FOUND
213
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
214
+
215
+ Section [X]: [Name]
216
+ Tests: [passed] passed, [issues] issues, [skipped] skipped
217
+
218
+ ## Gap Summary
219
+
220
+ | # | Claim/Criterion | Severity | Reason |
221
+ |---|-----------------|----------|--------|
222
+ | 1 | [text] | major | [reason] |
223
+ | 2 | [text] | minor | [reason] |
224
+
225
+ ───────────────────────────────────────────
226
+
227
+ ## ▶ Next Up
228
+
229
+ **Plan revision** — create fix plan for identified issues
230
+
231
+ `/wtfp:plan-revision [section]`
232
+
233
+ <sub>`/clear` first → fresh context window</sub>
234
+
235
+ ───────────────────────────────────────────
236
+ ```
237
+ </step>
238
+
239
+ </process>
240
+
241
+ <success_criteria>
242
+ - [ ] Section resolved from arguments
243
+ - [ ] SUMMARY.md existence validated (section was written)
244
+ - [ ] Tests derived from BOTH PLAN.md success_criteria AND argument-map.md claims
245
+ - [ ] UAT.md created or resumed with correct state
246
+ - [ ] Each test presented one at a time with branded checkpoint box
247
+ - [ ] User response recorded (pass/skip/issue) with persistence
248
+ - [ ] Issues get severity classification and are added to Gaps
249
+ - [ ] UAT.md updated on disk after each result (survives /clear)
250
+ - [ ] Completion routes to progress (clean) or plan-revision (issues found)
251
+ </success_criteria>