@fclef819/cdx 0.1.5 → 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 +22 -6
- 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,7 +166,7 @@ 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) {
|
|
@@ -171,10 +178,16 @@ function runCodex(args, cwd, verbose) {
|
|
|
171
178
|
: null;
|
|
172
179
|
if (resolved) {
|
|
173
180
|
logVerbose(`Resolved codex path: ${resolved}`, verbose);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
+
}
|
|
178
191
|
if (!resolvedResult.error) {
|
|
179
192
|
return { status: resolvedResult.status ?? 0 };
|
|
180
193
|
}
|
|
@@ -263,6 +276,9 @@ async function runDefault(startDir, options) {
|
|
|
263
276
|
const cdxPath = found ? found.filePath : path.join(startDir, CDX_FILENAME);
|
|
264
277
|
const entries = loadEntries(found?.filePath);
|
|
265
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);
|
|
266
282
|
console.log(`.cdx: ${cdxPath}`);
|
|
267
283
|
const selection = options.forceNew
|
|
268
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
|
},
|