@fclef819/cdx 0.1.3 → 0.1.4

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 +25 -5
  2. package/package.json +1 -1
package/bin/cdx.js CHANGED
@@ -153,6 +153,14 @@ 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") {
@@ -167,8 +175,7 @@ function runCodex(args, cwd, verbose) {
167
175
  cwd
168
176
  });
169
177
  if (!psResult.error) {
170
- if (psResult.status !== 0) process.exit(psResult.status ?? 1);
171
- return;
178
+ return { status: psResult.status ?? 0 };
172
179
  }
173
180
  }
174
181
  console.error(
@@ -176,7 +183,7 @@ function runCodex(args, cwd, verbose) {
176
183
  );
177
184
  process.exit(1);
178
185
  }
179
- if (result.status !== 0) process.exit(result.status ?? 1);
186
+ return { status: result.status ?? 0 };
180
187
  }
181
188
 
182
189
  function suggestByNumber(input, choices) {
@@ -253,7 +260,7 @@ async function runDefault(startDir, options) {
253
260
  const label = sanitizeLabel(labelInput);
254
261
  const previousHistoryId = getLastHistorySessionId(options.verbose);
255
262
  const previousSession = getLatestSessionSnapshot(options.verbose);
256
- runCodex([], workDir, options.verbose);
263
+ const codexResult = runCodex([], workDir, options.verbose);
257
264
  const latestSession = getLatestSessionSnapshot(options.verbose);
258
265
  let newId = null;
259
266
  if (
@@ -269,14 +276,27 @@ async function runDefault(startDir, options) {
269
276
  }
270
277
  if (!newId) {
271
278
  console.error("Could not determine new session UUID; not updating .cdx.");
279
+ if (codexResult && codexResult.status !== 0) {
280
+ process.exit(codexResult.status);
281
+ }
272
282
  return;
273
283
  }
274
284
  appendEntry(cdxPath, { uuid: newId, label }, options.verbose);
285
+ if (codexResult && codexResult.status !== 0) {
286
+ process.exit(codexResult.status);
287
+ }
275
288
  return;
276
289
  }
277
290
 
278
291
  if (selection.type === "resume") {
279
- runCodex(["resume", selection.entry.uuid], workDir, options.verbose);
292
+ const codexResult = runCodex(
293
+ ["resume", selection.entry.uuid],
294
+ workDir,
295
+ options.verbose
296
+ );
297
+ if (codexResult && codexResult.status !== 0) {
298
+ process.exit(codexResult.status);
299
+ }
280
300
  }
281
301
  }
282
302
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fclef819/cdx",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Codex session wrapper",
5
5
  "keywords": [
6
6
  "codex",