@litfamily/litcodex 1.0.18 → 1.0.20

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 (50) hide show
  1. package/README-Ko-KR.md +46 -147
  2. package/README.md +46 -150
  3. package/dist/auto-update.d.ts +2 -1
  4. package/dist/auto-update.js +2 -1
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.js +85 -5
  7. package/dist/config-migration/gpt56-policy.js +0 -3
  8. package/dist/config-migration/multi-agent-v2-guard.js +10 -21
  9. package/dist/config-migration/root-settings.js +30 -31
  10. package/dist/config-migration/toml-lines.d.ts +12 -0
  11. package/dist/config-migration/toml-lines.js +113 -0
  12. package/dist/config-migration/toml-shape.js +8 -15
  13. package/dist/install/doctor-render.js +19 -0
  14. package/dist/install/doctor-tui.d.ts +7 -0
  15. package/dist/install/doctor-tui.js +65 -0
  16. package/dist/install/doctor.js +2 -0
  17. package/dist/install/generated-skill-payload-hashes.d.ts +5 -5
  18. package/dist/install/generated-skill-payload-hashes.js +5 -5
  19. package/dist/install/index.d.ts +6 -1
  20. package/dist/install/index.js +16 -2
  21. package/dist/install/office-runtime.d.ts +1 -0
  22. package/dist/install/office-runtime.js +2 -2
  23. package/dist/install/types.d.ts +10 -0
  24. package/dist/install/uninstall.d.ts +2 -0
  25. package/dist/install/uninstall.js +12 -1
  26. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
  27. package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.d.ts +16 -1
  28. package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.js +99 -13
  29. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  30. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  31. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  32. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  33. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  34. package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.d.ts +6 -0
  35. package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.js +10 -29
  36. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  37. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  38. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  39. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  40. package/marketplace/plugins/litcodex/hooks/hooks.json +1 -1
  41. package/marketplace/plugins/litcodex/skills/lit-pptx/runtime/package-lock.json +167 -119
  42. package/marketplace/plugins/litcodex/skills/lit-pptx/runtime/package.json +1 -1
  43. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/validate_pptx.py +3 -3
  44. package/marketplace/plugins/litcodex/skills/readme-studio/templates/hyperframes-cover/package-lock.json +169 -121
  45. package/marketplace/plugins/litcodex/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
  46. package/model-catalog.json +17 -8
  47. package/node_modules/@litcodex/lit-loop/README.md +1 -1
  48. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  49. package/package.json +12 -4
  50. package/readme-assets/badge-version.svg +1 -1
