@hassangameryt/freeflow 0.7.3 → 0.9.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 (426) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +2 -2
  4. package/.codex-plugin/plugin.json +3 -3
  5. package/.cursor-plugin/plugin.json +1 -1
  6. package/NOTICE +14 -0
  7. package/README.md +101 -159
  8. package/capabilities/cognitive-routing/SKILL.md +47 -210
  9. package/capabilities/cognitive-routing/references/coordinator.md +163 -0
  10. package/capabilities/cognitive-routing/references/worker.md +38 -0
  11. package/capabilities/compaction/SKILL.md +49 -0
  12. package/capabilities/compaction/references/summary-format.md +250 -0
  13. package/capabilities/messaging/SKILL.md +49 -0
  14. package/capabilities/task-memory/SKILL.md +87 -0
  15. package/command-surface.json +8 -52
  16. package/gemini-extension.json +1 -1
  17. package/hooks/claude/hooks.json +13 -3
  18. package/hooks/codex/hooks.json +2 -1
  19. package/hooks/shared/runtime-context.mjs +73 -83
  20. package/licenses/Apache-2.0.txt +55 -0
  21. package/package.json +42 -12
  22. package/pi-extension/README.md +41 -0
  23. package/pi-extension/dist/ask-user/ask.js +108 -0
  24. package/pi-extension/dist/ask-user/form.js +250 -0
  25. package/pi-extension/dist/ask-user/questions.js +66 -0
  26. package/pi-extension/dist/ask-user/tool.js +124 -0
  27. package/pi-extension/dist/cognitive-routing/assembler.js +417 -0
  28. package/pi-extension/dist/cognitive-routing/bootstrap.js +90 -0
  29. package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/config.js +8 -6
  30. package/pi-extension/dist/cognitive-routing/economics.js +45 -0
  31. package/pi-extension/dist/cognitive-routing/event-schema.js +388 -0
  32. package/pi-extension/dist/{session-sources/events.js → cognitive-routing/event-store.js} +107 -41
  33. package/pi-extension/dist/cognitive-routing/gate.js +256 -0
  34. package/pi-extension/dist/cognitive-routing/handlers.js +901 -0
  35. package/pi-extension/dist/cognitive-routing/handoffs.js +350 -0
  36. package/pi-extension/dist/cognitive-routing/model-control.js +476 -0
  37. package/pi-extension/dist/cognitive-routing/projection.js +520 -0
  38. package/pi-extension/dist/cognitive-routing/provenance.js +83 -0
  39. package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/render.js +15 -15
  40. package/pi-extension/dist/cognitive-routing/runtime.js +398 -0
  41. package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/schemas.js +47 -11
  42. package/pi-extension/dist/cognitive-routing/session.js +223 -0
  43. package/pi-extension/dist/{session-sources → cognitive-routing}/sources.js +126 -87
  44. package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/state.js +55 -386
  45. package/pi-extension/dist/cognitive-routing/status.js +81 -0
  46. package/pi-extension/dist/cognitive-routing/tools.js +74 -0
  47. package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/types.js +14 -11
  48. package/pi-extension/dist/compaction/carry.js +205 -0
  49. package/pi-extension/dist/compaction/config.js +24 -0
  50. package/pi-extension/dist/compaction/controller.js +494 -0
  51. package/pi-extension/dist/compaction/harness.js +93 -0
  52. package/pi-extension/dist/compaction/results.js +159 -0
  53. package/pi-extension/dist/compaction/thresholds.js +35 -0
  54. package/pi-extension/dist/compaction/tool.js +57 -0
  55. package/pi-extension/dist/host/branch.js +13 -0
  56. package/pi-extension/dist/host/canonical.js +12 -0
  57. package/pi-extension/dist/host/catalog.js +62 -0
  58. package/pi-extension/dist/host/config-validation.js +233 -0
  59. package/pi-extension/dist/host/config.js +361 -0
  60. package/pi-extension/dist/host/inbound.js +142 -0
  61. package/pi-extension/dist/host/projection-tags.js +60 -0
  62. package/pi-extension/dist/host/prompts.js +93 -0
  63. package/pi-extension/dist/{session-sources → host}/read-only-session.js +117 -1
  64. package/pi-extension/dist/{runtime → host}/request-history.js +125 -39
  65. package/pi-extension/dist/host/rows.js +25 -0
  66. package/pi-extension/dist/host/runtime-state.js +204 -0
  67. package/pi-extension/dist/host/section-keeper.js +85 -0
  68. package/pi-extension/dist/host/settings/freeflow-command.js +2323 -0
  69. package/pi-extension/dist/{settings/settings-tui.js → host/settings/settings-view.js} +205 -73
  70. package/pi-extension/dist/host/staging.js +28 -0
  71. package/pi-extension/dist/host/status.js +115 -0
  72. package/pi-extension/dist/index.js +1004 -188
  73. package/pi-extension/dist/messaging/config.js +27 -0
  74. package/pi-extension/dist/messaging/messaging.js +398 -0
  75. package/pi-extension/dist/messaging/registry.js +57 -0
  76. package/pi-extension/dist/messaging/render.js +90 -0
  77. package/pi-extension/dist/messaging/tools.js +109 -0
  78. package/pi-extension/dist/messaging/transport.js +101 -0
  79. package/pi-extension/dist/provider-support/cache/anchor.js +21 -0
  80. package/pi-extension/dist/provider-support/cache/anthropic.js +102 -0
  81. package/pi-extension/dist/provider-support/cache/health.js +73 -0
  82. package/pi-extension/dist/provider-support/cache/index.js +58 -0
  83. package/pi-extension/dist/provider-support/cache/keepalive.js +222 -0
  84. package/pi-extension/dist/provider-support/cache/monitor.js +17 -0
  85. package/pi-extension/dist/provider-support/cache/openai-responses.js +48 -0
  86. package/pi-extension/dist/provider-support/effort.js +13 -0
  87. package/pi-extension/dist/provider-support/index.js +44 -3
  88. package/pi-extension/dist/provider-support/{astra → openai}/adapter.js +46 -29
  89. package/pi-extension/dist/provider-support/{astra → openai}/history.js +10 -8
  90. package/pi-extension/dist/provider-support/{astra → openai}/index.js +8 -4
  91. package/pi-extension/dist/provider-support/{astra → openai}/session-state.js +29 -38
  92. package/pi-extension/dist/provider-support/routes.js +17 -0
  93. package/pi-extension/dist/task-memory/config.js +49 -0
  94. package/pi-extension/dist/task-memory/registry.js +119 -0
  95. package/pi-extension/dist/task-memory/render.js +107 -0
  96. package/pi-extension/dist/task-memory/runtime.js +994 -0
  97. package/pi-extension/dist/task-memory/tool.js +233 -0
  98. package/pi-extension/dist/tool-execution/apply-patch/grammar.js +23 -0
  99. package/pi-extension/dist/tool-execution/apply-patch/match.js +38 -0
  100. package/pi-extension/dist/tool-execution/apply-patch/parser.js +177 -0
  101. package/pi-extension/dist/tool-execution/apply-patch/plan.js +201 -0
  102. package/pi-extension/dist/tool-execution/apply-patch/tool.js +84 -0
  103. package/pi-extension/dist/tool-execution/background.js +430 -0
  104. package/pi-extension/dist/tool-execution/bash-guard.js +23 -0
  105. package/pi-extension/dist/tool-execution/config.js +33 -0
  106. package/pi-extension/dist/tool-execution/edit-messages.js +120 -0
  107. package/pi-extension/dist/tool-execution/file-state.js +138 -0
  108. package/pi-extension/dist/tool-execution/file-tracking.js +163 -0
  109. package/pi-extension/dist/tool-execution/guidance-notices.js +124 -0
  110. package/pi-extension/dist/tool-execution/prompt.js +54 -0
  111. package/pi-extension/dist/tool-execution/skill-reads.js +143 -0
  112. package/pi-extension/dist/tool-execution/tools.js +16 -0
  113. package/pi-extension/freeflow/README.md +9 -0
  114. package/runtime/prompts/cognitive-routing.md +4 -4
  115. package/runtime/prompts/core.md +29 -72
  116. package/runtime/prompts/interaction-contract.md +18 -8
  117. package/runtime/prompts/tool-execution.md +25 -0
  118. package/runtime/prompts/working-method.md +25 -0
  119. package/skills/deliver-work/SKILL.md +76 -0
  120. package/skills/deliver-work/references/branch-closeout.md +134 -0
  121. package/skills/deliver-work/references/commit.md +83 -0
  122. package/skills/deliver-work/references/launch.md +94 -0
  123. package/skills/deliver-work/references/release.md +85 -0
  124. package/skills/deliver-work/scripts/commit-state.mjs +139 -0
  125. package/skills/deliver-work/scripts/delivery-state.mjs +107 -0
  126. package/skills/deliver-work/scripts/lib/git-state.mjs +178 -0
  127. package/skills/deliver-work/scripts/push-route.mjs +122 -0
  128. package/skills/deliver-work/scripts/release-preflight.mjs +177 -0
  129. package/skills/discuss-work/SKILL.md +148 -0
  130. package/skills/{discuss → discuss-work}/references/discussion-continuity.md +13 -50
  131. package/skills/discuss-work/references/learning-action.md +36 -0
  132. package/skills/discuss-work/scripts/choices.mjs +101 -0
  133. package/skills/discuss-work/scripts/lib/choices.mjs +159 -0
  134. package/skills/evaluate-behavior/SKILL.md +107 -0
  135. package/skills/evaluate-behavior/references/authoring.md +381 -0
  136. package/skills/evaluate-behavior/references/coding-tasks.md +145 -0
  137. package/skills/evaluate-behavior/references/conversations-pipelines-judges.md +177 -0
  138. package/skills/evaluate-behavior/references/design-and-measurement.md +273 -0
  139. package/skills/evaluate-behavior/references/running-and-evidence.md +245 -0
  140. package/skills/evaluate-behavior/scripts/claude-guard.mjs +76 -0
  141. package/skills/evaluate-behavior/scripts/guard-rules.mjs +309 -0
  142. package/skills/evaluate-behavior/scripts/lib/agreement.mjs +90 -0
  143. package/skills/evaluate-behavior/scripts/lib/arms.mjs +55 -0
  144. package/skills/evaluate-behavior/scripts/lib/budget.mjs +87 -0
  145. package/skills/evaluate-behavior/scripts/lib/build-source.mjs +287 -0
  146. package/skills/evaluate-behavior/scripts/lib/clear.mjs +74 -0
  147. package/skills/evaluate-behavior/scripts/lib/container.mjs +395 -0
  148. package/skills/evaluate-behavior/scripts/lib/decision.mjs +418 -0
  149. package/skills/evaluate-behavior/scripts/lib/definitions.mjs +1072 -0
  150. package/skills/evaluate-behavior/scripts/lib/freeflow.mjs +103 -0
  151. package/skills/evaluate-behavior/scripts/lib/grade-command.mjs +591 -0
  152. package/skills/evaluate-behavior/scripts/lib/grade-comparison.mjs +90 -0
  153. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-interaction.mjs +19 -18
  154. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-support.mjs +32 -5
  155. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-workspace.mjs +28 -12
  156. package/skills/evaluate-behavior/scripts/lib/grade.mjs +101 -0
  157. package/skills/evaluate-behavior/scripts/lib/hooks.mjs +98 -0
  158. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/confinement.mjs +196 -0
  159. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/constraints.mjs +111 -0
  160. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/index.mjs +48 -0
  161. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/isolation.mjs +74 -0
  162. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/launch.mjs +123 -0
  163. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/model-call.mjs +73 -0
  164. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/recorder.mjs +178 -0
  165. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/session.mjs +494 -0
  166. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/skills.mjs +81 -0
  167. package/skills/evaluate-behavior/scripts/lib/hosts/index.mjs +31 -0
  168. package/skills/evaluate-behavior/scripts/lib/hosts/names.mjs +3 -0
  169. package/skills/evaluate-behavior/scripts/lib/hosts/pi/confinement.mjs +173 -0
  170. package/skills/evaluate-behavior/scripts/lib/hosts/pi/host.mjs +148 -0
  171. package/skills/evaluate-behavior/scripts/lib/hosts/pi/index.mjs +70 -0
  172. package/skills/evaluate-behavior/scripts/lib/hosts/pi/isolation.mjs +81 -0
  173. package/skills/evaluate-behavior/scripts/lib/hosts/pi/model-call.mjs +79 -0
  174. package/skills/evaluate-behavior/scripts/lib/hosts/pi/process.mjs +241 -0
  175. package/skills/{evaluate-skill/scripts/lib → evaluate-behavior/scripts/lib/hosts/pi}/rpc.mjs +144 -26
  176. package/skills/evaluate-behavior/scripts/lib/identity.mjs +82 -0
  177. package/skills/evaluate-behavior/scripts/lib/judge.mjs +688 -0
  178. package/skills/evaluate-behavior/scripts/lib/metrics.mjs +332 -0
  179. package/skills/evaluate-behavior/scripts/lib/model-call.mjs +17 -0
  180. package/skills/evaluate-behavior/scripts/lib/participants.mjs +616 -0
  181. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/process.mjs +22 -0
  182. package/skills/evaluate-behavior/scripts/lib/queue.mjs +54 -0
  183. package/skills/evaluate-behavior/scripts/lib/reference.mjs +343 -0
  184. package/skills/evaluate-behavior/scripts/lib/reuse.mjs +277 -0
  185. package/skills/evaluate-behavior/scripts/lib/review.mjs +933 -0
  186. package/skills/evaluate-behavior/scripts/lib/runner.mjs +732 -0
  187. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/sandbox.mjs +121 -14
  188. package/skills/evaluate-behavior/scripts/lib/scan-shell.mjs +457 -0
  189. package/skills/evaluate-behavior/scripts/lib/scan.mjs +479 -0
  190. package/skills/evaluate-behavior/scripts/lib/seal.mjs +91 -0
  191. package/skills/evaluate-behavior/scripts/lib/shell.mjs +560 -0
  192. package/skills/evaluate-behavior/scripts/lib/source-override.mjs +64 -0
  193. package/skills/evaluate-behavior/scripts/lib/subject-file.mjs +88 -0
  194. package/skills/{evaluate-skill/scripts/lib/pi.mjs → evaluate-behavior/scripts/lib/subject.mjs} +239 -262
  195. package/skills/evaluate-behavior/scripts/lib/task-copy.mjs +124 -0
  196. package/skills/evaluate-behavior/scripts/lib/trials.mjs +524 -0
  197. package/skills/evaluate-behavior/scripts/lib/validity.mjs +68 -0
  198. package/skills/evaluate-behavior/scripts/lib/view-html.mjs +454 -0
  199. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/view.mjs +218 -11
  200. package/skills/evaluate-behavior/scripts/pi-command-tool.mjs +159 -0
  201. package/skills/evaluate-behavior/scripts/pi-container-route.mjs +23 -0
  202. package/skills/evaluate-behavior/scripts/pi-guard.mjs +77 -0
  203. package/skills/evaluate-behavior/scripts/pi-login-refresh.mjs +31 -0
  204. package/skills/evaluate-behavior/scripts/skill-eval.mjs +586 -0
  205. package/skills/execute-work/SKILL.md +96 -72
  206. package/skills/execute-work/references/code-practices.md +27 -49
  207. package/skills/execute-work/references/design.md +271 -0
  208. package/skills/execute-work/references/diagnose.md +117 -0
  209. package/skills/execute-work/references/migration.md +108 -0
  210. package/skills/execute-work/references/simplify.md +65 -0
  211. package/skills/execute-work/scripts/self-review.mjs +422 -0
  212. package/skills/execute-work/scripts/touch-map.mjs +290 -0
  213. package/skills/review-work/SKILL.md +94 -64
  214. package/skills/review-work/references/adjudication.md +94 -0
  215. package/skills/review-work/references/artifact.md +198 -0
  216. package/skills/review-work/references/evals-and-judges.md +66 -0
  217. package/skills/review-work/references/work.md +177 -0
  218. package/skills/review-work/scripts/check-brief.mjs +128 -0
  219. package/skills/review-work/scripts/review-packet.mjs +233 -0
  220. package/skills/setup-freeflow/SKILL.md +69 -16
  221. package/skills/track-work/SKILL.md +135 -151
  222. package/skills/track-work/references/handoff.md +190 -0
  223. package/skills/track-work/references/projects.md +51 -0
  224. package/skills/track-work/references/working-record-format.md +201 -344
  225. package/skills/track-work/scripts/lib/document.mjs +79 -19
  226. package/skills/track-work/scripts/lib/format.mjs +18 -1
  227. package/skills/track-work/scripts/lib/recover.mjs +254 -0
  228. package/skills/track-work/scripts/lib/registry.mjs +656 -0
  229. package/skills/track-work/scripts/lib/search.mjs +40 -0
  230. package/skills/track-work/scripts/lib/store.mjs +53 -21
  231. package/skills/track-work/scripts/lib/transitions.mjs +79 -4
  232. package/skills/track-work/scripts/lib/views.mjs +50 -1
  233. package/skills/track-work/scripts/working-record.mjs +263 -22
  234. package/skills/verify-work/SKILL.md +64 -47
  235. package/skills/verify-work/references/feature-map.md +120 -0
  236. package/skills/verify-work/references/runtime-evidence.md +203 -0
  237. package/skills/verify-work/references/test-design.md +27 -6
  238. package/skills/verify-work/scripts/test-changes.mjs +246 -0
  239. package/skills/write-docs/SKILL.md +171 -0
  240. package/skills/write-docs/references/documentation-shapes.md +184 -0
  241. package/skills/write-docs/references/spec-and-plan-shapes.md +308 -0
  242. package/skills/write-docs/scripts/artifact-check.mjs +148 -0
  243. package/skills/write-docs/scripts/docs-check.mjs +229 -0
  244. package/skills/write-docs/scripts/plan-lint.mjs +123 -0
  245. package/skills/write-skill/SKILL.md +165 -165
  246. package/skills/write-skill/references/activation-and-wording.md +143 -0
  247. package/skills/write-skill/references/placement-and-dependencies.md +154 -0
  248. package/skills/write-skill/scripts/lib/compare.mjs +701 -0
  249. package/skills/write-skill/scripts/lib/similarity.mjs +56 -0
  250. package/skills/write-skill/scripts/lib/skill-author.mjs +197 -3
  251. package/skills/write-skill/scripts/skill-author.mjs +67 -8
  252. package/capabilities/context-virtualization/SKILL.md +0 -103
  253. package/capabilities/conversation-history/SKILL.md +0 -53
  254. package/hooks/tests/check-host-adapters.test.mjs +0 -82
  255. package/hooks/tests/check-runtime-context-hook.sh +0 -212
  256. package/pi-extension/dist/cognitive-routing-v2/projection.js +0 -330
  257. package/pi-extension/dist/cognitive-routing-v2/runtime.js +0 -2181
  258. package/pi-extension/dist/cognitive-routing-v2/tools.js +0 -60
  259. package/pi-extension/dist/context-virtualization/commands.js +0 -89
  260. package/pi-extension/dist/context-virtualization/projector.js +0 -42
  261. package/pi-extension/dist/context-virtualization/runtime.js +0 -378
  262. package/pi-extension/dist/context-virtualization/state.js +0 -57
  263. package/pi-extension/dist/context-virtualization/types.js +0 -10
  264. package/pi-extension/dist/conversation-history/passages.js +0 -66
  265. package/pi-extension/dist/conversation-history/ranking.js +0 -105
  266. package/pi-extension/dist/conversation-history/runtime.js +0 -226
  267. package/pi-extension/dist/conversation-history/search.js +0 -56
  268. package/pi-extension/dist/conversation-history/types.js +0 -1
  269. package/pi-extension/dist/freeflow-context/resolver.js +0 -120
  270. package/pi-extension/dist/freeflow-context/runtime.js +0 -80
  271. package/pi-extension/dist/freeflow-context/source-projector.js +0 -95
  272. package/pi-extension/dist/freeflow-context/tool.js +0 -314
  273. package/pi-extension/dist/freeflow-context/types.js +0 -12
  274. package/pi-extension/dist/freeflow-context/visibility.js +0 -28
  275. package/pi-extension/dist/integrations/mcp-config.js +0 -29
  276. package/pi-extension/dist/runtime/runtime-context.js +0 -754
  277. package/pi-extension/dist/runtime/runtime-identity.js +0 -5
  278. package/pi-extension/dist/session-sources/provenance.js +0 -32
  279. package/pi-extension/dist/settings/settings-ui.js +0 -1360
  280. package/pi-extension/dist/ui/text-component.js +0 -57
  281. package/pi-extension/src/cognitive-routing-v2/budget.ts +0 -42
  282. package/pi-extension/src/cognitive-routing-v2/config.ts +0 -173
  283. package/pi-extension/src/cognitive-routing-v2/projection.ts +0 -375
  284. package/pi-extension/src/cognitive-routing-v2/render.ts +0 -277
  285. package/pi-extension/src/cognitive-routing-v2/runtime.ts +0 -2241
  286. package/pi-extension/src/cognitive-routing-v2/schemas.ts +0 -180
  287. package/pi-extension/src/cognitive-routing-v2/state.ts +0 -839
  288. package/pi-extension/src/cognitive-routing-v2/tools.ts +0 -62
  289. package/pi-extension/src/cognitive-routing-v2/types.ts +0 -254
  290. package/pi-extension/src/context-virtualization/commands.ts +0 -111
  291. package/pi-extension/src/context-virtualization/projector.ts +0 -62
  292. package/pi-extension/src/context-virtualization/runtime.ts +0 -428
  293. package/pi-extension/src/context-virtualization/state.ts +0 -79
  294. package/pi-extension/src/context-virtualization/types.ts +0 -92
  295. package/pi-extension/src/conversation-history/passages.ts +0 -81
  296. package/pi-extension/src/conversation-history/ranking.ts +0 -155
  297. package/pi-extension/src/conversation-history/runtime.ts +0 -250
  298. package/pi-extension/src/conversation-history/search.ts +0 -79
  299. package/pi-extension/src/conversation-history/types.ts +0 -31
  300. package/pi-extension/src/freeflow-context/resolver.ts +0 -139
  301. package/pi-extension/src/freeflow-context/runtime.ts +0 -100
  302. package/pi-extension/src/freeflow-context/source-projector.ts +0 -106
  303. package/pi-extension/src/freeflow-context/tool.ts +0 -366
  304. package/pi-extension/src/freeflow-context/types.ts +0 -70
  305. package/pi-extension/src/freeflow-context/visibility.ts +0 -53
  306. package/pi-extension/src/index.ts +0 -390
  307. package/pi-extension/src/integrations/mcp-config.ts +0 -32
  308. package/pi-extension/src/provider-support/astra/adapter.ts +0 -108
  309. package/pi-extension/src/provider-support/astra/history.ts +0 -145
  310. package/pi-extension/src/provider-support/astra/index.ts +0 -12
  311. package/pi-extension/src/provider-support/astra/session-state.ts +0 -113
  312. package/pi-extension/src/provider-support/index.ts +0 -5
  313. package/pi-extension/src/runtime/request-history.ts +0 -243
  314. package/pi-extension/src/runtime/runtime-context.ts +0 -860
  315. package/pi-extension/src/runtime/runtime-identity.ts +0 -8
  316. package/pi-extension/src/session-sources/events.ts +0 -230
  317. package/pi-extension/src/session-sources/provenance.ts +0 -39
  318. package/pi-extension/src/session-sources/read-only-session.ts +0 -170
  319. package/pi-extension/src/session-sources/sources.ts +0 -334
  320. package/pi-extension/src/settings/settings-tui.ts +0 -501
  321. package/pi-extension/src/settings/settings-ui.ts +0 -1652
  322. package/pi-extension/src/ui/text-component.ts +0 -66
  323. package/pi-extension/tests/cache-reuse/history.test.js +0 -117
  324. package/pi-extension/tests/cache-reuse/native.test.js +0 -91
  325. package/pi-extension/tests/cache-reuse/settings.test.js +0 -211
  326. package/pi-extension/tests/cognitive-routing-v2/communication.test.js +0 -577
  327. package/pi-extension/tests/cognitive-routing-v2/compaction-input.test.js +0 -183
  328. package/pi-extension/tests/cognitive-routing-v2/delegation.test.js +0 -557
  329. package/pi-extension/tests/cognitive-routing-v2/native.test.js +0 -474
  330. package/pi-extension/tests/cognitive-routing-v2/performance.test.js +0 -87
  331. package/pi-extension/tests/cognitive-routing-v2/persistence.test.js +0 -300
  332. package/pi-extension/tests/cognitive-routing-v2/projection.test.js +0 -241
  333. package/pi-extension/tests/cognitive-routing-v2/recovery.test.js +0 -1034
  334. package/pi-extension/tests/cognitive-routing-v2/render.test.js +0 -244
  335. package/pi-extension/tests/cognitive-routing-v2/runtime.test.js +0 -423
  336. package/pi-extension/tests/cognitive-routing-v2/stabilization.test.js +0 -521
  337. package/pi-extension/tests/cognitive-routing-v2/state.test.js +0 -586
  338. package/pi-extension/tests/context-virtualization/extension.test.js +0 -775
  339. package/pi-extension/tests/context-virtualization/projector.test.js +0 -110
  340. package/pi-extension/tests/context-virtualization/runtime.test.js +0 -230
  341. package/pi-extension/tests/conversation-history/runtime.test.js +0 -98
  342. package/pi-extension/tests/conversation-history/search.test.js +0 -97
  343. package/pi-extension/tests/fixtures/pi-host.js +0 -4
  344. package/pi-extension/tests/fixtures/routing-native.js +0 -191
  345. package/pi-extension/tests/integration/mode-free-core.test.js +0 -220
  346. package/pi-extension/tests/integration/pi-extension.test.js +0 -1447
  347. package/pi-extension/tests/integration/prompt-architecture.test.js +0 -447
  348. package/pi-extension/tests/integration/unaffected-regressions.test.js +0 -478
  349. package/pi-extension/tests/provider-support/astra-boundaries.test.js +0 -75
  350. package/pi-extension/tests/provider-support/astra.test.js +0 -306
  351. package/pi-extension/tests/provider-support/cli.test.js +0 -92
  352. package/pi-extension/tests/provider-support/native.test.js +0 -183
  353. package/pi-extension/tests/settings/settings-tui.test.js +0 -243
  354. package/pi-extension/tsconfig.json +0 -16
  355. package/plugin.json +0 -33
  356. package/runtime/prompts/context-virtualization.md +0 -3
  357. package/runtime/prompts/conversation-history.md +0 -3
  358. package/skills/action-selection/SKILL.md +0 -100
  359. package/skills/action-selection/references/trajectory-stalls.md +0 -71
  360. package/skills/bypass/SKILL.md +0 -153
  361. package/skills/commit-work/SKILL.md +0 -145
  362. package/skills/commit-work/references/git-state-edges.md +0 -94
  363. package/skills/commit-work/references/simple-push.md +0 -92
  364. package/skills/commit-work/references/staging-decisions.md +0 -106
  365. package/skills/decision-gate/SKILL.md +0 -106
  366. package/skills/design-for-depth/SKILL.md +0 -117
  367. package/skills/design-for-depth/references/design-pressure-signals.md +0 -182
  368. package/skills/design-for-depth/references/implementation-decisions.md +0 -76
  369. package/skills/design-for-depth/references/interface-design-loop.md +0 -136
  370. package/skills/design-for-depth/references/module-and-dependency-design.md +0 -147
  371. package/skills/design-for-depth/references/software-design-philosophy.md +0 -202
  372. package/skills/design-for-depth/references/state-and-failure-boundaries.md +0 -136
  373. package/skills/diagnose-failure/SKILL.md +0 -125
  374. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +0 -48
  375. package/skills/diagnose-failure/references/flaky-and-performance-diagnosis.md +0 -51
  376. package/skills/discuss/SKILL.md +0 -116
  377. package/skills/evaluate-skill/SKILL.md +0 -219
  378. package/skills/evaluate-skill/references/evaluation-definition-schema.md +0 -385
  379. package/skills/evaluate-skill/references/evaluation-design.md +0 -112
  380. package/skills/evaluate-skill/references/execution-and-evidence.md +0 -90
  381. package/skills/evaluate-skill/references/review-and-revision.md +0 -92
  382. package/skills/evaluate-skill/scripts/lib/definitions.mjs +0 -407
  383. package/skills/evaluate-skill/scripts/lib/grade-comparison.mjs +0 -60
  384. package/skills/evaluate-skill/scripts/lib/grade.mjs +0 -64
  385. package/skills/evaluate-skill/scripts/lib/runner.mjs +0 -368
  386. package/skills/evaluate-skill/scripts/pi-guard.mjs +0 -164
  387. package/skills/evaluate-skill/scripts/skill-eval.mjs +0 -102
  388. package/skills/execute-work/references/execute-work-edges.md +0 -68
  389. package/skills/finish-branch/SKILL.md +0 -117
  390. package/skills/finish-branch/references/integration-options.md +0 -80
  391. package/skills/handoff/SKILL.md +0 -82
  392. package/skills/handoff/references/handoff-templates.md +0 -150
  393. package/skills/launch-work/SKILL.md +0 -116
  394. package/skills/launch-work/references/launch-readiness.md +0 -85
  395. package/skills/migration-work/SKILL.md +0 -115
  396. package/skills/migration-work/references/migration-lifecycle.md +0 -82
  397. package/skills/release-work/SKILL.md +0 -118
  398. package/skills/release-work/references/release-evidence.md +0 -78
  399. package/skills/review-artifact/SKILL.md +0 -142
  400. package/skills/review-artifact/references/adjudicate-artifact-review.md +0 -101
  401. package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +0 -159
  402. package/skills/review-work/references/adjudicate-work-review.md +0 -97
  403. package/skills/review-work/references/independent-work-reviewer-contract.md +0 -139
  404. package/skills/review-work/references/security-risk-lens.md +0 -69
  405. package/skills/setup-freeflow/references/activation-contract.md +0 -109
  406. package/skills/setup-freeflow/references/host-setup.md +0 -67
  407. package/skills/simplify-code/SKILL.md +0 -85
  408. package/skills/simplify-code/references/simplification-patterns.md +0 -70
  409. package/skills/verify-work/references/browser-runtime-evidence.md +0 -55
  410. package/skills/verify-work/references/integration-evidence.md +0 -47
  411. package/skills/verify-work/references/performance-evidence.md +0 -57
  412. package/skills/workflow/SKILL.md +0 -127
  413. package/skills/workflow/references/domain-skill-composition.md +0 -43
  414. package/skills/write-plan/SKILL.md +0 -92
  415. package/skills/write-plan/references/plan-shapes.md +0 -156
  416. package/skills/write-skill/references/activation-boundaries.md +0 -104
  417. package/skills/write-skill/references/agent-first-instructions.md +0 -121
  418. package/skills/write-skill/references/progressive-disclosure.md +0 -127
  419. package/skills/write-skill/references/skill-dependency-graphs.md +0 -190
  420. package/skills/write-spec/SKILL.md +0 -92
  421. package/skills/write-spec/references/artifact-standards.md +0 -86
  422. package/skills/write-spec/references/decision-records.md +0 -78
  423. package/skills/write-spec/references/spec-shapes.md +0 -143
  424. /package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/budget.js +0 -0
  425. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/evidence.mjs +0 -0
  426. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/pi-observer.mjs +0 -0
