@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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// (skills.mjs) and what Claude Code reports live (subagents, context and rate-limit usage). Pure: the mod calls these on each refresh and hands the result to the
|
|
3
3
|
// band's surface module, which only draws and animates it.
|
|
4
4
|
|
|
5
|
+
import { lookOf } from "./motion.mjs";
|
|
5
6
|
import { AUTOLOOP_LIMITS, GATE_LIMITS } from "./state.mjs";
|
|
6
7
|
import { buildWorkflow } from "./workflow.mjs";
|
|
7
8
|
|
|
@@ -13,6 +14,13 @@ export const AGENT_STALE_MS = 30 * 60 * 1000;
|
|
|
13
14
|
// The context warning starts this many points before the auto-handoff percent.
|
|
14
15
|
export const CONTEXT_LEAD = 5;
|
|
15
16
|
|
|
17
|
+
// How long the rewind look stays after `lit adhd` was sent. The ignition keeps naming lit-adhd
|
|
18
|
+
// until the next prompt, so the look lasts while the user reads the brief, but no longer than this.
|
|
19
|
+
export const REWIND_LINGER_MS = 15 * 60 * 1000;
|
|
20
|
+
|
|
21
|
+
// How long the card must have sat idle since its newest skill before it offers `lit adhd`.
|
|
22
|
+
export const BREAK_MS = 30 * 60 * 1000;
|
|
23
|
+
|
|
16
24
|
const LIVE_AGENT = new Set(["running", "pending", "waiting", "idle"]);
|
|
17
25
|
const ENDED_AGENT = new Set(["completed", "failed", "killed"]);
|
|
18
26
|
const NONTERMINAL_GOAL = new Set(["active", "blocked", "review_blocked", "needs_user_decision"]);
|
|
@@ -86,6 +94,216 @@ export const stalledLanes = (agents, activity, now, thresholdMs = STALL_MS) =>
|
|
|
86
94
|
|
|
87
95
|
export const laneName = (agent) => String(agent.name || agent.description || agent.type || "agent").slice(0, 40);
|
|
88
96
|
|
|
97
|
+
// The card shows at most this many threads; the rest are counted as `+N more`. A deep chain still
|
|
98
|
+
// leaves PARALLEL_ROWS for the lanes and tasks under it.
|
|
99
|
+
export const THREAD_ROWS = 4;
|
|
100
|
+
const PARALLEL_ROWS = 3;
|
|
101
|
+
// Another session of this project counts as live while its stack was written this recently.
|
|
102
|
+
export const OTHER_SESSION_MS = 15 * 60 * 1000;
|
|
103
|
+
|
|
104
|
+
const countOrNull = (value) => (Number.isInteger(value) && value >= 0 ? value : null);
|
|
105
|
+
|
|
106
|
+
// `lists` maps a loop (`main`, or a subagent's id) to what its tool calls say of its progress:
|
|
107
|
+
// `steps`, the tool calls it finished; `todos`, the counts of its last TodoWrite; `tasks`, the
|
|
108
|
+
// status of each task it created with TaskCreate (TaskUpdate moves them, and may give one to a lane
|
|
109
|
+
// by `owner`); `latest`, which of the two lists it touched last; `last`, its last finished step as a
|
|
110
|
+
// tool name and at most a file's base name. Only statuses are kept, never a todo's or a task's text.
|
|
111
|
+
export const EMPTY_LISTS = Object.freeze({});
|
|
112
|
+
const LIST_CAP = 200;
|
|
113
|
+
const LOOP_CAP = 40;
|
|
114
|
+
const TASK_STATUS = new Set(["pending", "in_progress", "completed"]);
|
|
115
|
+
|
|
116
|
+
const loopEntry = (lists, loop) => lists[loop] ?? { steps: 0, todos: null, tasks: {}, latest: null, last: null };
|
|
117
|
+
const OWNER = /^[\w .:-]{1,40}$/u;
|
|
118
|
+
// `Edit README.md`: the tool and the base name of the file it touched, nothing of its arguments.
|
|
119
|
+
const lastStepOf = (call) => {
|
|
120
|
+
const tool = stepName(call?.tool);
|
|
121
|
+
if (!tool) return null;
|
|
122
|
+
const path = typeof call.file_path === "string" ? call.file_path : typeof call.notebook_path === "string" ? call.notebook_path : null;
|
|
123
|
+
const base = path ? path.split(/[\\/]/u).pop().replace(/[^\w .@+-]/gu, "").slice(0, 28) : "";
|
|
124
|
+
return base ? `${tool} ${base}` : tool;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Folds one finished tool call of `loop` into `lists`: every call counts a step, a TodoWrite
|
|
129
|
+
* replaces the loop's todo counts, a TaskCreate adds its task and a TaskUpdate moves the task in
|
|
130
|
+
* whichever loop created it (or in this loop, marked unseen, when its creation was not seen).
|
|
131
|
+
*/
|
|
132
|
+
export const noteLoopCall = (lists, loop, call, result) => {
|
|
133
|
+
if (typeof loop !== "string" || !loop) return lists;
|
|
134
|
+
const next = { ...lists };
|
|
135
|
+
const entry = { ...loopEntry(lists, loop) };
|
|
136
|
+
entry.steps += 1;
|
|
137
|
+
entry.last = lastStepOf(call) ?? entry.last ?? null;
|
|
138
|
+
if (call?.tool === "TodoWrite" && Array.isArray(call.todos)) {
|
|
139
|
+
const todos = call.todos.slice(0, LIST_CAP);
|
|
140
|
+
entry.todos = { done: todos.filter((todo) => todo?.status === "completed").length, total: todos.length };
|
|
141
|
+
entry.latest = "todos";
|
|
142
|
+
} else if (call?.tool === "TaskCreate" && typeof result?.task?.id === "string") {
|
|
143
|
+
entry.tasks = { ...entry.tasks, [result.task.id.slice(0, 64)]: { status: "pending", seen: true } };
|
|
144
|
+
entry.latest = "tasks";
|
|
145
|
+
} else if (call?.tool === "TaskUpdate" && typeof call.taskId === "string" && (TASK_STATUS.has(call.status) || call.status === "deleted" || typeof call.owner === "string")) {
|
|
146
|
+
const id = call.taskId.slice(0, 64);
|
|
147
|
+
const owner = Object.keys(next).find((key) => key !== loop && next[key].tasks?.[id]);
|
|
148
|
+
const target = owner ? { ...next[owner] } : entry;
|
|
149
|
+
const tasks = { ...target.tasks };
|
|
150
|
+
if (call.status === "deleted") delete tasks[id];
|
|
151
|
+
else if (TASK_STATUS.has(call.status) || tasks[id]) {
|
|
152
|
+
const assignee = typeof call.owner === "string" && OWNER.test(call.owner.trim()) ? call.owner.trim() : tasks[id]?.owner;
|
|
153
|
+
tasks[id] = { status: TASK_STATUS.has(call.status) ? call.status : tasks[id].status, seen: tasks[id]?.seen ?? false, ...(assignee ? { owner: assignee } : {}) };
|
|
154
|
+
}
|
|
155
|
+
target.tasks = Object.fromEntries(Object.entries(tasks).slice(-LIST_CAP));
|
|
156
|
+
target.latest = "tasks";
|
|
157
|
+
if (owner) next[owner] = target;
|
|
158
|
+
}
|
|
159
|
+
next[loop] = entry;
|
|
160
|
+
const loops = Object.keys(next);
|
|
161
|
+
return loops.length > LOOP_CAP ? Object.fromEntries(loops.slice(-LOOP_CAP).map((key) => [key, next[key]])) : next;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A loop's `{ done, total }` from its list, or null when it keeps none. A task list whose
|
|
166
|
+
* creation was not all seen knows its done count but not its total.
|
|
167
|
+
*/
|
|
168
|
+
export const listProgress = (entry) => {
|
|
169
|
+
if (!entry) return null;
|
|
170
|
+
const tasks = Object.values(entry.tasks ?? {});
|
|
171
|
+
const fromTasks = tasks.length ? { done: tasks.filter(({ status }) => status === "completed").length, total: tasks.every(({ seen }) => seen) ? tasks.length : null } : null;
|
|
172
|
+
if (entry.latest === "tasks" && fromTasks) return fromTasks;
|
|
173
|
+
return entry.todos ?? fromTasks;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// The tasks any loop's list gave to `owner` by name, as `{ done, total }`, or null when none did.
|
|
177
|
+
const ownedProgress = (lists, owner) => {
|
|
178
|
+
if (!owner) return null;
|
|
179
|
+
const owned = Object.values(lists).flatMap((entry) => Object.values(entry?.tasks ?? {})).filter((task) => task.owner === owner);
|
|
180
|
+
return owned.length ? { done: owned.filter(({ status }) => status === "completed").length, total: owned.length } : null;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// `tasks` maps a background task's id to `{ id, kind, name, at, until }`: a shell a Bash call left
|
|
184
|
+
// running (its own `backgroundTaskId`) or a monitor, named by the call's description, never its
|
|
185
|
+
// command. `until` is a monitor's deadline. A task ends with its notification, a TaskStop, its
|
|
186
|
+
// deadline, or after TASK_STALE_MS when no ending was ever seen.
|
|
187
|
+
export const EMPTY_TASKS = Object.freeze({});
|
|
188
|
+
export const TASK_STALE_MS = 12 * 60 * 60 * 1000;
|
|
189
|
+
const TASK_CAP = 12;
|
|
190
|
+
const TASK_ID = /^[A-Za-z0-9_-]{1,64}$/u;
|
|
191
|
+
|
|
192
|
+
export const noteBackgroundTask = (tasks, { id, kind, name, at, until = null }) => {
|
|
193
|
+
if (typeof id !== "string" || !TASK_ID.test(id)) return tasks;
|
|
194
|
+
const label = String(name || kind).replace(/[\u0000-\u001f\u007f]/gu, " ").trim().slice(0, 40) || kind;
|
|
195
|
+
const next = { ...tasks, [id]: { id, kind, name: label, at, until: Number.isFinite(until) ? until : null } };
|
|
196
|
+
const ids = Object.keys(next);
|
|
197
|
+
return ids.length > TASK_CAP ? Object.fromEntries(ids.slice(-TASK_CAP).map((key) => [key, next[key]])) : next;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const endBackgroundTask = (tasks, id) => (typeof id === "string" && tasks[id] ? Object.fromEntries(Object.entries(tasks).filter(([key]) => key !== id)) : tasks);
|
|
201
|
+
|
|
202
|
+
// The ids a task notification names as ended. Its text is read for `<task-id>` and `<status>`
|
|
203
|
+
// alone and kept nowhere; a notification that still reports a running task ends nothing.
|
|
204
|
+
export const endedTaskIds = (text) => {
|
|
205
|
+
const body = String(text ?? "").slice(0, 65_536);
|
|
206
|
+
const ids = [];
|
|
207
|
+
for (const block of body.split(/<\/task-notification>/u)) {
|
|
208
|
+
const id = /<task-id>\s*([A-Za-z0-9_-]{1,64})\s*<\/task-id>/u.exec(block)?.[1];
|
|
209
|
+
const status = /<status>\s*([a-z_]{1,24})\s*<\/status>/u.exec(block)?.[1] ?? "completed";
|
|
210
|
+
if (id && !["running", "pending", "in_progress"].includes(status)) ids.push(id);
|
|
211
|
+
}
|
|
212
|
+
return ids;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const pruneBackgroundTasks = (tasks, now) => {
|
|
216
|
+
const kept = Object.entries(tasks).filter(([, task]) => !(task.until !== null && now > task.until) && !(now - task.at > TASK_STALE_MS));
|
|
217
|
+
return kept.length === Object.keys(tasks).length ? tasks : Object.fromEntries(kept);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const goalCount = (goal) => (goalIsOpen(goal) && goal.criteria.length > 0 ? { done: goal.criteria.filter(({ status }) => status === "pass").length, total: goal.criteria.length } : null);
|
|
221
|
+
const LOOP_SKILLS = new Set(["lit-loop", "litgoal", "litwork"]);
|
|
222
|
+
|
|
223
|
+
// A frame's k/n, the first source that knows it: the count the frame recorded, the start-work run
|
|
224
|
+
// it drives, the checkboxes of the plan it works from, the open goal's criteria (a loop), and for
|
|
225
|
+
// the frame on top the main loop's own todo or task list.
|
|
226
|
+
const frameCount = (frame, snapshot, mainList) => {
|
|
227
|
+
const record = frame.record;
|
|
228
|
+
if (countOrNull(record?.total) !== null) return { done: countOrNull(record.n) ?? 0, total: record.total };
|
|
229
|
+
const work = snapshot.work;
|
|
230
|
+
if (work?.total > 0 && (frame.skill === "start-work" || (record?.family === "main" && record.stage === "work"))) return { done: work.checked, total: work.total };
|
|
231
|
+
if (frame.plan?.total > 0) return frame.plan;
|
|
232
|
+
if (LOOP_SKILLS.has(frame.skill) || record?.family === "loop") {
|
|
233
|
+
const goal = goalCount(snapshot.goal);
|
|
234
|
+
if (goal) return goal;
|
|
235
|
+
}
|
|
236
|
+
return mainList ?? { done: countOrNull(record?.n), total: null };
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// A thread with no total carries what is known instead: its finished steps, how long it has run
|
|
240
|
+
// and its last step (knownFacts in rewind/gauge.mjs words them).
|
|
241
|
+
const frameThread = (frame, index, snapshot, active, mainList = null, now = null, mainEntry = null) => {
|
|
242
|
+
const { done, total } = frameCount(frame, snapshot, active ? mainList : null);
|
|
243
|
+
const started = Number.isFinite(frame.at) ? frame.at : frame.record?.at;
|
|
244
|
+
return {
|
|
245
|
+
key: `frame-${index}`,
|
|
246
|
+
name: frame.skill ?? frame.record?.family ?? "work",
|
|
247
|
+
stage: frame.record?.step ?? frame.record?.stage ?? null,
|
|
248
|
+
done,
|
|
249
|
+
total,
|
|
250
|
+
state: frame.record?.done ? "done" : frame.status === "paused" ? "paused" : frame.skill === "start-work" && snapshot.work?.status === "paused" ? "blocked" : "running",
|
|
251
|
+
active,
|
|
252
|
+
steps: active && mainEntry ? mainEntry.steps : null,
|
|
253
|
+
last: active && mainEntry ? mainEntry.last ?? null : null,
|
|
254
|
+
elapsedMs: Number.isFinite(now) && Number.isFinite(started) ? Math.max(0, now - started) : null,
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// A lane's k/n: its own todo or task list, then the tasks a loop gave it by name; else no total,
|
|
259
|
+
// with the steps it has finished and its last one.
|
|
260
|
+
const laneCount = (entry, lists, name) => listProgress(entry) ?? ownedProgress(lists, name) ?? { done: null, total: null, steps: entry?.steps ?? 0, last: entry?.last ?? null };
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The live threads, or null while there is at most one: `{ chain, lanes, others, laneCount,
|
|
264
|
+
* taskCount, more, reserve }`. `chain` is this session's stack, parent first; `lanes` the subagents
|
|
265
|
+
* or work lanes running under its top frame, then its background tasks (`task` names the kind);
|
|
266
|
+
* `others` the top frame of each other session of this project whose stack moved within
|
|
267
|
+
* OTHER_SESSION_MS. At most THREAD_ROWS are kept (more under a deep chain, see PARALLEL_ROWS): the
|
|
268
|
+
* active frame and its parents first, then lanes and tasks, then other sessions. `reserve` is the card's thread-row count, never below the
|
|
269
|
+
* `threadReserve` the caller carried over, so the card does not shrink while threads are live.
|
|
270
|
+
*/
|
|
271
|
+
const threadsOf = ({ snapshot, lanes, tasks, lists, now, threadReserve }) => {
|
|
272
|
+
const frames = snapshot.workflow?.stack?.frames ?? [];
|
|
273
|
+
const mainList = listProgress(lists.main);
|
|
274
|
+
const chain = frames.map((frame, index) => frameThread(frame, index, snapshot, index === frames.length - 1, mainList, now, lists.main));
|
|
275
|
+
const laneThreads = lanes.map((lane, index) => ({
|
|
276
|
+
key: `lane-${lane.id ?? index}`,
|
|
277
|
+
name: lane.name,
|
|
278
|
+
stage: null,
|
|
279
|
+
...laneCount(lane.id ? lists[lane.id] : null, lists, lane.name),
|
|
280
|
+
state: lane.status === "stalled" ? "blocked" : lane.status === "idle" ? "idle" : "running",
|
|
281
|
+
active: false,
|
|
282
|
+
elapsedMs: Number.isFinite(lane.elapsedMs) ? lane.elapsedMs : null,
|
|
283
|
+
}));
|
|
284
|
+
const taskThreads = tasks.map((task) => ({ key: `task-${task.id}`, name: task.name, stage: task.kind, done: null, total: null, state: "running", active: false, task: task.kind, elapsedMs: Number.isFinite(task.at) ? Math.max(0, now - task.at) : null }));
|
|
285
|
+
const parallel = [...laneThreads, ...taskThreads];
|
|
286
|
+
const others = (snapshot.workflow?.others ?? [])
|
|
287
|
+
.filter((other) => Number.isFinite(other.at) && now - other.at <= OTHER_SESSION_MS && other.frames?.length)
|
|
288
|
+
.map((other) => ({ ...frameThread(other.frames.at(-1), 0, {}, false, null, now), key: `session-${other.id8}`, session: other.id8 }));
|
|
289
|
+
const total = chain.length + parallel.length + others.length;
|
|
290
|
+
if (total < 2) return null;
|
|
291
|
+
const room = Math.max(PARALLEL_ROWS, THREAD_ROWS - chain.length);
|
|
292
|
+
const keptLanes = parallel.slice(0, room);
|
|
293
|
+
const keptOthers = others.slice(0, Math.max(0, room - keptLanes.length));
|
|
294
|
+
const fork = parallel.length >= 2 ? 1 : 0;
|
|
295
|
+
const needed = chain.length + keptLanes.length + keptOthers.length + fork;
|
|
296
|
+
return {
|
|
297
|
+
chain,
|
|
298
|
+
lanes: keptLanes,
|
|
299
|
+
others: keptOthers,
|
|
300
|
+
laneCount: laneThreads.length,
|
|
301
|
+
taskCount: taskThreads.length,
|
|
302
|
+
more: total - chain.length - keptLanes.length - keptOthers.length,
|
|
303
|
+
reserve: Math.max(needed, Number.isInteger(threadReserve) ? threadReserve : 0),
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
|
|
89
307
|
const goalIsOpen = (goal) => Boolean(goal && NONTERMINAL_GOAL.has(goal.status));
|
|
90
308
|
|
|
91
309
|
const progressOf = (snapshot) => {
|
|
@@ -168,9 +386,11 @@ export const stepName = (tool) => {
|
|
|
168
386
|
* `$.session.usage()`, `notice` and `completion` whatever the mod is currently playing, `skills`
|
|
169
387
|
* the chips (skills.mjs chipStates), `lastDiscipline` the discipline or skill the session last
|
|
170
388
|
* lit (the idle title), `git` the branch and `step` the live step (`{ name, at }`, the tool the
|
|
171
|
-
* main loop runs and since when).
|
|
389
|
+
* main loop runs and since when). `threadReserve` is the previous model's `threads.reserve`,
|
|
390
|
+
* `lists` the loops' todo and task counts (noteLoopCall) and `tasks` the background tasks
|
|
391
|
+
* (noteBackgroundTask).
|
|
172
392
|
*/
|
|
173
|
-
export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVITY, usage = null, now, band = "always", isWorking = false, notice = null, completion = null, skills = [], lastDiscipline = null, git = null, step = null }) => {
|
|
393
|
+
export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVITY, usage = null, now, band = "always", isWorking = false, notice = null, completion = null, skills = [], lastDiscipline = null, git = null, step = null, threadReserve = 0, lists = EMPTY_LISTS, tasks = EMPTY_TASKS }) => {
|
|
174
394
|
const discipline = snapshot.ignition?.discipline ?? null;
|
|
175
395
|
const progress = progressOf(snapshot);
|
|
176
396
|
const completing = completion !== null;
|
|
@@ -197,16 +417,22 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
|
|
|
197
417
|
if (probe?.issue && probe.issueAt >= (probe.editAt ?? 0)) warnings.push({ tone: "red", subject: "ui probe", text: probe.issue, hint: "interface check failed" });
|
|
198
418
|
const active = Boolean(snapshot.work) || goalIsOpen(goal) || (discipline !== null && isWorking) || liveAgents.length > 0;
|
|
199
419
|
const lit = skills.some(({ state }) => state === "current");
|
|
200
|
-
const
|
|
420
|
+
const workflow = buildWorkflow({ snapshot, skills, completion, now });
|
|
421
|
+
const title = discipline ?? skills.find(({ state }) => state === "current")?.id ?? lastDiscipline;
|
|
422
|
+
const rewind = lookOf(discipline) === "rewind" && Number.isFinite(snapshot.ignition?.at) && now - snapshot.ignition.at < REWIND_LINGER_MS;
|
|
423
|
+
const visible = band === "off" ? false : band === "always" || active || lit || rewind || notice !== null || completion !== null || warnings.length > 0;
|
|
201
424
|
return {
|
|
202
425
|
visible,
|
|
203
426
|
idle: !active && !lit,
|
|
427
|
+
rewind,
|
|
428
|
+
away: !active && !lit && !rewind && skills.length > 0 && now - Math.max(...skills.map(({ at }) => (Number.isFinite(at) ? at : now))) >= BREAK_MS,
|
|
204
429
|
discipline,
|
|
205
|
-
title:
|
|
430
|
+
title: workflow?.paused ? crumbOf(workflow.paused) : title,
|
|
206
431
|
phases,
|
|
207
432
|
progress,
|
|
208
433
|
next: snapshot.work?.nextTask ?? (goalIsOpen(goal) ? goal.criteria.find(({ status }) => status !== "pass")?.description || goal.objective || null : null),
|
|
209
434
|
lanes: { count: lanes.length, list: lanes },
|
|
435
|
+
threads: threadsOf({ snapshot, lanes, tasks: Object.values(pruneBackgroundTasks(tasks, now)), lists, now, threadReserve }),
|
|
210
436
|
autoloop,
|
|
211
437
|
ctxWarning,
|
|
212
438
|
warnings,
|
|
@@ -214,16 +440,24 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
|
|
|
214
440
|
goal: goalSummaryOf(goal),
|
|
215
441
|
skills: skills.map(({ id, at, state }) => ({ id, at, state })),
|
|
216
442
|
figures: figuresOf(usage, git),
|
|
217
|
-
workflow
|
|
443
|
+
workflow,
|
|
218
444
|
step: step && isWorking && stepName(step.name) ? { name: stepName(step.name), elapsedMs: Math.max(0, now - step.at) } : null,
|
|
219
445
|
notice,
|
|
220
446
|
completion,
|
|
221
447
|
};
|
|
222
448
|
};
|
|
223
449
|
|
|
224
|
-
|
|
450
|
+
// `lit-loop || > lit-brainstorm`, or `lit-loop || > … > lit-brainstorm` with a side between them.
|
|
451
|
+
const crumbOf = ({ parent, child, chain }) => `${parent} || > ${chain.length > 1 ? "… > " : ""}${child}`;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* The spinner's suffix: the ellipsis Claude Code drew, then the discipline and the progress count,
|
|
455
|
+
* or the paused parent and its count while a side runs over it.
|
|
456
|
+
*/
|
|
225
457
|
export const spinnerSuffix = (model, base = "…") => {
|
|
226
458
|
if (!model?.visible || !model.discipline) return null;
|
|
459
|
+
const paused = model.workflow?.paused;
|
|
460
|
+
if (paused) return `${base} · ${paused.child} (|| ${paused.parent}${paused.count ? ` ${paused.count.done}/${paused.count.total}` : ""})`;
|
|
227
461
|
const count = model.progress ? ` · ${model.progress.done}/${model.progress.total}` : "";
|
|
228
462
|
return `${base} · ${model.discipline}${count}`;
|
|
229
463
|
};
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Three families. The main chain runs a request from the interview to review (litgoal and
|
|
6
6
|
// autoresearch ride its work stage with criteria or iterations); litresearch has its own waves; a
|
|
7
|
-
// lit-loop criterion cycles through its test-first steps. The stage comes from the
|
|
8
|
-
//
|
|
9
|
-
// workflow-stage
|
|
10
|
-
// any of those, from the durable state that says work is under way. The durable state also fills
|
|
7
|
+
// lit-loop criterion cycles through its test-first steps. The stage comes from the session's workflow
|
|
8
|
+
// stack (`.litclaude/workflow-stack/<session>.json`, kept by the hooks and `litclaude-ai
|
|
9
|
+
// workflow-stage`) when it is fresh, else from the newer of the ignited discipline and a skill this
|
|
10
|
+
// request fired; without any of those, from the durable state that says work is under way. The durable state also fills
|
|
11
11
|
// in the detail: interview rounds, the plan draft's status, the work's tasks, research waves.
|
|
12
12
|
|
|
13
13
|
export const WORKFLOW_FAMILIES = Object.freeze({
|
|
@@ -107,6 +107,8 @@ const entryOf = ({ snapshot, skills, now }) => {
|
|
|
107
107
|
const chip = skills.find(({ id, state }) => state === "current" && DISCIPLINE_ENTRY[id]);
|
|
108
108
|
if (chip) candidates.push({ ...DISCIPLINE_ENTRY[chip.id], at: chip.at ?? 0, from: "skill" });
|
|
109
109
|
const record = snapshot.workflow?.record;
|
|
110
|
+
// The session's stack already follows every discipline the session started, paused or not.
|
|
111
|
+
if (record?.stacked && fresh(record, now)) return { family: record.family, stage: record.stage, at: record.at, from: "record", record };
|
|
110
112
|
if (fresh(record, now)) candidates.push({ family: record.family, stage: record.stage, at: record.at, from: "record", record });
|
|
111
113
|
// The record is written a moment after the ignition it answers, so a tie goes to the record.
|
|
112
114
|
return candidates.sort((a, b) => b.at - a.at || (a.from === "record" ? -1 : 1))[0] ?? null;
|
|
@@ -153,11 +155,13 @@ const plainText = (text) => (typeof text === "string" ? text.replace(/\*\*|__|`/
|
|
|
153
155
|
const percent = (value) => (Number.isFinite(value) ? Math.round(value <= 1 ? value * 100 : value) : null);
|
|
154
156
|
|
|
155
157
|
/**
|
|
156
|
-
* The map: `{ family, stages: [{ id, label, state }], current, count, items, verdicts, next }`,
|
|
158
|
+
* The map: `{ family, stages: [{ id, label, state }], current, count, items, verdicts, next, paused }`,
|
|
157
159
|
* or null when nothing places the session on a family's map (the card then keeps its PLAN / WORK /
|
|
158
160
|
* REVIEW track). `state` is done, now or todo; `current` is the index of the stage that is now,
|
|
159
161
|
* or -1 once the family is done. `count` is the current stage's n/m, `items` short facts about
|
|
160
|
-
* it, `verdicts` the review lanes or a crucible verdict, `next` the next task or criterion.
|
|
162
|
+
* it, `verdicts` the review lanes or a crucible verdict, `next` the next task or criterion. Under
|
|
163
|
+
* a side frame the map is the paused spine's: its stage marked `||` with its count, `paused` names
|
|
164
|
+
* the parent and the child, and the items give the child and the way back.
|
|
161
165
|
*/
|
|
162
166
|
export const buildWorkflow = ({ snapshot, skills = [], completion = null, now }) => {
|
|
163
167
|
const entry = entryOf({ snapshot, skills, now }) ?? inferredEntry(snapshot, now);
|
|
@@ -201,6 +205,9 @@ export const buildWorkflow = ({ snapshot, skills = [], completion = null, now })
|
|
|
201
205
|
next = plainText(goal.criteria.find(({ status }) => status !== "pass")?.description);
|
|
202
206
|
} else if (record?.stage === "work" && record.total) {
|
|
203
207
|
countOf = { done: Math.min(record.n ?? 0, record.total), total: record.total, unit: record.unit ?? "iteration" };
|
|
208
|
+
} else if (record?.plan?.total) {
|
|
209
|
+
// A work stage with nothing else to count counts the plan it took over from lit-plan.
|
|
210
|
+
countOf = { done: record.plan.done, total: record.plan.total, unit: "task" };
|
|
204
211
|
}
|
|
205
212
|
}
|
|
206
213
|
if (stage === "review") {
|
|
@@ -225,6 +232,8 @@ export const buildWorkflow = ({ snapshot, skills = [], completion = null, now })
|
|
|
225
232
|
} else if (goalIsOpen(goal) && goal.criteria.length > 0) {
|
|
226
233
|
countOf = { done: goal.criteria.filter(({ status }) => status === "pass").length, total: goal.criteria.length, unit: "criterion" };
|
|
227
234
|
next = goal.criteria.find(({ status }) => status !== "pass")?.description || null;
|
|
235
|
+
} else if (record?.plan?.total) {
|
|
236
|
+
countOf = { done: record.plan.done, total: record.plan.total, unit: "task" };
|
|
228
237
|
}
|
|
229
238
|
if (record && record.step.toUpperCase() !== record.stage) items.push(record.step.toLowerCase());
|
|
230
239
|
if (completion) stage = "RECORD";
|
|
@@ -237,8 +246,28 @@ export const buildWorkflow = ({ snapshot, skills = [], completion = null, now })
|
|
|
237
246
|
const stages = order.map((id, index) => {
|
|
238
247
|
let label = id;
|
|
239
248
|
if (index === current && countOf && family === "main") label = `${id} ${countOf.done}/${countOf.total}`;
|
|
249
|
+
// An open work ahead of the current stage keeps its task count in view.
|
|
250
|
+
else if (family === "main" && id === "work" && index > current && current >= 0 && snapshot.work?.total > 0) label = `work ${snapshot.work.checked}/${snapshot.work.total}`;
|
|
240
251
|
if (family === "research" && id === "wave" && wave > 0) label = `wave ${wave}`;
|
|
241
252
|
return { id, label, state: finished || index < current ? "done" : index === current ? "now" : "todo" };
|
|
242
253
|
});
|
|
243
|
-
|
|
254
|
+
const paused = pausedUnder(sources.stack, entry, finished);
|
|
255
|
+
if (paused) {
|
|
256
|
+
// The parent's map stays where it stopped; the row under it says what runs and the way back.
|
|
257
|
+
const at = stages[current];
|
|
258
|
+
const count = family !== "main" && countOf ? ` ${countOf.done}/${countOf.total}` : "";
|
|
259
|
+
at.label = `|| ${at.label}${count}`;
|
|
260
|
+
paused.count = countOf;
|
|
261
|
+
if (!next && goalIsOpen(snapshot.goal)) next = plainText(snapshot.goal.criteria.find(({ status }) => status !== "pass")?.description);
|
|
262
|
+
return { family, stages, current, count: null, items: [`↳ ${paused.child}`, "back: lit continue"], verdicts: null, next, paused };
|
|
263
|
+
}
|
|
264
|
+
return { family, stages, current, count: countOf, items, verdicts, next, paused: null };
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// The stack's spine below a side frame: `{ parent, child, chain }` names the paused work, the
|
|
268
|
+
// discipline on top and the sides between them; null while the spine itself runs.
|
|
269
|
+
const pausedUnder = (stack, entry, finished) => {
|
|
270
|
+
if (finished || !entry.record?.stacked || !stack || stack.owner >= stack.frames.length - 1) return null;
|
|
271
|
+
const sides = stack.frames.slice(stack.owner + 1).map(({ skill }) => skill ?? "work");
|
|
272
|
+
return { parent: stack.frames[stack.owner].skill ?? entry.family, child: sides.at(-1), chain: sides };
|
|
244
273
|
};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// environment (exit 10-12, 14, 15, 21, 22) goes straight to that notice. A done film with a downgrade, open
|
|
12
12
|
// look items or no image tool blocks once so the reply says so.
|
|
13
13
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
14
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
14
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
15
15
|
|
|
16
16
|
import { ensureStateDirIgnored, resolveProjectStateRoot } from "./project-state-root.mjs";
|
|
17
17
|
|
|
@@ -23,6 +23,16 @@ const DONE_MODULE = new URL("../skills/lit-typographic-motion/engine/node/done.m
|
|
|
23
23
|
|
|
24
24
|
export const motionTurnPath = (cwd = resolveProjectStateRoot()) => join(resolveProjectStateRoot(cwd), ".litclaude", "motion", "turn.json");
|
|
25
25
|
|
|
26
|
+
// The model often works inside the film folder (`cd motion-x && motion.mjs stage --out .`). Outside a Git
|
|
27
|
+
// repository that folder resolves to its own state root, so the tool and Stop hooks look for the turn the
|
|
28
|
+
// prompt armed in the nearest folder up the tree that holds one.
|
|
29
|
+
const turnRoot = (cwd) => {
|
|
30
|
+
for (let dir = resolve(cwd); ; dir = dirname(dir)) {
|
|
31
|
+
if (existsSync(motionTurnPath(dir))) return dir;
|
|
32
|
+
if (dirname(dir) === dir) return cwd;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
26
36
|
const readTurn = (cwd) => {
|
|
27
37
|
const path = motionTurnPath(cwd);
|
|
28
38
|
if (!existsSync(path)) return null;
|
|
@@ -51,11 +61,17 @@ export const recordMotionTurn = (cwd, { sessionId, discipline, now = Date.now()
|
|
|
51
61
|
|
|
52
62
|
const unquote = (value) => value?.replace(/^["']|["']$/gu, "");
|
|
53
63
|
|
|
64
|
+
// `$NAME` / `${NAME}` from `NAME=value` assignments earlier in the same command line. A variable the
|
|
65
|
+
// command never sets stays unexpanded, and the caller treats that path as unknown.
|
|
66
|
+
const expandVars = (value, vars) => value?.replace(/\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?/gu, (whole, name) => vars.get(name) ?? whole);
|
|
67
|
+
|
|
54
68
|
/** Parse one `motion.mjs <subcommand> ...` command line into { mode, out, brief, round, stillsOnly }. */
|
|
55
69
|
export function parseMotionCommand(command, workdir) {
|
|
56
70
|
const match = COMMAND.exec(command);
|
|
57
71
|
if (!match) return null;
|
|
58
|
-
const
|
|
72
|
+
const vars = new Map();
|
|
73
|
+
for (const m of command.slice(0, match.index).matchAll(/(?:^|[\s;&|(])([A-Za-z_][A-Za-z0-9_]*)=("[^"]*"|'[^']*'|[^\s;&|]*)/gu)) vars.set(m[1], expandVars(unquote(m[2]), vars));
|
|
74
|
+
const tokens = [...match[2].matchAll(/"[^"]*"|'[^']*'|[^\s]+/gu)].map((m) => expandVars(unquote(m[0]), vars));
|
|
59
75
|
const values = {};
|
|
60
76
|
const positional = [];
|
|
61
77
|
let stillsOnly = false;
|
|
@@ -69,7 +85,7 @@ export function parseMotionCommand(command, workdir) {
|
|
|
69
85
|
}
|
|
70
86
|
} else if (!t.startsWith(">") && !t.startsWith("2>")) positional.push(t);
|
|
71
87
|
}
|
|
72
|
-
const abs = (p) => (p ? (isAbsolute(p) ? p : join(workdir, p)) : null);
|
|
88
|
+
const abs = (p) => (p && !p.includes("$") ? (isAbsolute(p) ? p : join(workdir, p)) : null);
|
|
73
89
|
const mode = match[1];
|
|
74
90
|
if (mode === "gate") return { mode, out: abs(positional[0]), brief: null, round: null, stillsOnly: false };
|
|
75
91
|
// cover-gate checks a file; it is not a render, so it never becomes the output the Stop hook judges.
|
|
@@ -90,7 +106,8 @@ const toolOutput = (input) => {
|
|
|
90
106
|
return [response.stdout, response.stderr, response.output].filter((part) => typeof part === "string").join("\n");
|
|
91
107
|
};
|
|
92
108
|
|
|
93
|
-
export const observeMotionTool = (
|
|
109
|
+
export const observeMotionTool = (start, { input, now = Date.now() }) => {
|
|
110
|
+
const cwd = turnRoot(start);
|
|
94
111
|
let turn;
|
|
95
112
|
try {
|
|
96
113
|
turn = readTurn(cwd);
|
|
@@ -98,7 +115,7 @@ export const observeMotionTool = (cwd, { input, now = Date.now() }) => {
|
|
|
98
115
|
return null;
|
|
99
116
|
}
|
|
100
117
|
if (!turn || turn.sessionId !== input.session_id) return null;
|
|
101
|
-
const workdir = typeof input.cwd === "string" ? input.cwd :
|
|
118
|
+
const workdir = typeof input.cwd === "string" ? input.cwd : start;
|
|
102
119
|
const command = input.tool_name === "Bash" && typeof input.tool_input?.command === "string" ? input.tool_input.command : "";
|
|
103
120
|
const parsed = parseMotionCommand(command, workdir);
|
|
104
121
|
if (!parsed) return null;
|
|
@@ -126,7 +143,8 @@ export function readsFromTranscript(transcriptPath) {
|
|
|
126
143
|
|
|
127
144
|
const notDoneNotice = (reasons) => `lit-typographic-motion: the film is not done (${reasons.join("; ")}). Stop rendering now and say in the reply, in plain words, that the film is not done and why, and what the user can run to finish it.`;
|
|
128
145
|
|
|
129
|
-
export const evaluateMotionStop = async ({ cwd, sessionId, transcriptPath = null, now = Date.now() }) => {
|
|
146
|
+
export const evaluateMotionStop = async ({ cwd: start, sessionId, transcriptPath = null, now = Date.now() }) => {
|
|
147
|
+
const cwd = turnRoot(start);
|
|
130
148
|
let turn;
|
|
131
149
|
try {
|
|
132
150
|
turn = readTurn(cwd);
|
|
@@ -153,7 +171,7 @@ export const evaluateMotionStop = async ({ cwd, sessionId, transcriptPath = null
|
|
|
153
171
|
];
|
|
154
172
|
if (!say.length) return { action: "allow", why: "done" };
|
|
155
173
|
writeTurn(cwd, { ...turn, notified: true });
|
|
156
|
-
return { action: "block", why: verdict.status, reason: `lit-typographic-motion: the film is finished. The reply must say plainly: ${say.join("; ")}.` };
|
|
174
|
+
return { action: "block", why: verdict.status, reason: `lit-typographic-motion: ${verdict.preview ? "the storyboard preview is finished" : "the film is finished"}. The reply must say plainly: ${say.join("; ")}.` };
|
|
157
175
|
}
|
|
158
176
|
if (verdict.status === "BLOCKED" || turn.blockCount >= MOTION_MAX_BLOCKS) {
|
|
159
177
|
writeTurn(cwd, { ...turn, notified: true, warned: true });
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
"""Render a .pptx, .docx or .pdf to PNG pages so a person (or the model) can look at it.
|
|
3
3
|
|
|
4
4
|
LibreOffice (soffice) converts Office files to PDF in a private profile directory,
|
|
5
|
-
so parallel runs never share a lock; PyMuPDF rasterises the PDF pages.
|
|
5
|
+
so parallel runs never share a lock; PyMuPDF rasterises the PDF pages. Fonts a .pptx
|
|
6
|
+
embeds as plain font files are placed in that profile's font folder first, so the pages
|
|
7
|
+
show the faces PowerPoint shows even where the font is not installed. A PDF input
|
|
6
8
|
skips the conversion. Without soffice an Office file cannot be rendered: the script
|
|
7
9
|
prints SKIP with the reason and exits 0, and the caller must say that the visual
|
|
8
10
|
pass did not happen.
|
|
@@ -21,9 +23,34 @@ import shutil
|
|
|
21
23
|
import subprocess
|
|
22
24
|
import sys
|
|
23
25
|
import tempfile
|
|
26
|
+
import zipfile
|
|
24
27
|
from pathlib import Path
|
|
25
28
|
|
|
26
29
|
|
|
30
|
+
def profile_fonts(source: Path, profile: Path) -> list[Path]:
|
|
31
|
+
"""Copy the plain font files a .pptx embeds (ppt/fonts/*.fntdata) into the profile's font folder."""
|
|
32
|
+
if source.suffix.lower() != ".pptx":
|
|
33
|
+
return []
|
|
34
|
+
placed = []
|
|
35
|
+
try:
|
|
36
|
+
with zipfile.ZipFile(source) as z:
|
|
37
|
+
for name in z.namelist():
|
|
38
|
+
if not (name.startswith("ppt/fonts/") and name.endswith(".fntdata")):
|
|
39
|
+
continue
|
|
40
|
+
data = z.read(name)
|
|
41
|
+
# Only a TrueType or OpenType file; an obfuscated or EOT part is left to the renderer.
|
|
42
|
+
kind = ".otf" if data[:4] == b"OTTO" else ".ttf" if data[:4] in (b"\x00\x01\x00\x00", b"true") else None
|
|
43
|
+
if not kind:
|
|
44
|
+
continue
|
|
45
|
+
target = profile / "user" / "fonts" / (Path(name).stem + kind)
|
|
46
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
47
|
+
target.write_bytes(data)
|
|
48
|
+
placed.append(target)
|
|
49
|
+
except zipfile.BadZipFile:
|
|
50
|
+
return []
|
|
51
|
+
return placed
|
|
52
|
+
|
|
53
|
+
|
|
27
54
|
def to_pdf(source: Path, out_dir: Path) -> tuple[Path | None, str]:
|
|
28
55
|
if source.suffix.lower() == ".pdf":
|
|
29
56
|
return source, "input is already PDF"
|
|
@@ -31,6 +58,7 @@ def to_pdf(source: Path, out_dir: Path) -> tuple[Path | None, str]:
|
|
|
31
58
|
if not soffice:
|
|
32
59
|
return None, "LibreOffice (soffice) is not on PATH"
|
|
33
60
|
with tempfile.TemporaryDirectory(prefix="litclaude-soffice-") as profile:
|
|
61
|
+
profile_fonts(source, Path(profile))
|
|
34
62
|
result = subprocess.run(
|
|
35
63
|
[
|
|
36
64
|
soffice,
|