@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ChecklistRow, type MapCell, type WorkflowMap } from "./workflow-map.js";
|
|
2
|
+
/** Codex indents hook rows by four cells; the card stays inside a common terminal width. */
|
|
3
|
+
export declare const DEFAULT_CARD_WIDTH = 96;
|
|
4
|
+
export interface ScreenCardInput {
|
|
5
|
+
readonly mode: string;
|
|
6
|
+
readonly note: string | null;
|
|
7
|
+
readonly map: WorkflowMap | null;
|
|
8
|
+
readonly checklist: readonly ChecklistRow[];
|
|
9
|
+
}
|
|
10
|
+
export interface ScreenCardOptions {
|
|
11
|
+
readonly color: boolean;
|
|
12
|
+
readonly width?: number;
|
|
13
|
+
}
|
|
14
|
+
/** One stage as the card, the `litcodex run` panel and the status line show it: the stage word always in capitals. */
|
|
15
|
+
export declare function stageText(item: MapCell): string;
|
|
16
|
+
/** The card rows joined by newlines, without the leading newline the caller adds for row one. */
|
|
17
|
+
export declare function renderScreenCard(input: ScreenCardInput, options: ScreenCardOptions): string;
|
|
18
|
+
/**
|
|
19
|
+
* The card for a session's saved state. With `quietWhenEmpty`, null when there is neither a map nor a
|
|
20
|
+
* checklist, since the route row alone would repeat the activation banner above it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function workflowCard(repoRoot: string, sessionId: string | null, mode: string, note: string | null, options: ScreenCardOptions & {
|
|
23
|
+
readonly quietWhenEmpty?: boolean;
|
|
24
|
+
}): string | null;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// src/screen-card.ts — the LIT card the hooks print inside the Codex screen.
|
|
2
|
+
//
|
|
3
|
+
// A few `┃` rows in a hook `systemMessage`: the route (`🔥 LIT · <mode>` and a short note), the stage map,
|
|
4
|
+
// then at most three checklist rows around the open task. The same rows come out as plain text (emoji and
|
|
5
|
+
// `┃` only) unless colour is asked for; the caller asks only when `screen-status` is on and
|
|
6
|
+
// NO_COLOR is unset, because only the terminal UI is known to draw the escapes. Record-derived text is
|
|
7
|
+
// stripped of control characters and every row is cut to the width given.
|
|
8
|
+
import { clean, displayWidth, fit } from "./hud.js";
|
|
9
|
+
import { progressBar, readChecklist, readWorkflowSignals, workflowMapCells, } from "./workflow-map.js";
|
|
10
|
+
const ACCENT = "\u001b[38;2;255;155;94m";
|
|
11
|
+
const GREEN = "\u001b[38;2;107;196;109m";
|
|
12
|
+
const BOLD = "\u001b[1m";
|
|
13
|
+
const DIM = "\u001b[2m";
|
|
14
|
+
const RESET = "\u001b[0m";
|
|
15
|
+
/** Codex indents hook rows by four cells; the card stays inside a common terminal width. */
|
|
16
|
+
export const DEFAULT_CARD_WIDTH = 96;
|
|
17
|
+
const MIN_CARD_WIDTH = 20;
|
|
18
|
+
const MAX_CHECKLIST = 3;
|
|
19
|
+
const seg = (text, style = "") => ({ text, style });
|
|
20
|
+
/** One stage as the card, the `litcodex run` panel and the status line show it: the stage word always in capitals. */
|
|
21
|
+
export function stageText(item) {
|
|
22
|
+
const word = item.word.toUpperCase();
|
|
23
|
+
const bar = item.progress === null
|
|
24
|
+
? ""
|
|
25
|
+
: ` ${progressBar(item.progress.done, item.progress.total)} ${item.progress.done}/${item.progress.total}`;
|
|
26
|
+
switch (item.state) {
|
|
27
|
+
case "pending":
|
|
28
|
+
return `${item.icon} ${word}`;
|
|
29
|
+
case "done":
|
|
30
|
+
return item.label === null ? `✓ ${word}` : `✓ ${clean(item.label)}`;
|
|
31
|
+
case "partial":
|
|
32
|
+
return `${item.icon} ${word}${bar}`;
|
|
33
|
+
case "current":
|
|
34
|
+
return `${item.icon} ${clean(item.label ?? word)}${bar}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function cellStyle(item) {
|
|
38
|
+
if (item.state === "done")
|
|
39
|
+
return GREEN;
|
|
40
|
+
if (item.state === "current")
|
|
41
|
+
return `${BOLD}${ACCENT}`;
|
|
42
|
+
return DIM;
|
|
43
|
+
}
|
|
44
|
+
function mapRow(map) {
|
|
45
|
+
const row = [];
|
|
46
|
+
map.cells.forEach((item, index) => {
|
|
47
|
+
if (index > 0)
|
|
48
|
+
row.push(seg(" › ", DIM));
|
|
49
|
+
row.push(seg(stageText(item), cellStyle(item)));
|
|
50
|
+
});
|
|
51
|
+
return row;
|
|
52
|
+
}
|
|
53
|
+
function checklistRow(item) {
|
|
54
|
+
const label = clean(item.label);
|
|
55
|
+
if (item.state === "done")
|
|
56
|
+
return [seg("✓", GREEN), seg(` ${label}`, DIM)];
|
|
57
|
+
if (item.state === "current")
|
|
58
|
+
return [seg("▸", ACCENT), seg(` ${label}`)];
|
|
59
|
+
return [seg(`· ${label}`, DIM)];
|
|
60
|
+
}
|
|
61
|
+
/** Cut a row of styled pieces to `width` cells; the cut piece ends in `…` and nothing follows it. */
|
|
62
|
+
function fitRow(row, width) {
|
|
63
|
+
const out = [];
|
|
64
|
+
let used = 0;
|
|
65
|
+
for (const piece of row) {
|
|
66
|
+
const size = displayWidth(piece.text);
|
|
67
|
+
if (used + size <= width) {
|
|
68
|
+
out.push(piece);
|
|
69
|
+
used += size;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
out.push({ text: fit(piece.text, width - used), style: piece.style });
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
function paint(row, color) {
|
|
78
|
+
return row.map(({ text, style }) => (color && style !== "" ? `${style}${text}${RESET}` : text)).join("");
|
|
79
|
+
}
|
|
80
|
+
/** The card rows joined by newlines, without the leading newline the caller adds for row one. */
|
|
81
|
+
export function renderScreenCard(input, options) {
|
|
82
|
+
const width = Math.max(MIN_CARD_WIDTH, Math.floor(options.width ?? DEFAULT_CARD_WIDTH));
|
|
83
|
+
const bar = seg("┃ ", ACCENT);
|
|
84
|
+
const route = [seg(`🔥 LIT · ${clean(input.mode)}`, `${BOLD}${ACCENT}`)];
|
|
85
|
+
if (input.note !== null && clean(input.note) !== "")
|
|
86
|
+
route.push(seg(` ${clean(input.note)}`, DIM));
|
|
87
|
+
const rows = [route];
|
|
88
|
+
if (input.map !== null && input.map.cells.length > 0)
|
|
89
|
+
rows.push(mapRow(input.map));
|
|
90
|
+
for (const item of input.checklist.slice(0, MAX_CHECKLIST))
|
|
91
|
+
rows.push(checklistRow(item));
|
|
92
|
+
return rows.map((row) => paint([bar, ...fitRow(row, width - displayWidth(bar.text))], options.color)).join("\n");
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The card for a session's saved state. With `quietWhenEmpty`, null when there is neither a map nor a
|
|
96
|
+
* checklist, since the route row alone would repeat the activation banner above it.
|
|
97
|
+
*/
|
|
98
|
+
export function workflowCard(repoRoot, sessionId, mode, note, options) {
|
|
99
|
+
const map = workflowMapCells(mode, readWorkflowSignals(repoRoot, sessionId));
|
|
100
|
+
const checklist = readChecklist(repoRoot, sessionId);
|
|
101
|
+
if (options.quietWhenEmpty === true && map === null && checklist.length === 0)
|
|
102
|
+
return null;
|
|
103
|
+
return renderScreenCard({ mode, note, map, checklist }, options);
|
|
104
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const SCREEN_STATUS_ENV = "LITCODEX_SCREEN_STATUS";
|
|
2
|
+
export interface ScreenStatusState {
|
|
3
|
+
/** The hook card is coloured (NO_COLOR is applied by `screenColor`). */
|
|
4
|
+
readonly enabled: boolean;
|
|
5
|
+
readonly source: "default" | "command" | "environment";
|
|
6
|
+
readonly warnings: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const SCREEN_STATUS_HELP_TEXT = "litcodex screen-status on|off|status\n\nColour the LIT card the hooks print inside Codex. Off by default.\nOnly the terminal `codex` draws the colour:\nthe Codex desktop app and IDE extensions show the colour codes as raw text,\nso turn it on only if you use the terminal `codex`. Without colour the card has the same rows.\nThe setting is stored in $CODEX_HOME/litcodex/screen-status.json; LITCODEX_SCREEN_STATUS=1 or 0 overrides it.\nNO_COLOR keeps the card plain.\n";
|
|
9
|
+
/** The stored choice and the environment override; a missing, corrupt or linked file reads as off. */
|
|
10
|
+
export declare function readScreenStatus(env: NodeJS.ProcessEnv): ScreenStatusState;
|
|
11
|
+
/** True when the hooks may colour the card: the switch is on and NO_COLOR is unset or empty. */
|
|
12
|
+
export declare function screenColor(env: NodeJS.ProcessEnv): boolean;
|
|
13
|
+
export declare function writeScreenStatus(env: NodeJS.ProcessEnv, enabled: boolean): boolean;
|
|
14
|
+
export interface ScreenStatusIo {
|
|
15
|
+
readonly env: NodeJS.ProcessEnv;
|
|
16
|
+
readonly stdout: {
|
|
17
|
+
write(text: string): unknown;
|
|
18
|
+
};
|
|
19
|
+
readonly stderr: {
|
|
20
|
+
write(text: string): unknown;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** `litcodex screen-status on|off|status`; resolves an exit code and never throws. */
|
|
24
|
+
export declare function screenStatusCommand(args: readonly string[], io: ScreenStatusIo): number;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// src/screen-status.ts — the user-level switch for the LIT card's colour.
|
|
2
|
+
//
|
|
3
|
+
// Off by default. `litcodex screen-status on` colours the LIT card the hooks print, `off` keeps it plain and
|
|
4
|
+
// `status` reports the state. The choice lives in `$CODEX_HOME/litcodex/screen-status.json` (else
|
|
5
|
+
// `~/.codex`), written atomically and never through a symlink; `LITCODEX_SCREEN_STATUS=1|0` overrides it.
|
|
6
|
+
// Codex 0.162.0 and later draw ANSI colour inside hook text in the terminal UI, but the desktop app and IDE
|
|
7
|
+
// show the escape codes as raw text, and the hook input does not say which client is attached, hence the
|
|
8
|
+
// switch. NO_COLOR keeps the card plain either way; without colour the card has the same rows.
|
|
9
|
+
import { lstatSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { writeSmallFile } from "./auto-handoff-settings.js";
|
|
12
|
+
import { codexHomeFrom, readSmallJson } from "./live-step.js";
|
|
13
|
+
export const SCREEN_STATUS_ENV = "LITCODEX_SCREEN_STATUS";
|
|
14
|
+
const SETTINGS_DIR = "litcodex";
|
|
15
|
+
const SETTINGS_FILE = "screen-status.json";
|
|
16
|
+
const MAX_SETTINGS_BYTES = 4_096;
|
|
17
|
+
const USAGE_EXIT_CODE = 64;
|
|
18
|
+
export const SCREEN_STATUS_HELP_TEXT = `litcodex screen-status on|off|status
|
|
19
|
+
|
|
20
|
+
Colour the LIT card the hooks print inside Codex. Off by default.
|
|
21
|
+
Only the terminal \`codex\` draws the colour:
|
|
22
|
+
the Codex desktop app and IDE extensions show the colour codes as raw text,
|
|
23
|
+
so turn it on only if you use the terminal \`codex\`. Without colour the card has the same rows.
|
|
24
|
+
The setting is stored in $CODEX_HOME/litcodex/screen-status.json; ${SCREEN_STATUS_ENV}=1 or 0 overrides it.
|
|
25
|
+
NO_COLOR keeps the card plain.
|
|
26
|
+
`;
|
|
27
|
+
function settingsPath(env) {
|
|
28
|
+
const home = codexHomeFrom(env);
|
|
29
|
+
return home === null ? null : { home, path: join(home, SETTINGS_DIR, SETTINGS_FILE) };
|
|
30
|
+
}
|
|
31
|
+
function isRecord(value) {
|
|
32
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
/** True when something sits at `path`, readable or not. */
|
|
35
|
+
function present(path) {
|
|
36
|
+
try {
|
|
37
|
+
return lstatSync(path, { throwIfNoEntry: false }) !== undefined;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The stored choice and the environment override; a missing, corrupt or linked file reads as off. */
|
|
44
|
+
export function readScreenStatus(env) {
|
|
45
|
+
const warnings = [];
|
|
46
|
+
const flag = env[SCREEN_STATUS_ENV]?.trim() ?? "";
|
|
47
|
+
if (flag === "1" || flag === "0")
|
|
48
|
+
return { enabled: flag === "1", source: "environment", warnings };
|
|
49
|
+
if (flag !== "")
|
|
50
|
+
warnings.push(`${SCREEN_STATUS_ENV} is not 1 or 0 and was ignored.`);
|
|
51
|
+
const settings = settingsPath(env);
|
|
52
|
+
if (settings === null)
|
|
53
|
+
return { enabled: false, source: "default", warnings };
|
|
54
|
+
const stored = readSmallJson(settings.path, MAX_SETTINGS_BYTES);
|
|
55
|
+
if (!isRecord(stored)) {
|
|
56
|
+
if (present(settings.path))
|
|
57
|
+
warnings.push(`${SETTINGS_DIR}/${SETTINGS_FILE} could not be read, so the card stays plain.`);
|
|
58
|
+
return { enabled: false, source: "default", warnings };
|
|
59
|
+
}
|
|
60
|
+
const enabled = stored["enabled"] === true;
|
|
61
|
+
return { enabled, source: enabled ? "command" : "default", warnings };
|
|
62
|
+
}
|
|
63
|
+
/** True when the hooks may colour the card: the switch is on and NO_COLOR is unset or empty. */
|
|
64
|
+
export function screenColor(env) {
|
|
65
|
+
const noColor = env["NO_COLOR"];
|
|
66
|
+
return readScreenStatus(env).enabled && (noColor === undefined || noColor === "");
|
|
67
|
+
}
|
|
68
|
+
export function writeScreenStatus(env, enabled) {
|
|
69
|
+
const settings = settingsPath(env);
|
|
70
|
+
if (settings === null)
|
|
71
|
+
return false;
|
|
72
|
+
return writeSmallFile(settings.path, `${JSON.stringify({ version: 1, enabled })}\n`, settings.home);
|
|
73
|
+
}
|
|
74
|
+
function describe(state, noColor) {
|
|
75
|
+
const origin = state.source === "environment" ? ` (set by ${SCREEN_STATUS_ENV})` : "";
|
|
76
|
+
const value = state.enabled ? (noColor ? "ON, but NO_COLOR keeps it plain" : "ON") : "OFF";
|
|
77
|
+
const lines = [`LIT card colour is ${value}${origin}.`];
|
|
78
|
+
for (const warning of state.warnings)
|
|
79
|
+
lines.push(`Warning: ${warning}`);
|
|
80
|
+
return `${lines.join("\n")}\n`;
|
|
81
|
+
}
|
|
82
|
+
/** `litcodex screen-status on|off|status`; resolves an exit code and never throws. */
|
|
83
|
+
export function screenStatusCommand(args, io) {
|
|
84
|
+
const [verb, ...extra] = args;
|
|
85
|
+
if (verb === "--help" || verb === "-h") {
|
|
86
|
+
io.stdout.write(SCREEN_STATUS_HELP_TEXT);
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
if ((verb !== "on" && verb !== "off" && verb !== "status") || extra.length > 0) {
|
|
90
|
+
io.stderr.write("Usage: litcodex screen-status on|off|status\n");
|
|
91
|
+
return USAGE_EXIT_CODE;
|
|
92
|
+
}
|
|
93
|
+
if (verb === "status") {
|
|
94
|
+
const noColor = io.env["NO_COLOR"] !== undefined && io.env["NO_COLOR"] !== "";
|
|
95
|
+
io.stdout.write(describe(readScreenStatus(io.env), noColor));
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
if (!writeScreenStatus(io.env, verb === "on")) {
|
|
99
|
+
io.stderr.write("litcodex screen-status: the setting could not be saved, so nothing changed.\n");
|
|
100
|
+
return 1;
|
|
101
|
+
}
|
|
102
|
+
const overridden = readScreenStatus(io.env).source === "environment"
|
|
103
|
+
? ` ${SCREEN_STATUS_ENV} is set in the environment and takes priority over this setting.`
|
|
104
|
+
: "";
|
|
105
|
+
const note = verb === "on"
|
|
106
|
+
? " The Codex desktop app and IDE show colour codes as raw text; use it with the terminal `codex`."
|
|
107
|
+
: "";
|
|
108
|
+
io.stdout.write(`LIT card colour is ${verb === "on" ? "ON" : "OFF"}.${note}${overridden}\n`);
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CardStatus } from "./card-status.js";
|
|
2
|
+
export interface StatuslineIo {
|
|
3
|
+
readonly stdin: NodeJS.ReadableStream & {
|
|
4
|
+
readonly isTTY?: boolean;
|
|
5
|
+
};
|
|
6
|
+
readonly stdout: {
|
|
7
|
+
write(text: string): unknown;
|
|
8
|
+
};
|
|
9
|
+
readonly env: NodeJS.ProcessEnv;
|
|
10
|
+
readonly now?: () => number;
|
|
11
|
+
}
|
|
12
|
+
/** The one line, coloured on request and cut to `width` cells; "" when there is no LIT turn to show. */
|
|
13
|
+
export declare function statuslineText(status: CardStatus | null, options: {
|
|
14
|
+
width: number;
|
|
15
|
+
color: boolean;
|
|
16
|
+
}): string;
|
|
17
|
+
export declare function statuslineCommand(_args: readonly string[], io: StatuslineIo): Promise<number>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/statusline.ts — `litcodex statusline`: the LIT status as one line, for a host status line command.
|
|
2
|
+
//
|
|
3
|
+
// Codex 0.163.0 has no command-backed status line yet; this prints the line such a command would show, in
|
|
4
|
+
// the shape Claude-compatible status line hosts use: optional JSON on stdin naming `session_id` and `cwd`
|
|
5
|
+
// (or `workspace.current_dir`), one line on stdout, the width from `COLUMNS`. It picks that session's LIT
|
|
6
|
+
// records, else the newest LIT session in the same folder, else the newest LIT session, the way
|
|
7
|
+
// `litcodex hud` does (hud.ts), and reads the same card (card-status.ts) without opening a Codex rollout.
|
|
8
|
+
// Stdin is capped at 64 KiB and read for at most 200 ms. Nothing is written but the line; any problem
|
|
9
|
+
// prints an empty line, and the exit code is always 0.
|
|
10
|
+
import { clock } from "./card-status.js";
|
|
11
|
+
import { cleanStatus, fit, listSessions, readHud } from "./hud.js";
|
|
12
|
+
import { stageText } from "./screen-card.js";
|
|
13
|
+
const MAX_STDIN_BYTES = 64 * 1024;
|
|
14
|
+
const STDIN_BUDGET_MS = 200;
|
|
15
|
+
const DEFAULT_WIDTH = 120;
|
|
16
|
+
const ACCENT = "\u001b[38;2;255;155;94m";
|
|
17
|
+
const BOLD = "\u001b[1m";
|
|
18
|
+
const DIM = "\u001b[2m";
|
|
19
|
+
const RESET = "\u001b[0m";
|
|
20
|
+
const NO_INPUT = { sessionId: null, cwd: null };
|
|
21
|
+
/** Whatever arrives within the budget and the cap; null when the cap is passed. */
|
|
22
|
+
function readInput(stdin) {
|
|
23
|
+
if (stdin.isTTY === true)
|
|
24
|
+
return Promise.resolve("");
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const chunks = [];
|
|
27
|
+
let total = 0;
|
|
28
|
+
let settled = false;
|
|
29
|
+
const finish = (value) => {
|
|
30
|
+
if (settled)
|
|
31
|
+
return;
|
|
32
|
+
settled = true;
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
stdin.removeListener("data", onData);
|
|
35
|
+
stdin.pause();
|
|
36
|
+
resolve(value);
|
|
37
|
+
};
|
|
38
|
+
const onData = (chunk) => {
|
|
39
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
40
|
+
total += buffer.length;
|
|
41
|
+
if (total > MAX_STDIN_BYTES)
|
|
42
|
+
finish(null);
|
|
43
|
+
else
|
|
44
|
+
chunks.push(buffer);
|
|
45
|
+
};
|
|
46
|
+
const timer = setTimeout(() => finish(Buffer.concat(chunks).toString("utf8")), STDIN_BUDGET_MS);
|
|
47
|
+
stdin.on("data", onData);
|
|
48
|
+
stdin.once("end", () => finish(Buffer.concat(chunks).toString("utf8")));
|
|
49
|
+
stdin.once("error", () => finish(null));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function parseInput(raw) {
|
|
53
|
+
if (raw === null || raw.trim() === "")
|
|
54
|
+
return NO_INPUT;
|
|
55
|
+
try {
|
|
56
|
+
const value = JSON.parse(raw);
|
|
57
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
58
|
+
return NO_INPUT;
|
|
59
|
+
const record = value;
|
|
60
|
+
const workspace = record["workspace"];
|
|
61
|
+
const current = typeof workspace === "object" && workspace !== null
|
|
62
|
+
? workspace["current_dir"]
|
|
63
|
+
: undefined;
|
|
64
|
+
const cwd = typeof current === "string" ? current : typeof record["cwd"] === "string" ? record["cwd"] : null;
|
|
65
|
+
const sessionId = typeof record["session_id"] === "string" ? record["session_id"] : null;
|
|
66
|
+
return { sessionId: sessionId === "" ? null : sessionId, cwd: cwd === "" ? null : cwd };
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return NO_INPUT;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** The session the line is about: the named one when LIT knows it, else the newest one in `cwd`, else null (newest). */
|
|
73
|
+
function wantedSession(env, input) {
|
|
74
|
+
const sessions = listSessions(env);
|
|
75
|
+
if (input.sessionId !== null && sessions.some((session) => session.id === input.sessionId))
|
|
76
|
+
return input.sessionId;
|
|
77
|
+
return sessions.find((session) => input.cwd !== null && session.cwd === input.cwd)?.id ?? null;
|
|
78
|
+
}
|
|
79
|
+
/** The one line, coloured on request and cut to `width` cells; "" when there is no LIT turn to show. */
|
|
80
|
+
export function statuslineText(status, options) {
|
|
81
|
+
if (status === null || status.state === "ready")
|
|
82
|
+
return "";
|
|
83
|
+
const card = cleanStatus(status);
|
|
84
|
+
const route = `🔥 LIT · ${card.mode ?? "lit"}${card.state === "complete" ? " ✓" : ""}`;
|
|
85
|
+
const parts = [card.map === null ? null : card.map.cells.map(stageText).join(" › ")];
|
|
86
|
+
if (card.step !== null)
|
|
87
|
+
parts.push(`⠹ ${card.step.tool} ${clock(card.now - card.step.startedAt)}`);
|
|
88
|
+
const rest = parts.filter((part) => part !== null && part !== "").join(" ");
|
|
89
|
+
const line = fit(rest === "" ? route : `${route} ${rest}`, Math.max(10, options.width));
|
|
90
|
+
if (!options.color)
|
|
91
|
+
return line;
|
|
92
|
+
return line.startsWith(route)
|
|
93
|
+
? `${BOLD}${ACCENT}${route}${RESET}${DIM}${line.slice(route.length)}${RESET}`
|
|
94
|
+
: `${BOLD}${ACCENT}${line}${RESET}`;
|
|
95
|
+
}
|
|
96
|
+
export async function statuslineCommand(_args, io) {
|
|
97
|
+
try {
|
|
98
|
+
const input = parseInput(await readInput(io.stdin));
|
|
99
|
+
const now = (io.now ?? Date.now)();
|
|
100
|
+
const view = readHud(io.env, wantedSession(io.env, input), now);
|
|
101
|
+
const columns = Number.parseInt(io.env["COLUMNS"] ?? "", 10);
|
|
102
|
+
const noColor = io.env["NO_COLOR"];
|
|
103
|
+
const line = statuslineText(view.status, {
|
|
104
|
+
width: Number.isFinite(columns) && columns > 0 ? columns : DEFAULT_WIDTH,
|
|
105
|
+
color: noColor === undefined || noColor === "",
|
|
106
|
+
});
|
|
107
|
+
io.stdout.write(`${line}\n`);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
io.stdout.write("\n");
|
|
111
|
+
}
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The accepted bounded lit-family tokens, longest-first (ordering is load-bearing — see below). */
|
|
2
|
-
export type LitTriggerToken = "lit-comprehend" | "deep-interview" | "lit-crucible" | "lit-init" | "start-work" | "review-work" | "litresearch" | "lit-recap" | "lit-loop" | "lit-plan" | "litcodex" | "litgoal" | "litwork" | "lit";
|
|
2
|
+
export type LitTriggerToken = "lit-comprehend" | "lit-brainstorm" | "deep-interview" | "lit-crucible" | "lit-init" | "start-work" | "review-work" | "litresearch" | "lit-recap" | "lit-loop" | "lit-plan" | "litcodex" | "litgoal" | "litwork" | "lit";
|
|
3
3
|
/**
|
|
4
4
|
* Frozen tuple of the accepted tokens in match-priority (longest-first) order.
|
|
5
5
|
* Exported so tests and the mode router (modes.ts) can enumerate without re-deriving.
|
|
@@ -15,7 +15,7 @@ export declare const LIT_TRIGGER_TOKENS: readonly LitTriggerToken[];
|
|
|
15
15
|
*
|
|
16
16
|
* MUST NOT carry the /g or /y flag: a global regex retains `lastIndex` between calls and would
|
|
17
17
|
* make `.test()` return alternating results for the same input. Longest-first alternation
|
|
18
|
-
* (`lit-comprehend|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit`)
|
|
18
|
+
* (`lit-comprehend|lit-brainstorm|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit`)
|
|
19
19
|
* guarantees a longer family token wins over a bare `lit` at the same start; the trailing-`-`
|
|
20
20
|
* lookahead means `lit work` (space) is a bare `lit` while `litwork` (glued) is the work mode.
|
|
21
21
|
* The `litrecap` / `recap` / `리캡` alternatives are ROUTING ALIASES normalized to the canonical
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
// Explicit leading `start-work ...` routes execute with the installed skill body, while ordinary
|
|
7
7
|
// discussion stays inert and scoped mentions such as `$litcodex:start-work ...` stay native.
|
|
8
8
|
// Recap aliases (`litrecap` / `recap` / `리캡`) normalize to the single `lit-recap` token.
|
|
9
|
-
// The bare `comprehend` alias normalizes to the `lit-comprehend` token.
|
|
9
|
+
// The bare `comprehend` alias normalizes to the `lit-comprehend` token. `lit` followed by an ideation
|
|
10
|
+
// word (brainstorm, brainstorming, ideation, ideate, idea, ideas) routes to `lit-brainstorm`; those words
|
|
11
|
+
// never route without the `lit` in front. Rejects
|
|
10
12
|
// every substring collision (`split`, `literal`, `litmus`, `lithium`, `glitter`, `flit`, `slit`,
|
|
11
13
|
// `litter`, `recapture`, …) while respecting Korean (Hangul) and English boundaries.
|
|
12
14
|
//
|
|
@@ -22,6 +24,7 @@ import { renamedSkillId } from "./skill-renames.js";
|
|
|
22
24
|
*/
|
|
23
25
|
export const LIT_TRIGGER_TOKENS = Object.freeze([
|
|
24
26
|
"lit-comprehend",
|
|
27
|
+
"lit-brainstorm",
|
|
25
28
|
"deep-interview",
|
|
26
29
|
"lit-crucible",
|
|
27
30
|
"lit-init",
|
|
@@ -46,7 +49,7 @@ export const LIT_TRIGGER_TOKENS = Object.freeze([
|
|
|
46
49
|
*
|
|
47
50
|
* MUST NOT carry the /g or /y flag: a global regex retains `lastIndex` between calls and would
|
|
48
51
|
* make `.test()` return alternating results for the same input. Longest-first alternation
|
|
49
|
-
* (`lit-comprehend|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit`)
|
|
52
|
+
* (`lit-comprehend|lit-brainstorm|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit`)
|
|
50
53
|
* guarantees a longer family token wins over a bare `lit` at the same start; the trailing-`-`
|
|
51
54
|
* lookahead means `lit work` (space) is a bare `lit` while `litwork` (glued) is the work mode.
|
|
52
55
|
* The `litrecap` / `recap` / `리캡` alternatives are ROUTING ALIASES normalized to the canonical
|
|
@@ -54,7 +57,7 @@ export const LIT_TRIGGER_TOKENS = Object.freeze([
|
|
|
54
57
|
* (they are not members of the token union).
|
|
55
58
|
* No nested quantifiers / no backreferences ⇒ ReDoS-free.
|
|
56
59
|
*/
|
|
57
|
-
export const LIT_TRIGGER_PATTERN = /(?:^|[^\p{L}\p{N}_])(lit-comprehend|deep-interview|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit)(?![\p{L}\p{N}_-])/iu;
|
|
60
|
+
export const LIT_TRIGGER_PATTERN = /(?:^|[^\p{L}\p{N}_])(lit-comprehend|lit-brainstorm|deep-interview|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit)(?![\p{L}\p{N}_-])/iu;
|
|
58
61
|
const NOT_A_STRING = "lit trigger: prompt must be a string";
|
|
59
62
|
/**
|
|
60
63
|
* Returns true iff `prompt` contains at least one bounded lit trigger.
|
|
@@ -87,7 +90,7 @@ export function matchLitTrigger(prompt) {
|
|
|
87
90
|
return { token: "start-work", raw: explicitStartWork, index: 0 };
|
|
88
91
|
}
|
|
89
92
|
const searchable = maskMarkdownCode(prompt);
|
|
90
|
-
const scan = /(?:^|[^\p{L}\p{N}_])(lit-comprehend|deep-interview|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit)(?![\p{L}\p{N}_-])/giu;
|
|
93
|
+
const scan = /(?:^|[^\p{L}\p{N}_])(lit-comprehend|lit-brainstorm|deep-interview|lit-crucible|lit-init|hyperplan|init-deep|start-work|review-work|litresearch|comprehend|lit-recap|lit-loop|lit-plan|litcodex|litrecap|litgoal|litwork|recap|리캡|lit)(?![\p{L}\p{N}_-])/giu;
|
|
91
94
|
for (const m of searchable.matchAll(scan)) {
|
|
92
95
|
const raw = m[1];
|
|
93
96
|
if (raw === undefined) {
|
|
@@ -172,7 +175,7 @@ function explicitStartWorkPrefix(prompt) {
|
|
|
172
175
|
function naturalPhraseAfterLit(prompt, searchable, index, rawLength) {
|
|
173
176
|
const start = index + rawLength;
|
|
174
177
|
const rest = searchable.slice(start);
|
|
175
|
-
const m = /^(\s+)(start\s+work|deep\s+interview|lit-crucible|lit-init|hyperplan|init-deep|comprehend|plan|review|research|goal|recap)(?![\p{L}\p{N}_-])/iu.exec(rest);
|
|
178
|
+
const m = /^(\s+)(start\s+work|deep\s+interview|lit-brainstorm|lit-crucible|lit-init|hyperplan|init-deep|comprehend|brainstorming|brainstorm|ideation|ideate|ideas?|plan|review|research|goal|recap)(?![\p{L}\p{N}_-])/iu.exec(rest);
|
|
176
179
|
if (m === null || m[1] === undefined || m[2] === undefined) {
|
|
177
180
|
return null;
|
|
178
181
|
}
|
|
@@ -180,11 +183,18 @@ function naturalPhraseAfterLit(prompt, searchable, index, rawLength) {
|
|
|
180
183
|
const tokenByPhrase = {
|
|
181
184
|
"start work": "start-work",
|
|
182
185
|
"deep interview": "deep-interview",
|
|
186
|
+
"lit-brainstorm": "lit-brainstorm",
|
|
183
187
|
"lit-crucible": "lit-crucible",
|
|
184
188
|
hyperplan: "lit-crucible",
|
|
185
189
|
"lit-init": "lit-init",
|
|
186
190
|
"init-deep": "lit-init",
|
|
187
191
|
comprehend: "lit-comprehend",
|
|
192
|
+
brainstorming: "lit-brainstorm",
|
|
193
|
+
brainstorm: "lit-brainstorm",
|
|
194
|
+
ideation: "lit-brainstorm",
|
|
195
|
+
ideate: "lit-brainstorm",
|
|
196
|
+
idea: "lit-brainstorm",
|
|
197
|
+
ideas: "lit-brainstorm",
|
|
188
198
|
plan: "lit-plan",
|
|
189
199
|
review: "review-work",
|
|
190
200
|
research: "litresearch",
|
|
@@ -34,6 +34,13 @@ export declare function progressBar(done: number, total: number): string;
|
|
|
34
34
|
* with fewer than three words left before the cut is dropped.
|
|
35
35
|
*/
|
|
36
36
|
export declare function safeTitle(label: string): string | null;
|
|
37
|
+
/** One row of the card's checklist: a plan task or a lit-loop goal. */
|
|
38
|
+
export interface ChecklistRow {
|
|
39
|
+
readonly state: "done" | "current" | "pending";
|
|
40
|
+
readonly label: string;
|
|
41
|
+
}
|
|
42
|
+
/** The checklist under the map: the start-work plan rows, else this session's lit-loop goals; [] when neither. */
|
|
43
|
+
export declare function readChecklist(repoRoot: string, sessionId: string | null): ChecklistRow[];
|
|
37
44
|
export declare function readWorkflowSignals(repoRoot: string, sessionId: string | null, now?: number): WorkflowSignals;
|
|
38
45
|
/** One stage of the map, as the text line and the LIT card both draw it. */
|
|
39
46
|
export interface MapCell {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// src/workflow-map.ts — the
|
|
1
|
+
// src/workflow-map.ts — the LIT workflow map and the checklist under it.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// The map is plain text: emoji and block cells. Codex 0.162.0 and later draw ANSI colour inside a hook
|
|
4
|
+
// `systemMessage` in the terminal UI, but other clients may show escape codes literally, so colour is
|
|
5
|
+
// added only by the card (screen-card.ts) and only when the user turns it on. Everything here is built
|
|
6
|
+
// from saved state only: the start-work record and its plan checkboxes, lit-loop goals, the lit-plan
|
|
7
|
+
// activation record and the litresearch journal. A stage with no saved signal is left out rather than
|
|
8
|
+
// guessed. Every read fails open.
|
|
7
9
|
import { createHash } from "node:crypto";
|
|
8
10
|
import { lstatSync, mkdirSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
9
11
|
import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
@@ -19,6 +21,7 @@ const STAGES = [
|
|
|
19
21
|
/** Where each LIT skill sits in the main chain; `research` is its own short family. */
|
|
20
22
|
const MODE_STAGE = {
|
|
21
23
|
"deep-interview": "interview",
|
|
24
|
+
"lit-brainstorm": "interview",
|
|
22
25
|
"lit-crucible": "interview",
|
|
23
26
|
"lit-plan": "plan",
|
|
24
27
|
litgoal: "plan",
|
|
@@ -172,7 +175,8 @@ export function safeTitle(label) {
|
|
|
172
175
|
return `${title.slice(0, MAX_TITLE - 1)}…`;
|
|
173
176
|
return cut < 0 ? title : `${title} …`;
|
|
174
177
|
}
|
|
175
|
-
|
|
178
|
+
/** The start-work plan this session shows, with its status and text; null when there is none. */
|
|
179
|
+
function activeWorkPlan(repoRoot, sessionId) {
|
|
176
180
|
const state = readJson(repoRoot, join(repoRoot, ".litcodex/start-work/state.json"));
|
|
177
181
|
if (!isRecord(state) || !isRecord(state["works"]))
|
|
178
182
|
return null;
|
|
@@ -198,17 +202,28 @@ function readWork(repoRoot, sessionId) {
|
|
|
198
202
|
const text = readText(repoRoot, join(repoRoot, ".litcodex/plans", file));
|
|
199
203
|
if (text === null)
|
|
200
204
|
return null;
|
|
201
|
-
|
|
205
|
+
return { status: work["status"], text };
|
|
206
|
+
}
|
|
207
|
+
function readWork(repoRoot, sessionId) {
|
|
208
|
+
const plan = activeWorkPlan(repoRoot, sessionId);
|
|
209
|
+
if (plan === null)
|
|
210
|
+
return null;
|
|
211
|
+
const rows = countPlanRows(plan.text);
|
|
202
212
|
if (rows.total === 0)
|
|
203
213
|
return null;
|
|
204
|
-
return { ...rows, status:
|
|
214
|
+
return { ...rows, status: plan.status };
|
|
205
215
|
}
|
|
206
|
-
|
|
216
|
+
/** The goal records of one lit-loop goals file; null when it has none. */
|
|
217
|
+
function goalList(repoRoot, path) {
|
|
207
218
|
const plan = readJson(repoRoot, path);
|
|
208
219
|
if (!isRecord(plan) || !Array.isArray(plan["goals"]))
|
|
209
220
|
return null;
|
|
210
221
|
const goals = plan["goals"].filter(isRecord);
|
|
211
|
-
|
|
222
|
+
return goals.length === 0 ? null : goals;
|
|
223
|
+
}
|
|
224
|
+
function goalProgress(repoRoot, path) {
|
|
225
|
+
const goals = goalList(repoRoot, path);
|
|
226
|
+
if (goals === null)
|
|
212
227
|
return null;
|
|
213
228
|
const open = goals.find((goal) => goal["status"] === "in_progress") ?? goals.find((goal) => goal["status"] === "pending");
|
|
214
229
|
return {
|
|
@@ -226,6 +241,40 @@ function readGoals(repoRoot, sessionId) {
|
|
|
226
241
|
const shared = goalProgress(repoRoot, join(repoRoot, LIT_LOOP_DIR, LIT_LOOP_GOALS));
|
|
227
242
|
return shared !== null && shared.done < shared.total ? shared : null;
|
|
228
243
|
}
|
|
244
|
+
const MAX_CHECKLIST = 3;
|
|
245
|
+
/**
|
|
246
|
+
* At most three rows around the open one: the last finished row, the open row and the next one. With
|
|
247
|
+
* nothing open, the last three finished rows. A label cut down to nothing by `safeTitle` reads `#<n>`.
|
|
248
|
+
*/
|
|
249
|
+
function checklistWindow(items, current) {
|
|
250
|
+
const start = current < 0
|
|
251
|
+
? Math.max(0, items.length - MAX_CHECKLIST)
|
|
252
|
+
: Math.max(0, Math.min(current - 1, items.length - MAX_CHECKLIST));
|
|
253
|
+
return items.slice(start, start + MAX_CHECKLIST).map((item, offset) => ({
|
|
254
|
+
state: start + offset === current ? "current" : item.done ? "done" : "pending",
|
|
255
|
+
label: safeTitle(item.label) ?? `#${start + offset + 1}`,
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
/** The checklist under the map: the start-work plan rows, else this session's lit-loop goals; [] when neither. */
|
|
259
|
+
export function readChecklist(repoRoot, sessionId) {
|
|
260
|
+
if (typeof repoRoot !== "string" || !isAbsolute(repoRoot))
|
|
261
|
+
return [];
|
|
262
|
+
const id = normalizeSessionId(sessionId);
|
|
263
|
+
const plan = activeWorkPlan(repoRoot, id);
|
|
264
|
+
const rows = plan === null ? [] : planRows(plan.text);
|
|
265
|
+
if (rows.length > 0)
|
|
266
|
+
return checklistWindow(rows, rows.findIndex((row) => !row.done));
|
|
267
|
+
const scoped = id === null ? null : goalList(repoRoot, join(repoRoot, LIT_LOOP_DIR, id, LIT_LOOP_GOALS));
|
|
268
|
+
const goals = scoped ?? goalList(repoRoot, join(repoRoot, LIT_LOOP_DIR, LIT_LOOP_GOALS));
|
|
269
|
+
if (goals === null)
|
|
270
|
+
return [];
|
|
271
|
+
const items = goals.map((goal) => ({
|
|
272
|
+
done: goal["status"] === "complete",
|
|
273
|
+
label: typeof goal["title"] === "string" ? goal["title"] : "",
|
|
274
|
+
}));
|
|
275
|
+
const running = goals.findIndex((goal) => goal["status"] === "in_progress");
|
|
276
|
+
return checklistWindow(items, running >= 0 ? running : items.findIndex((item) => !item.done));
|
|
277
|
+
}
|
|
229
278
|
function readPlanRecord(repoRoot, sessionId) {
|
|
230
279
|
if (sessionId === null)
|
|
231
280
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litcodex/lit-loop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
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,
|