claude-yes 1.30.0 → 1.31.1

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/codex-yes.js CHANGED
@@ -14017,12 +14017,12 @@ function catcher(catchFn, fn) {
14017
14017
  }
14018
14018
 
14019
14019
  // ts/codexSessionManager.ts
14020
- import { mkdir, readFile, writeFile } from "fs/promises";
14020
+ import { mkdir, readdir, readFile, writeFile } from "fs/promises";
14021
14021
  import { homedir } from "os";
14022
14022
  import path7 from "path";
14023
14023
  async function loadSessionMap() {
14024
14024
  try {
14025
- const content = await readFile(SESSIONS_FILE, "utf-8");
14025
+ const content = await readFile(getSessionsFile(), "utf-8");
14026
14026
  return JSON.parse(content);
14027
14027
  } catch (error) {
14028
14028
  return {};
@@ -14030,8 +14030,9 @@ async function loadSessionMap() {
14030
14030
  }
14031
14031
  async function saveSessionMap(sessionMap) {
14032
14032
  try {
14033
- await mkdir(path7.dirname(SESSIONS_FILE), { recursive: true });
14034
- await writeFile(SESSIONS_FILE, JSON.stringify(sessionMap, null, 2));
14033
+ const sessionsFile = getSessionsFile();
14034
+ await mkdir(path7.dirname(sessionsFile), { recursive: true });
14035
+ await writeFile(sessionsFile, JSON.stringify(sessionMap, null, 2));
14035
14036
  } catch (error) {
14036
14037
  console.warn("Failed to save codex session map:", error);
14037
14038
  }
@@ -14044,7 +14045,78 @@ async function storeSessionForCwd(cwd, sessionId) {
14044
14045
  };
14045
14046
  await saveSessionMap(sessionMap);
14046
14047
  }
14048
+ async function parseCodexSessionFile(filePath) {
14049
+ try {
14050
+ const content = await readFile(filePath, "utf-8");
14051
+ const lines2 = content.trim().split(`
14052
+ `);
14053
+ for (const line of lines2) {
14054
+ if (!line.trim())
14055
+ continue;
14056
+ const data = JSON.parse(line);
14057
+ if (data.type === "session_meta" && data.payload) {
14058
+ const payload = data.payload;
14059
+ return {
14060
+ id: payload.id,
14061
+ timestamp: payload.timestamp || data.timestamp,
14062
+ cwd: payload.cwd,
14063
+ filePath,
14064
+ git: payload.git
14065
+ };
14066
+ }
14067
+ }
14068
+ return null;
14069
+ } catch (error) {
14070
+ return null;
14071
+ }
14072
+ }
14073
+ async function getAllCodexSessions() {
14074
+ const sessions = [];
14075
+ const codexSessionsDir = getCodexSessionsDir();
14076
+ try {
14077
+ const years = await readdir(codexSessionsDir);
14078
+ for (const year of years) {
14079
+ const yearPath = path7.join(codexSessionsDir, year);
14080
+ try {
14081
+ const months = await readdir(yearPath);
14082
+ for (const month of months) {
14083
+ const monthPath = path7.join(yearPath, month);
14084
+ try {
14085
+ const days = await readdir(monthPath);
14086
+ for (const day of days) {
14087
+ const dayPath = path7.join(monthPath, day);
14088
+ try {
14089
+ const files = await readdir(dayPath);
14090
+ for (const file of files) {
14091
+ if (file.endsWith(".jsonl")) {
14092
+ const sessionPath = path7.join(dayPath, file);
14093
+ const session = await parseCodexSessionFile(sessionPath);
14094
+ if (session) {
14095
+ sessions.push(session);
14096
+ }
14097
+ }
14098
+ }
14099
+ } catch (error) {}
14100
+ }
14101
+ } catch (error) {}
14102
+ }
14103
+ } catch (error) {}
14104
+ }
14105
+ } catch (error) {
14106
+ return [];
14107
+ }
14108
+ return sessions.sort((a2, b) => new Date(b.timestamp).getTime() - new Date(a2.timestamp).getTime());
14109
+ }
14110
+ async function getMostRecentCodexSessionForCwd(targetCwd) {
14111
+ const allSessions = await getAllCodexSessions();
14112
+ const sessionsForCwd = allSessions.filter((session) => session.cwd === targetCwd);
14113
+ return sessionsForCwd[0] || null;
14114
+ }
14047
14115
  async function getSessionForCwd(cwd) {
14116
+ const recentSession = await getMostRecentCodexSessionForCwd(cwd);
14117
+ if (recentSession) {
14118
+ return recentSession.id;
14119
+ }
14048
14120
  const sessionMap = await loadSessionMap();
14049
14121
  return sessionMap[cwd]?.sessionId || null;
14050
14122
  }
@@ -14053,10 +14125,8 @@ function extractSessionId(output) {
14053
14125
  const match = output.match(sessionIdRegex);
14054
14126
  return match ? match[0] : null;
14055
14127
  }
14056
- var SESSIONS_FILE;
14057
- var init_codexSessionManager = __esm(() => {
14058
- SESSIONS_FILE = path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json");
14059
- });
14128
+ var getSessionsFile = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".config", "cli-yes", "codex-sessions.json") : path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json"), getCodexSessionsDir = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".codex", "sessions") : path7.join(homedir(), ".codex", "sessions");
14129
+ var init_codexSessionManager = () => {};
14060
14130
 
14061
14131
  // ts/idleWaiter.ts
14062
14132
  class IdleWaiter {
@@ -20339,8 +20409,9 @@ var init_ts = __esm(async () => {
20339
20409
  // ts/cli.ts
20340
20410
  init_dist();
20341
20411
  init_cli_yes_config();
20342
- if (!globalThis.Bun) {
20343
- console.log("Re-running with Bun...", process.argv);
20412
+ var hasNodePty = !!await import("node-pty").catch(() => null);
20413
+ if (!globalThis.Bun && !hasNodePty) {
20414
+ console.log("No node-pty installed. Re-running with Bun...", process.argv);
20344
20415
  (await import("child_process")).spawnSync("node_modules/.bin/bun", [process.argv[1], "--", ...process.argv.slice(2)], { stdio: "inherit" });
20345
20416
  process.exit(0);
20346
20417
  }
@@ -20357,5 +20428,5 @@ if (config2.verbose) {
20357
20428
  var { exitCode } = await cliYes2(config2);
20358
20429
  process.exit(exitCode ?? 1);
20359
20430
 
20360
- //# debugId=A6B971C2331DA0F864756E2164756E21
20431
+ //# debugId=229819D0379CAA1264756E2164756E21
20361
20432
  //# sourceMappingURL=cli.js.map
@@ -14017,12 +14017,12 @@ function catcher(catchFn, fn) {
14017
14017
  }
14018
14018
 
14019
14019
  // ts/codexSessionManager.ts
14020
- import { mkdir, readFile, writeFile } from "fs/promises";
14020
+ import { mkdir, readdir, readFile, writeFile } from "fs/promises";
14021
14021
  import { homedir } from "os";
14022
14022
  import path7 from "path";
14023
14023
  async function loadSessionMap() {
14024
14024
  try {
14025
- const content = await readFile(SESSIONS_FILE, "utf-8");
14025
+ const content = await readFile(getSessionsFile(), "utf-8");
14026
14026
  return JSON.parse(content);
14027
14027
  } catch (error) {
14028
14028
  return {};
@@ -14030,8 +14030,9 @@ async function loadSessionMap() {
14030
14030
  }
14031
14031
  async function saveSessionMap(sessionMap) {
14032
14032
  try {
14033
- await mkdir(path7.dirname(SESSIONS_FILE), { recursive: true });
14034
- await writeFile(SESSIONS_FILE, JSON.stringify(sessionMap, null, 2));
14033
+ const sessionsFile = getSessionsFile();
14034
+ await mkdir(path7.dirname(sessionsFile), { recursive: true });
14035
+ await writeFile(sessionsFile, JSON.stringify(sessionMap, null, 2));
14035
14036
  } catch (error) {
14036
14037
  console.warn("Failed to save codex session map:", error);
14037
14038
  }
@@ -14044,7 +14045,78 @@ async function storeSessionForCwd(cwd, sessionId) {
14044
14045
  };
14045
14046
  await saveSessionMap(sessionMap);
14046
14047
  }
14048
+ async function parseCodexSessionFile(filePath) {
14049
+ try {
14050
+ const content = await readFile(filePath, "utf-8");
14051
+ const lines2 = content.trim().split(`
14052
+ `);
14053
+ for (const line of lines2) {
14054
+ if (!line.trim())
14055
+ continue;
14056
+ const data = JSON.parse(line);
14057
+ if (data.type === "session_meta" && data.payload) {
14058
+ const payload = data.payload;
14059
+ return {
14060
+ id: payload.id,
14061
+ timestamp: payload.timestamp || data.timestamp,
14062
+ cwd: payload.cwd,
14063
+ filePath,
14064
+ git: payload.git
14065
+ };
14066
+ }
14067
+ }
14068
+ return null;
14069
+ } catch (error) {
14070
+ return null;
14071
+ }
14072
+ }
14073
+ async function getAllCodexSessions() {
14074
+ const sessions = [];
14075
+ const codexSessionsDir = getCodexSessionsDir();
14076
+ try {
14077
+ const years = await readdir(codexSessionsDir);
14078
+ for (const year of years) {
14079
+ const yearPath = path7.join(codexSessionsDir, year);
14080
+ try {
14081
+ const months = await readdir(yearPath);
14082
+ for (const month of months) {
14083
+ const monthPath = path7.join(yearPath, month);
14084
+ try {
14085
+ const days = await readdir(monthPath);
14086
+ for (const day of days) {
14087
+ const dayPath = path7.join(monthPath, day);
14088
+ try {
14089
+ const files = await readdir(dayPath);
14090
+ for (const file of files) {
14091
+ if (file.endsWith(".jsonl")) {
14092
+ const sessionPath = path7.join(dayPath, file);
14093
+ const session = await parseCodexSessionFile(sessionPath);
14094
+ if (session) {
14095
+ sessions.push(session);
14096
+ }
14097
+ }
14098
+ }
14099
+ } catch (error) {}
14100
+ }
14101
+ } catch (error) {}
14102
+ }
14103
+ } catch (error) {}
14104
+ }
14105
+ } catch (error) {
14106
+ return [];
14107
+ }
14108
+ return sessions.sort((a2, b) => new Date(b.timestamp).getTime() - new Date(a2.timestamp).getTime());
14109
+ }
14110
+ async function getMostRecentCodexSessionForCwd(targetCwd) {
14111
+ const allSessions = await getAllCodexSessions();
14112
+ const sessionsForCwd = allSessions.filter((session) => session.cwd === targetCwd);
14113
+ return sessionsForCwd[0] || null;
14114
+ }
14047
14115
  async function getSessionForCwd(cwd) {
14116
+ const recentSession = await getMostRecentCodexSessionForCwd(cwd);
14117
+ if (recentSession) {
14118
+ return recentSession.id;
14119
+ }
14048
14120
  const sessionMap = await loadSessionMap();
14049
14121
  return sessionMap[cwd]?.sessionId || null;
14050
14122
  }
@@ -14053,10 +14125,8 @@ function extractSessionId(output) {
14053
14125
  const match = output.match(sessionIdRegex);
14054
14126
  return match ? match[0] : null;
14055
14127
  }
14056
- var SESSIONS_FILE;
14057
- var init_codexSessionManager = __esm(() => {
14058
- SESSIONS_FILE = path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json");
14059
- });
14128
+ var getSessionsFile = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".config", "cli-yes", "codex-sessions.json") : path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json"), getCodexSessionsDir = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".codex", "sessions") : path7.join(homedir(), ".codex", "sessions");
14129
+ var init_codexSessionManager = () => {};
14060
14130
 
14061
14131
  // ts/idleWaiter.ts
14062
14132
  class IdleWaiter {
@@ -20339,8 +20409,9 @@ var init_ts = __esm(async () => {
20339
20409
  // ts/cli.ts
20340
20410
  init_dist();
20341
20411
  init_cli_yes_config();
20342
- if (!globalThis.Bun) {
20343
- console.log("Re-running with Bun...", process.argv);
20412
+ var hasNodePty = !!await import("node-pty").catch(() => null);
20413
+ if (!globalThis.Bun && !hasNodePty) {
20414
+ console.log("No node-pty installed. Re-running with Bun...", process.argv);
20344
20415
  (await import("child_process")).spawnSync("node_modules/.bin/bun", [process.argv[1], "--", ...process.argv.slice(2)], { stdio: "inherit" });
20345
20416
  process.exit(0);
20346
20417
  }
@@ -20357,5 +20428,5 @@ if (config2.verbose) {
20357
20428
  var { exitCode } = await cliYes2(config2);
20358
20429
  process.exit(exitCode ?? 1);
20359
20430
 
20360
- //# debugId=A6B971C2331DA0F864756E2164756E21
20431
+ //# debugId=229819D0379CAA1264756E2164756E21
20361
20432
  //# sourceMappingURL=cli.js.map
@@ -14017,12 +14017,12 @@ function catcher(catchFn, fn) {
14017
14017
  }
14018
14018
 
14019
14019
  // ts/codexSessionManager.ts
14020
- import { mkdir, readFile, writeFile } from "fs/promises";
14020
+ import { mkdir, readdir, readFile, writeFile } from "fs/promises";
14021
14021
  import { homedir } from "os";
14022
14022
  import path7 from "path";
14023
14023
  async function loadSessionMap() {
14024
14024
  try {
14025
- const content = await readFile(SESSIONS_FILE, "utf-8");
14025
+ const content = await readFile(getSessionsFile(), "utf-8");
14026
14026
  return JSON.parse(content);
14027
14027
  } catch (error) {
14028
14028
  return {};
@@ -14030,8 +14030,9 @@ async function loadSessionMap() {
14030
14030
  }
14031
14031
  async function saveSessionMap(sessionMap) {
14032
14032
  try {
14033
- await mkdir(path7.dirname(SESSIONS_FILE), { recursive: true });
14034
- await writeFile(SESSIONS_FILE, JSON.stringify(sessionMap, null, 2));
14033
+ const sessionsFile = getSessionsFile();
14034
+ await mkdir(path7.dirname(sessionsFile), { recursive: true });
14035
+ await writeFile(sessionsFile, JSON.stringify(sessionMap, null, 2));
14035
14036
  } catch (error) {
14036
14037
  console.warn("Failed to save codex session map:", error);
14037
14038
  }
@@ -14044,7 +14045,78 @@ async function storeSessionForCwd(cwd, sessionId) {
14044
14045
  };
14045
14046
  await saveSessionMap(sessionMap);
14046
14047
  }
14048
+ async function parseCodexSessionFile(filePath) {
14049
+ try {
14050
+ const content = await readFile(filePath, "utf-8");
14051
+ const lines2 = content.trim().split(`
14052
+ `);
14053
+ for (const line of lines2) {
14054
+ if (!line.trim())
14055
+ continue;
14056
+ const data = JSON.parse(line);
14057
+ if (data.type === "session_meta" && data.payload) {
14058
+ const payload = data.payload;
14059
+ return {
14060
+ id: payload.id,
14061
+ timestamp: payload.timestamp || data.timestamp,
14062
+ cwd: payload.cwd,
14063
+ filePath,
14064
+ git: payload.git
14065
+ };
14066
+ }
14067
+ }
14068
+ return null;
14069
+ } catch (error) {
14070
+ return null;
14071
+ }
14072
+ }
14073
+ async function getAllCodexSessions() {
14074
+ const sessions = [];
14075
+ const codexSessionsDir = getCodexSessionsDir();
14076
+ try {
14077
+ const years = await readdir(codexSessionsDir);
14078
+ for (const year of years) {
14079
+ const yearPath = path7.join(codexSessionsDir, year);
14080
+ try {
14081
+ const months = await readdir(yearPath);
14082
+ for (const month of months) {
14083
+ const monthPath = path7.join(yearPath, month);
14084
+ try {
14085
+ const days = await readdir(monthPath);
14086
+ for (const day of days) {
14087
+ const dayPath = path7.join(monthPath, day);
14088
+ try {
14089
+ const files = await readdir(dayPath);
14090
+ for (const file of files) {
14091
+ if (file.endsWith(".jsonl")) {
14092
+ const sessionPath = path7.join(dayPath, file);
14093
+ const session = await parseCodexSessionFile(sessionPath);
14094
+ if (session) {
14095
+ sessions.push(session);
14096
+ }
14097
+ }
14098
+ }
14099
+ } catch (error) {}
14100
+ }
14101
+ } catch (error) {}
14102
+ }
14103
+ } catch (error) {}
14104
+ }
14105
+ } catch (error) {
14106
+ return [];
14107
+ }
14108
+ return sessions.sort((a2, b) => new Date(b.timestamp).getTime() - new Date(a2.timestamp).getTime());
14109
+ }
14110
+ async function getMostRecentCodexSessionForCwd(targetCwd) {
14111
+ const allSessions = await getAllCodexSessions();
14112
+ const sessionsForCwd = allSessions.filter((session) => session.cwd === targetCwd);
14113
+ return sessionsForCwd[0] || null;
14114
+ }
14047
14115
  async function getSessionForCwd(cwd) {
14116
+ const recentSession = await getMostRecentCodexSessionForCwd(cwd);
14117
+ if (recentSession) {
14118
+ return recentSession.id;
14119
+ }
14048
14120
  const sessionMap = await loadSessionMap();
14049
14121
  return sessionMap[cwd]?.sessionId || null;
14050
14122
  }
@@ -14053,10 +14125,8 @@ function extractSessionId(output) {
14053
14125
  const match = output.match(sessionIdRegex);
14054
14126
  return match ? match[0] : null;
14055
14127
  }
14056
- var SESSIONS_FILE;
14057
- var init_codexSessionManager = __esm(() => {
14058
- SESSIONS_FILE = path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json");
14059
- });
14128
+ var getSessionsFile = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".config", "cli-yes", "codex-sessions.json") : path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json"), getCodexSessionsDir = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".codex", "sessions") : path7.join(homedir(), ".codex", "sessions");
14129
+ var init_codexSessionManager = () => {};
14060
14130
 
14061
14131
  // ts/idleWaiter.ts
14062
14132
  class IdleWaiter {
@@ -20339,8 +20409,9 @@ var init_ts = __esm(async () => {
20339
20409
  // ts/cli.ts
20340
20410
  init_dist();
20341
20411
  init_cli_yes_config();
20342
- if (!globalThis.Bun) {
20343
- console.log("Re-running with Bun...", process.argv);
20412
+ var hasNodePty = !!await import("node-pty").catch(() => null);
20413
+ if (!globalThis.Bun && !hasNodePty) {
20414
+ console.log("No node-pty installed. Re-running with Bun...", process.argv);
20344
20415
  (await import("child_process")).spawnSync("node_modules/.bin/bun", [process.argv[1], "--", ...process.argv.slice(2)], { stdio: "inherit" });
20345
20416
  process.exit(0);
20346
20417
  }
@@ -20357,5 +20428,5 @@ if (config2.verbose) {
20357
20428
  var { exitCode } = await cliYes2(config2);
20358
20429
  process.exit(exitCode ?? 1);
20359
20430
 
20360
- //# debugId=A6B971C2331DA0F864756E2164756E21
20431
+ //# debugId=229819D0379CAA1264756E2164756E21
20361
20432
  //# sourceMappingURL=cli.js.map
@@ -14017,12 +14017,12 @@ function catcher(catchFn, fn) {
14017
14017
  }
14018
14018
 
14019
14019
  // ts/codexSessionManager.ts
14020
- import { mkdir, readFile, writeFile } from "fs/promises";
14020
+ import { mkdir, readdir, readFile, writeFile } from "fs/promises";
14021
14021
  import { homedir } from "os";
14022
14022
  import path7 from "path";
14023
14023
  async function loadSessionMap() {
14024
14024
  try {
14025
- const content = await readFile(SESSIONS_FILE, "utf-8");
14025
+ const content = await readFile(getSessionsFile(), "utf-8");
14026
14026
  return JSON.parse(content);
14027
14027
  } catch (error) {
14028
14028
  return {};
@@ -14030,8 +14030,9 @@ async function loadSessionMap() {
14030
14030
  }
14031
14031
  async function saveSessionMap(sessionMap) {
14032
14032
  try {
14033
- await mkdir(path7.dirname(SESSIONS_FILE), { recursive: true });
14034
- await writeFile(SESSIONS_FILE, JSON.stringify(sessionMap, null, 2));
14033
+ const sessionsFile = getSessionsFile();
14034
+ await mkdir(path7.dirname(sessionsFile), { recursive: true });
14035
+ await writeFile(sessionsFile, JSON.stringify(sessionMap, null, 2));
14035
14036
  } catch (error) {
14036
14037
  console.warn("Failed to save codex session map:", error);
14037
14038
  }
@@ -14044,7 +14045,78 @@ async function storeSessionForCwd(cwd, sessionId) {
14044
14045
  };
14045
14046
  await saveSessionMap(sessionMap);
14046
14047
  }
14048
+ async function parseCodexSessionFile(filePath) {
14049
+ try {
14050
+ const content = await readFile(filePath, "utf-8");
14051
+ const lines2 = content.trim().split(`
14052
+ `);
14053
+ for (const line of lines2) {
14054
+ if (!line.trim())
14055
+ continue;
14056
+ const data = JSON.parse(line);
14057
+ if (data.type === "session_meta" && data.payload) {
14058
+ const payload = data.payload;
14059
+ return {
14060
+ id: payload.id,
14061
+ timestamp: payload.timestamp || data.timestamp,
14062
+ cwd: payload.cwd,
14063
+ filePath,
14064
+ git: payload.git
14065
+ };
14066
+ }
14067
+ }
14068
+ return null;
14069
+ } catch (error) {
14070
+ return null;
14071
+ }
14072
+ }
14073
+ async function getAllCodexSessions() {
14074
+ const sessions = [];
14075
+ const codexSessionsDir = getCodexSessionsDir();
14076
+ try {
14077
+ const years = await readdir(codexSessionsDir);
14078
+ for (const year of years) {
14079
+ const yearPath = path7.join(codexSessionsDir, year);
14080
+ try {
14081
+ const months = await readdir(yearPath);
14082
+ for (const month of months) {
14083
+ const monthPath = path7.join(yearPath, month);
14084
+ try {
14085
+ const days = await readdir(monthPath);
14086
+ for (const day of days) {
14087
+ const dayPath = path7.join(monthPath, day);
14088
+ try {
14089
+ const files = await readdir(dayPath);
14090
+ for (const file of files) {
14091
+ if (file.endsWith(".jsonl")) {
14092
+ const sessionPath = path7.join(dayPath, file);
14093
+ const session = await parseCodexSessionFile(sessionPath);
14094
+ if (session) {
14095
+ sessions.push(session);
14096
+ }
14097
+ }
14098
+ }
14099
+ } catch (error) {}
14100
+ }
14101
+ } catch (error) {}
14102
+ }
14103
+ } catch (error) {}
14104
+ }
14105
+ } catch (error) {
14106
+ return [];
14107
+ }
14108
+ return sessions.sort((a2, b) => new Date(b.timestamp).getTime() - new Date(a2.timestamp).getTime());
14109
+ }
14110
+ async function getMostRecentCodexSessionForCwd(targetCwd) {
14111
+ const allSessions = await getAllCodexSessions();
14112
+ const sessionsForCwd = allSessions.filter((session) => session.cwd === targetCwd);
14113
+ return sessionsForCwd[0] || null;
14114
+ }
14047
14115
  async function getSessionForCwd(cwd) {
14116
+ const recentSession = await getMostRecentCodexSessionForCwd(cwd);
14117
+ if (recentSession) {
14118
+ return recentSession.id;
14119
+ }
14048
14120
  const sessionMap = await loadSessionMap();
14049
14121
  return sessionMap[cwd]?.sessionId || null;
14050
14122
  }
@@ -14053,10 +14125,8 @@ function extractSessionId(output) {
14053
14125
  const match = output.match(sessionIdRegex);
14054
14126
  return match ? match[0] : null;
14055
14127
  }
14056
- var SESSIONS_FILE;
14057
- var init_codexSessionManager = __esm(() => {
14058
- SESSIONS_FILE = path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json");
14059
- });
14128
+ var getSessionsFile = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".config", "cli-yes", "codex-sessions.json") : path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json"), getCodexSessionsDir = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".codex", "sessions") : path7.join(homedir(), ".codex", "sessions");
14129
+ var init_codexSessionManager = () => {};
14060
14130
 
14061
14131
  // ts/idleWaiter.ts
14062
14132
  class IdleWaiter {
@@ -20339,8 +20409,9 @@ var init_ts = __esm(async () => {
20339
20409
  // ts/cli.ts
20340
20410
  init_dist();
20341
20411
  init_cli_yes_config();
20342
- if (!globalThis.Bun) {
20343
- console.log("Re-running with Bun...", process.argv);
20412
+ var hasNodePty = !!await import("node-pty").catch(() => null);
20413
+ if (!globalThis.Bun && !hasNodePty) {
20414
+ console.log("No node-pty installed. Re-running with Bun...", process.argv);
20344
20415
  (await import("child_process")).spawnSync("node_modules/.bin/bun", [process.argv[1], "--", ...process.argv.slice(2)], { stdio: "inherit" });
20345
20416
  process.exit(0);
20346
20417
  }
@@ -20357,5 +20428,5 @@ if (config2.verbose) {
20357
20428
  var { exitCode } = await cliYes2(config2);
20358
20429
  process.exit(exitCode ?? 1);
20359
20430
 
20360
- //# debugId=A6B971C2331DA0F864756E2164756E21
20431
+ //# debugId=229819D0379CAA1264756E2164756E21
20361
20432
  //# sourceMappingURL=cli.js.map
package/dist/grok-yes.js CHANGED
@@ -14017,12 +14017,12 @@ function catcher(catchFn, fn) {
14017
14017
  }
14018
14018
 
14019
14019
  // ts/codexSessionManager.ts
14020
- import { mkdir, readFile, writeFile } from "fs/promises";
14020
+ import { mkdir, readdir, readFile, writeFile } from "fs/promises";
14021
14021
  import { homedir } from "os";
14022
14022
  import path7 from "path";
14023
14023
  async function loadSessionMap() {
14024
14024
  try {
14025
- const content = await readFile(SESSIONS_FILE, "utf-8");
14025
+ const content = await readFile(getSessionsFile(), "utf-8");
14026
14026
  return JSON.parse(content);
14027
14027
  } catch (error) {
14028
14028
  return {};
@@ -14030,8 +14030,9 @@ async function loadSessionMap() {
14030
14030
  }
14031
14031
  async function saveSessionMap(sessionMap) {
14032
14032
  try {
14033
- await mkdir(path7.dirname(SESSIONS_FILE), { recursive: true });
14034
- await writeFile(SESSIONS_FILE, JSON.stringify(sessionMap, null, 2));
14033
+ const sessionsFile = getSessionsFile();
14034
+ await mkdir(path7.dirname(sessionsFile), { recursive: true });
14035
+ await writeFile(sessionsFile, JSON.stringify(sessionMap, null, 2));
14035
14036
  } catch (error) {
14036
14037
  console.warn("Failed to save codex session map:", error);
14037
14038
  }
@@ -14044,7 +14045,78 @@ async function storeSessionForCwd(cwd, sessionId) {
14044
14045
  };
14045
14046
  await saveSessionMap(sessionMap);
14046
14047
  }
14048
+ async function parseCodexSessionFile(filePath) {
14049
+ try {
14050
+ const content = await readFile(filePath, "utf-8");
14051
+ const lines2 = content.trim().split(`
14052
+ `);
14053
+ for (const line of lines2) {
14054
+ if (!line.trim())
14055
+ continue;
14056
+ const data = JSON.parse(line);
14057
+ if (data.type === "session_meta" && data.payload) {
14058
+ const payload = data.payload;
14059
+ return {
14060
+ id: payload.id,
14061
+ timestamp: payload.timestamp || data.timestamp,
14062
+ cwd: payload.cwd,
14063
+ filePath,
14064
+ git: payload.git
14065
+ };
14066
+ }
14067
+ }
14068
+ return null;
14069
+ } catch (error) {
14070
+ return null;
14071
+ }
14072
+ }
14073
+ async function getAllCodexSessions() {
14074
+ const sessions = [];
14075
+ const codexSessionsDir = getCodexSessionsDir();
14076
+ try {
14077
+ const years = await readdir(codexSessionsDir);
14078
+ for (const year of years) {
14079
+ const yearPath = path7.join(codexSessionsDir, year);
14080
+ try {
14081
+ const months = await readdir(yearPath);
14082
+ for (const month of months) {
14083
+ const monthPath = path7.join(yearPath, month);
14084
+ try {
14085
+ const days = await readdir(monthPath);
14086
+ for (const day of days) {
14087
+ const dayPath = path7.join(monthPath, day);
14088
+ try {
14089
+ const files = await readdir(dayPath);
14090
+ for (const file of files) {
14091
+ if (file.endsWith(".jsonl")) {
14092
+ const sessionPath = path7.join(dayPath, file);
14093
+ const session = await parseCodexSessionFile(sessionPath);
14094
+ if (session) {
14095
+ sessions.push(session);
14096
+ }
14097
+ }
14098
+ }
14099
+ } catch (error) {}
14100
+ }
14101
+ } catch (error) {}
14102
+ }
14103
+ } catch (error) {}
14104
+ }
14105
+ } catch (error) {
14106
+ return [];
14107
+ }
14108
+ return sessions.sort((a2, b) => new Date(b.timestamp).getTime() - new Date(a2.timestamp).getTime());
14109
+ }
14110
+ async function getMostRecentCodexSessionForCwd(targetCwd) {
14111
+ const allSessions = await getAllCodexSessions();
14112
+ const sessionsForCwd = allSessions.filter((session) => session.cwd === targetCwd);
14113
+ return sessionsForCwd[0] || null;
14114
+ }
14047
14115
  async function getSessionForCwd(cwd) {
14116
+ const recentSession = await getMostRecentCodexSessionForCwd(cwd);
14117
+ if (recentSession) {
14118
+ return recentSession.id;
14119
+ }
14048
14120
  const sessionMap = await loadSessionMap();
14049
14121
  return sessionMap[cwd]?.sessionId || null;
14050
14122
  }
@@ -14053,10 +14125,8 @@ function extractSessionId(output) {
14053
14125
  const match = output.match(sessionIdRegex);
14054
14126
  return match ? match[0] : null;
14055
14127
  }
14056
- var SESSIONS_FILE;
14057
- var init_codexSessionManager = __esm(() => {
14058
- SESSIONS_FILE = path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json");
14059
- });
14128
+ var getSessionsFile = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".config", "cli-yes", "codex-sessions.json") : path7.join(homedir(), ".config", "cli-yes", "codex-sessions.json"), getCodexSessionsDir = () => process.env.CLI_YES_TEST_HOME ? path7.join(process.env.CLI_YES_TEST_HOME, ".codex", "sessions") : path7.join(homedir(), ".codex", "sessions");
14129
+ var init_codexSessionManager = () => {};
14060
14130
 
14061
14131
  // ts/idleWaiter.ts
14062
14132
  class IdleWaiter {
@@ -20339,8 +20409,9 @@ var init_ts = __esm(async () => {
20339
20409
  // ts/cli.ts
20340
20410
  init_dist();
20341
20411
  init_cli_yes_config();
20342
- if (!globalThis.Bun) {
20343
- console.log("Re-running with Bun...", process.argv);
20412
+ var hasNodePty = !!await import("node-pty").catch(() => null);
20413
+ if (!globalThis.Bun && !hasNodePty) {
20414
+ console.log("No node-pty installed. Re-running with Bun...", process.argv);
20344
20415
  (await import("child_process")).spawnSync("node_modules/.bin/bun", [process.argv[1], "--", ...process.argv.slice(2)], { stdio: "inherit" });
20345
20416
  process.exit(0);
20346
20417
  }
@@ -20357,5 +20428,5 @@ if (config2.verbose) {
20357
20428
  var { exitCode } = await cliYes2(config2);
20358
20429
  process.exit(exitCode ?? 1);
20359
20430
 
20360
- //# debugId=A6B971C2331DA0F864756E2164756E21
20431
+ //# debugId=229819D0379CAA1264756E2164756E21
20361
20432
  //# sourceMappingURL=cli.js.map