@litfamily/litcodex 1.0.30 → 1.0.32
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/README-Ko-KR.md +13 -12
- package/README.md +13 -12
- package/TRADEMARK.md +12 -0
- package/dist/install/generated-skill-payload-hashes.d.ts +188 -82
- package/dist/install/generated-skill-payload-hashes.js +188 -82
- package/dist/install/skill-catalog.d.ts +1 -1
- package/dist/install/skill-catalog.js +12 -1
- package/dist/install/skill-resource-hashes.d.ts +1 -1
- package/dist/install/skill-resource-hashes.js +1 -1
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
- package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
- package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
- package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directive.md +10 -4
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-adhd.md +194 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-handoff.md +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-hijack.md +219 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-plan.md +2 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-recap.md +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-schematic.md +199 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/litwork.md +2 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/adhd-suggest.d.ts +10 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/adhd-suggest.js +67 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.d.ts +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.js +128 -8
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-looks.d.ts +19 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-looks.js +58 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.d.ts +30 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.js +97 -7
- package/marketplace/plugins/litcodex/components/lit-loop/dist/cli.js +13 -3
- package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +8 -9
- package/marketplace/plugins/litcodex/components/lit-loop/dist/control-chars.d.ts +5 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/control-chars.js +23 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +8 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +126 -13
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.d.ts +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.js +29 -13
- package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-events.d.ts +13 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-events.js +85 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-state.d.ts +55 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/lane-state.js +227 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.d.ts +5 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.js +17 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +6 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +6 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +25 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-gate.d.ts +79 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-gate.js +310 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-route.js +5 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.d.ts +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.js +38 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-scope-roots.d.ts +7 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-scope-roots.js +76 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/redaction.js +18 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.d.ts +15 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.js +46 -9
- package/marketplace/plugins/litcodex/components/lit-loop/dist/restart-chip.d.ts +6 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/restart-chip.js +59 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-cli.d.ts +10 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-cli.js +88 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.d.ts +20 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.js +94 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-look.d.ts +6 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-look.js +41 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-redact.d.ts +3 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-redact.js +40 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-rollout.d.ts +48 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-rollout.js +292 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.d.ts +168 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.js +867 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +45 -3
- package/marketplace/plugins/litcodex/components/lit-loop/dist/run-panel.js +1 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/schematic-route.d.ts +6 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/schematic-route.js +35 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.d.ts +3 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.js +15 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/session-liveness.d.ts +16 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/session-liveness.js +90 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-mention-scope.js +6 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/stack-hook.d.ts +8 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/stack-hook.js +57 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/statusline.js +8 -3
- package/marketplace/plugins/litcodex/components/lit-loop/dist/threads.d.ts +50 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/threads.js +183 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.d.ts +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.js +29 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.d.ts +10 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +11 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-stack.d.ts +139 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-stack.js +518 -0
- package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
- package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
- package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.d.ts +6 -0
- package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.js +65 -0
- package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
- package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
- package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
- package/marketplace/plugins/litcodex/hooks/hooks.json +24 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/SKILL.md +6 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/components.css +414 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/fonts.json +22 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/kit/ui.js +228 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/brand-and-imagery.md +1 -1
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/complete-contract.md +1 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/craft-floor.md +2 -2
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/default-editorial-pixel.json +15 -8
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/design-choice.md +19 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/house-styles.md +235 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/motion-guide.md +2 -2
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/probe-and-review.md +6 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/production-interview.md +2 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/slop-register.md +4 -4
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/lock-probe.mjs +196 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/page-probe.mjs +22 -4
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/probe.mjs +59 -13
- package/marketplace/plugins/litcodex/skills/frontend-ui-ux/scripts/rule-data.mjs +38 -4
- package/marketplace/plugins/litcodex/skills/lit-adhd/SKILL.md +185 -0
- package/marketplace/plugins/litcodex/skills/lit-adhd/agents/openai.yaml +6 -0
- package/marketplace/plugins/litcodex/skills/lit-adhd/references/card-examples.md +163 -0
- package/marketplace/plugins/litcodex/skills/lit-adhd/references/status-taxonomy.md +45 -0
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/SKILL.md +18 -7
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/style-guide.md +20 -11
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-swimlane.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-tree-block-decomposition.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-tree.md +3 -3
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/references/verifier-guide.md +1 -0
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +1 -2
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/visual-quality.mjs +1 -2
- package/marketplace/plugins/litcodex/skills/lit-docx/SKILL.md +12 -3
- package/marketplace/plugins/litcodex/skills/lit-docx/references/direction-step.md +6 -3
- package/marketplace/plugins/litcodex/skills/lit-hijack/SKILL.md +449 -0
- package/marketplace/plugins/litcodex/skills/lit-hijack/agents/openai.yaml +6 -0
- package/marketplace/plugins/litcodex/skills/lit-hijack/references/capture-and-provenance.md +100 -0
- package/marketplace/plugins/litcodex/skills/lit-hijack/references/clean-room-build.md +111 -0
- package/marketplace/plugins/litcodex/skills/lit-hijack/references/distil-and-licence.md +102 -0
- package/marketplace/plugins/litcodex/skills/lit-hijack/references/gap-and-port-design.md +125 -0
- package/marketplace/plugins/litcodex/skills/lit-hijack/references/parity-and-report.md +108 -0
- package/marketplace/plugins/litcodex/skills/lit-hijack/scripts/hijack.mjs +1050 -0
- package/marketplace/plugins/litcodex/skills/lit-loop/SKILL.md +13 -4
- package/marketplace/plugins/litcodex/skills/lit-plan/SKILL.md +9 -2
- package/marketplace/plugins/litcodex/skills/lit-plan/references/full-workflow.md +2 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/NOTICE +1 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/SKILL.md +35 -8
- package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/fonts/jetbrains-mono/SOURCE.md +21 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/anti-slop-checklist.md +5 -2
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/authoring-guide.md +3 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/density-and-fill.md +20 -6
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/direction-step.md +26 -8
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/14-engineering-review-computational-brutalism-ko.md +173 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/15-launch-pitch-neo-brutalism-ko.md +154 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/16-design-lecture-bauhaus-ko.md +139 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/17-community-programme-riso-ko.md +158 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/18-public-data-briefing-newsroom-ko.md +179 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/layout-families.md +42 -27
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/title-treatments.md +31 -27
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/bauhaus.md +136 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/chalk.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/computational-brutalism.md +145 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/neo-brutalism.md +155 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/newsroom.md +141 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/riso.md +133 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/signal.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/studio.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/compile-deck.js +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/craft_extras.py +136 -94
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/embed_fonts.py +13 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/render-pack.js +386 -579
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/office-run.mjs +2 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/qa_deck.py +7 -13
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/render_pages.py +124 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +100 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
- package/marketplace/plugins/litcodex/skills/lit-recap/SKILL.md +2 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/SKILL.md +198 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/agents/openai.yaml +6 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/cutaway-outputs.md +70 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/isometric-craft.md +101 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/journal-figures.md +72 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/kit-api.md +134 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/pfd-and-layout.md +53 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/pid-drafting.md +103 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/pid-symbols.md +163 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/references/verification.md +100 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/doctor.mjs +57 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/fonts.mjs +28 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/png.mjs +132 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/route.mjs +218 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/motion.mjs +129 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/qa.mjs +92 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/render.mjs +233 -0
- package/marketplace/plugins/litcodex/skills/lit-schematic/scripts/scaffold.mjs +60 -0
- package/marketplace/plugins/litcodex/skills/lit-scientific-visualization/SKILL.md +34 -8
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/SKILL.md +18 -14
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +12 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/assets.mjs +388 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/blender/runner.py +221 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/blender.mjs +132 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/board.mjs +142 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/constants.mjs +6 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-assets.mjs +7 -4
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-capture.mjs +8 -7
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-init.js +14 -2
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-treatment.mjs +38 -3
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover.mjs +19 -4
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/driver.mjs +8 -8
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/gallery.mjs +147 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/house.mjs +45 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/image.mjs +89 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/look.mjs +58 -25
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/runtime.mjs +59 -14
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/safe-read.mjs +32 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/scaffold.mjs +208 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/score.mjs +668 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/sound.mjs +174 -31
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-gate.mjs +45 -3
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-kit.js +99 -1
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-qa.js +8 -1
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-qa.mjs +180 -11
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-render.mjs +42 -12
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage-worker.mjs +7 -4
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage.mjs +96 -10
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/styles.mjs +233 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/treatment.mjs +291 -14
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/hero-3d/expected.json +33 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/cover.md +44 -7
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/depth.md +156 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/design-choice.md +22 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/quality-gate.md +29 -7
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/runtime.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/sound.md +87 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/stage.md +19 -7
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/studio.md +246 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/style-bibles.md +2 -2
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/treatment.md +41 -21
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/render.mjs +51 -4
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/paper.json +185 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/swiss-signal.json +188 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/terminalcore.json +182 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/styles/tidal.json +187 -0
- package/marketplace/plugins/litcodex/skills/litresearch/SKILL.md +7 -0
- package/marketplace/plugins/litcodex/skills/litwork/SKILL.md +2 -1
- package/marketplace/plugins/litcodex/skills/readme-studio/SKILL.md +10 -0
- package/marketplace/plugins/litcodex/skills/review-work/SKILL.md +7 -1
- package/marketplace/plugins/litcodex/skills/start-work/SKILL.md +11 -1
- package/node_modules/@litcodex/lit-loop/directive.md +10 -4
- package/node_modules/@litcodex/lit-loop/directives/lit-adhd.md +194 -0
- package/node_modules/@litcodex/lit-loop/directives/lit-handoff.md +2 -0
- package/node_modules/@litcodex/lit-loop/directives/lit-hijack.md +219 -0
- package/node_modules/@litcodex/lit-loop/directives/lit-plan.md +2 -1
- package/node_modules/@litcodex/lit-loop/directives/lit-recap.md +2 -0
- package/node_modules/@litcodex/lit-loop/directives/lit-schematic.md +199 -0
- package/node_modules/@litcodex/lit-loop/directives/litwork.md +2 -1
- package/node_modules/@litcodex/lit-loop/dist/adhd-suggest.d.ts +10 -0
- package/node_modules/@litcodex/lit-loop/dist/adhd-suggest.js +67 -0
- package/node_modules/@litcodex/lit-loop/dist/card-html.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/card-html.js +128 -8
- package/node_modules/@litcodex/lit-loop/dist/card-looks.d.ts +19 -0
- package/node_modules/@litcodex/lit-loop/dist/card-looks.js +58 -0
- package/node_modules/@litcodex/lit-loop/dist/card-status.d.ts +30 -0
- package/node_modules/@litcodex/lit-loop/dist/card-status.js +97 -7
- package/node_modules/@litcodex/lit-loop/dist/cli.js +13 -3
- package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +8 -9
- package/node_modules/@litcodex/lit-loop/dist/control-chars.d.ts +5 -0
- package/node_modules/@litcodex/lit-loop/dist/control-chars.js +23 -0
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +8 -0
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +126 -13
- package/node_modules/@litcodex/lit-loop/dist/hud.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/hud.js +29 -13
- package/node_modules/@litcodex/lit-loop/dist/lane-events.d.ts +13 -0
- package/node_modules/@litcodex/lit-loop/dist/lane-events.js +85 -0
- package/node_modules/@litcodex/lit-loop/dist/lane-state.d.ts +55 -0
- package/node_modules/@litcodex/lit-loop/dist/lane-state.js +227 -0
- package/node_modules/@litcodex/lit-loop/dist/live-step.d.ts +5 -1
- package/node_modules/@litcodex/lit-loop/dist/live-step.js +17 -1
- package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +6 -0
- package/node_modules/@litcodex/lit-loop/dist/markers.js +6 -0
- package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/modes.js +25 -1
- package/node_modules/@litcodex/lit-loop/dist/motion-gate.d.ts +79 -0
- package/node_modules/@litcodex/lit-loop/dist/motion-gate.js +310 -0
- package/node_modules/@litcodex/lit-loop/dist/motion-route.js +5 -1
- package/node_modules/@litcodex/lit-loop/dist/plan-persistence.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/plan-persistence.js +38 -2
- package/node_modules/@litcodex/lit-loop/dist/plan-scope-roots.d.ts +7 -0
- package/node_modules/@litcodex/lit-loop/dist/plan-scope-roots.js +76 -0
- package/node_modules/@litcodex/lit-loop/dist/redaction.js +18 -0
- package/node_modules/@litcodex/lit-loop/dist/reentry.d.ts +15 -0
- package/node_modules/@litcodex/lit-loop/dist/reentry.js +46 -9
- package/node_modules/@litcodex/lit-loop/dist/restart-chip.d.ts +6 -0
- package/node_modules/@litcodex/lit-loop/dist/restart-chip.js +59 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-cli.d.ts +10 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-cli.js +88 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-go.d.ts +20 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-go.js +94 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-look.d.ts +6 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-look.js +41 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-redact.d.ts +3 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-redact.js +40 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-rollout.d.ts +48 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind-rollout.js +292 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind.d.ts +168 -0
- package/node_modules/@litcodex/lit-loop/dist/rewind.js +867 -0
- package/node_modules/@litcodex/lit-loop/dist/route-heads.js +45 -3
- package/node_modules/@litcodex/lit-loop/dist/run-panel.js +1 -0
- package/node_modules/@litcodex/lit-loop/dist/schematic-route.d.ts +6 -0
- package/node_modules/@litcodex/lit-loop/dist/schematic-route.js +35 -0
- package/node_modules/@litcodex/lit-loop/dist/screen-card.d.ts +3 -0
- package/node_modules/@litcodex/lit-loop/dist/screen-card.js +15 -5
- package/node_modules/@litcodex/lit-loop/dist/session-liveness.d.ts +16 -0
- package/node_modules/@litcodex/lit-loop/dist/session-liveness.js +90 -0
- package/node_modules/@litcodex/lit-loop/dist/skill-mention-scope.js +6 -0
- package/node_modules/@litcodex/lit-loop/dist/stack-hook.d.ts +8 -0
- package/node_modules/@litcodex/lit-loop/dist/stack-hook.js +57 -0
- package/node_modules/@litcodex/lit-loop/dist/statusline.js +8 -3
- package/node_modules/@litcodex/lit-loop/dist/threads.d.ts +50 -0
- package/node_modules/@litcodex/lit-loop/dist/threads.js +183 -0
- package/node_modules/@litcodex/lit-loop/dist/trigger.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/trigger.js +29 -5
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +10 -0
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +11 -1
- package/node_modules/@litcodex/lit-loop/dist/workflow-stack.d.ts +139 -0
- package/node_modules/@litcodex/lit-loop/dist/workflow-stack.js +518 -0
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/node_modules/@litcodex/lit-loop/skills/lit-adhd/SKILL.md +185 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-hijack/SKILL.md +449 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-loop/SKILL.md +13 -4
- package/node_modules/@litcodex/lit-loop/skills/lit-plan/SKILL.md +9 -2
- package/node_modules/@litcodex/lit-loop/skills/lit-recap/SKILL.md +2 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-schematic/SKILL.md +198 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-scientific-visualization/SKILL.md +34 -8
- package/node_modules/@litcodex/lit-loop/skills/litresearch/SKILL.md +7 -0
- package/node_modules/@litcodex/lit-loop/skills/litwork/SKILL.md +2 -1
- package/node_modules/@litcodex/lit-loop/skills/review-work/SKILL.md +7 -1
- package/node_modules/@litcodex/lit-loop/skills/start-work/SKILL.md +11 -1
- package/package.json +3 -2
- package/readme-assets/badge-version.svg +1 -1
- package/readme-assets/skills/lit-adhd.webp +0 -0
- package/readme-assets/skills/lit-hijack.webp +0 -0
- package/readme-assets/skills/lit-schematic.webp +0 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
// src/workflow-stack.ts — the session's workflow stack: where each running discipline stands, so asking
|
|
2
|
+
// for something in the middle of a loop or a plan run pauses that work instead of erasing it.
|
|
3
|
+
//
|
|
4
|
+
// The bottom frame is the spine (the main line of work: interview, plan, work, review, or a research
|
|
5
|
+
// run); a discipline started on top of it is a side frame. A successor in the main chain (plan after
|
|
6
|
+
// interview, work after plan, review after work) finishes the frame below it instead of pausing it.
|
|
7
|
+
// Asking for a skill already in the stack resumes its frame with its stage and count; `lit continue`
|
|
8
|
+
// on a side frame closes it and resumes the paused spine at the stage and k/n it left. Read-only
|
|
9
|
+
// disciplines never touch the stack.
|
|
10
|
+
//
|
|
11
|
+
// `applyStackEvent` is pure. The store writes one small file per session under
|
|
12
|
+
// `.litcodex/workflow-stack/`, whole, through a temporary file; every read and write fails open, so a
|
|
13
|
+
// hook never fails because of it. Frames keep skills, stages and counts only: never a prompt, a command
|
|
14
|
+
// or a path other than a project-relative plan name.
|
|
15
|
+
import { closeSync, fstatSync, lstatSync, mkdirSync, readdirSync, readSync } from "node:fs";
|
|
16
|
+
import { isAbsolute, join } from "node:path";
|
|
17
|
+
import { openRegularFile, plainDirs, plainDirsOrMissing, writeFileAtomic } from "./live-step.js";
|
|
18
|
+
import { readSessionsLiveness } from "./session-liveness.js";
|
|
19
|
+
import { normalizeSessionId } from "./state-paths.js";
|
|
20
|
+
export const STACK_DIR = ".litcodex/workflow-stack";
|
|
21
|
+
export const MAX_FRAMES = 3;
|
|
22
|
+
export const MAX_HISTORY = 20;
|
|
23
|
+
export const MAX_STACK_BYTES = 64 * 1024;
|
|
24
|
+
/** A frame nobody touched for this long is dropped on the next event. */
|
|
25
|
+
export const STACK_DROP_MS = 24 * 60 * 60 * 1000;
|
|
26
|
+
/** Disciplines that only read: they neither pause the work under them nor appear as a frame. */
|
|
27
|
+
export const READ_ONLY_DISCIPLINES = [
|
|
28
|
+
"lit-recap",
|
|
29
|
+
"lit-comprehend",
|
|
30
|
+
"lit-handoff",
|
|
31
|
+
"lit-adhd",
|
|
32
|
+
"lit-rewind",
|
|
33
|
+
];
|
|
34
|
+
export const WORKFLOW_FAMILIES = {
|
|
35
|
+
main: ["interview", "plan", "work", "review", "done"],
|
|
36
|
+
research: ["decompose", "wave", "expand", "verify", "synthesis"],
|
|
37
|
+
loop: ["PIN", "RED", "GREEN", "VERIFY", "REVIEW", "RECORD"],
|
|
38
|
+
};
|
|
39
|
+
/** lit-loop writes eight steps; the map shows six, so SURFACE sits on VERIFY and CLEAN on RECORD. */
|
|
40
|
+
const STAGE_ALIASES = { SURFACE: "VERIFY", CLEAN: "RECORD" };
|
|
41
|
+
const STAGE_UNITS = ["task", "criterion", "iteration", "wave", "round"];
|
|
42
|
+
const VERDICT_STATES = ["pass", "fail", "pending", "running"];
|
|
43
|
+
const REVIEW_LANES = ["goal", "quality", "security", "qa", "context"];
|
|
44
|
+
const MAX_VERDICTS = 8;
|
|
45
|
+
/** Where each discipline enters the map. A discipline not listed here is always a side frame. */
|
|
46
|
+
const DISCIPLINE_ENTRY = {
|
|
47
|
+
"deep-interview": { family: "main", stage: "interview" },
|
|
48
|
+
"lit-brainstorm": { family: "main", stage: "interview" },
|
|
49
|
+
"lit-crucible": { family: "main", stage: "plan" },
|
|
50
|
+
"lit-plan": { family: "main", stage: "plan" },
|
|
51
|
+
"start-work": { family: "main", stage: "work" },
|
|
52
|
+
litwork: { family: "main", stage: "work" },
|
|
53
|
+
litgoal: { family: "main", stage: "work" },
|
|
54
|
+
"lit-loop": { family: "main", stage: "work" },
|
|
55
|
+
"review-work": { family: "main", stage: "review" },
|
|
56
|
+
litresearch: { family: "research", stage: "decompose" },
|
|
57
|
+
};
|
|
58
|
+
/** Order in the main chain; a newcomer of a higher rank succeeds the frame below it. */
|
|
59
|
+
const CHAIN_RANK = {
|
|
60
|
+
"deep-interview": 0,
|
|
61
|
+
"lit-brainstorm": 0,
|
|
62
|
+
"lit-crucible": 1,
|
|
63
|
+
"lit-plan": 1,
|
|
64
|
+
"start-work": 2,
|
|
65
|
+
litwork: 2,
|
|
66
|
+
litgoal: 2,
|
|
67
|
+
"lit-loop": 2,
|
|
68
|
+
"review-work": 3,
|
|
69
|
+
};
|
|
70
|
+
const PLAN_REF = /^(?:\.litcodex\/)?plans\/[A-Za-z0-9_-][A-Za-z0-9._-]*\.md$/u;
|
|
71
|
+
export function emptyStack(sessionId) {
|
|
72
|
+
return {
|
|
73
|
+
version: 1,
|
|
74
|
+
sessionId: typeof sessionId === "string" && sessionId ? sessionId : null,
|
|
75
|
+
frames: [],
|
|
76
|
+
history: [],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function lastIndexWhere(items, test) {
|
|
80
|
+
for (let index = items.length - 1; index >= 0; index -= 1)
|
|
81
|
+
if (test(items[index]))
|
|
82
|
+
return index;
|
|
83
|
+
return -1;
|
|
84
|
+
}
|
|
85
|
+
function countOf(value) {
|
|
86
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 9999 ? value : undefined;
|
|
87
|
+
}
|
|
88
|
+
function planRef(ref) {
|
|
89
|
+
return ref && typeof ref.plan === "string" && PLAN_REF.test(ref.plan) && !ref.plan.includes("..")
|
|
90
|
+
? { plan: ref.plan }
|
|
91
|
+
: undefined;
|
|
92
|
+
}
|
|
93
|
+
/** A known stage of a known family in its stored spelling, or null. */
|
|
94
|
+
export function normalizeStage(family, stage) {
|
|
95
|
+
if (typeof family !== "string" || !Object.hasOwn(WORKFLOW_FAMILIES, family))
|
|
96
|
+
return null;
|
|
97
|
+
const stages = WORKFLOW_FAMILIES[family] ?? [];
|
|
98
|
+
const raw = String(stage ?? "").trim();
|
|
99
|
+
const named = family === "loop" ? (STAGE_ALIASES[raw.toUpperCase()] ?? raw.toUpperCase()) : raw.toLowerCase();
|
|
100
|
+
return stages.includes(named) ? named : null;
|
|
101
|
+
}
|
|
102
|
+
function isSuccessor(skill, frame) {
|
|
103
|
+
const next = CHAIN_RANK[skill];
|
|
104
|
+
const below = frame.skill === null ? undefined : CHAIN_RANK[frame.skill];
|
|
105
|
+
return next !== undefined && below !== undefined && next > below;
|
|
106
|
+
}
|
|
107
|
+
function newFrame(skill, ref, role, at) {
|
|
108
|
+
const entry = DISCIPLINE_ENTRY[skill];
|
|
109
|
+
const frame = {
|
|
110
|
+
skill,
|
|
111
|
+
family: entry?.family ?? null,
|
|
112
|
+
stage: entry?.stage ?? null,
|
|
113
|
+
role,
|
|
114
|
+
status: "active",
|
|
115
|
+
verdicts: {},
|
|
116
|
+
at,
|
|
117
|
+
};
|
|
118
|
+
const plan = planRef(ref);
|
|
119
|
+
if (plan)
|
|
120
|
+
frame.ref = plan;
|
|
121
|
+
return frame;
|
|
122
|
+
}
|
|
123
|
+
/** A saved plan, or a review whose five lanes have all reported: what comes next replaces it. */
|
|
124
|
+
function isFinished(frame) {
|
|
125
|
+
return (frame.done === true ||
|
|
126
|
+
(frame.family === "main" &&
|
|
127
|
+
frame.stage === "review" &&
|
|
128
|
+
REVIEW_LANES.every((id) => ["pass", "fail"].includes(frame.verdicts?.[id] ?? ""))));
|
|
129
|
+
}
|
|
130
|
+
function snapshot(frame) {
|
|
131
|
+
return {
|
|
132
|
+
stage: frame.stage,
|
|
133
|
+
...(frame.n === undefined ? {} : { n: frame.n }),
|
|
134
|
+
...(frame.total === undefined ? {} : { total: frame.total }),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Apply one event to the stack and return the next stack with the transitions it made (`started`,
|
|
139
|
+
* `paused`, `resumed`, `side.done`, `finished`, `dropped`), which the caller may log.
|
|
140
|
+
* Events: `start {skill, ref?, restart?}`, `continue`, `move {family, stage, n?, total?, unit?, done?,
|
|
141
|
+
* verdicts?, ref?, scope?}` (the hooks' observations) and `record {...same fields}` (the model's
|
|
142
|
+
* `loop stage` call, which updates the top frame or opens one).
|
|
143
|
+
*/
|
|
144
|
+
export function applyStackEvent(stack, event, now = new Date()) {
|
|
145
|
+
const at = now.toISOString();
|
|
146
|
+
const transitions = [];
|
|
147
|
+
const note = (type, frame) => {
|
|
148
|
+
transitions.push({ type, skill: frame.skill, ...snapshot(frame) });
|
|
149
|
+
};
|
|
150
|
+
let frames = (Array.isArray(stack?.frames) ? stack.frames : [])
|
|
151
|
+
.filter((frame) => now.getTime() - Date.parse(frame.at) <= STACK_DROP_MS)
|
|
152
|
+
.map((frame) => ({ ...frame }));
|
|
153
|
+
const pause = (frame) => {
|
|
154
|
+
if (frame.status === "paused")
|
|
155
|
+
return;
|
|
156
|
+
frame.status = "paused";
|
|
157
|
+
frame.pausedAt = at;
|
|
158
|
+
note("paused", frame);
|
|
159
|
+
};
|
|
160
|
+
const activate = (frame) => {
|
|
161
|
+
const wasPaused = frame.status === "paused";
|
|
162
|
+
frame.status = "active";
|
|
163
|
+
frame.at = at;
|
|
164
|
+
delete frame.pausedAt;
|
|
165
|
+
if (wasPaused)
|
|
166
|
+
note("resumed", frame);
|
|
167
|
+
};
|
|
168
|
+
const closeAbove = (index, type) => {
|
|
169
|
+
for (const frame of frames.slice(index + 1).reverse())
|
|
170
|
+
note(type, frame);
|
|
171
|
+
frames = frames.slice(0, index + 1);
|
|
172
|
+
};
|
|
173
|
+
const push = (frame) => {
|
|
174
|
+
frames.push(frame);
|
|
175
|
+
note("started", frame);
|
|
176
|
+
while (frames.length > MAX_FRAMES) {
|
|
177
|
+
const side = frames.findIndex((candidate, index) => index < frames.length - 1 && candidate.role === "side");
|
|
178
|
+
const [dropped] = frames.splice(side === -1 ? 0 : side, 1);
|
|
179
|
+
if (dropped)
|
|
180
|
+
note("dropped", dropped);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const start = (skill, ref, restart) => {
|
|
184
|
+
if (READ_ONLY_DISCIPLINES.includes(skill))
|
|
185
|
+
return;
|
|
186
|
+
const hasFamily = Object.hasOwn(DISCIPLINE_ENTRY, skill);
|
|
187
|
+
if (restart) {
|
|
188
|
+
closeAbove(-1, "finished");
|
|
189
|
+
push(newFrame(skill, ref, hasFamily ? "spine" : "side", at));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const existing = lastIndexWhere(frames, (frame) => frame.skill === skill);
|
|
193
|
+
const found = existing === -1 ? undefined : frames[existing];
|
|
194
|
+
if (found) {
|
|
195
|
+
const wanted = planRef(ref);
|
|
196
|
+
const kept = found.ref?.plan;
|
|
197
|
+
if (!isFinished(found) && (!wanted || !kept || wanted.plan === kept)) {
|
|
198
|
+
closeAbove(existing, "side.done");
|
|
199
|
+
activate(found);
|
|
200
|
+
if (wanted)
|
|
201
|
+
found.ref = wanted;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const role = found.role;
|
|
205
|
+
closeAbove(existing - 1, "finished");
|
|
206
|
+
const below = frames.at(-1);
|
|
207
|
+
if (below)
|
|
208
|
+
pause(below);
|
|
209
|
+
push(newFrame(skill, ref, role, at));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
let inherited = null;
|
|
213
|
+
let handed;
|
|
214
|
+
while (frames.length > 0 && isFinished(frames[frames.length - 1])) {
|
|
215
|
+
const done = frames.pop();
|
|
216
|
+
note("finished", done);
|
|
217
|
+
inherited = done.role;
|
|
218
|
+
handed = handed ?? done.ref;
|
|
219
|
+
}
|
|
220
|
+
// Work that follows a plan in the main chain carries the plan's name on, so its count is the plan's.
|
|
221
|
+
const carried = (from) => ref ?? ((CHAIN_RANK[skill] ?? -1) >= (CHAIN_RANK["start-work"] ?? 99) ? from : undefined);
|
|
222
|
+
const top = frames.at(-1);
|
|
223
|
+
if (!top) {
|
|
224
|
+
push(newFrame(skill, carried(handed), hasFamily ? (inherited ?? "spine") : "side", at));
|
|
225
|
+
}
|
|
226
|
+
else if (!frames.some((frame) => frame.role === "spine")) {
|
|
227
|
+
closeAbove(-1, "finished");
|
|
228
|
+
push(newFrame(skill, ref, hasFamily ? "spine" : "side", at));
|
|
229
|
+
}
|
|
230
|
+
else if (hasFamily && isSuccessor(skill, top)) {
|
|
231
|
+
frames.pop();
|
|
232
|
+
note(top.role === "spine" ? "finished" : "side.done", top);
|
|
233
|
+
push(newFrame(skill, carried(top.ref ?? handed), top.role, at));
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
pause(top);
|
|
237
|
+
push(newFrame(skill, ref, "side", at));
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
const update = (frame, fields) => {
|
|
241
|
+
const named = normalizeStage(fields.family, fields.stage);
|
|
242
|
+
if (named === null || typeof fields.family !== "string")
|
|
243
|
+
return;
|
|
244
|
+
const sameStage = frame.family === fields.family && frame.stage === named;
|
|
245
|
+
frame.family = fields.family;
|
|
246
|
+
frame.stage = named;
|
|
247
|
+
const n = countOf(fields.n);
|
|
248
|
+
if (n !== undefined)
|
|
249
|
+
frame.n = n;
|
|
250
|
+
const total = countOf(fields.total);
|
|
251
|
+
if (total !== undefined)
|
|
252
|
+
frame.total = total;
|
|
253
|
+
if (fields.unit !== undefined && STAGE_UNITS.includes(fields.unit))
|
|
254
|
+
frame.unit = fields.unit;
|
|
255
|
+
if (typeof fields.done === "boolean")
|
|
256
|
+
frame.done = fields.done;
|
|
257
|
+
const plan = planRef(fields.ref);
|
|
258
|
+
if (plan)
|
|
259
|
+
frame.ref = plan;
|
|
260
|
+
const given = Object.entries(fields.verdicts ?? {}).filter(([name, state]) => /^[a-z][a-z0-9-]{0,23}$/u.test(name) && VERDICT_STATES.includes(state));
|
|
261
|
+
frame.verdicts = Object.fromEntries([...Object.entries(sameStage ? (frame.verdicts ?? {}) : {}), ...given].slice(-MAX_VERDICTS));
|
|
262
|
+
frame.at = at;
|
|
263
|
+
};
|
|
264
|
+
switch (event.type) {
|
|
265
|
+
case "start":
|
|
266
|
+
start(event.skill, event.ref, event.restart === true);
|
|
267
|
+
break;
|
|
268
|
+
case "continue": {
|
|
269
|
+
const top = frames.at(-1);
|
|
270
|
+
const spine = lastIndexWhere(frames, (frame) => frame.role === "spine");
|
|
271
|
+
const spineFrame = spine === -1 ? undefined : frames[spine];
|
|
272
|
+
if (top?.role === "side" && spineFrame) {
|
|
273
|
+
closeAbove(spine, "side.done");
|
|
274
|
+
activate(spineFrame);
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case "move": {
|
|
279
|
+
const target = event.scope === "nearest"
|
|
280
|
+
? frames[lastIndexWhere(frames, (frame) => frame.family === event.family && frame.stage === event.stage)]
|
|
281
|
+
: frames.at(-1);
|
|
282
|
+
if (target && target.family === event.family && (event.scope === "nearest" || target.status === "active"))
|
|
283
|
+
update(target, event);
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
case "record": {
|
|
287
|
+
const top = frames.at(-1);
|
|
288
|
+
if (top)
|
|
289
|
+
update(top, event);
|
|
290
|
+
else if (normalizeStage(event.family, event.stage) !== null) {
|
|
291
|
+
const frame = {
|
|
292
|
+
skill: null,
|
|
293
|
+
family: event.family ?? null,
|
|
294
|
+
stage: null,
|
|
295
|
+
role: "spine",
|
|
296
|
+
status: "active",
|
|
297
|
+
verdicts: {},
|
|
298
|
+
at,
|
|
299
|
+
};
|
|
300
|
+
update(frame, event);
|
|
301
|
+
push(frame);
|
|
302
|
+
}
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
default:
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
const last = frames.at(-1);
|
|
309
|
+
if (last && last.status !== "active")
|
|
310
|
+
activate(last);
|
|
311
|
+
const history = [
|
|
312
|
+
...(Array.isArray(stack?.history) ? stack.history : []),
|
|
313
|
+
...transitions.map(({ type, skill }) => ({ event: type, skill, at })),
|
|
314
|
+
].slice(-MAX_HISTORY);
|
|
315
|
+
return { stack: { version: 1, sessionId: stack?.sessionId ?? null, frames, history }, transitions };
|
|
316
|
+
}
|
|
317
|
+
// ── Store ────────────────────────────────────────────────────────────────────
|
|
318
|
+
export function stackPath(cwd, sessionId) {
|
|
319
|
+
const id = normalizeSessionId(sessionId);
|
|
320
|
+
if (id === null || !isAbsolute(cwd))
|
|
321
|
+
return null;
|
|
322
|
+
return join(cwd, STACK_DIR, `${id}.json`);
|
|
323
|
+
}
|
|
324
|
+
function wellFormedFrame(value) {
|
|
325
|
+
if (typeof value !== "object" || value === null)
|
|
326
|
+
return false;
|
|
327
|
+
const frame = value;
|
|
328
|
+
return ((frame.skill === null || typeof frame.skill === "string") &&
|
|
329
|
+
(frame.role === "spine" || frame.role === "side") &&
|
|
330
|
+
(frame.status === "active" || frame.status === "paused") &&
|
|
331
|
+
typeof frame.at === "string" &&
|
|
332
|
+
Number.isFinite(Date.parse(frame.at)) &&
|
|
333
|
+
typeof frame.verdicts === "object" &&
|
|
334
|
+
frame.verdicts !== null);
|
|
335
|
+
}
|
|
336
|
+
/** The session's stack; a link, a non-file, an oversized or malformed file reads as empty. */
|
|
337
|
+
export function readStack(cwd, sessionId) {
|
|
338
|
+
const empty = emptyStack(sessionId);
|
|
339
|
+
const path = stackPath(cwd, sessionId);
|
|
340
|
+
if (path === null)
|
|
341
|
+
return empty;
|
|
342
|
+
let fd = null;
|
|
343
|
+
try {
|
|
344
|
+
if (!plainDirsOrMissing(cwd, STACK_DIR))
|
|
345
|
+
return empty;
|
|
346
|
+
fd = openRegularFile(path);
|
|
347
|
+
if (fd === null)
|
|
348
|
+
return empty;
|
|
349
|
+
const stat = fstatSync(fd);
|
|
350
|
+
if (!stat.isFile() || stat.size > MAX_STACK_BYTES)
|
|
351
|
+
return empty;
|
|
352
|
+
const buffer = Buffer.alloc(stat.size);
|
|
353
|
+
const read = readSync(fd, buffer, 0, stat.size, 0);
|
|
354
|
+
const parsed = JSON.parse(buffer.subarray(0, read).toString("utf8"));
|
|
355
|
+
const record = parsed;
|
|
356
|
+
if (!record || !Array.isArray(record.frames) || record.frames.length > MAX_FRAMES)
|
|
357
|
+
return empty;
|
|
358
|
+
if (!record.frames.every(wellFormedFrame))
|
|
359
|
+
return empty;
|
|
360
|
+
const history = Array.isArray(record.history) ? record.history.slice(-MAX_HISTORY) : [];
|
|
361
|
+
return { ...empty, frames: record.frames, history };
|
|
362
|
+
}
|
|
363
|
+
catch {
|
|
364
|
+
return empty;
|
|
365
|
+
}
|
|
366
|
+
finally {
|
|
367
|
+
if (fd !== null)
|
|
368
|
+
closeSync(fd);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/** Write the whole stack through a temporary file; a link at the destination is replaced, never followed. */
|
|
372
|
+
export function writeStack(cwd, sessionId, stack) {
|
|
373
|
+
const path = stackPath(cwd, sessionId);
|
|
374
|
+
if (path === null)
|
|
375
|
+
return;
|
|
376
|
+
try {
|
|
377
|
+
if (!plainDirsOrMissing(cwd, STACK_DIR))
|
|
378
|
+
return;
|
|
379
|
+
mkdirSync(join(cwd, STACK_DIR), { recursive: true });
|
|
380
|
+
const stat = lstatSync(join(cwd, STACK_DIR));
|
|
381
|
+
if (!stat.isDirectory())
|
|
382
|
+
return;
|
|
383
|
+
writeFileAtomic(path, `${JSON.stringify(stack)}\n`);
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
// The card shows the last good stack; a hook never fails because of it.
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
/** Read, apply one event and write back; returns the transitions it made. Never throws. */
|
|
390
|
+
export function recordStackEvent(cwd, sessionId, event, now = new Date()) {
|
|
391
|
+
try {
|
|
392
|
+
const result = applyStackEvent({ ...readStack(cwd, sessionId), sessionId }, event, now);
|
|
393
|
+
writeStack(cwd, sessionId, result.stack);
|
|
394
|
+
return result;
|
|
395
|
+
}
|
|
396
|
+
catch {
|
|
397
|
+
return { stack: emptyStack(sessionId), transitions: [] };
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/** Another session of the project counts as live while its stack was written this recently. */
|
|
401
|
+
export const OTHER_SESSION_MS = 15 * 60 * 1000;
|
|
402
|
+
const MAX_OTHER_SESSIONS = 6;
|
|
403
|
+
const MAX_OTHER_FILES = 24;
|
|
404
|
+
/** A finished start-work run stays on other sessions' views this long, then leaves. */
|
|
405
|
+
export const FINISHED_WORK_MS = 60_000;
|
|
406
|
+
/** Running first, then idle, then the rest (paused, done, or silent). */
|
|
407
|
+
function otherRank(other) {
|
|
408
|
+
const top = other.frames.at(-1);
|
|
409
|
+
if (other.liveness === "idle")
|
|
410
|
+
return 1;
|
|
411
|
+
if (top?.done === true || top?.status === "paused")
|
|
412
|
+
return 2;
|
|
413
|
+
return other.liveness === "alive" || other.liveness === null ? 0 : 2;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* The stacks of the project's other sessions that moved within OTHER_SESSION_MS, or whose liveness record is
|
|
417
|
+
* still fresh, running first, then idle, then the rest, newest first within each. A start-work run that
|
|
418
|
+
* finished leaves after FINISHED_WORK_MS. It only reads: a link, an oversized or malformed file reads as
|
|
419
|
+
* empty, and an older session is simply dropped.
|
|
420
|
+
*/
|
|
421
|
+
export function readOtherStacks(cwd, selfId, now = Date.now()) {
|
|
422
|
+
try {
|
|
423
|
+
const own = normalizeSessionId(selfId);
|
|
424
|
+
if (!isAbsolute(cwd) || !plainDirs(cwd, STACK_DIR))
|
|
425
|
+
return [];
|
|
426
|
+
const lives = new Map(readSessionsLiveness(cwd, now)
|
|
427
|
+
.filter((record) => record.state !== "ended")
|
|
428
|
+
.map((record) => [normalizeSessionId(record.sessionId), record]));
|
|
429
|
+
const found = [];
|
|
430
|
+
const names = readdirSync(join(cwd, STACK_DIR))
|
|
431
|
+
.filter((name) => name.endsWith(".json"))
|
|
432
|
+
.sort()
|
|
433
|
+
.slice(0, MAX_OTHER_FILES);
|
|
434
|
+
for (const name of names) {
|
|
435
|
+
const id = name.slice(0, -".json".length);
|
|
436
|
+
if (normalizeSessionId(id) !== id || id === own)
|
|
437
|
+
continue;
|
|
438
|
+
const frames = readStack(cwd, id).frames;
|
|
439
|
+
const at = Math.max(0, ...frames.map((frame) => Date.parse(frame.at)));
|
|
440
|
+
const live = lives.get(id);
|
|
441
|
+
const top = frames.at(-1);
|
|
442
|
+
if (top === undefined || (now - at > OTHER_SESSION_MS && live === undefined))
|
|
443
|
+
continue;
|
|
444
|
+
if (top.skill === "start-work" && top.done === true && now - at > FINISHED_WORK_MS)
|
|
445
|
+
continue;
|
|
446
|
+
found.push({
|
|
447
|
+
id,
|
|
448
|
+
frames,
|
|
449
|
+
at: Math.max(at, live?.at ?? 0),
|
|
450
|
+
liveness: live === undefined ? null : live.state,
|
|
451
|
+
pane: live?.herdrPane ?? null,
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
return found
|
|
455
|
+
.sort((a, b) => otherRank(a) - otherRank(b) || b.at - a.at || a.id.localeCompare(b.id))
|
|
456
|
+
.slice(0, MAX_OTHER_SESSIONS);
|
|
457
|
+
}
|
|
458
|
+
catch {
|
|
459
|
+
return [];
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
// ── Reading a stack back ─────────────────────────────────────────────────────
|
|
463
|
+
/** The frame a bare `lit continue` should resume: the nearest spine below a side frame, else null. */
|
|
464
|
+
export function pausedSpine(stack) {
|
|
465
|
+
const top = stack.frames.at(-1);
|
|
466
|
+
if (!top || top.role !== "side")
|
|
467
|
+
return null;
|
|
468
|
+
const spine = stack.frames[lastIndexWhere(stack.frames, (frame) => frame.role === "spine")];
|
|
469
|
+
return spine && spine.status === "paused" ? spine : null;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* `[▉▉▉░░] 3/5` when both counts are real, otherwise null. A count with no total is never drawn as a
|
|
473
|
+
* placeholder gauge: callers say what is known in words (`frameNote`) instead.
|
|
474
|
+
*/
|
|
475
|
+
export function stackGauge(frame) {
|
|
476
|
+
const { n, total } = frame;
|
|
477
|
+
if (n === undefined || total === undefined || total <= 0)
|
|
478
|
+
return null;
|
|
479
|
+
return `${gaugeBar(Math.min(n, total), total)} ${n}/${total}`;
|
|
480
|
+
}
|
|
481
|
+
/** Up to ten cells; a larger total is scaled down so the bar never grows past ten. */
|
|
482
|
+
export function gaugeBar(done, total) {
|
|
483
|
+
const cells = Math.min(10, Math.max(1, total));
|
|
484
|
+
const filled = total <= 0 ? 0 : Math.min(cells, Math.round((done / total) * cells));
|
|
485
|
+
return `[${"▉".repeat(filled)}${"░".repeat(cells - filled)}]`;
|
|
486
|
+
}
|
|
487
|
+
/** What a frame knows when it has no real gauge, in words: `step 2`, or an empty string. */
|
|
488
|
+
export function frameNote(frame) {
|
|
489
|
+
return stackGauge(frame) === null && frame.n !== undefined ? `step ${frame.n}` : "";
|
|
490
|
+
}
|
|
491
|
+
/** One frame as a short label: `lit-loop WORK [▉▉░░░] 2/5`, or `lit-loop WORK step 2` without a total. */
|
|
492
|
+
export function frameLabel(frame) {
|
|
493
|
+
const name = frame.skill ?? frame.family ?? "work";
|
|
494
|
+
const stage = frame.stage ? ` ${frame.stage}` : "";
|
|
495
|
+
const counted = stackGauge(frame) ?? frameNote(frame);
|
|
496
|
+
return `${name}${stage}${counted === "" ? "" : ` ${counted}`}`;
|
|
497
|
+
}
|
|
498
|
+
/** `lit-loop ‖ > lit-brainstorm`: paused frames, then the running one after `>`; null for one frame or none. */
|
|
499
|
+
export function breadcrumb(stack) {
|
|
500
|
+
const frames = stack.frames;
|
|
501
|
+
if (frames.length < 2)
|
|
502
|
+
return null;
|
|
503
|
+
const names = frames.map((frame) => frame.skill ?? frame.family ?? "work");
|
|
504
|
+
const head = names.slice(0, -1).join(" ‖ ");
|
|
505
|
+
return `${head} ‖ > ${names.at(-1)}`;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* The stack as one card row: paused frames with their stage and gauge, then the running frame after `>`,
|
|
509
|
+
* then the way back. Null while there is a single frame or none, since the map already shows that.
|
|
510
|
+
*/
|
|
511
|
+
export function stackRow(stack) {
|
|
512
|
+
if (stack.frames.length < 2)
|
|
513
|
+
return null;
|
|
514
|
+
const labels = stack.frames.map((frame) => frameLabel(frame));
|
|
515
|
+
const running = labels.pop();
|
|
516
|
+
const paused = labels.join(" ‖ ");
|
|
517
|
+
return `⏸ ${paused} ‖ ▶ ${running} · back: lit continue`;
|
|
518
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litcodex/lit-loop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "LitCodex Lit-Loop runtime: durable repo-native multi-goal orchestration with embedded success criteria and observable evidence audit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": true,
|
package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { StoreOptions } from "./lifecycle-store.js";
|
|
2
2
|
import type { ReadonlyFileSystem } from "./types.js";
|
|
3
3
|
export declare function runStopHook(input: unknown, _legacyFs?: ReadonlyFileSystem): string;
|
|
4
|
+
export type BoundaryAnswer = "approve" | "deny";
|
|
5
|
+
/**
|
|
6
|
+
* The whole prompt `lit approve` / `lit 승인` or `lit deny` / `lit 거절`, case-sensitive, at most 512 bytes.
|
|
7
|
+
* Anything around it (a quote, a code fence, a leading word) is ordinary text and answers nothing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseBoundaryAnswer(prompt: string): BoundaryAnswer | null;
|
|
4
10
|
export declare function runUserPromptSubmitHook(input: unknown, options?: StoreOptions): string;
|
|
5
11
|
interface StartWorkRoute {
|
|
6
12
|
readonly selector: string | null;
|
|
@@ -37,9 +37,74 @@ export function runStopHook(input, _legacyFs) {
|
|
|
37
37
|
throw error;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The whole prompt `lit approve` / `lit 승인` or `lit deny` / `lit 거절`, case-sensitive, at most 512 bytes.
|
|
42
|
+
* Anything around it (a quote, a code fence, a leading word) is ordinary text and answers nothing.
|
|
43
|
+
*/
|
|
44
|
+
export function parseBoundaryAnswer(prompt) {
|
|
45
|
+
if (prompt.length > 512)
|
|
46
|
+
return null;
|
|
47
|
+
const match = prompt.trim().match(/^lit[ \t]+(approve|승인|deny|거절)$/u);
|
|
48
|
+
if (match === null)
|
|
49
|
+
return null;
|
|
50
|
+
return match[1] === "approve" || match[1] === "승인" ? "approve" : "deny";
|
|
51
|
+
}
|
|
52
|
+
function answerContext(text) {
|
|
53
|
+
return JSON.stringify({ hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: text } });
|
|
54
|
+
}
|
|
55
|
+
const NOTHING_WAITING = "The user typed a start-work boundary answer, but this session has no paused start-work run waiting at a boundary, so nothing changed. Tell the user that in one sentence.";
|
|
56
|
+
/**
|
|
57
|
+
* Typed answer to the boundary a paused start-work run waits at. `lit approve` resumes the run with a grant the
|
|
58
|
+
* hook derives from this turn, through the same transition as the exact resume line, so the stored authority
|
|
59
|
+
* still decides what the grant may cover. `lit deny` changes no state: the run stays paused and the model is told
|
|
60
|
+
* not to take that action. Both answer only this session's own paused run.
|
|
61
|
+
*/
|
|
62
|
+
function answerBoundary(input, answer, options) {
|
|
63
|
+
try {
|
|
64
|
+
reconcileLifecycleState(input.cwd, options);
|
|
65
|
+
const inspected = inspectLifecycleState(input.cwd);
|
|
66
|
+
if (!inspected.ok || inspected.state.active_work_id === null)
|
|
67
|
+
return answerContext(NOTHING_WAITING);
|
|
68
|
+
const work = selectWorkForSession(inspected.state, input.session_id, ["paused"]);
|
|
69
|
+
const pending = work?.pending_boundary;
|
|
70
|
+
if (work === null || pending === undefined)
|
|
71
|
+
return answerContext(NOTHING_WAITING);
|
|
72
|
+
const what = `boundary ${pending.boundary_id} (action ${pending.action}, root ${pending.root}) of work ${work.work_id}`;
|
|
73
|
+
if (answer === "deny") {
|
|
74
|
+
return answerContext(`The user typed \`lit deny\` for ${what}. Do not take that action or retry it. The run stays paused; ask what to do instead or replan inside the stored authority, and resume only after a new \`lit approve\`.`);
|
|
75
|
+
}
|
|
76
|
+
const key = digest([work.work_id, pending.boundary_id, input.session_id, input.turn_id].join("\0"));
|
|
77
|
+
transitionWork(input.cwd, {
|
|
78
|
+
action: "resume",
|
|
79
|
+
expectedRevision: inspected.state.revision,
|
|
80
|
+
sessionId: input.session_id,
|
|
81
|
+
transitionId: `prompt-approve:${key}`,
|
|
82
|
+
workId: work.work_id,
|
|
83
|
+
reasonCode: "explicit_user_resume",
|
|
84
|
+
turnId: input.turn_id,
|
|
85
|
+
boundary: pending,
|
|
86
|
+
grant: {
|
|
87
|
+
grant_id: `typed-approve:${key}`,
|
|
88
|
+
authority_id: pending.authority_id,
|
|
89
|
+
boundary_id: pending.boundary_id,
|
|
90
|
+
action: pending.action,
|
|
91
|
+
root: pending.root,
|
|
92
|
+
},
|
|
93
|
+
}, options);
|
|
94
|
+
return answerContext(`The user typed \`lit approve\` for ${what}. The run is active again with a grant for exactly that action and root. Continue the plan's next open task inside it, and ask again before anything beyond it.`);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (!(error instanceof Error))
|
|
98
|
+
throw error;
|
|
99
|
+
return answerContext("The user typed a start-work boundary answer, but the lifecycle store refused it, so the run is unchanged. Tell the user in one sentence and offer to show the run's state.");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
40
102
|
export function runUserPromptSubmitHook(input, options = {}) {
|
|
41
103
|
if (!isUserPromptSubmitInput(input))
|
|
42
104
|
return "";
|
|
105
|
+
const answer = parseBoundaryAnswer(input.prompt);
|
|
106
|
+
if (answer !== null)
|
|
107
|
+
return answerBoundary(input, answer, options);
|
|
43
108
|
const route = parseExplicitStartWorkPrompt(input.prompt);
|
|
44
109
|
if (route === null)
|
|
45
110
|
return "";
|