package/dist/cli.js CHANGED
@@ -7,10 +7,10 @@ import { readEffortChoice, readLeadModelChoice, readModelChoice, readSubagentEff
7
7
  import { acceptedModelIds, FALLBACK_CATALOG } from "./config-migration/catalog.js";
8
8
  import { runConfigMigrateCli } from "./config-migration/cli.js";
9
9
  import { resolveCodexHome } from "./install/codex.js";
10
- import { runDoctorCli, runInstallCli, runUninstallCli } from "./install/index.js";
10
+ import { renderDryRunPlan, runDoctorCli, runInstallCli, runUninstallCli } from "./install/index.js";
11
11
  import { managedMarketplaceRoot } from "./install/marketplace.js";
12
- import { motionRuntimeStatus, prepareMotionRuntime, renderMotionRuntime } from "./install/motion-runtime.js";
13
- import { officeRuntimeNotice, officeRuntimeStatus, prepareOfficeRuntime } from "./install/office-runtime.js";
12
+ import { motionRuntimeScript, motionRuntimeStatus, prepareMotionRuntime, renderMotionRuntime, } from "./install/motion-runtime.js";
13
+ import { officeRuntimeNotice, officeRuntimeScript, officeRuntimeStatus, prepareOfficeRuntime, } from "./install/office-runtime.js";
14
14
  import { buildInstallPlan } from "./install/plan.js";
15
15
  import { renderInstallPlan } from "./install/render-plan.js";
16
16
  import { renderBanner, shouldDecorate } from "./ui.js";
@@ -174,7 +174,13 @@ export function dispatch(argv) {
174
174
  * (M13, in-process), and the bundled `@litcodex/lit-loop` runtime routes `loop`/`hook`. Returns the
175
175
  * integer exit code; the bin owns `process.exit`. No forwarding, no exec-wrapper, no harness.
176
176
  */
177
- export async function runCli(argv) {
177
+ export async function runCli(rawArgv) {
178
+ const normalized = normalizeDryRunValue(rawArgv);
179
+ if (typeof normalized === "string") {
180
+ process.stderr.write(`litcodex: ${normalized} is not a valid --dry-run; use --dry-run, --dry-run=true or --dry-run=false. Nothing was changed.\n`);
181
+ return USAGE_EXIT_CODE;
182
+ }
183
+ const argv = normalized;
178
184
  const dryRun = argv.includes("--dry-run");
179
185
  const rest = argv.filter((token) => token !== "--dry-run");
180
186
  const head = rest[0];
@@ -204,7 +210,17 @@ export async function runCli(argv) {
204
210
  const mode = rest[1];
205
211
  if (mode !== "install" && mode !== "status")
206
212
  return dispatchExit(dispatch(argv));
213
+ if (mode === "install") {
214
+ const refused = refuseUnknownOptions("office-runtime install", rest.slice(2), []);
215
+ if (refused !== undefined)
216
+ return refused;
217
+ }
207
218
  const codexHome = resolveCodexHome(process.env);
219
+ if (dryRun && mode === "install") {
220
+ return writeDryRun("litcodex office-runtime install", [
221
+ `Run the pinned Office installer: ${officeRuntimeScript(codexHome)} install`,
222
+ ]);
223
+ }
208
224
  const result = mode === "install" ? prepareOfficeRuntime(codexHome) : officeRuntimeStatus(codexHome);
209
225
  process.stdout.write(`${officeRuntimeNotice(result.ready)}\n`);
210
226
  return result.ready ? 0 : mode === "install" ? 3 : 4;
@@ -212,11 +228,21 @@ export async function runCli(argv) {
212
228
  if (head === "motion-runtime") {
213
229
  const mode = rest[1];
214
230
  const flags = rest.slice(2);
231
+ if (mode === "install") {
232
+ const refused = refuseUnknownOptions("motion-runtime install", flags, ["--audio", "--word-timing"]);
233
+ if (refused !== undefined)
234
+ return refused;
235
+ }
215
236
  const valid = (mode === "install" && flags.every((flag) => flag === "--audio" || flag === "--word-timing")) ||
216
237
  (mode === "status" && flags.length === 0);
217
238
  if (!valid)
218
239
  return dispatchExit(dispatch(argv));
219
240
  const codexHome = resolveCodexHome(process.env);
241
+ if (dryRun && mode === "install") {
242
+ return writeDryRun(`litcodex motion-runtime ${rest.slice(1).join(" ")}`, [
243
+ `Run the film renderer pre-warm: ${[motionRuntimeScript(codexHome), "install", ...flags].join(" ")}`,
244
+ ]);
245
+ }
220
246
  if (mode === "install") {
221
247
  const result = prepareMotionRuntime(codexHome, flags);
222
248
  process.stdout.write(`${result.output}${renderMotionRuntime(result.status)}\n[litcodex] ${result.receipt}\n`);
@@ -227,7 +253,18 @@ export async function runCli(argv) {
227
253
  return report.ready ? 0 : 4;
228
254
  }
229
255
  if (head === "uninstall") {
230
- return runUninstallCli(rest.slice(1));
256
+ const refused = refuseUnknownOptions("uninstall", rest.slice(1), ["--json", "--no-tui", "--no-auto-update"]);
257
+ if (refused !== undefined)
258
+ return refused;
259
+ return runUninstallCli(dryRun ? [...rest.slice(1), "--dry-run"] : rest.slice(1));
260
+ }
261
+ if (head === "loop" && dryRun && rest[1] !== undefined && Object.hasOwn(LOOP_WRITE_STEPS, rest[1])) {
262
+ return writeDryRun(`litcodex loop ${rest[1]}`, [LOOP_WRITE_STEPS[rest[1]]]);
263
+ }
264
+ if (head === "hook" && dryRun) {
265
+ return writeDryRun(`litcodex hook ${rest[1] ?? ""}`.trimEnd(), [
266
+ "Read the hook payload from stdin and run the hook (skipped: hooks change session and project state)",
267
+ ]);
231
268
  }
232
269
  if (head === "loop") {
233
270
  const { loopCommand } = await import("@litcodex/lit-loop/dist/loop-cli.js");
@@ -259,6 +296,49 @@ export async function runCli(argv) {
259
296
  }
260
297
  return exitCode;
261
298
  }
299
+ /** Loop subcommands that write project state; a `--dry-run` of these prints the step instead. */
300
+ const LOOP_WRITE_STEPS = {
301
+ create: "Derive goals and criteria from the brief and write the project's lit-loop plan and ledger",
302
+ run: "Schedule the next runnable goal, update the lit-loop plan and append to the ledger",
303
+ checkpoint: "Set the goal's terminal status in the lit-loop plan and append to the ledger",
304
+ "record-evidence": "Record the criterion result and its evidence in the lit-loop plan and ledger",
305
+ };
306
+ const USAGE_EXIT_CODE = 64;
307
+ /**
308
+ * `--dry-run=true` is `--dry-run`, `--dry-run=false` is an ordinary run. Any other value returns the
309
+ * offending token so the caller can refuse before doing anything.
310
+ */
311
+ function normalizeDryRunValue(argv) {
312
+ const out = [];
313
+ for (const token of argv) {
314
+ if (!token.startsWith("--dry-run=")) {
315
+ out.push(token);
316
+ }
317
+ else if (token === "--dry-run=true") {
318
+ out.push("--dry-run");
319
+ }
320
+ else if (token !== "--dry-run=false") {
321
+ return token;
322
+ }
323
+ }
324
+ return out;
325
+ }
326
+ /**
327
+ * State-changing routes accept only the options they document. An unknown option (such as `-n`)
328
+ * is refused before anything runs, so a mistyped dry run can never fall through to the real action.
329
+ */
330
+ function refuseUnknownOptions(command, args, allowed) {
331
+ const unknown = args.find((arg) => !allowed.includes(arg));
332
+ if (unknown === undefined)
333
+ return undefined;
334
+ const accepted = ["--dry-run", ...allowed].join(", ");
335
+ process.stderr.write(`litcodex ${command}: unknown option "${unknown}". Accepted: ${accepted}. Nothing was changed.\n`);
336
+ return USAGE_EXIT_CODE;
337
+ }
338
+ function writeDryRun(title, steps) {
339
+ process.stdout.write(renderDryRunPlan(title, steps));
340
+ return 0;
341
+ }
262
342
  /** Update notices run only after a successful management command has completed. */
263
343
  function notifyAfterManagementCommand(command, argv, exitCode) {
264
344
  const gate = {
@@ -54,9 +54,6 @@ export function unsafeEffectiveRoute(current) {
54
54
  }
55
55
  if (definition.safeExistingEfforts !== undefined &&
56
56
  !definition.safeExistingEfforts.includes(effort)) {
57
- if (definition.legacyProfile === "luna" && effort === "xhigh") {
58
- return `${model} cannot use xhigh reasoning effort; use max`;
59
- }
60
57
  return `${model} requires ${formatEfforts(definition.safeExistingEfforts)} reasoning effort`;
61
58
  }
62
59
  return null;
@@ -3,6 +3,7 @@
3
3
  // gpt-5.6 models reserve collaboration.spawn_agent and reject V2's extended
4
4
  // metadata schema. Hiding that metadata selects the model-owned schema while
5
5
  // retaining a hard 20-thread session cap and the host's depth-one guard.
6
+ import { stripTomlComment, tomlLineKinds } from "./toml-lines.js";
6
7
  const MANAGED_COMMENT_MARKER = "Managed by LitCodex";
7
8
  const MANAGED_GUARD_COMMENT = [
8
9
  `# ${MANAGED_COMMENT_MARKER}: reserved-schema-safe depth-one multi-agent, hard concurrency 20.`,
@@ -132,32 +133,20 @@ function hasSectionSetting(section, key, value) {
132
133
  const pattern = new RegExp(`^\\s*${key}\\s*=\\s*${value}\\s*(?:#[^\\n]*)?$`, "m");
133
134
  return pattern.test(section);
134
135
  }
135
- /** Strip a trailing inline comment (best-effort; quoted keys with # out of scope). */
136
- function stripTrailingComment(line) {
137
- const idx = line.indexOf("#");
138
- return idx === -1 ? line : line.slice(0, idx).trim();
139
- }
136
+ /** Span of the table whose header is `headerLine`, ending at the next header the shared line scan finds. */
140
137
  function findSection(config, headerLine) {
141
- const lines = config.match(/[^\n]*\n?|$/g) ?? [];
138
+ const lines = config.split("\n");
139
+ const kinds = tomlLineKinds(lines);
142
140
  let offset = 0;
143
141
  let start = -1;
144
- for (const line of lines) {
145
- if (line.length === 0) {
146
- break;
147
- }
148
- const trimmed = line.trim();
149
- if (start === -1) {
150
- if (stripTrailingComment(trimmed) === headerLine) {
151
- start = offset;
152
- }
153
- }
154
- else {
155
- const bare = stripTrailingComment(trimmed);
156
- if (bare.startsWith("[") && bare.endsWith("]")) {
142
+ for (const [index, line] of lines.entries()) {
143
+ if (kinds[index] === "header") {
144
+ if (start !== -1)
157
145
  return { start, end: offset, text: config.slice(start, offset) };
158
- }
146
+ if (stripTomlComment(line).trim() === headerLine)
147
+ start = offset;
159
148
  }
160
- offset += line.length;
149
+ offset += line.length + 1;
161
150
  }
162
151
  if (start === -1) {
163
152
  return null;
@@ -6,6 +6,7 @@
6
6
  //
7
7
  // These five managed root keys are part of the Codex config schema. Callers
8
8
  // decide whether a file is authorized for mutation before invoking this helper.
9
+ import { tomlLineKinds } from "./toml-lines.js";
9
10
  export const MANAGED_KEYS = [
10
11
  "model",
11
12
  "model_context_window",
@@ -41,10 +42,10 @@ export function ensureLitCodexOutputStyleConfig(config, styleId) {
41
42
  }
42
43
  /** Read `litcodex_output_style` from the root scope of a TOML config string. Returns undefined if absent. */
43
44
  export function readLitCodexOutputStyleId(config) {
44
- for (const line of config.split(/\n/)) {
45
- if (isSectionHeader(line))
46
- break;
47
- if (!isRootSetting(line, LITCODEX_OUTPUT_STYLE_KEY))
45
+ const lines = config.split(/\n/);
46
+ const scan = scanRootScope(lines);
47
+ for (const [index, line] of lines.slice(0, scan.end).entries()) {
48
+ if (scan.continuation.has(index) || !isRootSetting(line, LITCODEX_OUTPUT_STYLE_KEY))
48
49
  continue;
49
50
  const value = parseTomlScalar(line.slice(line.indexOf("=") + 1));
50
51
  return typeof value === "string" ? value : undefined;
@@ -53,22 +54,19 @@ export function readLitCodexOutputStyleId(config) {
53
54
  }
54
55
  function removeRootSetting(config, key) {
55
56
  const lines = config.split(/\n/);
56
- let inRoot = true;
57
+ const scan = scanRootScope(lines);
57
58
  return lines
58
- .filter((line) => {
59
- if (isSectionHeader(line)) {
60
- inRoot = false;
61
- }
62
- return !inRoot || !isRootSetting(line, key);
63
- })
59
+ .filter((line, index) => index >= scan.end || scan.continuation.has(index) || !isRootSetting(line, key))
64
60
  .join("\n");
65
61
  }
66
62
  /** Read only the five managed keys from root scope (stops at first section). Pure. */
67
63
  export function readRootSettings(config) {
68
64
  const settings = {};
69
- for (const line of config.split(/\n/)) {
70
- if (isSectionHeader(line)) {
71
- break;
65
+ const lines = config.split(/\n/);
66
+ const scan = scanRootScope(lines);
67
+ for (const [index, line] of lines.slice(0, scan.end).entries()) {
68
+ if (scan.continuation.has(index)) {
69
+ continue;
72
70
  }
73
71
  for (const key of MANAGED_KEYS) {
74
72
  if (!isRootSetting(line, key)) {
@@ -101,19 +99,15 @@ function parseTomlScalar(value) {
101
99
  }
102
100
  function replaceOrInsertRootSetting(config, key, value) {
103
101
  const lines = config.split(/\n/);
102
+ const scan = scanRootScope(lines);
104
103
  const output = [];
105
104
  let replaced = false;
106
- let inserted = false;
107
- let inRoot = true;
108
- for (const line of lines) {
109
- const sectionHeader = isSectionHeader(line);
110
- if (inRoot && !inserted && sectionHeader) {
111
- if (!replaced) {
112
- output.push(`${key} = ${value}`);
113
- }
114
- inserted = true;
105
+ for (const [index, line] of lines.entries()) {
106
+ if (index === scan.end && !replaced) {
107
+ output.push(`${key} = ${value}`);
108
+ replaced = true;
115
109
  }
116
- if (inRoot && isRootSetting(line, key)) {
110
+ if (index < scan.end && !scan.continuation.has(index) && isRootSetting(line, key)) {
117
111
  if (!replaced) {
118
112
  output.push(`${key} = ${value}`);
119
113
  replaced = true;
@@ -121,18 +115,23 @@ function replaceOrInsertRootSetting(config, key, value) {
121
115
  continue;
122
116
  }
123
117
  output.push(line);
124
- if (sectionHeader) {
125
- inRoot = false;
126
- }
127
118
  }
128
- if (!replaced && !inserted) {
119
+ if (!replaced) {
129
120
  output.push(`${key} = ${value}`);
130
121
  }
131
122
  return output.join("\n");
132
123
  }
133
- function isSectionHeader(line) {
134
- const trimmed = line.trim();
135
- return trimmed.startsWith("[") && trimmed.endsWith("]");
124
+ /** Where root scope ends, from the shared line scan. Every reader and writer here uses it, so they agree. */
125
+ function scanRootScope(lines) {
126
+ const kinds = tomlLineKinds(lines);
127
+ const header = kinds.indexOf("header");
128
+ const end = header === -1 ? lines.length : header;
129
+ const continuation = new Set();
130
+ for (let index = 0; index < end; index += 1) {
131
+ if (kinds[index] === "continuation")
132
+ continuation.add(index);
133
+ }
134
+ return { end, continuation };
136
135
  }
137
136
  function isRootSetting(line, key) {
138
137
  const trimmed = line.trimStart();
@@ -0,0 +1,12 @@
1
+ export type TomlLineKind = "header" | "continuation" | "other";
2
+ /**
3
+ * Classify every line. `header`: a table or array-of-tables header outside any open value.
4
+ * `continuation`: a line inside a multi-line array, inline table or `"""`/`'''` string.
5
+ * A value still open at end of file is invalid TOML; its lines are then rescanned as if it had
6
+ * closed on its first line, so an unclosed `[` cannot hide the headers after it.
7
+ */
8
+ export declare function tomlLineKinds(lines: readonly string[]): TomlLineKind[];
9
+ /** A line whose comment-stripped text is `[...]` or `[[...]]`. Callers decide whether it sits inside a value. */
10
+ export declare function isTomlTableHeader(line: string): boolean;
11
+ /** Drop a trailing `# comment`, ignoring `#` inside quoted strings (e.g. `[projects."/a#b"]`). */
12
+ export declare function stripTomlComment(line: string): string;
@@ -0,0 +1,113 @@
1
+ // Line classification shared by the root-settings writer, the shape validator and uninstall.
2
+ //
3
+ // Pure. Not a TOML parser: it only knows enough to tell a table header from a line that continues a
4
+ // multi-line value, so a row such as `["b"],` inside an array or a `[x]` line inside a `"""` string is
5
+ // never taken for a header, and a header with a trailing comment (`[mcp_servers.x] # server`) is.
6
+ /**
7
+ * Classify every line. `header`: a table or array-of-tables header outside any open value.
8
+ * `continuation`: a line inside a multi-line array, inline table or `"""`/`'''` string.
9
+ * A value still open at end of file is invalid TOML; its lines are then rescanned as if it had
10
+ * closed on its first line, so an unclosed `[` cannot hide the headers after it.
11
+ */
12
+ export function tomlLineKinds(lines) {
13
+ const kinds = [];
14
+ scanFrom(lines, 0, kinds);
15
+ return kinds;
16
+ }
17
+ function scanFrom(lines, start, kinds) {
18
+ let depth = 0;
19
+ let openString = null;
20
+ let openedAt = -1;
21
+ for (let index = start; index < lines.length; index += 1) {
22
+ const line = lines[index] ?? "";
23
+ const open = depth > 0 || openString !== null;
24
+ if (open) {
25
+ kinds[index] = "continuation";
26
+ }
27
+ else if (isTomlTableHeader(line)) {
28
+ kinds[index] = "header";
29
+ continue;
30
+ }
31
+ else {
32
+ kinds[index] = "other";
33
+ }
34
+ let i = 0;
35
+ while (i < line.length) {
36
+ if (openString !== null) {
37
+ const close = findMultilineClose(line, i, openString);
38
+ if (close === -1)
39
+ break;
40
+ i = close + 3;
41
+ openString = null;
42
+ continue;
43
+ }
44
+ const ch = line[i];
45
+ if (ch === "#")
46
+ break;
47
+ if (line.startsWith('"""', i) || line.startsWith("'''", i)) {
48
+ openString = line.startsWith('"""', i) ? '"""' : "'''";
49
+ i += 3;
50
+ continue;
51
+ }
52
+ if (ch === '"' || ch === "'") {
53
+ i = endOfQuoted(line, i);
54
+ continue;
55
+ }
56
+ if (ch === "[" || ch === "{")
57
+ depth += 1;
58
+ if ((ch === "]" || ch === "}") && depth > 0)
59
+ depth -= 1;
60
+ i += 1;
61
+ }
62
+ const stillOpen = depth > 0 || openString !== null;
63
+ if (!open && stillOpen)
64
+ openedAt = index;
65
+ if (!stillOpen)
66
+ openedAt = -1;
67
+ }
68
+ if (openedAt !== -1)
69
+ scanFrom(lines, openedAt + 1, kinds);
70
+ }
71
+ /** A line whose comment-stripped text is `[...]` or `[[...]]`. Callers decide whether it sits inside a value. */
72
+ export function isTomlTableHeader(line) {
73
+ const bare = stripTomlComment(line).trim();
74
+ return bare.startsWith("[") && bare.endsWith("]");
75
+ }
76
+ /** Drop a trailing `# comment`, ignoring `#` inside quoted strings (e.g. `[projects."/a#b"]`). */
77
+ export function stripTomlComment(line) {
78
+ let i = 0;
79
+ while (i < line.length) {
80
+ const ch = line[i];
81
+ if (ch === "#")
82
+ return line.slice(0, i);
83
+ i = ch === '"' || ch === "'" ? endOfQuoted(line, i) : i + 1;
84
+ }
85
+ return line;
86
+ }
87
+ /** Index of the closing delimiter of a multi-line string, honoring `\` escapes in `"""` strings. */
88
+ function findMultilineClose(line, from, delimiter) {
89
+ for (let i = from; i < line.length; i += 1) {
90
+ if (delimiter === '"""' && line[i] === "\\") {
91
+ i += 1;
92
+ continue;
93
+ }
94
+ if (line.startsWith(delimiter, i))
95
+ return i;
96
+ }
97
+ return -1;
98
+ }
99
+ /** Index just past a single-line basic (`"…"`, with escapes) or literal (`'…'`) string starting at `start`. */
100
+ function endOfQuoted(line, start) {
101
+ const quote = line[start];
102
+ let i = start + 1;
103
+ while (i < line.length) {
104
+ if (quote === '"' && line[i] === "\\") {
105
+ i += 2;
106
+ continue;
107
+ }
108
+ if (line[i] === quote)
109
+ return i + 1;
110
+ i += 1;
111
+ }
112
+ return line.length;
113
+ }
@@ -7,22 +7,21 @@
7
7
  //
8
8
  // Accepts exotic-but-valid TOML: multiline strings ("""/'''), arrays-of-tables
9
9
  // ([[...]]), inline arrays/tables, section-scoped clipped strings.
10
+ import { stripTomlComment, tomlLineKinds } from "./toml-lines.js";
10
11
  const WELL_FORMED_HEADER = /^\s*\[\[?[^[\]]+\]\]?\s*(?:#[^\n]*)?$/;
11
12
  const GUARD_HEADER = "[features.multi_agent_v2]";
12
13
  /** Validate the structural shape. Pure, never throws. */
13
14
  export function validateTomlShape(config) {
14
15
  const lines = config.split(/\n/);
16
+ const kinds = tomlLineKinds(lines);
15
17
  let inRoot = true;
16
18
  let guardCount = 0;
17
- let multilineCloser = null;
18
19
  for (let i = 0; i < lines.length; i++) {
19
20
  const raw = lines[i] ?? "";
20
21
  const lineNo = i + 1;
21
- // Inside an open multiline string: skip until the closer appears.
22
- if (multilineCloser !== null) {
23
- if (raw.includes(multilineCloser)) {
24
- multilineCloser = null;
25
- }
22
+ // Inside an open multi-line value (array, inline table, or multi-line string): an array row such
23
+ // as `["a"],` or a `[` line inside a string is not a header.
24
+ if (kinds[i] === "continuation") {
26
25
  continue;
27
26
  }
28
27
  const trimmed = raw.trim();
@@ -35,7 +34,7 @@ export function validateTomlShape(config) {
35
34
  return reject("unbalanced-section-header", lineNo);
36
35
  }
37
36
  // R3 — duplicate [features.multi_agent_v2] table.
38
- if (stripInlineComment(trimmed) === GUARD_HEADER) {
37
+ if (stripTomlComment(trimmed).trim() === GUARD_HEADER) {
39
38
  guardCount += 1;
40
39
  if (guardCount >= 2) {
41
40
  return reject("duplicate-multi-agent-v2", lineNo);
@@ -46,10 +45,8 @@ export function validateTomlShape(config) {
46
45
  }
47
46
  // R1 — only root-scope scalar lines are checked.
48
47
  if (inRoot) {
49
- const opener = multilineOpener(raw);
50
- if (opener !== null) {
51
- // A multiline opener whose closer is NOT on the same line opens a block.
52
- multilineCloser = opener;
48
+ if (multilineOpener(raw) !== null) {
49
+ // A multiline opener whose closer is NOT on the same line opens a block; its rows are continuation lines.
53
50
  continue;
54
51
  }
55
52
  if (hasUnterminatedQuote(raw, '"') || hasUnterminatedQuote(raw, "'")) {
@@ -103,10 +100,6 @@ function hasUnterminatedQuote(line, delim) {
103
100
  }
104
101
  return count % 2 === 1;
105
102
  }
106
- function stripInlineComment(line) {
107
- const idx = line.indexOf("#");
108
- return idx === -1 ? line.trim() : line.slice(0, idx).trim();
109
- }
110
103
  /**
111
104
  * Replace every quoted span (basic `"…"` or literal `'…'`) with a single inert placeholder, so a
112
105
  * structural scan never sees `[`, `]`, `#`, or quote chars that live INSIDE a TOML string. Basic
@@ -42,10 +42,29 @@ export function renderDoctorText(report) {
42
42
  for (const warning of report.warnings)
43
43
  lines.push(` - ${warning}`);
44
44
  }
45
+ // A cosmetic tip would only crowd real issues, so it waits for a clean run.
46
+ if (report.issues.length === 0 && report.tuiSuggestion)
47
+ lines.push(...tuiSuggestionLines(report.tuiSuggestion));
45
48
  if (report.issues.length === 0)
46
49
  lines.push("All checks passed.");
47
50
  return lines.join("\n");
48
51
  }
52
+ function tuiSuggestionLines(suggestion) {
53
+ const what = suggestion.missing
54
+ .map((key) => (key === "status_line" ? "status line" : "terminal title"))
55
+ .join(" and ");
56
+ const commands = suggestion.missing.map((key) => (key === "status_line" ? "/statusline" : "/title")).join(" and ");
57
+ const where = {
58
+ "new-table": `paste this into ${suggestion.configPath}`,
59
+ "existing-table": `add these lines under the [tui] table in ${suggestion.configPath}`,
60
+ "root-dotted": `add these lines above the first table in ${suggestion.configPath}`,
61
+ }[suggestion.placement];
62
+ return [
63
+ `Suggestion: your Codex config has no built-in ${what}. LitCodex never edits it for you.`,
64
+ ` Pick items in Codex with ${commands}, or ${where}:`,
65
+ ...suggestion.snippet.split("\n").map((line) => ` ${line}`),
66
+ ];
67
+ }
49
68
  function missingResourceSummary(paths) {
50
69
  const byFamily = new Map();
51
70
  for (const path of paths) {
@@ -0,0 +1,7 @@
1
+ import type { ReadonlyFsLike } from "./codex.js";
2
+ import type { TuiSuggestion } from "./types.js";
3
+ /** Item ids checked against the Codex 0.159.3 binary. */
4
+ export declare const RECOMMENDED_STATUS_LINE: readonly ["model-with-reasoning", "context-used", "five-hour-limit", "weekly-limit", "task-progress", "git-branch"];
5
+ /** `activity` is the spinner item: it spins while Codex works and shows a notice while it waits on you. */
6
+ export declare const RECOMMENDED_TERMINAL_TITLE: readonly ["activity", "project-name"];
7
+ export declare function inspectTuiSuggestion(fs: ReadonlyFsLike, configPath: string): TuiSuggestion | null;
@@ -0,0 +1,65 @@
1
+ // Read-only `[tui]` look-up for the doctor. Codex draws its own status line and terminal title from
2
+ // built-in item ids; plugins cannot add to either. When the user's config lacks either key, the doctor
3
+ // shows a snippet to paste (or points at `/statusline` and `/title`). It never writes the config.
4
+ import { stripTomlComment, tomlLineKinds } from "../config-migration/toml-lines.js";
5
+ /** Item ids checked against the Codex 0.159.3 binary. */
6
+ export const RECOMMENDED_STATUS_LINE = [
7
+ "model-with-reasoning",
8
+ "context-used",
9
+ "five-hour-limit",
10
+ "weekly-limit",
11
+ "task-progress",
12
+ "git-branch",
13
+ ];
14
+ /** `activity` is the spinner item: it spins while Codex works and shows a notice while it waits on you. */
15
+ export const RECOMMENDED_TERMINAL_TITLE = ["activity", "project-name"];
16
+ const RECOMMENDED = {
17
+ status_line: RECOMMENDED_STATUS_LINE,
18
+ terminal_title: RECOMMENDED_TERMINAL_TITLE,
19
+ };
20
+ export function inspectTuiSuggestion(fs, configPath) {
21
+ let config = "";
22
+ try {
23
+ if (fs.existsSync(configPath))
24
+ config = fs.readFileSync(configPath, "utf8");
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ const lines = config.split(/\r?\n/u);
30
+ const kinds = tomlLineKinds(lines);
31
+ const present = new Set();
32
+ let table = null;
33
+ let tuiTable = false;
34
+ let rootDotted = false;
35
+ lines.forEach((line, index) => {
36
+ const bare = stripTomlComment(line).trim();
37
+ if (kinds[index] === "header") {
38
+ table = bare.replace(/^\[+|\]+$/gu, "").trim();
39
+ if (table === "tui")
40
+ tuiTable = true;
41
+ return;
42
+ }
43
+ if (kinds[index] !== "other")
44
+ return;
45
+ const key = bare.split("=", 1)[0]?.trim() ?? "";
46
+ if (table === "tui")
47
+ present.add(key);
48
+ if (table === null && key.startsWith("tui.")) {
49
+ rootDotted = true;
50
+ present.add(key.slice("tui.".length));
51
+ }
52
+ });
53
+ const missing = Object.keys(RECOMMENDED).filter((key) => !present.has(key));
54
+ if (missing.length === 0)
55
+ return null;
56
+ const placement = tuiTable ? "existing-table" : rootDotted ? "root-dotted" : "new-table";
57
+ const prefix = placement === "root-dotted" ? "tui." : "";
58
+ const rows = missing.map((key) => `${prefix}${key} = [${RECOMMENDED[key].map((id) => `"${id}"`).join(", ")}]`);
59
+ return {
60
+ missing,
61
+ placement,
62
+ configPath,
63
+ snippet: (placement === "new-table" ? ["[tui]", ...rows] : rows).join("\n"),
64
+ };
65
+ }
@@ -15,6 +15,7 @@ import { inspectAutoHandoff } from "./auto-handoff-doctor.js";
15
15
  import { probeBundledSkills } from "./bundled-skills.js";
16
16
  import { findCodexBinary, probeMarketplaceRegistration, probePluginInstalled, resolveCodexHome, } from "./codex.js";
17
17
  import { inspectEffectiveConfig } from "./doctor-config.js";
18
+ import { inspectTuiSuggestion } from "./doctor-tui.js";
18
19
  import { modelContextsForWrites, probeHostCapabilities } from "./host-capabilities.js";
19
20
  import { canonicalMarketplacePath, LITCODEX_MARKETPLACE, managedMarketplaceRoot } from "./marketplace.js";
20
21
  import { probeSkillCatalogPayload } from "./skill-catalog.js";
@@ -175,6 +176,7 @@ export function runDoctor(deps) {
175
176
  autoUpdate,
176
177
  jevSkillHint: jevSkillHintState(deps.env),
177
178
  autoHandoff: autoHandoffWithWarnings(deps, codexHome, warnings),
179
+ tuiSuggestion: inspectTuiSuggestion(deps.fs, join(codexHome, "config.toml")),
178
180
  issues,
179
181
  warnings,
180
182
  };
@@ -302,11 +302,11 @@ export declare const README_STUDIO_PAYLOAD_HASHES: {
302
302
  readonly "templates/cover-source.json": "2f65ec7706431a308619f57c5741c5fa0b24bd60c0c2c649c364aafdb8170e26";
303
303
  readonly "templates/hyperframes-cover/index.html": "cd89b5c6c0fbeeb895eb38a7eb9e232d622323a48adc9773b548032acf6d6c64";
304
304
  readonly "templates/hyperframes-cover/index.motion.json": "18dab5464db575a5048e0f3a476c0eddbf284545147283ba04025a8495d16e43";
305
- readonly "templates/hyperframes-cover/package-lock.json": "6cb809955794acbefa0f8f4ba0a00ba7d91e0b79c65345653ef5a5a8e21d59d8";
305
+ readonly "templates/hyperframes-cover/package-lock.json": "d6d9b47ce49369bfc73d62e8efa01de2dca153e17fdde274456bb642a1afe2c8";
306
306
  readonly "templates/hyperframes-cover/package.json": "9ec0e871126193a545f898f0ed994412a518e2bf06170cd07b3fc9e61cae2530";
307
307
  readonly "templates/readme-cover-section.md": "324e61dd601c42af7117f0eed7ef6ca58c66444c0607919831a64685f4d49b7a";
308
308
  readonly "templates/readme-facts.json": "3155f9b36f98db20d588f68358d0152aa24ad395c1cb62c39a72d2084abb6ddd";
309
- readonly "templates/remotion-cover/package-lock.json": "09fb65f7b5a5088e4f568e6e444a0606f220116d3b3eae0d9ccbec17573219b1";
309
+ readonly "templates/remotion-cover/package-lock.json": "586931a24fffb1117eb5b04f5a4917b5c099f0c040f6c04d278e2ba3c39f1f77";
310
310
  readonly "templates/remotion-cover/package.json": "88448fd7021c32527fb36ee4d6a709f32f1289eae126d9532fca033c4b2debeb";
311
311
  readonly "templates/remotion-cover/src/ReadmeCover.tsx": "bdaddbadcddd99102e2f915eb16eaa1d1def9d8aacd777772afc6d66d106443d";
312
312
  readonly "templates/remotion-cover/src/Root.tsx": "0b3e22dd556216d67bbbca4745f5b041c9fc2a986ca3ba9945bf4b916a51e004";
@@ -804,8 +804,8 @@ export declare const PPTX_PAYLOAD_HASHES: {
804
804
  readonly "references/tonalities/paper.md": "39973f22a4021c5dc1a4210ef123d7444b2dd279352418314caaabb8ae5d669e";
805
805
  readonly "references/tonalities/signal.md": "3c52945f7c4d513b97ae382b6bd544f9cf1daf5780b6f462ac947284b1d38285";
806
806
  readonly "references/tonalities/studio.md": "cca577f4458a6be2306995d996dd99e2d605b7f2a80cbc256c7eff776b65858f";
807
- readonly "runtime/package-lock.json": "73cd3f54d979460757603c8a44c395e777cc0655d7f1c54dfb9512a9c77b8acd";
808
- readonly "runtime/package.json": "700e183641eff75aa87b963d68d96b9c8e0bb21516a3b413c94b70bea10fbd55";
807
+ readonly "runtime/package-lock.json": "67b19a8431f408ab6c75eeb6dd658850089e13f072bf475ae72a2ae79d4e1687";
808
+ readonly "runtime/package.json": "a92c2edf9320ce49043317cb4c8437134a8473bd935f1b769fc595303fb1f879";
809
809
  readonly "runtime/requirements.in": "893e4232e7e69e731053a8c3b3383eb22fb3f82affd6d96ad96d3a8ef8321656";
810
810
  readonly "runtime/requirements.lock": "79028c622048b4a43f747a2bee14ce838b7092aa7eff39c0c725463394a2c85d";
811
811
  readonly "scripts/check_ooxml.py": "52078a351f5f999e2871e9d4136c195f396dcfee45fea6cb6d2a84f07bd837a2";
@@ -831,7 +831,7 @@ export declare const PPTX_PAYLOAD_HASHES: {
831
831
  readonly "scripts/office-run.mjs": "272f9bd74db9456fe5f5cce8f1dbf04fac60469f470a41c6571afafc5f444508";
832
832
  readonly "scripts/package.json": "dbf8353f77358bc12169b7bb7301e1978d5b503e002ee927229a8993672818fc";
833
833
  readonly "scripts/qa_deck.py": "dbde757b72dffe3f5b31def40dc5f7b92444a2b768ac3c91879fc959c30a2edc";
834
- readonly "scripts/validate_pptx.py": "24032616fdfac18f42839667c601d12fd7ea425e8230b96ef3681ea290f2755a";
834
+ readonly "scripts/validate_pptx.py": "2d3ddd0fd2564dab93f1bd74832c602d8df4f31e2856fd8a3b1e2c3e089d4ec4";
835
835
  readonly "specs/markdown-slide-spec-v1.md": "eb9b04d070d9f2774746e65a34e5e6833fefd097ea7e01fc32327934ca8ee42b";
836
836
  readonly "specs/markdown-slide-spec-v2.md": "3a7a91dfb21418711d5ad28f7a542603bc2f145051950478be0d2107f7fa5458";
837
837
  readonly "specs/slide-ast-v1.schema.json": "d6d244bd30b6747645bd4a4f81cf0e2a3d12aa5aa4d0d11f2fb8b5f93dca1187";