holycodex 0.7.0-dev.29549907491.1 → 0.7.0-dev.29579145024.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 +77 -37
  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.29549907491.1";
10
+ var VERSION = "0.7.0-dev.29579145024.1";
11
11
  var SKILLS = [
12
12
  "ast-grep",
13
13
  "caveman",
@@ -97,7 +97,7 @@ function effectiveMcpServers(platform) {
97
97
  };
98
98
  }
99
99
  function requiredPackageRuntimes(platform) {
100
- return platform === "win32" ? GENERATED_RUNTIMES : GENERATED_RUNTIMES.filter((file) => file !== "git-bash.js" && file !== "git-bash-resolver.js");
100
+ return platform === "win32" ? GENERATED_RUNTIMES : GENERATED_RUNTIMES.filter((file) => file !== "git-bash.js");
101
101
  }
102
102
  //#endregion
103
103
  //#region packages/git-bash-mcp/src/git-bash-resolver.ts
@@ -316,6 +316,53 @@ function rootTomlString(input, key) {
316
316
  return;
317
317
  }
318
318
  }
319
+ function rootTomlStringArray(input, key) {
320
+ const table = TOML_TABLE.exec(input);
321
+ const root = table === null ? input : input.slice(0, table.index);
322
+ const assignment = new RegExp(String.raw`^[ \t]*${escapeRegExp(key)}[ \t]*=`, "m").exec(root);
323
+ if (assignment === null) return void 0;
324
+ const start = root.indexOf("[", assignment.index + assignment[0].length);
325
+ if (start < 0) return void 0;
326
+ const items = [];
327
+ let quote;
328
+ let raw = "";
329
+ let escaped = false;
330
+ let comment = false;
331
+ for (let index = start + 1; index < root.length; index += 1) {
332
+ const character = root[index];
333
+ if (comment) {
334
+ if (character === "\n") comment = false;
335
+ continue;
336
+ }
337
+ if (quote === "\"") {
338
+ if (escaped) {
339
+ raw += character;
340
+ escaped = false;
341
+ } else if (character === "\\") {
342
+ raw += character;
343
+ escaped = true;
344
+ } else if (character === "\"") {
345
+ const parsed = JSON.parse(`"${raw}"`);
346
+ if (typeof parsed !== "string") return void 0;
347
+ items.push(parsed);
348
+ quote = void 0;
349
+ raw = "";
350
+ } else raw += character;
351
+ continue;
352
+ }
353
+ if (quote === "'") {
354
+ if (character === "'") {
355
+ items.push(raw);
356
+ quote = void 0;
357
+ raw = "";
358
+ } else raw += character;
359
+ continue;
360
+ }
361
+ if (character === "#") comment = true;
362
+ else if (character === "\"" || character === "'") quote = character;
363
+ else if (character === "]") return items;
364
+ }
365
+ }
319
366
  function escapeRegExp(value) {
320
367
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
321
368
  }
@@ -358,7 +405,8 @@ async function startContext7(platform) {
358
405
  });
359
406
  const diagnostic = `${result.stdout}\n${result.stderr}`.trim() || result.error || "";
360
407
  return {
361
- ok: result.matched,
408
+ ok: result.matched && !result.timedOut,
409
+ timedOut: result.timedOut,
362
410
  packageFailure: /(?:404|failed to resolve|package.*not found|error: GET)/i.test(diagnostic),
363
411
  detail: diagnostic
364
412
  };
@@ -378,6 +426,14 @@ function check(id, status, code, detail, fix) {
378
426
  ...fix === void 0 ? {} : { fix }
379
427
  };
380
428
  }
