@fclef819/cdx 0.1.3 → 0.1.5

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/bin/cdx.js +41 -6
  2. package/package.json +1 -1
package/bin/cdx.js CHANGED
@@ -153,10 +153,33 @@ function getNewestHistorySessionIdSince(previousId, verbose) {
153
153
 
154
154
  function runCodex(args, cwd, verbose) {
155
155
  logVerbose(`Running codex ${args.join(" ")}`.trim(), verbose);
156
+ if (process.stdin.isTTY) {
157
+ try {
158
+ process.stdin.setRawMode(false);
159
+ } catch {
160
+ // ignore if not supported
161
+ }
162
+ process.stdin.pause();
163
+ }
156
164
  const result = spawnSync("codex", args, { stdio: "inherit", cwd });
157
165
  if (result.error) {
158
166
  if (result.error.code === "ENOENT" && process.platform === "win32") {
159
- logVerbose("codex not found directly; trying PowerShell fallback", verbose);
167
+ logVerbose("codex not found directly; trying where.exe lookup", verbose);
168
+ const whereResult = spawnSync("where.exe", ["codex"], { encoding: "utf8" });
169
+ const resolved = whereResult.stdout
170
+ ? whereResult.stdout.split(/\r?\n/).find(Boolean)
171
+ : null;
172
+ if (resolved) {
173
+ logVerbose(`Resolved codex path: ${resolved}`, verbose);
174
+ const resolvedResult = spawnSync(resolved, args, {
175
+ stdio: "inherit",
176
+ cwd
177
+ });
178
+ if (!resolvedResult.error) {
179
+ return { status: resolvedResult.status ?? 0 };
180
+ }
181
+ }
182
+ logVerbose("codex not found via where.exe; trying PowerShell fallback", verbose);
160
183
  const psArgs = [
161
184
  "-NoProfile",
162
185
  "-Command",
@@ -167,8 +190,7 @@ function runCodex(args, cwd, verbose) {
167
190
  cwd
168
191
  });
169
192
  if (!psResult.error) {
170
- if (psResult.status !== 0) process.exit(psResult.status ?? 1);
171
- return;
193
+ return { status: psResult.status ?? 0 };
172
194
  }
173
195
  }
174
196
  console.error(
@@ -176,7 +198,7 @@ function runCodex(args, cwd, verbose) {
176
198
  );
177
199
  process.exit(1);
178
200
  }
179
- if (result.status !== 0) process.exit(result.status ?? 1);
201
+ return { status: result.status ?? 0 };
180
202
  }
181
203
 
182
204
  function suggestByNumber(input, choices) {
@@ -253,7 +275,7 @@ async function runDefault(startDir, options) {
253
275
  const label = sanitizeLabel(labelInput);
254
276
  const previousHistoryId = getLastHistorySessionId(options.verbose);
255
277
  const previousSession = getLatestSessionSnapshot(options.verbose);
256
- runCodex([], workDir, options.verbose);
278
+ const codexResult = runCodex([], workDir, options.verbose);
257
279
  const latestSession = getLatestSessionSnapshot(options.verbose);
258
280
  let newId = null;
259
281
  if (
@@ -269,14 +291,27 @@ async function runDefault(startDir, options) {
269
291
  }
270
292
  if (!newId) {
271
293
  console.error("Could not determine new session UUID; not updating .cdx.");
294
+ if (codexResult && codexResult.status !== 0) {
295
+ process.exit(codexResult.status);
296
+ }
272
297
  return;
273
298
  }
274
299
  appendEntry(cdxPath, { uuid: newId, label }, options.verbose);
300
+ if (codexResult && codexResult.status !== 0) {
301
+ process.exit(codexResult.status);
302
+ }
275
303
  return;
276
304
  }
277
305
 
278
306
  if (selection.type === "resume") {
279
- runCodex(["resume", selection.entry.uuid], workDir, options.verbose);
307
+ const codexResult = runCodex(
308
+ ["resume", selection.entry.uuid],
309
+ workDir,
310
+ options.verbose
311
+ );
312
+ if (codexResult && codexResult.status !== 0) {
313
+ process.exit(codexResult.status);
314
+ }
280
315
  }
281
316
  }
282
317
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fclef819/cdx",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Codex session wrapper",
5
5
  "keywords": [
6
6
  "codex",