waypoint-codex 0.1.10 → 0.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waypoint-codex",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Codex-native repository operating system: scaffolding, docs routing, repo-local skills, doctor, and sync.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -213,7 +213,9 @@ function mergeConsecutiveTurns(turns) {
213
213
  }
214
214
 
215
215
  function parseSession(sessionFile, projectRoot) {
216
+ let sessionId = null;
216
217
  let sessionCwd = null;
218
+ let sessionStartedAt = null;
217
219
  let compactionCount = 0;
218
220
  const rawTurns = [];
219
221
  const compactionBoundaries = [];
@@ -231,10 +233,18 @@ function parseSession(sessionFile, projectRoot) {
231
233
  }
232
234
 
233
235
  if (parsed.type === "session_meta") {
236
+ const sessionMetaId = parsed.payload?.id;
237
+ if (typeof sessionMetaId === "string") {
238
+ sessionId = sessionMetaId;
239
+ }
234
240
  const cwd = parsed.payload?.cwd;
235
241
  if (typeof cwd === "string") {
236
242
  sessionCwd = cwd;
237
243
  }
244
+ const timestamp = parsed.payload?.timestamp;
245
+ if (typeof timestamp === "string") {
246
+ sessionStartedAt = timestamp;
247
+ }
238
248
  continue;
239
249
  }
240
250
 
@@ -279,14 +289,16 @@ function parseSession(sessionFile, projectRoot) {
279
289
 
280
290
  return {
281
291
  path: sessionFile,
292
+ sessionId,
282
293
  sessionCwd,
283
294
  turns,
284
295
  compactionCount,
285
296
  selectedFromPreCompaction,
297
+ sessionStartedAt,
286
298
  };
287
299
  }
288
300
 
289
- function latestMatchingSession(projectRoot) {
301
+ function latestMatchingSession(projectRoot, threadIdOverride = null) {
290
302
  const matches = [];
291
303
  for (const dirName of SESSION_DIR_NAMES) {
292
304
  for (const sessionFile of collectSessionFiles(path.join(codexHome(), dirName))) {
@@ -297,13 +309,28 @@ function latestMatchingSession(projectRoot) {
297
309
  }
298
310
  }
299
311
 
300
- matches.sort((a, b) => statSync(b.path).mtimeMs - statSync(a.path).mtimeMs);
312
+ const requestedThreadId = threadIdOverride || process.env.CODEX_THREAD_ID || null;
313
+ if (requestedThreadId) {
314
+ const exact = matches.find((item) => item.sessionId === requestedThreadId);
315
+ if (exact) {
316
+ return exact;
317
+ }
318
+ }
319
+
320
+ matches.sort((a, b) => {
321
+ const left = a.sessionStartedAt || "";
322
+ const right = b.sessionStartedAt || "";
323
+ if (left === right) {
324
+ return b.path.localeCompare(a.path);
325
+ }
326
+ return right.localeCompare(left);
327
+ });
301
328
  return matches[0] || null;
302
329
  }
303
330
 
304
- function writeRecentThread(contextDir, projectRoot) {
331
+ function writeRecentThread(contextDir, projectRoot, threadIdOverride = null) {
305
332
  const filePath = path.join(contextDir, "RECENT_THREAD.md");
306
- const snapshot = latestMatchingSession(projectRoot);
333
+ const snapshot = latestMatchingSession(projectRoot, threadIdOverride);
307
334
  const generatedAt = new Date().toString();
308
335
 
309
336
  if (!snapshot) {
@@ -414,6 +441,11 @@ function main() {
414
441
  const projectRoot = detectProjectRoot();
415
442
  const contextDir = path.join(projectRoot, ".waypoint", "context");
416
443
  ensureDir(contextDir);
444
+ const threadIdFlagIndex = process.argv.indexOf("--thread-id");
445
+ const threadIdOverride =
446
+ threadIdFlagIndex >= 0 && threadIdFlagIndex + 1 < process.argv.length
447
+ ? process.argv[threadIdFlagIndex + 1]
448
+ : null;
417
449
 
418
450
  const docsIndexPath = writeDocsIndex(projectRoot);
419
451
 
@@ -557,7 +589,7 @@ function main() {
557
589
  "```",
558
590
  ].join("\n")
559
591
  );
560
- const recentThreadPath = writeRecentThread(contextDir, projectRoot);
592
+ const recentThreadPath = writeRecentThread(contextDir, projectRoot, threadIdOverride);
561
593
 
562
594
  const manifestPath = path.join(contextDir, "MANIFEST.md");
563
595
  const manifestLines = [