@litfamily/litclaude 1.0.37 → 1.0.39

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 (256) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +11 -8
  3. package/README_ko-KR.md +11 -8
  4. package/bin/litclaude-ai.js +3 -3
  5. package/docs/assets/readme/badge-version.svg +1 -1
  6. package/docs/assets/skills/lit-adhd.webp +0 -0
  7. package/docs/assets/skills/lit-hijack.webp +0 -0
  8. package/docs/assets/skills/lit-schematic.webp +0 -0
  9. package/docs/hooks.md +117 -26
  10. package/docs/workflow-compatibility-audit.md +1 -1
  11. package/package.json +1 -1
  12. package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
  13. package/plugins/litclaude/agents/lit-executor.md +4 -2
  14. package/plugins/litclaude/bin/litclaude-ai +1 -0
  15. package/plugins/litclaude/bin/litclaude-hook.js +373 -53
  16. package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
  17. package/plugins/litclaude/commands/lit-adhd.md +107 -0
  18. package/plugins/litclaude/commands/lit-hijack.md +102 -0
  19. package/plugins/litclaude/commands/lit-loop.md +4 -2
  20. package/plugins/litclaude/commands/lit-plan.md +5 -4
  21. package/plugins/litclaude/commands/lit-rewind.md +107 -0
  22. package/plugins/litclaude/commands/litgoal.md +5 -4
  23. package/plugins/litclaude/commands/start-work.md +25 -10
  24. package/plugins/litclaude/hooks/lit-mod.mjs +51 -5
  25. package/plugins/litclaude/lib/canonical-skill-catalog.mjs +3 -0
  26. package/plugins/litclaude/lib/canonical-skill-resources.mjs +205 -101
  27. package/plugins/litclaude/lib/lit-activation.mjs +24 -10
  28. package/plugins/litclaude/lib/mod/frame.mjs +235 -49
  29. package/plugins/litclaude/lib/mod/motion.mjs +21 -0
  30. package/plugins/litclaude/lib/mod/settings.mjs +4 -0
  31. package/plugins/litclaude/lib/mod/skills.mjs +3 -0
  32. package/plugins/litclaude/lib/mod/state.mjs +100 -7
  33. package/plugins/litclaude/lib/mod/svg-card.mjs +167 -25
  34. package/plugins/litclaude/lib/mod/timeline.mjs +28 -5
  35. package/plugins/litclaude/lib/mod/toasts.mjs +5 -2
  36. package/plugins/litclaude/lib/mod/view.mjs +240 -6
  37. package/plugins/litclaude/lib/mod/workflow.mjs +36 -7
  38. package/plugins/litclaude/lib/motion-render-gate.mjs +25 -7
  39. package/plugins/litclaude/lib/render_pages.py +29 -1
  40. package/plugins/litclaude/lib/rewind/brief.mjs +370 -0
  41. package/plugins/litclaude/lib/rewind/collect.mjs +413 -0
  42. package/plugins/litclaude/lib/rewind/gauge.mjs +87 -0
  43. package/plugins/litclaude/lib/rewind/next-step.mjs +89 -0
  44. package/plugins/litclaude/lib/rewind/redact.mjs +36 -0
  45. package/plugins/litclaude/lib/rewind/suggest.mjs +51 -0
  46. package/plugins/litclaude/lib/rewind/transcripts.mjs +259 -0
  47. package/plugins/litclaude/lib/start-work-lifecycle.mjs +403 -18
  48. package/plugins/litclaude/lib/workflow-stack.mjs +243 -0
  49. package/plugins/litclaude/lib/workflow-stage.mjs +127 -103
  50. package/plugins/litclaude/scripts/scaffold-plan.mjs +1 -1
  51. package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +18 -3
  52. package/plugins/litclaude/skills/frontend-ui-ux/kit/components.css +414 -0
  53. package/plugins/litclaude/skills/frontend-ui-ux/kit/fonts.json +22 -0
  54. package/plugins/litclaude/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
  55. package/plugins/litclaude/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
  56. package/plugins/litclaude/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
  57. package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
  58. package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
  59. package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
  60. package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
  61. package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
  62. package/plugins/litclaude/skills/frontend-ui-ux/kit/ui.js +226 -0
  63. package/plugins/litclaude/skills/frontend-ui-ux/references/brand-and-imagery.md +1 -1
  64. package/plugins/litclaude/skills/frontend-ui-ux/references/complete-contract.md +1 -0
  65. package/plugins/litclaude/skills/frontend-ui-ux/references/craft-floor.md +9 -4
  66. package/plugins/litclaude/skills/frontend-ui-ux/references/default-editorial-pixel.json +6 -5
  67. package/plugins/litclaude/skills/frontend-ui-ux/references/house-styles.md +234 -0
  68. package/plugins/litclaude/skills/frontend-ui-ux/references/motion-guide.md +3 -3
  69. package/plugins/litclaude/skills/frontend-ui-ux/references/production-interview.md +1 -1
  70. package/plugins/litclaude/skills/frontend-ui-ux/references/slop-register.md +7 -7
  71. package/plugins/litclaude/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
  72. package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +196 -0
  73. package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +30 -9
  74. package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +19 -7
  75. package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-static.mjs +12 -2
  76. package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe.mjs +53 -6
  77. package/plugins/litclaude/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
  78. package/plugins/litclaude/skills/lit-adhd/SKILL.md +168 -0
  79. package/plugins/litclaude/skills/lit-adhd/references/card-examples.md +125 -0
  80. package/plugins/litclaude/skills/lit-adhd/references/status-taxonomy.md +43 -0
  81. package/plugins/litclaude/skills/lit-adhd/scripts/rewind.mjs +11 -0
  82. package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +17 -5
  83. package/plugins/litclaude/skills/lit-diagram-drawer/references/style-guide.md +20 -11
  84. package/plugins/litclaude/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
  85. package/plugins/litclaude/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
  86. package/plugins/litclaude/skills/lit-diagram-drawer/references/type-tree.md +3 -3
  87. package/plugins/litclaude/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
  88. package/plugins/litclaude/skills/lit-diagram-drawer/references/verifier-guide.md +1 -1
  89. package/plugins/litclaude/skills/lit-diagram-drawer/scripts/visual-quality.mjs +3 -3
  90. package/plugins/litclaude/skills/lit-docx/SKILL.md +6 -1
  91. package/plugins/litclaude/skills/lit-docx/references/direction-step.md +8 -4
  92. package/plugins/litclaude/skills/lit-handoff/SKILL.md +2 -1
  93. package/plugins/litclaude/skills/lit-hijack/SKILL.md +551 -0
  94. package/plugins/litclaude/skills/lit-hijack/references/capture-and-provenance.md +124 -0
  95. package/plugins/litclaude/skills/lit-hijack/references/clean-room-build.md +133 -0
  96. package/plugins/litclaude/skills/lit-hijack/references/distil-and-licence.md +128 -0
  97. package/plugins/litclaude/skills/lit-hijack/references/gap-and-port-design.md +152 -0
  98. package/plugins/litclaude/skills/lit-hijack/references/parity-and-report.md +131 -0
  99. package/plugins/litclaude/skills/lit-hijack/scripts/hijack.mjs +854 -0
  100. package/plugins/litclaude/skills/lit-loop/SKILL.md +4 -3
  101. package/plugins/litclaude/skills/lit-plan/SKILL.md +16 -10
  102. package/plugins/litclaude/skills/lit-pptx/SKILL.md +35 -15
  103. package/plugins/litclaude/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
  104. package/plugins/litclaude/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
  105. package/plugins/litclaude/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
  106. package/plugins/litclaude/skills/lit-pptx/fonts/provenance.json +32 -1
  107. package/plugins/litclaude/skills/lit-pptx/references/agents/architect.md +1 -1
  108. package/plugins/litclaude/skills/lit-pptx/references/anti-slop-checklist.md +32 -11
  109. package/plugins/litclaude/skills/lit-pptx/references/authoring-guide.md +2 -2
  110. package/plugins/litclaude/skills/lit-pptx/references/data-display-cookbook.md +1 -1
  111. package/plugins/litclaude/skills/lit-pptx/references/density-and-fill.md +3 -4
  112. package/plugins/litclaude/skills/lit-pptx/references/direction-step.md +23 -4
  113. package/plugins/litclaude/skills/lit-pptx/references/examples/13-engineering-review-computational-brutalism-ko.md +173 -0
  114. package/plugins/litclaude/skills/lit-pptx/references/examples/14-launch-pitch-neo-brutalism-ko.md +154 -0
  115. package/plugins/litclaude/skills/lit-pptx/references/examples/15-design-lecture-bauhaus-ko.md +139 -0
  116. package/plugins/litclaude/skills/lit-pptx/references/examples/16-community-programme-riso-ko.md +158 -0
  117. package/plugins/litclaude/skills/lit-pptx/references/examples/17-public-data-briefing-newsroom-ko.md +179 -0
  118. package/plugins/litclaude/skills/lit-pptx/references/layout-families.md +22 -26
  119. package/plugins/litclaude/skills/lit-pptx/references/title-treatments.md +30 -26
  120. package/plugins/litclaude/skills/lit-pptx/references/tonalities/atlas.md +4 -4
  121. package/plugins/litclaude/skills/lit-pptx/references/tonalities/bauhaus.md +140 -0
  122. package/plugins/litclaude/skills/lit-pptx/references/tonalities/chalk.md +3 -3
  123. package/plugins/litclaude/skills/lit-pptx/references/tonalities/computational-brutalism.md +150 -0
  124. package/plugins/litclaude/skills/lit-pptx/references/tonalities/gazette.md +1 -1
  125. package/plugins/litclaude/skills/lit-pptx/references/tonalities/ledger.md +1 -1
  126. package/plugins/litclaude/skills/lit-pptx/references/tonalities/neo-brutalism.md +161 -0
  127. package/plugins/litclaude/skills/lit-pptx/references/tonalities/newsroom.md +144 -0
  128. package/plugins/litclaude/skills/lit-pptx/references/tonalities/night.md +1 -1
  129. package/plugins/litclaude/skills/lit-pptx/references/tonalities/paper.md +3 -3
  130. package/plugins/litclaude/skills/lit-pptx/references/tonalities/riso.md +137 -0
  131. package/plugins/litclaude/skills/lit-pptx/references/tonalities/signal.md +2 -2
  132. package/plugins/litclaude/skills/lit-pptx/references/tonalities/studio.md +6 -7
  133. package/plugins/litclaude/skills/lit-pptx/scripts/compile-deck.js +1 -1
  134. package/plugins/litclaude/skills/lit-pptx/scripts/craft_extras.py +135 -91
  135. package/plugins/litclaude/skills/lit-pptx/scripts/embed_fonts.py +13 -1
  136. package/plugins/litclaude/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
  137. package/plugins/litclaude/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
  138. package/plugins/litclaude/skills/lit-pptx/scripts/lib/render-pack.js +370 -563
  139. package/plugins/litclaude/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
  140. package/plugins/litclaude/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
  141. package/plugins/litclaude/skills/lit-pptx/scripts/qa_deck.py +5 -5
  142. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
  143. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
  144. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
  145. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +99 -0
  146. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
  147. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
  148. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
  149. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
  150. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
  151. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
  152. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
  153. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
  154. package/plugins/litclaude/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
  155. package/plugins/litclaude/skills/lit-recap/SKILL.md +4 -0
  156. package/plugins/litclaude/skills/lit-schematic/SKILL.md +123 -0
  157. package/plugins/litclaude/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
  158. package/plugins/litclaude/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
  159. package/plugins/litclaude/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
  160. package/plugins/litclaude/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
  161. package/plugins/litclaude/skills/lit-schematic/references/cutaway-outputs.md +70 -0
  162. package/plugins/litclaude/skills/lit-schematic/references/isometric-craft.md +101 -0
  163. package/plugins/litclaude/skills/lit-schematic/references/journal-figures.md +72 -0
  164. package/plugins/litclaude/skills/lit-schematic/references/kit-api.md +134 -0
  165. package/plugins/litclaude/skills/lit-schematic/references/pfd-and-layout.md +53 -0
  166. package/plugins/litclaude/skills/lit-schematic/references/pid-drafting.md +103 -0
  167. package/plugins/litclaude/skills/lit-schematic/references/pid-symbols.md +163 -0
  168. package/plugins/litclaude/skills/lit-schematic/references/verification.md +100 -0
  169. package/plugins/litclaude/skills/lit-schematic/scripts/doctor.mjs +57 -0
  170. package/plugins/litclaude/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
  171. package/plugins/litclaude/skills/lit-schematic/scripts/lib/fonts.mjs +27 -0
  172. package/plugins/litclaude/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
  173. package/plugins/litclaude/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
  174. package/plugins/litclaude/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
  175. package/plugins/litclaude/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
  176. package/plugins/litclaude/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
  177. package/plugins/litclaude/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
  178. package/plugins/litclaude/skills/lit-schematic/scripts/lib/png.mjs +132 -0
  179. package/plugins/litclaude/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
  180. package/plugins/litclaude/skills/lit-schematic/scripts/lib/route.mjs +218 -0
  181. package/plugins/litclaude/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
  182. package/plugins/litclaude/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
  183. package/plugins/litclaude/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
  184. package/plugins/litclaude/skills/lit-schematic/scripts/motion.mjs +129 -0
  185. package/plugins/litclaude/skills/lit-schematic/scripts/qa.mjs +92 -0
  186. package/plugins/litclaude/skills/lit-schematic/scripts/render.mjs +233 -0
  187. package/plugins/litclaude/skills/lit-schematic/scripts/scaffold.mjs +60 -0
  188. package/plugins/litclaude/skills/lit-scientific-visualization/SKILL.md +14 -4
  189. package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +54 -45
  190. package/plugins/litclaude/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +11 -0
  191. package/plugins/litclaude/skills/lit-typographic-motion/engine/blender/runner.py +218 -0
  192. package/plugins/litclaude/skills/lit-typographic-motion/engine/core/presets.mjs +1 -1
  193. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/analysis.mjs +65 -1
  194. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/assets.mjs +208 -0
  195. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/blender.mjs +143 -0
  196. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/board.mjs +136 -0
  197. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/brief.mjs +7 -1
  198. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/chrome.mjs +6 -4
  199. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-assets.mjs +5 -3
  200. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-capture.mjs +4 -4
  201. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +37 -4
  202. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +17 -5
  203. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/done.mjs +42 -3
  204. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/frame-worker.mjs +7 -5
  205. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/gallery.mjs +121 -0
  206. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/house.mjs +44 -0
  207. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/look.mjs +33 -19
  208. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/pipeline.mjs +18 -7
  209. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/scaffold.mjs +210 -0
  210. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/score.mjs +639 -0
  211. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/sound-cli.mjs +21 -4
  212. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/sound.mjs +126 -27
  213. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-capture.mjs +7 -6
  214. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-gate.mjs +59 -5
  215. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-qa.mjs +141 -9
  216. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-serve.mjs +28 -5
  217. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +82 -14
  218. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/styles.mjs +213 -0
  219. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/treatment.mjs +311 -10
  220. package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/cover-init.js +14 -2
  221. package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/init.js +11 -1
  222. package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/qa.js +6 -1
  223. package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/stage-kit.js +83 -0
  224. package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
  225. package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
  226. package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
  227. package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
  228. package/plugins/litclaude/skills/lit-typographic-motion/recipes/hero-3d/expected.json +69 -0
  229. package/plugins/litclaude/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
  230. package/plugins/litclaude/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +2 -0
  231. package/plugins/litclaude/skills/lit-typographic-motion/recipes/painted-light/expected.json +2 -0
  232. package/plugins/litclaude/skills/lit-typographic-motion/recipes/weight-tide/expected.json +2 -0
  233. package/plugins/litclaude/skills/lit-typographic-motion/references/cover.md +67 -15
  234. package/plugins/litclaude/skills/lit-typographic-motion/references/craft-loop.md +3 -2
  235. package/plugins/litclaude/skills/lit-typographic-motion/references/depth.md +122 -0
  236. package/plugins/litclaude/skills/lit-typographic-motion/references/look.md +28 -13
  237. package/plugins/litclaude/skills/lit-typographic-motion/references/runtime.md +4 -3
  238. package/plugins/litclaude/skills/lit-typographic-motion/references/sound.md +92 -23
  239. package/plugins/litclaude/skills/lit-typographic-motion/references/stage.md +43 -22
  240. package/plugins/litclaude/skills/lit-typographic-motion/references/studio.md +245 -0
  241. package/plugins/litclaude/skills/lit-typographic-motion/references/style-bibles.md +30 -6
  242. package/plugins/litclaude/skills/lit-typographic-motion/references/treatment.md +108 -14
  243. package/plugins/litclaude/skills/lit-typographic-motion/scripts/motion-doctor.mjs +16 -3
  244. package/plugins/litclaude/skills/lit-typographic-motion/scripts/motion.mjs +47 -7
  245. package/plugins/litclaude/skills/lit-typographic-motion/styles/paper.json +41 -0
  246. package/plugins/litclaude/skills/lit-typographic-motion/styles/swiss-signal.json +41 -0
  247. package/plugins/litclaude/skills/lit-typographic-motion/styles/terminalcore.json +42 -0
  248. package/plugins/litclaude/skills/lit-typographic-motion/styles/tidal.json +41 -0
  249. package/plugins/litclaude/skills/litgoal/SKILL.md +3 -2
  250. package/plugins/litclaude/skills/litresearch/SKILL.md +5 -0
  251. package/plugins/litclaude/skills/readme-studio/SKILL.md +10 -0
  252. package/plugins/litclaude/skills/readme-studio/references/production-interview.md +2 -0
  253. package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/package-lock.json +3 -3
  254. package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
  255. package/plugins/litclaude/skills/start-work/SKILL.md +24 -11
  256. package/scripts/qa-cover-recipes.mjs +3 -3
