@adhdev/daemon-core 0.9.82-rc.313 → 0.9.82-rc.315
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/commands/upgrade-helper.d.ts +12 -0
- package/dist/index.js +116 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/commands/upgrade-helper.ts +52 -30
- package/src/providers/spec/native-history-executor.ts +104 -3
package/dist/index.mjs
CHANGED
|
@@ -311,10 +311,10 @@ function readInjected(value) {
|
|
|
311
311
|
}
|
|
312
312
|
function getDaemonBuildInfo() {
|
|
313
313
|
if (cached) return cached;
|
|
314
|
-
const commit = readInjected(true ? "
|
|
315
|
-
const commitShort = readInjected(true ? "
|
|
316
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
317
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
314
|
+
const commit = readInjected(true ? "e28347641639c9d0a1e46a6141e3cfed2bc90ac2" : void 0) ?? "unknown";
|
|
315
|
+
const commitShort = readInjected(true ? "e2834764" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
316
|
+
const version = readInjected(true ? "0.9.82-rc.315" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
317
|
+
const builtAt = readInjected(true ? "2026-06-18T05:47:44.462Z" : void 0);
|
|
318
318
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
319
319
|
return cached;
|
|
320
320
|
}
|
|
@@ -31044,6 +31044,7 @@ function collectStableSizes(when, sizes) {
|
|
|
31044
31044
|
}
|
|
31045
31045
|
|
|
31046
31046
|
// src/providers/spec/native-history-executor.ts
|
|
31047
|
+
init_logger();
|
|
31047
31048
|
import * as fs12 from "fs";
|
|
31048
31049
|
import * as os17 from "os";
|
|
31049
31050
|
import * as path21 from "path";
|
|
@@ -31079,8 +31080,33 @@ function executeJsonl(src, input) {
|
|
|
31079
31080
|
if (!sourcePath && hasDateTemplateSegment(src.path)) {
|
|
31080
31081
|
sourcePath = pickExactSessionFileAcrossDateWindow(src.path, input, filePat, requestedSessionId) || (requestedSessionId ? null : pickSessionBoundFileAcrossDateWindow(src.path, input, filePat, windowMs, sessionFloor, workspaceHint)) || (requestedSessionId ? null : newestRecentFileAcrossDateWindow(src.path, input, filePat, windowMs, sessionFloor));
|
|
31081
31082
|
}
|
|
31083
|
+
if (!sourcePath && !hasDateTemplateSegment(src.path)) {
|
|
31084
|
+
const resolvedRaw = expandPath2(src.path, input, { skipWorkspaceRealpath: true });
|
|
31085
|
+
if (resolvedRaw && resolvedRaw !== resolved) {
|
|
31086
|
+
try {
|
|
31087
|
+
const rawStat = fs12.statSync(resolvedRaw);
|
|
31088
|
+
if (rawStat.isFile()) sourcePath = resolvedRaw;
|
|
31089
|
+
else if (rawStat.isDirectory()) {
|
|
31090
|
+
sourcePath = pickExactSessionFile(resolvedRaw, filePat, requestedSessionId) || (requestedSessionId ? null : newestRecentFile(resolvedRaw, filePat, windowMs, sessionFloor));
|
|
31091
|
+
}
|
|
31092
|
+
} catch {
|
|
31093
|
+
}
|
|
31094
|
+
}
|
|
31095
|
+
}
|
|
31096
|
+
if (!sourcePath && requestedSessionId) {
|
|
31097
|
+
sourcePath = scanProjectsRootForSessionFile(src.path, input, requestedSessionId);
|
|
31098
|
+
}
|
|
31099
|
+
}
|
|
31100
|
+
if (!sourcePath) {
|
|
31101
|
+
const wsRaw = typeof input.workspace === "string" ? input.workspace : "";
|
|
31102
|
+
let wsReal = wsRaw;
|
|
31103
|
+
try {
|
|
31104
|
+
if (wsRaw) wsReal = fs12.realpathSync(wsRaw);
|
|
31105
|
+
} catch {
|
|
31106
|
+
}
|
|
31107
|
+
LOG.debug("NativeHistory", `jsonl unresolved: tried=${JSON.stringify(resolved)} sessionId=${requestedSessionId || "(none)"} wsRaw=${JSON.stringify(wsRaw)} wsReal=${JSON.stringify(wsReal)} rawSlug=${JSON.stringify(claudeProjectDirName(wsRaw))} realSlug=${JSON.stringify(claudeProjectDirName(wsReal))} (concrete miss + raw-slug retry + projects scan all failed)`);
|
|
31108
|
+
return null;
|
|
31082
31109
|
}
|
|
31083
|
-
if (!sourcePath) return null;
|
|
31084
31110
|
const mtime = safeMtimeMs(sourcePath);
|
|
31085
31111
|
const lines = readJsonlLines(sourcePath);
|
|
31086
31112
|
if (lines.length === 0) return null;
|
|
@@ -31199,7 +31225,7 @@ function executeSqlite(src, input) {
|
|
|
31199
31225
|
}
|
|
31200
31226
|
}
|
|
31201
31227
|
}
|
|
31202
|
-
function expandPath2(template, input) {
|
|
31228
|
+
function expandPath2(template, input, opts) {
|
|
31203
31229
|
if (!template) return null;
|
|
31204
31230
|
let out = template;
|
|
31205
31231
|
if (out.startsWith("~/") || out === "~") {
|
|
@@ -31213,7 +31239,7 @@ function expandPath2(template, input) {
|
|
|
31213
31239
|
const now = /* @__PURE__ */ new Date();
|
|
31214
31240
|
const workspaceRaw = input.workspace ?? "";
|
|
31215
31241
|
let workspaceResolved = workspaceRaw;
|
|
31216
|
-
if (workspaceRaw) {
|
|
31242
|
+
if (workspaceRaw && !opts?.skipWorkspaceRealpath) {
|
|
31217
31243
|
try {
|
|
31218
31244
|
workspaceResolved = fs12.realpathSync(workspaceRaw);
|
|
31219
31245
|
} catch {
|
|
@@ -31240,6 +31266,50 @@ function expandPath2(template, input) {
|
|
|
31240
31266
|
function claudeProjectDirName(workspace) {
|
|
31241
31267
|
return workspace.replace(/[^A-Za-z0-9_-]/g, "-");
|
|
31242
31268
|
}
|
|
31269
|
+
function scanProjectsRootForSessionFile(template, input, requestedSessionId) {
|
|
31270
|
+
if (!requestedSessionId) return null;
|
|
31271
|
+
let head = template;
|
|
31272
|
+
if (head.startsWith("~/") || head === "~") head = path21.join(os17.homedir(), head.slice(2));
|
|
31273
|
+
const segs = head.split("/");
|
|
31274
|
+
const baseParts = [];
|
|
31275
|
+
for (const seg of segs) {
|
|
31276
|
+
if (/[{}*?]/.test(seg)) break;
|
|
31277
|
+
baseParts.push(seg);
|
|
31278
|
+
}
|
|
31279
|
+
const base = baseParts.join("/");
|
|
31280
|
+
if (!base) return null;
|
|
31281
|
+
let baseStat = null;
|
|
31282
|
+
try {
|
|
31283
|
+
baseStat = fs12.statSync(base);
|
|
31284
|
+
} catch {
|
|
31285
|
+
return null;
|
|
31286
|
+
}
|
|
31287
|
+
if (!baseStat.isDirectory()) return null;
|
|
31288
|
+
const needle = `${requestedSessionId.toLowerCase()}.jsonl`;
|
|
31289
|
+
const dirsToScan = [base];
|
|
31290
|
+
try {
|
|
31291
|
+
for (const entry of fs12.readdirSync(base, { withFileTypes: true })) {
|
|
31292
|
+
if (entry.isDirectory()) dirsToScan.push(path21.join(base, entry.name));
|
|
31293
|
+
}
|
|
31294
|
+
} catch {
|
|
31295
|
+
}
|
|
31296
|
+
for (const dir of dirsToScan) {
|
|
31297
|
+
let entries;
|
|
31298
|
+
try {
|
|
31299
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
31300
|
+
} catch {
|
|
31301
|
+
continue;
|
|
31302
|
+
}
|
|
31303
|
+
for (const entry of entries) {
|
|
31304
|
+
if (!entry.isFile()) continue;
|
|
31305
|
+
if (entry.name.toLowerCase() !== needle) continue;
|
|
31306
|
+
const found = path21.join(dir, entry.name);
|
|
31307
|
+
LOG.debug("NativeHistory", `jsonl scan-fallback hit: sessionId=${requestedSessionId} resolved via projects-root scan \u2192 ${JSON.stringify(found)} (slug-derived path missed; likely realpath/slug divergence)`);
|
|
31308
|
+
return found;
|
|
31309
|
+
}
|
|
31310
|
+
}
|
|
31311
|
+
return null;
|
|
31312
|
+
}
|
|
31243
31313
|
function globToRegex(pattern) {
|
|
31244
31314
|
const re = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]");
|
|
31245
31315
|
return new RegExp(`^${re}$`);
|
|
@@ -41820,39 +41890,48 @@ function removeDaemonPidFile() {
|
|
|
41820
41890
|
} catch {
|
|
41821
41891
|
}
|
|
41822
41892
|
}
|
|
41893
|
+
function safeRemoveStaleEntry(target, label) {
|
|
41894
|
+
try {
|
|
41895
|
+
fs24.rmSync(target, { recursive: true, force: true });
|
|
41896
|
+
appendUpgradeLog(`${label}: ${target}`);
|
|
41897
|
+
} catch (error) {
|
|
41898
|
+
appendUpgradeLog(`Skipped locked stale entry (${error?.code || "error"}): ${target} \u2014 ${error?.message || String(error)}`);
|
|
41899
|
+
}
|
|
41900
|
+
}
|
|
41823
41901
|
function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
41824
|
-
|
|
41825
|
-
|
|
41826
|
-
|
|
41827
|
-
|
|
41828
|
-
|
|
41829
|
-
|
|
41830
|
-
|
|
41831
|
-
|
|
41832
|
-
|
|
41833
|
-
|
|
41834
|
-
|
|
41835
|
-
|
|
41836
|
-
|
|
41837
|
-
|
|
41838
|
-
|
|
41839
|
-
|
|
41840
|
-
|
|
41841
|
-
|
|
41842
|
-
|
|
41843
|
-
|
|
41844
|
-
|
|
41845
|
-
|
|
41846
|
-
|
|
41847
|
-
|
|
41902
|
+
try {
|
|
41903
|
+
const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
|
|
41904
|
+
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
41905
|
+
if (!npmRoot) return;
|
|
41906
|
+
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
41907
|
+
const binDir = process.platform === "win32" ? npmPrefix : path35.join(npmPrefix, "bin");
|
|
41908
|
+
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
41909
|
+
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
41910
|
+
if (pkgName === "@adhdev/daemon-standalone") {
|
|
41911
|
+
binNames.add("adhdev-standalone");
|
|
41912
|
+
}
|
|
41913
|
+
if (pkgName.startsWith("@")) {
|
|
41914
|
+
const [scope, name] = pkgName.split("/");
|
|
41915
|
+
const scopeDir = path35.join(npmRoot, scope);
|
|
41916
|
+
if (!fs24.existsSync(scopeDir)) return;
|
|
41917
|
+
for (const entry of fs24.readdirSync(scopeDir)) {
|
|
41918
|
+
if (!entry.startsWith(`.${name}-`)) continue;
|
|
41919
|
+
safeRemoveStaleEntry(path35.join(scopeDir, entry), "Removed stale scoped staging dir");
|
|
41920
|
+
}
|
|
41921
|
+
} else {
|
|
41922
|
+
for (const entry of fs24.readdirSync(npmRoot)) {
|
|
41923
|
+
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
41924
|
+
safeRemoveStaleEntry(path35.join(npmRoot, entry), "Removed stale staging dir");
|
|
41925
|
+
}
|
|
41848
41926
|
}
|
|
41849
|
-
|
|
41850
|
-
|
|
41851
|
-
|
|
41852
|
-
|
|
41853
|
-
|
|
41854
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${path35.join(binDir, entry)}`);
|
|
41927
|
+
if (fs24.existsSync(binDir)) {
|
|
41928
|
+
for (const entry of fs24.readdirSync(binDir)) {
|
|
41929
|
+
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
41930
|
+
safeRemoveStaleEntry(path35.join(binDir, entry), "Removed stale bin staging entry");
|
|
41931
|
+
}
|
|
41855
41932
|
}
|
|
41933
|
+
} catch (error) {
|
|
41934
|
+
appendUpgradeLog(`Stale staging cleanup skipped (${error?.code || "error"}): ${error?.message || String(error)}`);
|
|
41856
41935
|
}
|
|
41857
41936
|
}
|
|
41858
41937
|
function spawnDetachedDaemonUpgradeHelper(payload) {
|