@litfamily/litcodex 1.0.39 → 1.0.41

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.
Files changed (61) hide show
  1. package/README-Ko-KR.md +37 -15
  2. package/README.md +37 -15
  3. package/dist/cli.js +13 -0
  4. package/dist/install/auto-handoff-doctor.js +14 -8
  5. package/dist/install/extensions-notice.d.ts +13 -0
  6. package/dist/install/extensions-notice.js +26 -6
  7. package/dist/install/extensions.d.ts +74 -0
  8. package/dist/install/extensions.js +856 -0
  9. package/dist/install/generated-skill-payload-hashes.d.ts +8 -8
  10. package/dist/install/generated-skill-payload-hashes.js +8 -8
  11. package/dist/install/index.js +7 -1
  12. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
  13. package/marketplace/plugins/litcodex/components/auto-update/dist/extensions-notice.js +13 -2
  14. package/marketplace/plugins/litcodex/components/auto-update/dist/shown-notices.d.ts +6 -0
  15. package/marketplace/plugins/litcodex/components/auto-update/dist/shown-notices.js +63 -0
  16. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  17. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  18. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  19. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-schematic.md +5 -3
  20. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-scientific-visualization.md +5 -3
  21. package/marketplace/plugins/litcodex/components/lit-loop/dist/auto-handoff-settings.d.ts +7 -4
  22. package/marketplace/plugins/litcodex/components/lit-loop/dist/auto-handoff-settings.js +38 -22
  23. package/marketplace/plugins/litcodex/components/lit-loop/dist/auto-handoff.js +7 -5
  24. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +7 -0
  25. package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +1 -2
  26. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-end.d.ts +22 -0
  27. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-end.js +93 -0
  28. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.d.ts +2 -0
  29. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +3 -1
  30. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  31. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  32. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  33. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  34. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  35. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  36. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/SKILL.md +6 -4
  37. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/SKILL.md +6 -4
  38. package/marketplace/plugins/litcodex/skills/lit-docx/SKILL.md +6 -4
  39. package/marketplace/plugins/litcodex/skills/lit-pptx/SKILL.md +6 -4
  40. package/marketplace/plugins/litcodex/skills/lit-schematic/SKILL.md +6 -4
  41. package/marketplace/plugins/litcodex/skills/lit-scientific-visualization/SKILL.md +6 -4
  42. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/SKILL.md +6 -4
  43. package/marketplace/plugins/litcodex/skills/readme-studio/SKILL.md +6 -4
  44. package/marketplace/plugins/litcodex/skills/visual-qa/SKILL.md +6 -4
  45. package/node_modules/@litcodex/lit-loop/README.md +4 -4
  46. package/node_modules/@litcodex/lit-loop/directives/lit-schematic.md +5 -3
  47. package/node_modules/@litcodex/lit-loop/directives/lit-scientific-visualization.md +5 -3
  48. package/node_modules/@litcodex/lit-loop/dist/auto-handoff-settings.d.ts +7 -4
  49. package/node_modules/@litcodex/lit-loop/dist/auto-handoff-settings.js +38 -22
  50. package/node_modules/@litcodex/lit-loop/dist/auto-handoff.js +7 -5
  51. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +7 -0
  52. package/node_modules/@litcodex/lit-loop/dist/route-heads.js +1 -2
  53. package/node_modules/@litcodex/lit-loop/dist/run-end.d.ts +22 -0
  54. package/node_modules/@litcodex/lit-loop/dist/run-end.js +93 -0
  55. package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +2 -0
  56. package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +3 -1
  57. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  58. package/node_modules/@litcodex/lit-loop/skills/lit-schematic/SKILL.md +6 -4
  59. package/node_modules/@litcodex/lit-loop/skills/lit-scientific-visualization/SKILL.md +6 -4
  60. package/package.json +2 -2
  61. package/readme-assets/badge-version.svg +1 -1
@@ -1,10 +1,12 @@
1
1
  // src/auto-handoff-settings.ts — the user-controlled switch for automatic handoff.
2
2
  //
