@litfamily/litcodex 1.0.27 → 1.0.28
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 +9 -9
- package/README.md +9 -9
- package/dist/cli.d.ts +3 -2
- package/dist/cli.js +72 -3
- package/dist/install/generated-skill-payload-hashes.d.ts +2 -2
- package/dist/install/generated-skill-payload-hashes.js +2 -2
- package/dist/postinstall.js +12 -1
- 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/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/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/hook-cli.js +28 -10
- 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/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/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/workflow-map.d.ts +7 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +58 -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/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/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 +2 -1
- 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/hook-cli.js +28 -10
- 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/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/statusline.d.ts +17 -0
- package/node_modules/@litcodex/lit-loop/dist/statusline.js +113 -0
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +7 -0
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +58 -10
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- 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 +2 -1
- package/package.json +5 -2
- package/readme-assets/badge-version.svg +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CardStatus } from "./card-status.js";
|
|
2
|
+
import { type ChecklistRow } from "./workflow-map.js";
|
|
3
|
+
/** Rows the panel takes below Codex. */
|
|
4
|
+
export declare const PANEL_ROWS = 4;
|
|
5
|
+
/** The panel needs room for its own rows and a usable Codex above them. */
|
|
6
|
+
export declare const MIN_RUN_ROWS = 12;
|
|
7
|
+
export declare const MIN_RUN_COLUMNS = 40;
|
|
8
|
+
export interface RunPanelView {
|
|
9
|
+
/** The session's card, or null while no LIT turn has run in this folder since the run started. */
|
|
10
|
+
readonly status: CardStatus | null;
|
|
11
|
+
/** The open checklist row, else the next one, else the last finished one; null when there is none. */
|
|
12
|
+
readonly checklist: ChecklistRow | null;
|
|
13
|
+
}
|
|
14
|
+
export interface RunPanelOptions {
|
|
15
|
+
readonly width: number;
|
|
16
|
+
readonly color: boolean;
|
|
17
|
+
readonly now: number;
|
|
18
|
+
}
|
|
19
|
+
/** What the panel shows now for a run started in `cwd` at `since`. Never throws and never writes. */
|
|
20
|
+
export declare function readRunPanel(env: NodeJS.ProcessEnv, cwd: string, since: number, now: number): RunPanelView;
|
|
21
|
+
/** Exactly `PANEL_ROWS` rows, each at most `width` cells. Pure. */
|
|
22
|
+
export declare function renderRunPanel(view: RunPanelView, options: RunPanelOptions): string[];
|
|
23
|
+
/** The escapes that draw `rows` below a child of `childRows` rows and put the cursor back where it was. */
|
|
24
|
+
export declare function panelFrame(rows: readonly string[], options: {
|
|
25
|
+
readonly childRows: number;
|
|
26
|
+
readonly cursorVisible: boolean;
|
|
27
|
+
}): string;
|
|
28
|
+
/** The escapes that give the whole screen back: no scroll region, empty panel rows, cursor below the child. */
|
|
29
|
+
export declare function panelClear(childRows: number): string;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/run-panel.ts — the LIT panel `litcodex run` draws in the rows below Codex.
|
|
2
|
+
//
|
|
3
|
+
// Four rows, the same `┃` card the hooks print (screen-card.ts): the route with the turn's clock, the
|
|
4
|
+
// stage map, the running step, and the open checklist row. The session is the newest one whose thread
|
|
5
|
+
// pointer names the folder `litcodex run` started in and whose LIT activity is newer than the run, read
|
|
6
|
+
// the way `litcodex hud` reads it (hud.ts) with `rollout: false`, so no Codex rollout is opened. Until
|
|
7
|
+
// then the panel says, dimmed, that it waits for a LIT turn. Record text is stripped of control
|
|
8
|
+
// characters and every row is cut to the width given. The escape strings that place the panel save and
|
|
9
|
+
// restore the cursor around it and leave Codex's own rows alone. Nothing here writes a file.
|
|
10
|
+
import { realpathSync } from "node:fs";
|
|
11
|
+
import { clock, readCardStatus } from "./card-status.js";
|
|
12
|
+
import { clean, cleanStatus, fit, listSessions } from "./hud.js";
|
|
13
|
+
import { renderScreenCard } from "./screen-card.js";
|
|
14
|
+
import { readChecklist } from "./workflow-map.js";
|
|
15
|
+
/** Rows the panel takes below Codex. */
|
|
16
|
+
export const PANEL_ROWS = 4;
|
|
17
|
+
/** The panel needs room for its own rows and a usable Codex above them. */
|
|
18
|
+
export const MIN_RUN_ROWS = 12;
|
|
19
|
+
export const MIN_RUN_COLUMNS = 40;
|
|
20
|
+
const ACCENT = "\u001b[38;2;255;155;94m";
|
|
21
|
+
const DIM = "\u001b[2m";
|
|
22
|
+
const RESET = "\u001b[0m";
|
|
23
|
+
const MIN_WIDTH = 20;
|
|
24
|
+
const WAITING = { status: null, checklist: null };
|
|
25
|
+
function realOrSame(path) {
|
|
26
|
+
try {
|
|
27
|
+
return realpathSync(path);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** What the panel shows now for a run started in `cwd` at `since`. Never throws and never writes. */
|
|
34
|
+
export function readRunPanel(env, cwd, since, now) {
|
|
35
|
+
try {
|
|
36
|
+
const real = realOrSame(cwd);
|
|
37
|
+
const session = listSessions(env).find((candidate) => (candidate.cwd === cwd || candidate.cwd === real) && candidate.activeAt >= since);
|
|
38
|
+
if (session === undefined)
|
|
39
|
+
return WAITING;
|
|
40
|
+
const status = readCardStatus(session.id, env, now, { rollout: false });
|
|
41
|
+
if (status.state === "ready")
|
|
42
|
+
return WAITING;
|
|
43
|
+
const rows = readChecklist(session.cwd, session.id);
|
|
44
|
+
const checklist = rows.find((row) => row.state === "current") ??
|
|
45
|
+
rows.find((row) => row.state === "pending") ??
|
|
46
|
+
rows.at(-1) ??
|
|
47
|
+
null;
|
|
48
|
+
return { status: cleanStatus(status), checklist };
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return WAITING;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function stepText(status, now) {
|
|
55
|
+
if (status.step !== null)
|
|
56
|
+
return { text: `⠹ ${clean(status.step.tool)} · ${clock(now - status.step.startedAt)}`, live: true };
|
|
57
|
+
if (status.working)
|
|
58
|
+
return { text: "⠹ thinking", live: true };
|
|
59
|
+
if (status.state === "complete")
|
|
60
|
+
return { text: "✓ turn done", live: false };
|
|
61
|
+
return { text: "· waiting for your next prompt", live: false };
|
|
62
|
+
}
|
|
63
|
+
/** Exactly `PANEL_ROWS` rows, each at most `width` cells. Pure. */
|
|
64
|
+
export function renderRunPanel(view, options) {
|
|
65
|
+
const width = Math.max(MIN_WIDTH, Math.floor(options.width));
|
|
66
|
+
const status = view.status;
|
|
67
|
+
if (status === null) {
|
|
68
|
+
const rows = ["┃ 🔥 LIT · waiting for a LIT turn", "┃ Type `lit <task>` in Codex to start one.", "", ""];
|
|
69
|
+
return rows.map((row) => {
|
|
70
|
+
const line = fit(row, width);
|
|
71
|
+
return options.color && line !== "" ? `${DIM}${line}${RESET}` : line;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const started = status.turnStartedAt ?? status.ignitedAt ?? options.now;
|
|
75
|
+
const elapsed = clock((status.turnEndedAt ?? options.now) - started);
|
|
76
|
+
const hasMap = status.map !== null && status.map.cells.length > 0;
|
|
77
|
+
const card = renderScreenCard({
|
|
78
|
+
mode: status.mode ?? "lit",
|
|
79
|
+
note: status.state === "complete" ? `✓ ${elapsed}` : elapsed,
|
|
80
|
+
map: status.map,
|
|
81
|
+
checklist: view.checklist === null ? [] : [view.checklist],
|
|
82
|
+
}, { color: options.color, width }).split("\n");
|
|
83
|
+
const step = stepText(status, options.now);
|
|
84
|
+
const stepLine = fit(`┃ ${step.text}`, width);
|
|
85
|
+
const stepRow = options.color ? `${ACCENT}┃ ${RESET}${step.live ? "" : DIM}${stepLine.slice(2)}${RESET}` : stepLine;
|
|
86
|
+
return [card[0] ?? "", hasMap ? (card[1] ?? "") : "", stepRow, view.checklist === null ? "" : (card.at(-1) ?? "")];
|
|
87
|
+
}
|
|
88
|
+
/** The escapes that draw `rows` below a child of `childRows` rows and put the cursor back where it was. */
|
|
89
|
+
export function panelFrame(rows, options) {
|
|
90
|
+
let out = "\u001b7\u001b[?25l";
|
|
91
|
+
rows.forEach((row, index) => {
|
|
92
|
+
out += `\u001b[${options.childRows + 1 + index};1H\u001b[0m\u001b[2K${row}`;
|
|
93
|
+
});
|
|
94
|
+
return `${out}\u001b8${options.cursorVisible ? "\u001b[?25h" : ""}`;
|
|
95
|
+
}
|
|
96
|
+
/** The escapes that give the whole screen back: no scroll region, empty panel rows, cursor below the child. */
|
|
97
|
+
export function panelClear(childRows) {
|
|
98
|
+
let out = "\u001b[r\u001b[0m";
|
|
99
|
+
for (let index = 0; index < PANEL_ROWS; index++)
|
|
100
|
+
out += `\u001b[${childRows + 1 + index};1H\u001b[2K`;
|
|
101
|
+
return `${out}\u001b[${childRows + 1};1H\u001b[?25h`;
|
|
102
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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";
|
|
@@ -172,7 +174,8 @@ export function safeTitle(label) {
|
|
|
172
174
|
return `${title.slice(0, MAX_TITLE - 1)}…`;
|
|
173
175
|
return cut < 0 ? title : `${title} …`;
|
|
174
176
|
}
|
|
175
|
-
|
|
177
|
+
/** The start-work plan this session shows, with its status and text; null when there is none. */
|
|
178
|
+
function activeWorkPlan(repoRoot, sessionId) {
|
|
176
179
|
const state = readJson(repoRoot, join(repoRoot, ".litcodex/start-work/state.json"));
|
|
177
180
|
if (!isRecord(state) || !isRecord(state["works"]))
|
|
178
181
|
return null;
|
|
@@ -198,17 +201,28 @@ function readWork(repoRoot, sessionId) {
|
|
|
198
201
|
const text = readText(repoRoot, join(repoRoot, ".litcodex/plans", file));
|
|
199
202
|
if (text === null)
|
|
200
203
|
return null;
|
|
201
|
-
|
|
204
|
+
return { status: work["status"], text };
|
|
205
|
+
}
|
|
206
|
+
function readWork(repoRoot, sessionId) {
|
|
207
|
+
const plan = activeWorkPlan(repoRoot, sessionId);
|
|
208
|
+
if (plan === null)
|
|
209
|
+
return null;
|
|
210
|
+
const rows = countPlanRows(plan.text);
|
|
202
211
|
if (rows.total === 0)
|
|
203
212
|
return null;
|
|
204
|
-
return { ...rows, status:
|
|
213
|
+
return { ...rows, status: plan.status };
|
|
205
214
|
}
|
|
206
|
-
|
|
215
|
+
/** The goal records of one lit-loop goals file; null when it has none. */
|
|
216
|
+
function goalList(repoRoot, path) {
|
|
207
217
|
const plan = readJson(repoRoot, path);
|
|
208
218
|
if (!isRecord(plan) || !Array.isArray(plan["goals"]))
|
|
209
219
|
return null;
|
|
210
220
|
const goals = plan["goals"].filter(isRecord);
|
|
211
|
-
|
|
221
|
+
return goals.length === 0 ? null : goals;
|
|
222
|
+
}
|
|
223
|
+
function goalProgress(repoRoot, path) {
|
|
224
|
+
const goals = goalList(repoRoot, path);
|
|
225
|
+
if (goals === null)
|
|
212
226
|
return null;
|
|
213
227
|
const open = goals.find((goal) => goal["status"] === "in_progress") ?? goals.find((goal) => goal["status"] === "pending");
|
|
214
228
|
return {
|
|
@@ -226,6 +240,40 @@ function readGoals(repoRoot, sessionId) {
|
|
|
226
240
|
const shared = goalProgress(repoRoot, join(repoRoot, LIT_LOOP_DIR, LIT_LOOP_GOALS));
|
|
227
241
|
return shared !== null && shared.done < shared.total ? shared : null;
|
|
228
242
|
}
|
|
243
|
+
const MAX_CHECKLIST = 3;
|
|
244
|
+
/**
|
|
245
|
+
* At most three rows around the open one: the last finished row, the open row and the next one. With
|
|
246
|
+
* nothing open, the last three finished rows. A label cut down to nothing by `safeTitle` reads `#<n>`.
|
|
247
|
+
*/
|
|
248
|
+
function checklistWindow(items, current) {
|
|
249
|
+
const start = current < 0
|
|
250
|
+
? Math.max(0, items.length - MAX_CHECKLIST)
|
|
251
|
+
: Math.max(0, Math.min(current - 1, items.length - MAX_CHECKLIST));
|
|
252
|
+
return items.slice(start, start + MAX_CHECKLIST).map((item, offset) => ({
|
|
253
|
+
state: start + offset === current ? "current" : item.done ? "done" : "pending",
|
|
254
|
+
label: safeTitle(item.label) ?? `#${start + offset + 1}`,
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
/** The checklist under the map: the start-work plan rows, else this session's lit-loop goals; [] when neither. */
|
|
258
|
+
export function readChecklist(repoRoot, sessionId) {
|
|
259
|
+
if (typeof repoRoot !== "string" || !isAbsolute(repoRoot))
|
|
260
|
+
return [];
|
|
261
|
+
const id = normalizeSessionId(sessionId);
|
|
262
|
+
const plan = activeWorkPlan(repoRoot, id);
|
|
263
|
+
const rows = plan === null ? [] : planRows(plan.text);
|
|
264
|
+
if (rows.length > 0)
|
|
265
|
+
return checklistWindow(rows, rows.findIndex((row) => !row.done));
|
|
266
|
+
const scoped = id === null ? null : goalList(repoRoot, join(repoRoot, LIT_LOOP_DIR, id, LIT_LOOP_GOALS));
|
|
267
|
+
const goals = scoped ?? goalList(repoRoot, join(repoRoot, LIT_LOOP_DIR, LIT_LOOP_GOALS));
|
|
268
|
+
if (goals === null)
|
|
269
|
+
return [];
|
|
270
|
+
const items = goals.map((goal) => ({
|
|
271
|
+
done: goal["status"] === "complete",
|
|
272
|
+
label: typeof goal["title"] === "string" ? goal["title"] : "",
|
|
273
|
+
}));
|
|
274
|
+
const running = goals.findIndex((goal) => goal["status"] === "in_progress");
|
|
275
|
+
return checklistWindow(items, running >= 0 ? running : items.findIndex((item) => !item.done));
|
|
276
|
+
}
|
|
229
277
|
function readPlanRecord(repoRoot, sessionId) {
|
|
230
278
|
if (sessionId === null)
|
|
231
279
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litcodex/lit-loop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
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,
|