@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.
- package/CHANGELOG.md +71 -0
- package/README.md +11 -8
- package/README_ko-KR.md +11 -8
- package/bin/litclaude-ai.js +3 -3
- package/docs/assets/readme/badge-version.svg +1 -1
- package/docs/assets/skills/lit-adhd.webp +0 -0
- package/docs/assets/skills/lit-hijack.webp +0 -0
- package/docs/assets/skills/lit-schematic.webp +0 -0
- package/docs/hooks.md +117 -26
- package/docs/workflow-compatibility-audit.md +1 -1
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/agents/lit-executor.md +4 -2
- package/plugins/litclaude/bin/litclaude-ai +1 -0
- package/plugins/litclaude/bin/litclaude-hook.js +373 -53
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/commands/lit-adhd.md +107 -0
- package/plugins/litclaude/commands/lit-hijack.md +102 -0
- package/plugins/litclaude/commands/lit-loop.md +4 -2
- package/plugins/litclaude/commands/lit-plan.md +5 -4
- package/plugins/litclaude/commands/lit-rewind.md +107 -0
- package/plugins/litclaude/commands/litgoal.md +5 -4
- package/plugins/litclaude/commands/start-work.md +25 -10
- package/plugins/litclaude/hooks/lit-mod.mjs +51 -5
- package/plugins/litclaude/lib/canonical-skill-catalog.mjs +3 -0
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +205 -101
- package/plugins/litclaude/lib/lit-activation.mjs +24 -10
- package/plugins/litclaude/lib/mod/frame.mjs +235 -49
- package/plugins/litclaude/lib/mod/motion.mjs +21 -0
- package/plugins/litclaude/lib/mod/settings.mjs +4 -0
- package/plugins/litclaude/lib/mod/skills.mjs +3 -0
- package/plugins/litclaude/lib/mod/state.mjs +100 -7
- package/plugins/litclaude/lib/mod/svg-card.mjs +167 -25
- package/plugins/litclaude/lib/mod/timeline.mjs +28 -5
- package/plugins/litclaude/lib/mod/toasts.mjs +5 -2
- package/plugins/litclaude/lib/mod/view.mjs +240 -6
- package/plugins/litclaude/lib/mod/workflow.mjs +36 -7
- package/plugins/litclaude/lib/motion-render-gate.mjs +25 -7
- package/plugins/litclaude/lib/render_pages.py +29 -1
- package/plugins/litclaude/lib/rewind/brief.mjs +370 -0
- package/plugins/litclaude/lib/rewind/collect.mjs +413 -0
- package/plugins/litclaude/lib/rewind/gauge.mjs +87 -0
- package/plugins/litclaude/lib/rewind/next-step.mjs +89 -0
- package/plugins/litclaude/lib/rewind/redact.mjs +36 -0
- package/plugins/litclaude/lib/rewind/suggest.mjs +51 -0
- package/plugins/litclaude/lib/rewind/transcripts.mjs +259 -0
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +403 -18
- package/plugins/litclaude/lib/workflow-stack.mjs +243 -0
- package/plugins/litclaude/lib/workflow-stage.mjs +127 -103
- package/plugins/litclaude/scripts/scaffold-plan.mjs +1 -1
- package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +18 -3
- package/plugins/litclaude/skills/frontend-ui-ux/kit/components.css +414 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/fonts.json +22 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
- package/plugins/litclaude/skills/frontend-ui-ux/kit/ui.js +226 -0
- package/plugins/litclaude/skills/frontend-ui-ux/references/brand-and-imagery.md +1 -1
- package/plugins/litclaude/skills/frontend-ui-ux/references/complete-contract.md +1 -0
- package/plugins/litclaude/skills/frontend-ui-ux/references/craft-floor.md +9 -4
- package/plugins/litclaude/skills/frontend-ui-ux/references/default-editorial-pixel.json +6 -5
- package/plugins/litclaude/skills/frontend-ui-ux/references/house-styles.md +234 -0
- package/plugins/litclaude/skills/frontend-ui-ux/references/motion-guide.md +3 -3
- package/plugins/litclaude/skills/frontend-ui-ux/references/production-interview.md +1 -1
- package/plugins/litclaude/skills/frontend-ui-ux/references/slop-register.md +7 -7
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +196 -0
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +30 -9
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +19 -7
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-static.mjs +12 -2
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe.mjs +53 -6
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +168 -0
- package/plugins/litclaude/skills/lit-adhd/references/card-examples.md +125 -0
- package/plugins/litclaude/skills/lit-adhd/references/status-taxonomy.md +43 -0
- package/plugins/litclaude/skills/lit-adhd/scripts/rewind.mjs +11 -0
- package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +17 -5
- package/plugins/litclaude/skills/lit-diagram-drawer/references/style-guide.md +20 -11
- package/plugins/litclaude/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
- package/plugins/litclaude/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
- package/plugins/litclaude/skills/lit-diagram-drawer/references/type-tree.md +3 -3
- package/plugins/litclaude/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
- package/plugins/litclaude/skills/lit-diagram-drawer/references/verifier-guide.md +1 -1
- package/plugins/litclaude/skills/lit-diagram-drawer/scripts/visual-quality.mjs +3 -3
- package/plugins/litclaude/skills/lit-docx/SKILL.md +6 -1
- package/plugins/litclaude/skills/lit-docx/references/direction-step.md +8 -4
- package/plugins/litclaude/skills/lit-handoff/SKILL.md +2 -1
- package/plugins/litclaude/skills/lit-hijack/SKILL.md +551 -0
- package/plugins/litclaude/skills/lit-hijack/references/capture-and-provenance.md +124 -0
- package/plugins/litclaude/skills/lit-hijack/references/clean-room-build.md +133 -0
- package/plugins/litclaude/skills/lit-hijack/references/distil-and-licence.md +128 -0
- package/plugins/litclaude/skills/lit-hijack/references/gap-and-port-design.md +152 -0
- package/plugins/litclaude/skills/lit-hijack/references/parity-and-report.md +131 -0
- package/plugins/litclaude/skills/lit-hijack/scripts/hijack.mjs +854 -0
- package/plugins/litclaude/skills/lit-loop/SKILL.md +4 -3
- package/plugins/litclaude/skills/lit-plan/SKILL.md +16 -10
- package/plugins/litclaude/skills/lit-pptx/SKILL.md +35 -15
- package/plugins/litclaude/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
- package/plugins/litclaude/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
- package/plugins/litclaude/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
- package/plugins/litclaude/skills/lit-pptx/fonts/provenance.json +32 -1
- package/plugins/litclaude/skills/lit-pptx/references/agents/architect.md +1 -1
- package/plugins/litclaude/skills/lit-pptx/references/anti-slop-checklist.md +32 -11
- package/plugins/litclaude/skills/lit-pptx/references/authoring-guide.md +2 -2
- package/plugins/litclaude/skills/lit-pptx/references/data-display-cookbook.md +1 -1
- package/plugins/litclaude/skills/lit-pptx/references/density-and-fill.md +3 -4
- package/plugins/litclaude/skills/lit-pptx/references/direction-step.md +23 -4
- package/plugins/litclaude/skills/lit-pptx/references/examples/13-engineering-review-computational-brutalism-ko.md +173 -0
- package/plugins/litclaude/skills/lit-pptx/references/examples/14-launch-pitch-neo-brutalism-ko.md +154 -0
- package/plugins/litclaude/skills/lit-pptx/references/examples/15-design-lecture-bauhaus-ko.md +139 -0
- package/plugins/litclaude/skills/lit-pptx/references/examples/16-community-programme-riso-ko.md +158 -0
- package/plugins/litclaude/skills/lit-pptx/references/examples/17-public-data-briefing-newsroom-ko.md +179 -0
- package/plugins/litclaude/skills/lit-pptx/references/layout-families.md +22 -26
- package/plugins/litclaude/skills/lit-pptx/references/title-treatments.md +30 -26
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/atlas.md +4 -4
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/bauhaus.md +140 -0
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/chalk.md +3 -3
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/computational-brutalism.md +150 -0
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/gazette.md +1 -1
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/ledger.md +1 -1
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/neo-brutalism.md +161 -0
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/newsroom.md +144 -0
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/night.md +1 -1
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/paper.md +3 -3
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/riso.md +137 -0
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/signal.md +2 -2
- package/plugins/litclaude/skills/lit-pptx/references/tonalities/studio.md +6 -7
- package/plugins/litclaude/skills/lit-pptx/scripts/compile-deck.js +1 -1
- package/plugins/litclaude/skills/lit-pptx/scripts/craft_extras.py +135 -91
- package/plugins/litclaude/skills/lit-pptx/scripts/embed_fonts.py +13 -1
- package/plugins/litclaude/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
- package/plugins/litclaude/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
- package/plugins/litclaude/skills/lit-pptx/scripts/lib/render-pack.js +370 -563
- package/plugins/litclaude/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
- package/plugins/litclaude/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
- package/plugins/litclaude/skills/lit-pptx/scripts/qa_deck.py +5 -5
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +99 -0
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
- package/plugins/litclaude/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
- package/plugins/litclaude/skills/lit-recap/SKILL.md +4 -0
- package/plugins/litclaude/skills/lit-schematic/SKILL.md +123 -0
- package/plugins/litclaude/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
- package/plugins/litclaude/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
- package/plugins/litclaude/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
- package/plugins/litclaude/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
- package/plugins/litclaude/skills/lit-schematic/references/cutaway-outputs.md +70 -0
- package/plugins/litclaude/skills/lit-schematic/references/isometric-craft.md +101 -0
- package/plugins/litclaude/skills/lit-schematic/references/journal-figures.md +72 -0
- package/plugins/litclaude/skills/lit-schematic/references/kit-api.md +134 -0
- package/plugins/litclaude/skills/lit-schematic/references/pfd-and-layout.md +53 -0
- package/plugins/litclaude/skills/lit-schematic/references/pid-drafting.md +103 -0
- package/plugins/litclaude/skills/lit-schematic/references/pid-symbols.md +163 -0
- package/plugins/litclaude/skills/lit-schematic/references/verification.md +100 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/doctor.mjs +57 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/fonts.mjs +27 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/png.mjs +132 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/route.mjs +218 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/motion.mjs +129 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/qa.mjs +92 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/render.mjs +233 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/scaffold.mjs +60 -0
- package/plugins/litclaude/skills/lit-scientific-visualization/SKILL.md +14 -4
- package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +54 -45
- package/plugins/litclaude/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +11 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/blender/runner.py +218 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/core/presets.mjs +1 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/analysis.mjs +65 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/assets.mjs +208 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/blender.mjs +143 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/board.mjs +136 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/brief.mjs +7 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/chrome.mjs +6 -4
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-assets.mjs +5 -3
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-capture.mjs +4 -4
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +37 -4
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +17 -5
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/done.mjs +42 -3
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/frame-worker.mjs +7 -5
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/gallery.mjs +121 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/house.mjs +44 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/look.mjs +33 -19
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/pipeline.mjs +18 -7
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/scaffold.mjs +210 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/score.mjs +639 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/sound-cli.mjs +21 -4
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/sound.mjs +126 -27
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-capture.mjs +7 -6
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-gate.mjs +59 -5
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-qa.mjs +141 -9
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-serve.mjs +28 -5
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +82 -14
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/styles.mjs +213 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/treatment.mjs +311 -10
- package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/cover-init.js +14 -2
- package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/init.js +11 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/qa.js +6 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/stage-kit.js +83 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
- package/plugins/litclaude/skills/lit-typographic-motion/recipes/hero-3d/expected.json +69 -0
- package/plugins/litclaude/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
- package/plugins/litclaude/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +2 -0
- package/plugins/litclaude/skills/lit-typographic-motion/recipes/painted-light/expected.json +2 -0
- package/plugins/litclaude/skills/lit-typographic-motion/recipes/weight-tide/expected.json +2 -0
- package/plugins/litclaude/skills/lit-typographic-motion/references/cover.md +67 -15
- package/plugins/litclaude/skills/lit-typographic-motion/references/craft-loop.md +3 -2
- package/plugins/litclaude/skills/lit-typographic-motion/references/depth.md +122 -0
- package/plugins/litclaude/skills/lit-typographic-motion/references/look.md +28 -13
- package/plugins/litclaude/skills/lit-typographic-motion/references/runtime.md +4 -3
- package/plugins/litclaude/skills/lit-typographic-motion/references/sound.md +92 -23
- package/plugins/litclaude/skills/lit-typographic-motion/references/stage.md +43 -22
- package/plugins/litclaude/skills/lit-typographic-motion/references/studio.md +245 -0
- package/plugins/litclaude/skills/lit-typographic-motion/references/style-bibles.md +30 -6
- package/plugins/litclaude/skills/lit-typographic-motion/references/treatment.md +108 -14
- package/plugins/litclaude/skills/lit-typographic-motion/scripts/motion-doctor.mjs +16 -3
- package/plugins/litclaude/skills/lit-typographic-motion/scripts/motion.mjs +47 -7
- package/plugins/litclaude/skills/lit-typographic-motion/styles/paper.json +41 -0
- package/plugins/litclaude/skills/lit-typographic-motion/styles/swiss-signal.json +41 -0
- package/plugins/litclaude/skills/lit-typographic-motion/styles/terminalcore.json +42 -0
- package/plugins/litclaude/skills/lit-typographic-motion/styles/tidal.json +41 -0
- package/plugins/litclaude/skills/litgoal/SKILL.md +3 -2
- package/plugins/litclaude/skills/litresearch/SKILL.md +5 -0
- package/plugins/litclaude/skills/readme-studio/SKILL.md +10 -0
- package/plugins/litclaude/skills/readme-studio/references/production-interview.md +2 -0
- package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/package-lock.json +3 -3
- package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
- package/plugins/litclaude/skills/start-work/SKILL.md +24 -11
- 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
|
|
2
|
-
//
|
|
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)
|
|
5
|
-
// see, with no help from the model. The
|
|
6
|
-
//
|
|
7
|
-
// lane running when its reviewer is spawned; PostToolUse moves
|
|
8
|
-
// task is checked in the active plan, a lit-loop test
|
|
9
|
-
// the shell), made to pass, run or recorded, or a
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// stage, which lane and how many; never a path, a command or a prompt.
|
|
14
|
-
|
|
15
|
-
import { closeSync, lstatSync,
|
|
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 {
|
|
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
|
|
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
|
|
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 (
|
|
35
|
-
const
|
|
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
|
-
|
|
58
|
+
// An unreadable goal or ledger never stops the stack from moving.
|
|
39
59
|
}
|
|
40
60
|
};
|
|
41
61
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
*
|
|
53
|
-
*
|
|
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 (!
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
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
|
|
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
|
-
|
|
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
|
|
93
|
-
const
|
|
94
|
-
const same =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
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
|
|
114
|
-
const currentRecord = (cwd, sessionId) =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|