3
- // Off by default. The user turns it on with the exact prompt `lit-handoff auto on <percent>` (or sets
4
- // `LITCODEX_AUTO_HANDOFF=1` plus `LITCODEX_AUTO_HANDOFF_PERCENT`), turns it off with
5
- // `lit-handoff auto off`, and reads the state with `lit-handoff auto status`. The percent is never
6
- // hard-coded: `on` without a number reuses the last value the user stored and asks for one when there
7
- // is none. A percent that is not a whole number from 1 to 99 keeps the feature off and is reported.
3
+ // On by default at DEFAULT_AUTO_HANDOFF_PERCENT of the context window, so a long conversation saves its
4
+ // handoff before it is compacted without anyone setting anything up. The one off switch is the exact prompt
5
+ // `lit-handoff auto off` (or `LITCODEX_AUTO_HANDOFF=0`); `lit-handoff auto on <percent>` (or
6
+ // `LITCODEX_AUTO_HANDOFF=1` plus `LITCODEX_AUTO_HANDOFF_PERCENT`) chooses another percent, and
7
+ // `lit-handoff auto status` reads the state. `on` without a number reuses the last value the user stored,
8
+ // else the default. A percent that is not a whole number from 1 to 99 keeps the feature off and is reported,
9
+ // and so does a settings file that cannot be read: the user's choice is unknown, so nothing is assumed.
8
10
  //
9
11
  // Command-set values live in `.litcodex/auto-handoff/settings.json` under the project folder. When the
10
12
  // feature is turned on by command, the same percent is written to the PROJECT `.codex/config.toml` as
@@ -20,11 +22,16 @@ export const AUTO_HANDOFF_FLAG_ENV = "LITCODEX_AUTO_HANDOFF";
20
22
  export const AUTO_HANDOFF_PERCENT_ENV = "LITCODEX_AUTO_HANDOFF_PERCENT";
21
23
  export const AUTO_HANDOFF_DIR = ".litcodex/auto-handoff";
22
24
  export const AUTO_HANDOFF_SETTINGS_FILE = "settings.json";
25
+ /** Chosen below Codex's own automatic compaction point, so the handoff is written before the host compacts. */
26
+ export const DEFAULT_AUTO_HANDOFF_PERCENT = 80;
23
27
  export const HOST_COMPACT_KEY = "model_post_turn_compact_threshold_percent";
24
28
  export const HOST_COMPACT_BEGIN = "# litcodex automatic handoff (managed by `lit-handoff auto`; `lit-handoff auto off` removes it)";
25
29
  const NO_FOLLOW = constants.O_NOFOLLOW ?? 0;
26
30
  const MAX_FILE_BYTES = 256 * 1024;
27
- const DEFAULT_STORED = Object.freeze({ enabled: false, percent: null });
31
+ /** No settings file: the product default. */
32
+ const DEFAULT_STORED = Object.freeze({ enabled: true, percent: null });
33
+ /** A settings file that cannot be read: the user's choice is unknown, so the feature stays off. */
34
+ const UNREADABLE_STORED = Object.freeze({ enabled: false, percent: null });
28
35
  /** A whole number from 1 to 99 written as plain digits, else null. */
29
36
  export function parsePercent(raw) {
30
37
  const text = raw?.trim() ?? "";
@@ -61,7 +68,7 @@ export function readSmallFile(path) {
61
68
  closeSync(fd);
62
69
  }
63
70
  }