@@ -0,0 +1,243 @@
1
+ // The session's workflow stack, `.litclaude/workflow-stack/<session>.json`: where each running
2
+ // discipline stands, so asking for something in the middle of a loop or a plan run pauses that
3
+ // work instead of erasing it. The bottom frame is the spine (the main line of work: interview,
4
+ // plan, work, review, or a lit-loop or research run); a discipline started on top of it is a side
5
+ // frame. A successor in the main chain (plan after interview, work after plan, review after work)
6
+ // finishes the frame below it instead of pausing it. Asking for a skill already in the stack
7
+ // resumes its frame with its stage and count; `lit continue` on a side frame closes it and
8
+ // resumes the paused spine (plans/lit-adhd.md D1). Read-only disciplines never touch the stack.
9
+ // `applyStackEvent` is pure; the store below writes one small file per session, whole, and the
10
+ // card reads it back through its own guarded read. Frames keep skills, stages and counts only;
11
+ // never a prompt, a command or a path other than a project-relative plan name.
12
+
13
+ import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readSync, renameSync, writeFileSync } from "node:fs";
14
+ import { dirname, join } from "node:path";
15
+
16
+ import { ignitionFileName } from "./mod/state.mjs";
17
+ import { DISCIPLINE_ENTRY, REVIEW_LANES, STAGE_UNITS, VERDICT_STATES, normalizeStage } from "./mod/workflow.mjs";
18
+ import { ensureStateDirIgnored, resolveProjectStateRoot } from "./project-state-root.mjs";
19
+
20
+ export const MAX_FRAMES = 3;
21
+ export const MAX_HISTORY = 20;
22
+ export const MAX_STACK_BYTES = 64 * 1024;
23
+ export const STACK_DROP_MS = 24 * 60 * 60 * 1000;
24
+ export const READ_ONLY_DISCIPLINES = Object.freeze(["lit-recap", "lit-comprehend", "lit-handoff", "lit-adhd", "lit-rewind"]);
25
+
26
+ // Order in the main chain; a newcomer of a higher rank succeeds the frame below it.
27
+ const CHAIN_RANK = Object.freeze({
28
+ "deep-interview": 0,
29
+ "lit-brainstorm": 0,
30
+ "lit-crucible": 1,
31
+ "lit-plan": 1,
32
+ "start-work": 2,
33
+ litwork: 2,
34
+ litgoal: 2,
35
+ autoresearch: 2,
36
+ "lit-loop": 2,
37
+ "review-work": 3,
38
+ });
39
+ const MAX_VERDICTS = 8;
40
+ const PLAN_REF = /^plans\/[A-Za-z0-9_-][A-Za-z0-9._-]*\.md$/u;
41
+
42
+ export const emptyStack = (sessionId) => ({ version: 1, sessionId: typeof sessionId === "string" && sessionId ? sessionId : null, frames: [], history: [] });
43
+
44
+ const countOf = (value) => (Number.isInteger(value) && value >= 0 && value <= 9999 ? value : undefined);
45
+ const planRef = (ref) => (ref && typeof ref.plan === "string" && PLAN_REF.test(ref.plan) && !ref.plan.includes("..") ? { plan: ref.plan } : undefined);
46
+ const isSuccessor = (skill, frame) => CHAIN_RANK[skill] !== undefined && CHAIN_RANK[frame.skill] !== undefined && CHAIN_RANK[skill] > CHAIN_RANK[frame.skill];
47
+
48
+ const newFrame = (skill, ref, role, at) => {
49
+ const entry = DISCIPLINE_ENTRY[skill];
50
+ const frame = { skill, family: entry?.family ?? null, stage: entry?.stage ?? null, role, status: "active", verdicts: {}, at };
51
+ const plan = planRef(ref);
52
+ if (plan) frame.ref = plan;
53
+ return frame;
54
+ };
55
+
56
+ // A saved plan, or a review whose five lanes have all reported: what comes next replaces it.
57
+ const isFinished = (frame) => frame.done === true
58
+ || (frame.family === "main" && frame.stage === "review" && REVIEW_LANES.every(({ id }) => ["pass", "fail"].includes(frame.verdicts?.[id])));
59
+
60
+ const counts = (frame) => ({ stage: frame.stage, n: frame.n, total: frame.total });
61
+
62
+ /**
63
+ * Applies one event to the stack and returns the next stack with the transitions it made
64
+ * (`started`, `paused`, `resumed`, `side.done`, `finished`, `dropped`), which the caller may log.
65
+ * Events: `start {skill, ref?, restart?}`, `continue`, `move {family, stage, n?, total?, unit?,
66
+ * done?, verdicts?, ref?, scope?}` (the hooks' observations) and `record {...same fields}` (the model's
67
+ * `litclaude-ai workflow-stage` call, which updates the top frame or opens one).
68
+ */
69
+ export const applyStackEvent = (stack, event, now = new Date()) => {
70
+ const at = now.toISOString();
71
+ const transitions = [];
72
+ const note = (type, frame) => transitions.push({ type, skill: frame.skill, ...counts(frame) });
73
+ let frames = (Array.isArray(stack?.frames) ? stack.frames : [])
74
+ .filter((frame) => now.getTime() - Date.parse(frame.at) <= STACK_DROP_MS)
75
+ .map((frame) => ({ ...frame }));
76
+ const pause = (frame) => {
77
+ if (frame.status === "paused") return;
78
+ frame.status = "paused";
79
+ frame.pausedAt = at;
80
+ note("paused", frame);
81
+ };
82
+ const activate = (frame) => {
83
+ const wasPaused = frame.status === "paused";
84
+ frame.status = "active";
85
+ frame.at = at;
86
+ delete frame.pausedAt;
87
+ if (wasPaused) note("resumed", frame);
88
+ };
89
+ const closeAbove = (index, type) => {
90
+ for (const frame of frames.slice(index + 1).reverse()) note(type, frame);
91
+ frames = frames.slice(0, index + 1);
92
+ };
93
+ const push = (frame) => {
94
+ frames.push(frame);
95
+ note("started", frame);
96
+ while (frames.length > MAX_FRAMES) {
97
+ const side = frames.findIndex((candidate, index) => index < frames.length - 1 && candidate.role === "side");
98
+ const [dropped] = frames.splice(side === -1 ? 0 : side, 1);
99
+ note("dropped", dropped);
100
+ }
101
+ };
102
+
103
+ const start = (skill, ref, restart) => {
104
+ if (READ_ONLY_DISCIPLINES.includes(skill)) return;
105
+ const hasFamily = Boolean(DISCIPLINE_ENTRY[skill]);
106
+ if (restart) {
107
+ closeAbove(-1, "finished");
108
+ push(newFrame(skill, ref, hasFamily ? "spine" : "side", at));
109
+ return;
110
+ }
111
+ const existing = frames.findLastIndex((frame) => frame.skill === skill);
112
+ if (existing !== -1) {
113
+ const wanted = planRef(ref);
114
+ const kept = frames[existing].ref?.plan;
115
+ if (!isFinished(frames[existing]) && (!wanted || !kept || wanted.plan === kept)) {
116
+ closeAbove(existing, "side.done");
117
+ activate(frames[existing]);
118
+ if (wanted) frames[existing].ref = wanted;
119
+ return;
120
+ }
121
+ const role = frames[existing].role;
122
+ closeAbove(existing - 1, "finished");
123
+ if (frames.length) pause(frames.at(-1));
124
+ push(newFrame(skill, ref, role, at));
125
+ return;
126
+ }
127
+ let inherited = null;
128
+ let handed = null;
129
+ while (frames.length && isFinished(frames.at(-1))) {
130
+ const done = frames.pop();
131
+ note("finished", done);
132
+ inherited = done.role;
133
+ handed = handed ?? done.ref;
134
+ }
135
+ // Work that follows a plan in the main chain carries the plan's name on, so its count is the plan's.
136
+ const carried = (from) => ref ?? (CHAIN_RANK[skill] >= CHAIN_RANK["start-work"] ? from : undefined);
137
+ const top = frames.at(-1);
138
+ if (!top) {
139
+ push(newFrame(skill, carried(handed), hasFamily ? inherited ?? "spine" : "side", at));
140
+ } else if (!frames.some((frame) => frame.role === "spine")) {
141
+ closeAbove(-1, "finished");
142
+ push(newFrame(skill, ref, hasFamily ? "spine" : "side", at));
143
+ } else if (hasFamily && isSuccessor(skill, top)) {
144
+ frames.pop();
145
+ note(top.role === "spine" ? "finished" : "side.done", top);
146
+ push(newFrame(skill, carried(top.ref ?? handed), top.role, at));
147
+ } else {
148
+ pause(top);
149
+ push(newFrame(skill, ref, "side", at));
150
+ }
151
+ };
152
+
153
+ const update = (frame, fields) => {
154
+ const stage = normalizeStage(fields.family, fields.stage) ? String(fields.stage).trim() : null;
155
+ if (!stage) return;
156
+ const named = fields.family === "loop" ? stage.toUpperCase() : stage.toLowerCase();
157
+ const sameStage = frame.family === fields.family && frame.stage === named;
158
+ frame.family = fields.family;
159
+ frame.stage = named;
160
+ for (const key of ["n", "total"]) {
161
+ const value = countOf(fields[key]);
162
+ if (value !== undefined) frame[key] = value;
163
+ }
164
+ if (STAGE_UNITS.includes(fields.unit)) frame.unit = fields.unit;
165
+ if (typeof fields.done === "boolean") frame.done = fields.done;
166
+ const plan = planRef(fields.ref);
167
+ if (plan) frame.ref = plan;
168
+ const given = Object.entries(fields.verdicts ?? {}).filter(([name, state]) => /^[a-z][a-z0-9-]{0,23}$/u.test(name) && VERDICT_STATES.includes(state));
169
+ frame.verdicts = Object.fromEntries([...Object.entries(sameStage ? frame.verdicts ?? {} : {}), ...given].slice(-MAX_VERDICTS));
170
+ frame.at = at;
171
+ };
172
+
173
+ switch (event?.type) {
174
+ case "start":
175
+ start(event.skill, event.ref, event.restart === true);
176
+ break;
177
+ case "continue": {
178
+ const top = frames.at(-1);
179
+ const spine = frames.findLastIndex((frame) => frame.role === "spine");
180
+ if (top?.role === "side" && spine !== -1) {
181
+ closeAbove(spine, "side.done");
182
+ activate(frames[spine]);
183
+ }
184
+ break;
185
+ }
186
+ case "move": {
187
+ const target = event.scope === "nearest"
188
+ ? frames.findLast((frame) => frame.family === event.family && frame.stage === event.stage)
189
+ : frames.at(-1);
190
+ if (target && target.family === event.family && (event.scope === "nearest" || target.status === "active")) update(target, event);
191
+ break;
192
+ }
193
+ case "record":
194
+ if (frames.length) update(frames.at(-1), event);
195
+ else if (normalizeStage(event.family, event.stage)) {
196
+ const frame = { skill: null, family: event.family, stage: null, role: "spine", status: "active", verdicts: {}, at };
197
+ update(frame, event);
198
+ push(frame);
199
+ }
200
+ break;
201
+ default:
202
+ break;
203
+ }
204
+
205
+ if (frames.length && frames.at(-1).status !== "active") activate(frames.at(-1));
206
+ const history = [...(Array.isArray(stack?.history) ? stack.history : []), ...transitions.map(({ type, skill }) => ({ event: type, skill, at }))].slice(-MAX_HISTORY);
207
+ return { stack: { version: 1, sessionId: stack?.sessionId ?? null, frames, history }, transitions };
208
+ };
209
+
210
+ export const stackPath = (cwd, sessionId) => join(resolveProjectStateRoot(cwd), ".litclaude", "workflow-stack", ignitionFileName(sessionId));
211
+
212
+ /** Reads the session's stack; a link, a non-file, an oversized or malformed file reads as empty. */
213
+ export const readStack = (cwd, sessionId) => {
214
+ const empty = emptyStack(sessionId);
215
+ let fd;
216
+ try {
217
+ const path = stackPath(cwd, sessionId);
218
+ if (!lstatSync(path).isFile()) return empty;
219
+ fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
220
+ const { size } = fstatSync(fd);
221
+ if (size > MAX_STACK_BYTES) return empty;
222
+ const buffer = Buffer.alloc(size);
223
+ readSync(fd, buffer, 0, size, 0);
224
+ const parsed = JSON.parse(buffer.toString("utf8"));
225
+ if (!parsed || !Array.isArray(parsed.frames) || parsed.frames.length > MAX_FRAMES) return empty;
226
+ return { ...empty, frames: parsed.frames, history: Array.isArray(parsed.history) ? parsed.history.slice(-MAX_HISTORY) : [] };
227
+ } catch {
228
+ return empty;
229
+ } finally {
230
+ if (fd !== undefined) closeSync(fd);
231
+ }
232
+ };
233
+
234
+ /** Writes the whole stack through a temporary file; a link at the destination is replaced, never followed. */
235
+ export const writeStack = (cwd, sessionId, stack) => {
236
+ const path = stackPath(cwd, sessionId);
237
+ mkdirSync(dirname(path), { recursive: true });
238
+ ensureStateDirIgnored(path);
239
+ const staging = `${path}.${process.pid}.tmp`;
240
+ writeFileSync(staging, `${JSON.stringify(stack)}\n`, { flag: "w" });
241
+ renameSync(staging, path);
242
+ return stack;
243
+ };
@@ -1,71 +1,88 @@
1
- // The LIT card's stage record, `.litclaude/workflow-stage.json`: where the session stands when the
2
- // state files alone cannot say (a plan just saved, the task count between start-work's own
1
+ // The LIT card's workflow map follows the session's workflow stack
2
+ // (`.litclaude/workflow-stack/<session>.json`, lib/workflow-stack.mjs): where the session stands
3
+ // when the state files alone cannot say (a plan just saved, the task count between start-work's own
3
4
  // progress records, review lanes starting and reporting, lit-loop's step, autoresearch's