429
+ function mcpConfigMatches(actual, expected) {
430
+ const expectedEntries = Object.entries(expected);
431
+ if (Object.keys(actual).length !== expectedEntries.length) return false;
432
+ return expectedEntries.every(([key, expectedValue]) => {
433
+ const actualValue = actual[key];
434
+ return Array.isArray(expectedValue) ? Array.isArray(actualValue) && actualValue.length === expectedValue.length && actualValue.every((value, index) => value === expectedValue[index]) : actualValue === expectedValue;
435
+ });
436
+ }
381
437
  async function missingFiles(root, paths) {
382
438
  const missing = [];
383
439
  for (const path of paths) try {
@@ -424,11 +480,16 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
424
480
  }
425
481
  const servers = mcp?.mcpServers;
426
482
  const requiredMcps = runtime.platform === "win32" ? ["git_bash", "lsp"] : ["lsp"];
427
- for (const name of requiredMcps) checks.push(servers?.[name] === void 0 ? check(`mcp-${name}`, "error", "missing-required-mcp", `${name} is not configured.`, "Reinstall HolyCodex.") : check(`mcp-${name}`, "ok", "required-mcp-ready", `${name} is configured locally.`));
483
+ const expectedMcps = effectiveMcpServers(runtime.platform);
484
+ for (const name of requiredMcps) {
485
+ const configured = servers?.[name];
486
+ const expected = expectedMcps[name];
487
+ checks.push(configured === void 0 ? check(`mcp-${name}`, "error", "missing-required-mcp", `${name} is not configured.`, "Reinstall HolyCodex.") : !mcpConfigMatches(configured, expected) ? check(`mcp-${name}`, "error", "invalid-required-mcp-config", `${name} configuration is stale or contains unsupported settings.`, "Reinstall HolyCodex.") : check(`mcp-${name}`, "ok", "required-mcp-ready", `${name} is configured locally.`));
488
+ }
428
489
  const gitBashConfig = servers?.git_bash;
429
490
  if (runtime.platform === "win32" && gitBashConfig !== void 0) {
430
491
  const expected = effectiveMcpServers("win32").git_bash;
431
- checks.push(JSON.stringify(gitBashConfig) === JSON.stringify(expected) ? check("mcp-git_bash-config", "ok", "git-bash-mcp-config-ready", "Git Bash MCP exposes only run through the supported allowlist.") : check("mcp-git_bash-config", "error", "invalid-git-bash-mcp-config", "Git Bash MCP command or enabled_tools configuration is stale.", "Reinstall HolyCodex."));
492
+ checks.push(mcpConfigMatches(gitBashConfig, expected) ? check("mcp-git_bash-config", "ok", "git-bash-mcp-config-ready", "Git Bash MCP exposes only run through the supported allowlist.") : check("mcp-git_bash-config", "error", "invalid-git-bash-mcp-config", "Git Bash MCP command or enabled_tools configuration is stale.", "Reinstall HolyCodex."));
432
493
  } else if (runtime.platform !== "win32" && gitBashConfig !== void 0) checks.push(check("mcp-git_bash-config", "error", "unexpected-git-bash-mcp", "Git Bash MCP must not be installed on non-Windows platforms.", "Reinstall HolyCodex for this platform."));
433
494
  const context7 = servers?.context7;
434
495
  const obsoleteAuth = context7 !== void 0 && [
@@ -448,7 +509,7 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
448
509
  checks.push(bunx.ok ? check("bunx", "ok", "bunx-ready", `bunx ${bunx.output || "available"}.`) : check("bunx", "error", "missing-bunx", "bunx is unavailable.", "Repair the Bun installation."));
449
510
  if (bun.ok && bunx.ok && checks.some((item) => item.code === "local-context7-config")) {
450
511
  const started = await runtime.context7();
451
- checks.push(started.ok ? check("context7-startup", "ok", "context7-healthy", "Context7 completed a bounded MCP handshake.") : started.packageFailure ? check("context7-startup", "error", "context7-package-resolution-failed", started.detail || "Context7 package resolution failed.", "Check network/package availability.") : check("context7-startup", "error", "context7-startup-failed", started.detail || "Context7 did not complete an MCP handshake within 15 seconds.", runtime.platform === "win32" ? "Run bunx @upstash/context7-mcp in Git Bash." : "Run bunx @upstash/context7-mcp in the native shell."));
512
+ checks.push(started.ok && !started.timedOut ? check("context7-startup", "ok", "context7-healthy", "Context7 completed a bounded MCP handshake.") : started.packageFailure ? check("context7-startup", "error", "context7-package-resolution-failed", started.detail || "Context7 package resolution failed.", "Check network/package availability.") : check("context7-startup", "error", "context7-startup-failed", started.detail || "Context7 did not complete an MCP handshake within 15 seconds.", runtime.platform === "win32" ? "Run bunx @upstash/context7-mcp in Git Bash." : "Run bunx @upstash/context7-mcp in the native shell."));
452
513
  }
453
514
  if (runtime.platform === "win32") {
454
515
  const gitBash = runtime.gitBash();
@@ -463,7 +524,7 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
463
524
  const mode = autonomy(config);
464
525
  checks.push(mode === "unknown" ? check("autonomy", "error", "invalid-autonomy-config", "Approval, sandbox, and network settings do not match a supported mode.", "Rerun install with the intended autonomy flag.") : mode === "dangerous" ? check("autonomy", "warning", "dangerous-autonomy", "Explicit dangerous autonomy is active; workspace containment is removed.") : check("autonomy", "ok", `${mode}-ready`, mode === "safe-workspace" ? "Safe workspace autonomy is active." : "Approval-free workspace autonomy is active."));
465
526
  checks.push(tableBoolean(config, "features", "default_mode_request_user_input") === true ? check("user-input", "ok", "user-input-ready", "default_mode_request_user_input is enabled.") : check("user-input", "error", "user-input-disabled", "default_mode_request_user_input is not enabled.", "Rerun holycodex install."));
466
- checks.push(/^\s*status_line\s*=\s*\[[\s\S]*?context-remaining[\s\S]*?]/m.test(config) ? check("context-visibility", "warning", "context-visible-support-unverified", "status_line includes context-remaining. Current official Codex config documents this item, but publishes no minimum compatible Codex version.") : check("context-visibility", "error", "context-hidden", "status_line does not include context-remaining.", "Rerun holycodex install."));
527
+ checks.push(rootTomlStringArray(config, "status_line")?.includes("context-remaining") === true ? check("context-visibility", "warning", "context-visible-support-unverified", "status_line includes context-remaining. Current official Codex config documents this item, but publishes no minimum compatible Codex version.") : check("context-visibility", "error", "context-hidden", "status_line does not include context-remaining.", "Rerun holycodex install."));
467
528
  const codex = await runtime.command("codex", ["--version"]);
468
529
  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."));
469
530
  const agentModelFailures = [];
@@ -580,37 +641,10 @@ function preserveManagedRootPreferences(input, base) {
580
641
  }
581
642
  function mergedStatusLine(original) {
582
643
  if (original === void 0) return "[\"model-with-reasoning\", \"context-remaining\", \"current-dir\"]";
583
- const items = [...tomlArrayValue(original.slice(original.indexOf("=") + 1)).matchAll(/"((?:\\.|[^"\\])*)"|'([^']*)'/g)].map((match) => {
584
- if (match[1] === void 0) return match[2] ?? "";
585
- const parsed = JSON.parse(`"${match[1]}"`);
586
- if (typeof parsed !== "string") throw new Error("Invalid status-line string");
587
- return parsed;
588
- });
644
+ const items = rootTomlStringArray(original, "status_line") ?? [];
589
645
  if (!items.includes("context-remaining")) items.push("context-remaining");
590
646
  return `[${items.map((item) => JSON.stringify(item)).join(", ")}]`;
591
647
  }
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
- }
614
648
  function installConfig(input, mode, _platform) {
615
649
  const base = preserveManagedRootPreferences(input, removeLegacyOmo(removeManaged(input)));
616
650
  const firstTable = base.search(/^\s*\[/m);
@@ -792,7 +826,7 @@ async function writePlatformAgents(root, platform) {
792
826
  if (platform === "win32") return;
793
827
  await Promise.all(AGENTS.map(async (agent) => {
794
828
  const path = join(root, `${agent}.toml`);
795
- await atomicWrite(path, (await readText(path)).replace(`${WINDOWS_SHELL_POLICY}\n\n`, ""));
829
+ await atomicWrite(path, (await readText(path)).replace(`${WINDOWS_SHELL_POLICY}\r\n\r\n`, "").replace(`${WINDOWS_SHELL_POLICY}\n\n`, ""));
796
830
  }));
797
831
  }
798
832
  async function cleanup(_options) {
@@ -912,5 +946,11 @@ async function main() {
912
946
  }
913
947
  process$1.stdout.write(options.json ? `${JSON.stringify(result)}\n` : renderRunResult(result, stdoutColor));
914
948
  }
915
- await main();
949
+ try {
950
+ await main();
951
+ } catch (error) {
952
+ const stderrColor = supportsColor(process$1.stderr.isTTY, process$1.env.NO_COLOR);
953
+ process$1.stderr.write(renderError(error instanceof Error ? error.message : String(error), stderrColor));
954
+ process$1.exitCode = 1;
955
+ }
916
956
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holycodex",
3
- "version": "0.7.0-dev.29549907491.1",
3
+ "version": "0.7.0-dev.29579145024.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.29549907491.1"
42
+ "@holycodex/plugin": "0.7.0-dev.29579145024.1"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=20"