codexuse-cli 2.4.18 → 2.4.20

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/dist/index.js CHANGED
@@ -80,22 +80,6 @@ function normalizeAutoRollSettings(raw) {
80
80
  };
81
81
  }
82
82
 
83
- // ../../lib/codex-cli-channel.ts
84
- var KNOWN_CHANNELS = /* @__PURE__ */ new Set(["stable", "alpha"]);
85
- function parseCodexCliChannel(value) {
86
- if (typeof value !== "string") {
87
- return null;
88
- }
89
- const normalized = value.trim().toLowerCase();
90
- if (!normalized) {
91
- return null;
92
- }
93
- return KNOWN_CHANNELS.has(normalized) ? normalized : null;
94
- }
95
- function normalizeCodexCliChannel(value, fallback = "stable") {
96
- return parseCodexCliChannel(value) ?? fallback;
97
- }
98
-
99
83
  // ../../lib/app-state.ts
100
84
  var import_node_fs = require("fs");
101
85
  var import_node_async_hooks = require("async_hooks");
@@ -129,6 +113,22 @@ function normalizeChatHistoryScrollbackItems(value) {
129
113
  return CHAT_SCROLLBACK_DEFAULT;
130
114
  }
131
115
 
116
+ // ../../lib/commit-message-prompt.ts
117
+ var DEFAULT_COMMIT_MESSAGE_PROMPT = `Generate a concise git commit message for the following changes. Follow conventional commit format (e.g., feat:, fix:, refactor:, docs:, etc.). Keep the summary line under 72 characters. Only output the commit message, nothing else.
118
+
119
+ Changes:
120
+ {diff}`;
121
+ function normalizeLineEndings(value) {
122
+ return value.replace(/\r\n/g, "\n");
123
+ }
124
+ function normalizeCommitMessagePrompt(value) {
125
+ if (typeof value !== "string") {
126
+ return null;
127
+ }
128
+ const normalized = normalizeLineEndings(value).trim();
129
+ return normalized.length > 0 ? normalized : null;
130
+ }
131
+
132
132
  // ../../lib/app-state.ts
133
133
  var APP_STATE_FILE = "app-state.json";
134
134
  var APP_NAME = "codexuse-desktop";
