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