64
- /** The stored choice; a missing, malformed or hand-edited file reads as "off, no percent". */
71
+ /** The stored choice; a missing file reads as the default (on), a malformed or hand-edited one as "off, no percent". */
65
72
  export function readStoredAutoHandoff(repoRoot) {
66
73
  if (!isAbsolute(repoRoot))
67
74
  return { stored: DEFAULT_STORED, warning: null };
@@ -80,7 +87,7 @@ export function readStoredAutoHandoff(repoRoot) {
80
87
  }
81
88
  catch {
82
89
  return {
83
- stored: DEFAULT_STORED,
90
+ stored: UNREADABLE_STORED,
84
91
  warning: `${AUTO_HANDOFF_DIR}/${AUTO_HANDOFF_SETTINGS_FILE} could not be read, so automatic handoff stays off.`,
85
92
  };
86
93
  }
@@ -92,7 +99,7 @@ function shown(raw) {
92
99
  /**
93
100
  * Combine the environment with the stored choice. The environment wins when it is set: `=1` turns the
94
101
  * feature on and `=0` turns it off. The percent comes from its variable first, then from the stored
95
- * value. Nothing is active without a valid percent.
102
+ * value, then from the default. An invalid percent variable keeps the feature off.
96
103
  */
97
104
  export function resolveAutoHandoff(env, stored, storedWarning = null) {
98
105
  const warnings = [];
@@ -110,11 +117,13 @@ export function resolveAutoHandoff(env, stored, storedWarning = null) {
110
117
  if (envPercentInvalid) {
111
118
  warnings.push(`${AUTO_HANDOFF_PERCENT_ENV}=${shown(rawPercent)} is not a whole number from 1 to 99, so automatic handoff stays off.`);
112
119
  }
113
- const percent = envPercentInvalid ? null : (envPercent ?? stored.percent);
114
- const source = envDecision !== null || envPercent !== null ? "environment" : enabled ? "command" : "default";
115
- if (enabled && !envPercentInvalid && percent === null) {
116
- warnings.push(`Automatic handoff is on but has no percent. Run "lit-handoff auto on <percent>" or set ${AUTO_HANDOFF_PERCENT_ENV}.`);
117
- }
120
+ const fallback = enabled ? DEFAULT_AUTO_HANDOFF_PERCENT : null;
121
+ const percent = envPercentInvalid ? null : (envPercent ?? stored.percent ?? fallback);
122
+ let source = "command";
123
+ if (envDecision !== null || envPercent !== null)
124
+ source = "environment";
125
+ else if (enabled && stored.percent === null)
126
+ source = "default";
118
127
  return { active: enabled && percent !== null, percent, source, warnings };
119
128
  }
120
129
  export function loadAutoHandoffState(repoRoot, env) {
@@ -315,13 +324,17 @@ export function removeProjectCompaction(repoRoot) {
315
324
  }
316
325
  /**
317
326
  * Remove the managed block when the feature is effectively off, however it got there: `lit-handoff auto
318
- * off`, `LITCODEX_AUTO_HANDOFF=0`, a deleted settings file, or a percent that is not valid. Without this the
319
- * block outlives the switch and Codex keeps compacting at that percent with no handoff. Only the marked
327
+ * off`, `LITCODEX_AUTO_HANDOFF=0`, or a percent that is not valid. A deleted settings file puts the feature
328
+ * back on its default percent, which the block no longer matches, so it goes too. Without this the block
329
+ * outlives the switch and Codex keeps compacting at that percent with no handoff. Only the marked
320
330
  * block goes; a key the user wrote by hand is never touched. Never throws.
321
331
  */
322
332
  export function clearManagedCompactionWhenOff(repoRoot, env) {
323
333
  try {
324
- if (!isAbsolute(repoRoot) || loadAutoHandoffState(repoRoot, env).active)
334
+ if (!isAbsolute(repoRoot))
335
+ return "nothing-to-remove";
336
+ const state = loadAutoHandoffState(repoRoot, env);
337
+ if (state.active && state.source !== "default")
325
338
  return "nothing-to-remove";
326
339
  return removeProjectCompaction(repoRoot);
327
340
  }
@@ -354,8 +367,14 @@ function compactionSentence(repoRoot, percent, env) {
354
367
  export function describeAutoHandoff(repoRoot, state, env) {
355
368
  const lines = [];
356
369
  if (state.active && state.percent !== null) {
357
- const origin = state.source === "environment" ? "set by environment variables" : "set by command";
370
+ const origin = state.source === "environment"
371
+ ? "set by environment variables"
372
+ : state.source === "default"
373
+ ? "default"
374
+ : "set by command";
358
375
  lines.push(`Automatic handoff is ON at ${state.percent}% (${origin}).`);
376
+ if (state.source === "default")
377
+ lines.push('Run "lit-handoff auto off" to turn it off.');
359
378
  lines.push(compactionSentence(repoRoot, state.percent, env));
360
379
  }
361
380
  else {
@@ -388,10 +407,7 @@ export function applyAutoHandoffRoute(repoRoot, env, route) {
388
407
  const kept = stored.percent === null ? "" : ` Your last percent (${stored.percent}%) is kept for next time.`;
389
408
  return `Automatic handoff is OFF.${kept}${envNote}`;
390
409
  }
391
- const percent = route.argument === null ? stored.percent : parsePercent(route.argument);
392
- if (route.argument === null && percent === null) {
393
- return "Which percent should trigger the handoff? Run: lit-handoff auto on <percent from 1 to 99> (for example 60).";
394
- }
410
+ const percent = route.argument === null ? (stored.percent ?? DEFAULT_AUTO_HANDOFF_PERCENT) : parsePercent(route.argument);
395
411
  if (percent === null)
396
412
  return `"${shown(route.argument ?? "")}" is not a whole number from 1 to 99. Nothing changed.`;
397
413
  if (!writeStoredAutoHandoff(repoRoot, { enabled: true, percent })) {
@@ -3,9 +3,9 @@
3
3
  // The flow across Codex hooks, each step reading and writing one small per-session record under
4
4
  // `.litcodex/auto-handoff/<session>.json`:
5
5
  //
6
- // Stop reads the context percent from the session transcript. At or above the user's
7
- // percent, once per crossing, it blocks the stop with an instruction to write the
8
- // handoff now and to tell the user one plain line.
6
+ // Stop reads the context percent from the session transcript. At or above the percent in
7
+ // force (the user's, else the default), once per crossing, it blocks the stop with an
8
+ // instruction to write the handoff now and to tell the user one plain line.
9
9
  // PostCompact marks the session as compacted (Codex compacts after the handoff turn when the
10
10
  // project config asks for it, or the user runs /compact).
11
11
  // SessionStart source "compact" (compaction inside a turn) and the next UserPromptSubmit (compaction
@@ -145,7 +145,7 @@ function percentText(value) {
145
145
  export function buildHandoffInstruction(sessionId, percent, threshold, hostCompacts) {
146
146
  const line = hostCompacts ? SAVED_LINE_HOST_COMPACTS : SAVED_LINE_RUN_COMPACT;
147
147
  return [
148
- `Automatic handoff: this conversation has used ${percentText(percent)}% of the context window, past the ${threshold}% the user chose.`,
148
+ `Automatic handoff: this conversation has used ${percentText(percent)}% of the context window, past the ${threshold}% set for automatic handoff.`,
149
149
  "Save the handoff now, before anything else:",
150
150
  `1. Read ${resolveSkillPath("lit-handoff")} in full and follow it to create or refresh the handoff file. Its destination rules pick the file.`,
151
151
  `2. Put this exact line in the handoff file so the next context can find it: ${HANDOFF_MARKER_LABEL} ${sessionId}`,
@@ -176,8 +176,10 @@ export function evaluateAutoHandoffStop(input) {
176
176
  return PASS;
177
177
  if (reading.percent < state.percent) {
178
178
  if (session.phase === "idle" || session.phase === "compacted") {
179
- if (session.lastPercent !== seen.lastPercent)
179
+ // On the default alone nothing is written below the percent, so a project that never gets there stays untouched.
180
+ if (session.lastPercent !== seen.lastPercent && state.source !== "default") {
180
181
  writeSession(input.repoRoot, path, seen);
182
+ }
181
183
  return PASS;
182
184
  }
183
185
  writeSession(input.repoRoot, path, { ...seen, phase: "idle", firedAt: null, firedPercent: null });
@@ -18,6 +18,7 @@ import { detectWaitReason, endLiveStep, recordLiveStepEnd, recordLiveStepStart,
18
18
  import { evaluatePlanPersistence, formatStopBlockOutput, rearmLitPlanIfSatisfied, recordLitPlanActivation, } from "./plan-persistence.js";
19
19
  import { clearActiveRoute, isBareLit, isLitContinue, readActiveRoute, readResumeWork, recordActiveRoute, } from "./reentry.js";
20
20
  import { isBoundaryAnswer, isGoPrompt, takeGo } from "./rewind-go.js";
21
+ import { outcomeFor, recordRunEnd } from "./run-end.js";
21
22
  import { workflowCard } from "./screen-card.js";
22
23
  import { screenColor } from "./screen-status.js";
23
24
  import { recordLiveness } from "./session-liveness.js";
@@ -390,6 +391,12 @@ export async function runStopPlanPersistenceHookCli(stdin, stdout, stderr, repoR
390
391
  : null;
391
392
  const turn = line === null ? null : workflowTurn(scope.cwd, scope.sessionId);
392
393
  const card = turn === null ? null : workflowCard(scope.cwd, scope.sessionId, turn.mode, line, { color: screenColor(env) });
394
+ // The end of a LIT run: remember whether it reported, had nothing to report, or waits on the user.
395
+ const opened = workflowTurn(scope.cwd, scope.sessionId);
396
+ const outcome = opened === null ? null : outcomeFor(line, detectWaitReason(lastMsg));
397
+ if (opened !== null && outcome !== null) {
398
+ recordRunEnd(scope.cwd, scope.sessionId, { mode: opened.mode, outcome }, auto.now);
399
+ }
393
400
  // Codex puts a hook label before the first row, so the card starts on the next one.
394
401
  if (card !== null)
395
402
  stdout.write(`${JSON.stringify({ systemMessage: `\n${card}` })}\n`);
@@ -216,8 +216,7 @@ const LIT_SCHEMATIC = [
216
216
  BLOCKED,
217
217
  "",
218
218
  "1. Read the stub {skill:lit-schematic}. When the session's skill list has a separate `lit-schematic` copy (normally under `$CODEX_HOME/skills/`, where `$CODEX_HOME` defaults to `~/.codex`), open that file and let it handle the request.",
219
- "2. Otherwise say what lit-schematic makes, that it is a LitFamily extension in wjgoarxiv-skills, and give the stub's install lines unchanged, for example:",
220
- ' `cp -R "<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-schematic" "$CODEX_HOME/skills/lit-schematic"`, then a new Codex session.',
219
+ "2. Otherwise say what lit-schematic makes, that it is a LitFamily extension in wjgoarxiv-skills, and give the stub's four install lines unchanged: a check for same-name skills, a move-aside of an old copy into `$CODEX_HOME/extension-backups/`, the copy from `<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-schematic`, and a receipt (or `litcodex extensions install lit-schematic --yes`); then a new Codex session.",
221
220
  "3. Draw nothing by hand and do not imitate the moved procedure. Stop after the notice.",
222
221
  ];
223
222
  const LIT_HIJACK = [
@@ -0,0 +1,22 @@
1
+ export type RunOutcome = "sent" | "nothing" | "waiting";
2
+ export interface RunEnd {
3
+ readonly version: 1;
4
+ readonly at: number;
5
+ readonly session: string;
6
+ readonly mode: string;
7
+ readonly outcome: RunOutcome;
8
+ }
9
+ export declare function runEndPath(repoRoot: string): string;
10
+ /**
11
+ * The outcome for a turn that just closed, or null when the run is not over. `line` is the Stop line
12
+ * `workflowStopLine` made for the recorded turn (null when it made none) and `waitReason` what
13
+ * `detectWaitReason` read from the last assistant message.
14
+ */
15
+ export declare function outcomeFor(line: string | null, waitReason: string | null): RunOutcome | null;
16
+ /** Append one run end. Never throws. */
17
+ export declare function recordRunEnd(repoRoot: string, sessionId: string, entry: {
18
+ readonly mode: string;
19
+ readonly outcome: RunOutcome;
20
+ }, now?: number): void;
21
+ /** Every well-formed run end, oldest first; a corrupt line is skipped and an unreadable file reads as empty. */
22
+ export declare function readRunEnds(repoRoot: string): RunEnd[];
@@ -0,0 +1,93 @@
1
+ // src/run-end.ts — how each LIT run ended: `sent`, `nothing` or `waiting`.
2
+ //
3
+ // The lit-loop Stop hook is the run-end point of a LIT thread: the turn that ignited a LIT skill closes there. It
4
+ // then leaves one line in `.litcodex/run-end/outcomes.jsonl`:
5
+ //
6
+ // sent the turn closed with its summary card, the report LitCodex itself prints
7
+ // waiting the last assistant message asks the user something or reports BLOCKED, so the run waits on a person
8
+ // nothing the Stop has no card to print for the recorded turn
9
+ //
10
+ // A Stop that start-work keeps running (the `⏳ … continuing` line) is not an end and writes nothing, and a
11
+ // session that never ignited LIT writes nothing, so other projects get no `.litcodex` folder. The record is
12
+ // append-only, capped, never written through a symlink, and every failure is silent: the Stop output is the same
13
+ // with or without it.
14
+ import { appendFileSync, lstatSync, mkdirSync, readFileSync } from "node:fs";
15
+ import { join } from "node:path";
16
+ import { plainDirsOrMissing, writeFileAtomic } from "./live-step.js";
17
+ import { normalizeSessionId } from "./state-paths.js";
18
+ import { CONTINUING_MARK } from "./workflow-map.js";
19
+ const RUN_END_DIR = ".litcodex/run-end";
20
+ const RUN_END_FILE = "outcomes.jsonl";
21
+ /** Past this the oldest lines are dropped before the next one is appended. */
22
+ const MAX_BYTES = 32 * 1024;
23
+ const KEEP_LINES = 100;
24
+ const OUTCOMES = ["sent", "nothing", "waiting"];
25
+ export function runEndPath(repoRoot) {
26
+ return join(repoRoot, RUN_END_DIR, RUN_END_FILE);
27
+ }
28
+ /**
29
+ * The outcome for a turn that just closed, or null when the run is not over. `line` is the Stop line
30
+ * `workflowStopLine` made for the recorded turn (null when it made none) and `waitReason` what
31
+ * `detectWaitReason` read from the last assistant message.
32
+ */
33
+ export function outcomeFor(line, waitReason) {
34
+ if (line?.startsWith(CONTINUING_MARK) === true)
35
+ return null;
36
+ if (waitReason !== null)
37
+ return "waiting";
38
+ return line === null ? "nothing" : "sent";
39
+ }
40
+ /** Append one run end. Never throws. */
41
+ export function recordRunEnd(repoRoot, sessionId, entry, now = Date.now()) {
42
+ try {
43
+ const session = normalizeSessionId(sessionId);
44
+ if (session === null || !plainDirsOrMissing(repoRoot, RUN_END_DIR))
45
+ return;
46
+ const path = runEndPath(repoRoot);
47
+ const existing = lstatSync(path, { throwIfNoEntry: false });
48
+ if (existing !== undefined && !existing.isFile())
49
+ return;
50
+ mkdirSync(join(repoRoot, RUN_END_DIR), { recursive: true });
51
+ if (existing !== undefined && existing.size >= MAX_BYTES) {
52
+ const kept = readFileSync(path, "utf8").split("\n").filter(Boolean).slice(-KEEP_LINES);
53
+ writeFileAtomic(path, `${kept.join("\n")}\n`);
54
+ }
55
+ const line = { version: 1, at: now, session, mode: entry.mode, outcome: entry.outcome };
56
+ appendFileSync(path, `${JSON.stringify(line)}\n`);
57
+ }
58
+ catch {
59
+ // The Stop output does not depend on this record.
60
+ }
61
+ }
62
+ /** Every well-formed run end, oldest first; a corrupt line is skipped and an unreadable file reads as empty. */
63
+ export function readRunEnds(repoRoot) {
64
+ try {
65
+ const path = runEndPath(repoRoot);
66
+ const stat = lstatSync(path, { throwIfNoEntry: false });
67
+ if (stat === undefined || !stat.isFile() || stat.size > 4 * MAX_BYTES)
68
+ return [];
69
+ const ends = [];
70
+ for (const line of readFileSync(path, "utf8").split("\n")) {
71
+ try {
72
+ const entry = JSON.parse(line);
73
+ if (typeof entry === "object" &&
74
+ entry !== null &&
75
+ entry["version"] === 1 &&
76
+ typeof entry["at"] === "number" &&
77
+ typeof entry["session"] === "string" &&
78
+ typeof entry["mode"] === "string" &&
79
+ typeof entry["outcome"] === "string" &&
80
+ OUTCOMES.includes(entry["outcome"])) {
81
+ ends.push(entry);
82
+ }
83
+ }
84
+ catch {
85
+ // a corrupt line is skipped
86
+ }
87
+ }
88
+ return ends;
89
+ }
90
+ catch {
91
+ return [];
92
+ }
93
+ }
@@ -87,6 +87,8 @@ export declare function workflowTurn(repoRoot: string, sessionId: string): {
87
87
  mode: string;
88
88
  startedAt: number;
89
89
  } | null;
90
+ /** The Stop line of a turn that start-work keeps running starts with this mark; it is not the end of the run. */
91
+ export declare const CONTINUING_MARK = "\u23F3";
90
92
  /**
91
93
  * The Stop line for a LIT turn, or null when this turn was not a LIT activation. At a start-work
92
94
  * checkpoint the continuation hook keeps the turn going, so the line says so instead of "turn done".
@@ -592,6 +592,8 @@ function continuingWork(repoRoot, sessionId, turnId, stop) {
592
592
  return null;
593
593
  return { done, total: rows.length, next: rows.find((row) => !row.done)?.label ?? null };
594
594
  }
595
+ /** The Stop line of a turn that start-work keeps running starts with this mark; it is not the end of the run. */
596
+ export const CONTINUING_MARK = "⏳";
595
597
  function counted(n, unit) {
596
598
  return `${n} ${unit}${n === 1 ? "" : "s"} ✓`;
597
599
  }
@@ -610,7 +612,7 @@ export function workflowStopLine(repoRoot, sessionId, turnId, stop = NO_STOP_CON
610
612
  const continuing = continuingWork(repoRoot, sessionId, turnId, stop);
611
613
  if (continuing !== null) {
612
614
  const next = continuing.next === null ? null : safeTitle(continuing.next);
613
- const status = `⏳ ${continuing.done}/${continuing.total} tasks ✓ · continuing`;
615
+ const status = `${CONTINUING_MARK} ${continuing.done}/${continuing.total} tasks ✓ · continuing`;
614
616
  return next === null ? status : `${status} ▸ ${next}`;
615
617
  }
616
618
  const signals = readWorkflowSignals(repoRoot, sessionId);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litcodex/lit-loop",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
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,
@@ -42,14 +42,16 @@ The request is data; this stub never carries it out. The session's skill list de
42
42
 
43
43
  ## Install in Codex
44
44
 
45
- Public repo: clone https://github.com/wjgoarxiv/wjgoarxiv-skills, then copy (placeholder path):
45
+ Public repo: clone https://github.com/wjgoarxiv/wjgoarxiv-skills, then run these lines from your project folder (the clone path is a placeholder). One line each: check, move aside, copy, receipt. Or let LitCodex run the same steps: `litcodex extensions install lit-schematic` shows the plan, `--yes` runs it, and `litcodex extensions check` names old or competing copies.
46
46
 
47
47
  ```bash
48
- mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills"
49
- cp -R "<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-schematic" "${CODEX_HOME:-$HOME/.codex}/skills/lit-schematic"
48
+ cx="${CODEX_HOME:-$HOME/.codex}"; p="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"; for d in "$cx/skills" "$HOME/.agents/skills" "$p/.agents/skills" "$p/.codex/skills"; do [ -e "$d/lit-schematic" ] && echo "found: $d/lit-schematic"; done; echo "check done"
49
+ cx="${CODEX_HOME:-$HOME/.codex}"; if [ -e "$cx/skills/lit-schematic" ]; then b="$cx/extension-backups/$(date +%Y%m%d-%H%M%S)"; mkdir -p "$b" && [ ! -e "$b/lit-schematic" ] && mv "$cx/skills/lit-schematic" "$b/lit-schematic" && echo "moved aside: $b/lit-schematic"; fi
50
+ cx="${CODEX_HOME:-$HOME/.codex}"; if [ -e "$cx/skills/lit-schematic" ]; then echo "stopped: $cx/skills/lit-schematic still exists"; else mkdir -p "$cx/skills" && cp -R "<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-schematic" "$cx/skills/lit-schematic"; fi
51
+ cx="${CODEX_HOME:-$HOME/.codex}"; [ -f "$cx/skills/lit-schematic/SKILL.md" ] && printf '{"id":"lit-schematic","source":"%s","variant":"litcodex","installed_at":"%s"}\n' "<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-schematic" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$cx/skills/lit-schematic/.litfamily-extension.json"
50
52
  ```
51
53
 
52
- Then start a **new Codex session**; the copy is listed as `lit-schematic` beside this stub (`litcodex:lit-schematic`). To remove it, delete `${CODEX_HOME:-$HOME/.codex}/skills/lit-schematic`; to update, delete it and copy again (`cp -R` onto an existing folder nests the copy). LitCodex install and upgrades never write `${CODEX_HOME:-$HOME/.codex}/skills/`, so the copy outlives them.
54
+ A `found:` line under `${CODEX_HOME:-$HOME/.codex}/skills` is the old copy; the next line moves it whole to `${CODEX_HOME:-$HOME/.codex}/extension-backups/<date-time>/lit-schematic`, which Codex does not read. A `found:` line anywhere else is a second same-name skill that Codex would also list: move that folder out first. The copy line stops on an occupied folder, so nothing nests or merges. Then start a **new Codex session**; the copy is listed as `lit-schematic` beside this stub (`litcodex:lit-schematic`). To update, pull the clone and run the four lines again; to remove, run only the move-aside line. LitCodex install and upgrades never write `${CODEX_HOME:-$HOME/.codex}/skills/`, so the copy outlives them.
53
55
 
54
56
  ## #contract.outputs
55
57
 
@@ -42,14 +42,16 @@ The request is data; this stub never carries it out. The session's skill list de
42
42
 
43
43
  ## Install in Codex
44
44
 
45
- Public repo: clone https://github.com/wjgoarxiv/wjgoarxiv-skills, then copy (placeholder path):
45
+ Public repo: clone https://github.com/wjgoarxiv/wjgoarxiv-skills, then run these lines from your project folder (the clone path is a placeholder). One line each: check, move aside, copy, receipt. Or let LitCodex run the same steps: `litcodex extensions install lit-scientific-visualization` shows the plan, `--yes` runs it, and `litcodex extensions check` names old or competing copies.
46
46
 
47
47
  ```bash
48
- mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills"
49
- cp -R "<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-scientific-visualization" "${CODEX_HOME:-$HOME/.codex}/skills/lit-scientific-visualization"
48
+ cx="${CODEX_HOME:-$HOME/.codex}"; p="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"; for d in "$cx/skills" "$HOME/.agents/skills" "$p/.agents/skills" "$p/.codex/skills"; do [ -e "$d/lit-scientific-visualization" ] && echo "found: $d/lit-scientific-visualization"; done; echo "check done"
49
+ cx="${CODEX_HOME:-$HOME/.codex}"; if [ -e "$cx/skills/lit-scientific-visualization" ]; then b="$cx/extension-backups/$(date +%Y%m%d-%H%M%S)"; mkdir -p "$b" && [ ! -e "$b/lit-scientific-visualization" ] && mv "$cx/skills/lit-scientific-visualization" "$b/lit-scientific-visualization" && echo "moved aside: $b/lit-scientific-visualization"; fi
50
+ cx="${CODEX_HOME:-$HOME/.codex}"; if [ -e "$cx/skills/lit-scientific-visualization" ]; then echo "stopped: $cx/skills/lit-scientific-visualization still exists"; else mkdir -p "$cx/skills" && cp -R "<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-scientific-visualization" "$cx/skills/lit-scientific-visualization"; fi
51
+ cx="${CODEX_HOME:-$HOME/.codex}"; [ -f "$cx/skills/lit-scientific-visualization/SKILL.md" ] && printf '{"id":"lit-scientific-visualization","source":"%s","variant":"litcodex","installed_at":"%s"}\n' "<path to your wjgoarxiv-skills clone>/variants/litcodex/lit-scientific-visualization" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$cx/skills/lit-scientific-visualization/.litfamily-extension.json"
50
52
  ```
51
53
 
52
- Then start a **new Codex session**; the copy is listed as `lit-scientific-visualization` beside this stub (`litcodex:lit-scientific-visualization`). To remove it, delete `${CODEX_HOME:-$HOME/.codex}/skills/lit-scientific-visualization`; to update, delete it and copy again (`cp -R` onto an existing folder nests the copy). LitCodex install and upgrades never write `${CODEX_HOME:-$HOME/.codex}/skills/`, so the copy outlives them.
54
+ A `found:` line under `${CODEX_HOME:-$HOME/.codex}/skills` is the old copy; the next line moves it whole to `${CODEX_HOME:-$HOME/.codex}/extension-backups/<date-time>/lit-scientific-visualization`, which Codex does not read. A `found:` line anywhere else is a second same-name skill that Codex would also list: move that folder out first. The copy line stops on an occupied folder, so nothing nests or merges. Then start a **new Codex session**; the copy is listed as `lit-scientific-visualization` beside this stub (`litcodex:lit-scientific-visualization`). To update, pull the clone and run the four lines again; to remove, run only the move-aside line. LitCodex install and upgrades never write `${CODEX_HOME:-$HOME/.codex}/skills/`, so the copy outlives them.
53
55
 
54
56
  ## #contract.outputs
55
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litfamily/litcodex",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "Codex CLI plugin that turns a request into a goal with checks, keeps the evidence in your project and hands unfinished work to the next session.",
5
5
  "keywords": [
6
6
  "codex",
@@ -53,7 +53,7 @@
53
53
  "readme-assets"
54
54
  ],
55
55
  "dependencies": {
56
- "@litcodex/lit-loop": "1.0.39"
56
+ "@litcodex/lit-loop": "1.0.41"
57
57
  },
58
58
  "bundledDependencies": [
59
59
  "@litcodex/lit-loop"
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="146" height="20" role="img" aria-label="release: 1.0.39"><title>release: 1.0.39</title><g shape-rendering="crispEdges"><rect width="49" height="20" fill="#080d14"/><rect x="49" width="97" height="20" fill="#ff6337"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text x="255" y="140" textLength="390" transform="scale(.1)">release</text><text x="965" y="140" textLength="870" transform="scale(.1)" fill="#080D14">1.0.39</text></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="146" height="20" role="img" aria-label="release: 1.0.41"><title>release: 1.0.41</title><g shape-rendering="crispEdges"><rect width="49" height="20" fill="#080d14"/><rect x="49" width="97" height="20" fill="#ff6337"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text x="255" y="140" textLength="390" transform="scale(.1)">release</text><text x="965" y="140" textLength="870" transform="scale(.1)" fill="#080D14">1.0.41</text></g></svg>