holycodex 0.7.0-dev.29548804255.1 → 0.7.0-dev.29549907491.1

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 (2) hide show
  1. package/dist/cli.js +63 -20
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import { existsSync } from "node:fs";
7
7
  import { pluginRoot } from "@holycodex/plugin";
8
8
  import { Buffer } from "node:buffer";
9
9
  //#region packages/cli/src/catalog.ts
10
- var VERSION = "0.7.0-dev.29548804255.1";
10
+ var VERSION = "0.7.0-dev.29549907491.1";
11
11
  var SKILLS = [
12
12
  "ast-grep",
13
13
  "caveman",
@@ -181,7 +181,11 @@ function missing(checkedPaths) {
181
181
  //#endregion
182
182
  //#region packages/mcp-stdio-core/src/process.ts
183
183
  var TRUNCATED_MARKER = "\n... diagnostic output truncated ...\n";
184
- async function runManagedProcess(input) {
184
+ var defaultManagedProcessRuntime = {
185
+ terminationGraceMs: 2e3,
186
+ kill: killProcessTree
187
+ };
188
+ async function runManagedProcess(input, runtime = defaultManagedProcessRuntime) {
185
189
  return await new Promise((resolve) => {
186
190
  const child = spawn(input.command, [...input.args], {
187
191
  ...input.cwd === void 0 ? {} : { cwd: input.cwd },
@@ -207,12 +211,12 @@ async function runManagedProcess(input) {
207
211
  let timedOut = false;
208
212
  let matched = false;
209
213
  let settled = false;
210
- let terminationFallback;
214
+ let forceKillTimeout;
211
215
  const finish = (exitCode, error) => {
212
216
  if (settled) return;
213
217
  settled = true;
214
218
  clearTimeout(timeout);
215
- if (terminationFallback !== void 0) clearTimeout(terminationFallback);
219
+ if (forceKillTimeout !== void 0) clearTimeout(forceKillTimeout);
216
220
  resolve({
217
221
  exitCode,
218
222
  stdout: outputText(stdout),
@@ -224,9 +228,12 @@ async function runManagedProcess(input) {
224
228
  });
225
229
  };
226
230
  const terminate = () => {
227
- killProcessTree(child, input.platform);
228
- terminationFallback ??= setTimeout(() => finish(child.exitCode), 2e3);
229
- terminationFallback.unref();
231
+ if (forceKillTimeout !== void 0) return;
232
+ runtime.kill(child, input.platform, "SIGTERM");
233
+ forceKillTimeout = setTimeout(() => {
234
+ runtime.kill(child, input.platform, "SIGKILL");
235
+ }, runtime.terminationGraceMs);
236
+ forceKillTimeout.unref();
230
237
  };
231
238
  const inspectMatch = () => {
232
239
  if (matched || input.matchOutput === void 0) return;
@@ -294,6 +301,25 @@ function outputText(state) {
294
301
  return state.truncated ? `${state.head}${TRUNCATED_MARKER}${state.tail}` : state.head;
295
302
  }
296
303
  //#endregion
304
+ //#region packages/cli/src/toml.ts
305
+ var TOML_TABLE = /^[ \t]*(?:\[[^\]\r\n]+\]|\[\[[^\]\r\n]+\]\])[ \t]*(?:#.*)?$/m;
306
+ function rootTomlString(input, key) {
307
+ const table = TOML_TABLE.exec(input);
308
+ const root = table === null ? input : input.slice(0, table.index);
309
+ const match = new RegExp(String.raw`^[ \t]*${escapeRegExp(key)}[ \t]*=[ \t]*(?:"((?:\\.|[^"\\\r\n])*)"|'([^'\r\n]*)')[ \t]*(?:#.*)?$`, "m").exec(root);
310
+ if (match === null) return void 0;
311
+ if (match[2] !== void 0) return match[2];
312
+ try {
313
+ const parsed = JSON.parse(`"${match[1] ?? ""}"`);
314
+ return typeof parsed === "string" ? parsed : void 0;
315
+ } catch {
316
+ return;
317
+ }
318
+ }
319
+ function escapeRegExp(value) {
320
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
321
+ }
322
+ //#endregion
297
323
  //#region packages/cli/src/doctor.ts
298
324
  async function runCommand(name, args, platform) {
299
325
  const result = await runManagedProcess({
@@ -361,17 +387,14 @@ async function missingFiles(root, paths) {
361
387
  }
362
388
  return missing;
363
389
  }
364
- function rootString(config, key) {
365
- return new RegExp(`^\\s*${key}\\s*=\\s*"([^"]+)"`, "m").exec(config)?.[1];
366
- }
367
390
  function tableBoolean(config, table, key) {
368
391
  const body = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*$([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(config)?.[1];
369
392
  const value = body === void 0 ? void 0 : new RegExp(`^\\s*${key}\\s*=\\s*(true|false)`, "m").exec(body)?.[1];
370
393
  return value === void 0 ? void 0 : value === "true";
371
394
  }
372
395
  function autonomy(config) {
373
- const approval = rootString(config, "approval_policy");
374
- const sandbox = rootString(config, "sandbox_mode");
396
+ const approval = rootTomlString(config, "approval_policy");
397
+ const sandbox = rootTomlString(config, "sandbox_mode");
375
398
  const network = tableBoolean(config, "sandbox_workspace_write", "network_access");
376
399
  if (approval === "on-request" && sandbox === "workspace-write" && network === true) return "safe-workspace";
377
400
  if (approval === "never" && sandbox === "workspace-write" && network === true) return "autonomous-workspace";
@@ -381,6 +404,7 @@ function autonomy(config) {
381
404
  async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex"), runtime = defaultRuntime$1) {
382
405
  const checks = [];
383
406
  const pluginRoot = join(home, "plugins", "cache", "holycodex", "holycodex", VERSION);
407
+ const agentRoot = join(home, "holycodex", "agents");
384
408
  const configPath = join(home, "config.toml");
385
409
  const missing = await missingFiles(pluginRoot, [
386
410
  ".codex-plugin/plugin.json",
@@ -444,9 +468,9 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
444
468
  checks.push(codex.ok ? check("codex", "ok", "codex-version", codex.output || "Codex is available.") : check("codex", "warning", "codex-version-unavailable", "Codex version could not be read; status-line compatibility cannot be independently confirmed."));
445
469
  const agentModelFailures = [];
446
470
  for (const agent of AGENTS) try {
447
- const text = await readFile(join(pluginRoot, "agents", `${agent}.toml`), "utf8");
471
+ const text = await readFile(join(agentRoot, `${agent}.toml`), "utf8");
448
472
  const expected = AGENT_MODELS[agent];
449
- if (!text.includes(`model = "${expected.model}"`) || !text.includes(`model_reasoning_effort = "${expected.reasoningEffort}"`)) agentModelFailures.push(agent);
473
+ if (rootTomlString(text, "model") !== expected.model || rootTomlString(text, "model_reasoning_effort") !== expected.reasoningEffort) agentModelFailures.push(agent);
450
474
  } catch {
451
475
  agentModelFailures.push(agent);
452
476
  }
@@ -556,7 +580,7 @@ function preserveManagedRootPreferences(input, base) {
556
580
  }
557
581
  function mergedStatusLine(original) {
558
582
  if (original === void 0) return "[\"model-with-reasoning\", \"context-remaining\", \"current-dir\"]";
559
- const items = [...original.slice(original.indexOf("=") + 1).matchAll(/"((?:\\.|[^"\\])*)"|'([^']*)'/g)].map((match) => {
583
+ const items = [...tomlArrayValue(original.slice(original.indexOf("=") + 1)).matchAll(/"((?:\\.|[^"\\])*)"|'([^']*)'/g)].map((match) => {
560
584
  if (match[1] === void 0) return match[2] ?? "";
561
585
  const parsed = JSON.parse(`"${match[1]}"`);
562
586
  if (typeof parsed !== "string") throw new Error("Invalid status-line string");
@@ -565,6 +589,28 @@ function mergedStatusLine(original) {
565
589
  if (!items.includes("context-remaining")) items.push("context-remaining");
566
590
  return `[${items.map((item) => JSON.stringify(item)).join(", ")}]`;
567
591
  }
592
+ function tomlArrayValue(input) {
593
+ const start = input.indexOf("[");
594
+ if (start < 0) return input;
595
+ let quote;
596
+ let escaped = false;
597
+ for (let index = start + 1; index < input.length; index += 1) {
598
+ const character = input[index];
599
+ if (quote === "\"") {
600
+ if (escaped) escaped = false;
601
+ else if (character === "\\") escaped = true;
602
+ else if (character === "\"") quote = void 0;
603
+ continue;
604
+ }
605
+ if (quote === "'") {
606
+ if (character === "'") quote = void 0;
607
+ continue;
608
+ }
609
+ if (character === "\"" || character === "'") quote = character;
610
+ else if (character === "]") return input.slice(start, index + 1);
611
+ }
612
+ return input.slice(start);
613
+ }
568
614
  function installConfig(input, mode, _platform) {
569
615
  const base = preserveManagedRootPreferences(input, removeLegacyOmo(removeManaged(input)));
570
616
  const firstTable = base.search(/^\s*\[/m);
@@ -714,8 +760,8 @@ async function readAgentPreferences(root) {
714
760
  const preferences = {};
715
761
  await Promise.all(AGENTS.map(async (agent) => {
716
762
  const source = await readText(join(root, `${agent}.toml`));
717
- const model = tomlString(source, "model");
718
- const reasoningEffort = tomlString(source, "model_reasoning_effort");
763
+ const model = rootTomlString(source, "model");
764
+ const reasoningEffort = rootTomlString(source, "model_reasoning_effort");
719
765
  if (model === void 0 && reasoningEffort === void 0) return;
720
766
  if (!MANAGED_AGENT_MODEL_HISTORY[agent].some((item) => item.model === model && item.reasoningEffort === reasoningEffort)) preferences[agent] = {
721
767
  ...model === void 0 ? {} : { model },
@@ -735,9 +781,6 @@ async function preserveAgentPreferences(root, preferences) {
735
781
  await atomicWrite(path, source);
736
782
  }));
737
783
  }
738
- function tomlString(input, key) {
739
- return new RegExp(`^${key}\\s*=\\s*"([^"]+)"`, "m").exec(input)?.[1];
740
- }
741
784
  function replaceTomlString(input, key, value) {
742
785
  return input.replace(new RegExp(`^${key}\\s*=.*$`, "m"), `${key} = ${JSON.stringify(value)}`);
743
786
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holycodex",
3
- "version": "0.7.0-dev.29548804255.1",
3
+ "version": "0.7.0-dev.29549907491.1",
4
4
  "description": "Lean Codex-only agent toolkit installer and doctor",
5
5
  "keywords": [
6
6
  "agents",
@@ -39,7 +39,7 @@
39
39
  "prepack": "vp run --workspace-root build"
40
40
  },
41
41
  "dependencies": {
42
- "@holycodex/plugin": "0.7.0-dev.29548804255.1"
42
+ "@holycodex/plugin": "0.7.0-dev.29549907491.1"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=20"