@adhdev/daemon-standalone 0.9.50 → 0.9.52
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 +464 -401
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{index-BNCOpUZd.js → index-BBcPdOv8.js} +28 -27
- package/public/index.html +1 -1
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,6 +38945,50 @@ ${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) {
|
|
38945
38993
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
38946
38994
|
if (!targetSessionId && !h.currentSession) {
|
|
@@ -39052,6 +39100,20 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39052
39100
|
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
39053
39101
|
};
|
|
39054
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
|
+
}
|
|
39055
39117
|
return {
|
|
39056
39118
|
success: true,
|
|
39057
39119
|
bundle,
|
|
@@ -40031,9 +40093,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40031
40093
|
}
|
|
40032
40094
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
40033
40095
|
}
|
|
40034
|
-
var
|
|
40035
|
-
var
|
|
40036
|
-
var
|
|
40096
|
+
var fs52 = __toESM2(require("fs"));
|
|
40097
|
+
var path9 = __toESM2(require("path"));
|
|
40098
|
+
var os7 = __toESM2(require("os"));
|
|
40037
40099
|
var KEY_TO_VK = {
|
|
40038
40100
|
Backspace: 8,
|
|
40039
40101
|
Tab: 9,
|
|
@@ -40287,27 +40349,27 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40287
40349
|
function resolveSafePath(requestedPath) {
|
|
40288
40350
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
40289
40351
|
const inputPath = rawPath || ".";
|
|
40290
|
-
const home =
|
|
40352
|
+
const home = os7.homedir();
|
|
40291
40353
|
if (inputPath.startsWith("~")) {
|
|
40292
|
-
return
|
|
40354
|
+
return path9.resolve(path9.join(home, inputPath.slice(1)));
|
|
40293
40355
|
}
|
|
40294
40356
|
if (process.platform === "win32") {
|
|
40295
40357
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
40296
|
-
if (
|
|
40297
|
-
return
|
|
40358
|
+
if (path9.win32.isAbsolute(normalized)) {
|
|
40359
|
+
return path9.win32.normalize(normalized);
|
|
40298
40360
|
}
|
|
40299
|
-
return
|
|
40361
|
+
return path9.win32.resolve(normalized);
|
|
40300
40362
|
}
|
|
40301
|
-
if (
|
|
40302
|
-
return
|
|
40363
|
+
if (path9.isAbsolute(inputPath)) {
|
|
40364
|
+
return path9.normalize(inputPath);
|
|
40303
40365
|
}
|
|
40304
|
-
return
|
|
40366
|
+
return path9.resolve(inputPath);
|
|
40305
40367
|
}
|
|
40306
40368
|
function listDirectoryEntriesSafe(dirPath) {
|
|
40307
|
-
const entries =
|
|
40369
|
+
const entries = fs52.readdirSync(dirPath, { withFileTypes: true });
|
|
40308
40370
|
const files = [];
|
|
40309
40371
|
for (const entry of entries) {
|
|
40310
|
-
const entryPath =
|
|
40372
|
+
const entryPath = path9.join(dirPath, entry.name);
|
|
40311
40373
|
try {
|
|
40312
40374
|
if (entry.isDirectory()) {
|
|
40313
40375
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -40316,14 +40378,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40316
40378
|
if (entry.isFile()) {
|
|
40317
40379
|
let size;
|
|
40318
40380
|
try {
|
|
40319
|
-
size =
|
|
40381
|
+
size = fs52.statSync(entryPath).size;
|
|
40320
40382
|
} catch {
|
|
40321
40383
|
size = void 0;
|
|
40322
40384
|
}
|
|
40323
40385
|
files.push({ name: entry.name, type: "file", size });
|
|
40324
40386
|
continue;
|
|
40325
40387
|
}
|
|
40326
|
-
const stat4 =
|
|
40388
|
+
const stat4 = fs52.statSync(entryPath);
|
|
40327
40389
|
files.push({
|
|
40328
40390
|
name: entry.name,
|
|
40329
40391
|
type: stat4.isDirectory() ? "directory" : "file",
|
|
@@ -40341,7 +40403,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40341
40403
|
const letter = String.fromCharCode(code);
|
|
40342
40404
|
const root = `${letter}:\\`;
|
|
40343
40405
|
try {
|
|
40344
|
-
if (!
|
|
40406
|
+
if (!fs52.existsSync(root)) continue;
|
|
40345
40407
|
if (excluded && root.toLowerCase() === excluded) continue;
|
|
40346
40408
|
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
40347
40409
|
} catch {
|
|
@@ -40352,7 +40414,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40352
40414
|
async function handleFileRead(h, args) {
|
|
40353
40415
|
try {
|
|
40354
40416
|
const filePath = resolveSafePath(args?.path);
|
|
40355
|
-
const content =
|
|
40417
|
+
const content = fs52.readFileSync(filePath, "utf-8");
|
|
40356
40418
|
return { success: true, content, path: filePath };
|
|
40357
40419
|
} catch (e) {
|
|
40358
40420
|
return { success: false, error: e.message };
|
|
@@ -40361,8 +40423,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40361
40423
|
async function handleFileWrite(h, args) {
|
|
40362
40424
|
try {
|
|
40363
40425
|
const filePath = resolveSafePath(args?.path);
|
|
40364
|
-
|
|
40365
|
-
|
|
40426
|
+
fs52.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
40427
|
+
fs52.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
40366
40428
|
return { success: true, path: filePath };
|
|
40367
40429
|
} catch (e) {
|
|
40368
40430
|
return { success: false, error: e.message };
|
|
@@ -40587,12 +40649,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40587
40649
|
});
|
|
40588
40650
|
loader.reload();
|
|
40589
40651
|
loader.registerToDetector();
|
|
40652
|
+
const refreshedInstances = h.ctx.instanceManager ? h.ctx.instanceManager.refreshProviderDefinitions((providerType) => loader.resolve(providerType)) : 0;
|
|
40590
40653
|
await h.ctx.onProviderSourceConfigChanged?.();
|
|
40591
40654
|
LOG2.info(
|
|
40592
40655
|
"Command",
|
|
40593
40656
|
`[set_provider_source_config] mode=${sourceConfig.sourceMode} explicitProviderDir=${sourceConfig.explicitProviderDir || "-"} userDir=${sourceConfig.userDir}`
|
|
40594
40657
|
);
|
|
40595
|
-
return { success: true, reloaded: true, ...sourceConfig };
|
|
40658
|
+
return { success: true, reloaded: true, refreshedInstances, ...sourceConfig };
|
|
40596
40659
|
}
|
|
40597
40660
|
function normalizeProviderScriptArgs(args, scriptName) {
|
|
40598
40661
|
const normalizedArgs = { ...args || {} };
|
|
@@ -41449,18 +41512,18 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41449
41512
|
}
|
|
41450
41513
|
}
|
|
41451
41514
|
};
|
|
41452
|
-
var
|
|
41453
|
-
var
|
|
41515
|
+
var os13 = __toESM2(require("os"));
|
|
41516
|
+
var path13 = __toESM2(require("path"));
|
|
41454
41517
|
var crypto4 = __toESM2(require("crypto"));
|
|
41455
41518
|
var import_fs5 = require("fs");
|
|
41456
41519
|
var import_child_process6 = require("child_process");
|
|
41457
41520
|
var import_chalk = __toESM2(require("chalk"));
|
|
41458
41521
|
init_provider_cli_adapter();
|
|
41459
41522
|
init_config();
|
|
41460
|
-
var
|
|
41461
|
-
var
|
|
41523
|
+
var os12 = __toESM2(require("os"));
|
|
41524
|
+
var path12 = __toESM2(require("path"));
|
|
41462
41525
|
var crypto3 = __toESM2(require("crypto"));
|
|
41463
|
-
var
|
|
41526
|
+
var fs6 = __toESM2(require("fs"));
|
|
41464
41527
|
var import_node_module = require("module");
|
|
41465
41528
|
init_contracts();
|
|
41466
41529
|
init_provider_cli_adapter();
|
|
@@ -41515,7 +41578,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41515
41578
|
var CachedDatabaseSync = null;
|
|
41516
41579
|
function getDatabaseSync() {
|
|
41517
41580
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
41518
|
-
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(
|
|
41581
|
+
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path12.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
41519
41582
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
41520
41583
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
41521
41584
|
if (!CachedDatabaseSync) {
|
|
@@ -41665,10 +41728,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41665
41728
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
41666
41729
|
*/
|
|
41667
41730
|
probeSessionIdFromConfig(probe) {
|
|
41668
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
41731
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os12.homedir());
|
|
41669
41732
|
const now = Date.now();
|
|
41670
41733
|
if (this.cachedSqliteDbMissingUntil > now) return null;
|
|
41671
|
-
if (!
|
|
41734
|
+
if (!fs6.existsSync(resolvedDbPath)) {
|
|
41672
41735
|
this.cachedSqliteDbMissingUntil = now + 1e4;
|
|
41673
41736
|
return null;
|
|
41674
41737
|
}
|
|
@@ -42400,7 +42463,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
42400
42463
|
};
|
|
42401
42464
|
addDir(this.workingDir);
|
|
42402
42465
|
try {
|
|
42403
|
-
addDir(
|
|
42466
|
+
addDir(fs6.realpathSync.native(this.workingDir));
|
|
42404
42467
|
} catch {
|
|
42405
42468
|
}
|
|
42406
42469
|
return Array.from(dirs);
|
|
@@ -43591,11 +43654,11 @@ ${rawInput}` : rawInput;
|
|
|
43591
43654
|
}
|
|
43592
43655
|
function isExplicitCommand(command) {
|
|
43593
43656
|
const trimmed = command.trim();
|
|
43594
|
-
return
|
|
43657
|
+
return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
43595
43658
|
}
|
|
43596
43659
|
function expandExecutable(command) {
|
|
43597
43660
|
const trimmed = command.trim();
|
|
43598
|
-
return trimmed.startsWith("~") ?
|
|
43661
|
+
return trimmed.startsWith("~") ? path13.join(os13.homedir(), trimmed.slice(1)) : trimmed;
|
|
43599
43662
|
}
|
|
43600
43663
|
function commandExists(command) {
|
|
43601
43664
|
const trimmed = command.trim();
|
|
@@ -43876,7 +43939,7 @@ ${rawInput}` : rawInput;
|
|
|
43876
43939
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
43877
43940
|
const trimmed = (workingDir || "").trim();
|
|
43878
43941
|
if (!trimmed) throw new Error("working directory required");
|
|
43879
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
43942
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path13.resolve(trimmed);
|
|
43880
43943
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
43881
43944
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
43882
43945
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -44374,11 +44437,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44374
44437
|
};
|
|
44375
44438
|
var import_child_process7 = require("child_process");
|
|
44376
44439
|
var net3 = __toESM2(require("net"));
|
|
44377
|
-
var
|
|
44440
|
+
var os15 = __toESM2(require("os"));
|
|
44441
|
+
var path15 = __toESM2(require("path"));
|
|
44442
|
+
var fs7 = __toESM2(require("fs"));
|
|
44378
44443
|
var path14 = __toESM2(require("path"));
|
|
44379
|
-
var
|
|
44380
|
-
var path13 = __toESM2(require("path"));
|
|
44381
|
-
var os13 = __toESM2(require("os"));
|
|
44444
|
+
var os14 = __toESM2(require("os"));
|
|
44382
44445
|
var chokidar = __toESM2((init_chokidar(), __toCommonJS(chokidar_exports)));
|
|
44383
44446
|
init_logger();
|
|
44384
44447
|
var VALID_CAPABILITY_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
|
|
@@ -44636,9 +44699,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44636
44699
|
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
44637
44700
|
static looksLikeProviderRoot(candidate) {
|
|
44638
44701
|
try {
|
|
44639
|
-
if (!
|
|
44702
|
+
if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
|
|
44640
44703
|
return ["ide", "extension", "cli", "acp"].some(
|
|
44641
|
-
(category) =>
|
|
44704
|
+
(category) => fs7.existsSync(path14.join(candidate, category))
|
|
44642
44705
|
);
|
|
44643
44706
|
} catch {
|
|
44644
44707
|
return false;
|
|
@@ -44646,20 +44709,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44646
44709
|
}
|
|
44647
44710
|
static hasProviderRootMarker(candidate) {
|
|
44648
44711
|
try {
|
|
44649
|
-
return
|
|
44712
|
+
return fs7.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
44650
44713
|
} catch {
|
|
44651
44714
|
return false;
|
|
44652
44715
|
}
|
|
44653
44716
|
}
|
|
44654
44717
|
detectDefaultUserDir() {
|
|
44655
|
-
const fallback =
|
|
44718
|
+
const fallback = path14.join(os14.homedir(), ".adhdev", "providers");
|
|
44656
44719
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
44657
44720
|
const visited = /* @__PURE__ */ new Set();
|
|
44658
44721
|
for (const start of this.probeStarts) {
|
|
44659
|
-
let current =
|
|
44722
|
+
let current = path14.resolve(start);
|
|
44660
44723
|
while (!visited.has(current)) {
|
|
44661
44724
|
visited.add(current);
|
|
44662
|
-
const siblingCandidate =
|
|
44725
|
+
const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
44663
44726
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
44664
44727
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
44665
44728
|
if (envOptIn || hasMarker) {
|
|
@@ -44681,7 +44744,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44681
44744
|
return { path: siblingCandidate, source };
|
|
44682
44745
|
}
|
|
44683
44746
|
}
|
|
44684
|
-
const parent =
|
|
44747
|
+
const parent = path14.dirname(current);
|
|
44685
44748
|
if (parent === current) break;
|
|
44686
44749
|
current = parent;
|
|
44687
44750
|
}
|
|
@@ -44691,11 +44754,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44691
44754
|
constructor(options) {
|
|
44692
44755
|
this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
|
|
44693
44756
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
44694
|
-
this.defaultProvidersDir =
|
|
44757
|
+
this.defaultProvidersDir = path14.join(os14.homedir(), ".adhdev", "providers");
|
|
44695
44758
|
const detected = this.detectDefaultUserDir();
|
|
44696
44759
|
this.userDir = detected.path;
|
|
44697
44760
|
this.userDirSource = detected.source;
|
|
44698
|
-
this.upstreamDir =
|
|
44761
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
44699
44762
|
this.disableUpstream = false;
|
|
44700
44763
|
this.applySourceConfig({
|
|
44701
44764
|
userDir: options?.userDir,
|
|
@@ -44754,7 +44817,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44754
44817
|
this.userDir = detected.path;
|
|
44755
44818
|
this.userDirSource = detected.source;
|
|
44756
44819
|
}
|
|
44757
|
-
this.upstreamDir =
|
|
44820
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
44758
44821
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
44759
44822
|
if (this.explicitProviderDir) {
|
|
44760
44823
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -44768,7 +44831,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44768
44831
|
* Canonical provider directory shape for a given root.
|
|
44769
44832
|
*/
|
|
44770
44833
|
getProviderDir(root, category, type) {
|
|
44771
|
-
return
|
|
44834
|
+
return path14.join(root, category, type);
|
|
44772
44835
|
}
|
|
44773
44836
|
/**
|
|
44774
44837
|
* Canonical user override directory for a provider.
|
|
@@ -44795,7 +44858,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44795
44858
|
resolveProviderFile(type, ...segments) {
|
|
44796
44859
|
const dir = this.findProviderDirInternal(type);
|
|
44797
44860
|
if (!dir) return null;
|
|
44798
|
-
return
|
|
44861
|
+
return path14.join(dir, ...segments);
|
|
44799
44862
|
}
|
|
44800
44863
|
/**
|
|
44801
44864
|
* Load all providers (3-tier priority)
|
|
@@ -44808,7 +44871,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44808
44871
|
this.providers.clear();
|
|
44809
44872
|
this.providerAvailability.clear();
|
|
44810
44873
|
let upstreamCount = 0;
|
|
44811
|
-
if (!this.disableUpstream &&
|
|
44874
|
+
if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
|
|
44812
44875
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
44813
44876
|
if (upstreamCount > 0) {
|
|
44814
44877
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -44816,7 +44879,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44816
44879
|
} else if (this.disableUpstream) {
|
|
44817
44880
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
44818
44881
|
}
|
|
44819
|
-
if (
|
|
44882
|
+
if (fs7.existsSync(this.userDir)) {
|
|
44820
44883
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
44821
44884
|
if (userCount > 0) {
|
|
44822
44885
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -44831,10 +44894,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44831
44894
|
* Check if upstream directory exists and has providers.
|
|
44832
44895
|
*/
|
|
44833
44896
|
hasUpstream() {
|
|
44834
|
-
if (!
|
|
44897
|
+
if (!fs7.existsSync(this.upstreamDir)) return false;
|
|
44835
44898
|
try {
|
|
44836
|
-
return
|
|
44837
|
-
(d) =>
|
|
44899
|
+
return fs7.readdirSync(this.upstreamDir).some(
|
|
44900
|
+
(d) => fs7.statSync(path14.join(this.upstreamDir, d)).isDirectory()
|
|
44838
44901
|
);
|
|
44839
44902
|
} catch {
|
|
44840
44903
|
return false;
|
|
@@ -45331,8 +45394,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45331
45394
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
45332
45395
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
45333
45396
|
if (providerDir) {
|
|
45334
|
-
const fullDir =
|
|
45335
|
-
resolved._resolvedScriptsPath =
|
|
45397
|
+
const fullDir = path14.join(providerDir, entry.scriptDir);
|
|
45398
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45336
45399
|
}
|
|
45337
45400
|
matched = true;
|
|
45338
45401
|
}
|
|
@@ -45347,8 +45410,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45347
45410
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
45348
45411
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
45349
45412
|
if (providerDir) {
|
|
45350
|
-
const fullDir =
|
|
45351
|
-
resolved._resolvedScriptsPath =
|
|
45413
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
45414
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45352
45415
|
}
|
|
45353
45416
|
}
|
|
45354
45417
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -45365,8 +45428,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45365
45428
|
resolved._resolvedScriptDir = dirOverride;
|
|
45366
45429
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
45367
45430
|
if (providerDir) {
|
|
45368
|
-
const fullDir =
|
|
45369
|
-
resolved._resolvedScriptsPath =
|
|
45431
|
+
const fullDir = path14.join(providerDir, dirOverride);
|
|
45432
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45370
45433
|
}
|
|
45371
45434
|
}
|
|
45372
45435
|
} else if (override.scripts) {
|
|
@@ -45382,8 +45445,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45382
45445
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
45383
45446
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
45384
45447
|
if (providerDir) {
|
|
45385
|
-
const fullDir =
|
|
45386
|
-
resolved._resolvedScriptsPath =
|
|
45448
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
45449
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
45387
45450
|
}
|
|
45388
45451
|
}
|
|
45389
45452
|
}
|
|
@@ -45415,15 +45478,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45415
45478
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
45416
45479
|
return null;
|
|
45417
45480
|
}
|
|
45418
|
-
const dir =
|
|
45419
|
-
if (!
|
|
45481
|
+
const dir = path14.join(providerDir, scriptDir);
|
|
45482
|
+
if (!fs7.existsSync(dir)) {
|
|
45420
45483
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
45421
45484
|
return null;
|
|
45422
45485
|
}
|
|
45423
45486
|
const cached2 = this.scriptsCache.get(dir);
|
|
45424
45487
|
if (cached2) return cached2;
|
|
45425
|
-
const scriptsJs =
|
|
45426
|
-
if (
|
|
45488
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
45489
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
45427
45490
|
try {
|
|
45428
45491
|
delete require.cache[require.resolve(scriptsJs)];
|
|
45429
45492
|
const loaded = require(scriptsJs);
|
|
@@ -45444,9 +45507,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45444
45507
|
watch() {
|
|
45445
45508
|
this.stopWatch();
|
|
45446
45509
|
const watchDir = (dir) => {
|
|
45447
|
-
if (!
|
|
45510
|
+
if (!fs7.existsSync(dir)) {
|
|
45448
45511
|
try {
|
|
45449
|
-
|
|
45512
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
45450
45513
|
} catch {
|
|
45451
45514
|
return;
|
|
45452
45515
|
}
|
|
@@ -45464,7 +45527,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45464
45527
|
return;
|
|
45465
45528
|
}
|
|
45466
45529
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
45467
|
-
this.log(`File changed: ${
|
|
45530
|
+
this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
|
|
45468
45531
|
this.reload();
|
|
45469
45532
|
}
|
|
45470
45533
|
};
|
|
@@ -45519,12 +45582,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45519
45582
|
}
|
|
45520
45583
|
const https = require("https");
|
|
45521
45584
|
const { execSync: execSync7 } = require("child_process");
|
|
45522
|
-
const metaPath =
|
|
45585
|
+
const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
45523
45586
|
let prevEtag = "";
|
|
45524
45587
|
let prevTimestamp = 0;
|
|
45525
45588
|
try {
|
|
45526
|
-
if (
|
|
45527
|
-
const meta3 = JSON.parse(
|
|
45589
|
+
if (fs7.existsSync(metaPath)) {
|
|
45590
|
+
const meta3 = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
|
|
45528
45591
|
prevEtag = meta3.etag || "";
|
|
45529
45592
|
prevTimestamp = meta3.timestamp || 0;
|
|
45530
45593
|
}
|
|
@@ -45579,39 +45642,39 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45579
45642
|
return { updated: false };
|
|
45580
45643
|
}
|
|
45581
45644
|
this.log("Downloading latest providers from GitHub...");
|
|
45582
|
-
const tmpTar =
|
|
45583
|
-
const tmpExtract =
|
|
45645
|
+
const tmpTar = path14.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
45646
|
+
const tmpExtract = path14.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
45584
45647
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
45585
|
-
|
|
45648
|
+
fs7.mkdirSync(tmpExtract, { recursive: true });
|
|
45586
45649
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
45587
|
-
const extracted =
|
|
45650
|
+
const extracted = fs7.readdirSync(tmpExtract);
|
|
45588
45651
|
const rootDir = extracted.find(
|
|
45589
|
-
(d) =>
|
|
45652
|
+
(d) => fs7.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
45590
45653
|
);
|
|
45591
45654
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
45592
|
-
const sourceDir =
|
|
45655
|
+
const sourceDir = path14.join(tmpExtract, rootDir);
|
|
45593
45656
|
const backupDir = this.upstreamDir + ".bak";
|
|
45594
|
-
if (
|
|
45595
|
-
if (
|
|
45596
|
-
|
|
45657
|
+
if (fs7.existsSync(this.upstreamDir)) {
|
|
45658
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
45659
|
+
fs7.renameSync(this.upstreamDir, backupDir);
|
|
45597
45660
|
}
|
|
45598
45661
|
try {
|
|
45599
45662
|
this.copyDirRecursive(sourceDir, this.upstreamDir);
|
|
45600
45663
|
this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
|
|
45601
|
-
if (
|
|
45664
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
45602
45665
|
} catch (e) {
|
|
45603
|
-
if (
|
|
45604
|
-
if (
|
|
45605
|
-
|
|
45666
|
+
if (fs7.existsSync(backupDir)) {
|
|
45667
|
+
if (fs7.existsSync(this.upstreamDir)) fs7.rmSync(this.upstreamDir, { recursive: true, force: true });
|
|
45668
|
+
fs7.renameSync(backupDir, this.upstreamDir);
|
|
45606
45669
|
}
|
|
45607
45670
|
throw e;
|
|
45608
45671
|
}
|
|
45609
45672
|
try {
|
|
45610
|
-
|
|
45673
|
+
fs7.rmSync(tmpTar, { force: true });
|
|
45611
45674
|
} catch {
|
|
45612
45675
|
}
|
|
45613
45676
|
try {
|
|
45614
|
-
|
|
45677
|
+
fs7.rmSync(tmpExtract, { recursive: true, force: true });
|
|
45615
45678
|
} catch {
|
|
45616
45679
|
}
|
|
45617
45680
|
const upstreamCount = this.countProviders(this.upstreamDir);
|
|
@@ -45643,7 +45706,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45643
45706
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
45644
45707
|
return;
|
|
45645
45708
|
}
|
|
45646
|
-
const ws2 =
|
|
45709
|
+
const ws2 = fs7.createWriteStream(destPath);
|
|
45647
45710
|
res.pipe(ws2);
|
|
45648
45711
|
ws2.on("finish", () => {
|
|
45649
45712
|
ws2.close();
|
|
@@ -45662,22 +45725,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45662
45725
|
}
|
|
45663
45726
|
/** Recursive directory copy */
|
|
45664
45727
|
copyDirRecursive(src, dest) {
|
|
45665
|
-
|
|
45666
|
-
for (const entry of
|
|
45667
|
-
const srcPath =
|
|
45668
|
-
const destPath =
|
|
45728
|
+
fs7.mkdirSync(dest, { recursive: true });
|
|
45729
|
+
for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
|
|
45730
|
+
const srcPath = path14.join(src, entry.name);
|
|
45731
|
+
const destPath = path14.join(dest, entry.name);
|
|
45669
45732
|
if (entry.isDirectory()) {
|
|
45670
45733
|
this.copyDirRecursive(srcPath, destPath);
|
|
45671
45734
|
} else {
|
|
45672
|
-
|
|
45735
|
+
fs7.copyFileSync(srcPath, destPath);
|
|
45673
45736
|
}
|
|
45674
45737
|
}
|
|
45675
45738
|
}
|
|
45676
45739
|
/** .meta.json save */
|
|
45677
45740
|
writeMeta(metaPath, etag, timestamp) {
|
|
45678
45741
|
try {
|
|
45679
|
-
|
|
45680
|
-
|
|
45742
|
+
fs7.mkdirSync(path14.dirname(metaPath), { recursive: true });
|
|
45743
|
+
fs7.writeFileSync(metaPath, JSON.stringify({
|
|
45681
45744
|
etag,
|
|
45682
45745
|
timestamp,
|
|
45683
45746
|
lastCheck: new Date(timestamp).toISOString(),
|
|
@@ -45688,12 +45751,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45688
45751
|
}
|
|
45689
45752
|
/** Count provider files (provider.js or provider.json) */
|
|
45690
45753
|
countProviders(dir) {
|
|
45691
|
-
if (!
|
|
45754
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
45692
45755
|
let count = 0;
|
|
45693
45756
|
const scan = (d) => {
|
|
45694
45757
|
try {
|
|
45695
|
-
for (const entry of
|
|
45696
|
-
if (entry.isDirectory()) scan(
|
|
45758
|
+
for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
|
|
45759
|
+
if (entry.isDirectory()) scan(path14.join(d, entry.name));
|
|
45697
45760
|
else if (entry.name === "provider.json") count++;
|
|
45698
45761
|
}
|
|
45699
45762
|
} catch {
|
|
@@ -45919,19 +45982,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45919
45982
|
const cat = provider.category;
|
|
45920
45983
|
const searchRoots = this.getProviderRoots();
|
|
45921
45984
|
for (const root of searchRoots) {
|
|
45922
|
-
if (!
|
|
45985
|
+
if (!fs7.existsSync(root)) continue;
|
|
45923
45986
|
const candidate = this.getProviderDir(root, cat, type);
|
|
45924
|
-
if (
|
|
45925
|
-
const catDir =
|
|
45926
|
-
if (
|
|
45987
|
+
if (fs7.existsSync(path14.join(candidate, "provider.json"))) return candidate;
|
|
45988
|
+
const catDir = path14.join(root, cat);
|
|
45989
|
+
if (fs7.existsSync(catDir)) {
|
|
45927
45990
|
try {
|
|
45928
|
-
for (const entry of
|
|
45991
|
+
for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
|
|
45929
45992
|
if (!entry.isDirectory()) continue;
|
|
45930
|
-
const jsonPath =
|
|
45931
|
-
if (
|
|
45993
|
+
const jsonPath = path14.join(catDir, entry.name, "provider.json");
|
|
45994
|
+
if (fs7.existsSync(jsonPath)) {
|
|
45932
45995
|
try {
|
|
45933
|
-
const data = JSON.parse(
|
|
45934
|
-
if (data.type === type) return
|
|
45996
|
+
const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
|
|
45997
|
+
if (data.type === type) return path14.join(catDir, entry.name);
|
|
45935
45998
|
} catch {
|
|
45936
45999
|
}
|
|
45937
46000
|
}
|
|
@@ -45948,8 +46011,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45948
46011
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
45949
46012
|
*/
|
|
45950
46013
|
buildScriptWrappersFromDir(dir) {
|
|
45951
|
-
const scriptsJs =
|
|
45952
|
-
if (
|
|
46014
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
46015
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
45953
46016
|
try {
|
|
45954
46017
|
delete require.cache[require.resolve(scriptsJs)];
|
|
45955
46018
|
return require(scriptsJs);
|
|
@@ -45959,13 +46022,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45959
46022
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
45960
46023
|
const result = {};
|
|
45961
46024
|
try {
|
|
45962
|
-
for (const file2 of
|
|
46025
|
+
for (const file2 of fs7.readdirSync(dir)) {
|
|
45963
46026
|
if (!file2.endsWith(".js")) continue;
|
|
45964
46027
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
45965
|
-
const filePath =
|
|
46028
|
+
const filePath = path14.join(dir, file2);
|
|
45966
46029
|
result[scriptName] = (...args) => {
|
|
45967
46030
|
try {
|
|
45968
|
-
let content =
|
|
46031
|
+
let content = fs7.readFileSync(filePath, "utf-8");
|
|
45969
46032
|
if (args[0] && typeof args[0] === "object") {
|
|
45970
46033
|
for (const [key, val] of Object.entries(args[0])) {
|
|
45971
46034
|
let v2 = val;
|
|
@@ -46011,20 +46074,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46011
46074
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
46012
46075
|
*/
|
|
46013
46076
|
loadDir(dir, excludeDirs) {
|
|
46014
|
-
if (!
|
|
46077
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
46015
46078
|
let count = 0;
|
|
46016
46079
|
const scan = (d) => {
|
|
46017
46080
|
let entries;
|
|
46018
46081
|
try {
|
|
46019
|
-
entries =
|
|
46082
|
+
entries = fs7.readdirSync(d, { withFileTypes: true });
|
|
46020
46083
|
} catch {
|
|
46021
46084
|
return;
|
|
46022
46085
|
}
|
|
46023
46086
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
46024
46087
|
if (hasJson) {
|
|
46025
|
-
const jsonPath =
|
|
46088
|
+
const jsonPath = path14.join(d, "provider.json");
|
|
46026
46089
|
try {
|
|
46027
|
-
const raw =
|
|
46090
|
+
const raw = fs7.readFileSync(jsonPath, "utf-8");
|
|
46028
46091
|
const mod = JSON.parse(raw);
|
|
46029
46092
|
if (typeof mod.extensionIdPattern === "string") {
|
|
46030
46093
|
const flags = mod.extensionIdPattern_flags || "";
|
|
@@ -46043,8 +46106,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46043
46106
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
46044
46107
|
} else {
|
|
46045
46108
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
46046
|
-
const scriptsPath =
|
|
46047
|
-
if (!hasCompatibility &&
|
|
46109
|
+
const scriptsPath = path14.join(d, "scripts.js");
|
|
46110
|
+
if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
|
|
46048
46111
|
try {
|
|
46049
46112
|
delete require.cache[require.resolve(scriptsPath)];
|
|
46050
46113
|
const scripts = require(scriptsPath);
|
|
@@ -46069,7 +46132,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46069
46132
|
if (!entry.isDirectory()) continue;
|
|
46070
46133
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
46071
46134
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
46072
|
-
scan(
|
|
46135
|
+
scan(path14.join(d, entry.name));
|
|
46073
46136
|
}
|
|
46074
46137
|
}
|
|
46075
46138
|
};
|
|
@@ -46255,7 +46318,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46255
46318
|
});
|
|
46256
46319
|
}
|
|
46257
46320
|
async function killIdeProcess(ideId) {
|
|
46258
|
-
const plat =
|
|
46321
|
+
const plat = os15.platform();
|
|
46259
46322
|
const appName = getMacAppIdentifiers()[ideId];
|
|
46260
46323
|
const winProcesses = getWinProcessNames()[ideId];
|
|
46261
46324
|
try {
|
|
@@ -46316,7 +46379,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46316
46379
|
}
|
|
46317
46380
|
}
|
|
46318
46381
|
function isIdeRunning(ideId) {
|
|
46319
|
-
const plat =
|
|
46382
|
+
const plat = os15.platform();
|
|
46320
46383
|
try {
|
|
46321
46384
|
if (plat === "darwin") {
|
|
46322
46385
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -46371,7 +46434,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46371
46434
|
}
|
|
46372
46435
|
}
|
|
46373
46436
|
function detectCurrentWorkspace(ideId) {
|
|
46374
|
-
const plat =
|
|
46437
|
+
const plat = os15.platform();
|
|
46375
46438
|
if (plat === "darwin") {
|
|
46376
46439
|
try {
|
|
46377
46440
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -46386,17 +46449,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46386
46449
|
}
|
|
46387
46450
|
} else if (plat === "win32") {
|
|
46388
46451
|
try {
|
|
46389
|
-
const
|
|
46452
|
+
const fs16 = require("fs");
|
|
46390
46453
|
const appNameMap = getMacAppIdentifiers();
|
|
46391
46454
|
const appName = appNameMap[ideId];
|
|
46392
46455
|
if (appName) {
|
|
46393
|
-
const storagePath =
|
|
46394
|
-
process.env.APPDATA ||
|
|
46456
|
+
const storagePath = path15.join(
|
|
46457
|
+
process.env.APPDATA || path15.join(os15.homedir(), "AppData", "Roaming"),
|
|
46395
46458
|
appName,
|
|
46396
46459
|
"storage.json"
|
|
46397
46460
|
);
|
|
46398
|
-
if (
|
|
46399
|
-
const data = JSON.parse(
|
|
46461
|
+
if (fs16.existsSync(storagePath)) {
|
|
46462
|
+
const data = JSON.parse(fs16.readFileSync(storagePath, "utf-8"));
|
|
46400
46463
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
46401
46464
|
if (workspaces.length > 0) {
|
|
46402
46465
|
const recent = workspaces[0];
|
|
@@ -46413,7 +46476,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46413
46476
|
return void 0;
|
|
46414
46477
|
}
|
|
46415
46478
|
async function launchWithCdp(options = {}) {
|
|
46416
|
-
const platform10 =
|
|
46479
|
+
const platform10 = os15.platform();
|
|
46417
46480
|
let targetIde;
|
|
46418
46481
|
const ides = await detectIDEs(getProviderLoader());
|
|
46419
46482
|
if (options.ideId) {
|
|
@@ -46564,14 +46627,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46564
46627
|
}
|
|
46565
46628
|
init_config();
|
|
46566
46629
|
init_logger();
|
|
46567
|
-
var
|
|
46568
|
-
var
|
|
46569
|
-
var
|
|
46570
|
-
var LOG_DIR2 = process.platform === "win32" ?
|
|
46630
|
+
var fs8 = __toESM2(require("fs"));
|
|
46631
|
+
var path16 = __toESM2(require("path"));
|
|
46632
|
+
var os16 = __toESM2(require("os"));
|
|
46633
|
+
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");
|
|
46571
46634
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
46572
46635
|
var MAX_DAYS = 7;
|
|
46573
46636
|
try {
|
|
46574
|
-
|
|
46637
|
+
fs8.mkdirSync(LOG_DIR2, { recursive: true });
|
|
46575
46638
|
} catch {
|
|
46576
46639
|
}
|
|
46577
46640
|
var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -46605,19 +46668,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46605
46668
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
46606
46669
|
}
|
|
46607
46670
|
var currentDate2 = getDateStr2();
|
|
46608
|
-
var currentFile =
|
|
46671
|
+
var currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
46609
46672
|
var writeCount2 = 0;
|
|
46610
46673
|
function checkRotation() {
|
|
46611
46674
|
const today = getDateStr2();
|
|
46612
46675
|
if (today !== currentDate2) {
|
|
46613
46676
|
currentDate2 = today;
|
|
46614
|
-
currentFile =
|
|
46677
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
46615
46678
|
cleanOldFiles();
|
|
46616
46679
|
}
|
|
46617
46680
|
}
|
|
46618
46681
|
function cleanOldFiles() {
|
|
46619
46682
|
try {
|
|
46620
|
-
const files =
|
|
46683
|
+
const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
46621
46684
|
const cutoff = /* @__PURE__ */ new Date();
|
|
46622
46685
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
46623
46686
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -46625,7 +46688,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46625
46688
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
46626
46689
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
46627
46690
|
try {
|
|
46628
|
-
|
|
46691
|
+
fs8.unlinkSync(path16.join(LOG_DIR2, file2));
|
|
46629
46692
|
} catch {
|
|
46630
46693
|
}
|
|
46631
46694
|
}
|
|
@@ -46635,14 +46698,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46635
46698
|
}
|
|
46636
46699
|
function checkSize() {
|
|
46637
46700
|
try {
|
|
46638
|
-
const stat4 =
|
|
46701
|
+
const stat4 = fs8.statSync(currentFile);
|
|
46639
46702
|
if (stat4.size > MAX_FILE_SIZE) {
|
|
46640
46703
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
46641
46704
|
try {
|
|
46642
|
-
|
|
46705
|
+
fs8.unlinkSync(backup);
|
|
46643
46706
|
} catch {
|
|
46644
46707
|
}
|
|
46645
|
-
|
|
46708
|
+
fs8.renameSync(currentFile, backup);
|
|
46646
46709
|
}
|
|
46647
46710
|
} catch {
|
|
46648
46711
|
}
|
|
@@ -46675,14 +46738,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46675
46738
|
...entry.error ? { err: entry.error } : {},
|
|
46676
46739
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
46677
46740
|
});
|
|
46678
|
-
|
|
46741
|
+
fs8.appendFileSync(currentFile, line + "\n");
|
|
46679
46742
|
} catch {
|
|
46680
46743
|
}
|
|
46681
46744
|
}
|
|
46682
46745
|
function getRecentCommands(count = 50) {
|
|
46683
46746
|
try {
|
|
46684
|
-
if (!
|
|
46685
|
-
const content =
|
|
46747
|
+
if (!fs8.existsSync(currentFile)) return [];
|
|
46748
|
+
const content = fs8.readFileSync(currentFile, "utf-8");
|
|
46686
46749
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
46687
46750
|
return lines.slice(-count).map((line) => {
|
|
46688
46751
|
try {
|
|
@@ -46707,7 +46770,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46707
46770
|
}
|
|
46708
46771
|
cleanOldFiles();
|
|
46709
46772
|
init_logger();
|
|
46710
|
-
var
|
|
46773
|
+
var os17 = __toESM2(require("os"));
|
|
46711
46774
|
init_config();
|
|
46712
46775
|
init_terminal_screen();
|
|
46713
46776
|
init_logger();
|
|
@@ -46762,8 +46825,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46762
46825
|
}
|
|
46763
46826
|
function buildMachineInfo2(profile = "full") {
|
|
46764
46827
|
const base = {
|
|
46765
|
-
hostname:
|
|
46766
|
-
platform:
|
|
46828
|
+
hostname: os17.hostname(),
|
|
46829
|
+
platform: os17.platform()
|
|
46767
46830
|
};
|
|
46768
46831
|
if (profile === "live") {
|
|
46769
46832
|
return base;
|
|
@@ -46772,23 +46835,23 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46772
46835
|
const memSnap2 = getHostMemorySnapshot();
|
|
46773
46836
|
return {
|
|
46774
46837
|
...base,
|
|
46775
|
-
arch:
|
|
46776
|
-
cpus:
|
|
46838
|
+
arch: os17.arch(),
|
|
46839
|
+
cpus: os17.cpus().length,
|
|
46777
46840
|
totalMem: memSnap2.totalMem,
|
|
46778
|
-
release:
|
|
46841
|
+
release: os17.release()
|
|
46779
46842
|
};
|
|
46780
46843
|
}
|
|
46781
46844
|
const memSnap = getHostMemorySnapshot();
|
|
46782
46845
|
return {
|
|
46783
46846
|
...base,
|
|
46784
|
-
arch:
|
|
46785
|
-
cpus:
|
|
46847
|
+
arch: os17.arch(),
|
|
46848
|
+
cpus: os17.cpus().length,
|
|
46786
46849
|
totalMem: memSnap.totalMem,
|
|
46787
46850
|
freeMem: memSnap.freeMem,
|
|
46788
46851
|
availableMem: memSnap.availableMem,
|
|
46789
|
-
loadavg:
|
|
46790
|
-
uptime:
|
|
46791
|
-
release:
|
|
46852
|
+
loadavg: os17.loadavg(),
|
|
46853
|
+
uptime: os17.uptime(),
|
|
46854
|
+
release: os17.release()
|
|
46792
46855
|
};
|
|
46793
46856
|
}
|
|
46794
46857
|
function parseMessageTime(value) {
|
|
@@ -47013,42 +47076,42 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47013
47076
|
}
|
|
47014
47077
|
var import_child_process8 = require("child_process");
|
|
47015
47078
|
var import_child_process9 = require("child_process");
|
|
47016
|
-
var
|
|
47017
|
-
var
|
|
47018
|
-
var
|
|
47079
|
+
var fs9 = __toESM2(require("fs"));
|
|
47080
|
+
var os18 = __toESM2(require("os"));
|
|
47081
|
+
var path17 = __toESM2(require("path"));
|
|
47019
47082
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
47020
47083
|
function getUpgradeLogPath() {
|
|
47021
|
-
const home =
|
|
47022
|
-
const dir =
|
|
47023
|
-
|
|
47024
|
-
return
|
|
47084
|
+
const home = os18.homedir();
|
|
47085
|
+
const dir = path17.join(home, ".adhdev");
|
|
47086
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
47087
|
+
return path17.join(dir, "daemon-upgrade.log");
|
|
47025
47088
|
}
|
|
47026
47089
|
function appendUpgradeLog(message) {
|
|
47027
47090
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
47028
47091
|
`;
|
|
47029
47092
|
try {
|
|
47030
|
-
|
|
47093
|
+
fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
47031
47094
|
} catch {
|
|
47032
47095
|
}
|
|
47033
47096
|
}
|
|
47034
47097
|
function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
|
|
47035
|
-
const binDir =
|
|
47098
|
+
const binDir = path17.dirname(nodeExecutable);
|
|
47036
47099
|
if (platform10 === "win32") {
|
|
47037
|
-
const npmCliPath =
|
|
47038
|
-
if (
|
|
47100
|
+
const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
47101
|
+
if (fs9.existsSync(npmCliPath)) {
|
|
47039
47102
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
47040
47103
|
}
|
|
47041
47104
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
47042
|
-
const candidatePath =
|
|
47043
|
-
if (
|
|
47105
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
47106
|
+
if (fs9.existsSync(candidatePath)) {
|
|
47044
47107
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
47045
47108
|
}
|
|
47046
47109
|
}
|
|
47047
47110
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
47048
47111
|
}
|
|
47049
47112
|
for (const candidate of ["npm"]) {
|
|
47050
|
-
const candidatePath =
|
|
47051
|
-
if (
|
|
47113
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
47114
|
+
if (fs9.existsSync(candidatePath)) {
|
|
47052
47115
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
47053
47116
|
}
|
|
47054
47117
|
}
|
|
@@ -47058,22 +47121,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47058
47121
|
if (!currentCliPath) return null;
|
|
47059
47122
|
let resolvedPath = currentCliPath;
|
|
47060
47123
|
try {
|
|
47061
|
-
resolvedPath =
|
|
47124
|
+
resolvedPath = fs9.realpathSync.native(currentCliPath);
|
|
47062
47125
|
} catch {
|
|
47063
47126
|
}
|
|
47064
47127
|
let currentDir = resolvedPath;
|
|
47065
47128
|
try {
|
|
47066
|
-
if (
|
|
47067
|
-
currentDir =
|
|
47129
|
+
if (fs9.statSync(resolvedPath).isFile()) {
|
|
47130
|
+
currentDir = path17.dirname(resolvedPath);
|
|
47068
47131
|
}
|
|
47069
47132
|
} catch {
|
|
47070
|
-
currentDir =
|
|
47133
|
+
currentDir = path17.dirname(resolvedPath);
|
|
47071
47134
|
}
|
|
47072
47135
|
while (true) {
|
|
47073
|
-
const packageJsonPath =
|
|
47136
|
+
const packageJsonPath = path17.join(currentDir, "package.json");
|
|
47074
47137
|
try {
|
|
47075
|
-
if (
|
|
47076
|
-
const parsed = JSON.parse(
|
|
47138
|
+
if (fs9.existsSync(packageJsonPath)) {
|
|
47139
|
+
const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
|
|
47077
47140
|
if (parsed?.name === packageName) {
|
|
47078
47141
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
47079
47142
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -47081,7 +47144,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47081
47144
|
}
|
|
47082
47145
|
} catch {
|
|
47083
47146
|
}
|
|
47084
|
-
const parentDir =
|
|
47147
|
+
const parentDir = path17.dirname(currentDir);
|
|
47085
47148
|
if (parentDir === currentDir) {
|
|
47086
47149
|
return null;
|
|
47087
47150
|
}
|
|
@@ -47089,13 +47152,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47089
47152
|
}
|
|
47090
47153
|
}
|
|
47091
47154
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
47092
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
47093
|
-
if (
|
|
47155
|
+
const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
|
|
47156
|
+
if (path17.basename(nodeModulesDir) !== "node_modules") {
|
|
47094
47157
|
return null;
|
|
47095
47158
|
}
|
|
47096
|
-
const maybeLibDir =
|
|
47097
|
-
if (
|
|
47098
|
-
return
|
|
47159
|
+
const maybeLibDir = path17.dirname(nodeModulesDir);
|
|
47160
|
+
if (path17.basename(maybeLibDir) === "lib") {
|
|
47161
|
+
return path17.dirname(maybeLibDir);
|
|
47099
47162
|
}
|
|
47100
47163
|
return maybeLibDir;
|
|
47101
47164
|
}
|
|
@@ -47210,10 +47273,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47210
47273
|
}
|
|
47211
47274
|
}
|
|
47212
47275
|
function stopSessionHostProcesses(appName) {
|
|
47213
|
-
const pidFile =
|
|
47276
|
+
const pidFile = path17.join(os18.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
47214
47277
|
try {
|
|
47215
|
-
if (
|
|
47216
|
-
const pid = Number.parseInt(
|
|
47278
|
+
if (fs9.existsSync(pidFile)) {
|
|
47279
|
+
const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
|
|
47217
47280
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
47218
47281
|
killPid2(pid);
|
|
47219
47282
|
}
|
|
@@ -47221,15 +47284,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47221
47284
|
} catch {
|
|
47222
47285
|
} finally {
|
|
47223
47286
|
try {
|
|
47224
|
-
|
|
47287
|
+
fs9.unlinkSync(pidFile);
|
|
47225
47288
|
} catch {
|
|
47226
47289
|
}
|
|
47227
47290
|
}
|
|
47228
47291
|
}
|
|
47229
47292
|
function removeDaemonPidFile() {
|
|
47230
|
-
const pidFile =
|
|
47293
|
+
const pidFile = path17.join(os18.homedir(), ".adhdev", "daemon.pid");
|
|
47231
47294
|
try {
|
|
47232
|
-
|
|
47295
|
+
fs9.unlinkSync(pidFile);
|
|
47233
47296
|
} catch {
|
|
47234
47297
|
}
|
|
47235
47298
|
}
|
|
@@ -47238,7 +47301,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47238
47301
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
47239
47302
|
if (!npmRoot) return;
|
|
47240
47303
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
47241
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
47304
|
+
const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
|
|
47242
47305
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
47243
47306
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
47244
47307
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -47246,25 +47309,25 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47246
47309
|
}
|
|
47247
47310
|
if (pkgName.startsWith("@")) {
|
|
47248
47311
|
const [scope, name] = pkgName.split("/");
|
|
47249
|
-
const scopeDir =
|
|
47250
|
-
if (!
|
|
47251
|
-
for (const entry of
|
|
47312
|
+
const scopeDir = path17.join(npmRoot, scope);
|
|
47313
|
+
if (!fs9.existsSync(scopeDir)) return;
|
|
47314
|
+
for (const entry of fs9.readdirSync(scopeDir)) {
|
|
47252
47315
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
47253
|
-
|
|
47254
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
47316
|
+
fs9.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
|
|
47317
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
|
|
47255
47318
|
}
|
|
47256
47319
|
} else {
|
|
47257
|
-
for (const entry of
|
|
47320
|
+
for (const entry of fs9.readdirSync(npmRoot)) {
|
|
47258
47321
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
47259
|
-
|
|
47260
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
47322
|
+
fs9.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
|
|
47323
|
+
appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
|
|
47261
47324
|
}
|
|
47262
47325
|
}
|
|
47263
|
-
if (
|
|
47264
|
-
for (const entry of
|
|
47326
|
+
if (fs9.existsSync(binDir)) {
|
|
47327
|
+
for (const entry of fs9.readdirSync(binDir)) {
|
|
47265
47328
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
47266
|
-
|
|
47267
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
47329
|
+
fs9.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
|
|
47330
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
|
|
47268
47331
|
}
|
|
47269
47332
|
}
|
|
47270
47333
|
}
|
|
@@ -47347,7 +47410,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47347
47410
|
process.exit(1);
|
|
47348
47411
|
}
|
|
47349
47412
|
}
|
|
47350
|
-
var
|
|
47413
|
+
var fs10 = __toESM2(require("fs"));
|
|
47351
47414
|
var CHAT_COMMANDS = [
|
|
47352
47415
|
"send_chat",
|
|
47353
47416
|
"new_chat",
|
|
@@ -47583,8 +47646,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47583
47646
|
if (sinceTs > 0) {
|
|
47584
47647
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
47585
47648
|
}
|
|
47586
|
-
if (
|
|
47587
|
-
const content =
|
|
47649
|
+
if (fs10.existsSync(LOG_PATH)) {
|
|
47650
|
+
const content = fs10.readFileSync(LOG_PATH, "utf-8");
|
|
47588
47651
|
const allLines = content.split("\n");
|
|
47589
47652
|
const recent = allLines.slice(-count).join("\n");
|
|
47590
47653
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -49715,12 +49778,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49715
49778
|
};
|
|
49716
49779
|
init_io_contracts();
|
|
49717
49780
|
init_chat_message_normalization();
|
|
49718
|
-
var
|
|
49719
|
-
var
|
|
49720
|
-
var
|
|
49781
|
+
var fs11 = __toESM2(require("fs"));
|
|
49782
|
+
var path18 = __toESM2(require("path"));
|
|
49783
|
+
var os19 = __toESM2(require("os"));
|
|
49721
49784
|
var import_child_process10 = require("child_process");
|
|
49722
49785
|
var import_os3 = require("os");
|
|
49723
|
-
var ARCHIVE_PATH =
|
|
49786
|
+
var ARCHIVE_PATH = path18.join(os19.homedir(), ".adhdev", "version-history.json");
|
|
49724
49787
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
49725
49788
|
var VersionArchive = class {
|
|
49726
49789
|
history = {};
|
|
@@ -49729,8 +49792,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49729
49792
|
}
|
|
49730
49793
|
load() {
|
|
49731
49794
|
try {
|
|
49732
|
-
if (
|
|
49733
|
-
this.history = JSON.parse(
|
|
49795
|
+
if (fs11.existsSync(ARCHIVE_PATH)) {
|
|
49796
|
+
this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
49734
49797
|
}
|
|
49735
49798
|
} catch {
|
|
49736
49799
|
this.history = {};
|
|
@@ -49767,8 +49830,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49767
49830
|
}
|
|
49768
49831
|
save() {
|
|
49769
49832
|
try {
|
|
49770
|
-
|
|
49771
|
-
|
|
49833
|
+
fs11.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
|
|
49834
|
+
fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
49772
49835
|
} catch {
|
|
49773
49836
|
}
|
|
49774
49837
|
}
|
|
@@ -49823,19 +49886,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49823
49886
|
function checkPathExists2(paths) {
|
|
49824
49887
|
for (const p of paths) {
|
|
49825
49888
|
if (p.includes("*")) {
|
|
49826
|
-
const home =
|
|
49827
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
49828
|
-
if (
|
|
49889
|
+
const home = os19.homedir();
|
|
49890
|
+
const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
|
|
49891
|
+
if (fs11.existsSync(resolved)) return resolved;
|
|
49829
49892
|
} else {
|
|
49830
|
-
if (
|
|
49893
|
+
if (fs11.existsSync(p)) return p;
|
|
49831
49894
|
}
|
|
49832
49895
|
}
|
|
49833
49896
|
return null;
|
|
49834
49897
|
}
|
|
49835
49898
|
function getMacAppVersion(appPath) {
|
|
49836
49899
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
49837
|
-
const plistPath =
|
|
49838
|
-
if (!
|
|
49900
|
+
const plistPath = path18.join(appPath, "Contents", "Info.plist");
|
|
49901
|
+
if (!fs11.existsSync(plistPath)) return null;
|
|
49839
49902
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
49840
49903
|
return raw || null;
|
|
49841
49904
|
}
|
|
@@ -49860,8 +49923,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49860
49923
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
49861
49924
|
let resolvedBin = cliBin;
|
|
49862
49925
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
49863
|
-
const bundled =
|
|
49864
|
-
if (provider.cli &&
|
|
49926
|
+
const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
49927
|
+
if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
|
|
49865
49928
|
}
|
|
49866
49929
|
info.installed = !!(appPath || resolvedBin);
|
|
49867
49930
|
info.path = appPath || null;
|
|
@@ -49898,8 +49961,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49898
49961
|
return results;
|
|
49899
49962
|
}
|
|
49900
49963
|
var http2 = __toESM2(require("http"));
|
|
49901
|
-
var
|
|
49902
|
-
var
|
|
49964
|
+
var fs15 = __toESM2(require("fs"));
|
|
49965
|
+
var path222 = __toESM2(require("path"));
|
|
49903
49966
|
init_config();
|
|
49904
49967
|
function generateFiles(type, name, category, opts = {}) {
|
|
49905
49968
|
const { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2 = "0.1" } = opts;
|
|
@@ -50243,8 +50306,8 @@ async (params) => {
|
|
|
50243
50306
|
};
|
|
50244
50307
|
}
|
|
50245
50308
|
init_logger();
|
|
50246
|
-
var
|
|
50247
|
-
var
|
|
50309
|
+
var fs12 = __toESM2(require("fs"));
|
|
50310
|
+
var path19 = __toESM2(require("path"));
|
|
50248
50311
|
init_logger();
|
|
50249
50312
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
50250
50313
|
const body = await ctx.readBody(req);
|
|
@@ -50423,18 +50486,18 @@ async (params) => {
|
|
|
50423
50486
|
return;
|
|
50424
50487
|
}
|
|
50425
50488
|
let scriptsPath = "";
|
|
50426
|
-
const directScripts =
|
|
50427
|
-
if (
|
|
50489
|
+
const directScripts = path19.join(dir, "scripts.js");
|
|
50490
|
+
if (fs12.existsSync(directScripts)) {
|
|
50428
50491
|
scriptsPath = directScripts;
|
|
50429
50492
|
} else {
|
|
50430
|
-
const scriptsDir =
|
|
50431
|
-
if (
|
|
50432
|
-
const versions =
|
|
50433
|
-
return
|
|
50493
|
+
const scriptsDir = path19.join(dir, "scripts");
|
|
50494
|
+
if (fs12.existsSync(scriptsDir)) {
|
|
50495
|
+
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
50496
|
+
return fs12.statSync(path19.join(scriptsDir, d)).isDirectory();
|
|
50434
50497
|
}).sort().reverse();
|
|
50435
50498
|
for (const ver of versions) {
|
|
50436
|
-
const p =
|
|
50437
|
-
if (
|
|
50499
|
+
const p = path19.join(scriptsDir, ver, "scripts.js");
|
|
50500
|
+
if (fs12.existsSync(p)) {
|
|
50438
50501
|
scriptsPath = p;
|
|
50439
50502
|
break;
|
|
50440
50503
|
}
|
|
@@ -50446,7 +50509,7 @@ async (params) => {
|
|
|
50446
50509
|
return;
|
|
50447
50510
|
}
|
|
50448
50511
|
try {
|
|
50449
|
-
const source =
|
|
50512
|
+
const source = fs12.readFileSync(scriptsPath, "utf-8");
|
|
50450
50513
|
const hints = {};
|
|
50451
50514
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
50452
50515
|
let match;
|
|
@@ -51259,8 +51322,8 @@ async (params) => {
|
|
|
51259
51322
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
51260
51323
|
}
|
|
51261
51324
|
}
|
|
51262
|
-
var
|
|
51263
|
-
var
|
|
51325
|
+
var fs13 = __toESM2(require("fs"));
|
|
51326
|
+
var path20 = __toESM2(require("path"));
|
|
51264
51327
|
function slugifyFixtureName(value) {
|
|
51265
51328
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
51266
51329
|
return normalized || `fixture-${Date.now()}`;
|
|
@@ -51270,15 +51333,15 @@ async (params) => {
|
|
|
51270
51333
|
if (!providerDir) {
|
|
51271
51334
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
51272
51335
|
}
|
|
51273
|
-
return
|
|
51336
|
+
return path20.join(providerDir, "fixtures");
|
|
51274
51337
|
}
|
|
51275
51338
|
function readCliFixture(ctx, type, name) {
|
|
51276
51339
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
51277
|
-
const filePath =
|
|
51278
|
-
if (!
|
|
51340
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
51341
|
+
if (!fs13.existsSync(filePath)) {
|
|
51279
51342
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
51280
51343
|
}
|
|
51281
|
-
return JSON.parse(
|
|
51344
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
|
|
51282
51345
|
}
|
|
51283
51346
|
function getExerciseTranscriptText(result) {
|
|
51284
51347
|
const parts = [];
|
|
@@ -52014,7 +52077,7 @@ async (params) => {
|
|
|
52014
52077
|
return;
|
|
52015
52078
|
}
|
|
52016
52079
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
52017
|
-
|
|
52080
|
+
fs13.mkdirSync(fixtureDir, { recursive: true });
|
|
52018
52081
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
52019
52082
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
52020
52083
|
const fixture = {
|
|
@@ -52041,8 +52104,8 @@ async (params) => {
|
|
|
52041
52104
|
},
|
|
52042
52105
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
52043
52106
|
};
|
|
52044
|
-
const filePath =
|
|
52045
|
-
|
|
52107
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
52108
|
+
fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
52046
52109
|
ctx.json(res, 200, {
|
|
52047
52110
|
saved: true,
|
|
52048
52111
|
name,
|
|
@@ -52060,14 +52123,14 @@ async (params) => {
|
|
|
52060
52123
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
52061
52124
|
try {
|
|
52062
52125
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
52063
|
-
if (!
|
|
52126
|
+
if (!fs13.existsSync(fixtureDir)) {
|
|
52064
52127
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
52065
52128
|
return;
|
|
52066
52129
|
}
|
|
52067
|
-
const fixtures =
|
|
52068
|
-
const fullPath =
|
|
52130
|
+
const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
52131
|
+
const fullPath = path20.join(fixtureDir, file2);
|
|
52069
52132
|
try {
|
|
52070
|
-
const raw = JSON.parse(
|
|
52133
|
+
const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
|
|
52071
52134
|
return {
|
|
52072
52135
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
52073
52136
|
path: fullPath,
|
|
@@ -52198,9 +52261,9 @@ async (params) => {
|
|
|
52198
52261
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
52199
52262
|
}
|
|
52200
52263
|
}
|
|
52201
|
-
var
|
|
52202
|
-
var
|
|
52203
|
-
var
|
|
52264
|
+
var fs14 = __toESM2(require("fs"));
|
|
52265
|
+
var path21 = __toESM2(require("path"));
|
|
52266
|
+
var os20 = __toESM2(require("os"));
|
|
52204
52267
|
function getAutoImplPid(ctx) {
|
|
52205
52268
|
const pid = ctx.autoImplProcess?.pid;
|
|
52206
52269
|
return typeof pid === "number" && pid > 0 ? pid : null;
|
|
@@ -52246,38 +52309,38 @@ async (params) => {
|
|
|
52246
52309
|
return fallback?.type || null;
|
|
52247
52310
|
}
|
|
52248
52311
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
52249
|
-
if (!
|
|
52250
|
-
const versions =
|
|
52312
|
+
if (!fs14.existsSync(scriptsDir)) return null;
|
|
52313
|
+
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
52251
52314
|
try {
|
|
52252
|
-
return
|
|
52315
|
+
return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
|
|
52253
52316
|
} catch {
|
|
52254
52317
|
return false;
|
|
52255
52318
|
}
|
|
52256
52319
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
52257
52320
|
if (versions.length === 0) return null;
|
|
52258
|
-
return
|
|
52321
|
+
return path21.join(scriptsDir, versions[0]);
|
|
52259
52322
|
}
|
|
52260
52323
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
52261
|
-
const canonicalUserDir =
|
|
52262
|
-
const desiredDir = requestedDir ?
|
|
52263
|
-
const upstreamRoot =
|
|
52264
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
52324
|
+
const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
52325
|
+
const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
|
|
52326
|
+
const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
|
|
52327
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
|
|
52265
52328
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
52266
52329
|
}
|
|
52267
|
-
if (
|
|
52330
|
+
if (path21.basename(desiredDir) !== type) {
|
|
52268
52331
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
52269
52332
|
}
|
|
52270
52333
|
const sourceDir = ctx.findProviderDir(type);
|
|
52271
52334
|
if (!sourceDir) {
|
|
52272
52335
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
52273
52336
|
}
|
|
52274
|
-
if (!
|
|
52275
|
-
|
|
52276
|
-
|
|
52337
|
+
if (!fs14.existsSync(desiredDir)) {
|
|
52338
|
+
fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
|
|
52339
|
+
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
52277
52340
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
52278
52341
|
}
|
|
52279
|
-
const providerJson =
|
|
52280
|
-
if (!
|
|
52342
|
+
const providerJson = path21.join(desiredDir, "provider.json");
|
|
52343
|
+
if (!fs14.existsSync(providerJson)) {
|
|
52281
52344
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
52282
52345
|
}
|
|
52283
52346
|
return { dir: desiredDir };
|
|
@@ -52285,15 +52348,15 @@ async (params) => {
|
|
|
52285
52348
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
52286
52349
|
if (!referenceType) return {};
|
|
52287
52350
|
const refDir = ctx.findProviderDir(referenceType);
|
|
52288
|
-
if (!refDir || !
|
|
52351
|
+
if (!refDir || !fs14.existsSync(refDir)) return {};
|
|
52289
52352
|
const referenceScripts = {};
|
|
52290
|
-
const scriptsDir =
|
|
52353
|
+
const scriptsDir = path21.join(refDir, "scripts");
|
|
52291
52354
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
52292
52355
|
if (!latestDir) return referenceScripts;
|
|
52293
|
-
for (const file2 of
|
|
52356
|
+
for (const file2 of fs14.readdirSync(latestDir)) {
|
|
52294
52357
|
if (!file2.endsWith(".js")) continue;
|
|
52295
52358
|
try {
|
|
52296
|
-
referenceScripts[file2] =
|
|
52359
|
+
referenceScripts[file2] = fs14.readFileSync(path21.join(latestDir, file2), "utf-8");
|
|
52297
52360
|
} catch {
|
|
52298
52361
|
}
|
|
52299
52362
|
}
|
|
@@ -52401,16 +52464,16 @@ async (params) => {
|
|
|
52401
52464
|
});
|
|
52402
52465
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
52403
52466
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
52404
|
-
const tmpDir =
|
|
52405
|
-
if (!
|
|
52406
|
-
const promptFile =
|
|
52407
|
-
|
|
52467
|
+
const tmpDir = path21.join(os20.tmpdir(), "adhdev-autoimpl");
|
|
52468
|
+
if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
|
|
52469
|
+
const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
52470
|
+
fs14.writeFileSync(promptFile, prompt, "utf-8");
|
|
52408
52471
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
52409
52472
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
52410
52473
|
const spawn4 = agentProvider?.spawn;
|
|
52411
52474
|
if (!spawn4?.command) {
|
|
52412
52475
|
try {
|
|
52413
|
-
|
|
52476
|
+
fs14.unlinkSync(promptFile);
|
|
52414
52477
|
} catch {
|
|
52415
52478
|
}
|
|
52416
52479
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -52512,7 +52575,7 @@ async (params) => {
|
|
|
52512
52575
|
} catch {
|
|
52513
52576
|
}
|
|
52514
52577
|
try {
|
|
52515
|
-
|
|
52578
|
+
fs14.unlinkSync(promptFile);
|
|
52516
52579
|
} catch {
|
|
52517
52580
|
}
|
|
52518
52581
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -52556,7 +52619,7 @@ async (params) => {
|
|
|
52556
52619
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
52557
52620
|
const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
52558
52621
|
let shellCmd;
|
|
52559
|
-
const isWin =
|
|
52622
|
+
const isWin = os20.platform() === "win32";
|
|
52560
52623
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
52561
52624
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
52562
52625
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -52595,7 +52658,7 @@ async (params) => {
|
|
|
52595
52658
|
try {
|
|
52596
52659
|
const pty = require("node-pty");
|
|
52597
52660
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
52598
|
-
const isWin2 =
|
|
52661
|
+
const isWin2 = os20.platform() === "win32";
|
|
52599
52662
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
52600
52663
|
name: "xterm-256color",
|
|
52601
52664
|
cols: 120,
|
|
@@ -52738,7 +52801,7 @@ async (params) => {
|
|
|
52738
52801
|
}
|
|
52739
52802
|
});
|
|
52740
52803
|
try {
|
|
52741
|
-
|
|
52804
|
+
fs14.unlinkSync(promptFile);
|
|
52742
52805
|
} catch {
|
|
52743
52806
|
}
|
|
52744
52807
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -52835,7 +52898,7 @@ async (params) => {
|
|
|
52835
52898
|
setMode: "set_mode.js"
|
|
52836
52899
|
};
|
|
52837
52900
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
52838
|
-
const scriptsDir =
|
|
52901
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
52839
52902
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
52840
52903
|
if (latestScriptsDir) {
|
|
52841
52904
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -52843,10 +52906,10 @@ async (params) => {
|
|
|
52843
52906
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
52844
52907
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
52845
52908
|
lines.push("");
|
|
52846
|
-
for (const file2 of
|
|
52909
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
52847
52910
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
52848
52911
|
try {
|
|
52849
|
-
const content =
|
|
52912
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
52850
52913
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
52851
52914
|
lines.push("```javascript");
|
|
52852
52915
|
lines.push(content);
|
|
@@ -52856,14 +52919,14 @@ async (params) => {
|
|
|
52856
52919
|
}
|
|
52857
52920
|
}
|
|
52858
52921
|
}
|
|
52859
|
-
const refFiles =
|
|
52922
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
52860
52923
|
if (refFiles.length > 0) {
|
|
52861
52924
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
52862
52925
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
52863
52926
|
lines.push("");
|
|
52864
52927
|
for (const file2 of refFiles) {
|
|
52865
52928
|
try {
|
|
52866
|
-
const content =
|
|
52929
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
52867
52930
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
52868
52931
|
lines.push("```javascript");
|
|
52869
52932
|
lines.push(content);
|
|
@@ -52904,11 +52967,11 @@ async (params) => {
|
|
|
52904
52967
|
lines.push("");
|
|
52905
52968
|
}
|
|
52906
52969
|
}
|
|
52907
|
-
const docsDir =
|
|
52970
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
52908
52971
|
const loadGuide = (name) => {
|
|
52909
52972
|
try {
|
|
52910
|
-
const p =
|
|
52911
|
-
if (
|
|
52973
|
+
const p = path21.join(docsDir, name);
|
|
52974
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
52912
52975
|
} catch {
|
|
52913
52976
|
}
|
|
52914
52977
|
return null;
|
|
@@ -53144,7 +53207,7 @@ async (params) => {
|
|
|
53144
53207
|
parseApproval: "parse_approval.js"
|
|
53145
53208
|
};
|
|
53146
53209
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
53147
|
-
const scriptsDir =
|
|
53210
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
53148
53211
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
53149
53212
|
if (latestScriptsDir) {
|
|
53150
53213
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -53152,11 +53215,11 @@ async (params) => {
|
|
|
53152
53215
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
53153
53216
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
53154
53217
|
lines.push("");
|
|
53155
|
-
for (const file2 of
|
|
53218
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
53156
53219
|
if (!file2.endsWith(".js")) continue;
|
|
53157
53220
|
if (!targetFileNames.has(file2)) continue;
|
|
53158
53221
|
try {
|
|
53159
|
-
const content =
|
|
53222
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
53160
53223
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
53161
53224
|
lines.push("```javascript");
|
|
53162
53225
|
lines.push(content);
|
|
@@ -53165,14 +53228,14 @@ async (params) => {
|
|
|
53165
53228
|
} catch {
|
|
53166
53229
|
}
|
|
53167
53230
|
}
|
|
53168
|
-
const refFiles =
|
|
53231
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
53169
53232
|
if (refFiles.length > 0) {
|
|
53170
53233
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
53171
53234
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
53172
53235
|
lines.push("");
|
|
53173
53236
|
for (const file2 of refFiles) {
|
|
53174
53237
|
try {
|
|
53175
|
-
const content =
|
|
53238
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
53176
53239
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
53177
53240
|
lines.push("```javascript");
|
|
53178
53241
|
lines.push(content);
|
|
@@ -53205,11 +53268,11 @@ async (params) => {
|
|
|
53205
53268
|
lines.push("");
|
|
53206
53269
|
}
|
|
53207
53270
|
}
|
|
53208
|
-
const docsDir =
|
|
53271
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
53209
53272
|
const loadGuide = (name) => {
|
|
53210
53273
|
try {
|
|
53211
|
-
const p =
|
|
53212
|
-
if (
|
|
53274
|
+
const p = path21.join(docsDir, name);
|
|
53275
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
53213
53276
|
} catch {
|
|
53214
53277
|
}
|
|
53215
53278
|
return null;
|
|
@@ -53653,8 +53716,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53653
53716
|
}
|
|
53654
53717
|
getEndpointList() {
|
|
53655
53718
|
return this.routes.map((r) => {
|
|
53656
|
-
const
|
|
53657
|
-
return `${r.method.padEnd(5)} ${
|
|
53719
|
+
const path232 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
53720
|
+
return `${r.method.padEnd(5)} ${path232}`;
|
|
53658
53721
|
});
|
|
53659
53722
|
}
|
|
53660
53723
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -53942,12 +54005,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53942
54005
|
// ─── DevConsole SPA ───
|
|
53943
54006
|
getConsoleDistDir() {
|
|
53944
54007
|
const candidates = [
|
|
53945
|
-
|
|
53946
|
-
|
|
53947
|
-
|
|
54008
|
+
path222.resolve(__dirname, "../../web-devconsole/dist"),
|
|
54009
|
+
path222.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
54010
|
+
path222.join(process.cwd(), "packages/web-devconsole/dist")
|
|
53948
54011
|
];
|
|
53949
54012
|
for (const dir of candidates) {
|
|
53950
|
-
if (
|
|
54013
|
+
if (fs15.existsSync(path222.join(dir, "index.html"))) return dir;
|
|
53951
54014
|
}
|
|
53952
54015
|
return null;
|
|
53953
54016
|
}
|
|
@@ -53957,9 +54020,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53957
54020
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
53958
54021
|
return;
|
|
53959
54022
|
}
|
|
53960
|
-
const htmlPath =
|
|
54023
|
+
const htmlPath = path222.join(distDir, "index.html");
|
|
53961
54024
|
try {
|
|
53962
|
-
const html =
|
|
54025
|
+
const html = fs15.readFileSync(htmlPath, "utf-8");
|
|
53963
54026
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
53964
54027
|
res.end(html);
|
|
53965
54028
|
} catch (e) {
|
|
@@ -53982,15 +54045,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53982
54045
|
this.json(res, 404, { error: "Not found" });
|
|
53983
54046
|
return;
|
|
53984
54047
|
}
|
|
53985
|
-
const safePath =
|
|
53986
|
-
const filePath =
|
|
54048
|
+
const safePath = path222.normalize(pathname).replace(/^\.\.\//, "");
|
|
54049
|
+
const filePath = path222.join(distDir, safePath);
|
|
53987
54050
|
if (!filePath.startsWith(distDir)) {
|
|
53988
54051
|
this.json(res, 403, { error: "Forbidden" });
|
|
53989
54052
|
return;
|
|
53990
54053
|
}
|
|
53991
54054
|
try {
|
|
53992
|
-
const content =
|
|
53993
|
-
const ext =
|
|
54055
|
+
const content = fs15.readFileSync(filePath);
|
|
54056
|
+
const ext = path222.extname(filePath);
|
|
53994
54057
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
53995
54058
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
53996
54059
|
res.end(content);
|
|
@@ -54098,14 +54161,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54098
54161
|
const files = [];
|
|
54099
54162
|
const scan = (d, prefix) => {
|
|
54100
54163
|
try {
|
|
54101
|
-
for (const entry of
|
|
54164
|
+
for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
|
|
54102
54165
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
54103
54166
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
54104
54167
|
if (entry.isDirectory()) {
|
|
54105
54168
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
54106
|
-
scan(
|
|
54169
|
+
scan(path222.join(d, entry.name), rel);
|
|
54107
54170
|
} else {
|
|
54108
|
-
const stat4 =
|
|
54171
|
+
const stat4 = fs15.statSync(path222.join(d, entry.name));
|
|
54109
54172
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
54110
54173
|
}
|
|
54111
54174
|
}
|
|
@@ -54128,16 +54191,16 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54128
54191
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
54129
54192
|
return;
|
|
54130
54193
|
}
|
|
54131
|
-
const fullPath =
|
|
54194
|
+
const fullPath = path222.resolve(dir, path222.normalize(filePath));
|
|
54132
54195
|
if (!fullPath.startsWith(dir)) {
|
|
54133
54196
|
this.json(res, 403, { error: "Forbidden" });
|
|
54134
54197
|
return;
|
|
54135
54198
|
}
|
|
54136
|
-
if (!
|
|
54199
|
+
if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
|
|
54137
54200
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
54138
54201
|
return;
|
|
54139
54202
|
}
|
|
54140
|
-
const content =
|
|
54203
|
+
const content = fs15.readFileSync(fullPath, "utf-8");
|
|
54141
54204
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
54142
54205
|
}
|
|
54143
54206
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -54153,15 +54216,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54153
54216
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
54154
54217
|
return;
|
|
54155
54218
|
}
|
|
54156
|
-
const fullPath =
|
|
54219
|
+
const fullPath = path222.resolve(dir, path222.normalize(filePath));
|
|
54157
54220
|
if (!fullPath.startsWith(dir)) {
|
|
54158
54221
|
this.json(res, 403, { error: "Forbidden" });
|
|
54159
54222
|
return;
|
|
54160
54223
|
}
|
|
54161
54224
|
try {
|
|
54162
|
-
if (
|
|
54163
|
-
|
|
54164
|
-
|
|
54225
|
+
if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
|
|
54226
|
+
fs15.mkdirSync(path222.dirname(fullPath), { recursive: true });
|
|
54227
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
54165
54228
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
54166
54229
|
this.providerLoader.reload();
|
|
54167
54230
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -54177,9 +54240,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54177
54240
|
return;
|
|
54178
54241
|
}
|
|
54179
54242
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
54180
|
-
const p =
|
|
54181
|
-
if (
|
|
54182
|
-
const source =
|
|
54243
|
+
const p = path222.join(dir, name);
|
|
54244
|
+
if (fs15.existsSync(p)) {
|
|
54245
|
+
const source = fs15.readFileSync(p, "utf-8");
|
|
54183
54246
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
54184
54247
|
return;
|
|
54185
54248
|
}
|
|
@@ -54198,11 +54261,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54198
54261
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
54199
54262
|
return;
|
|
54200
54263
|
}
|
|
54201
|
-
const target =
|
|
54202
|
-
const targetPath =
|
|
54264
|
+
const target = fs15.existsSync(path222.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
54265
|
+
const targetPath = path222.join(dir, target);
|
|
54203
54266
|
try {
|
|
54204
|
-
if (
|
|
54205
|
-
|
|
54267
|
+
if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
|
|
54268
|
+
fs15.writeFileSync(targetPath, source, "utf-8");
|
|
54206
54269
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
54207
54270
|
this.providerLoader.reload();
|
|
54208
54271
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -54346,21 +54409,21 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54346
54409
|
}
|
|
54347
54410
|
let targetDir;
|
|
54348
54411
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
54349
|
-
const jsonPath =
|
|
54350
|
-
if (
|
|
54412
|
+
const jsonPath = path222.join(targetDir, "provider.json");
|
|
54413
|
+
if (fs15.existsSync(jsonPath)) {
|
|
54351
54414
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
54352
54415
|
return;
|
|
54353
54416
|
}
|
|
54354
54417
|
try {
|
|
54355
54418
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
54356
|
-
|
|
54357
|
-
|
|
54419
|
+
fs15.mkdirSync(targetDir, { recursive: true });
|
|
54420
|
+
fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
54358
54421
|
const createdFiles = ["provider.json"];
|
|
54359
54422
|
if (result.files) {
|
|
54360
54423
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
54361
|
-
const fullPath =
|
|
54362
|
-
|
|
54363
|
-
|
|
54424
|
+
const fullPath = path222.join(targetDir, relPath);
|
|
54425
|
+
fs15.mkdirSync(path222.dirname(fullPath), { recursive: true });
|
|
54426
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
54364
54427
|
createdFiles.push(relPath);
|
|
54365
54428
|
}
|
|
54366
54429
|
}
|
|
@@ -54409,38 +54472,38 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54409
54472
|
}
|
|
54410
54473
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
54411
54474
|
getLatestScriptVersionDir(scriptsDir) {
|
|
54412
|
-
if (!
|
|
54413
|
-
const versions =
|
|
54475
|
+
if (!fs15.existsSync(scriptsDir)) return null;
|
|
54476
|
+
const versions = fs15.readdirSync(scriptsDir).filter((d) => {
|
|
54414
54477
|
try {
|
|
54415
|
-
return
|
|
54478
|
+
return fs15.statSync(path222.join(scriptsDir, d)).isDirectory();
|
|
54416
54479
|
} catch {
|
|
54417
54480
|
return false;
|
|
54418
54481
|
}
|
|
54419
54482
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
54420
54483
|
if (versions.length === 0) return null;
|
|
54421
|
-
return
|
|
54484
|
+
return path222.join(scriptsDir, versions[0]);
|
|
54422
54485
|
}
|
|
54423
54486
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
54424
|
-
const canonicalUserDir =
|
|
54425
|
-
const desiredDir = requestedDir ?
|
|
54426
|
-
const upstreamRoot =
|
|
54427
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
54487
|
+
const canonicalUserDir = path222.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
54488
|
+
const desiredDir = requestedDir ? path222.resolve(requestedDir) : canonicalUserDir;
|
|
54489
|
+
const upstreamRoot = path222.resolve(this.providerLoader.getUpstreamDir());
|
|
54490
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path222.sep}`)) {
|
|
54428
54491
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
54429
54492
|
}
|
|
54430
|
-
if (
|
|
54493
|
+
if (path222.basename(desiredDir) !== type) {
|
|
54431
54494
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
54432
54495
|
}
|
|
54433
54496
|
const sourceDir = this.findProviderDir(type);
|
|
54434
54497
|
if (!sourceDir) {
|
|
54435
54498
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
54436
54499
|
}
|
|
54437
|
-
if (!
|
|
54438
|
-
|
|
54439
|
-
|
|
54500
|
+
if (!fs15.existsSync(desiredDir)) {
|
|
54501
|
+
fs15.mkdirSync(path222.dirname(desiredDir), { recursive: true });
|
|
54502
|
+
fs15.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
54440
54503
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
54441
54504
|
}
|
|
54442
|
-
const providerJson =
|
|
54443
|
-
if (!
|
|
54505
|
+
const providerJson = path222.join(desiredDir, "provider.json");
|
|
54506
|
+
if (!fs15.existsSync(providerJson)) {
|
|
54444
54507
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
54445
54508
|
}
|
|
54446
54509
|
return { dir: desiredDir };
|
|
@@ -54475,7 +54538,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54475
54538
|
setMode: "set_mode.js"
|
|
54476
54539
|
};
|
|
54477
54540
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
54478
|
-
const scriptsDir =
|
|
54541
|
+
const scriptsDir = path222.join(providerDir, "scripts");
|
|
54479
54542
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
54480
54543
|
if (latestScriptsDir) {
|
|
54481
54544
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -54483,10 +54546,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54483
54546
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
54484
54547
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
54485
54548
|
lines.push("");
|
|
54486
|
-
for (const file2 of
|
|
54549
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
54487
54550
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
54488
54551
|
try {
|
|
54489
|
-
const content =
|
|
54552
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54490
54553
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
54491
54554
|
lines.push("```javascript");
|
|
54492
54555
|
lines.push(content);
|
|
@@ -54496,14 +54559,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54496
54559
|
}
|
|
54497
54560
|
}
|
|
54498
54561
|
}
|
|
54499
|
-
const refFiles =
|
|
54562
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
54500
54563
|
if (refFiles.length > 0) {
|
|
54501
54564
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
54502
54565
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
54503
54566
|
lines.push("");
|
|
54504
54567
|
for (const file2 of refFiles) {
|
|
54505
54568
|
try {
|
|
54506
|
-
const content =
|
|
54569
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54507
54570
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
54508
54571
|
lines.push("```javascript");
|
|
54509
54572
|
lines.push(content);
|
|
@@ -54544,11 +54607,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54544
54607
|
lines.push("");
|
|
54545
54608
|
}
|
|
54546
54609
|
}
|
|
54547
|
-
const docsDir =
|
|
54610
|
+
const docsDir = path222.join(providerDir, "../../docs");
|
|
54548
54611
|
const loadGuide = (name) => {
|
|
54549
54612
|
try {
|
|
54550
|
-
const p =
|
|
54551
|
-
if (
|
|
54613
|
+
const p = path222.join(docsDir, name);
|
|
54614
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
54552
54615
|
} catch {
|
|
54553
54616
|
}
|
|
54554
54617
|
return null;
|
|
@@ -54721,7 +54784,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54721
54784
|
parseApproval: "parse_approval.js"
|
|
54722
54785
|
};
|
|
54723
54786
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
54724
|
-
const scriptsDir =
|
|
54787
|
+
const scriptsDir = path222.join(providerDir, "scripts");
|
|
54725
54788
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
54726
54789
|
if (latestScriptsDir) {
|
|
54727
54790
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -54729,11 +54792,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54729
54792
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
54730
54793
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
54731
54794
|
lines.push("");
|
|
54732
|
-
for (const file2 of
|
|
54795
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
54733
54796
|
if (!file2.endsWith(".js")) continue;
|
|
54734
54797
|
if (!targetFileNames.has(file2)) continue;
|
|
54735
54798
|
try {
|
|
54736
|
-
const content =
|
|
54799
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54737
54800
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
54738
54801
|
lines.push("```javascript");
|
|
54739
54802
|
lines.push(content);
|
|
@@ -54742,14 +54805,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54742
54805
|
} catch {
|
|
54743
54806
|
}
|
|
54744
54807
|
}
|
|
54745
|
-
const refFiles =
|
|
54808
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
54746
54809
|
if (refFiles.length > 0) {
|
|
54747
54810
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
54748
54811
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
54749
54812
|
lines.push("");
|
|
54750
54813
|
for (const file2 of refFiles) {
|
|
54751
54814
|
try {
|
|
54752
|
-
const content =
|
|
54815
|
+
const content = fs15.readFileSync(path222.join(latestScriptsDir, file2), "utf-8");
|
|
54753
54816
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
54754
54817
|
lines.push("```javascript");
|
|
54755
54818
|
lines.push(content);
|
|
@@ -54782,11 +54845,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
54782
54845
|
lines.push("");
|
|
54783
54846
|
}
|
|
54784
54847
|
}
|
|
54785
|
-
const docsDir =
|
|
54848
|
+
const docsDir = path222.join(providerDir, "../../docs");
|
|
54786
54849
|
const loadGuide = (name) => {
|
|
54787
54850
|
try {
|
|
54788
|
-
const p =
|
|
54789
|
-
if (
|
|
54851
|
+
const p = path222.join(docsDir, name);
|
|
54852
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
54790
54853
|
} catch {
|
|
54791
54854
|
}
|
|
54792
54855
|
return null;
|
|
@@ -55649,8 +55712,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
55649
55712
|
const res = await fetch(extension.vsixUrl);
|
|
55650
55713
|
if (res.ok) {
|
|
55651
55714
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
55652
|
-
const
|
|
55653
|
-
|
|
55715
|
+
const fs16 = await import("fs");
|
|
55716
|
+
fs16.writeFileSync(vsixPath, buffer);
|
|
55654
55717
|
return new Promise((resolve12) => {
|
|
55655
55718
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
55656
55719
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|