@litfamily/litcodex 1.0.27 → 1.0.29
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 +10 -10
- package/README.md +10 -10
- package/dist/cli.d.ts +3 -2
- package/dist/cli.js +73 -4
- package/dist/config-migration/cli.js +11 -3
- package/dist/install/generated-skill-payload-hashes.d.ts +58 -30
- package/dist/install/generated-skill-payload-hashes.js +58 -30
- package/dist/install/index.js +1 -1
- package/dist/install/motion-runtime.d.ts +4 -1
- package/dist/install/motion-runtime.js +15 -4
- package/dist/install/office-runtime.d.ts +10 -11
- package/dist/install/office-runtime.js +8 -3
- package/dist/install/skill-catalog.d.ts +1 -1
- package/dist/install/skill-catalog.js +1 -0
- package/dist/postinstall.js +16 -3
- package/dist/pty-helper.d.ts +7 -0
- package/dist/pty-helper.js +45 -0
- package/dist/run.d.ts +57 -0
- package/dist/run.js +354 -0
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
- package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.d.ts +12 -0
- package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.js +31 -2
- 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 +2 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directives/deep-interview.md +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-brainstorm.md +216 -0
- package/marketplace/plugins/litcodex/components/lit-loop/directives/litgoal.md +8 -1
- package/marketplace/plugins/litcodex/components/lit-loop/directives/review-work.md +12 -4
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.d.ts +8 -3
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.js +11 -6
- package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.d.ts +6 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +16 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/guards.d.ts +3 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/guards.js +5 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +53 -17
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hud-cli.d.ts +38 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hud-cli.js +155 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.d.ts +42 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.js +297 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +9 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-route.js +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.js +8 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.d.ts +56 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.js +171 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/route-context.js +5 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +35 -15
- package/marketplace/plugins/litcodex/components/lit-loop/dist/run-filter.d.ts +23 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/run-filter.js +142 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/run-panel.d.ts +29 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/run-panel.js +102 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.d.ts +24 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.js +104 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-status.d.ts +24 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-status.js +110 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-mention-scope.js +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/statusline.d.ts +17 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/statusline.js +113 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.d.ts +2 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.js +15 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.d.ts +7 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +59 -10
- 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/bundled-rules/lit-humanizer.md +2 -0
- package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.d.ts +8 -0
- package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.js +381 -39
- package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.d.ts +16 -0
- package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.js +37 -1
- package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
- 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/skills/browser-drive/scripts/capability-probe.mjs +24 -4
- package/marketplace/plugins/litcodex/skills/deep-interview/SKILL.md +3 -1
- package/marketplace/plugins/litcodex/skills/lit-brainstorm/SKILL.md +271 -0
- package/marketplace/plugins/litcodex/skills/lit-brainstorm/agents/openai.yaml +6 -0
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/doctor.mjs +4 -3
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/export.mjs +6 -5
- package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/runtime-probes.mjs +25 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/scripts/convert_md_to_pdf.py +31 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/acs/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/elsevier/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/ieee/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/korean-generic/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/nature/template.tex +2 -0
- package/marketplace/plugins/litcodex/skills/lit-humanizer/SKILL.md +4 -0
- package/marketplace/plugins/litcodex/skills/lit-humanizer/scripts/core.mjs +5 -1
- package/marketplace/plugins/litcodex/skills/lit-loop/SKILL.md +10 -2
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/office-run.mjs +42 -10
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/SKILL.md +11 -9
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/agents/openai.yaml +3 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +4 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/constants.mjs +38 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-assets.mjs +113 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-capture.mjs +161 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-gate.mjs +327 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-image.mjs +136 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-init.js +43 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-sheet.mjs +69 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-treatment.mjs +102 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-worker.mjs +21 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover.mjs +352 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/driver.mjs +19 -1
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/fonts.mjs +11 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/look.mjs +128 -2
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/loop-kit.js +104 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/runtime.mjs +92 -18
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage.mjs +2 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/treatment.mjs +3 -2
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/webp.mjs +140 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/fonts/jetbrains-mono/JetBrainsMono-wght-latin.woff2 +0 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/fonts/jetbrains-mono/OFL.txt +93 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/card-scenes/expected.json +16 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/card-scenes/index.html +42 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/reset-sweep/expected.json +16 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/reset-sweep/index.html +27 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/still-glow/expected.json +17 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/still-glow/index.html +29 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/title-slam/expected.json +17 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/title-slam/index.html +44 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +67 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/orbit-loop/index.html +182 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/painted-light/expected.json +95 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/painted-light/index.html +231 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/weight-tide/expected.json +67 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/weight-tide/index.html +103 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/cover.md +389 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/quality-gate.md +4 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/runtime.md +7 -6
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/stage.md +3 -1
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/treatment.md +2 -0
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/render.mjs +37 -5
- package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/runtime.mjs +1 -1
- package/marketplace/plugins/litcodex/skills/litgoal/SKILL.md +8 -3
- package/marketplace/plugins/litcodex/skills/lsp-setup/scripts/verify-lsp.ts +43 -7
- package/marketplace/plugins/litcodex/skills/review-work/SKILL.md +21 -4
- package/node_modules/@litcodex/lit-loop/CHANGELOG.md +7 -0
- package/node_modules/@litcodex/lit-loop/README.md +6 -0
- package/node_modules/@litcodex/lit-loop/directive.md +2 -1
- package/node_modules/@litcodex/lit-loop/directives/deep-interview.md +2 -0
- package/node_modules/@litcodex/lit-loop/directives/lit-brainstorm.md +216 -0
- package/node_modules/@litcodex/lit-loop/directives/litgoal.md +8 -1
- package/node_modules/@litcodex/lit-loop/directives/review-work.md +12 -4
- package/node_modules/@litcodex/lit-loop/dist/card-status.d.ts +8 -3
- package/node_modules/@litcodex/lit-loop/dist/card-status.js +11 -6
- package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +6 -1
- package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +16 -5
- package/node_modules/@litcodex/lit-loop/dist/guards.d.ts +3 -1
- package/node_modules/@litcodex/lit-loop/dist/guards.js +5 -2
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +53 -17
- package/node_modules/@litcodex/lit-loop/dist/hud-cli.d.ts +38 -0
- package/node_modules/@litcodex/lit-loop/dist/hud-cli.js +155 -0
- package/node_modules/@litcodex/lit-loop/dist/hud.d.ts +42 -0
- package/node_modules/@litcodex/lit-loop/dist/hud.js +297 -0
- package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/markers.js +2 -0
- package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/modes.js +9 -1
- package/node_modules/@litcodex/lit-loop/dist/motion-route.js +2 -0
- package/node_modules/@litcodex/lit-loop/dist/plan-persistence.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/plan-persistence.js +8 -0
- package/node_modules/@litcodex/lit-loop/dist/reentry.d.ts +56 -0
- package/node_modules/@litcodex/lit-loop/dist/reentry.js +171 -0
- package/node_modules/@litcodex/lit-loop/dist/route-context.js +5 -2
- package/node_modules/@litcodex/lit-loop/dist/route-heads.js +35 -15
- package/node_modules/@litcodex/lit-loop/dist/run-filter.d.ts +23 -0
- package/node_modules/@litcodex/lit-loop/dist/run-filter.js +142 -0
- package/node_modules/@litcodex/lit-loop/dist/run-panel.d.ts +29 -0
- package/node_modules/@litcodex/lit-loop/dist/run-panel.js +102 -0
- package/node_modules/@litcodex/lit-loop/dist/screen-card.d.ts +24 -0
- package/node_modules/@litcodex/lit-loop/dist/screen-card.js +104 -0
- package/node_modules/@litcodex/lit-loop/dist/screen-status.d.ts +24 -0
- package/node_modules/@litcodex/lit-loop/dist/screen-status.js +110 -0
- package/node_modules/@litcodex/lit-loop/dist/skill-mention-scope.js +2 -0
- package/node_modules/@litcodex/lit-loop/dist/statusline.d.ts +17 -0
- package/node_modules/@litcodex/lit-loop/dist/statusline.js +113 -0
- package/node_modules/@litcodex/lit-loop/dist/trigger.d.ts +2 -2
- package/node_modules/@litcodex/lit-loop/dist/trigger.js +15 -5
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +7 -0
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +59 -10
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/node_modules/@litcodex/lit-loop/skills/browser-drive/scripts/capability-probe.mjs +24 -4
- package/node_modules/@litcodex/lit-loop/skills/deep-interview/SKILL.md +3 -1
- package/node_modules/@litcodex/lit-loop/skills/lit-brainstorm/SKILL.md +271 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-humanizer/SKILL.md +4 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-humanizer/scripts/core.mjs +5 -1
- package/node_modules/@litcodex/lit-loop/skills/lit-loop/SKILL.md +10 -2
- package/node_modules/@litcodex/lit-loop/skills/litgoal/SKILL.md +8 -3
- package/node_modules/@litcodex/lit-loop/skills/review-work/SKILL.md +21 -4
- package/package.json +5 -2
- package/readme-assets/badge-version.svg +1 -1
- package/readme-assets/cover-motion-still.webp +0 -0
- package/readme-assets/cover-motion.webp +0 -0
- package/readme-assets/cover.webp +0 -0
- package/readme-assets/litfamily-machines.png +0 -0
- package/readme-assets/skills/lit-brainstorm.webp +0 -0
|
@@ -12,8 +12,11 @@ import { claimReloadContext, evaluateAutoHandoffStop, recordCompaction, takeRelo
|
|
|
12
12
|
import { applyAutoHandoffRoute, clearManagedCompactionWhenOff, parseAutoHandoffRoute, } from "./auto-handoff-settings.js";
|
|
13
13
|
import { applyPreToolUseCreateGoalGuard, isLitUserPromptSubmitInput, runUserPromptSubmitHook } from "./codex-hook.js";
|
|
14
14
|
import { endLiveStep, recordLiveStepEnd, recordLiveStepStart, recordTurnStart, writeThreadPointer, } from "./live-step.js";
|
|
15
|
-
import { evaluatePlanPersistence, formatStopBlockOutput, recordLitPlanActivation } from "./plan-persistence.js";
|
|
16
|
-
import {
|
|
15
|
+
import { evaluatePlanPersistence, formatStopBlockOutput, rearmLitPlanIfSatisfied, recordLitPlanActivation, } from "./plan-persistence.js";
|
|
16
|
+
import { clearActiveRoute, isBareLit, readActiveRoute, readResumeWork, recordActiveRoute } from "./reentry.js";
|
|
17
|
+
import { workflowCard } from "./screen-card.js";
|
|
18
|
+
import { screenColor } from "./screen-status.js";
|
|
19
|
+
import { recordWorkflowTurn, workflowStopLine, workflowTurn } from "./workflow-map.js";
|
|
17
20
|
/** Hard cap on stdin to bound memory / ReDoS exposure inside the 5 s Codex hook budget. 8 MB. */
|
|
18
21
|
export const MAX_STDIN_BYTES = 8_000_000;
|
|
19
22
|
const INVALID_JSON_MESSAGE = "lit hook: stdin was not valid JSON";
|
|
@@ -100,19 +103,31 @@ export async function runUserPromptSubmitHookCli(stdin, stdout, stderr, repoRoot
|
|
|
100
103
|
}
|
|
101
104
|
clearManagedCompactionWhenOff(hookCwd(parsed, repoRoot), auto.env ?? process.env);
|
|
102
105
|
const pointer = hookSessionScope(parsed, repoRoot);
|
|
103
|
-
const decision = runUserPromptSubmitHook(parsed)
|
|
106
|
+
const decision = runUserPromptSubmitHook(parsed, () => ({
|
|
107
|
+
active: pointer === null ? null : readActiveRoute(pointer.cwd, pointer.sessionId),
|
|
108
|
+
resume: pointer === null ? null : readResumeWork(pointer.cwd, pointer.sessionId),
|
|
109
|
+
}));
|
|
110
|
+
if (pointer !== null && decision.kind === "inject")
|
|
111
|
+
recordActiveRoute(pointer.cwd, pointer.sessionId, decision.mode);
|
|
104
112
|
// Only a LIT thread gets a pointer: this prompt ignites LIT, or an earlier one already did.
|
|
105
113
|
if (pointer !== null && (decision.kind === "inject" || workflowTurn(pointer.cwd, pointer.sessionId) !== null)) {
|
|
106
114
|
writeThreadPointer(auto.env ?? process.env, pointer.sessionId, pointer.cwd, auto.now);
|
|
107
115
|
recordTurnStart(pointer.cwd, pointer.sessionId, auto.now);
|
|
108
116
|
}
|
|
117
|
+
// A continued lit-plan keeps its persistence gate as it is. A fresh activation arms it again, and so does an
|
|
118
|
+
// explicit `lit plan …` once the previous plan was saved (a bare `lit` carries on and never re-arms).
|
|
109
119
|
if (decision.kind === "inject" && decision.mode === "lit-plan") {
|
|
110
120
|
const scope = hookSessionScope(parsed, repoRoot);
|
|
111
|
-
if (scope !== null)
|
|
112
|
-
|
|
121
|
+
if (scope !== null) {
|
|
122
|
+
if (decision.entry !== "continue")
|
|
123
|
+
recordLitPlanActivation(scope.cwd, scope.sessionId);
|
|
124
|
+
else if (isLitUserPromptSubmitInput(parsed) && !isBareLit(parsed.prompt))
|
|
125
|
+
rearmLitPlanIfSatisfied(scope.cwd, scope.sessionId);
|
|
126
|
+
}
|
|
113
127
|
}
|
|
128
|
+
const env = auto.env ?? process.env;
|
|
114
129
|
const own = decision.kind === "inject"
|
|
115
|
-
? withCardOffer(withWorkflowMap(decision.stdout, parsed, decision.mode), pointer, auto)
|
|
130
|
+
? withCardOffer(withWorkflowMap(decision.stdout, parsed, decision.mode, env), pointer, auto, decision.entry === "continue")
|
|
116
131
|
: "";
|
|
117
132
|
const output = withAutoHandoffReload(own, parsed, repoRoot, auto);
|
|
118
133
|
if (output !== "")
|
|
@@ -172,10 +187,11 @@ function withReloadContext(stdout, reload) {
|
|
|
172
187
|
}
|
|
173
188
|
}
|
|
174
189
|
/**
|
|
175
|
-
* Add the
|
|
176
|
-
* event that names its own absolute `cwd` is mapped, so the
|
|
190
|
+
* Add the LIT card (map and checklist) under the activation banner and remember the turn for the Stop
|
|
191
|
+
* card. Only an event that names its own absolute `cwd` is mapped, so the card always describes the
|
|
192
|
+
* session's repo.
|
|
177
193
|
*/
|
|
178
|
-
function withWorkflowMap(stdout, parsed, mode) {
|
|
194
|
+
function withWorkflowMap(stdout, parsed, mode, env) {
|
|
179
195
|
if (!isRecord(parsed) || typeof parsed["cwd"] !== "string" || !isAbsolute(parsed["cwd"]))
|
|
180
196
|
return stdout;
|
|
181
197
|
const cwd = parsed["cwd"];
|
|
@@ -184,13 +200,16 @@ function withWorkflowMap(stdout, parsed, mode) {
|
|
|
184
200
|
if (sessionId !== null && typeof parsed["turn_id"] === "string") {
|
|
185
201
|
recordWorkflowTurn(cwd, sessionId, parsed["turn_id"], mode);
|
|
186
202
|
}
|
|
187
|
-
const
|
|
188
|
-
|
|
203
|
+
const card = workflowCard(cwd, sessionId, mode, "turn started", {
|
|
204
|
+
color: screenColor(env),
|
|
205
|
+
quietWhenEmpty: true,
|
|
206
|
+
});
|
|
207
|
+
if (card === null)
|
|
189
208
|
return stdout;
|
|
190
209
|
const output = JSON.parse(stdout);
|
|
191
210
|
if (!isRecord(output) || typeof output["systemMessage"] !== "string")
|
|
192
211
|
return stdout;
|
|
193
|
-
output["systemMessage"] = `${output["systemMessage"]}\n${
|
|
212
|
+
output["systemMessage"] = `${output["systemMessage"]}\n${card}`;
|
|
194
213
|
return `${JSON.stringify(output)}\n`;
|
|
195
214
|
}
|
|
196
215
|
catch {
|
|
@@ -202,14 +221,17 @@ function withWorkflowMap(stdout, parsed, mode) {
|
|
|
202
221
|
* instead of scrolling away with the first one. In the terminal `codex` the same tool returns the map as text.
|
|
203
222
|
*/
|
|
204
223
|
export const CARD_OFFER_CONTEXT = "LIT card: if the `lit_card` tool (litcodex MCP server) is available, call the `lit_card` tool once now, with no arguments, so the user sees the live LIT card for this turn. It replaces the previous turn's card, which folds itself into one line. Do not call it again in this turn; it updates by itself.";
|
|
224
|
+
/** The card request for a continued discipline: the model already read the full one when it was activated. */
|
|
225
|
+
export const CARD_OFFER_CONTINUE_CONTEXT = "LIT card: if the `lit_card` tool is available, call it once now with no arguments; it updates by itself.";
|
|
205
226
|
/**
|
|
206
227
|
* Add the card request to every LIT activation, right under the banner line so it stays inside the part
|
|
207
228
|
* of the context Codex always shows, and remember when it was last made.
|
|
208
229
|
*/
|
|
209
|
-
function withCardOffer(stdout, scope, auto) {
|
|
230
|
+
function withCardOffer(stdout, scope, auto, continued = false) {
|
|
210
231
|
if (scope === null || stdout === "")
|
|
211
232
|
return stdout;
|
|
212
|
-
const
|
|
233
|
+
const offer = continued ? CARD_OFFER_CONTINUE_CONTEXT : CARD_OFFER_CONTEXT;
|
|
234
|
+
const merged = withContextAfterBanner(stdout, offer) ?? withReloadContext(stdout, offer);
|
|
213
235
|
if (merged === null)
|
|
214
236
|
return stdout;
|
|
215
237
|
writeThreadPointer(auto.env ?? process.env, scope.sessionId, scope.cwd, auto.now, { cardOffered: true });
|
|
@@ -237,6 +259,10 @@ function withContextAfterBanner(stdout, text) {
|
|
|
237
259
|
function isRecord(value) {
|
|
238
260
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
239
261
|
}
|
|
262
|
+
/** A subagent's hooks carry the root session id, so its Stop must not end the parent's turn card. */
|
|
263
|
+
function isSubagent(parsed) {
|
|
264
|
+
return isRecord(parsed) && typeof parsed["agent_id"] === "string" && parsed["agent_id"] !== "";
|
|
265
|
+
}
|
|
240
266
|
/** Absolute `cwd` from a hook event, else the fallback root. */
|
|
241
267
|
function hookCwd(parsed, repoRoot) {
|
|
242
268
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
@@ -299,15 +325,22 @@ export async function runStopPlanPersistenceHookCli(stdin, stdout, stderr, repoR
|
|
|
299
325
|
stdout.write(formatStopBlockOutput(handoff.reason));
|
|
300
326
|
return 0;
|
|
301
327
|
}
|
|
328
|
+
// A subagent's Stop carries the parent's session id; the parent's turn is still running.
|
|
329
|
+
if (isSubagent(parsed))
|
|
330
|
+
return 0;
|
|
302
331
|
endLiveStep(scope.cwd, scope.sessionId, auto.now);
|
|
332
|
+
const env = auto.env ?? process.env;
|
|
303
333
|
const line = typeof record["turn_id"] === "string"
|
|
304
334
|
? workflowStopLine(scope.cwd, scope.sessionId, record["turn_id"], {
|
|
305
335
|
stopHookActive: record["stop_hook_active"] === true,
|
|
306
336
|
transcriptPath: typeof record["transcript_path"] === "string" ? record["transcript_path"] : null,
|
|
307
337
|
})
|
|
308
338
|
: null;
|
|
309
|
-
|
|
310
|
-
|
|
339
|
+
const turn = line === null ? null : workflowTurn(scope.cwd, scope.sessionId);
|
|
340
|
+
const card = turn === null ? null : workflowCard(scope.cwd, scope.sessionId, turn.mode, line, { color: screenColor(env) });
|
|
341
|
+
// Codex puts a hook label before the first row, so the card starts on the next one.
|
|
342
|
+
if (card !== null)
|
|
343
|
+
stdout.write(`${JSON.stringify({ systemMessage: `\n${card}` })}\n`);
|
|
311
344
|
}
|
|
312
345
|
return 0;
|
|
313
346
|
}
|
|
@@ -356,8 +389,11 @@ export async function runPostCompactHookCli(stdin, _stdout, stderr, repoRoot = p
|
|
|
356
389
|
return event.exit;
|
|
357
390
|
clearManagedCompactionWhenOff(hookCwd(event.parsed, repoRoot), auto.env ?? process.env);
|
|
358
391
|
const scope = hookSessionScope(event.parsed, repoRoot);
|
|
359
|
-
if (scope !== null)
|
|
392
|
+
if (scope !== null) {
|
|
360
393
|
recordCompaction(scope.cwd, scope.sessionId);
|
|
394
|
+
// The activation text may be gone from the model's context, so the next lit prompt sends it in full.
|
|
395
|
+
clearActiveRoute(scope.cwd, scope.sessionId);
|
|
396
|
+
}
|
|
361
397
|
return 0;
|
|
362
398
|
}
|
|
363
399
|
export async function runPreToolUseCreateGoalGuardCli(stdin, stdout, stderr) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const HUD_HELP_TEXT = "litcodex hud [--session <id>] [--once]\n\nWatch the LIT card of your newest Codex session from a second terminal window or tab.\nIt reads only LIT's own records, never writes a file and never touches Codex. Ctrl-C quits.\n\nOptions:\n --session <id> Follow this session (an exact id or a unique prefix) instead of the newest.\n --once Print one plain frame and exit.\n --help Show this help.\n";
|
|
2
|
+
export interface HudOutput {
|
|
3
|
+
write(text: string): unknown;
|
|
4
|
+
readonly isTTY?: boolean;
|
|
5
|
+
readonly columns?: number | undefined;
|
|
6
|
+
on?(event: "error", listener: (error: unknown) => void): unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface HudLoopOptions {
|
|
9
|
+
readonly env: NodeJS.ProcessEnv;
|
|
10
|
+
readonly wanted: string | null;
|
|
11
|
+
readonly out: HudOutput;
|
|
12
|
+
readonly color: boolean;
|
|
13
|
+
readonly now: () => number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A frame writer: each `tick` reads and renders once, and writes only when the frame text changed or the
|
|
17
|
+
* terminal was resized. On a terminal the frame stays one column short of the edge, where a full line
|
|
18
|
+
* followed by erase-to-end would lose its last glyph or wrap.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createHudLoop(options: HudLoopOptions): {
|
|
21
|
+
tick(): boolean;
|
|
22
|
+
};
|
|
23
|
+
/** The process events the command listens to; a test passes its own emitter. */
|
|
24
|
+
interface HudSignals {
|
|
25
|
+
on(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
26
|
+
off(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface HudIo {
|
|
29
|
+
readonly stdout: HudOutput;
|
|
30
|
+
readonly stderr: {
|
|
31
|
+
write(text: string): unknown;
|
|
32
|
+
};
|
|
33
|
+
readonly env: NodeJS.ProcessEnv;
|
|
34
|
+
readonly signals?: HudSignals;
|
|
35
|
+
readonly now?: () => number;
|
|
36
|
+
}
|
|
37
|
+
export declare function hudCommand(args: readonly string[], io: HudIo): Promise<number>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/hud-cli.ts — `litcodex hud`: the LIT card, kept live in a second terminal window.
|
|
2
|
+
//
|
|
3
|
+
// One 1 s timer reads the small, size-capped LIT records (hud.ts), builds the frame and writes it only
|
|
4
|
+
// when its text changed; a running step changes it once a second through its clock. On a terminal the
|
|
5
|
+
// frame is drawn in place on the alternate screen with the cursor hidden, and both come back on every
|
|
6
|
+
// way out: a signal, an unexpected error or process exit. The command resolves its exit code and never
|
|
7
|
+
// calls `process.exit`; it writes no file, starts no process and opens no Codex rollout.
|
|
8
|
+
import { readHud, renderHud } from "./hud.js";
|
|
9
|
+
const TICK_MS = 1_000;
|
|
10
|
+
const DEFAULT_WIDTH = 80;
|
|
11
|
+
const ENTER_SCREEN = "\u001b[?1049h\u001b[?25l";
|
|
12
|
+
const LEAVE_SCREEN = "\u001b[?25h\u001b[?1049l";
|
|
13
|
+
const HOME = "\u001b[H";
|
|
14
|
+
const CLEAR_LINE = "\u001b[K";
|
|
15
|
+
const CLEAR_BELOW = "\u001b[J";
|
|
16
|
+
const USAGE_EXIT_CODE = 64;
|
|
17
|
+
const STOP_EVENTS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
18
|
+
export const HUD_HELP_TEXT = `litcodex hud [--session <id>] [--once]
|
|
19
|
+
|
|
20
|
+
Watch the LIT card of your newest Codex session from a second terminal window or tab.
|
|
21
|
+
It reads only LIT's own records, never writes a file and never touches Codex. Ctrl-C quits.
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
--session <id> Follow this session (an exact id or a unique prefix) instead of the newest.
|
|
25
|
+
--once Print one plain frame and exit.
|
|
26
|
+
--help Show this help.
|
|
27
|
+
`;
|
|
28
|
+
/**
|
|
29
|
+
* A frame writer: each `tick` reads and renders once, and writes only when the frame text changed or the
|
|
30
|
+
* terminal was resized. On a terminal the frame stays one column short of the edge, where a full line
|
|
31
|
+
* followed by erase-to-end would lose its last glyph or wrap.
|
|
32
|
+
*/
|
|
33
|
+
export function createHudLoop(options) {
|
|
34
|
+
let last = null;
|
|
35
|
+
let lastColumns;
|
|
36
|
+
return {
|
|
37
|
+
tick() {
|
|
38
|
+
const now = options.now();
|
|
39
|
+
const tty = options.out.isTTY === true;
|
|
40
|
+
const columns = options.out.columns;
|
|
41
|
+
if (columns !== lastColumns)
|
|
42
|
+
last = null;
|
|
43
|
+
lastColumns = columns;
|
|
44
|
+
const width = columns ?? DEFAULT_WIDTH;
|
|
45
|
+
const frame = renderHud(readHud(options.env, options.wanted, now), {
|
|
46
|
+
width: tty ? width - 1 : width,
|
|
47
|
+
color: options.color,
|
|
48
|
+
now,
|
|
49
|
+
});
|
|
50
|
+
if (frame === last)
|
|
51
|
+
return false;
|
|
52
|
+
last = frame;
|
|
53
|
+
options.out.write(tty ? `${HOME}${frame.split("\n").join(`${CLEAR_LINE}\n`)}${CLEAR_LINE}${CLEAR_BELOW}` : `${frame}\n`);
|
|
54
|
+
return true;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function parseArgs(args) {
|
|
59
|
+
let help = false;
|
|
60
|
+
let once = false;
|
|
61
|
+
let session = null;
|
|
62
|
+
for (let index = 0; index < args.length; index++) {
|
|
63
|
+
const arg = args[index];
|
|
64
|
+
if (arg === "--help" || arg === "-h")
|
|
65
|
+
help = true;
|
|
66
|
+
else if (arg === "--once")
|
|
67
|
+
once = true;
|
|
68
|
+
else if (arg === "--session") {
|
|
69
|
+
const value = args[index + 1];
|
|
70
|
+
if (value === undefined || value.startsWith("-") || value.trim() === "")
|
|
71
|
+
return "--session needs a session id";
|
|
72
|
+
session = value.trim();
|
|
73
|
+
index++;
|
|
74
|
+
}
|
|
75
|
+
else
|
|
76
|
+
return `unknown option "${arg}"`;
|
|
77
|
+
}
|
|
78
|
+
return { help, once, session };
|
|
79
|
+
}
|
|
80
|
+
function colorAllowed(env) {
|
|
81
|
+
const noColor = env["NO_COLOR"];
|
|
82
|
+
return noColor === undefined || noColor === "";
|
|
83
|
+
}
|
|
84
|
+
export async function hudCommand(args, io) {
|
|
85
|
+
const parsed = parseArgs(args);
|
|
86
|
+
if (typeof parsed === "string") {
|
|
87
|
+
io.stderr.write(`litcodex hud: ${parsed}.\n\n${HUD_HELP_TEXT}`);
|
|
88
|
+
return USAGE_EXIT_CODE;
|
|
89
|
+
}
|
|
90
|
+
if (parsed.help) {
|
|
91
|
+
io.stdout.write(HUD_HELP_TEXT);
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
const now = io.now ?? Date.now;
|
|
95
|
+
if (parsed.once) {
|
|
96
|
+
createHudLoop({ env: io.env, wanted: parsed.session, out: plain(io.stdout), color: false, now }).tick();
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
const tty = io.stdout.isTTY === true;
|
|
100
|
+
const loop = createHudLoop({
|
|
101
|
+
env: io.env,
|
|
102
|
+
wanted: parsed.session,
|
|
103
|
+
out: io.stdout,
|
|
104
|
+
color: tty && colorAllowed(io.env),
|
|
105
|
+
now,
|
|
106
|
+
});
|
|
107
|
+
const signals = io.signals ?? process;
|
|
108
|
+
// A write to a terminal that has gone away (SIGHUP) fails with EIO; it must not become a stack trace.
|
|
109
|
+
io.stdout.on?.("error", () => undefined);
|
|
110
|
+
return new Promise((resolve) => {
|
|
111
|
+
let restored = false;
|
|
112
|
+
let timer;
|
|
113
|
+
const restore = () => {
|
|
114
|
+
if (restored)
|
|
115
|
+
return;
|
|
116
|
+
restored = true;
|
|
117
|
+
clearInterval(timer);
|
|
118
|
+
for (const event of STOP_EVENTS)
|
|
119
|
+
signals.off(event, stop);
|
|
120
|
+
signals.off("uncaughtException", crash);
|
|
121
|
+
signals.off("exit", restore);
|
|
122
|
+
if (tty)
|
|
123
|
+
io.stdout.write(LEAVE_SCREEN);
|
|
124
|
+
};
|
|
125
|
+
const stop = () => {
|
|
126
|
+
restore();
|
|
127
|
+
resolve(0);
|
|
128
|
+
};
|
|
129
|
+
const crash = (error) => {
|
|
130
|
+
restore();
|
|
131
|
+
io.stderr.write(`litcodex hud: stopped: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
132
|
+
resolve(1);
|
|
133
|
+
};
|
|
134
|
+
for (const event of STOP_EVENTS)
|
|
135
|
+
signals.on(event, stop);
|
|
136
|
+
signals.on("uncaughtException", crash);
|
|
137
|
+
signals.on("exit", restore);
|
|
138
|
+
if (tty)
|
|
139
|
+
io.stdout.write(ENTER_SCREEN);
|
|
140
|
+
const tick = () => {
|
|
141
|
+
try {
|
|
142
|
+
loop.tick();
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
crash(error);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
timer = setInterval(tick, TICK_MS);
|
|
149
|
+
tick();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/** The stream as a plain, non-terminal writer: one frame, no cursor moves. */
|
|
153
|
+
function plain(out) {
|
|
154
|
+
return { write: (text) => out.write(text), columns: out.isTTY === true ? out.columns : DEFAULT_WIDTH };
|
|
155
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type CardStatus } from "./card-status.js";
|
|
2
|
+
export interface HudSession {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
readonly updatedAt: number;
|
|
6
|
+
/** The newest LIT activity: the pointer time or a time the live step or workflow record carries. */
|
|
7
|
+
readonly activeAt: number;
|
|
8
|
+
}
|
|
9
|
+
export interface HudView {
|
|
10
|
+
/** What `--session` asked for, or null to follow the newest session. */
|
|
11
|
+
readonly wanted: string | null;
|
|
12
|
+
readonly session: {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly folder: string;
|
|
15
|
+
readonly lastSeen: number;
|
|
16
|
+
} | null;
|
|
17
|
+
readonly status: CardStatus | null;
|
|
18
|
+
/** Records that exist but could not be read, named for the user. */
|
|
19
|
+
readonly unreadable: readonly string[];
|
|
20
|
+
/** How many sessions `wanted` matched when it named more than one. */
|
|
21
|
+
readonly matches?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface HudRenderOptions {
|
|
24
|
+
readonly width: number;
|
|
25
|
+
readonly color: boolean;
|
|
26
|
+
readonly now: number;
|
|
27
|
+
}
|
|
28
|
+
/** Every session with a readable pointer, newest LIT activity first. */
|
|
29
|
+
export declare function listSessions(env: NodeJS.ProcessEnv): HudSession[];
|
|
30
|
+
/** The most recently active session, or the one `wanted` names by exact id or unique prefix; else null. */
|
|
31
|
+
export declare function pickSession(env: NodeJS.ProcessEnv, wanted?: string | null): HudSession | null;
|
|
32
|
+
/** Everything one frame needs, read once. Never throws and never writes. */
|
|
33
|
+
export declare function readHud(env: NodeJS.ProcessEnv, wanted: string | null, now: number): HudView;
|
|
34
|
+
export declare function clean(text: string): string;
|
|
35
|
+
/** The card with every record-derived string stripped of control characters. */
|
|
36
|
+
export declare function cleanStatus(status: CardStatus): CardStatus;
|
|
37
|
+
/** Terminal cells a plain string takes: CJK and emoji take two, combining marks none. */
|
|
38
|
+
export declare function displayWidth(text: string): number;
|
|
39
|
+
/** The line cut to `width` terminal cells, ending in `…` when anything was cut. */
|
|
40
|
+
export declare function fit(line: string, width: number): string;
|
|
41
|
+
/** One frame as text: a header, the card, and at most one "cannot read" line. Pure. */
|
|
42
|
+
export declare function renderHud(view: HudView, options: HudRenderOptions): string;
|