@adhdev/daemon-standalone 0.9.49 → 0.9.51
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 +472 -403
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-CgLuVDjL.js +92 -0
- package/public/index.html +1 -1
- package/public/assets/index-CXnxi_4k.js +0 -91
package/dist/index.js
CHANGED
|
@@ -29209,14 +29209,14 @@ var require_dist2 = __commonJS({
|
|
|
29209
29209
|
}
|
|
29210
29210
|
return cachedPty;
|
|
29211
29211
|
}
|
|
29212
|
-
var
|
|
29212
|
+
var os8;
|
|
29213
29213
|
var cachedPty;
|
|
29214
29214
|
var NodePtyRuntimeTransport;
|
|
29215
29215
|
var NodePtyTransportFactory;
|
|
29216
29216
|
var init_pty_transport = __esm2({
|
|
29217
29217
|
"src/cli-adapters/pty-transport.ts"() {
|
|
29218
29218
|
"use strict";
|
|
29219
|
-
|
|
29219
|
+
os8 = __toESM2(require("os"));
|
|
29220
29220
|
init_spawn_env();
|
|
29221
29221
|
NodePtyRuntimeTransport = class {
|
|
29222
29222
|
constructor(handle) {
|
|
@@ -29253,11 +29253,11 @@ var require_dist2 = __commonJS({
|
|
|
29253
29253
|
let cwd = options.cwd;
|
|
29254
29254
|
if (cwd) {
|
|
29255
29255
|
try {
|
|
29256
|
-
const
|
|
29257
|
-
const stat4 =
|
|
29258
|
-
if (!stat4.isDirectory()) cwd =
|
|
29256
|
+
const fs16 = require("fs");
|
|
29257
|
+
const stat4 = fs16.statSync(cwd);
|
|
29258
|
+
if (!stat4.isDirectory()) cwd = os8.homedir();
|
|
29259
29259
|
} catch {
|
|
29260
|
-
cwd =
|
|
29260
|
+
cwd = os8.homedir();
|
|
29261
29261
|
}
|
|
29262
29262
|
}
|
|
29263
29263
|
const handle = pty.spawn(command, args, {
|
|
@@ -29335,11 +29335,11 @@ var require_dist2 = __commonJS({
|
|
|
29335
29335
|
function findBinary(name) {
|
|
29336
29336
|
const trimmed = String(name || "").trim();
|
|
29337
29337
|
if (!trimmed) return trimmed;
|
|
29338
|
-
const expanded = trimmed.startsWith("~") ?
|
|
29339
|
-
if (
|
|
29340
|
-
return
|
|
29338
|
+
const expanded = trimmed.startsWith("~") ? path10.join(os9.homedir(), trimmed.slice(1)) : trimmed;
|
|
29339
|
+
if (path10.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
29340
|
+
return path10.isAbsolute(expanded) ? expanded : path10.resolve(expanded);
|
|
29341
29341
|
}
|
|
29342
|
-
const isWin =
|
|
29342
|
+
const isWin = os9.platform() === "win32";
|
|
29343
29343
|
try {
|
|
29344
29344
|
const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
|
|
29345
29345
|
return (0, import_child_process4.execSync)(cmd, {
|
|
@@ -29353,14 +29353,14 @@ var require_dist2 = __commonJS({
|
|
|
29353
29353
|
}
|
|
29354
29354
|
}
|
|
29355
29355
|
function isScriptBinary(binaryPath) {
|
|
29356
|
-
if (!
|
|
29356
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
29357
29357
|
try {
|
|
29358
|
-
const
|
|
29359
|
-
const resolved =
|
|
29358
|
+
const fs16 = require("fs");
|
|
29359
|
+
const resolved = fs16.realpathSync(binaryPath);
|
|
29360
29360
|
const head = Buffer.alloc(8);
|
|
29361
|
-
const fd =
|
|
29362
|
-
|
|
29363
|
-
|
|
29361
|
+
const fd = fs16.openSync(resolved, "r");
|
|
29362
|
+
fs16.readSync(fd, head, 0, 8, 0);
|
|
29363
|
+
fs16.closeSync(fd);
|
|
29364
29364
|
let i = 0;
|
|
29365
29365
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
29366
29366
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -29369,14 +29369,14 @@ var require_dist2 = __commonJS({
|
|
|
29369
29369
|
}
|
|
29370
29370
|
}
|
|
29371
29371
|
function looksLikeMachOOrElf(filePath) {
|
|
29372
|
-
if (!
|
|
29372
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
29373
29373
|
try {
|
|
29374
|
-
const
|
|
29375
|
-
const resolved =
|
|
29374
|
+
const fs16 = require("fs");
|
|
29375
|
+
const resolved = fs16.realpathSync(filePath);
|
|
29376
29376
|
const buf = Buffer.alloc(8);
|
|
29377
|
-
const fd =
|
|
29378
|
-
|
|
29379
|
-
|
|
29377
|
+
const fd = fs16.openSync(resolved, "r");
|
|
29378
|
+
fs16.readSync(fd, buf, 0, 8, 0);
|
|
29379
|
+
fs16.closeSync(fd);
|
|
29380
29380
|
let i = 0;
|
|
29381
29381
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
29382
29382
|
const b2 = buf.subarray(i);
|
|
@@ -29392,7 +29392,7 @@ var require_dist2 = __commonJS({
|
|
|
29392
29392
|
}
|
|
29393
29393
|
function shSingleQuote(arg) {
|
|
29394
29394
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
29395
|
-
if (
|
|
29395
|
+
if (os9.platform() === "win32") {
|
|
29396
29396
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
29397
29397
|
}
|
|
29398
29398
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -29519,16 +29519,16 @@ var require_dist2 = __commonJS({
|
|
|
29519
29519
|
}
|
|
29520
29520
|
};
|
|
29521
29521
|
}
|
|
29522
|
-
var
|
|
29523
|
-
var
|
|
29522
|
+
var os9;
|
|
29523
|
+
var path10;
|
|
29524
29524
|
var import_child_process4;
|
|
29525
29525
|
var buildCliSpawnEnv;
|
|
29526
29526
|
var COMMON_COMPARABLE_WRAP_WORDS;
|
|
29527
29527
|
var init_provider_cli_shared = __esm2({
|
|
29528
29528
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
29529
29529
|
"use strict";
|
|
29530
|
-
|
|
29531
|
-
|
|
29530
|
+
os9 = __toESM2(require("os"));
|
|
29531
|
+
path10 = __toESM2(require("path"));
|
|
29532
29532
|
import_child_process4 = require("child_process");
|
|
29533
29533
|
init_spawn_env();
|
|
29534
29534
|
buildCliSpawnEnv = import_session_host_core3.sanitizeSpawnEnv;
|
|
@@ -29835,13 +29835,13 @@ var require_dist2 = __commonJS({
|
|
|
29835
29835
|
const { spawn: spawnConfig } = provider;
|
|
29836
29836
|
const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
|
|
29837
29837
|
const binaryPath = findBinary(configuredCommand);
|
|
29838
|
-
const isWin =
|
|
29838
|
+
const isWin = os10.platform() === "win32";
|
|
29839
29839
|
const allArgs = [...spawnConfig.args, ...extraArgs];
|
|
29840
29840
|
let shellCmd;
|
|
29841
29841
|
let shellArgs;
|
|
29842
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
29842
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
29843
29843
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
29844
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
29844
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
29845
29845
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
29846
29846
|
if (useShell) {
|
|
29847
29847
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -29917,14 +29917,14 @@ var require_dist2 = __commonJS({
|
|
|
29917
29917
|
}
|
|
29918
29918
|
return "";
|
|
29919
29919
|
}
|
|
29920
|
-
var
|
|
29921
|
-
var
|
|
29920
|
+
var os10;
|
|
29921
|
+
var path11;
|
|
29922
29922
|
var import_session_host_core22;
|
|
29923
29923
|
var init_provider_cli_runtime = __esm2({
|
|
29924
29924
|
"src/cli-adapters/provider-cli-runtime.ts"() {
|
|
29925
29925
|
"use strict";
|
|
29926
|
-
|
|
29927
|
-
|
|
29926
|
+
os10 = __toESM2(require("os"));
|
|
29927
|
+
path11 = __toESM2(require("path"));
|
|
29928
29928
|
import_session_host_core22 = require_dist();
|
|
29929
29929
|
init_provider_cli_shared();
|
|
29930
29930
|
}
|
|
@@ -30044,13 +30044,13 @@ var require_dist2 = __commonJS({
|
|
|
30044
30044
|
return;
|
|
30045
30045
|
}
|
|
30046
30046
|
}
|
|
30047
|
-
var
|
|
30047
|
+
var os11;
|
|
30048
30048
|
var COMMITTED_ACTIVITY_PREFIX_BLOCK_RE;
|
|
30049
30049
|
var ProviderCliAdapter;
|
|
30050
30050
|
var init_provider_cli_adapter = __esm2({
|
|
30051
30051
|
"src/cli-adapters/provider-cli-adapter.ts"() {
|
|
30052
30052
|
"use strict";
|
|
30053
|
-
|
|
30053
|
+
os11 = __toESM2(require("os"));
|
|
30054
30054
|
init_logger();
|
|
30055
30055
|
init_debug_config();
|
|
30056
30056
|
init_terminal_screen();
|
|
@@ -30070,7 +30070,7 @@ var require_dist2 = __commonJS({
|
|
|
30070
30070
|
this.transportFactory = transportFactory;
|
|
30071
30071
|
this.cliType = provider.type;
|
|
30072
30072
|
this.cliName = provider.name;
|
|
30073
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
30073
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os11.homedir()) : workingDir;
|
|
30074
30074
|
const resolvedConfig = resolveCliAdapterConfig(provider);
|
|
30075
30075
|
this.timeouts = resolvedConfig.timeouts;
|
|
30076
30076
|
this.approvalKeys = resolvedConfig.approvalKeys;
|
|
@@ -33129,17 +33129,17 @@ var require_dist2 = __commonJS({
|
|
|
33129
33129
|
return null;
|
|
33130
33130
|
}
|
|
33131
33131
|
async function detectIDEs(providerLoader) {
|
|
33132
|
-
const
|
|
33132
|
+
const os21 = (0, import_os22.platform)();
|
|
33133
33133
|
const results = [];
|
|
33134
33134
|
for (const def of getMergedDefinitions()) {
|
|
33135
33135
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
33136
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
33136
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os21] || []) || []);
|
|
33137
33137
|
let resolvedCli = cliPath;
|
|
33138
|
-
if (!resolvedCli && appPath &&
|
|
33138
|
+
if (!resolvedCli && appPath && os21 === "darwin") {
|
|
33139
33139
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
33140
33140
|
if ((0, import_fs3.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
33141
33141
|
}
|
|
33142
|
-
if (!resolvedCli && appPath &&
|
|
33142
|
+
if (!resolvedCli && appPath && os21 === "win32") {
|
|
33143
33143
|
const { dirname: dirname7 } = await import("path");
|
|
33144
33144
|
const appDir = dirname7(appPath);
|
|
33145
33145
|
const candidates = [
|
|
@@ -33156,7 +33156,7 @@ var require_dist2 = __commonJS({
|
|
|
33156
33156
|
}
|
|
33157
33157
|
}
|
|
33158
33158
|
}
|
|
33159
|
-
const installed =
|
|
33159
|
+
const installed = os21 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
33160
33160
|
const version2 = resolvedCli ? getIdeVersion(resolvedCli) : null;
|
|
33161
33161
|
results.push({
|
|
33162
33162
|
id: def.id,
|
|
@@ -38262,6 +38262,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38262
38262
|
}
|
|
38263
38263
|
return fn2() || null;
|
|
38264
38264
|
}
|
|
38265
|
+
var fs42 = __toESM2(require("fs"));
|
|
38266
|
+
var os62 = __toESM2(require("os"));
|
|
38267
|
+
var path8 = __toESM2(require("path"));
|
|
38268
|
+
var import_node_crypto = require("crypto");
|
|
38265
38269
|
init_contracts();
|
|
38266
38270
|
var VALID_INPUT_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
38267
38271
|
function getProviderLabel(provider) {
|
|
@@ -38941,10 +38945,57 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38941
38945
|
"```"
|
|
38942
38946
|
].join("\n");
|
|
38943
38947
|
}
|
|
38948
|
+
function getChatDebugBundleDir() {
|
|
38949
|
+
const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
|
|
38950
|
+
return override || path8.join(os62.homedir(), ".adhdev", "debug-bundles", "chat");
|
|
38951
|
+
}
|
|
38952
|
+
function safeBundleIdSegment(value, fallback) {
|
|
38953
|
+
const normalized = String(value || fallback).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
38954
|
+
return normalized || fallback;
|
|
38955
|
+
}
|
|
38956
|
+
function createChatDebugBundleId(targetSessionId) {
|
|
38957
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.]/g, "").replace("T", "T").replace("Z", "Z");
|
|
38958
|
+
const sessionSegment = safeBundleIdSegment(targetSessionId, "unknown-session");
|
|
38959
|
+
return `chat-debug-${timestamp}-${sessionSegment}-${(0, import_node_crypto.randomUUID)().slice(0, 8)}`;
|
|
38960
|
+
}
|
|
38961
|
+
function buildChatDebugBundleSummary(bundle) {
|
|
38962
|
+
const target = bundle.target && typeof bundle.target === "object" ? bundle.target : {};
|
|
38963
|
+
const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
|
|
38964
|
+
const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
|
|
38965
|
+
const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
|
|
38966
|
+
return {
|
|
38967
|
+
createdAt: bundle.createdAt,
|
|
38968
|
+
targetSessionId: target.targetSessionId,
|
|
38969
|
+
providerType: target.providerType,
|
|
38970
|
+
transport: target.transport,
|
|
38971
|
+
readChatSuccess: readChat.success,
|
|
38972
|
+
readChatStatus: readChat.status,
|
|
38973
|
+
readChatTotalMessages: readChat.totalMessages,
|
|
38974
|
+
cliStatus: cli?.status,
|
|
38975
|
+
cliMessageCount: cli?.messageCount,
|
|
38976
|
+
hasFrontendSnapshot: !!frontend
|
|
38977
|
+
};
|
|
38978
|
+
}
|
|
38979
|
+
function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
|
|
38980
|
+
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
38981
|
+
const dir = getChatDebugBundleDir();
|
|
38982
|
+
fs42.mkdirSync(dir, { recursive: true });
|
|
38983
|
+
const savedPath = path8.join(dir, `${bundleId}.json`);
|
|
38984
|
+
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
38985
|
+
`;
|
|
38986
|
+
fs42.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
38987
|
+
return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json2, "utf8") };
|
|
38988
|
+
}
|
|
38989
|
+
function isDaemonFileDebugDelivery(args) {
|
|
38990
|
+
return args?.delivery === "daemon_file" || args?.delivery === "file";
|
|
38991
|
+
}
|
|
38944
38992
|
async function handleGetChatDebugBundle(h, args) {
|
|
38993
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
38994
|
+
if (!targetSessionId && !h.currentSession) {
|
|
38995
|
+
return { success: false, error: "No targetSessionId specified \u2014 cannot route command" };
|
|
38996
|
+
}
|
|
38945
38997
|
const provider = h.getProvider(args?.agentType);
|
|
38946
38998
|
const transport = getTargetTransport(h, provider);
|
|
38947
|
-
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
38948
38999
|
const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
|
|
38949
39000
|
const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
|
|
38950
39001
|
const targetInstance = getTargetInstance(h, args);
|
|
@@ -39049,6 +39100,20 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39049
39100
|
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
39050
39101
|
};
|
|
39051
39102
|
const bundle = sanitizeDebugBundleValue(rawBundle);
|
|
39103
|
+
if (isDaemonFileDebugDelivery(args)) {
|
|
39104
|
+
const summary = buildChatDebugBundleSummary(bundle);
|
|
39105
|
+
const stored = storeChatDebugBundleOnDaemon(bundle, targetSessionId || String(summary.targetSessionId || "unknown-session"));
|
|
39106
|
+
LOG2.info("Command", `[get_chat_debug_bundle] saved daemon_file bundle id=${stored.bundleId} path=${stored.savedPath} sizeBytes=${stored.sizeBytes} targetSessionId=${summary.targetSessionId || ""} providerType=${summary.providerType || ""} transport=${summary.transport || ""}`);
|
|
39107
|
+
return {
|
|
39108
|
+
success: true,
|
|
39109
|
+
delivery: "daemon_file",
|
|
39110
|
+
bundleId: stored.bundleId,
|
|
39111
|
+
savedPath: stored.savedPath,
|
|
39112
|
+
sizeBytes: stored.sizeBytes,
|
|
39113
|
+
createdAt: bundle.createdAt,
|
|
39114
|
+
summary
|
|
39115
|
+
};
|
|
39116
|
+
}
|
|
39052
39117
|
return {
|
|
39053
39118
|
success: true,
|
|
39054
39119
|
bundle,
|
|
@@ -40028,9 +40093,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40028
40093
|
}
|
|
40029
40094
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
40030
40095
|
}
|
|
40031
|
-
var
|
|
40032
|
-
var
|
|
40033
|
-
var
|
|
40096
|
+
var fs52 = __toESM2(require("fs"));
|
|
40097
|
+
var path9 = __toESM2(require("path"));
|
|
40098
|
+
var os7 = __toESM2(require("os"));
|
|
40034
40099
|
var KEY_TO_VK = {
|
|
40035
40100
|
Backspace: 8,
|
|
40036
40101
|
Tab: 9,
|
|
@@ -40284,27 +40349,27 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40284
40349
|
function resolveSafePath(requestedPath) {
|
|
40285
40350
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
40286
40351
|
const inputPath = rawPath || ".";
|
|
40287
|
-
const home =
|
|
40352
|
+
const home = os7.homedir();
|
|
40288
40353
|
if (inputPath.startsWith("~")) {
|
|
40289
|
-
return
|
|
40354
|
+
return path9.resolve(path9.join(home, inputPath.slice(1)));
|
|
40290
40355
|
}
|
|
40291
40356
|
if (process.platform === "win32") {
|
|
40292
40357
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
40293
|
-
if (
|
|
40294
|
-
return
|
|
40358
|
+
if (path9.win32.isAbsolute(normalized)) {
|
|
40359
|
+
return path9.win32.normalize(normalized);
|
|
40295
40360
|
}
|
|
40296
|
-
return
|
|
40361
|
+
return path9.win32.resolve(normalized);
|
|
40297
40362
|
}
|
|
40298
|
-
if (
|
|
40299
|
-
return
|
|
40363
|
+
if (path9.isAbsolute(inputPath)) {
|
|
40364
|
+
return path9.normalize(inputPath);
|
|
40300
40365
|
}
|
|
40301
|
-
return
|
|
40366
|
+
return path9.resolve(inputPath);
|
|
40302
40367
|
}
|
|
40303
40368
|
function listDirectoryEntriesSafe(dirPath) {
|
|
40304
|
-
const entries =
|
|
40369
|
+
const entries = fs52.readdirSync(dirPath, { withFileTypes: true });
|
|
40305
40370
|
const files = [];
|
|
40306
40371
|
for (const entry of entries) {
|
|
40307
|
-
const entryPath =
|
|
40372
|
+
const entryPath = path9.join(dirPath, entry.name);
|
|
40308
40373
|
try {
|
|
40309
40374
|
if (entry.isDirectory()) {
|
|
40310
40375
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -40313,14 +40378,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40313
40378
|
if (entry.isFile()) {
|
|
40314
40379
|
let size;
|
|
40315
40380
|
try {
|
|
40316
|
-
size =
|
|
40381
|
+
size = fs52.statSync(entryPath).size;
|
|
40317
40382
|
} catch {
|
|
40318
40383
|
size = void 0;
|
|
40319
40384
|
}
|
|
40320
40385
|
files.push({ name: entry.name, type: "file", size });
|
|
40321
40386
|
continue;
|
|
40322
40387
|
}
|
|
40323
|
-
const stat4 =
|
|
40388
|
+
const stat4 = fs52.statSync(entryPath);
|
|
40324
40389
|
files.push({
|
|
40325
40390
|
name: entry.name,
|
|
40326
40391
|
type: stat4.isDirectory() ? "directory" : "file",
|
|
@@ -40338,7 +40403,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40338
40403
|
const letter = String.fromCharCode(code);
|
|
40339
40404
|
const root = `${letter}:\\`;
|
|
40340
40405
|
try {
|
|
40341
|
-
if (!
|
|
40406
|
+
if (!fs52.existsSync(root)) continue;
|
|
40342
40407
|
if (excluded && root.toLowerCase() === excluded) continue;
|
|
40343
40408
|
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
40344
40409
|
} catch {
|
|
@@ -40349,7 +40414,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40349
40414
|
async function handleFileRead(h, args) {
|
|
40350
40415
|
try {
|
|
40351
40416
|
const filePath = resolveSafePath(args?.path);
|
|
40352
|
-
const content =
|
|
40417
|
+
const content = fs52.readFileSync(filePath, "utf-8");
|
|
40353
40418
|
return { success: true, content, path: filePath };
|
|
40354
40419
|
} catch (e) {
|
|
40355
40420
|
return { success: false, error: e.message };
|
|
@@ -40358,8 +40423,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40358
40423
|
async function handleFileWrite(h, args) {
|
|
40359
40424
|
try {
|
|
40360
40425
|
const filePath = resolveSafePath(args?.path);
|
|
40361
|
-
|
|
40362
|
-
|
|
40426
|
+
fs52.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
40427
|
+
fs52.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
40363
40428
|
return { success: true, path: filePath };
|
|
40364
40429
|
} catch (e) {
|
|
40365
40430
|
return { success: false, error: e.message };
|
|
@@ -41190,6 +41255,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41190
41255
|
this.logCommandStart(cmd, args);
|
|
41191
41256
|
const sessionScopedCommands = /* @__PURE__ */ new Set([
|
|
41192
41257
|
"read_chat",
|
|
41258
|
+
"get_chat_debug_bundle",
|
|
41193
41259
|
"send_chat",
|
|
41194
41260
|
"list_chats",
|
|
41195
41261
|
"new_chat",
|
|
@@ -41445,18 +41511,18 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41445
41511
|
}
|
|
41446
41512
|
}
|
|
41447
41513
|
};
|
|
41448
|
-
var
|
|
41449
|
-
var
|
|
41514
|
+
var os13 = __toESM2(require("os"));
|
|
41515
|
+
var path13 = __toESM2(require("path"));
|
|
41450
41516
|
var crypto4 = __toESM2(require("crypto"));
|
|
41451
41517
|
var import_fs5 = require("fs");
|
|
41452
41518
|
var import_child_process6 = require("child_process");
|
|
41453
41519
|
var import_chalk = __toESM2(require("chalk"));
|
|
41454
41520
|
init_provider_cli_adapter();
|
|
41455
41521
|
init_config();
|
|
41456
|
-
var
|
|
41457
|
-
var
|
|
41522
|
+
var os12 = __toESM2(require("os"));
|
|
41523
|
+
var path12 = __toESM2(require("path"));
|
|
41458
41524
|
var crypto3 = __toESM2(require("crypto"));
|
|
41459
|
-
var
|
|
41525
|
+
var fs6 = __toESM2(require("fs"));
|
|
41460
41526
|
var import_node_module = require("module");
|
|
41461
41527
|
init_contracts();
|
|
41462
41528
|
init_provider_cli_adapter();
|
|
@@ -41511,7 +41577,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41511
41577
|
var CachedDatabaseSync = null;
|
|
41512
41578
|
function getDatabaseSync() {
|
|
41513
41579
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
41514
|
-
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(
|
|
41580
|
+
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path12.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
41515
41581
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
41516
41582
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
41517
41583
|
if (!CachedDatabaseSync) {
|
|
@@ -41661,10 +41727,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41661
41727
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
41662
41728
|
*/
|
|
41663
41729
|
probeSessionIdFromConfig(probe) {
|
|
41664
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
41730
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os12.homedir());
|
|
41665
41731
|
const now = Date.now();
|
|
41666
41732
|
if (this.cachedSqliteDbMissingUntil > now) return null;
|
|
41667
|
-
if (!
|
|
41733
|
+
if (!fs6.existsSync(resolvedDbPath)) {
|
|
41668
41734
|
this.cachedSqliteDbMissingUntil = now + 1e4;
|
|
41669
41735
|
return null;
|
|
41670
41736
|
}
|
|
@@ -42396,7 +42462,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
42396
42462
|
};
|
|
42397
42463
|
addDir(this.workingDir);
|
|
42398
42464
|
try {
|
|
42399
|
-
addDir(
|
|
42465
|
+
addDir(fs6.realpathSync.native(this.workingDir));
|
|
42400
42466
|
} catch {
|
|
42401
42467
|
}
|
|
42402
42468
|
return Array.from(dirs);
|
|
@@ -43587,11 +43653,11 @@ ${rawInput}` : rawInput;
|
|
|
43587
43653
|
}
|
|
43588
43654
|
function isExplicitCommand(command) {
|
|
43589
43655
|
const trimmed = command.trim();
|
|
43590
|
-
return
|
|
43656
|
+
return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
43591
43657
|
}
|
|
43592
43658
|
function expandExecutable(command) {
|
|
43593
43659
|
const trimmed = command.trim();
|
|
43594
|
-
return trimmed.startsWith("~") ?
|
|
43660
|
+
return trimmed.startsWith("~") ? path13.join(os13.homedir(), trimmed.slice(1)) : trimmed;
|
|
43595
43661
|
}
|
|
43596
43662
|
function commandExists(command) {
|
|
43597
43663
|
const trimmed = command.trim();
|
|
@@ -43872,7 +43938,7 @@ ${rawInput}` : rawInput;
|
|
|
43872
43938
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
43873
43939
|
const trimmed = (workingDir || "").trim();
|
|
43874
43940
|
if (!trimmed) throw new Error("working directory required");
|
|
43875
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
43941
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path13.resolve(trimmed);
|
|
43876
43942
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
43877
43943
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
43878
43944
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -44370,11 +44436,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44370
44436
|
};
|
|
44371
44437
|
var import_child_process7 = require("child_process");
|
|
44372
44438
|
var net3 = __toESM2(require("net"));
|
|
44373
|
-
var
|
|
44439
|
+
var os15 = __toESM2(require("os"));
|
|
44440
|
+
var path15 = __toESM2(require("path"));
|
|
44441
|
+
var fs7 = __toESM2(require("fs"));
|
|
44374
44442
|
var path14 = __toESM2(require("path"));
|
|
44375
|
-
var
|
|
44376
|
-
var path13 = __toESM2(require("path"));
|
|
44377
|
-
var os13 = __toESM2(require("os"));
|
|
44443
|
+
var os14 = __toESM2(require("os"));
|
|
44378
44444
|
var chokidar = __toESM2((init_chokidar(), __toCommonJS(chokidar_exports)));
|
|
44379
44445
|
init_logger();
|
|
44380
44446
|
var VALID_CAPABILITY_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
@@ -44632,9 +44698,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44632
44698
|
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
44633
44699
|
static looksLikeProviderRoot(candidate) {
|
|
44634
44700
|
try {
|
|
44635
|
-
if (!
|
|
44701
|
+
if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
|
|
44636
44702
|
return ["ide", "extension", "cli", "acp"].some(
|
|
44637
|
-
(category) =>
|
|
44703
|
+
(category) => fs7.existsSync(path14.join(candidate, category))
|
|
44638
44704
|
);
|
|
44639
44705
|
} catch {
|
|
44640
44706
|
return false;
|
|
@@ -44642,20 +44708,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44642
44708
|
}
|
|
44643
44709
|
static hasProviderRootMarker(candidate) {
|
|
44644
44710
|
try {
|
|
44645
|
-
return
|
|
44711
|
+
return fs7.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
44646
44712
|
} catch {
|
|
44647
44713
|
return false;
|
|
44648
44714
|
}
|
|
44649
44715
|
}
|
|
44650
44716
|
detectDefaultUserDir() {
|
|
44651
|
-
const fallback =
|
|
44717
|
+
const fallback = path14.join(os14.homedir(), ".adhdev", "providers");
|
|
44652
44718
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
44653
44719
|
const visited = /* @__PURE__ */ new Set();
|
|
44654
44720
|
for (const start of this.probeStarts) {
|
|
44655
|
-
let current =
|
|
44721
|
+
let current = path14.resolve(start);
|
|
44656
44722
|
while (!visited.has(current)) {
|
|
44657
44723
|
visited.add(current);
|
|
44658
|
-
const siblingCandidate =
|
|
44724
|
+
const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
44659
44725
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
44660
44726
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
44661
44727
|
if (envOptIn || hasMarker) {
|
|
@@ -44677,7 +44743,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44677
44743
|
return { path: siblingCandidate, source };
|
|
44678
44744
|
}
|
|
44679
44745
|
}
|
|
44680
|
-
const parent =
|
|
44746
|
+
const parent = path14.dirname(current);
|
|
44681
44747
|
if (parent === current) break;
|
|
44682
44748
|
current = parent;
|
|
44683
44749
|
}
|
|
@@ -44687,11 +44753,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44687
44753
|
constructor(options) {
|
|
44688
44754
|
this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
|
|
44689
44755
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
44690
|
-
this.defaultProvidersDir =
|
|
44756
|
+
this.defaultProvidersDir = path14.join(os14.homedir(), ".adhdev", "providers");
|
|
44691
44757
|
const detected = this.detectDefaultUserDir();
|
|
44692
44758
|
this.userDir = detected.path;
|
|
44693
44759
|
this.userDirSource = detected.source;
|
|
44694
|
-
this.upstreamDir =
|
|
44760
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
44695
44761
|
this.disableUpstream = false;
|
|
44696
44762
|
this.applySourceConfig({
|
|
44697
44763
|
userDir: options?.userDir,
|
|
@@ -44750,7 +44816,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44750
44816
|
this.userDir = detected.path;
|
|
44751
44817
|
this.userDirSource = detected.source;
|
|
44752
44818
|
}
|
|
44753
|
-
this.upstreamDir =
|
|
44819
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
44754
44820
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
44755
44821
|
if (this.explicitProviderDir) {
|
|
44756
44822
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -44764,7 +44830,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44764
44830
|
* Canonical provider directory shape for a given root.
|
|
44765
44831
|
*/
|
|
44766
44832
|
getProviderDir(root, category, type) {
|
|
44767
|
-
return
|
|
44833
|
+
return path14.join(root, category, type);
|
|
44768
44834
|
}
|
|
44769
44835
|
/**
|
|
44770
44836
|
* Canonical user override directory for a provider.
|
|
@@ -44791,7 +44857,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44791
44857
|
resolveProviderFile(type, ...segments) {
|
|
44792
44858
|
const dir = this.findProviderDirInternal(type);
|
|
44793
44859
|
if (!dir) return null;
|
|
44794
|
-
return
|
|
44860
|
+
return path14.join(dir, ...segments);
|
|
44795
44861
|
}
|
|
44796
44862
|
/**
|
|
44797
44863
|
* Load all providers (3-tier priority)
|
|
@@ -44804,7 +44870,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44804
44870
|
this.providers.clear();
|
|
44805
44871
|
this.providerAvailability.clear();
|
|
44806
44872
|
let upstreamCount = 0;
|
|
44807
|
-
if (!this.disableUpstream &&
|
|
44873
|
+
if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
|
|
44808
44874
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
44809
44875
|
if (upstreamCount > 0) {
|
|
44810
44876
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -44812,7 +44878,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44812
44878
|
} else if (this.disableUpstream) {
|
|
44813
44879
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
44814
44880
|
}
|
|
44815
|
-
if (
|
|
44881
|
+
if (fs7.existsSync(this.userDir)) {
|
|
44816
44882
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
44817
44883
|
if (userCount > 0) {
|
|
44818
44884
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -44827,10 +44893,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44827
44893
|
* Check if upstream directory exists and has providers.
|
|
44828
44894
|
*/
|
|
44829
44895
|
hasUpstream() {
|
|
44830
|
-
if (!
|
|
44896
|
+
if (!fs7.existsSync(this.upstreamDir)) return false;
|
|
44831
44897
|
try {
|
|
44832
|
-
return
|
|
44833
|
-
(d) =>
|
|
44898
|
+
return fs7.readdirSync(this.upstreamDir).some(
|
|
44899
|
+
(d) => fs7.statSync(path14.join(this.upstreamDir, d)).isDirectory()
|
|
44834
44900
|
);
|
|
44835
44901
|
} catch {
|
|
44836
44902
|
return false;
|
|
@@ -45327,8 +45393,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45327
45393
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
45328
45394
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
45329
45395
|
if (providerDir) {
|
|
45330
|
-
const fullDir =
|
|
45331
|
-
resolved._resolvedScriptsPath =
|
|
45396
|
+
const fullDir = path14.join(providerDir, entry.scriptDir);
|
|
45397
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45332
45398
|
}
|
|
45333
45399
|
matched = true;
|
|
45334
45400
|
}
|
|
@@ -45343,8 +45409,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45343
45409
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
45344
45410
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
45345
45411
|
if (providerDir) {
|
|
45346
|
-
const fullDir =
|
|
45347
|
-
resolved._resolvedScriptsPath =
|
|
45412
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
45413
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45348
45414
|
}
|
|
45349
45415
|
}
|
|
45350
45416
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -45361,8 +45427,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45361
45427
|
resolved._resolvedScriptDir = dirOverride;
|
|
45362
45428
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
45363
45429
|
if (providerDir) {
|
|
45364
|
-
const fullDir =
|
|
45365
|
-
resolved._resolvedScriptsPath =
|
|
45430
|
+
const fullDir = path14.join(providerDir, dirOverride);
|
|
45431
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45366
45432
|
}
|
|
45367
45433
|
}
|
|
45368
45434
|
} else if (override.scripts) {
|
|
@@ -45378,8 +45444,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45378
45444
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
45379
45445
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
45380
45446
|
if (providerDir) {
|
|
45381
|
-
const fullDir =
|
|
45382
|
-
resolved._resolvedScriptsPath =
|
|
45447
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
45448
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45383
45449
|
}
|
|
45384
45450
|
}
|
|
45385
45451
|
}
|
|
@@ -45411,15 +45477,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45411
45477
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
45412
45478
|
return null;
|
|
45413
45479
|
}
|
|
45414
|
-
const dir =
|
|
45415
|
-
if (!
|
|
45480
|
+
const dir = path14.join(providerDir, scriptDir);
|
|
45481
|
+
if (!fs7.existsSync(dir)) {
|
|
45416
45482
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
45417
45483
|
return null;
|
|
45418
45484
|
}
|
|
45419
45485
|
const cached2 = this.scriptsCache.get(dir);
|
|
45420
45486
|
if (cached2) return cached2;
|
|
45421
|
-
const scriptsJs =
|
|
45422
|
-
if (
|
|
45487
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
45488
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
45423
45489
|
try {
|
|
45424
45490
|
delete require.cache[require.resolve(scriptsJs)];
|
|
45425
45491
|
const loaded = require(scriptsJs);
|
|
@@ -45440,9 +45506,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45440
45506
|
watch() {
|
|
45441
45507
|
this.stopWatch();
|
|
45442
45508
|
const watchDir = (dir) => {
|
|
45443
|
-
if (!
|
|
45509
|
+
if (!fs7.existsSync(dir)) {
|
|
45444
45510
|
try {
|
|
45445
|
-
|
|
45511
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
45446
45512
|
} catch {
|
|
45447
45513
|
return;
|
|
45448
45514
|
}
|
|
@@ -45460,7 +45526,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45460
45526
|
return;
|
|
45461
45527
|
}
|
|
45462
45528
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
45463
|
-
this.log(`File changed: ${
|
|
45529
|
+
this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
|
|
45464
45530
|
this.reload();
|
|
45465
45531
|
}
|
|
45466
45532
|
};
|
|
@@ -45515,12 +45581,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45515
45581
|
}
|
|
45516
45582
|
const https = require("https");
|
|
45517
45583
|
const { execSync: execSync7 } = require("child_process");
|
|
45518
|
-
const metaPath =
|
|
45584
|
+
const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
45519
45585
|
let prevEtag = "";
|
|
45520
45586
|
let prevTimestamp = 0;
|
|
45521
45587
|
try {
|
|
45522
|
-
if (
|
|
45523
|
-
const meta3 = JSON.parse(
|
|
45588
|
+
if (fs7.existsSync(metaPath)) {
|
|
45589
|
+
const meta3 = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
|
|
45524
45590
|
prevEtag = meta3.etag || "";
|
|
45525
45591
|
prevTimestamp = meta3.timestamp || 0;
|
|
45526
45592
|
}
|
|
@@ -45575,39 +45641,39 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45575
45641
|
return { updated: false };
|
|
45576
45642
|
}
|
|
45577
45643
|
this.log("Downloading latest providers from GitHub...");
|
|
45578
|
-
const tmpTar =
|
|
45579
|
-
const tmpExtract =
|
|
45644
|
+
const tmpTar = path14.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
45645
|
+
const tmpExtract = path14.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
45580
45646
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
45581
|
-
|
|
45647
|
+
fs7.mkdirSync(tmpExtract, { recursive: true });
|
|
45582
45648
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
45583
|
-
const extracted =
|
|
45649
|
+
const extracted = fs7.readdirSync(tmpExtract);
|
|
45584
45650
|
const rootDir = extracted.find(
|
|
45585
|
-
(d) =>
|
|
45651
|
+
(d) => fs7.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
45586
45652
|
);
|
|
45587
45653
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
45588
|
-
const sourceDir =
|
|
45654
|
+
const sourceDir = path14.join(tmpExtract, rootDir);
|
|
45589
45655
|
const backupDir = this.upstreamDir + ".bak";
|
|
45590
|
-
if (
|
|
45591
|
-
if (
|
|
45592
|
-
|
|
45656
|
+
if (fs7.existsSync(this.upstreamDir)) {
|
|
45657
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
45658
|
+
fs7.renameSync(this.upstreamDir, backupDir);
|
|
45593
45659
|
}
|
|
45594
45660
|
try {
|
|
45595
45661
|
this.copyDirRecursive(sourceDir, this.upstreamDir);
|
|
45596
45662
|
this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
|
|
45597
|
-
if (
|
|
45663
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
45598
45664
|
} catch (e) {
|
|
45599
|
-
if (
|
|
45600
|
-
if (
|
|
45601
|
-
|
|
45665
|
+
if (fs7.existsSync(backupDir)) {
|
|
45666
|
+
if (fs7.existsSync(this.upstreamDir)) fs7.rmSync(this.upstreamDir, { recursive: true, force: true });
|
|
45667
|
+
fs7.renameSync(backupDir, this.upstreamDir);
|
|
45602
45668
|
}
|
|
45603
45669
|
throw e;
|
|
45604
45670
|
}
|
|
45605
45671
|
try {
|
|
45606
|
-
|
|
45672
|
+
fs7.rmSync(tmpTar, { force: true });
|
|
45607
45673
|
} catch {
|
|
45608
45674
|
}
|
|
45609
45675
|
try {
|
|
45610
|
-
|
|
45676
|
+
fs7.rmSync(tmpExtract, { recursive: true, force: true });
|
|
45611
45677
|
} catch {
|
|
45612
45678
|
}
|
|
45613
45679
|
const upstreamCount = this.countProviders(this.upstreamDir);
|
|
@@ -45639,7 +45705,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45639
45705
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
45640
45706
|
return;
|
|
45641
45707
|
}
|
|
45642
|
-
const ws2 =
|
|
45708
|
+
const ws2 = fs7.createWriteStream(destPath);
|
|
45643
45709
|
res.pipe(ws2);
|
|
45644
45710
|
ws2.on("finish", () => {
|
|
45645
45711
|
ws2.close();
|
|
@@ -45658,22 +45724,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45658
45724
|
}
|
|
45659
45725
|
/** Recursive directory copy */
|
|
45660
45726
|
copyDirRecursive(src, dest) {
|
|
45661
|
-
|
|
45662
|
-
for (const entry of
|
|
45663
|
-
const srcPath =
|
|
45664
|
-
const destPath =
|
|
45727
|
+
fs7.mkdirSync(dest, { recursive: true });
|
|
45728
|
+
for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
|
|
45729
|
+
const srcPath = path14.join(src, entry.name);
|
|
45730
|
+
const destPath = path14.join(dest, entry.name);
|
|
45665
45731
|
if (entry.isDirectory()) {
|
|
45666
45732
|
this.copyDirRecursive(srcPath, destPath);
|
|
45667
45733
|
} else {
|
|
45668
|
-
|
|
45734
|
+
fs7.copyFileSync(srcPath, destPath);
|
|
45669
45735
|
}
|
|
45670
45736
|
}
|
|
45671
45737
|
}
|
|
45672
45738
|
/** .meta.json save */
|
|
45673
45739
|
writeMeta(metaPath, etag, timestamp) {
|
|
45674
45740
|
try {
|
|
45675
|
-
|
|
45676
|
-
|
|
45741
|
+
fs7.mkdirSync(path14.dirname(metaPath), { recursive: true });
|
|
45742
|
+
fs7.writeFileSync(metaPath, JSON.stringify({
|
|
45677
45743
|
etag,
|
|
45678
45744
|
timestamp,
|
|
45679
45745
|
lastCheck: new Date(timestamp).toISOString(),
|
|
@@ -45684,12 +45750,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45684
45750
|
}
|
|
45685
45751
|
/** Count provider files (provider.js or provider.json) */
|
|
45686
45752
|
countProviders(dir) {
|
|
45687
|
-
if (!
|
|
45753
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
45688
45754
|
let count = 0;
|
|
45689
45755
|
const scan = (d) => {
|
|
45690
45756
|
try {
|
|
45691
|
-
for (const entry of
|
|
45692
|
-
if (entry.isDirectory()) scan(
|
|
45757
|
+
for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
|
|
45758
|
+
if (entry.isDirectory()) scan(path14.join(d, entry.name));
|
|
45693
45759
|
else if (entry.name === "provider.json") count++;
|
|
45694
45760
|
}
|
|
45695
45761
|
} catch {
|
|
@@ -45915,19 +45981,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45915
45981
|
const cat = provider.category;
|
|
45916
45982
|
const searchRoots = this.getProviderRoots();
|
|
45917
45983
|
for (const root of searchRoots) {
|
|
45918
|
-
if (!
|
|
45984
|
+
if (!fs7.existsSync(root)) continue;
|
|
45919
45985
|
const candidate = this.getProviderDir(root, cat, type);
|
|
45920
|
-
if (
|
|
45921
|
-
const catDir =
|
|
45922
|
-
if (
|
|
45986
|
+
if (fs7.existsSync(path14.join(candidate, "provider.json"))) return candidate;
|
|
45987
|
+
const catDir = path14.join(root, cat);
|
|
45988
|
+
if (fs7.existsSync(catDir)) {
|
|
45923
45989
|
try {
|
|
45924
|
-
for (const entry of
|
|
45990
|
+
for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
|
|
45925
45991
|
if (!entry.isDirectory()) continue;
|
|
45926
|
-
const jsonPath =
|
|
45927
|
-
if (
|
|
45992
|
+
const jsonPath = path14.join(catDir, entry.name, "provider.json");
|
|
45993
|
+
if (fs7.existsSync(jsonPath)) {
|
|
45928
45994
|
try {
|
|
45929
|
-
const data = JSON.parse(
|
|
45930
|
-
if (data.type === type) return
|
|
45995
|
+
const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
|
|
45996
|
+
if (data.type === type) return path14.join(catDir, entry.name);
|
|
45931
45997
|
} catch {
|
|
45932
45998
|
}
|
|
45933
45999
|
}
|
|
@@ -45944,8 +46010,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45944
46010
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
45945
46011
|
*/
|
|
45946
46012
|
buildScriptWrappersFromDir(dir) {
|
|
45947
|
-
const scriptsJs =
|
|
45948
|
-
if (
|
|
46013
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
46014
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
45949
46015
|
try {
|
|
45950
46016
|
delete require.cache[require.resolve(scriptsJs)];
|
|
45951
46017
|
return require(scriptsJs);
|
|
@@ -45955,13 +46021,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45955
46021
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
45956
46022
|
const result = {};
|
|
45957
46023
|
try {
|
|
45958
|
-
for (const file2 of
|
|
46024
|
+
for (const file2 of fs7.readdirSync(dir)) {
|
|
45959
46025
|
if (!file2.endsWith(".js")) continue;
|
|
45960
46026
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
45961
|
-
const filePath =
|
|
46027
|
+
const filePath = path14.join(dir, file2);
|
|
45962
46028
|
result[scriptName] = (...args) => {
|
|
45963
46029
|
try {
|
|
45964
|
-
let content =
|
|
46030
|
+
let content = fs7.readFileSync(filePath, "utf-8");
|
|
45965
46031
|
if (args[0] && typeof args[0] === "object") {
|
|
45966
46032
|
for (const [key, val] of Object.entries(args[0])) {
|
|
45967
46033
|
let v2 = val;
|
|
@@ -46007,20 +46073,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46007
46073
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
46008
46074
|
*/
|
|
46009
46075
|
loadDir(dir, excludeDirs) {
|
|
46010
|
-
if (!
|
|
46076
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
46011
46077
|
let count = 0;
|
|
46012
46078
|
const scan = (d) => {
|
|
46013
46079
|
let entries;
|
|
46014
46080
|
try {
|
|
46015
|
-
entries =
|
|
46081
|
+
entries = fs7.readdirSync(d, { withFileTypes: true });
|
|
46016
46082
|
} catch {
|
|
46017
46083
|
return;
|
|
46018
46084
|
}
|
|
46019
46085
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
46020
46086
|
if (hasJson) {
|
|
46021
|
-
const jsonPath =
|
|
46087
|
+
const jsonPath = path14.join(d, "provider.json");
|
|
46022
46088
|
try {
|
|
46023
|
-
const raw =
|
|
46089
|
+
const raw = fs7.readFileSync(jsonPath, "utf-8");
|
|
46024
46090
|
const mod = JSON.parse(raw);
|
|
46025
46091
|
if (typeof mod.extensionIdPattern === "string") {
|
|
46026
46092
|
const flags = mod.extensionIdPattern_flags || "";
|
|
@@ -46039,8 +46105,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46039
46105
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
46040
46106
|
} else {
|
|
46041
46107
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
46042
|
-
const scriptsPath =
|
|
46043
|
-
if (!hasCompatibility &&
|
|
46108
|
+
const scriptsPath = path14.join(d, "scripts.js");
|
|
46109
|
+
if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
|
|
46044
46110
|
try {
|
|
46045
46111
|
delete require.cache[require.resolve(scriptsPath)];
|
|
46046
46112
|
const scripts = require(scriptsPath);
|
|
@@ -46065,7 +46131,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46065
46131
|
if (!entry.isDirectory()) continue;
|
|
46066
46132
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
46067
46133
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
46068
|
-
scan(
|
|
46134
|
+
scan(path14.join(d, entry.name));
|
|
46069
46135
|
}
|
|
46070
46136
|
}
|
|
46071
46137
|
};
|
|
@@ -46251,7 +46317,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46251
46317
|
});
|
|
46252
46318
|
}
|
|
46253
46319
|
async function killIdeProcess(ideId) {
|
|
46254
|
-
const plat =
|
|
46320
|
+
const plat = os15.platform();
|
|
46255
46321
|
const appName = getMacAppIdentifiers()[ideId];
|
|
46256
46322
|
const winProcesses = getWinProcessNames()[ideId];
|
|
46257
46323
|
try {
|
|
@@ -46312,7 +46378,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46312
46378
|
}
|
|
46313
46379
|
}
|
|
46314
46380
|
function isIdeRunning(ideId) {
|
|
46315
|
-
const plat =
|
|
46381
|
+
const plat = os15.platform();
|
|
46316
46382
|
try {
|
|
46317
46383
|
if (plat === "darwin") {
|
|
46318
46384
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -46367,7 +46433,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46367
46433
|
}
|
|
46368
46434
|
}
|
|
46369
46435
|
function detectCurrentWorkspace(ideId) {
|
|
46370
|
-
const plat =
|
|
46436
|
+
const plat = os15.platform();
|
|
46371
46437
|
if (plat === "darwin") {
|
|
46372
46438
|
try {
|
|
46373
46439
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -46382,17 +46448,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46382
46448
|
}
|
|
46383
46449
|
} else if (plat === "win32") {
|
|
46384
46450
|
try {
|
|
46385
|
-
const
|
|
46451
|
+
const fs16 = require("fs");
|
|
46386
46452
|
const appNameMap = getMacAppIdentifiers();
|
|
46387
46453
|
const appName = appNameMap[ideId];
|
|
46388
46454
|
if (appName) {
|
|
46389
|
-
const storagePath =
|
|
46390
|
-
process.env.APPDATA ||
|
|
46455
|
+
const storagePath = path15.join(
|
|
46456
|
+
process.env.APPDATA || path15.join(os15.homedir(), "AppData", "Roaming"),
|
|
46391
46457
|
appName,
|
|
46392
46458
|
"storage.json"
|
|
46393
46459
|
);
|
|
46394
|
-
if (
|
|
46395
|
-
const data = JSON.parse(
|
|
46460
|
+
if (fs16.existsSync(storagePath)) {
|
|
46461
|
+
const data = JSON.parse(fs16.readFileSync(storagePath, "utf-8"));
|
|
46396
46462
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
46397
46463
|
if (workspaces.length > 0) {
|
|
46398
46464
|
const recent = workspaces[0];
|
|
@@ -46409,7 +46475,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46409
46475
|
return void 0;
|
|
46410
46476
|
}
|
|
46411
46477
|
async function launchWithCdp(options = {}) {
|
|
46412
|
-
const platform10 =
|
|
46478
|
+
const platform10 = os15.platform();
|
|
46413
46479
|
let targetIde;
|
|
46414
46480
|
const ides = await detectIDEs(getProviderLoader());
|
|
46415
46481
|
if (options.ideId) {
|
|
@@ -46560,14 +46626,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46560
46626
|
}
|
|
46561
46627
|
init_config();
|
|
46562
46628
|
init_logger();
|
|
46563
|
-
var
|
|
46564
|
-
var
|
|
46565
|
-
var
|
|
46566
|
-
var LOG_DIR2 = process.platform === "win32" ?
|
|
46629
|
+
var fs8 = __toESM2(require("fs"));
|
|
46630
|
+
var path16 = __toESM2(require("path"));
|
|
46631
|
+
var os16 = __toESM2(require("os"));
|
|
46632
|
+
var LOG_DIR2 = process.platform === "win32" ? path16.join(process.env.LOCALAPPDATA || process.env.APPDATA || path16.join(os16.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path16.join(os16.homedir(), "Library", "Logs", "adhdev") : path16.join(os16.homedir(), ".local", "share", "adhdev", "logs");
|
|
46567
46633
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
46568
46634
|
var MAX_DAYS = 7;
|
|
46569
46635
|
try {
|
|
46570
|
-
|
|
46636
|
+
fs8.mkdirSync(LOG_DIR2, { recursive: true });
|
|
46571
46637
|
} catch {
|
|
46572
46638
|
}
|
|
46573
46639
|
var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -46601,19 +46667,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46601
46667
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
46602
46668
|
}
|
|
46603
46669
|
var currentDate2 = getDateStr2();
|
|
46604
|
-
var currentFile =
|
|
46670
|
+
var currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
46605
46671
|
var writeCount2 = 0;
|
|
46606
46672
|
function checkRotation() {
|
|
46607
46673
|
const today = getDateStr2();
|
|
46608
46674
|
if (today !== currentDate2) {
|
|
46609
46675
|
currentDate2 = today;
|
|
46610
|
-
currentFile =
|
|
46676
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
46611
46677
|
cleanOldFiles();
|
|
46612
46678
|
}
|
|
46613
46679
|
}
|
|
46614
46680
|
function cleanOldFiles() {
|
|
46615
46681
|
try {
|
|
46616
|
-
const files =
|
|
46682
|
+
const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
46617
46683
|
const cutoff = /* @__PURE__ */ new Date();
|
|
46618
46684
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
46619
46685
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -46621,7 +46687,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46621
46687
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
46622
46688
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
46623
46689
|
try {
|
|
46624
|
-
|
|
46690
|
+
fs8.unlinkSync(path16.join(LOG_DIR2, file2));
|
|
46625
46691
|
} catch {
|
|
46626
46692
|
}
|
|
46627
46693
|
}
|
|
@@ -46631,14 +46697,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46631
46697
|
}
|
|
46632
46698
|
function checkSize() {
|
|
46633
46699
|
try {
|
|
46634
|
-
const stat4 =
|
|
46700
|
+
const stat4 = fs8.statSync(currentFile);
|
|
46635
46701
|
if (stat4.size > MAX_FILE_SIZE) {
|
|
46636
46702
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
46637
46703
|
try {
|
|
46638
|
-
|
|
46704
|
+
fs8.unlinkSync(backup);
|
|
46639
46705
|
} catch {
|
|
46640
46706
|
}
|
|
46641
|
-
|
|
46707
|
+
fs8.renameSync(currentFile, backup);
|
|
46642
46708
|
}
|
|
46643
46709
|
} catch {
|
|
46644
46710
|
}
|
|
@@ -46671,14 +46737,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46671
46737
|
...entry.error ? { err: entry.error } : {},
|
|
46672
46738
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
46673
46739
|
});
|
|
46674
|
-
|
|
46740
|
+
fs8.appendFileSync(currentFile, line + "\n");
|
|
46675
46741
|
} catch {
|
|
46676
46742
|
}
|
|
46677
46743
|
}
|
|
46678
46744
|
function getRecentCommands(count = 50) {
|
|
46679
46745
|
try {
|
|
46680
|
-
if (!
|
|
46681
|
-
const content =
|
|
46746
|
+
if (!fs8.existsSync(currentFile)) return [];
|
|
46747
|
+
const content = fs8.readFileSync(currentFile, "utf-8");
|
|
46682
46748
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
46683
46749
|
return lines.slice(-count).map((line) => {
|
|
46684
46750
|
try {
|
|
@@ -46703,7 +46769,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46703
46769
|
}
|
|
46704
46770
|
cleanOldFiles();
|
|
46705
46771
|
init_logger();
|
|
46706
|
-
var
|
|
46772
|
+
var os17 = __toESM2(require("os"));
|
|
46707
46773
|
init_config();
|
|
46708
46774
|
init_terminal_screen();
|
|
46709
46775
|
init_logger();
|
|
@@ -46758,8 +46824,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46758
46824
|
}
|
|
46759
46825
|
function buildMachineInfo2(profile = "full") {
|
|
46760
46826
|
const base = {
|
|
46761
|
-
hostname:
|
|
46762
|
-
platform:
|
|
46827
|
+
hostname: os17.hostname(),
|
|
46828
|
+
platform: os17.platform()
|
|
46763
46829
|
};
|
|
46764
46830
|
if (profile === "live") {
|
|
46765
46831
|
return base;
|
|
@@ -46768,23 +46834,23 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46768
46834
|
const memSnap2 = getHostMemorySnapshot();
|
|
46769
46835
|
return {
|
|
46770
46836
|
...base,
|
|
46771
|
-
arch:
|
|
46772
|
-
cpus:
|
|
46837
|
+
arch: os17.arch(),
|
|
46838
|
+
cpus: os17.cpus().length,
|
|
46773
46839
|
totalMem: memSnap2.totalMem,
|
|
46774
|
-
release:
|
|
46840
|
+
release: os17.release()
|
|
46775
46841
|
};
|
|
46776
46842
|
}
|
|
46777
46843
|
const memSnap = getHostMemorySnapshot();
|
|
46778
46844
|
return {
|
|
46779
46845
|
...base,
|
|
46780
|
-
arch:
|
|
46781
|
-
cpus:
|
|
46846
|
+
arch: os17.arch(),
|
|
46847
|
+
cpus: os17.cpus().length,
|
|
46782
46848
|
totalMem: memSnap.totalMem,
|
|
46783
46849
|
freeMem: memSnap.freeMem,
|
|
46784
46850
|
availableMem: memSnap.availableMem,
|
|
46785
|
-
loadavg:
|
|
46786
|
-
uptime:
|
|
46787
|
-
release:
|
|
46851
|
+
loadavg: os17.loadavg(),
|
|
46852
|
+
uptime: os17.uptime(),
|
|
46853
|
+
release: os17.release()
|
|
46788
46854
|
};
|
|
46789
46855
|
}
|
|
46790
46856
|
function parseMessageTime(value) {
|
|
@@ -47009,42 +47075,42 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47009
47075
|
}
|
|
47010
47076
|
var import_child_process8 = require("child_process");
|
|
47011
47077
|
var import_child_process9 = require("child_process");
|
|
47012
|
-
var
|
|
47013
|
-
var
|
|
47014
|
-
var
|
|
47078
|
+
var fs9 = __toESM2(require("fs"));
|
|
47079
|
+
var os18 = __toESM2(require("os"));
|
|
47080
|
+
var path17 = __toESM2(require("path"));
|
|
47015
47081
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
47016
47082
|
function getUpgradeLogPath() {
|
|
47017
|
-
const home =
|
|
47018
|
-
const dir =
|
|
47019
|
-
|
|
47020
|
-
return
|
|
47083
|
+
const home = os18.homedir();
|
|
47084
|
+
const dir = path17.join(home, ".adhdev");
|
|
47085
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
47086
|
+
return path17.join(dir, "daemon-upgrade.log");
|
|
47021
47087
|
}
|
|
47022
47088
|
function appendUpgradeLog(message) {
|
|
47023
47089
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
47024
47090
|
`;
|
|
47025
47091
|
try {
|
|
47026
|
-
|
|
47092
|
+
fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
47027
47093
|
} catch {
|
|
47028
47094
|
}
|
|
47029
47095
|
}
|
|
47030
47096
|
function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
|
|
47031
|
-
const binDir =
|
|
47097
|
+
const binDir = path17.dirname(nodeExecutable);
|
|
47032
47098
|
if (platform10 === "win32") {
|
|
47033
|
-
const npmCliPath =
|
|
47034
|
-
if (
|
|
47099
|
+
const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
47100
|
+
if (fs9.existsSync(npmCliPath)) {
|
|
47035
47101
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
47036
47102
|
}
|
|
47037
47103
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
47038
|
-
const candidatePath =
|
|
47039
|
-
if (
|
|
47104
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
47105
|
+
if (fs9.existsSync(candidatePath)) {
|
|
47040
47106
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
47041
47107
|
}
|
|
47042
47108
|
}
|
|
47043
47109
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
47044
47110
|
}
|
|
47045
47111
|
for (const candidate of ["npm"]) {
|
|
47046
|
-
const candidatePath =
|
|
47047
|
-
if (
|
|
47112
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
47113
|
+
if (fs9.existsSync(candidatePath)) {
|
|
47048
47114
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
47049
47115
|
}
|
|
47050
47116
|
}
|
|
@@ -47054,22 +47120,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47054
47120
|
if (!currentCliPath) return null;
|
|
47055
47121
|
let resolvedPath = currentCliPath;
|
|
47056
47122
|
try {
|
|
47057
|
-
resolvedPath =
|
|
47123
|
+
resolvedPath = fs9.realpathSync.native(currentCliPath);
|
|
47058
47124
|
} catch {
|
|
47059
47125
|
}
|
|
47060
47126
|
let currentDir = resolvedPath;
|
|
47061
47127
|
try {
|
|
47062
|
-
if (
|
|
47063
|
-
currentDir =
|
|
47128
|
+
if (fs9.statSync(resolvedPath).isFile()) {
|
|
47129
|
+
currentDir = path17.dirname(resolvedPath);
|
|
47064
47130
|
}
|
|
47065
47131
|
} catch {
|
|
47066
|
-
currentDir =
|
|
47132
|
+
currentDir = path17.dirname(resolvedPath);
|
|
47067
47133
|
}
|
|
47068
47134
|
while (true) {
|
|
47069
|
-
const packageJsonPath =
|
|
47135
|
+
const packageJsonPath = path17.join(currentDir, "package.json");
|
|
47070
47136
|
try {
|
|
47071
|
-
if (
|
|
47072
|
-
const parsed = JSON.parse(
|
|
47137
|
+
if (fs9.existsSync(packageJsonPath)) {
|
|
47138
|
+
const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
|
|
47073
47139
|
if (parsed?.name === packageName) {
|
|
47074
47140
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
47075
47141
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -47077,7 +47143,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47077
47143
|
}
|
|
47078
47144
|
} catch {
|
|
47079
47145
|
}
|
|
47080
|
-
const parentDir =
|
|
47146
|
+
const parentDir = path17.dirname(currentDir);
|
|
47081
47147
|
if (parentDir === currentDir) {
|
|
47082
47148
|
return null;
|
|
47083
47149
|
}
|
|
@@ -47085,13 +47151,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47085
47151
|
}
|
|
47086
47152
|
}
|
|
47087
47153
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
47088
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
47089
|
-
if (
|
|
47154
|
+
const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
|
|
47155
|
+
if (path17.basename(nodeModulesDir) !== "node_modules") {
|
|
47090
47156
|
return null;
|
|
47091
47157
|
}
|
|
47092
|
-
const maybeLibDir =
|
|
47093
|
-
if (
|
|
47094
|
-
return
|
|
47158
|
+
const maybeLibDir = path17.dirname(nodeModulesDir);
|
|
47159
|
+
if (path17.basename(maybeLibDir) === "lib") {
|
|
47160
|
+
return path17.dirname(maybeLibDir);
|
|
47095
47161
|
}
|
|
47096
47162
|
return maybeLibDir;
|
|
47097
47163
|
}
|
|
@@ -47206,10 +47272,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47206
47272
|
}
|
|
47207
47273
|
}
|
|
47208
47274
|
function stopSessionHostProcesses(appName) {
|
|
47209
|
-
const pidFile =
|
|
47275
|
+
const pidFile = path17.join(os18.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
47210
47276
|
try {
|
|
47211
|
-
if (
|
|
47212
|
-
const pid = Number.parseInt(
|
|
47277
|
+
if (fs9.existsSync(pidFile)) {
|
|
47278
|
+
const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
|
|
47213
47279
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
47214
47280
|
killPid2(pid);
|
|
47215
47281
|
}
|
|
@@ -47217,15 +47283,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47217
47283
|
} catch {
|
|
47218
47284
|
} finally {
|
|
47219
47285
|
try {
|
|
47220
|
-
|
|
47286
|
+
fs9.unlinkSync(pidFile);
|
|
47221
47287
|
} catch {
|
|
47222
47288
|
}
|
|
47223
47289
|
}
|
|
47224
47290
|
}
|
|
47225
47291
|
function removeDaemonPidFile() {
|
|
47226
|
-
const pidFile =
|
|
47292
|
+
const pidFile = path17.join(os18.homedir(), ".adhdev", "daemon.pid");
|
|
47227
47293
|
try {
|
|
47228
|
-
|
|
47294
|
+
fs9.unlinkSync(pidFile);
|
|
47229
47295
|
} catch {
|
|
47230
47296
|
}
|
|
47231
47297
|
}
|
|
@@ -47234,7 +47300,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47234
47300
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
47235
47301
|
if (!npmRoot) return;
|
|
47236
47302
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
47237
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
47303
|
+
const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
|
|
47238
47304
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
47239
47305
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
47240
47306
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -47242,25 +47308,25 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47242
47308
|
}
|
|
47243
47309
|
if (pkgName.startsWith("@")) {
|
|
47244
47310
|
const [scope, name] = pkgName.split("/");
|
|
47245
|
-
const scopeDir =
|
|
47246
|
-
if (!
|
|
47247
|
-
for (const entry of
|
|
47311
|
+
const scopeDir = path17.join(npmRoot, scope);
|
|
47312
|
+
if (!fs9.existsSync(scopeDir)) return;
|
|
47313
|
+
for (const entry of fs9.readdirSync(scopeDir)) {
|
|
47248
47314
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
47249
|
-
|
|
47250
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
47315
|
+
fs9.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
|
|
47316
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
|
|
47251
47317
|
}
|
|
47252
47318
|
} else {
|
|
47253
|
-
for (const entry of
|
|
47319
|
+
for (const entry of fs9.readdirSync(npmRoot)) {
|
|
47254
47320
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
47255
|
-
|
|
47256
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
47321
|
+
fs9.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
|
|
47322
|
+
appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
|
|
47257
47323
|
}
|
|
47258
47324
|
}
|
|
47259
|
-
if (
|
|
47260
|
-
for (const entry of
|
|
47325
|
+
if (fs9.existsSync(binDir)) {
|
|
47326
|
+
for (const entry of fs9.readdirSync(binDir)) {
|
|
47261
47327
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
47262
|
-
|
|
47263
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
47328
|
+
fs9.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
|
|
47329
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
|
|
47264
47330
|
}
|
|
47265
47331
|
}
|
|
47266
47332
|
}
|
|
@@ -47343,7 +47409,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47343
47409
|
process.exit(1);
|
|
47344
47410
|
}
|
|
47345
47411
|
}
|
|
47346
|
-
var
|
|
47412
|
+
var fs10 = __toESM2(require("fs"));
|
|
47347
47413
|
var CHAT_COMMANDS = [
|
|
47348
47414
|
"send_chat",
|
|
47349
47415
|
"new_chat",
|
|
@@ -47579,8 +47645,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47579
47645
|
if (sinceTs > 0) {
|
|
47580
47646
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
47581
47647
|
}
|
|
47582
|
-
if (
|
|
47583
|
-
const content =
|
|
47648
|
+
if (fs10.existsSync(LOG_PATH)) {
|
|
47649
|
+
const content = fs10.readFileSync(LOG_PATH, "utf-8");
|
|
47584
47650
|
const allLines = content.split("\n");
|
|
47585
47651
|
const recent = allLines.slice(-count).join("\n");
|
|
47586
47652
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -47722,6 +47788,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47722
47788
|
const wantsAll = args?.all === true;
|
|
47723
47789
|
const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
|
|
47724
47790
|
const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
|
|
47791
|
+
const requestedWorkspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|
|
47792
|
+
const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
|
|
47725
47793
|
const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
|
|
47726
47794
|
const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
|
|
47727
47795
|
canonicalHistory: providerMeta?.canonicalHistory,
|
|
@@ -47741,6 +47809,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47741
47809
|
sessions: historySessions.map((session) => {
|
|
47742
47810
|
const saved = savedSessionById.get(session.historySessionId);
|
|
47743
47811
|
const recent = recentSessionById.get(session.historySessionId);
|
|
47812
|
+
const workspace = saved?.workspace || recent?.workspace || session.workspace || (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : void 0);
|
|
47744
47813
|
return {
|
|
47745
47814
|
id: session.historySessionId,
|
|
47746
47815
|
providerSessionId: session.historySessionId,
|
|
@@ -47748,13 +47817,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47748
47817
|
providerName: saved?.providerName || recent?.providerName || providerType,
|
|
47749
47818
|
kind: saved?.kind || recent?.kind || kind,
|
|
47750
47819
|
title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
|
|
47751
|
-
workspace
|
|
47820
|
+
workspace,
|
|
47752
47821
|
summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
|
|
47753
47822
|
preview: session.preview,
|
|
47754
47823
|
messageCount: session.messageCount,
|
|
47755
47824
|
firstMessageAt: session.firstMessageAt,
|
|
47756
47825
|
lastMessageAt: session.lastMessageAt,
|
|
47757
|
-
canResume: !!
|
|
47826
|
+
canResume: !!workspace && canResumeById,
|
|
47758
47827
|
historySource: session.source,
|
|
47759
47828
|
sourcePath: session.sourcePath,
|
|
47760
47829
|
sourceMtimeMs: session.sourceMtimeMs
|
|
@@ -49708,12 +49777,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49708
49777
|
};
|
|
49709
49778
|
init_io_contracts();
|
|
49710
49779
|
init_chat_message_normalization();
|
|
49711
|
-
var
|
|
49712
|
-
var
|
|
49713
|
-
var
|
|
49780
|
+
var fs11 = __toESM2(require("fs"));
|
|
49781
|
+
var path18 = __toESM2(require("path"));
|
|
49782
|
+
var os19 = __toESM2(require("os"));
|
|
49714
49783
|
var import_child_process10 = require("child_process");
|
|
49715
49784
|
var import_os3 = require("os");
|
|
49716
|
-
var ARCHIVE_PATH =
|
|
49785
|
+
var ARCHIVE_PATH = path18.join(os19.homedir(), ".adhdev", "version-history.json");
|
|
49717
49786
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
49718
49787
|
var VersionArchive = class {
|
|
49719
49788
|
history = {};
|
|
@@ -49722,8 +49791,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49722
49791
|
}
|
|
49723
49792
|
load() {
|
|
49724
49793
|
try {
|
|
49725
|
-
if (
|
|
49726
|
-
this.history = JSON.parse(
|
|
49794
|
+
if (fs11.existsSync(ARCHIVE_PATH)) {
|
|
49795
|
+
this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
49727
49796
|
}
|
|
49728
49797
|
} catch {
|
|
49729
49798
|
this.history = {};
|
|
@@ -49760,8 +49829,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49760
49829
|
}
|
|
49761
49830
|
save() {
|
|
49762
49831
|
try {
|
|
49763
|
-
|
|
49764
|
-
|
|
49832
|
+
fs11.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
|
|
49833
|
+
fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
49765
49834
|
} catch {
|
|
49766
49835
|
}
|
|
49767
49836
|
}
|
|
@@ -49816,19 +49885,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49816
49885
|
function checkPathExists2(paths) {
|
|
49817
49886
|
for (const p of paths) {
|
|
49818
49887
|
if (p.includes("*")) {
|
|
49819
|
-
const home =
|
|
49820
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
49821
|
-
if (
|
|
49888
|
+
const home = os19.homedir();
|
|
49889
|
+
const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
|
|
49890
|
+
if (fs11.existsSync(resolved)) return resolved;
|
|
49822
49891
|
} else {
|
|
49823
|
-
if (
|
|
49892
|
+
if (fs11.existsSync(p)) return p;
|
|
49824
49893
|
}
|
|
49825
49894
|
}
|
|
49826
49895
|
return null;
|
|
49827
49896
|
}
|
|
49828
49897
|
function getMacAppVersion(appPath) {
|
|
49829
49898
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
49830
|
-
const plistPath =
|
|
49831
|
-
if (!
|
|
49899
|
+
const plistPath = path18.join(appPath, "Contents", "Info.plist");
|
|
49900
|
+
if (!fs11.existsSync(plistPath)) return null;
|
|
49832
49901
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
49833
49902
|
return raw || null;
|
|
49834
49903
|
}
|
|
@@ -49853,8 +49922,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49853
49922
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
49854
49923
|
let resolvedBin = cliBin;
|
|
49855
49924
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
49856
|
-
const bundled =
|
|
49857
|
-
if (provider.cli &&
|
|
49925
|
+
const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
49926
|
+
if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
|
|
49858
49927
|
}
|
|
49859
49928
|
info.installed = !!(appPath || resolvedBin);
|
|
49860
49929
|
info.path = appPath || null;
|
|
@@ -49891,8 +49960,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49891
49960
|
return results;
|
|
49892
49961
|
}
|
|
49893
49962
|
var http2 = __toESM2(require("http"));
|
|
49894
|
-
var
|
|
49895
|
-
var
|
|
49963
|
+
var fs15 = __toESM2(require("fs"));
|
|
49964
|
+
var path222 = __toESM2(require("path"));
|
|
49896
49965
|
init_config();
|
|
49897
49966
|
function generateFiles(type, name, category, opts = {}) {
|
|
49898
49967
|
const { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2 = "0.1" } = opts;
|
|
@@ -50236,8 +50305,8 @@ async (params) => {
|
|
|
50236
50305
|
};
|
|
50237
50306
|
}
|
|
50238
50307
|
init_logger();
|
|
50239
|
-
var
|
|
50240
|
-
var
|
|
50308
|
+
var fs12 = __toESM2(require("fs"));
|
|
50309
|
+
var path19 = __toESM2(require("path"));
|
|
50241
50310
|
init_logger();
|
|
50242
50311
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
50243
50312
|
const body = await ctx.readBody(req);
|
|
@@ -50416,18 +50485,18 @@ async (params) => {
|
|
|
50416
50485
|
return;
|
|
50417
50486
|
}
|
|
50418
50487
|
let scriptsPath = "";
|
|
50419
|
-
const directScripts =
|
|
50420
|
-
if (
|
|
50488
|
+
const directScripts = path19.join(dir, "scripts.js");
|
|
50489
|
+
if (fs12.existsSync(directScripts)) {
|
|
50421
50490
|
scriptsPath = directScripts;
|
|
50422
50491
|
} else {
|
|
50423
|
-
const scriptsDir =
|
|
50424
|
-
if (
|
|
50425
|
-
const versions =
|
|
50426
|
-
return
|
|
50492
|
+
const scriptsDir = path19.join(dir, "scripts");
|
|
50493
|
+
if (fs12.existsSync(scriptsDir)) {
|
|
50494
|
+
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
50495
|
+
return fs12.statSync(path19.join(scriptsDir, d)).isDirectory();
|
|
50427
50496
|
}).sort().reverse();
|
|
50428
50497
|
for (const ver of versions) {
|
|
50429
|
-
const p =
|
|
50430
|
-
if (
|
|
50498
|
+
const p = path19.join(scriptsDir, ver, "scripts.js");
|
|
50499
|
+
if (fs12.existsSync(p)) {
|
|
50431
50500
|
scriptsPath = p;
|
|
50432
50501
|
break;
|
|
50433
50502
|
}
|
|
@@ -50439,7 +50508,7 @@ async (params) => {
|
|
|
50439
50508
|
return;
|
|
50440
50509
|
}
|
|
50441
50510
|
try {
|
|
50442
|
-
const source =
|
|
50511
|
+
const source = fs12.readFileSync(scriptsPath, "utf-8");
|
|
50443
50512
|
const hints = {};
|
|
50444
50513
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
50445
50514
|
let match;
|
|
@@ -51252,8 +51321,8 @@ async (params) => {
|
|
|
51252
51321
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
51253
51322
|
}
|
|
51254
51323
|
}
|
|
51255
|
-
var
|
|
51256
|
-
var
|
|
51324
|
+
var fs13 = __toESM2(require("fs"));
|
|
51325
|
+
var path20 = __toESM2(require("path"));
|
|
51257
51326
|
function slugifyFixtureName(value) {
|
|
51258
51327
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
51259
51328
|
return normalized || `fixture-${Date.now()}`;
|
|
@@ -51263,15 +51332,15 @@ async (params) => {
|
|
|
51263
51332
|
if (!providerDir) {
|
|
51264
51333
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
51265
51334
|
}
|
|
51266
|
-
return
|
|
51335
|
+
return path20.join(providerDir, "fixtures");
|
|
51267
51336
|
}
|
|
51268
51337
|
function readCliFixture(ctx, type, name) {
|
|
51269
51338
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
51270
|
-
const filePath =
|
|
51271
|
-
if (!
|
|
51339
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
51340
|
+
if (!fs13.existsSync(filePath)) {
|
|
51272
51341
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
51273
51342
|
}
|
|
51274
|
-
return JSON.parse(
|
|
51343
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
|
|
51275
51344
|
}
|
|
51276
51345
|
function getExerciseTranscriptText(result) {
|
|
51277
51346
|
const parts = [];
|
|
@@ -52007,7 +52076,7 @@ async (params) => {
|
|
|
52007
52076
|
return;
|
|
52008
52077
|
}
|
|
52009
52078
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
52010
|
-
|
|
52079
|
+
fs13.mkdirSync(fixtureDir, { recursive: true });
|
|
52011
52080
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
52012
52081
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
52013
52082
|
const fixture = {
|
|
@@ -52034,8 +52103,8 @@ async (params) => {
|
|
|
52034
52103
|
},
|
|
52035
52104
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
52036
52105
|
};
|
|
52037
|
-
const filePath =
|
|
52038
|
-
|
|
52106
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
52107
|
+
fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
52039
52108
|
ctx.json(res, 200, {
|
|
52040
52109
|
saved: true,
|
|
52041
52110
|
name,
|
|
@@ -52053,14 +52122,14 @@ async (params) => {
|
|
|
52053
52122
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
52054
52123
|
try {
|
|
52055
52124
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
52056
|
-
if (!
|
|
52125
|
+
if (!fs13.existsSync(fixtureDir)) {
|
|
52057
52126
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
52058
52127
|
return;
|
|
52059
52128
|
}
|
|
52060
|
-
const fixtures =
|
|
52061
|
-
const fullPath =
|
|
52129
|
+
const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
52130
|
+
const fullPath = path20.join(fixtureDir, file2);
|
|
52062
52131
|
try {
|
|
52063
|
-
const raw = JSON.parse(
|
|
52132
|
+
const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
|
|
52064
52133
|
return {
|
|
52065
52134
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
52066
52135
|
path: fullPath,
|
|
@@ -52191,9 +52260,9 @@ async (params) => {
|
|
|
52191
52260
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
52192
52261
|
}
|
|
52193
52262
|
}
|
|
52194
|
-
var
|
|
52195
|
-
var
|
|
52196
|
-
var
|
|
52263
|
+
var fs14 = __toESM2(require("fs"));
|
|
52264
|
+
var path21 = __toESM2(require("path"));
|
|
52265
|
+
var os20 = __toESM2(require("os"));
|
|
52197
52266
|
function getAutoImplPid(ctx) {
|
|
52198
52267
|
const pid = ctx.autoImplProcess?.pid;
|
|
52199
52268
|
return typeof pid === "number" && pid > 0 ? pid : null;
|
|
@@ -52239,38 +52308,38 @@ async (params) => {
|
|
|
52239
52308
|
return fallback?.type || null;
|
|
52240
52309
|
}
|
|
52241
52310
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
52242
|
-
if (!
|
|
52243
|
-
const versions =
|
|
52311
|
+
if (!fs14.existsSync(scriptsDir)) return null;
|
|
52312
|
+
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
52244
52313
|
try {
|
|
52245
|
-
return
|
|
52314
|
+
return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
|
|
52246
52315
|
} catch {
|
|
52247
52316
|
return false;
|
|
52248
52317
|
}
|
|
52249
52318
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
52250
52319
|
if (versions.length === 0) return null;
|
|
52251
|
-
return
|
|
52320
|
+
return path21.join(scriptsDir, versions[0]);
|
|
52252
52321
|
}
|
|
52253
52322
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
52254
|
-
const canonicalUserDir =
|
|
52255
|
-
const desiredDir = requestedDir ?
|
|
52256
|
-
const upstreamRoot =
|
|
52257
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
52323
|
+
const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
52324
|
+
const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
|
|
52325
|
+
const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
|
|
52326
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
|
|
52258
52327
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
52259
52328
|
}
|
|
52260
|
-
if (
|
|
52329
|
+
if (path21.basename(desiredDir) !== type) {
|
|
52261
52330
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
52262
52331
|
}
|
|
52263
52332
|
const sourceDir = ctx.findProviderDir(type);
|
|
52264
52333
|
if (!sourceDir) {
|
|
52265
52334
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
52266
52335
|
}
|
|
52267
|
-
if (!
|
|
52268
|
-
|
|
52269
|
-
|
|
52336
|
+
if (!fs14.existsSync(desiredDir)) {
|
|
52337
|
+
fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
|
|
52338
|
+
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
52270
52339
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
52271
52340
|
}
|
|
52272
|
-
const providerJson =
|
|
52273
|
-
if (!
|
|
52341
|
+
const providerJson = path21.join(desiredDir, "provider.json");
|
|
52342
|
+
if (!fs14.existsSync(providerJson)) {
|
|
52274
52343
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
52275
52344
|
}
|
|
52276
52345
|
return { dir: desiredDir };
|
|
@@ -52278,15 +52347,15 @@ async (params) => {
|
|
|
52278
52347
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
52279
52348
|
if (!referenceType) return {};
|
|
52280
52349
|
const refDir = ctx.findProviderDir(referenceType);
|
|
52281
|
-
if (!refDir || !
|
|
52350
|
+
if (!refDir || !fs14.existsSync(refDir)) return {};
|
|
52282
52351
|
const referenceScripts = {};
|
|
52283
|
-
const scriptsDir =
|
|
52352
|
+
const scriptsDir = path21.join(refDir, "scripts");
|
|
52284
52353
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
52285
52354
|
if (!latestDir) return referenceScripts;
|
|
52286
|
-
for (const file2 of
|
|
52355
|
+
for (const file2 of fs14.readdirSync(latestDir)) {
|
|
52287
52356
|
if (!file2.endsWith(".js")) continue;
|
|
52288
52357
|
try {
|
|
52289
|
-
referenceScripts[file2] =
|
|
52358
|
+
referenceScripts[file2] = fs14.readFileSync(path21.join(latestDir, file2), "utf-8");
|
|
52290
52359
|
} catch {
|
|
52291
52360
|
}
|
|
52292
52361
|
}
|
|
@@ -52394,16 +52463,16 @@ async (params) => {
|
|
|
52394
52463
|
});
|
|
52395
52464
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
52396
52465
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
52397
|
-
const tmpDir =
|
|
52398
|
-
if (!
|
|
52399
|
-
const promptFile =
|
|
52400
|
-
|
|
52466
|
+
const tmpDir = path21.join(os20.tmpdir(), "adhdev-autoimpl");
|
|
52467
|
+
if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
|
|
52468
|
+
const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
52469
|
+
fs14.writeFileSync(promptFile, prompt, "utf-8");
|
|
52401
52470
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
52402
52471
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
52403
52472
|
const spawn4 = agentProvider?.spawn;
|
|
52404
52473
|
if (!spawn4?.command) {
|
|
52405
52474
|
try {
|
|
52406
|
-
|
|
52475
|
+
fs14.unlinkSync(promptFile);
|
|
52407
52476
|
} catch {
|
|
52408
52477
|
}
|
|
52409
52478
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -52505,7 +52574,7 @@ async (params) => {
|
|
|
52505
52574
|
} catch {
|
|
52506
52575
|
}
|
|
52507
52576
|
try {
|
|
52508
|
-
|
|
52577
|
+
fs14.unlinkSync(promptFile);
|
|
52509
52578
|
} catch {
|
|
52510
52579
|
}
|
|
52511
52580
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -52549,7 +52618,7 @@ async (params) => {
|
|
|
52549
52618
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
52550
52619
|
const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
52551
52620
|
let shellCmd;
|
|
52552
|
-
const isWin =
|
|
52621
|
+
const isWin = os20.platform() === "win32";
|
|
52553
52622
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
52554
52623
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
52555
52624
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -52588,7 +52657,7 @@ async (params) => {
|
|
|
52588
52657
|
try {
|
|
52589
52658
|
const pty = require("node-pty");
|
|
52590
52659
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
52591
|
-
const isWin2 =
|
|
52660
|
+
const isWin2 = os20.platform() === "win32";
|
|
52592
52661
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
52593
52662
|
name: "xterm-256color",
|
|
52594
52663
|
cols: 120,
|
|
@@ -52731,7 +52800,7 @@ async (params) => {
|
|
|
52731
52800
|
}
|
|
52732
52801
|
});
|
|
52733
52802
|
try {
|
|
52734
|
-
|
|
52803
|
+
fs14.unlinkSync(promptFile);
|
|
52735
52804
|
} catch {
|
|
52736
52805
|
}
|
|
52737
52806
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -52828,7 +52897,7 @@ async (params) => {
|
|
|
52828
52897
|
setMode: "set_mode.js"
|
|
52829
52898
|
};
|
|
52830
52899
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
52831
|
-
const scriptsDir =
|
|
52900
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
52832
52901
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
52833
52902
|
if (latestScriptsDir) {
|
|
52834
52903
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -52836,10 +52905,10 @@ async (params) => {
|
|
|
52836
52905
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
52837
52906
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
52838
52907
|
lines.push("");
|
|
52839
|
-
for (const file2 of
|
|
52908
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
52840
52909
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
52841
52910
|
try {
|
|
52842
|
-
const content =
|
|
52911
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
52843
52912
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
52844
52913
|
lines.push("```javascript");
|
|
52845
52914
|
lines.push(content);
|
|
@@ -52849,14 +52918,14 @@ async (params) => {
|
|
|
52849
52918
|
}
|
|
52850
52919
|
}
|
|
52851
52920
|
}
|
|
52852
|
-
const refFiles =
|
|
52921
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
52853
52922
|
if (refFiles.length > 0) {
|
|
52854
52923
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
52855
52924
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
52856
52925
|
lines.push("");
|
|
52857
52926
|
for (const file2 of refFiles) {
|
|
52858
52927
|
try {
|
|
52859
|
-
const content =
|
|
52928
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
52860
52929
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
52861
52930
|
lines.push("```javascript");
|
|
52862
52931
|
lines.push(content);
|
|
@@ -52897,11 +52966,11 @@ async (params) => {
|
|
|
52897
52966
|
lines.push("");
|
|
52898
52967
|
}
|
|
52899
52968
|
}
|
|
52900
|
-
const docsDir =
|
|
52969
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
52901
52970
|
const loadGuide = (name) => {
|
|
52902
52971
|
try {
|
|
52903
|
-
const p =
|
|
52904
|
-
if (
|
|
52972
|
+
const p = path21.join(docsDir, name);
|
|
52973
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
52905
52974
|
} catch {
|
|
52906
52975
|
}
|
|
52907
52976
|
return null;
|
|
@@ -53137,7 +53206,7 @@ async (params) => {
|
|
|
53137
53206
|
parseApproval: "parse_approval.js"
|
|
53138
53207
|
};
|
|
53139
53208
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
53140
|
-
const scriptsDir =
|
|
53209
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
53141
53210
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
53142
53211
|
if (latestScriptsDir) {
|
|
53143
53212
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -53145,11 +53214,11 @@ async (params) => {
|
|
|
53145
53214
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
53146
53215
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
53147
53216
|
lines.push("");
|
|
53148
|
-
for (const file2 of
|
|
53217
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
53149
53218
|
if (!file2.endsWith(".js")) continue;
|
|
53150
53219
|
if (!targetFileNames.has(file2)) continue;
|
|
53151
53220
|
try {
|
|
53152
|
-
const content =
|
|
53221
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
53153
53222
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
53154
53223
|
lines.push("```javascript");
|
|
53155
53224
|
lines.push(content);
|
|
@@ -53158,14 +53227,14 @@ async (params) => {
|
|
|
53158
53227
|
} catch {
|
|
53159
53228
|
}
|
|
53160
53229
|
}
|
|
53161
|
-
const refFiles =
|
|
53230
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
53162
53231
|
if (refFiles.length > 0) {
|
|
53163
53232
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
53164
53233
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
53165
53234
|
lines.push("");
|
|
53166
53235
|
for (const file2 of refFiles) {
|
|
53167
53236
|
try {
|
|
53168
|
-
const content =
|
|
53237
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
53169
53238
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
53170
53239
|
lines.push("```javascript");
|
|
53171
53240
|
lines.push(content);
|
|
@@ -53198,11 +53267,11 @@ async (params) => {
|
|
|
53198
53267
|
lines.push("");
|
|
53199
53268
|
}
|
|
53200
53269
|
}
|
|
53201
|
-
const docsDir =
|
|
53270
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
53202
53271
|
const loadGuide = (name) => {
|
|
53203
53272
|
try {
|
|
53204
|
-
const p =
|
|
53205
|
-
if (
|
|
53273
|
+
const p = path21.join(docsDir, name);
|
|
53274
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
53206
53275
|
} catch {
|
|
53207
53276
|
}
|
|
53208
53277
|
return null;
|
|
@@ -53646,8 +53715,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53646
53715
|
}
|
|
53647
53716
|
getEndpointList() {
|
|
53648
53717
|
return this.routes.map((r) => {
|
|
53649
|
-
const
|
|
53650
|
-
return `${r.method.padEnd(5)} ${
|
|
53718
|
+
const path232 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
53719
|
+
return `${r.method.padEnd(5)} ${path232}`;
|
|
53651
53720
|
});
|
|
53652
53721
|
}
|
|
53653
53722
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -53935,12 +54004,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53935
54004
|
// ─── DevConsole SPA ───
|
|
53936
54005
|
getConsoleDistDir() {
|
|
53937
54006
|
const candidates = [
|
|
53938
|
-
|
|
53939
|
-
|
|
53940
|
-
|
|
54007
|
+
path222.resolve(__dirname, "../../web-devconsole/dist"),
|
|
54008
|
+
path222.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
54009
|
+
path222.join(process.cwd(), "packages/web-devconsole/dist")
|
|
53941
54010
|
];
|
|
53942
54011
|
for (const dir of candidates) {
|
|
53943
|
-
if (
|
|
54012
|
+
if (fs15.existsSync(path222.join(dir, "index.html"))) return dir;
|
|
53944
54013
|
}
|
|
53945
54014
|
return null;
|
|
53946
54015
|
}
|
|
@@ -53950,9 +54019,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53950
54019
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
53951
54020
|
return;
|
|
53952
54021
|
}
|
|
53953
|
-
const htmlPath =
|
|
54022
|
+
const htmlPath = path222.join(distDir, "index.html");
|
|
53954
54023
|
try {
|
|
53955
|
-
const html =
|
|
54024
|
+
const html = fs15.readFileSync(htmlPath, "utf-8");
|
|
53956
54025
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
53957
54026
|
res.end(html);
|
|
53958
54027
|
} catch (e) {
|
|
@@ -53975,15 +54044,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53975
54044
|
this.json(res, 404, { error: "Not found" });
|
|
53976
54045
|
return;
|
|
53977
54046
|
}
|
|
53978
|
-
const safePath =
|
|
53979
|
-
const filePath =
|
|
54047
|
+
const safePath = path222.normalize(pathname).replace(/^\.\.\//, "");
|
|
54048
|
+
const filePath = path222.join(distDir, safePath);
|
|
53980
54049
|
if (!filePath.startsWith(distDir)) {
|
|
53981
54050
|
this.json(res, 403, { error: "Forbidden" });
|
|
53982
54051
|
return;
|
|
53983
54052
|
}
|
|
53984
54053
|
try {
|
|
53985
|
-
const content =
|
|
53986
|
-
const ext =
|
|
54054
|
+
const content = fs15.readFileSync(filePath);
|
|
54055
|
+
const ext = path222.extname(filePath);
|
|
53987
54056
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
53988
54057
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
53989
54058
|
res.end(content);
|
|
@@ -54091,14 +54160,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54091
54160
|
const files = [];
|
|
54092
54161
|
const scan = (d, prefix) => {
|
|
54093
54162
|
try {
|
|
54094
|
-
for (const entry of
|
|
54163
|
+
for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
|
|
54095
54164
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
54096
54165
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
54097
54166
|
if (entry.isDirectory()) {
|
|
54098
54167
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
54099
|
-
scan(
|
|
54168
|
+
scan(path222.join(d, entry.name), rel);
|
|
54100
54169
|
} else {
|
|
54101
|
-
const stat4 =
|
|
54170
|
+
const stat4 = fs15.statSync(path222.join(d, entry.name));
|
|
54102
54171
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
54103
54172
|
}
|
|
54104
54173
|
}
|
|
@@ -54121,16 +54190,16 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54121
54190
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
54122
54191
|
return;
|
|
54123
54192
|
}
|
|
54124
|
-
const fullPath =
|
|
54193
|
+
const fullPath = path222.resolve(dir, path222.normalize(filePath));
|
|
54125
54194
|
if (!fullPath.startsWith(dir)) {
|
|
54126
54195
|
this.json(res, 403, { error: "Forbidden" });
|
|
54127
54196
|
return;
|
|
54128
54197
|
}
|
|
54129
|
-
if (!
|
|
54198
|
+
if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
|
|
54130
54199
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
54131
54200
|
return;
|
|
54132
54201
|
}
|
|
54133
|
-
const content =
|
|
54202
|
+
const content = fs15.readFileSync(fullPath, "utf-8");
|
|
54134
54203
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
54135
54204
|
}
|
|
54136
54205
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -54146,15 +54215,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54146
54215
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
54147
54216
|
return;
|
|
54148
54217
|
}
|
|
54149
|
-
const fullPath =
|
|
54218
|
+
const fullPath = path222.resolve(dir, path222.normalize(filePath));
|
|
54150
54219
|
if (!fullPath.startsWith(dir)) {
|
|
54151
54220
|
this.json(res, 403, { error: "Forbidden" });
|
|
54152
54221
|
return;
|
|
54153
54222
|
}
|
|
54154
54223
|
try {
|
|
54155
|
-
if (
|
|
54156
|
-
|
|
54157
|
-
|
|
54224
|
+
if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
|
|
54225
|
+
fs15.mkdirSync(path222.dirname(fullPath), { recursive: true });
|
|
54226
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
54158
54227
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
54159
54228
|
this.providerLoader.reload();
|
|
54160
54229
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -54170,9 +54239,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54170
54239
|
return;
|
|
54171
54240
|
}
|
|
54172
54241
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
54173
|
-
const p =
|
|
54174
|
-
if (
|
|
54175
|
-
const source =
|
|
54242
|
+
const p = path222.join(dir, name);
|
|
54243
|
+
if (fs15.existsSync(p)) {
|
|
54244
|
+
const source = fs15.readFileSync(p, "utf-8");
|
|
54176
54245
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
54177
54246
|
return;
|
|
54178
54247
|
}
|
|
@@ -54191,11 +54260,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54191
54260
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
54192
54261
|
return;
|
|
54193
54262
|
}
|
|
54194
|
-
const target =
|
|
54195
|
-
const targetPath =
|
|
54263
|
+
const target = fs15.existsSync(path222.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
54264
|
+
const targetPath = path222.join(dir, target);
|
|
54196
54265
|
try {
|
|
54197
|
-
if (
|
|
54198
|
-
|
|
54266
|
+
if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
|
|
54267
|
+
fs15.writeFileSync(targetPath, source, "utf-8");
|
|
54199
54268
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
54200
54269
|
this.providerLoader.reload();
|
|
54201
54270
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -54339,21 +54408,21 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54339
54408
|
}
|
|
54340
54409
|
let targetDir;
|
|
54341
54410
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
54342
|
-
const jsonPath =
|
|
54343
|
-
if (
|
|
54411
|
+
const jsonPath = path222.join(targetDir, "provider.json");
|
|
54412
|
+
if (fs15.existsSync(jsonPath)) {
|
|
54344
54413
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
54345
54414
|
return;
|
|
54346
54415
|
}
|
|
54347
54416
|
try {
|
|
54348
54417
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
54349
|
-
|
|
54350
|
-
|
|
54418
|
+
fs15.mkdirSync(targetDir, { recursive: true });
|
|
54419
|
+
fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
54351
54420
|
const createdFiles = ["provider.json"];
|
|
54352
54421
|
if (result.files) {
|
|
54353
54422
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
54354
|
-
const fullPath =
|
|
54355
|
-
|
|
54356
|
-
|
|
54423
|
+
const fullPath = path222.join(targetDir, relPath);
|
|
54424
|
+
fs15.mkdirSync(path222.dirname(fullPath), { recursive: true });
|
|
54425
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
54357
54426
|
createdFiles.push(relPath);
|
|
54358
54427
|
}
|
|
54359
54428
|
}
|
|
@@ -54402,38 +54471,38 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54402
54471
|
}
|
|
54403
54472
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
54404
54473
|
getLatestScriptVersionDir(scriptsDir) {
|
|
54405
|
-
if (!
|
|
54406
|
-
const versions =
|
|
54474
|
+
if (!fs15.existsSync(scriptsDir)) return null;
|
|
54475
|
+
const versions = fs15.readdirSync(scriptsDir).filter((d) => {
|
|
54407
54476
|
try {
|
|
54408
|
-
return
|
|
54477
|
+
return fs15.statSync(path222.join(scriptsDir, d)).isDirectory();
|
|
54409
54478
|
} catch {
|
|
54410
54479
|
return false;
|
|
54411
54480
|
}
|
|
54412
54481
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
54413
54482
|
if (versions.length === 0) return null;
|
|
54414
|
-
return
|
|
54483
|
+
return path222.join(scriptsDir, versions[0]);
|
|
54415
54484
|
}
|
|
54416
54485
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
54417
|
-
const canonicalUserDir =
|
|
54418
|
-
const desiredDir = requestedDir ?
|
|
54419
|
-
const upstreamRoot =
|
|
54420
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
54486
|
+
const canonicalUserDir = path222.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
54487
|
+
const desiredDir = requestedDir ? path222.resolve(requestedDir) : canonicalUserDir;
|
|
54488
|
+
const upstreamRoot = path222.resolve(this.providerLoader.getUpstreamDir());
|
|
54489
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path222.sep}`)) {
|
|
54421
54490
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
54422
54491
|
}
|
|
54423
|
-
if (
|
|
54492
|
+
if (path222.basename(desiredDir) !== type) {
|
|
54424
54493
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
54425
54494
|
}
|
|
54426
54495
|
const sourceDir = this.findProviderDir(type);
|
|
54427
54496
|
if (!sourceDir) {
|
|
54428
54497
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
54429
54498
|
}
|
|
54430
|
-
if (!
|
|
54431
|
-
|
|
54432
|
-
|
|
54499
|
+
if (!fs15.existsSync(desiredDir)) {
|
|
54500
|
+
fs15.mkdirSync(path222.dirname(desiredDir), { recursive: true });
|
|
54501
|
+
fs15.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
54433
54502
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
54434
54503
|
}
|
|
54435
|
-
const providerJson =
|
|
54436
|
-
if (!
|
|
54504
|
+
const providerJson = path222.join(desiredDir, "provider.json");
|
|
54505
|
+
if (!fs15.existsSync(providerJson)) {
|
|
54437
54506
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
54438
54507
|
}
|
|
54439
54508
|
return { dir: desiredDir };
|
|
@@ -54468,7 +54537,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54468
54537
|
setMode: "set_mode.js"
|
|
54469
54538
|
};
|
|
54470
54539
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
54471
|
-
const scriptsDir =
|
|
54540
|
+
const scriptsDir = path222.join(providerDir, "scripts");
|
|
54472
54541
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
54473
54542
|
if (latestScriptsDir) {
|
|
54474
54543
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -54476,10 +54545,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54476
54545
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
54477
54546
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
54478
54547
|
lines.push("");
|
|
54479
|
-
for (const file2 of
|
|
54548
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
54480
54549
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
54481
54550
|
try {
|
|
54482
|
-
const content =
|
|
54551
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54483
54552
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
54484
54553
|
lines.push("```javascript");
|
|
54485
54554
|
lines.push(content);
|
|
@@ -54489,14 +54558,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54489
54558
|
}
|
|
54490
54559
|
}
|
|
54491
54560
|
}
|
|
54492
|
-
const refFiles =
|
|
54561
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
54493
54562
|
if (refFiles.length > 0) {
|
|
54494
54563
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
54495
54564
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
54496
54565
|
lines.push("");
|
|
54497
54566
|
for (const file2 of refFiles) {
|
|
54498
54567
|
try {
|
|
54499
|
-
const content =
|
|
54568
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54500
54569
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
54501
54570
|
lines.push("```javascript");
|
|
54502
54571
|
lines.push(content);
|
|
@@ -54537,11 +54606,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54537
54606
|
lines.push("");
|
|
54538
54607
|
}
|
|
54539
54608
|
}
|
|
54540
|
-
const docsDir =
|
|
54609
|
+
const docsDir = path222.join(providerDir, "../../docs");
|
|
54541
54610
|
const loadGuide = (name) => {
|
|
54542
54611
|
try {
|
|
54543
|
-
const p =
|
|
54544
|
-
if (
|
|
54612
|
+
const p = path222.join(docsDir, name);
|
|
54613
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
54545
54614
|
} catch {
|
|
54546
54615
|
}
|
|
54547
54616
|
return null;
|
|
@@ -54714,7 +54783,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54714
54783
|
parseApproval: "parse_approval.js"
|
|
54715
54784
|
};
|
|
54716
54785
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
54717
|
-
const scriptsDir =
|
|
54786
|
+
const scriptsDir = path222.join(providerDir, "scripts");
|
|
54718
54787
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
54719
54788
|
if (latestScriptsDir) {
|
|
54720
54789
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -54722,11 +54791,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54722
54791
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
54723
54792
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
54724
54793
|
lines.push("");
|
|
54725
|
-
for (const file2 of
|
|
54794
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
54726
54795
|
if (!file2.endsWith(".js")) continue;
|
|
54727
54796
|
if (!targetFileNames.has(file2)) continue;
|
|
54728
54797
|
try {
|
|
54729
|
-
const content =
|
|
54798
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54730
54799
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
54731
54800
|
lines.push("```javascript");
|
|
54732
54801
|
lines.push(content);
|
|
@@ -54735,14 +54804,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54735
54804
|
} catch {
|
|
54736
54805
|
}
|
|
54737
54806
|
}
|
|
54738
|
-
const refFiles =
|
|
54807
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
54739
54808
|
if (refFiles.length > 0) {
|
|
54740
54809
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
54741
54810
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
54742
54811
|
lines.push("");
|
|
54743
54812
|
for (const file2 of refFiles) {
|
|
54744
54813
|
try {
|
|
54745
|
-
const content =
|
|
54814
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54746
54815
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
54747
54816
|
lines.push("```javascript");
|
|
54748
54817
|
lines.push(content);
|
|
@@ -54775,11 +54844,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54775
54844
|
lines.push("");
|
|
54776
54845
|
}
|
|
54777
54846
|
}
|
|
54778
|
-
const docsDir =
|
|
54847
|
+
const docsDir = path222.join(providerDir, "../../docs");
|
|
54779
54848
|
const loadGuide = (name) => {
|
|
54780
54849
|
try {
|
|
54781
|
-
const p =
|
|
54782
|
-
if (
|
|
54850
|
+
const p = path222.join(docsDir, name);
|
|
54851
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
54783
54852
|
} catch {
|
|
54784
54853
|
}
|
|
54785
54854
|
return null;
|
|
@@ -55642,8 +55711,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
55642
55711
|
const res = await fetch(extension.vsixUrl);
|
|
55643
55712
|
if (res.ok) {
|
|
55644
55713
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
55645
|
-
const
|
|
55646
|
-
|
|
55714
|
+
const fs16 = await import("fs");
|
|
55715
|
+
fs16.writeFileSync(vsixPath, buffer);
|
|
55647
55716
|
return new Promise((resolve12) => {
|
|
55648
55717
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
55649
55718
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|