@childclm/codexx 0.1.1 → 0.1.2

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/package.json +1 -1
  2. package/src/index.js +44 -85
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@childclm/codexx",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Cross-platform launcher for Codex CLI with project-scoped session trees and provider switching.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -137,7 +137,7 @@ function saveProjectSessionsMeta(data, cwd = process.cwd()) {
137
137
 
138
138
  function detectCodex() {
139
139
  const settings = loadSettings();
140
- return settings.codexCommand || "codex";
140
+ return String(settings.codexCommand || "codex").trim().replace(/^"(.*)"$/, "$1");
141
141
  }
142
142
 
143
143
  function resolveWindowsCodexCandidates() {
@@ -151,24 +151,6 @@ function resolveWindowsCodexCandidates() {
151
151
  ];
152
152
  candidates.push(...localShims);
153
153
 
154
- const openaiCodexRoot = path.join(
155
- npmRoot,
156
- "node_modules",
157
- "@openai",
158
- "codex",
159
- "node_modules",
160
- );
161
- if (fileExists(openaiCodexRoot)) {
162
- try {
163
- const children = fs.readdirSync(openaiCodexRoot);
164
- for (const child of children) {
165
- if (!child.startsWith("@openai\\codex-win32-") && !child.startsWith("@openai/codex-win32-")) {
166
- continue;
167
- }
168
- }
169
- } catch {}
170
- }
171
-
172
154
  const finder = spawnSync("where", ["codex.exe"], { encoding: "utf8" });
173
155
  const foundExe = (finder.stdout || "")
174
156
  .trim()
@@ -183,70 +165,6 @@ function resolveWindowsCodexCandidates() {
183
165
  .filter(Boolean);
184
166
  candidates.push(...cmdHits);
185
167
 
186
- const vendorGlobRoot = path.join(
187
- npmRoot,
188
- "node_modules",
189
- "@openai",
190
- "codex",
191
- "node_modules",
192
- );
193
- if (fileExists(vendorGlobRoot)) {
194
- try {
195
- const dirs = fs.readdirSync(vendorGlobRoot);
196
- for (const dir of dirs) {
197
- if (!dir.startsWith("@openai")) continue;
198
- }
199
- } catch {}
200
- }
201
-
202
- const packageRoot = path.join(
203
- npmRoot,
204
- "node_modules",
205
- "@openai",
206
- "codex",
207
- "node_modules",
208
- );
209
- if (fileExists(packageRoot)) {
210
- try {
211
- const entries = fs.readdirSync(packageRoot);
212
- for (const entry of entries) {
213
- if (!entry.startsWith("@openai")) continue;
214
- }
215
- } catch {}
216
- }
217
-
218
- const openaiNodeModules = path.join(
219
- npmRoot,
220
- "node_modules",
221
- "@openai",
222
- "codex",
223
- "node_modules",
224
- );
225
- if (fileExists(openaiNodeModules)) {
226
- try {
227
- const entries = fs.readdirSync(openaiNodeModules);
228
- for (const entry of entries) {
229
- if (!entry.startsWith("@openai")) continue;
230
- }
231
- } catch {}
232
- }
233
-
234
- const codexNodeModules = path.join(
235
- npmRoot,
236
- "node_modules",
237
- "@openai",
238
- "codex",
239
- "node_modules",
240
- );
241
- if (fileExists(codexNodeModules)) {
242
- try {
243
- const entries = fs.readdirSync(codexNodeModules);
244
- for (const entry of entries) {
245
- if (!entry.startsWith("@openai")) continue;
246
- }
247
- } catch {}
248
- }
249
-
250
168
  const directVendorParent = path.join(
251
169
  npmRoot,
252
170
  "node_modules",
@@ -306,6 +224,46 @@ function codexPath() {
306
224
  return resolveCodexCommand();
307
225
  }
308
226
 
227
+ function buildCodexLaunch(cmd, args) {
228
+ const ext = path.extname(cmd).toLowerCase();
229
+ if (process.platform !== "win32") {
230
+ return {
231
+ command: cmd,
232
+ args,
233
+ shell: false,
234
+ };
235
+ }
236
+
237
+ if (ext === ".ps1") {
238
+ return {
239
+ command: "powershell.exe",
240
+ args: [
241
+ "-NoProfile",
242
+ "-ExecutionPolicy",
243
+ "Bypass",
244
+ "-File",
245
+ cmd,
246
+ ...args,
247
+ ],
248
+ shell: false,
249
+ };
250
+ }
251
+
252
+ if (ext === ".cmd" || ext === ".bat") {
253
+ return {
254
+ command: "cmd.exe",
255
+ args: ["/d", "/s", "/c", cmd, ...args],
256
+ shell: false,
257
+ };
258
+ }
259
+
260
+ return {
261
+ command: cmd,
262
+ args,
263
+ shell: false,
264
+ };
265
+ }
266
+
309
267
  function clearScreen() {
310
268
  process.stdout.write("\x1b[2J\x1b[0f");
311
269
  }
@@ -522,11 +480,12 @@ function buildCodexEnv(provider) {
522
480
  function runCodex(args, env, cwd = process.cwd()) {
523
481
  return new Promise((resolve, reject) => {
524
482
  const cmd = resolveCodexCommand();
525
- const child = spawn(cmd, args, {
483
+ const launch = buildCodexLaunch(cmd, args);
484
+ const child = spawn(launch.command, launch.args, {
526
485
  cwd,
527
486
  stdio: "inherit",
528
487
  env: { ...process.env, ...env },
529
- shell: false,
488
+ shell: launch.shell,
530
489
  });
531
490
  child.on("error", reject);
532
491
  child.on("exit", (code) => resolve(code ?? 0));