@fclef819/cdx 0.1.5 → 0.1.7
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 +23 -17
- package/package.json +5 -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,27 +166,21 @@ function runCodex(args, cwd, verbose) {
|
|
|
159
166
|
} catch {
|
|
160
167
|
// ignore if not supported
|
|
161
168
|
}
|
|
162
|
-
process.stdin.pause();
|
|
163
169
|
}
|
|
164
170
|
const result = spawnSync("codex", args, { stdio: "inherit", cwd });
|
|
165
171
|
if (result.error) {
|
|
166
172
|
if (result.error.code === "ENOENT" && process.platform === "win32") {
|
|
167
|
-
logVerbose("codex not found directly; trying
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
cwd
|
|
177
|
-
});
|
|
178
|
-
if (!resolvedResult.error) {
|
|
179
|
-
return { status: resolvedResult.status ?? 0 };
|
|
180
|
-
}
|
|
173
|
+
logVerbose("codex not found directly; trying cmd.exe /c", verbose);
|
|
174
|
+
const cmdResult = spawnSync(
|
|
175
|
+
"cmd.exe",
|
|
176
|
+
["/d", "/s", "/c", "codex", ...args],
|
|
177
|
+
{ stdio: "inherit", cwd }
|
|
178
|
+
);
|
|
179
|
+
if (!cmdResult.error) {
|
|
180
|
+
if (process.stdin.isTTY) process.stdin.pause();
|
|
181
|
+
return { status: cmdResult.status ?? 0 };
|
|
181
182
|
}
|
|
182
|
-
logVerbose("codex not found via
|
|
183
|
+
logVerbose("codex not found via cmd.exe; trying PowerShell fallback", verbose);
|
|
183
184
|
const psArgs = [
|
|
184
185
|
"-NoProfile",
|
|
185
186
|
"-Command",
|
|
@@ -190,6 +191,7 @@ function runCodex(args, cwd, verbose) {
|
|
|
190
191
|
cwd
|
|
191
192
|
});
|
|
192
193
|
if (!psResult.error) {
|
|
194
|
+
if (process.stdin.isTTY) process.stdin.pause();
|
|
193
195
|
return { status: psResult.status ?? 0 };
|
|
194
196
|
}
|
|
195
197
|
}
|
|
@@ -198,6 +200,7 @@ function runCodex(args, cwd, verbose) {
|
|
|
198
200
|
);
|
|
199
201
|
process.exit(1);
|
|
200
202
|
}
|
|
203
|
+
if (process.stdin.isTTY) process.stdin.pause();
|
|
201
204
|
return { status: result.status ?? 0 };
|
|
202
205
|
}
|
|
203
206
|
|
|
@@ -263,6 +266,9 @@ async function runDefault(startDir, options) {
|
|
|
263
266
|
const cdxPath = found ? found.filePath : path.join(startDir, CDX_FILENAME);
|
|
264
267
|
const entries = loadEntries(found?.filePath);
|
|
265
268
|
|
|
269
|
+
logVerbose(`CODEX_HOME: ${CODEX_HOME}`, options.verbose);
|
|
270
|
+
logVerbose(`Sessions dir: ${SESSIONS_DIR}`, options.verbose);
|
|
271
|
+
logVerbose(`History file: ${HISTORY_PATH}`, options.verbose);
|
|
266
272
|
console.log(`.cdx: ${cdxPath}`);
|
|
267
273
|
const selection = options.forceNew
|
|
268
274
|
? { 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.7",
|
|
4
4
|
"description": "Codex session wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codex",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"bin",
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"release": "npm login && npm pack && npm publish --access public",
|
|
21
|
+
"gh-release": "gh release create v$npm_package_version --generate-notes"
|
|
22
|
+
},
|
|
19
23
|
"engines": {
|
|
20
24
|
"node": ">=18"
|
|
21
25
|
},
|