@fclef819/cdx 0.1.4 → 0.1.6
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/bin/cdx.js +34 -3
- package/package.json +4 -1
package/bin/cdx.js
CHANGED
|
@@ -7,7 +7,14 @@ const { spawnSync } = require("child_process");
|
|
|
7
7
|
const prompts = require("prompts");
|
|
8
8
|
|
|
9
9
|
const CDX_FILENAME = ".cdx";
|
|
10
|
-
const
|
|
10
|
+
const USER_HOME =
|
|
11
|
+
process.env.CODEX_HOME ||
|
|
12
|
+
process.env.HOME ||
|
|
13
|
+
process.env.USERPROFILE ||
|
|
14
|
+
"";
|
|
15
|
+
const CODEX_HOME = process.env.CODEX_HOME
|
|
16
|
+
? process.env.CODEX_HOME
|
|
17
|
+
: path.join(USER_HOME, ".codex");
|
|
11
18
|
const HISTORY_PATH = path.join(CODEX_HOME, "history.jsonl");
|
|
12
19
|
const SESSIONS_DIR = path.join(CODEX_HOME, "sessions");
|
|
13
20
|
|
|
@@ -159,12 +166,33 @@ function runCodex(args, cwd, verbose) {
|
|
|
159
166
|
} catch {
|
|
160
167
|
// ignore if not supported
|
|
161
168
|
}
|
|
162
|
-
process.stdin.
|
|
169
|
+
process.stdin.resume();
|
|
163
170
|
}
|
|
164
171
|
const result = spawnSync("codex", args, { stdio: "inherit", cwd });
|
|
165
172
|
if (result.error) {
|
|
166
173
|
if (result.error.code === "ENOENT" && process.platform === "win32") {
|
|
167
|
-
logVerbose("codex not found directly; trying
|
|
174
|
+
logVerbose("codex not found directly; trying where.exe lookup", verbose);
|
|
175
|
+
const whereResult = spawnSync("where.exe", ["codex"], { encoding: "utf8" });
|
|
176
|
+
const resolved = whereResult.stdout
|
|
177
|
+
? whereResult.stdout.split(/\r?\n/).find(Boolean)
|
|
178
|
+
: null;
|
|
179
|
+
if (resolved) {
|
|
180
|
+
logVerbose(`Resolved codex path: ${resolved}`, verbose);
|
|
181
|
+
let resolvedResult;
|
|
182
|
+
if (resolved.toLowerCase().endsWith(".cmd") || resolved.toLowerCase().endsWith(".bat")) {
|
|
183
|
+
resolvedResult = spawnSync(
|
|
184
|
+
"cmd.exe",
|
|
185
|
+
["/d", "/s", "/c", resolved, ...args],
|
|
186
|
+
{ stdio: "inherit", cwd }
|
|
187
|
+
);
|
|
188
|
+
} else {
|
|
189
|
+
resolvedResult = spawnSync(resolved, args, { stdio: "inherit", cwd });
|
|
190
|
+
}
|
|
191
|
+
if (!resolvedResult.error) {
|
|
192
|
+
return { status: resolvedResult.status ?? 0 };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
logVerbose("codex not found via where.exe; trying PowerShell fallback", verbose);
|
|
168
196
|
const psArgs = [
|
|
169
197
|
"-NoProfile",
|
|
170
198
|
"-Command",
|
|
@@ -248,6 +276,9 @@ async function runDefault(startDir, options) {
|
|
|
248
276
|
const cdxPath = found ? found.filePath : path.join(startDir, CDX_FILENAME);
|
|
249
277
|
const entries = loadEntries(found?.filePath);
|
|
250
278
|
|
|
279
|
+
logVerbose(`CODEX_HOME: ${CODEX_HOME}`, options.verbose);
|
|
280
|
+
logVerbose(`Sessions dir: ${SESSIONS_DIR}`, options.verbose);
|
|
281
|
+
logVerbose(`History file: ${HISTORY_PATH}`, options.verbose);
|
|
251
282
|
console.log(`.cdx: ${cdxPath}`);
|
|
252
283
|
const selection = options.forceNew
|
|
253
284
|
? { type: "new" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fclef819/cdx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Codex session wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codex",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"bin",
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"release": "npm login && npm pack && npm publish --access public"
|
|
21
|
+
},
|
|
19
22
|
"engines": {
|
|
20
23
|
"node": ">=18"
|
|
21
24
|
},
|