@@ -176,7 +176,6 @@ function createDefaultAppState() {
176
176
  app: {
177
177
  lastAppVersion: null,
178
178
  pendingUpdateVersion: null,
179
- cliChannel: "stable",
180
179
  lastProfileName: null
181
180
  },
182
181
  license: {
@@ -207,16 +206,21 @@ function createDefaultAppState() {
207
206
  chatHistoryScrollbackItems: CHAT_SCROLLBACK_DEFAULT,
208
207
  systemNotificationsEnabled: true,
209
208
  subagentSystemNotificationsEnabled: true,
210
- dictationEnabled: true,
211
- dictationHoldKey: "",
212
- dictationPreferredLanguage: null,
213
- speakRepliesEnabled: false,
214
209
  folderHistory: [],
215
210
  pinnedPaths: []
216
211
  },
217
212
  projectSettingsByPath: {},
218
213
  conversationCategoriesByCwd: {},
219
214
  conversationCategoryAssignmentsByCwd: {},
215
+ git: {
216
+ commitMessagePrompt: DEFAULT_COMMIT_MESSAGE_PROMPT,
217
+ commitMessageModelId: null
218
+ },
219
+ agents: {
220
+ multiAgentEnabled: false,
221
+ maxThreads: 6,
222
+ maxDepth: 1
223
+ },
220
224
  skills: {
221
225
  sources: [],
222
226
  installsBySlug: {}
@@ -273,10 +277,17 @@ function normalizeAppState(raw) {
273
277
  if (merged.autoRoll.switchThreshold <= merged.autoRoll.warningThreshold || merged.autoRoll.switchThreshold > 100) {
274
278
  merged.autoRoll.switchThreshold = Math.min(100, Math.max(merged.autoRoll.warningThreshold + 1, 95));
275
279
  }
276
- merged.app.cliChannel = merged.app.cliChannel === "alpha" ? "alpha" : "stable";
277
280
  merged.app.lastAppVersion = asString(merged.app.lastAppVersion);
278
281
  merged.app.pendingUpdateVersion = asString(merged.app.pendingUpdateVersion);
279
282
  merged.app.lastProfileName = asString(merged.app.lastProfileName);
283
+ {
284
+ const allowedAppKeys = new Set(Object.keys(defaults.app));
285
+ for (const key of Object.keys(merged.app)) {
286
+ if (!allowedAppKeys.has(key)) {
287
+ delete merged.app[key];
288
+ }
289
+ }
290
+ }
280
291
  merged.license.licenseKey = asString(merged.license.licenseKey);
281
292
  merged.license.purchaseEmail = asString(merged.license.purchaseEmail);
282
293
  merged.license.lastVerifiedAt = asString(merged.license.lastVerifiedAt);
@@ -324,6 +335,14 @@ function normalizeAppState(raw) {
324
335
  if (!Array.isArray(merged.preferences.pinnedPaths)) {
325
336
  merged.preferences.pinnedPaths = [];
326
337
  }
338
+ {
339
+ const allowedPreferenceKeys = new Set(Object.keys(defaults.preferences));
340
+ for (const key of Object.keys(merged.preferences)) {
341
+ if (!allowedPreferenceKeys.has(key)) {
342
+ delete merged.preferences[key];
343
+ }
344
+ }
345
+ }
327
346
  if (!isRecord(merged.projectSettingsByPath)) {
328
347
  merged.projectSettingsByPath = {};
329
348
  }
@@ -333,6 +352,25 @@ function normalizeAppState(raw) {
333
352
  if (!isRecord(merged.conversationCategoryAssignmentsByCwd)) {
334
353
  merged.conversationCategoryAssignmentsByCwd = {};
335
354
  }
355
+ if (!isRecord(merged.git)) {
356
+ merged.git = clone(defaults.git);
357
+ }
358
+ merged.git.commitMessagePrompt = normalizeCommitMessagePrompt(merged.git.commitMessagePrompt) ?? DEFAULT_COMMIT_MESSAGE_PROMPT;
359
+ merged.git.commitMessageModelId = asString(merged.git.commitMessageModelId);
360
+ if (!isRecord(merged.agents)) {
361
+ merged.agents = clone(defaults.agents);
362
+ }
363
+ if (typeof merged.agents.multiAgentEnabled !== "boolean") {
364
+ merged.agents.multiAgentEnabled = defaults.agents.multiAgentEnabled;
365
+ }
366
+ if (!Number.isFinite(merged.agents.maxThreads)) {
367
+ merged.agents.maxThreads = defaults.agents.maxThreads;
368
+ }
369
+ merged.agents.maxThreads = Math.max(1, Math.min(12, Math.round(merged.agents.maxThreads)));
370
+ if (!Number.isFinite(merged.agents.maxDepth)) {
371
+ merged.agents.maxDepth = defaults.agents.maxDepth;
372
+ }
373
+ merged.agents.maxDepth = Math.max(1, Math.min(4, Math.round(merged.agents.maxDepth)));
336
374
  if (!isRecord(merged.skills)) {
337
375
  merged.skills = clone(defaults.skills);
338
376
  }
@@ -445,7 +483,7 @@ async function withWriteLock(task) {
445
483
  return task();
446
484
  }
447
485
  const previous = writeLock;
448
- let release = null;
486
+ let release;
449
487
  writeLock = new Promise((resolve) => {
450
488
  release = resolve;
451
489
  });
@@ -453,7 +491,9 @@ async function withWriteLock(task) {
453
491
  try {
454
492
  return await writeLockContext.run(true, task);
455
493
  } finally {
456
- release?.();
494
+ if (release) {
495
+ release();
496
+ }
457
497
  }
458
498
  }
459
499
  async function initializeAppState(userDataDir) {
@@ -570,17 +610,12 @@ async function getStoredAutoRollSettings() {
570
610
  const state = await getAppState();
571
611
  return normalizeAutoRollSettings(state.autoRoll);
572
612
  }
573
- async function getCodexCliChannel() {
574
- const state = await getAppState();
575
- return normalizeCodexCliChannel(state.app.cliChannel);
576
- }
577
613
  async function readCodexSettingsJsonRaw() {
578
614
  const state = await getAppState();
579
615
  return {
580
616
  lastProfileName: state.app.lastProfileName,
581
617
  lastAppVersion: state.app.lastAppVersion,
582
618
  pendingUpdateVersion: state.app.pendingUpdateVersion,
583
- cliChannel: state.app.cliChannel,
584
619
  autoRoll: state.autoRoll,
585
620
  license: state.license,
586
621
  providers: state.providers.list,
@@ -601,6 +636,8 @@ async function readCodexSettingsJsonRaw() {
601
636
  projectSettingsByPath: state.projectSettingsByPath,
602
637
  categoriesByCwd: state.conversationCategoriesByCwd,
603
638
  conversationCategoryByCwd: state.conversationCategoryAssignmentsByCwd,
639
+ git: state.git,
640
+ agents: state.agents,
604
641
  sync: state.sync
605
642
  };
606
643
  }
@@ -610,13 +647,11 @@ async function writeCodexSettingsJsonRaw(payload) {
610
647
  }
611
648
  const autoRoll = parseAutoRoll(payload.autoRoll ?? payload.auto_roll);
612
649
  const license = parseStoredLicense(payload.license);
613
- const cliChannel = parseCodexCliChannel(payload.cliChannel ?? payload.cli_channel);
614
650
  await patchAppState({
615
651
  app: {
616
652
  lastProfileName: asString2(payload.lastProfileName ?? payload.last_profile_name),
617
653
  lastAppVersion: asString2(payload.lastAppVersion ?? payload.last_app_version),
618
- pendingUpdateVersion: asString2(payload.pendingUpdateVersion ?? payload.pending_update_version),
619
- cliChannel: cliChannel ?? void 0
654
+ pendingUpdateVersion: asString2(payload.pendingUpdateVersion ?? payload.pending_update_version)
620
655
  },
621
656
  autoRoll: autoRoll ? {
622
657
  enabled: autoRoll.enabled,
@@ -656,6 +691,8 @@ async function writeCodexSettingsJsonRaw(payload) {
656
691
  projectSettingsByPath: isRecord2(payload.projectSettingsByPath) ? payload.projectSettingsByPath : void 0,
657
692
  conversationCategoriesByCwd: isRecord2(payload.categoriesByCwd) ? payload.categoriesByCwd : void 0,
658
693
  conversationCategoryAssignmentsByCwd: isRecord2(payload.conversationCategoryByCwd) ? payload.conversationCategoryByCwd : void 0,
694
+ git: isRecord2(payload.git) ? payload.git : void 0,
695
+ agents: isRecord2(payload.agents) ? payload.agents : void 0,
659
696
  sync: isRecord2(payload.sync) ? payload.sync : void 0
660
697
  });
661
698
  }
@@ -2726,8 +2763,8 @@ var import_node_path4 = __toESM(require("path"));
2726
2763
  // ../../lib/codex-cli.ts
2727
2764
  var import_node_fs3 = require("fs");
2728
2765
  var import_node_path3 = __toESM(require("path"));
2766
+ var STABLE_CHANNEL = "stable";
2729
2767
  var cachedStatus = null;
2730
- var cachedChannel = null;
2731
2768
  function fileExists(candidate) {
2732
2769
  if (!candidate) {
2733
2770
  return null;
@@ -2742,11 +2779,11 @@ function fileExists(candidate) {
2742
2779
  }
2743
2780
  return null;
2744
2781
  }
2745
- function resolveBundledCodexBinary(channel) {
2782
+ function resolveBundledCodexBinary() {
2746
2783
  const candidates = [];
2747
2784
  const processWithResources = process;
2748
2785
  const resourcesPath = processWithResources.resourcesPath;
2749
- const packageSegments = channel === "alpha" ? ["@openai", "codex-alpha"] : ["@openai", "codex"];
2786
+ const packageSegments = ["@openai", "codex"];
2750
2787
  if (resourcesPath) {
2751
2788
  candidates.push(
2752
2789
  import_node_path3.default.join(resourcesPath, "app.asar.unpacked", "node_modules", ...packageSegments, "bin", "codex.js")
@@ -2766,51 +2803,30 @@ function resolveBundledCodexBinary(channel) {
2766
2803
  }
2767
2804
  return null;
2768
2805
  }
2769
- function resolveBundledCodexBinaryWithFallback(requestedChannel) {
2770
- const direct = resolveBundledCodexBinary(requestedChannel);
2771
- if (direct) {
2772
- return { path: direct, resolvedChannel: requestedChannel, fallbackUsed: false };
2773
- }
2774
- if (requestedChannel === "alpha") {
2775
- const stable = resolveBundledCodexBinary("stable");
2776
- if (stable) {
2777
- return { path: stable, resolvedChannel: "stable", fallbackUsed: true };
2778
- }
2779
- }
2780
- return { path: null, resolvedChannel: null, fallbackUsed: false };
2781
- }
2782
- function buildUnavailableStatus(channel) {
2783
- const channelLabel = channel === "alpha" ? "alpha " : "";
2784
- const channelSuffix = channel === "alpha" ? " Switch to Stable in Settings or reinstall CodexUse to restore the CLI." : " Reinstall CodexUse to restore the CLI.";
2806
+ function buildUnavailableStatus() {
2785
2807
  return {
2786
2808
  available: false,
2787
2809
  path: null,
2788
- reason: `Bundled ${channelLabel}Codex CLI is missing.${channelSuffix}`,
2810
+ reason: "Bundled Codex CLI is missing. Reinstall CodexUse to restore the CLI.",
2789
2811
  source: null,
2790
- channel,
2791
- requestedChannel: channel,
2792
- fallbackUsed: false
2812
+ channel: STABLE_CHANNEL
2793
2813
  };
2794
2814
  }
2795
- function evaluateCodexCliStatus(requestedChannel) {
2796
- const resolved = resolveBundledCodexBinaryWithFallback(requestedChannel);
2797
- if (resolved.path && resolved.resolvedChannel) {
2815
+ function evaluateCodexCliStatus() {
2816
+ const resolvedPath = resolveBundledCodexBinary();
2817
+ if (resolvedPath) {
2798
2818
  return {
2799
2819
  available: true,
2800
- path: resolved.path,
2820
+ path: resolvedPath,
2801
2821
  reason: null,
2802
2822
  source: "bundled",
2803
- channel: resolved.resolvedChannel,
2804
- requestedChannel,
2805
- fallbackUsed: resolved.fallbackUsed
2823
+ channel: STABLE_CHANNEL
2806
2824
  };
2807
2825
  }
2808
- return buildUnavailableStatus(requestedChannel);
2826
+ return buildUnavailableStatus();
2809
2827
  }
2810
2828
  async function refreshCodexStatus() {
2811
- const channel = await getCodexCliChannel();
2812
- cachedChannel = channel;
2813
- cachedStatus = evaluateCodexCliStatus(channel);
2829
+ cachedStatus = evaluateCodexCliStatus();
2814
2830
  return { ...cachedStatus };
2815
2831
  }
2816
2832
  var CodexCliMissingError = class extends Error {
@@ -3016,8 +3032,7 @@ async function readSchemaFromLocal() {
3016
3032
  const candidates = [
3017
3033
  process.env.CODEX_CONFIG_SCHEMA_PATH,
3018
3034
  import_node_path4.default.join(process.cwd(), "codex-rs", "core", "config.schema.json"),
3019
- import_node_path4.default.join(process.cwd(), "node_modules", "@openai", "codex", "codex-rs", "core", "config.schema.json"),
3020
- import_node_path4.default.join(process.cwd(), "node_modules", "@openai", "codex-alpha", "codex-rs", "core", "config.schema.json")
3035
+ import_node_path4.default.join(process.cwd(), "node_modules", "@openai", "codex", "codex-rs", "core", "config.schema.json")
3021
3036
  ].filter((candidate) => Boolean(candidate));
3022
3037
  for (const candidate of candidates) {
3023
3038
  try {
@@ -3223,7 +3238,7 @@ async function ensureConfigDirExists(filePath) {
3223
3238
  const dir = import_node_path5.default.dirname(filePath);
3224
3239
  await (0, import_promises2.mkdir)(dir, { recursive: true });
3225
3240
  }
3226
- function normalizeLineEndings(content) {
3241
+ function normalizeLineEndings2(content) {
3227
3242
  return content.replace(/\r\n/g, "\n");
3228
3243
  }
3229
3244
  function ensureTrailingNewline(content) {
@@ -3520,7 +3535,7 @@ async function readConfigContent() {
3520
3535
  const content = await (0, import_promises2.readFile)(configPath, "utf8");
3521
3536
  return {
3522
3537
  exists: true,
3523
- content: normalizeLineEndings(content)
3538
+ content: normalizeLineEndings2(content)
3524
3539
  };
3525
3540
  } catch (error) {
3526
3541
  const nodeError = error;
@@ -3536,7 +3551,7 @@ async function readConfigContent() {
3536
3551
  async function writeConfigContent(content) {
3537
3552
  const configPath = getConfigPath();
3538
3553
  await ensureConfigDirExists(configPath);
3539
- const normalized = ensureTrailingNewline(normalizeLineEndings(content));
3554
+ const normalized = ensureTrailingNewline(normalizeLineEndings2(content));
3540
3555
  await (0, import_promises2.writeFile)(configPath, normalized, "utf8");
3541
3556
  }
3542
3557
  async function getUpdatedAt(configPath, exists) {
@@ -3582,7 +3597,7 @@ async function getCodexConfigSnapshot() {
3582
3597
  return buildSnapshot(content, exists);
3583
3598
  }
3584
3599
  async function saveCodexConfigContent(content) {
3585
- const normalized = ensureTrailingNewline(normalizeLineEndings(content));
3600
+ const normalized = ensureTrailingNewline(normalizeLineEndings2(content));
3586
3601
  const parsed = tryParseToml(normalized);
3587
3602
  if (!parsed.data) {
3588
3603
  throw new Error(parsed.error ?? "config.toml contains invalid TOML syntax.");
@@ -3935,10 +3950,7 @@ var import_node_child_process2 = require("child_process");
3935
3950
  var import_node_fs5 = require("fs");
3936
3951
  var import_node_path7 = __toESM(require("path"));
3937
3952
  var ENV_HINTS = ["CODEX_BINARY", "CODEX_CLI_PATH", "CODEX_PATH"];
3938
- var NODE_MODULE_CANDIDATES = [
3939
- ["@openai", "codex"],
3940
- ["@openai", "codex-alpha"]
3941
- ];
3953
+ var NODE_MODULE_CANDIDATES = [["@openai", "codex"]];
3942
3954
  function fileExists2(candidate) {
3943
3955
  if (!candidate) return null;
3944
3956
  const resolved = import_node_path7.default.resolve(candidate);
@@ -4507,14 +4519,12 @@ async function loadLegacySettingsPatch() {
4507
4519
  if (!isRecord5(raw)) {
4508
4520
  return {};
4509
4521
  }
4510
- const cliChannel = parseCodexCliChannel(raw.cliChannel ?? raw.cli_channel);
4511
4522
  const autoRoll = pickAutoRoll(raw.autoRoll ?? raw.auto_roll);
4512
4523
  const license = parseLegacyLicense(raw.license ?? raw.license_data ?? raw.license_state);
4513
4524
  return {
4514
4525
  app: {
4515
4526
  lastAppVersion: asString3(raw.lastAppVersion ?? raw.last_app_version),
4516
4527
  pendingUpdateVersion: asString3(raw.pendingUpdateVersion ?? raw.pending_update_version),
4517
- cliChannel: cliChannel ?? void 0,
4518
4528
  lastProfileName: asString3(raw.lastProfileName ?? raw.last_profile_name)
4519
4529
  },
4520
4530
  license,
@@ -5010,7 +5020,7 @@ async function importLegacyLocalStorageOnce(payload) {
5010
5020
  }
5011
5021
 
5012
5022
  // src/index.ts
5013
- var VERSION = true ? "2.4.18" : "0.0.0";
5023
+ var VERSION = true ? "2.4.20" : "0.0.0";
5014
5024
  var cliStorageReadyPromise = null;
5015
5025
  async function ensureCliStorageReady() {
5016
5026
  if (cliStorageReadyPromise) {