4
- // iteration, lit-crucible's verdict). LitClaude's hooks keep it moving from what they already
5
- // see, with no help from the model. The prompt and PreToolUse hooks start it when one of
6
- // STAGE_RECORD_SKILLS starts and clear it for any other discipline; PreToolUse marks a review
7
- // lane running when its reviewer is spawned; PostToolUse moves it when the plan file is saved, a
8
- // task is checked in the active plan, a lit-loop test is written (with Write or Edit or through
9
- // the shell), made to pass, run or recorded, or a foreground reviewer reports; SubagentStop takes a background reviewer's verdict.
10
- // `litclaude-ai workflow-stage` stays as the model's optional refinement. The card
11
- // (lib/mod/state.mjs) reads the record back. One small file, written whole, its fields checked
12
- // against the same tables the card draws from (lib/mod/workflow.mjs). The hooks keep only which
13
- // stage, which lane and how many; never a path, a command or a prompt.
14
-
15
- import { closeSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
5
+ // iteration, lit-crucible's verdict), and which work is paused under an interjected discipline.
6
+ // LitClaude's hooks keep it moving from what they already see, with no help from the model. The
7
+ // prompt and PreToolUse hooks push a frame when a discipline starts (a read-only one changes
8
+ // nothing); PreToolUse marks a review lane running when its reviewer is spawned; PostToolUse moves
9
+ // the top frame when the plan file is saved, a task is checked in the active plan, a lit-loop test
10
+ // is written (with Write or Edit or through the shell), made to pass, run or recorded, or a
11
+ // foreground reviewer reports; SubagentStop takes a background reviewer's verdict, which reaches the
12
+ // review frame even while a side frame is on top. `litclaude-ai workflow-stage` stays as the
13
+ // model's optional refinement. The card (lib/mod/state.mjs) reads the stack back. The hooks keep
14
+ // only which stage, which lane and how many; never a path, a command or a prompt.
15
+
16
+ import { closeSync, lstatSync, openSync, readFileSync, readSync, readdirSync, realpathSync, statSync } from "node:fs";
16
17
  import { join, relative, resolve } from "node:path";
17
18
 
18
19
  import { DISCIPLINE_ENTRY, STAGE_UNITS, VERDICT_STATES, WORKFLOW_FAMILIES, WORKFLOW_FRESH_MS, normalizeStage, reviewLaneOf } from "./mod/workflow.mjs";
19
- import { ensureStateDirIgnored, resolveProjectStateRoot } from "./project-state-root.mjs";
20
+ import { resolveProjectStateRoot } from "./project-state-root.mjs";
21
+ import { appendLitgoalLedger } from "./litgoal/ledger.mjs";
22
+ import { litgoalGoalsPath, litgoalLedgerPath } from "./litgoal/paths.mjs";
23
+ import { readLitgoalState } from "./litgoal/state.mjs";
20
24
  import { readPlanProgress } from "./start-work-lifecycle.mjs";
25
+ import { applyStackEvent, readStack, stackPath, writeStack } from "./workflow-stack.mjs";
21
26
 
22
- // The skills whose next move only this record can carry: the plan's save, review lanes, lit-loop
23
- // steps, autoresearch iterations, the crucible verdict. Every other skill's place comes from the
24
- // state files, so its start clears the record instead of writing one.
25
- export const STAGE_RECORD_SKILLS = Object.freeze(["lit-plan", "review-work", "lit-loop", "autoresearch", "lit-crucible"]);
26
27
  const MAX_VERDICTS = 8;
28
+ // A prompt's plan, kept on the frame so asking for the same skill on another plan starts over.
29
+ const PROMPT_PLAN = /(?:^|[\s(`'"])(plans\/[A-Za-z0-9_-][A-Za-z0-9._-]*\.md)(?=$|[\s)`'".,;:])/u;
27
30
 
28
31
  export class WorkflowStageError extends Error {}
29
32
 
30
- export const workflowStagePath = (cwd) => join(resolveProjectStateRoot(cwd), ".litclaude", "workflow-stage.json");
33
+ export const planRefOf = (prompt) => {
34
+ const plan = PROMPT_PLAN.exec(typeof prompt === "string" ? prompt.slice(0, 16_384) : "")?.[1];
35
+ return plan ? { plan } : undefined;
36
+ };
37
+
38
+ // A frame as the hooks' moves read it: a known family and stage, fresh, with the session's id.
39
+ const frameRecord = (frame, sessionId) => {
40
+ if (!frame || !Object.hasOwn(WORKFLOW_FAMILIES, frame.family ?? "")) return null;
41
+ const at = Date.parse(frame.at);
42
+ if (!Number.isFinite(at) || Date.now() - at > WORKFLOW_FRESH_MS) return null;
43
+ return { ...frame, sessionId, stage: normalizeStage(frame.family, frame.stage) };
44
+ };
45
+
46
+ // A pause, a side frame closed and a resume are part of the goal's story, so while a litgoal goal is
47
+ // open they go into its ledger: the skill, its stage and its count, never a prompt or a path.
48
+ const LEDGER_EVENTS = Object.freeze({ paused: "workflow.paused", resumed: "workflow.resumed", "side.done": "workflow.side.done" });
49
+ const OPEN_GOAL = new Set(["active", "review_blocked", "blocked", "needs_user_decision"]);
31
50
 
32
- const readRecord = (path) => {
51
+ const logStackTransitions = (cwd, transitions) => {
52
+ const logged = transitions.filter(({ type, skill }) => LEDGER_EVENTS[type] && skill);
53
+ if (!logged.length) return;
33
54
  try {
34
- if (lstatSync(path).isSymbolicLink()) return null;
35
- const parsed = JSON.parse(readFileSync(path, "utf8"));
36
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
55
+ if (!OPEN_GOAL.has(readLitgoalState(litgoalGoalsPath(cwd), null)?.status)) return;
56
+ for (const { type, skill, stage, n, total } of logged) appendLitgoalLedger(litgoalLedgerPath(cwd), { event: LEDGER_EVENTS[type], skill, stage, n, total });
37
57
  } catch {
38
- return null;
58
+ // An unreadable goal or ledger never stops the stack from moving.
39
59
  }
40
60
  };
41
61
 
42
- const writeRecord = (path, record) => {
43
- mkdirSync(join(path, ".."), { recursive: true });
44
- ensureStateDirIgnored(path);
45
- const staging = `${path}.${process.pid}.tmp`;
46
- writeFileSync(staging, `${JSON.stringify(record)}\n`);
47
- renameSync(staging, path);
48
- return record;
62
+ const applyAndWrite = (cwd, sessionId, event, now = new Date()) => {
63
+ const { stack, transitions } = applyStackEvent(readStack(cwd, sessionId), event, now);
64
+ writeStack(cwd, sessionId, stack);
65
+ logStackTransitions(cwd, transitions);
66
+ return { stack, transitions };
49
67
  };
50
68
 
51
69
  /**
52
- * Starts the record at the skill's first stage. Any other discipline removes it, so a record from
53
- * an earlier review or loop never outlasts the work that came after it.
70
+ * Pushes, resumes or restarts the skill's frame on the session's stack. Returns the transitions
71
+ * (`paused`, `resumed`, `side.done`, ...) so the caller can log them.
54
72
  */
55
- export const startWorkflowStage = (cwd, { sessionId, skill, now = new Date() }) => {
56
- if (!STAGE_RECORD_SKILLS.includes(skill)) {
57
- rmSync(workflowStagePath(cwd), { force: true });
58
- return null;
59
- }
60
- const { family, stage } = DISCIPLINE_ENTRY[skill];
61
- return writeRecord(workflowStagePath(cwd), {
62
- sessionId: typeof sessionId === "string" && sessionId ? sessionId : null,
63
- skill,
64
- family,
65
- stage,
66
- verdicts: {},
67
- at: now.toISOString(),
68
- });
73
+ export const startWorkflowStage = (cwd, { sessionId, skill, ref, restart = false, now = new Date() }) => {
74
+ if (typeof sessionId !== "string" || !sessionId || typeof skill !== "string") return [];
75
+ return applyAndWrite(cwd, sessionId, { type: "start", skill, ref, restart }, now).transitions;
76
+ };
77
+
78
+ /** `lit continue` on a side frame: closes it and resumes the paused spine (plans/lit-adhd.md D1). */
79
+ export const continueWorkflowStack = (cwd, { sessionId, now = new Date() }) => {
80
+ if (typeof sessionId !== "string" || !sessionId) return { stack: null, transitions: [] };
81
+ const result = applyStackEvent(readStack(cwd, sessionId), { type: "continue" }, now);
82
+ if (!result.transitions.length) return result;
83
+ writeStack(cwd, sessionId, result.stack);
84
+ logStackTransitions(cwd, result.transitions);
85
+ return result;
69
86
  };
70
87
 
71
88
  const countArg = (value, name) => {
@@ -76,64 +93,67 @@ const countArg = (value, name) => {
76
93
  };
77
94
 
78
95
  /**
79
- * Moves the record to `stage` of `family`. Verdicts given for the same family and stage add to the
80
- * ones already there, so review lanes report one at a time; the session is the one the hook
81
- * started the record for.
96
+ * The session `litclaude-ai workflow-stage` writes for: `--session`, else the host's session id,
97
+ * else the project's most recently written stack whose top frame is active and fresh, else
98
+ * `unknown-session` (which the card also reads).
82
99
  */
83
- export const recordWorkflowStage = (cwd, { family, stage, n, total, unit, verdicts = {}, now = new Date() }) => {
100
+ export const resolveStageSession = (cwd, { session, env = process.env, now = Date.now() } = {}) => {
101
+ if (typeof session === "string" && session.trim()) return session.trim();
102
+ const host = env.CLAUDE_CODE_SESSION_ID;
103
+ if (typeof host === "string" && host.trim()) return host.trim();
104
+ const dir = join(stackPath(cwd, "x"), "..");
105
+ let newest = null;
106
+ try {
107
+ for (const name of readdirSync(dir).filter((entry) => entry.endsWith(".json")).slice(0, 200)) {
108
+ const stat = lstatSync(join(dir, name));
109
+ if (!stat.isFile() || now - stat.mtimeMs > WORKFLOW_FRESH_MS || (newest && newest.at >= stat.mtimeMs)) continue;
110
+ const parsed = JSON.parse(readFileSync(join(dir, name), "utf8"));
111
+ if (parsed?.frames?.at?.(-1)?.status === "active" && typeof parsed.sessionId === "string" && parsed.sessionId) newest = { id: parsed.sessionId, at: stat.mtimeMs };
112
+ }
113
+ } catch {
114
+ // No stack directory yet.
115
+ }
116
+ return newest?.id ?? "unknown-session";
117
+ };
118
+
119
+ /**
120
+ * The model's refinement: moves the session's top frame to `stage` of `family`, or opens a frame
121
+ * when the stack is empty. Verdicts given for the same family and stage add to the ones already there.
122
+ */
123
+ export const recordWorkflowStage = (cwd, { sessionId, family, stage, n, total, unit, verdicts = {}, now = new Date() }) => {
84
124
  if (!Object.hasOwn(WORKFLOW_FAMILIES, family ?? "")) throw new WorkflowStageError(`unknown family "${family}"; families: ${Object.keys(WORKFLOW_FAMILIES).join(", ")}`);
85
- const normalized = normalizeStage(family, stage);
86
- if (!normalized) throw new WorkflowStageError(`unknown ${family} stage "${stage}"; stages: ${WORKFLOW_FAMILIES[family].join(", ")}`);
125
+ if (!normalizeStage(family, stage)) throw new WorkflowStageError(`unknown ${family} stage "${stage}"; stages: ${WORKFLOW_FAMILIES[family].join(", ")}`);
87
126
  if (unit !== undefined && !STAGE_UNITS.includes(unit)) throw new WorkflowStageError(`unit takes one of: ${STAGE_UNITS.join(", ")}`);
88
127
  for (const [name, state] of Object.entries(verdicts)) {
89
128
  if (!/^[a-z][a-z0-9-]{0,23}$/u.test(name)) throw new WorkflowStageError(`verdict name "${name}" must be lowercase letters, digits and dashes`);
90
129
  if (!VERDICT_STATES.includes(state)) throw new WorkflowStageError(`verdict takes one of: ${VERDICT_STATES.join(", ")}`);
91
130
  }
92
- const path = workflowStagePath(cwd);
93
- const previous = readRecord(path);
94
- const same = previous?.family === family && normalizeStage(family, previous.stage) === normalized;
95
- const merged = { ...(same && previous.verdicts && typeof previous.verdicts === "object" ? previous.verdicts : {}), ...verdicts };
96
- if (Object.keys(merged).length > MAX_VERDICTS) throw new WorkflowStageError(`at most ${MAX_VERDICTS} verdicts per stage`);
97
- const record = {
98
- sessionId: typeof previous?.sessionId === "string" ? previous.sessionId : null,
99
- skill: typeof previous?.skill === "string" ? previous.skill : null,
100
- family,
101
- stage: String(stage).trim(),
102
- verdicts: merged,
103
- at: now.toISOString(),
104
- };
105
- const counted = { n: countArg(n, "--n"), total: countArg(total, "--total") };
106
- for (const [key, value] of Object.entries(counted)) if (value !== undefined) record[key] = value;
107
- if (unit !== undefined) record.unit = unit;
108
- return writeRecord(path, record);
131
+ const session = resolveStageSession(cwd, { session: sessionId, now: now.getTime() });
132
+ const top = readStack(cwd, session).frames.at(-1);
133
+ const same = top?.family === family && normalizeStage(family, top.stage) === normalizeStage(family, stage);
134
+ if (Object.keys({ ...(same ? top.verdicts ?? {} : {}), ...verdicts }).length > MAX_VERDICTS) throw new WorkflowStageError(`at most ${MAX_VERDICTS} verdicts per stage`);
135
+ const event = { type: "record", family, stage: String(stage).trim(), n: countArg(n, "--n"), total: countArg(total, "--total"), unit, verdicts };
136
+ const { stack } = applyAndWrite(cwd, session, event, now);
137
+ return { sessionId: session, ...stack.frames.at(-1) };
109
138
  };
110
139
 
111
140
  // --- The hooks' own moves -------------------------------------------------------------------
112
141
 
113
- // This session's record while it still says where the session is.
114
- const currentRecord = (cwd, sessionId) => {
115
- const record = readRecord(workflowStagePath(cwd));
116
- if (!record || record.sessionId !== sessionId || !Object.hasOwn(WORKFLOW_FAMILIES, record.family ?? "")) return null;
117
- const at = Date.parse(record.at);
118
- if (!Number.isFinite(at) || Date.now() - at > WORKFLOW_FRESH_MS) return null;
119
- return { ...record, stage: normalizeStage(record.family, record.stage) };
120
- };
121
-
122
- // Writes the session's record at `stage`; verdicts add to those of the same stage.
123
- const moveStage = (cwd, sessionId, previous, { family, stage, n, total, unit, done, verdicts = {} }) => {
124
- const same = previous?.family === family && previous.stage === stage;
125
- const record = {
126
- sessionId,
127
- skill: typeof previous?.skill === "string" ? previous.skill : null,
128
- family,
129
- stage,
130
- verdicts: { ...(same && previous.verdicts && typeof previous.verdicts === "object" ? previous.verdicts : {}), ...verdicts },
131
- at: new Date().toISOString(),
132
- };
133
- if (Object.keys(record.verdicts).length > MAX_VERDICTS) return previous;
134
- if (Number.isInteger(n) && Number.isInteger(total)) Object.assign(record, { n, total, unit });
135
- if (done) record.done = true;
136
- return writeRecord(workflowStagePath(cwd), record);
142
+ // This session's top frame while it still says where the session is.
143
+ const currentRecord = (cwd, sessionId) => frameRecord(readStack(cwd, sessionId).frames.at(-1), sessionId);
144
+
145
+ // The session's nearest frame at `stage` of `family`, paused or not: where a background reviewer's
146
+ // verdict or a checked plan task belongs while a side frame is on top.
147
+ const nearestRecord = (cwd, sessionId, family, stage) => frameRecord(readStack(cwd, sessionId).frames.findLast((frame) => frame.family === family && normalizeStage(family, frame.stage) === stage), sessionId);
148
+
149
+ // Moves the session's top frame (or, with `nearest`, the nearest frame at that stage) and returns
150
+ // it; on an empty stack the move opens a frame, as the single record did.
151
+ const moveStage = (cwd, sessionId, fields, { nearest = false } = {}) => {
152
+ const stack = readStack(cwd, sessionId);
153
+ const event = stack.frames.length ? { type: "move", ...fields, scope: nearest ? "nearest" : "top" } : { type: "record", ...fields };
154
+ const next = applyAndWrite(cwd, sessionId, event).stack;
155
+ const frame = nearest ? next.frames.findLast((candidate) => candidate.family === fields.family && candidate.stage === fields.stage) : next.frames.at(-1);
156
+ return frameRecord(frame, sessionId);
137
157
  };
138
158
 
139
159
  // review-work titles every lane prompt `Review lane: <lane>.`; the card's lane comes from that title.
@@ -160,13 +180,14 @@ const resultText = (value, depth = 0) => {
160
180
  return ["text", "content", "result", "output"].map((key) => resultText(value[key], depth + 1)).join("\n");
161
181
  };
162
182
 
163
- const markLane = (cwd, sessionId, previous, lane, state) => {
183
+ const markLane = (cwd, sessionId, top, lane, state) => {
164
184
  if (!lane) return null;
185
+ const previous = top?.family === "main" && top.stage === "review" ? top : nearestRecord(cwd, sessionId, "main", "review") ?? top;
165
186
  const keep = previous?.family === "main" && previous.stage === "review";
166
187
  if (keep && previous.verdicts?.[lane] === state) return previous;
167
188
  // A reviewer that already reported is not set back to running by a second look.
168
189
  if (state === "running" && keep && ["pass", "fail"].includes(previous.verdicts?.[lane])) return previous;
169
- return moveStage(cwd, sessionId, previous, { family: "main", stage: "review", verdicts: { [lane]: state } });
190
+ return moveStage(cwd, sessionId, { family: "main", stage: "review", verdicts: { [lane]: state } }, { nearest: keep });
170
191
  };
171
192
 
172
193
  const TEST_PATH = /(?:^|\/)(?:tests?|__tests__|specs?)\/|[._-](?:test|spec)\.[A-Za-z0-9]+$/u;
@@ -188,7 +209,7 @@ const LOOP_MOVES = Object.freeze([
188
209
  const moveLoop = (cwd, sessionId, previous, signal) => {
189
210
  if (previous?.family !== "loop") return null;
190
211
  const move = LOOP_MOVES.find(({ on, from }) => on === signal && from.includes(previous.stage));
191
- return move ? moveStage(cwd, sessionId, previous, { family: "loop", stage: move.to }) : null;
212
+ return move ? moveStage(cwd, sessionId, { family: "loop", stage: move.to }) : null;
192
213
  };
193
214
 
194
215
  // A test run's report of at least one failure: TAP (`not ok 2`, `# fail 1`) or a runner's summary
@@ -341,7 +362,7 @@ export const observeWorkflowPostTool = (cwd, input, { filePaths = [], lifecycleR
341
362
  if (tool === "Bash") {
342
363
  const command = typeof input.tool_input?.command === "string" ? input.tool_input.command : "";
343
364
  if (!failed && planOpen && PLAN_SCAFFOLD.test(command) && !/--check\b|--draft-only\b/u.test(command)) {
344
- return moveStage(cwd, sessionId, previous, { family: "main", stage: "plan", done: true });
365
+ return moveStage(cwd, sessionId, { family: "main", stage: "plan", done: true, ref: { plan: inProject } });
345
366
  }
346
367
  if (!failed && LITGOAL_EVIDENCE.test(command)) return moveLoop(cwd, sessionId, previous, "evidence");
347
368
  // Files the command wrote move the loop as a Write or Edit would; then its test run, where a
@@ -370,16 +391,18 @@ export const observeWorkflowPostTool = (cwd, input, { filePaths = [], lifecycleR
370
391
  }
371
392
  if (!filePaths.length) return null;
372
393
  const root = resolveProjectStateRoot(cwd);
373
- const work = !previous || previous.family === "main" ? activeWork(lifecycleRoot, sessionId) : null;
394
+ const workFrame = previous?.family === "main" ? previous : nearestRecord(cwd, sessionId, "main", "work");
395
+ const work = !previous || workFrame ? activeWork(lifecycleRoot, sessionId) : null;
374
396
  let moved = null;
375
397
  for (const path of filePaths.slice(0, 20)) {
376
398
  const absolute = realOrResolved(resolve(cwd, path));
377
399
  if (work && absolute === realOrResolved(work.active_plan)) {
378
400
  const progress = readPlanProgress(work.active_plan);
379
- if (progress.total > 0) return moveStage(cwd, sessionId, previous, { family: "main", stage: "work", n: progress.checked, total: progress.total, unit: "task" });
401
+ const nearest = workFrame !== previous && workFrame?.stage === "work";
402
+ if (progress.total > 0) return moveStage(cwd, sessionId, { family: "main", stage: "work", n: progress.checked, total: progress.total, unit: "task" }, { nearest });
380
403
  }
381
404
  const inProject = relative(realOrResolved(root), absolute).split("\\").join("/");
382
- if (planOpen && /^plans\/[A-Za-z0-9._-]+\.md$/u.test(inProject)) return moveStage(cwd, sessionId, previous, { family: "main", stage: "plan", done: true });
405
+ if (planOpen && /^plans\/[A-Za-z0-9._-]+\.md$/u.test(inProject)) return moveStage(cwd, sessionId, { family: "main", stage: "plan", done: true, ref: { plan: inProject } });
383
406
  if (inProject.startsWith("..") || /^(?:\.litclaude|plans)\//u.test(inProject)) continue;
384
407
  moved = moveLoop(cwd, sessionId, moved ?? previous, TEST_PATH.test(inProject) ? "test-edit" : "source-edit") ?? moved;
385
408
  }
@@ -422,7 +445,7 @@ export const observeWorkflowSubagentStop = (cwd, input) => {
422
445
  return lane ? markLane(cwd, sessionId, currentRecord(cwd, sessionId), lane, verdict) : null;
423
446
  };
424
447
 
425
- const USAGE = `Usage: litclaude-ai workflow-stage <family> <stage> [--n N] [--total M] [--unit ${STAGE_UNITS.join("|")}] [--verdict <name>=${VERDICT_STATES.join("|")}]... [--json]
448
+ const USAGE = `Usage: litclaude-ai workflow-stage <family> <stage> [--n N] [--total M] [--unit ${STAGE_UNITS.join("|")}] [--verdict <name>=${VERDICT_STATES.join("|")}]... [--session <id>] [--json]
426
449
  Families and stages: ${Object.entries(WORKFLOW_FAMILIES).map(([family, stages]) => `${family}: ${stages.join(" ")}`).join("; ")}
427
450
  (lit-loop's SURFACE and CLEAN steps are accepted and shown on VERIFY and RECORD.)`;
428
451
 
@@ -450,6 +473,7 @@ export const runWorkflowStageCli = (args, cwd = process.cwd(), out = process.std
450
473
  else if (flag === "--total") options.total = value;
451
474
  else if (flag === "--unit") options.unit = value;
452
475
  else if (flag === "--verdict") verdicts.push(value.split("="));
476
+ else if (flag === "--session") options.sessionId = value;
453
477
  else throw new WorkflowStageError(`unknown option ${flag}`);
454
478
  }
455
479
  const record = recordWorkflowStage(cwd, { ...options, verdicts: Object.fromEntries(verdicts) });
@@ -771,7 +771,7 @@ Your next move: <fill — e.g. approve, or ask for a high-accuracy review>. Full
771
771
  Commit: <Y/N> | <type>(<scope>): <summary>
772
772
 
773
773
  ## Final verification wave
774
- > Runs in parallel after ALL todos. ALL must APPROVE. Surface the results and wait for the user's explicit okay before declaring the work complete.
774
+ > Runs in parallel after ALL todos. ALL must APPROVE. Surface the results, then complete the work; a commit and push still ask first.
775
775
  ${FINAL_VERIFICATION_ITEMS.map((item) => `- [ ] ${item}`).join("\n")}
776
776
 
777
777
  ## Commit strategy