@minhpnq1807/contextos 0.5.24 → 0.5.25

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.25
4
+
5
+ - **Fix Windows JSON parse crash:** All `readJsonFile`/`readHooksFile` helpers now catch corrupt JSON and warn instead of crashing, allowing fresh config to be generated automatically.
6
+ - **Fix Windows shell quoting:** `shellQuote` now uses double-quotes on Windows (`process.platform === "win32"`) instead of POSIX single-quotes which are not recognized by cmd.exe/PowerShell.
7
+ - **Fix Codex CLI invocation on Windows:** `runCodex`/`tryRunCodex` now pass `shell: true` to `execFileSync` so Windows can resolve `codex.cmd` via PATH.
8
+
3
9
  ## 0.5.24
4
10
 
5
11
  - **Interactive agent selection:** Replaces the comma-separated text input in `ctx setup` with an interactive multi-select prompt — use ↑/↓ to navigate, Space to toggle agents on/off, and Enter to confirm.
package/bin/ctx.js CHANGED
@@ -332,7 +332,7 @@ async function warmInstallEmbeddings() {
332
332
 
333
333
  function tryRunCodex(args) {
334
334
  try {
335
- execFileSync("codex", args, { stdio: "ignore" });
335
+ execFileSync("codex", args, { stdio: "ignore", shell: true });
336
336
  } catch {
337
337
  // Best effort cleanup for repeat installs.
338
338
  }
@@ -340,7 +340,7 @@ function tryRunCodex(args) {
340
340
 
341
341
  function runCodex(args) {
342
342
  try {
343
- execFileSync("codex", args, { stdio: "inherit" });
343
+ execFileSync("codex", args, { stdio: "inherit", shell: true });
344
344
  } catch (error) {
345
345
  const status = typeof error.status === "number" ? error.status : 1;
346
346
  throw new Error(`codex ${args.join(" ")} failed with exit code ${status}. Make sure Codex CLI is installed and authenticated.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minhpnq1807/contextos",
3
- "version": "0.5.24",
3
+ "version": "0.5.25",
4
4
  "description": "Task-aware AGENTS.md context injection and compliance reporting for Codex, Claude Code, and Antigravity.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,14 +3,23 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
 
5
5
  function shellQuote(value) {
6
- return `'${String(value).replaceAll("'", "'\\''")}'`;
6
+ const s = String(value);
7
+ if (process.platform === "win32") {
8
+ return `"${s.replaceAll('"', '\\"')}"`;
9
+ }
10
+ return `'${s.replaceAll("'", "'\\''")}'`;
7
11
  }
8
12
 
9
13
  function readJsonFile(filePath, fallback) {
10
14
  if (!fs.existsSync(filePath)) return fallback;
11
15
  const raw = fs.readFileSync(filePath, "utf8").trim();
12
16
  if (!raw) return fallback;
13
- return JSON.parse(raw);
17
+ try {
18
+ return JSON.parse(raw);
19
+ } catch {
20
+ console.warn(`[ctx] warning: corrupt JSON in ${filePath}, overwriting with defaults`);
21
+ return fallback;
22
+ }
14
23
  }
15
24
 
16
25
  function commandFor(installRoot, scriptName, { injectPromptContext = true } = {}) {
@@ -6,7 +6,12 @@ function readJsonFile(filePath, fallback) {
6
6
  if (!fs.existsSync(filePath)) return fallback;
7
7
  const raw = fs.readFileSync(filePath, "utf8").trim();
8
8
  if (!raw) return fallback;
9
- return JSON.parse(raw);
9
+ try {
10
+ return JSON.parse(raw);
11
+ } catch {
12
+ console.warn(`[ctx] warning: corrupt JSON in ${filePath}, overwriting with defaults`);
13
+ return fallback;
14
+ }
10
15
  }
11
16
 
12
17
  export function antigravityMcpConfigPaths() {
@@ -8,7 +8,12 @@ function readJsonFile(filePath, fallback) {
8
8
  if (!fs.existsSync(filePath)) return fallback;
9
9
  const raw = fs.readFileSync(filePath, "utf8").trim();
10
10
  if (!raw) return fallback;
11
- return JSON.parse(raw);
11
+ try {
12
+ return JSON.parse(raw);
13
+ } catch {
14
+ console.warn(`[ctx] warning: corrupt JSON in ${filePath}, overwriting with defaults`);
15
+ return fallback;
16
+ }
12
17
  }
13
18
 
14
19
  export function claudeHome() {
@@ -6,16 +6,25 @@ const QUIET_CODE_REVIEW_GRAPH_STATUS_COMMAND =
6
6
  "git rev-parse --git-dir >/dev/null 2>&1 && code-review-graph status >/dev/null 2>&1 || true";
7
7
 
8
8
  function shellQuote(value) {
9
- return `'${String(value).replaceAll("'", "'\\''")}'`;
9
+ const s = String(value);
10
+ if (process.platform === "win32") {
11
+ return `"${s.replaceAll('"', '\\"')}"`;
12
+ }
13
+ return `'${s.replaceAll("'", "'\\''")}'`;
10
14
  }
11
15
 
12
16
  function readHooksFile(hooksPath) {
13
17
  if (!fs.existsSync(hooksPath)) return { hooks: {} };
14
18
  const raw = fs.readFileSync(hooksPath, "utf8").trim();
15
19
  if (!raw) return { hooks: {} };
16
- const parsed = JSON.parse(raw);
17
- if (!parsed.hooks || typeof parsed.hooks !== "object") parsed.hooks = {};
18
- return parsed;
20
+ try {
21
+ const parsed = JSON.parse(raw);
22
+ if (!parsed.hooks || typeof parsed.hooks !== "object") parsed.hooks = {};
23
+ return parsed;
24
+ } catch {
25
+ console.warn(`[ctx] warning: corrupt JSON in ${hooksPath}, overwriting with defaults`);
26
+ return { hooks: {} };
27
+ }
19
28
  }
20
29
 
21
30
  function isContextOSHookEntry(entry) {