@@ -0,0 +1,246 @@
1
+ #!/usr/bin/env node
2
+ // Lists every existing test file, fixture, snapshot and shared test setup file that changed, moved or was deleted
3
+ // between a base and a head, with the changed hunks. It only lists; whether a change is justified is a judgment for
4
+ // the agent and the user (references/test-design.md). A file that does not exist at the base is a new test, not a
5
+ // changed one, and is not listed; --new lists those instead (added, copied, or untracked in the working tree).
6
+ // Usage: test-changes.mjs --base <ref> [--head <ref>] [--root <repository>] [--pattern <glob>]... [--only]
7
+ // [--exclude <glob>]... [--new] [--json]
8
+ // Without --head, the head is the working tree, staged and unstaged. Exit code 0 when it lists (even nothing),
9
+ // 2 on a usage or Git error.
10
+ import { execFileSync } from "node:child_process";
11
+ import { resolve } from "node:path";
12
+ import { parseArgs } from "node:util";
13
+
14
+ const USAGE =
15
+ "Usage: test-changes.mjs --base <ref> [--head <ref>] [--root <repository>] [--pattern <glob>]... [--only] [--exclude <glob>]... [--new] [--json]";
16
+
17
+ // Common layouts for JavaScript, TypeScript, Python, Go, Ruby, Java, Kotlin, C#, Swift, C and C++, PHP, Elixir and
18
+ // Dart. Matching is case-sensitive, so capitalised folders such as Swift's Tests/ are listed separately. --pattern adds
19
+ // to these; --only replaces them.
20
+ const DEFAULT_PATTERNS = [
21
+ "**/*.{test,spec}.{js,jsx,mjs,cjs,ts,tsx,mts,cts}",
22
+ "**/{test,tests,__tests__,spec,e2e,Tests}/**",
23
+ "**/*.{Tests,UnitTests,IntegrationTests}/**",
24
+ "**/src/*Test/**",
25
+ "**/*_test.{go,dart,exs}",
26
+ "**/*_{test,unittest}.{c,cc,cpp,cxx}",
27
+ "**/*_spec.rb",
28
+ "**/*{Test,Tests}.{java,kt,cs,swift,php}",
29
+ "**/test_*.py",
30
+ "**/*_test.py",
31
+ "**/conftest.py",
32
+ "**/{fixtures,__fixtures__,testdata,__mocks__}/**",
33
+ "**/__snapshots__/**",
34
+ "**/*.snap",
35
+ "**/{jest,vitest,playwright,cypress,karma}.config.*",
36
+ "**/vitest.workspace.*",
37
+ "**/{jest.setup,setupTests,setup-tests,test-setup,vitest.setup}.*",
38
+ "**/*.setup.{js,mjs,cjs,ts,mts,cts}",
39
+ "**/.mocharc*",
40
+ "**/{pytest.ini,tox.ini,noxfile.py}",
41
+ "**/{spec_helper,rails_helper}.rb",
42
+ "**/.rspec",
43
+ "**/phpunit.xml*",
44
+ "**/test_helper.exs",
45
+ ];
46
+
47
+ // The first matching kind wins, so a snapshot under tests/ is a snapshot and a fixture under tests/ is a fixture.
48
+ const KINDS = [
49
+ ["snapshot", ["**/__snapshots__/**", "**/*.snap"]],
50
+ [
51
+ "setup",
52
+ [
53
+ "**/conftest.py",
54
+ "**/{jest,vitest,playwright,cypress,karma}.config.*",
55
+ "**/vitest.workspace.*",
56
+ "**/{jest.setup,setupTests,setup-tests,test-setup,vitest.setup}.*",
57
+ "**/.mocharc*",
58
+ "**/{pytest.ini,tox.ini,noxfile.py}",
59
+ "**/*.setup.{js,mjs,cjs,ts,mts,cts}",
60
+ "**/{spec_helper,rails_helper}.rb",
61
+ "**/.rspec",
62
+ "**/phpunit.xml*",
63
+ "**/test_helper.exs",
64
+ ],
65
+ ],
66
+ ["fixture", ["**/{fixtures,__fixtures__,testdata,__mocks__}/**"]],
67
+ ];
68
+
69
+ const STATUS = { M: "modified", D: "deleted", R: "renamed", T: "type-changed" };
70
+
71
+ function fail(message) {
72
+ console.error(message);
73
+ process.exit(2);
74
+ }
75
+
76
+ let parsed;
77
+ try {
78
+ parsed = parseArgs({
79
+ options: {
80
+ base: { type: "string" },
81
+ head: { type: "string" },
82
+ root: { type: "string" },
83
+ pattern: { type: "string", multiple: true, default: [] },
84
+ only: { type: "boolean", default: false },
85
+ exclude: { type: "string", multiple: true, default: [] },
86
+ new: { type: "boolean", default: false },
87
+ json: { type: "boolean", default: false },
88
+ },
89
+ });
90
+ } catch (error) {
91
+ fail(`${error.message}\n${USAGE}`);
92
+ }
93
+ const { values } = parsed;
94
+ if (!values.base) fail(USAGE);
95
+ if (values.only && !values.pattern.length) fail(`--only needs at least one --pattern\n${USAGE}`);
96
+
97
+ // Glob to RegExp over repository-relative paths with "/" separators: "**/" is zero or more directories, "**" anything,
98
+ // "*" anything within one segment, "?" one character, and "{a,b}" either alternative.
99
+ function globToRegExp(glob) {
100
+ let source = "";
101
+ for (let index = 0; index < glob.length; index += 1) {
102
+ const char = glob[index];
103
+ if (char === "*" && glob[index + 1] === "*") {
104
+ const slash = glob[index + 2] === "/";
105
+ source += slash ? "(?:.*/)?" : ".*";
106
+ index += slash ? 2 : 1;
107
+ } else if (char === "*") source += "[^/]*";
108
+ else if (char === "?") source += "[^/]";
109
+ else if (char === "{") {
110
+ const end = glob.indexOf("}", index);
111
+ if (end === -1) source += "\\{";
112
+ else {
113
+ source += `(?:${glob
114
+ .slice(index + 1, end)
115
+ .split(",")
116
+ .map((part) => globToRegExp(part).source.slice(1, -1))
117
+ .join("|")})`;
118
+ index = end;
119
+ }
120
+ } else source += /[.+^$()|[\]\\]/.test(char) ? `\\${char}` : char;
121
+ }
122
+ return new RegExp(`^${source}$`);
123
+ }
124
+ const matcher = (globs) => {
125
+ const expressions = globs.map(globToRegExp);
126
+ return (path) => expressions.some((expression) => expression.test(path));
127
+ };
128
+
129
+ const patterns = values.only ? values.pattern : [...DEFAULT_PATTERNS, ...values.pattern];
130
+ const included = matcher(patterns);
131
+ const excluded = matcher(values.exclude);
132
+ const kindMatchers = KINDS.map(([kind, globs]) => [kind, matcher(globs)]);
133
+ const kindOf = (path) => kindMatchers.find(([, matches]) => matches(path))?.[0] ?? "test";
134
+
135
+ const git = (cwd, args) =>
136
+ execFileSync("git", args, { cwd, encoding: "utf8", maxBuffer: 256 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
137
+ const gitOrFail = (cwd, args, what) => {
138
+ try {
139
+ return git(cwd, args);
140
+ } catch (error) {
141
+ fail(`${what}: ${String(error.stderr || error.message).trim()}`);
142
+ }
143
+ };
144
+
145
+ const root = resolve(
146
+ gitOrFail(resolve(values.root ?? "."), ["rev-parse", "--show-toplevel"], "not inside a Git repository").trim(),
147
+ );
148
+ const commitOf = (ref) => {
149
+ try {
150
+ return git(root, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]).trim();
151
+ } catch {
152
+ fail(`no such commit: ${ref}`);
153
+ }
154
+ };
155
+ const base = { ref: values.base, commit: commitOf(values.base) };
156
+ const head = values.head ? { ref: values.head, commit: commitOf(values.head) } : { ref: "working tree", commit: null };
157
+
158
+ // Fixed flags so the user's Git configuration (colour, external diff tools, prefixes, rename limits) cannot change
159
+ // what is listed or how hunks read.
160
+ const DIFF = [
161
+ "-c",
162
+ "core.quotePath=false",
163
+ "diff",
164
+ "--no-color",
165
+ "--no-ext-diff",
166
+ "--no-textconv",
167
+ "--no-relative",
168
+ "-M",
169
+ ];
170
+ const range = head.commit ? [base.commit, head.commit] : [base.commit];
171
+
172
+ const fields = gitOrFail(root, [...DIFF, "--name-status", "-z", ...range], "git diff failed").split("\0");
173
+ const changes = [];
174
+ const added = [];
175
+ for (let index = 0; index < fields.length - 1;) {
176
+ const code = fields[index][0];
177
+ const paths = code === "R" || code === "C" ? [fields[index + 1], fields[index + 2]] : [fields[index + 1]];
178
+ index += 1 + paths.length;
179
+ const status = STATUS[code];
180
+ const [path] = paths;
181
+ if ((code === "A" || code === "C") && included(paths.at(-1)) && !excluded(paths.at(-1))) added.push(paths.at(-1));
182
+ // Only files that existed at the base: added and copied files are new.
183
+ if (!status || !included(path) || excluded(path)) continue;
184
+ const diff = gitOrFail(
185
+ root,
186
+ [...DIFF, "--unified=3", "--src-prefix=a/", "--dst-prefix=b/", ...range, "--", ...paths],
187
+ `git diff failed for ${path}`,
188
+ );
189
+ const lines = diff.split("\n");
190
+ const start = lines.findIndex((line) => line.startsWith("@@") || line.startsWith("Binary files"));
191
+ const body = start === -1 ? [] : lines.slice(start);
192
+ changes.push({
193
+ status,
194
+ path,
195
+ ...(status === "renamed" ? { to: paths[1] } : {}),
196
+ kind: kindOf(path),
197
+ added: body.filter((line) => line.startsWith("+")).length,
198
+ removed: body.filter((line) => line.startsWith("-")).length,
199
+ binary: body[0]?.startsWith("Binary files") ?? false,
200
+ // A deleted file's hunks are its whole content; the path and line count say what went.
201
+ hunks: status === "deleted" ? null : body.join("\n").trimEnd(),
202
+ });
203
+ }
204
+
205
+ // New test files, for a check that each one fails on the base: committed additions, plus untracked files when the head
206
+ // is the working tree.
207
+ if (values.new) {
208
+ if (!head.commit)
209
+ for (const path of gitOrFail(root, ["ls-files", "-z", "--others", "--exclude-standard"], "git ls-files failed")
210
+ .split("\0")
211
+ .filter(Boolean))
212
+ if (included(path) && !excluded(path)) added.push(path);
213
+ const tests = [...new Set(added)].sort().map((path) => ({ status: "added", path, kind: kindOf(path) }));
214
+ if (values.json)
215
+ console.log(
216
+ JSON.stringify(
217
+ { command: "test-changes", mode: "new", root, base, head, patterns, exclude: values.exclude, tests },
218
+ null,
219
+ 2,
220
+ ),
221
+ );
222
+ else if (!tests.length) console.log(`No new test, fixture, snapshot or test setup file since ${base.ref}.`);
223
+ else {
224
+ console.log(`${tests.length} new test, fixture, snapshot or test setup file(s) since ${base.ref}:`);
225
+ for (const each of tests) console.log(`added ${each.kind} ${each.path}`);
226
+ }
227
+ } else if (values.json) {
228
+ console.log(
229
+ JSON.stringify({ command: "test-changes", root, base, head, patterns, exclude: values.exclude, changes }, null, 2),
230
+ );
231
+ } else {
232
+ const against = `${base.ref} (${base.commit.slice(0, 12)})`;
233
+ const to = head.commit ? `${head.ref} (${head.commit.slice(0, 12)})` : head.ref;
234
+ if (!changes.length)
235
+ console.log(`No existing test, fixture, snapshot or test setup file changed between ${against} and ${to}.`);
236
+ else {
237
+ console.log(
238
+ `${changes.length} existing test, fixture, snapshot or test setup file${changes.length === 1 ? "" : "s"} changed between ${against} and ${to}:\n`,
239
+ );
240
+ for (const change of changes) {
241
+ const name = change.to ? `${change.path} -> ${change.to}` : change.path;
242
+ console.log(`${change.status} ${change.kind} ${name} (+${change.added} -${change.removed})`);
243
+ if (change.hunks) console.log(`${change.hunks}\n`);
244
+ }
245
+ }
246
+ }
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: write-docs
3
+ description: "Use when writing, updating or reviewing a document someone will act on: a spec, PRD, issue, requirements, API or interface contract, technical design, decision record or ADR; an implementation, remediation, migration or operations plan; a README, user guide, developer docs, subsystem doc, overview, folder README or feature file; or when a code change makes existing docs wrong, or a project has no developer docs yet. It covers where a document goes, its header and status, and the checks to run after writing it."
4
+ ---
5
+
6
+ # Write Docs
7
+
8
+ Write a document a reader will act on: true to its sources, no more certain than they are, and holding only what its use needs.
9
+
10
+ Documents come in two kinds, with different lives:
11
+
12
+ - **Specs and Plans decide work before it happens.** A Spec defines what to build or decide: a PRD, issue, requirements, technical design, API or migration contract. A Plan orders how to carry out agreed work. They are task artifacts, kept beside the task's Working Record (`specs/`, `plans/`) unless the repository keeps them elsewhere; they are drafted, accepted by the user, and left behind once the work is done. A decision record is written the same way and can outlive the task.
13
+ - **Documentation describes software that exists:** how it works and why, for the people and agents who use or change it. It lives in the repository and stays true only if it changes with the code; its header names the code it `Covers` and the commit it was `Verified at`. A document that decides work not yet done is a Spec or a Plan, not documentation.
14
+
15
+ Readers include agents. An agent that reads code sees what it does but not why; without the why, it may treat a deliberate choice as a bug, rebuild a design that was rejected for a reason, or break a rule nobody wrote down.
16
+
17
+ The **Rules** below are binding; if one cannot be met, stop and say why. Everything else is **judgment**: follow its stated goal, and adapt when a different choice serves that goal better.
18
+
19
+ ## Routes
20
+
21
+ | Situation | Read |
22
+ | --- | --- |
23
+ | A spec, PRD, issue, requirements, technical design, API or interface contract, or migration contract; an ordered plan for implementation, remediation, migration or operations | [spec and plan shapes](references/spec-and-plan-shapes.md) |
24
+ | Preserving a decision and its rationale: a decision note or ADR | [spec and plan shapes: Decision Records](references/spec-and-plan-shapes.md#decision-records) |
25
+ | Where a Spec, Plan or decision record goes, its header, status and source trail | Header, Status And Sources, below |
26
+ | Finding a project's developer docs or proposing them; the structure of an overview, subsystem doc, folder README, feature file or live-verification guide; a new or rewritten subsystem doc or overview | [documentation shapes](references/documentation-shapes.md) |
27
+ | After writing or revising a Spec, Plan or decision record | Run [artifact-check](scripts/artifact-check.mjs), and [plan-lint](scripts/plan-lint.mjs) for a Plan, as Specs And Plans says |
28
+ | After writing or changing documentation, or to find the docs and feature files covering a changed file | Run the [docs check](scripts/docs-check.mjs), as Check It says |
29
+ | A design whose open representation, identity, ownership, algorithm or failure choices could invalidate dependent work | Execute Work's [design](../execute-work/references/design.md) |
30
+ | Direction or alternatives still open, a user-owned choice, or conflicting sources | [Discuss Work](../discuss-work/SKILL.md) |
31
+ | Planning a fix whose cause is not supported | Execute Work's [diagnose](../execute-work/references/diagnose.md) |
32
+
33
+ ## Rules
34
+
35
+ - A document grants no permission. Accepting a Spec or Plan is not permission to execute it, and review establishes fitness, not acceptance or authority. Writing or revising one does not trigger independent review; never label author self-review as independent review, or give a document an accepted status without its source.
36
+ - Never add an obligation without an accepted source or a reason the stated outcome needs it. Never infer requirements from nearby code, existing tests or available machinery, invent a user-owned choice or scale, retry, recovery or extension machinery, or reduce agreed scope into an unapproved MVP, roadmap or later-version split.
37
+ - Label proposed design as proposed. Never write an assumption, a reviewer's suggestion or your own preference as an accepted decision, or a hoped-for answer or unsettled owner choice as a planning assumption. Authorization to investigate or draft an option does not accept its undisclosed production consequences.
38
+ - Stop the affected writing when it would silently settle a user-owned choice, as [Discuss Work](../discuss-work/SKILL.md) defines it, or a hard-to-reverse design; never settle such a choice through normative prose, an unexplained assumption or a polished placeholder. Return the concrete effect and supported alternatives to the owner through Discuss Work.
39
+ - Never rewrite source truth to suit implementation, let available tests redefine acceptance, or rewrite a historical decision as though it always contained the new choice.
40
+ - Check each factual claim against its source (the code, its tests, an observed run, or the accepted source) before writing it as fact; state what you could not check as unverified, or leave it out. Never claim whole-system completion from a narrow observer.
41
+ - Documentation says what is true now. Plans, task progress and open work belong in the task's record, Spec or Plan; history appears only as a short list of major changes.
42
+ - When your change makes a document wrong, correct it in the same change. Writing new documentation, or rewriting more than your change made wrong, needs a request or the repository's documentation rules.
43
+ - Follow the repository's documentation rules (`AGENTS.md` or its equivalent): where documents live, which parts need the user's approval to change, and what is public.
44
+ - Keep secrets, credentials, private task notes and personal data out of documents others can read.
45
+
46
+ ## Write The Document
47
+
48
+ Goal: a reader with only the document and its sources can act correctly, and can tell what is required, what is fact, and what is still open.
49
+
50
+ **Know the reader and the use.** Identify the document type, who reads it and for what later action, the accepted scope, the destination, and the open questions it must keep. Answer a question about a document without editing it unless revision is requested. Use Discuss Work when direction or alternatives are still materially open; do not repeat discussion that already settled the document's purpose. An agreement to implement accepted work may include documenting its supported contract; do not manufacture another approval because a document was produced.
51
+
52
+ **Ground it in current sources:** current user direction and accepted discussion, including later amendments; the Specs, issues, decisions and contracts it revises or consumes; live code, tests, policy and ADRs; current primary sources when an external version or interface constrains it; and the Working Record through [Track Work](../track-work/SKILL.md) when one exists. For documentation, start from the code and its tests, then read what explains them: specs, task records, decision records, commit messages, review threads. A reason that exists only in a task record or a conversation is the one most worth writing down, because it disappears with them.
53
+
54
+ A record or summary cannot override contradictory current intent or accepted source truth. Distinguish what was requested, proposed, accepted and observed, and know which accepted version or amendment the document follows; an earlier reviewed baseline does not excuse ignoring a later accepted change. An experiment produces evidence, not a requirement: carry its consequences only where they were selected for this outcome. A test can faithfully protect an unnecessary mechanism.
55
+
56
+ **Write only what the use needs**, in the shape the routes above name. Give the depth the reader needs, including architecture and ownership where the use requires it; do not cut necessary detail just to shorten the document, and leave out a section with nothing true to say. Keep distinguishable: required behavior and accepted decisions; supported facts and their limits; proposed mechanisms; assumptions and open questions; deferrals and superseded direction. Use the repository's vocabulary, and put a consequential uncertainty where the reader makes the affected decision, not in a distant caveat. A limitation of one technique does not establish a need for stronger guarantees, host changes, new persistence, retries or a subsystem. Open questions need not stop unrelated content; a document can be fit for discussion while unfit to guide production, so say which. Give each fact one home and link shared rationale instead of copying it.
57
+
58
+ **Self-review once before anyone relies on it.** After checking factual claims, use [Review Work](../review-work/SKILL.md) for one silent author self-review of the complete document against its use: it keeps accepted intent and amendments, separates requirements from proposals, has the evidence and acceptance conditions it needs, and keeps dependent documents coherent; for a Plan, also that the ordered work can achieve the outcome, its dependencies hold, later uncertainty is honest, final checks match acceptance, and selected checkpoints are proportionate. Correct clear defects and recheck what they affect; return an unresolved owner decision instead of inventing an answer to make the document consistent. Independent review applies only when selected and authorized to protect a concrete boundary: give the reviewer the complete document, its sources, dependencies and limits through Review Work, and adjudicate the report before revision or use. Respect a selected approval checkpoint, but do not create one for every document.
59
+
60
+ ## Specs And Plans
61
+
62
+ A Spec describes content, behavior, constraints and uncertainty for its use; it is not an implementation sequence, a Working Record, a transcript or a permission grant. Useful technical depth is welcome; hypothetical completeness is not required. A Plan describes intended execution; the Working Record keeps actual work, evolving state and the next useful action. Keep ordered execution in a Plan and live progress in the record. After writing or revising a Plan, run [plan-lint](scripts/plan-lint.mjs) (`node <write-docs-directory>/scripts/plan-lint.mjs <plan.md>`): it lists each step that names no check.
63
+
64
+ When a Working Record exists and the Spec or Plan is accepted for its task, list it under the record's `What defines this task` through Track Work, so every recovery reads it.
65
+
66
+ Revise for a change in the contract or strategy, not for progress. Preserve accepted content that still holds, change only what new intent or evidence affects, update the status honestly, and keep consequential prior rationale recoverable through a change note, decision record, supersession link or version control; a change note explains current intent or keeps rejected work from being repeated, never execution status or a transcript, and a first version needs none unless repository policy requires it. When an accepted amendment or learning result changes the contract, find the affected Plan, acceptance check or implementation assumption: reconcile it when authorized, otherwise mark it contingent and return the needed revision before dependent use. Learning does not enter the contract by itself: keep findings selected for implementation apart from observations kept as evidence. Do not keep an older baseline after the user accepted a change, synchronize unrelated documents, or repair consistency by silently changing the required outcome.
67
+
68
+ ### Header, Status And Sources
69
+
70
+ These apply to Specs, Plans and decision records; documentation uses the header in [documentation shapes](references/documentation-shapes.md#header) instead.
71
+
72
+ **Destination.** A task-local Spec or Plan goes in the task folder Track Work owns (`specs/`, `plans/`). Use an established product, design, API, issue, migration, policy or architecture location instead when the document should be canonical there, and the repository's issue tracker for an issue when it is available and intended. Ask before choosing between task-local memory and canonical repository documentation when the choice changes authority, review or longevity. Do not start a new top-level docs convention for one document.
73
+
74
+ **Header.** Use the repository's required metadata. Otherwise, when identity helps future readers, give a title and a compact header with only useful fields:
75
+
76
+ ```md
77
+ # Team Invitations API
78
+
79
+ > **Doc ID:** SPEC-001-team-invitations-api
80
+ > **Type:** API Contract
81
+ > **Status:** Draft
82
+ > **Owner:** User
83
+ > **Source:** Working Record task-004 and accepted product decisions
84
+ ```
85
+
86
+ **Doc ID** when links, review history or supersession need one; **Type** the document's actual job, such as PRD, Issue, Technical Design, API Contract, Migration Contract, Implementation Plan or Decision; **Owner** the person or role with authority over its intent; **Source** compact pointers to accepted context and evidence; a date, or **Supersedes** / **Superseded by**, only when reliable and needed. Never invent an owner, approval, date or authority to complete a header.
87
+
88
+ **Status.** Use the repository's statuses when it has them. Otherwise give one current status from this vocabulary, the same for every Spec, Plan and decision record, using only the states its life reaches:
89
+
90
+ | Status | Means |
91
+ | --- | --- |
92
+ | `Draft` | Being written, or proposed and not yet accepted. |
93
+ | `Reviewed` | Reviewed and not yet accepted; say whether by author self-review or selected independent review. |
94
+ | `Accepted` | The owner accepted it; `Source` names where. |
95
+ | `Rejected` | The owner declined it. |
96
+ | `Superseded` | Replaced; link the replacement both ways. |
97
+ | `Retired` | Dropped with nothing replacing it, with the date and the reason. |
98
+
99
+ Writing or reviewing a document never makes it `Accepted`, and `Accepted` is not permission to execute it. Status reports the document's state; it does not replace review evidence or user authority.
100
+
101
+ **Source trail.** Link stable sources that actually exist, such as `file:<path>#<section>`, `working-record:<task>/record.md#<section>`, `commit:<sha>`, `issue:<id>`, `output:<output-id>` or `session:<session-id>/turn:<turn-id>`, with concise quotations rather than copied inventories, logs, diffs or transcripts. The trail lets a later reader recover why the document says what it says, without preserving every turn: for a consequential choice, keep the proposal, its disclosed consequences and the acceptance source together rather than an isolated "proceed" or an agent's summary of approval, and keep accepted amendments apart from unselected experimental findings.
102
+
103
+ Then run [artifact-check](scripts/artifact-check.mjs) (`node <write-docs-directory>/scripts/artifact-check.mjs <document.md> [--statuses <the repository's own>]`): it refuses a missing title or status, a status outside this vocabulary, an `Accepted` document with no Source, a `Superseded` one with no replacement, and a `file:` or `commit:` pointer that does not resolve.
104
+
105
+ A Spec or Plan stays identifiable, source-backed and understandable without the original conversation, holding no information a Working Record, handoff or another canonical document owns.
106
+
107
+ ## Documentation
108
+
109
+ ### Choose The Document
110
+
111
+ Goal: each fact lives in one place, written for the reader who needs it.
112
+
113
+ | Reader | Document | Holds |
114
+ | --- | --- | --- |
115
+ | Someone using the software | User guide | What it does and how to use it: tasks, settings, commands, from the user's side. |
116
+ | Someone finding their way around the code | Overview (an `ARCHITECTURE.md`, or the index of the developer docs) | The problem the software solves, its parts and how they relate, a map of where things are, and the rules that hold across parts. Short and slow to change. |
117
+ | Someone changing one subsystem | Subsystem doc | How the subsystem works and why: its surface, state, invariants, decisions, failure behavior, code map, and tests. |
118
+ | Someone editing files in one folder | Folder `README.md` | What each file owns, local rules, and a pointer to its subsystem doc. |
119
+ | Someone checking a feature in the running software | Feature file, plus a shared live-verification guide | What the user sees and the exact steps that show it works. |
120
+ | Anyone revisiting a hard-to-reverse choice | Decision record | The decision and why, in the [Decision Records](references/spec-and-plan-shapes.md#decision-records) shape. |
121
+
122
+ Prefer extending an existing document to creating a new one: a small set of current documents serves readers better than many partly current ones. A subsystem earns its own doc when the reasons behind it cannot be read from the code and readers keep needing them: agents re-derive the same design, or mistake a deliberate behavior for a bug. A user guide and a subsystem doc about the same feature are different documents for different readers; link them rather than merging them.
123
+
124
+ Each kind of knowledge has one home. How the code works and why, its decisions, and behavior that looks wrong but is intended: developer docs, with hard-to-reverse choices in decision records and what the user sees in feature files. Rules for agents working in the repository: its instruction files. Task progress and decisions in flight: the task's record, until settled decisions move to the docs. The user's own preferences: the host's memory.
125
+
126
+ Write documentation where the repository keeps it; [documentation shapes](references/documentation-shapes.md#starting-developer-docs) says where to look, and what to propose when there is none. If the repository keeps none and you are asked to start, propose a location and confirm with the user before creating it. When a project has code and no developer docs, propose creating them and wait for the user's yes; keep that knowledge out of `AGENTS.md`, `CLAUDE.md` and other always-loaded instruction files, which every request pays for.
127
+
128
+ ### Write It For The Next Change
129
+
130
+ Goal: a reader with only the document and the code can make a correct change, and can tell what is deliberate.
131
+
132
+ - **Name, do not link to lines.** Write paths, functions, types, configuration keys, and messages exactly, in backticks, so readers and search tools find them. Line numbers go stale with the next edit.
133
+ - **Write invariants, including absences.** "Nothing outside `config.ts` reads the config file" or "the request path never reads session files" cannot be seen by reading any one file, so state it.
134
+ - **Say what looks wrong but is intended.** For behavior a careful reader would take for a bug, state the behavior, the reason, and what would break if it changed.
135
+ - **Keep explanation apart from reference.** Explanation (purpose, how it works, why) is read once to understand; reference (surface, state, invariants, code map, tests) is consulted while working. Put them in separate sections so a reader looking up a fact does not wade through reasoning.
136
+ - **Prefer present-tense facts to narrative.** "Compaction runs at the end of a turn" rather than "We changed compaction so that it now runs at the end of a turn". History gets one short section of major changes, with commits.
137
+
138
+ Depth follows the reader's risk. A subsystem with many hidden reasons needs most of the shape; a small one may need only purpose, surface, and code map.
139
+
140
+ ### Keep It Current
141
+
142
+ Goal: documentation stays true as the code changes, without anyone remembering to check.
143
+
144
+ - When you finish a change, ask whether any document now says something false: a user guide, a subsystem doc, a folder README, an overview. Correct it in the same change.
145
+ - When work settles a decision about a documented subsystem (a design choice, a rejected alternative, a limit accepted on purpose), record the decision and its reason in the subsystem doc once the work it decided is done. The task record is deleted or forgotten with the task; the doc stays.
146
+ - Before you treat behavior in a documented subsystem as a bug, read its decisions and its list of intended behavior that looks wrong. If the behavior is listed there, changing it is a design change for the user to decide, not a fix.
147
+ - Delete or correct documentation that is no longer true. A wrong document misleads more than a missing one.
148
+ - After checking a document against the code, update the commit it records as verified.
149
+
150
+ ### Check It
151
+
152
+ Run the bundled [docs check](scripts/docs-check.mjs) after writing or changing documentation:
153
+
154
+ ```text
155
+ node <write-docs-directory>/scripts/docs-check.mjs <docs-file-or-directory>... [--root <repository>] [--strict] [--driven] [--json]
156
+ node <write-docs-directory>/scripts/docs-check.mjs [<docs-file-or-directory>...] --covering <path>... [--root <repository>] [--json]
157
+ ```
158
+
159
+ It reports paths a document names that do not exist and, for documents with the header, those whose covered code changed since the commit they record as verified. A change made together with the document, in the same commit or both uncommitted, counts as reviewed with it. Missing paths are errors (exit code 1). Changed code is a warning, since many changes leave a document true; `--strict` makes it an error. Read the changes it lists and update the document or its verified commit. `--driven` counts a change made together with the document too: use it for feature files, whose verified commit is the last live drive, so editing the text does not count as driving it.
160
+
161
+ `--covering` instead lists the documents that cover each path and whether each is current: the ones a change should reread or update.
162
+
163
+ A passing check shows that the named paths exist; it does not prove every claim is current. A new or substantially rewritten subsystem doc or overview also gets the reader test in [documentation shapes](references/documentation-shapes.md#test-it-on-a-new-reader). Report what was checked.
164
+
165
+ ## Stop
166
+
167
+ Report the document's path, type and intended use, its source basis, what is unresolved, contingent or unverified, and what was checked. For a Spec or Plan, also report a Plan's invalidation conditions and selected checkpoints, and the actual review, acceptance and execution-authority status.
168
+
169
+ Stop when the document is fit for its use, or its blocking decision or evidence limit is explicit; for documentation, when it says only what is true now, each claim is checked or marked unverified, and the docs check passes. Then return to the activity that asked for it: if the agreement covers implementation, continue through the normal route; if it asks for a Plan first, stop there. Do not begin work outside that agreement or call an unresolved strategy ready.
170
+
171
+ Stop and ask when where a document lives, who may change it, or whether a disputed behavior is intended cannot be settled from the code, its tests and its sources.
@@ -0,0 +1,184 @@
1
+ # Documentation Shapes
2
+
3
+ This reference is judgment except for the header: these are shapes to adapt, not mandatory templates. Where the repository already has documentation conventions, follow them and borrow from these shapes only what they lack. Use the sections a document's readers need, in the order that serves them, and leave out a section with nothing true to say.
4
+
5
+ The header is binding when you use it, because the [docs check](../scripts/docs-check.mjs) reads it. Use it on a document whose code the check should watch for staleness.
6
+
7
+ ## Starting Developer Docs
8
+
9
+ First look for the project's own docs index, in this order: `dev-docs/README.md`, `ARCHITECTURE.md`, a `README.md` in `docs/`, then a docs folder the root `README.md` names. The first one found is the index. A project that has one keeps its home and its conventions: map these shapes onto what is there, never start a second tree, and never move existing docs without the user's yes.
10
+
11
+ Only when the project has no developer docs, propose this layout:
12
+
13
+ ```text
14
+ dev-docs/
15
+ README.md overview: purpose, parts, code map, rules across the code, review rules, index of docs
16
+ subsystems/ how each part works and why
17
+ features/ what the user sees, and how to drive it live
18
+ guides/ recurring maintainer jobs, such as a release or live verification
19
+ adr/ hard-to-reverse decisions
20
+ ```
21
+
22
+ Grow it on demand: start with `README.md` alone, and add a folder when its first document is needed. A small project may never need more than the overview and `features/`. The proposal names what the first change writes (the overview only, from the code), roughly what it costs, and what it gains.
23
+
24
+ ## Header
25
+
26
+ An overview, a subsystem doc, a feature file, and a live-verification guide start with a title and a header block:
27
+
28
+ ```markdown
29
+ # Compaction
30
+
31
+ > **Covers:** `pi-extension/src/compaction/`, `pi-extension/src/index.ts`
32
+ > **Tests:** `pi-extension/tests/compaction/`
33
+ > **Verified at:** `9078dd0` (2026-10-03)
34
+ > **User docs:** `plugin-docs/capabilities/compaction.md`
35
+ ```
36
+
37
+ - **Covers:** the files and directories the document describes, as repository-relative paths in backticks, separated by commas. The check reports a document as possibly stale when any of them changes after the verified commit, unless the document changed in the same commit.
38
+ - **Tests:** the tests that prove the document's claims, in the same form. Optional.
39
+ - **Verified at:** the commit the document was last checked against, in backticks, with the date. Update it only after checking the document against the code at that commit.
40
+ - **User docs:** the user guide for the same feature, when one exists. Optional.
41
+
42
+ Under the header, one or two sentences say who the document is for and what it lets them do.
43
+
44
+ ## Subsystem Doc
45
+
46
+ The first part explains; the second is reference to consult while working. The sections below are the full set for a subsystem with many hidden reasons; most need fewer.
47
+
48
+ ```markdown
49
+ ## Purpose
50
+ ## Vocabulary
51
+ ## How It Works
52
+ ## Decisions
53
+ ## Intended Behavior That Looks Wrong
54
+ ## Surface
55
+ ## State
56
+ ## Invariants
57
+ ## Failure Behavior
58
+ ## Cost
59
+ ## Code Map
60
+ ## Tests
61
+ ## Limits
62
+ ## Changes
63
+ ```
64
+
65
+ - **Purpose:** the problem it solves, what it does, and what it deliberately does not do.
66
+ - **Vocabulary:** the terms a reader needs, each mapped to its name in the code.
67
+ - **How It Works:** the model in prose, then its lifecycle: which events or calls drive it, in order, and what each step does. A sequence or diagram helps when several parts take turns.
68
+ - **Decisions:** one entry per choice a reader could reasonably question: the decision, the reason, the alternative rejected and why, and the source (decision record, commit, issue).
69
+ - **Intended Behavior That Looks Wrong:** behavior a careful reader would take for a bug. For each: the behavior, why it is intended, and what would break if it changed.
70
+ - **Surface:** everything outside the subsystem touches: configuration keys with defaults, commands, tools or APIs, events, messages shown to users or models.
71
+ - **State:** what is stored and where (file, entry type, schema), what lives only in memory, and how state is rebuilt after a restart, reload, or other loss.
72
+ - **Invariants:** what must always hold, including absences. Name the test that guards each one, or say that none does.
73
+ - **Failure Behavior:** what happens when each dependency or step fails, and what the user or caller sees.
74
+ - **Cost:** the performance, caching, or resource rules the subsystem follows, and any measured numbers with their date.
75
+ - **Code Map:** one line per directory or important file: what it owns, and its key types or functions by name. Point to folder READMEs for per-file detail rather than repeating it.
76
+ - **Tests:** each test file or group and what it proves.
77
+ - **Limits:** known limits and open questions, as facts about the present, not plans.
78
+ - **Changes:** major changes in a few lines each, newest first, with commits. Not a changelog of every edit.
79
+
80
+ ## Overview
81
+
82
+ One short document for the whole codebase, revised when its structure changes rather than with every edit.
83
+
84
+ ```markdown
85
+ ## Purpose
86
+ ## The Parts
87
+ ## Code Map
88
+ ## Rules Across The Code
89
+ ## Cross-Cutting Concerns
90
+ ## Subsystem Docs
91
+ ```
92
+
93
+ - **Purpose:** the problem the software solves, in a paragraph.
94
+ - **The Parts:** the major parts, how data and control flow between them, and the boundaries between layers.
95
+ - **Code Map:** one entry per top-level area: a sentence or three on what it does, its key types by name, and any boundary or invariant it keeps. A map of the country, not an atlas of its states.
96
+ - **Rules Across The Code:** invariants that span parts, especially absences, such as which layer never depends on which.
97
+ - **Cross-Cutting Concerns:** how errors, configuration, testing, performance, and security work across parts.
98
+ - **Subsystem Docs:** a list linking each subsystem doc with one line on what it covers.
99
+
100
+ ## Folder README
101
+
102
+ A folder README orients someone about to edit files in that folder.
103
+
104
+ ```markdown
105
+ # <Folder name>
106
+
107
+ <One sentence: what this folder is.> How it works and why: `<path to subsystem doc>`.
108
+
109
+ | File | Owns |
110
+ |---|---|
111
+ | `file.ts` | <what it is responsible for, in one or two sentences> |
112
+
113
+ ## Rules
114
+
115
+ - <A rule that holds for code in this folder.>
116
+
117
+ Tests: `<path to the folder's tests>`.
118
+ ```
119
+
120
+ Keep it to what someone editing the folder needs first. Explanation belongs in the subsystem doc it points to.
121
+
122
+ ## Feature File
123
+
124
+ Subsystem docs describe the software the way the code is built; a feature map describes it the way a user meets it, with the exact steps that show each feature working in the running software. Features cut across subsystems, so the map is its own folder beside them (`features/` in the developer docs): a `README.md` index and one file per user-facing feature. Software with nothing to run, such as a pure library, has no feature map; its tests are the live check.
125
+
126
+ A feature file uses the header. **Covers** names the code behind what the user sees, so the docs check flags the steps when that code changes. **Verified at** is the commit at which every step not marked unverified was last driven, not only read. Then:
127
+
128
+ ```markdown
129
+ # <Feature name>
130
+
131
+ <One paragraph: what the user sees and does.>
132
+
133
+ ## Sub-features
134
+ ## How to get to it (user POV)
135
+ ## Driving it
136
+ ## Gotchas
137
+ ```
138
+
139
+ - **Sub-features:** one line each, led by a short ID (`settings-open`) that evidence names reuse.
140
+ - **How to get to it (user POV):** every entry point a user has: a command, a key, a menu, a URL.
141
+ - **Driving it:** `Preconditions:` first, then one labeled bullet per user action, with the exact command and the observable result, including side effects such as files written. Mark a step that calls a paid service, such as a model, and say what it needs before it runs.
142
+ - **Gotchas:** traps that waste or invalidate a run, entry points not driven yet, and steps left unverified, with the reason.
143
+
144
+ Name only user paths, stable handles, required state, commands, and observable results; a source path appears only when it is the only stable handle. Link the subsystem docs the feature touches. A step that could not be driven stays marked unverified. A product bug the steps expose is reported to the user, never written into the steps as expected behavior.
145
+
146
+ The index `README.md` holds what every file shares: baseline preconditions, driving conventions, how proof and skipped steps are reported, and one line per feature file.
147
+
148
+ ## Live-Verification Guide
149
+
150
+ One guide shared by every feature file (for example `guides/verify-live.md` in the developer docs), with the helper script it documents kept in the repository. It uses the header, covering the helper.
151
+
152
+ ```markdown
153
+ ## Launch
154
+ ## Health Check
155
+ ## Drive
156
+ ## Evidence
157
+ ## Clean Up
158
+ ## Paid Calls
159
+ ```
160
+
161
+ - **Launch:** the exact command that starts an isolated instance from empty state, and the signal that it is usable, not merely running.
162
+ - **Health Check:** one read-only command that says whether this instance is worth driving: it is the one the run started, on the right build, with isolated state. Run it before the first step and after anything surprising.
163
+ - **Drive:** the helper's commands and the stable handles they rely on (prompts, labels, on-screen text), not coordinates or tab order.
164
+ - **Evidence:** what each step saves and where (an ignored folder), and the proof standards: drive the real user path, capture the action and the resulting state, and check side effects from a second view.
165
+ - **Clean Up:** stop only what the run started, never by process name; remove scratch state; keep the evidence.
166
+ - **Paid Calls:** which inputs call a model or another paid service, the guard that refuses them by default, and what a step needs before it may run one, such as a pinned cheap model and the user's yes.
167
+
168
+ ## Adapting To The Software
169
+
170
+ Shape the sections around what readers of this software need to know before changing it. For example:
171
+
172
+ - **A library:** the surface is its public API, so Surface becomes the API reference or points to the generated one; add compatibility promises and how versions change.
173
+ - **A service:** add how it is deployed, configured per environment, observed, and recovered; operational steps are how-to content, so keep them in a separate runbook the doc links.
174
+ - **A command-line tool:** the surface is its commands, flags, exit codes, and output formats.
175
+ - **A data pipeline:** add data shapes at each stage, ordering and idempotency guarantees, and what reprocessing does.
176
+ - **A small module:** purpose, surface, and a few invariants may be the whole document, or a folder README may be enough.
177
+
178
+ ## Test It On A New Reader
179
+
180
+ For a new subsystem doc or overview, or one you substantially rewrote, test it on a reader without your context. Write five to ten questions a newcomer would ask: where is the code that does X, why does it do Y, is Z a bug, what breaks if W changes, which test proves V. Give a fresh agent only the document and the questions (a subagent where the host has one; otherwise ask the user to run it in a new session). Compare each answer with the code. Where an answer is wrong or unsure, fix the document and ask again. The test passes when the answers are right without new gaps; it shows the reader understood the document, not that every claim is current.
181
+
182
+ ## User Guide
183
+
184
+ A user guide is task-oriented: what the user can do, the settings and commands involved, and what they will see. Keep internals out unless the user must understand them to use the feature correctly, and link the subsystem doc for readers who want more.