@litfamily/litcodex 1.0.17 → 1.0.19
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 +46 -147
- package/README.md +46 -150
- package/dist/auto-update.d.ts +2 -1
- package/dist/auto-update.js +2 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +85 -5
- package/dist/config-migration/multi-agent-v2-guard.js +10 -21
- package/dist/config-migration/root-settings.js +30 -31
- package/dist/config-migration/toml-lines.d.ts +12 -0
- package/dist/config-migration/toml-lines.js +113 -0
- package/dist/config-migration/toml-shape.js +8 -15
- package/dist/install/codex.js +6 -3
- package/dist/install/doctor-render.js +19 -0
- package/dist/install/doctor-tui.d.ts +7 -0
- package/dist/install/doctor-tui.js +65 -0
- package/dist/install/doctor.js +2 -0
- package/dist/install/generated-skill-payload-hashes.d.ts +26 -25
- package/dist/install/generated-skill-payload-hashes.js +26 -25
- package/dist/install/index.d.ts +6 -1
- package/dist/install/index.js +16 -2
- package/dist/install/office-runtime.d.ts +1 -0
- package/dist/install/office-runtime.js +2 -2
- package/dist/install/types.d.ts +10 -0
- package/dist/install/uninstall.d.ts +2 -0
- package/dist/install/uninstall.js +12 -1
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
- package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.d.ts +16 -1
- package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.js +99 -13
- 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/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
- package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.d.ts +6 -0
- package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.js +10 -29
- 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/hooks/hooks.json +1 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/scripts/docx_design.py +1 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/tonalities/brief.yaml +0 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/tonalities/journal.yaml +0 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/tonalities/manual.yaml +0 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/tonalities/memo.yaml +0 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/tonalities/proposal.yaml +0 -1
- package/marketplace/plugins/litcodex/skills/lit-docx/templates/tonalities/report.yaml +0 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/FORBIDDEN_TERMS.json +55 -0
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/atlas.md +4 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/chalk.md +4 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/gazette.md +4 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/ledger.md +6 -6
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/night.md +4 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/paper.md +4 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/signal.md +4 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/studio.md +4 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/lib/template-registry.js +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/validate_pptx.py +13 -3
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +0 -13
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +0 -13
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +0 -13
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -14
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/night/pack.yaml +0 -13
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/paper/pack.yaml +0 -13
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/signal/pack.yaml +0 -13
- package/marketplace/plugins/litcodex/skills/lit-pptx/templates/tonalities/studio/pack.yaml +0 -13
- package/node_modules/@litcodex/lit-loop/README.md +1 -1
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/package.json +12 -4
- 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(
|
|
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
|
-
|
|
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 = {
|
|
@@ -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
|
-
/**
|
|
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.
|
|
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 (
|
|
146
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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 (
|
|
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
|
|
119
|
+
if (!replaced) {
|
|
129
120
|
output.push(`${key} = ${value}`);
|
|
130
121
|
}
|
|
131
122
|
return output.join("\n");
|
|
132
123
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
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 (
|
|
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
|
-
|
|
50
|
-
|
|
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
|
package/dist/install/codex.js
CHANGED
|
@@ -88,9 +88,12 @@ export function findCodexBinary(env, fs, platform = process.platform) {
|
|
|
88
88
|
}
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
|
+
// The first listing after an install can refresh Codex's remote catalog and take several seconds; a short
|
|
92
|
+
// timeout turns that slow answer into a false "not registered" / "not installed".
|
|
93
|
+
const LIST_PROBE_TIMEOUT_MS = 30_000;
|
|
91
94
|
/** True if `codex plugin marketplace list` stdout names the LitCodex marketplace. Read-only. */
|
|
92
95
|
export function probeMarketplaceRegistered(codexBin, spawn) {
|
|
93
|
-
const res = spawn(codexBin, ["plugin", "marketplace", "list"], { stdio: "pipe", timeout:
|
|
96
|
+
const res = spawn(codexBin, ["plugin", "marketplace", "list"], { stdio: "pipe", timeout: LIST_PROBE_TIMEOUT_MS });
|
|
94
97
|
if (res.error || res.status !== 0) {
|
|
95
98
|
// "cannot determine" → "not present" (the add step is the authoritative source of truth).
|
|
96
99
|
return false;
|
|
@@ -101,7 +104,7 @@ export function probeMarketplaceRegistered(codexBin, spawn) {
|
|
|
101
104
|
export function probeMarketplaceRegistration(codexBin, spawn) {
|
|
102
105
|
const res = spawn(codexBin, ["plugin", "marketplace", "list", "--json"], {
|
|
103
106
|
stdio: "pipe",
|
|
104
|
-
timeout:
|
|
107
|
+
timeout: LIST_PROBE_TIMEOUT_MS,
|
|
105
108
|
});
|
|
106
109
|
if (res.error || res.status !== 0)
|
|
107
110
|
return null;
|
|
@@ -142,7 +145,7 @@ const PLUGIN_LIST_MAX_BUFFER = 64 * 1024 * 1024;
|
|
|
142
145
|
export function probePluginInstalled(codexBin, spawn) {
|
|
143
146
|
const res = spawn(codexBin, ["plugin", "list"], {
|
|
144
147
|
stdio: "pipe",
|
|
145
|
-
timeout:
|
|
148
|
+
timeout: LIST_PROBE_TIMEOUT_MS,
|
|
146
149
|
maxBuffer: PLUGIN_LIST_MAX_BUFFER,
|
|
147
150
|
});
|
|
148
151
|
if (res.error || res.status !== 0) {
|
|
@@ -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
|
+
}
|
package/dist/install/doctor.js
CHANGED
|
@@ -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
|
};
|