holycodex 0.7.0-dev.29549405174.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 +25 -12
  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.29549405174.1";
10
+ var VERSION = "0.7.0-dev.29549907491.1";
11
11
  var SKILLS = [
12
12
  "ast-grep",
13
13
  "caveman",
@@ -301,6 +301,25 @@ function outputText(state) {
301
301
  return state.truncated ? `${state.head}${TRUNCATED_MARKER}${state.tail}` : state.head;
302
302
  }
303
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
304
323
  //#region packages/cli/src/doctor.ts
305
324
  async function runCommand(name, args, platform) {
306
325
  const result = await runManagedProcess({
@@ -368,17 +387,14 @@ async function missingFiles(root, paths) {
368
387
  }
369
388
  return missing;
370
389
  }
371
- function rootString(config, key) {
372
- return new RegExp(`^\\s*${key}\\s*=\\s*"([^"]+)"`, "m").exec(config)?.[1];
373
- }
374
390
  function tableBoolean(config, table, key) {
375
391
  const body = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*$([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(config)?.[1];
376
392
  const value = body === void 0 ? void 0 : new RegExp(`^\\s*${key}\\s*=\\s*(true|false)`, "m").exec(body)?.[1];
377
393
  return value === void 0 ? void 0 : value === "true";
378
394
  }
379
395
  function autonomy(config) {
380
- const approval = rootString(config, "approval_policy");
381
- const sandbox = rootString(config, "sandbox_mode");
396
+ const approval = rootTomlString(config, "approval_policy");
397
+ const sandbox = rootTomlString(config, "sandbox_mode");
382
398
  const network = tableBoolean(config, "sandbox_workspace_write", "network_access");
383
399
  if (approval === "on-request" && sandbox === "workspace-write" && network === true) return "safe-workspace";
384
400
  if (approval === "never" && sandbox === "workspace-write" && network === true) return "autonomous-workspace";
@@ -454,7 +470,7 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
454
470
  for (const agent of AGENTS) try {
455
471
  const text = await readFile(join(agentRoot, `${agent}.toml`), "utf8");
456
472
  const expected = AGENT_MODELS[agent];
457
- 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);
458
474
  } catch {
459
475
  agentModelFailures.push(agent);
460
476
  }
@@ -744,8 +760,8 @@ async function readAgentPreferences(root) {
744
760
  const preferences = {};
745
761
  await Promise.all(AGENTS.map(async (agent) => {
746
762
  const source = await readText(join(root, `${agent}.toml`));
747
- const model = tomlString(source, "model");
748
- const reasoningEffort = tomlString(source, "model_reasoning_effort");
763
+ const model = rootTomlString(source, "model");
764
+ const reasoningEffort = rootTomlString(source, "model_reasoning_effort");
749
765
  if (model === void 0 && reasoningEffort === void 0) return;
750
766
  if (!MANAGED_AGENT_MODEL_HISTORY[agent].some((item) => item.model === model && item.reasoningEffort === reasoningEffort)) preferences[agent] = {
751
767
  ...model === void 0 ? {} : { model },
@@ -765,9 +781,6 @@ async function preserveAgentPreferences(root, preferences) {
765
781
  await atomicWrite(path, source);
766
782
  }));
767
783
  }
768
- function tomlString(input, key) {
769
- return new RegExp(`^${key}\\s*=\\s*"([^"]+)"`, "m").exec(input)?.[1];
770
- }
771
784
  function replaceTomlString(input, key, value) {
772
785
  return input.replace(new RegExp(`^${key}\\s*=.*$`, "m"), `${key} = ${JSON.stringify(value)}`);
773
786
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holycodex",
3
- "version": "0.7.0-dev.29549405174.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.29549405174.1"
42
+ "@holycodex/plugin": "0.7.0-dev.29549907491.1"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=20"