@adhdev/daemon-core 0.9.82-rc.173 → 0.9.82-rc.174

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
@@ -11385,13 +11385,15 @@ function executeJsonl(src, input) {
11385
11385
  try {
11386
11386
  stat2 = fs13.statSync(resolved);
11387
11387
  } catch {
11388
- return null;
11389
11388
  }
11390
- if (stat2.isFile()) {
11389
+ if (stat2 && stat2.isFile()) {
11391
11390
  sourcePath = resolved;
11392
- } else if (stat2.isDirectory()) {
11391
+ } else if (stat2 && stat2.isDirectory()) {
11393
11392
  sourcePath = newestRecentFile(resolved, filePat, windowMs, sessionFloor);
11394
11393
  }
11394
+ if (!sourcePath && hasDateTemplateSegment(src.path)) {
11395
+ sourcePath = newestRecentFileAcrossDateWindow(src.path, input, filePat, windowMs, sessionFloor);
11396
+ }
11395
11397
  }
11396
11398
  if (!sourcePath) return null;
11397
11399
  const mtime = safeMtimeMs(sourcePath);
@@ -11614,6 +11616,69 @@ function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs
11614
11616
  }
11615
11617
  return best ? best.p : null;
11616
11618
  }
11619
+ function hasDateTemplateSegment(template) {
11620
+ return /\{yyyy\}|\{mm\}|\{dd\}/.test(template);
11621
+ }
11622
+ function newestRecentFileAcrossDateWindow(template, input, pattern, windowMs, sessionFloorMs) {
11623
+ const cutoff = Math.max(Date.now() - windowMs, sessionFloorMs);
11624
+ let best = null;
11625
+ for (let dayOffset = 0; dayOffset < 3; dayOffset += 1) {
11626
+ const dayMs = Date.now() - dayOffset * 24 * 60 * 60 * 1e3;
11627
+ const dayInput = { ...input, sessionStartedAtMs: sessionFloorMs };
11628
+ const resolved = expandPathForDate(template, dayInput, new Date(dayMs));
11629
+ if (!resolved) continue;
11630
+ let entries;
11631
+ try {
11632
+ entries = fs13.readdirSync(resolved, { withFileTypes: true });
11633
+ } catch {
11634
+ continue;
11635
+ }
11636
+ for (const e of entries) {
11637
+ if (!e.isFile() || !pattern.test(e.name)) continue;
11638
+ const p = path25.join(resolved, e.name);
11639
+ const mtime = safeMtimeMs(p);
11640
+ if (mtime < cutoff) continue;
11641
+ if (!best || mtime > best.mtime) best = { p, mtime };
11642
+ }
11643
+ }
11644
+ return best ? best.p : null;
11645
+ }
11646
+ function expandPathForDate(template, input, day) {
11647
+ if (!template) return null;
11648
+ let out = template;
11649
+ if (out.startsWith("~/") || out === "~") {
11650
+ out = path25.join(os18.homedir(), out.slice(2));
11651
+ }
11652
+ out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
11653
+ const v = input.envOverrides?.[name] ?? process.env[name];
11654
+ return v != null && v !== "" ? v : fallback ?? "";
11655
+ });
11656
+ if (out.startsWith("~/")) out = path25.join(os18.homedir(), out.slice(2));
11657
+ const workspaceRaw = input.workspace ?? "";
11658
+ let workspaceResolved = workspaceRaw;
11659
+ if (workspaceRaw) {
11660
+ try {
11661
+ workspaceResolved = fs13.realpathSync(workspaceRaw);
11662
+ } catch {
11663
+ }
11664
+ }
11665
+ const vars = {
11666
+ cwd: workspaceResolved,
11667
+ cwd_dashed: workspaceResolved.replace(/\//g, "-"),
11668
+ session_id: input.providerSessionId || input.sessionId || input.historySessionId || "",
11669
+ yyyy: String(day.getUTCFullYear()),
11670
+ mm: String(day.getUTCMonth() + 1).padStart(2, "0"),
11671
+ dd: String(day.getUTCDate()).padStart(2, "0")
11672
+ };
11673
+ let missing = false;
11674
+ out = out.replace(/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g, (_m, name) => {
11675
+ const v = vars[name] ?? "";
11676
+ if (!v) missing = true;
11677
+ return v;
11678
+ });
11679
+ if (missing) return null;
11680
+ return out;
11681
+ }
11617
11682
  function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
11618
11683
  let entries;
11619
11684
  try {