@adhdev/daemon-core 0.8.10 → 0.8.12
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 +106 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -71
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +15 -2
- package/src/cli-adapters/pty-transport.ts +1 -1
- package/src/commands/cdp-commands.ts +45 -8
package/dist/index.mjs
CHANGED
|
@@ -694,7 +694,6 @@ var init_terminal_screen = __esm({
|
|
|
694
694
|
});
|
|
695
695
|
|
|
696
696
|
// src/cli-adapters/pty-transport.ts
|
|
697
|
-
import * as os7 from "os";
|
|
698
697
|
var pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
699
698
|
var init_pty_transport = __esm({
|
|
700
699
|
"src/cli-adapters/pty-transport.ts"() {
|
|
@@ -736,7 +735,7 @@ var init_pty_transport = __esm({
|
|
|
736
735
|
spawn(command, args, options) {
|
|
737
736
|
if (!pty) throw new Error("node-pty is not installed");
|
|
738
737
|
const handle = pty.spawn(command, args, {
|
|
739
|
-
name:
|
|
738
|
+
name: "xterm-256color",
|
|
740
739
|
cols: options.cols,
|
|
741
740
|
rows: options.rows,
|
|
742
741
|
cwd: options.cwd,
|
|
@@ -754,7 +753,7 @@ __export(provider_cli_adapter_exports, {
|
|
|
754
753
|
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
755
754
|
normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
|
|
756
755
|
});
|
|
757
|
-
import * as
|
|
756
|
+
import * as os7 from "os";
|
|
758
757
|
import * as path7 from "path";
|
|
759
758
|
import { execSync as execSync3 } from "child_process";
|
|
760
759
|
function stripAnsi(str) {
|
|
@@ -766,6 +765,17 @@ function stripTerminalNoise(str) {
|
|
|
766
765
|
function sanitizeTerminalText(str) {
|
|
767
766
|
return stripTerminalNoise(stripAnsi(str));
|
|
768
767
|
}
|
|
768
|
+
function applyPreferredTerminalColorEnv(env) {
|
|
769
|
+
if (env.NO_COLOR) return;
|
|
770
|
+
if (!env.TERM || env.TERM === "xterm-color") {
|
|
771
|
+
env.TERM = "xterm-256color";
|
|
772
|
+
}
|
|
773
|
+
if (!env.COLORTERM) env.COLORTERM = "truecolor";
|
|
774
|
+
if (process.platform === "win32") {
|
|
775
|
+
if (!env.FORCE_COLOR) env.FORCE_COLOR = "1";
|
|
776
|
+
if (!env.CLICOLOR) env.CLICOLOR = "1";
|
|
777
|
+
}
|
|
778
|
+
}
|
|
769
779
|
function buildCliSpawnEnv(baseEnv, overrides) {
|
|
770
780
|
const env = {};
|
|
771
781
|
const source = { ...baseEnv, ...overrides || {} };
|
|
@@ -774,10 +784,11 @@ function buildCliSpawnEnv(baseEnv, overrides) {
|
|
|
774
784
|
env[key] = value;
|
|
775
785
|
}
|
|
776
786
|
for (const key of Object.keys(env)) {
|
|
777
|
-
if (key === "INIT_CWD" || key === "
|
|
787
|
+
if (key === "INIT_CWD" || key === "npm_command" || key === "npm_execpath" || key === "npm_node_execpath" || key.startsWith("npm_") || key.startsWith("npm_config_") || key.startsWith("npm_package_") || key.startsWith("npm_lifecycle_") || key.startsWith("PNPM_") || key.startsWith("YARN_") || key.startsWith("BUN_")) {
|
|
778
788
|
delete env[key];
|
|
779
789
|
}
|
|
780
790
|
}
|
|
791
|
+
applyPreferredTerminalColorEnv(env);
|
|
781
792
|
return env;
|
|
782
793
|
}
|
|
783
794
|
function computeTerminalQueryTail(buffer) {
|
|
@@ -793,7 +804,7 @@ function computeTerminalQueryTail(buffer) {
|
|
|
793
804
|
return "";
|
|
794
805
|
}
|
|
795
806
|
function findBinary(name) {
|
|
796
|
-
const isWin =
|
|
807
|
+
const isWin = os7.platform() === "win32";
|
|
797
808
|
try {
|
|
798
809
|
const cmd = isWin ? `where ${name}` : `which ${name}`;
|
|
799
810
|
return execSync3(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
|
|
@@ -841,7 +852,7 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
841
852
|
}
|
|
842
853
|
function shSingleQuote(arg) {
|
|
843
854
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
844
|
-
if (
|
|
855
|
+
if (os7.platform() === "win32") {
|
|
845
856
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
846
857
|
}
|
|
847
858
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -917,11 +928,11 @@ var init_provider_cli_adapter = __esm({
|
|
|
917
928
|
init_pty_transport();
|
|
918
929
|
try {
|
|
919
930
|
pty2 = __require("node-pty");
|
|
920
|
-
if (
|
|
931
|
+
if (os7.platform() !== "win32") {
|
|
921
932
|
try {
|
|
922
933
|
const fs15 = __require("fs");
|
|
923
934
|
const ptyDir = path7.resolve(path7.dirname(__require.resolve("node-pty")), "..");
|
|
924
|
-
const platformArch = `${
|
|
935
|
+
const platformArch = `${os7.platform()}-${os7.arch()}`;
|
|
925
936
|
const helper = path7.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
926
937
|
if (fs15.existsSync(helper)) {
|
|
927
938
|
const stat = fs15.statSync(helper);
|
|
@@ -943,7 +954,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
943
954
|
this.transportFactory = transportFactory;
|
|
944
955
|
this.cliType = provider.type;
|
|
945
956
|
this.cliName = provider.name;
|
|
946
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
957
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os7.homedir()) : workingDir;
|
|
947
958
|
const t = provider.timeouts || {};
|
|
948
959
|
this.timeouts = {
|
|
949
960
|
ptyFlush: t.ptyFlush ?? 50,
|
|
@@ -1250,7 +1261,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
1250
1261
|
if (this.ptyProcess) return;
|
|
1251
1262
|
const { spawn: spawnConfig } = this.provider;
|
|
1252
1263
|
const binaryPath = findBinary(spawnConfig.command);
|
|
1253
|
-
const isWin =
|
|
1264
|
+
const isWin = os7.platform() === "win32";
|
|
1254
1265
|
const allArgs = [...spawnConfig.args, ...this.extraArgs];
|
|
1255
1266
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
1256
1267
|
this.resetTraceSession();
|
|
@@ -2654,18 +2665,18 @@ function checkPathExists(paths) {
|
|
|
2654
2665
|
return null;
|
|
2655
2666
|
}
|
|
2656
2667
|
async function detectIDEs() {
|
|
2657
|
-
const
|
|
2668
|
+
const os17 = platform();
|
|
2658
2669
|
const results = [];
|
|
2659
2670
|
for (const def of getMergedDefinitions()) {
|
|
2660
2671
|
const cliPath = findCliCommand(def.cli);
|
|
2661
|
-
const appPath = checkPathExists(def.paths[
|
|
2672
|
+
const appPath = checkPathExists(def.paths[os17] || []);
|
|
2662
2673
|
const installed = !!(cliPath || appPath);
|
|
2663
2674
|
let resolvedCli = cliPath;
|
|
2664
|
-
if (!resolvedCli && appPath &&
|
|
2675
|
+
if (!resolvedCli && appPath && os17 === "darwin") {
|
|
2665
2676
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
2666
2677
|
if (existsSync3(bundledCli)) resolvedCli = bundledCli;
|
|
2667
2678
|
}
|
|
2668
|
-
if (!resolvedCli && appPath &&
|
|
2679
|
+
if (!resolvedCli && appPath && os17 === "win32") {
|
|
2669
2680
|
const { dirname: dirname7 } = await import("path");
|
|
2670
2681
|
const appDir = dirname7(appPath);
|
|
2671
2682
|
const candidates = [
|
|
@@ -2717,8 +2728,8 @@ function execAsync(cmd, timeoutMs = 5e3) {
|
|
|
2717
2728
|
});
|
|
2718
2729
|
}
|
|
2719
2730
|
async function detectCLIs(providerLoader) {
|
|
2720
|
-
const
|
|
2721
|
-
const whichCmd =
|
|
2731
|
+
const platform9 = os2.platform();
|
|
2732
|
+
const whichCmd = platform9 === "win32" ? "where" : "which";
|
|
2722
2733
|
const cliList = providerLoader ? providerLoader.getCliDetectionList() : [];
|
|
2723
2734
|
const results = await Promise.all(
|
|
2724
2735
|
cliList.map(async (cli) => {
|
|
@@ -6867,17 +6878,44 @@ async function handleDiscoverAgents(h, args) {
|
|
|
6867
6878
|
const agents = await h.getCdp().discoverAgentWebviews();
|
|
6868
6879
|
return { success: true, agents };
|
|
6869
6880
|
}
|
|
6881
|
+
function normalizeWindowsRequestedPath(requestedPath) {
|
|
6882
|
+
const trimmed = requestedPath.trim();
|
|
6883
|
+
if (!trimmed) return ".";
|
|
6884
|
+
const slashDriveMatch = trimmed.match(/^[/\\]([A-Za-z])(?:[/\\](.*))?$/);
|
|
6885
|
+
if (slashDriveMatch) {
|
|
6886
|
+
const drive = slashDriveMatch[1].toUpperCase();
|
|
6887
|
+
const rest = (slashDriveMatch[2] || "").replace(/[/\\]+/g, "\\");
|
|
6888
|
+
return rest ? `${drive}:\\${rest}` : `${drive}:\\`;
|
|
6889
|
+
}
|
|
6890
|
+
if (/^[A-Za-z]:$/.test(trimmed)) {
|
|
6891
|
+
return `${trimmed[0].toUpperCase()}:\\`;
|
|
6892
|
+
}
|
|
6893
|
+
if (/^[A-Za-z]:[^/\\].*$/.test(trimmed)) {
|
|
6894
|
+
return `${trimmed[0].toUpperCase()}:\\${trimmed.slice(2).replace(/[/\\]+/g, "\\")}`;
|
|
6895
|
+
}
|
|
6896
|
+
if (/^[A-Za-z]:[/\\]/.test(trimmed)) {
|
|
6897
|
+
return `${trimmed[0].toUpperCase()}:${trimmed.slice(2)}`;
|
|
6898
|
+
}
|
|
6899
|
+
return trimmed;
|
|
6900
|
+
}
|
|
6870
6901
|
function resolveSafePath(requestedPath) {
|
|
6902
|
+
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
6903
|
+
const inputPath = rawPath || ".";
|
|
6871
6904
|
const home = os6.homedir();
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
resolved = path6.join(home, requestedPath.slice(1));
|
|
6875
|
-
} else if (path6.isAbsolute(requestedPath)) {
|
|
6876
|
-
resolved = requestedPath;
|
|
6877
|
-
} else {
|
|
6878
|
-
resolved = path6.resolve(requestedPath);
|
|
6905
|
+
if (inputPath.startsWith("~")) {
|
|
6906
|
+
return path6.resolve(path6.join(home, inputPath.slice(1)));
|
|
6879
6907
|
}
|
|
6880
|
-
|
|
6908
|
+
if (process.platform === "win32") {
|
|
6909
|
+
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
6910
|
+
if (path6.win32.isAbsolute(normalized)) {
|
|
6911
|
+
return path6.win32.normalize(normalized);
|
|
6912
|
+
}
|
|
6913
|
+
return path6.win32.resolve(normalized);
|
|
6914
|
+
}
|
|
6915
|
+
if (path6.isAbsolute(inputPath)) {
|
|
6916
|
+
return path6.normalize(inputPath);
|
|
6917
|
+
}
|
|
6918
|
+
return path6.resolve(inputPath);
|
|
6881
6919
|
}
|
|
6882
6920
|
function listDirectoryEntriesSafe(dirPath) {
|
|
6883
6921
|
const entries = fs4.readdirSync(dirPath, { withFileTypes: true });
|
|
@@ -7708,7 +7746,7 @@ var DaemonCommandHandler = class {
|
|
|
7708
7746
|
|
|
7709
7747
|
// src/commands/cli-manager.ts
|
|
7710
7748
|
init_provider_cli_adapter();
|
|
7711
|
-
import * as
|
|
7749
|
+
import * as os9 from "os";
|
|
7712
7750
|
import * as path9 from "path";
|
|
7713
7751
|
import * as crypto4 from "crypto";
|
|
7714
7752
|
import chalk from "chalk";
|
|
@@ -7716,7 +7754,7 @@ init_config();
|
|
|
7716
7754
|
|
|
7717
7755
|
// src/providers/cli-provider-instance.ts
|
|
7718
7756
|
init_provider_cli_adapter();
|
|
7719
|
-
import * as
|
|
7757
|
+
import * as os8 from "os";
|
|
7720
7758
|
import * as path8 from "path";
|
|
7721
7759
|
import * as crypto3 from "crypto";
|
|
7722
7760
|
import * as fs5 from "fs";
|
|
@@ -8113,7 +8151,7 @@ var CliProviderInstance = class {
|
|
|
8113
8151
|
LOG.info("CLI", `[${this.type}] discovered provider session id: ${nextSessionId}`);
|
|
8114
8152
|
}
|
|
8115
8153
|
probeOpenCodeSessionId() {
|
|
8116
|
-
const dbPath = path8.join(
|
|
8154
|
+
const dbPath = path8.join(os8.homedir(), ".local", "share", "opencode", "opencode.db");
|
|
8117
8155
|
if (!fs5.existsSync(dbPath)) return null;
|
|
8118
8156
|
const minCreatedAt = Math.max(0, this.startedAt - 6e4);
|
|
8119
8157
|
const directories = this.getProbeDirectories();
|
|
@@ -8121,7 +8159,7 @@ var CliProviderInstance = class {
|
|
|
8121
8159
|
return this.querySqliteText(dbPath, query, [...directories, minCreatedAt]);
|
|
8122
8160
|
}
|
|
8123
8161
|
probeCodexSessionId() {
|
|
8124
|
-
const dbPath = path8.join(
|
|
8162
|
+
const dbPath = path8.join(os8.homedir(), ".codex", "state_5.sqlite");
|
|
8125
8163
|
if (!fs5.existsSync(dbPath)) return null;
|
|
8126
8164
|
const minCreatedAt = Math.max(0, Math.floor((this.startedAt - 6e4) / 1e3));
|
|
8127
8165
|
const directories = this.getProbeDirectories();
|
|
@@ -8129,7 +8167,7 @@ var CliProviderInstance = class {
|
|
|
8129
8167
|
return this.querySqliteText(dbPath, query, [...directories, minCreatedAt]);
|
|
8130
8168
|
}
|
|
8131
8169
|
probeGooseSessionId() {
|
|
8132
|
-
const dbPath = path8.join(
|
|
8170
|
+
const dbPath = path8.join(os8.homedir(), ".local", "share", "goose", "sessions", "sessions.db");
|
|
8133
8171
|
if (!fs5.existsSync(dbPath)) return null;
|
|
8134
8172
|
const minCreatedAtIso = new Date(Math.max(0, this.startedAt - 6e4)).toISOString().slice(0, 19).replace("T", " ");
|
|
8135
8173
|
const directories = this.getProbeDirectories();
|
|
@@ -9329,7 +9367,7 @@ var DaemonCliManager = class {
|
|
|
9329
9367
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
9330
9368
|
const trimmed = (workingDir || "").trim();
|
|
9331
9369
|
if (!trimmed) throw new Error("working directory required");
|
|
9332
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
9370
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os9.homedir()) : path9.resolve(trimmed);
|
|
9333
9371
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
9334
9372
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
9335
9373
|
const key = crypto4.randomUUID();
|
|
@@ -9765,13 +9803,13 @@ ${installInfo}`
|
|
|
9765
9803
|
// src/launch.ts
|
|
9766
9804
|
import { execSync as execSync4, spawn as spawn2 } from "child_process";
|
|
9767
9805
|
import * as net from "net";
|
|
9768
|
-
import * as
|
|
9806
|
+
import * as os11 from "os";
|
|
9769
9807
|
import * as path11 from "path";
|
|
9770
9808
|
|
|
9771
9809
|
// src/providers/provider-loader.ts
|
|
9772
9810
|
import * as fs6 from "fs";
|
|
9773
9811
|
import * as path10 from "path";
|
|
9774
|
-
import * as
|
|
9812
|
+
import * as os10 from "os";
|
|
9775
9813
|
import * as chokidar from "chokidar";
|
|
9776
9814
|
init_logger();
|
|
9777
9815
|
var ProviderLoader = class _ProviderLoader {
|
|
@@ -9791,7 +9829,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
9791
9829
|
static META_FILE = ".meta.json";
|
|
9792
9830
|
constructor(options) {
|
|
9793
9831
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
9794
|
-
const defaultProvidersDir = path10.join(
|
|
9832
|
+
const defaultProvidersDir = path10.join(os10.homedir(), ".adhdev", "providers");
|
|
9795
9833
|
if (options?.userDir) {
|
|
9796
9834
|
this.userDir = options.userDir;
|
|
9797
9835
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -10391,8 +10429,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
10391
10429
|
return { updated: false };
|
|
10392
10430
|
}
|
|
10393
10431
|
this.log("Downloading latest providers from GitHub...");
|
|
10394
|
-
const tmpTar = path10.join(
|
|
10395
|
-
const tmpExtract = path10.join(
|
|
10432
|
+
const tmpTar = path10.join(os10.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
10433
|
+
const tmpExtract = path10.join(os10.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
10396
10434
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
10397
10435
|
fs6.mkdirSync(tmpExtract, { recursive: true });
|
|
10398
10436
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
@@ -10779,9 +10817,9 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
10779
10817
|
}
|
|
10780
10818
|
}
|
|
10781
10819
|
compareVersions(a, b) {
|
|
10782
|
-
const
|
|
10783
|
-
const pa =
|
|
10784
|
-
const pb =
|
|
10820
|
+
const normalize3 = (v) => v.split(/[-_+]/)[0].split(".").map((x) => parseInt(x, 10) || 0);
|
|
10821
|
+
const pa = normalize3(a);
|
|
10822
|
+
const pb = normalize3(b);
|
|
10785
10823
|
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
10786
10824
|
const va = pa[i] || 0;
|
|
10787
10825
|
const vb = pb[i] || 0;
|
|
@@ -10857,7 +10895,7 @@ async function isCdpActive(port) {
|
|
|
10857
10895
|
});
|
|
10858
10896
|
}
|
|
10859
10897
|
async function killIdeProcess(ideId) {
|
|
10860
|
-
const plat =
|
|
10898
|
+
const plat = os11.platform();
|
|
10861
10899
|
const appName = getMacAppIdentifiers()[ideId];
|
|
10862
10900
|
const winProcesses = getWinProcessNames()[ideId];
|
|
10863
10901
|
try {
|
|
@@ -10916,7 +10954,7 @@ async function killIdeProcess(ideId) {
|
|
|
10916
10954
|
}
|
|
10917
10955
|
}
|
|
10918
10956
|
function isIdeRunning(ideId) {
|
|
10919
|
-
const plat =
|
|
10957
|
+
const plat = os11.platform();
|
|
10920
10958
|
try {
|
|
10921
10959
|
if (plat === "darwin") {
|
|
10922
10960
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -10952,7 +10990,7 @@ function isIdeRunning(ideId) {
|
|
|
10952
10990
|
}
|
|
10953
10991
|
}
|
|
10954
10992
|
function detectCurrentWorkspace(ideId) {
|
|
10955
|
-
const plat =
|
|
10993
|
+
const plat = os11.platform();
|
|
10956
10994
|
if (plat === "darwin") {
|
|
10957
10995
|
try {
|
|
10958
10996
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -10972,7 +11010,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
10972
11010
|
const appName = appNameMap[ideId];
|
|
10973
11011
|
if (appName) {
|
|
10974
11012
|
const storagePath = path11.join(
|
|
10975
|
-
process.env.APPDATA || path11.join(
|
|
11013
|
+
process.env.APPDATA || path11.join(os11.homedir(), "AppData", "Roaming"),
|
|
10976
11014
|
appName,
|
|
10977
11015
|
"storage.json"
|
|
10978
11016
|
);
|
|
@@ -10994,7 +11032,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
10994
11032
|
return void 0;
|
|
10995
11033
|
}
|
|
10996
11034
|
async function launchWithCdp(options = {}) {
|
|
10997
|
-
const
|
|
11035
|
+
const platform9 = os11.platform();
|
|
10998
11036
|
let targetIde;
|
|
10999
11037
|
const ides = await detectIDEs();
|
|
11000
11038
|
if (options.ideId) {
|
|
@@ -11063,9 +11101,9 @@ async function launchWithCdp(options = {}) {
|
|
|
11063
11101
|
}
|
|
11064
11102
|
const port = await findFreePort(portPair);
|
|
11065
11103
|
try {
|
|
11066
|
-
if (
|
|
11104
|
+
if (platform9 === "darwin") {
|
|
11067
11105
|
await launchMacOS(targetIde, port, workspace, options.newWindow);
|
|
11068
|
-
} else if (
|
|
11106
|
+
} else if (platform9 === "win32") {
|
|
11069
11107
|
await launchWindows(targetIde, port, workspace, options.newWindow);
|
|
11070
11108
|
} else {
|
|
11071
11109
|
await launchLinux(targetIde, port, workspace, options.newWindow);
|
|
@@ -11146,8 +11184,8 @@ init_logger();
|
|
|
11146
11184
|
// src/logging/command-log.ts
|
|
11147
11185
|
import * as fs7 from "fs";
|
|
11148
11186
|
import * as path12 from "path";
|
|
11149
|
-
import * as
|
|
11150
|
-
var LOG_DIR2 = process.platform === "win32" ? path12.join(process.env.LOCALAPPDATA || process.env.APPDATA || path12.join(
|
|
11187
|
+
import * as os12 from "os";
|
|
11188
|
+
var LOG_DIR2 = process.platform === "win32" ? path12.join(process.env.LOCALAPPDATA || process.env.APPDATA || path12.join(os12.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path12.join(os12.homedir(), "Library", "Logs", "adhdev") : path12.join(os12.homedir(), ".local", "share", "adhdev", "logs");
|
|
11151
11189
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
11152
11190
|
var MAX_DAYS = 7;
|
|
11153
11191
|
try {
|
|
@@ -11283,7 +11321,7 @@ init_logger();
|
|
|
11283
11321
|
|
|
11284
11322
|
// src/status/snapshot.ts
|
|
11285
11323
|
init_config();
|
|
11286
|
-
import * as
|
|
11324
|
+
import * as os13 from "os";
|
|
11287
11325
|
init_terminal_screen();
|
|
11288
11326
|
init_logger();
|
|
11289
11327
|
var READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
@@ -11398,16 +11436,16 @@ function buildStatusSnapshot(options) {
|
|
|
11398
11436
|
version: options.version,
|
|
11399
11437
|
daemonMode: options.daemonMode,
|
|
11400
11438
|
machine: {
|
|
11401
|
-
hostname:
|
|
11402
|
-
platform:
|
|
11403
|
-
arch:
|
|
11404
|
-
cpus:
|
|
11439
|
+
hostname: os13.hostname(),
|
|
11440
|
+
platform: os13.platform(),
|
|
11441
|
+
arch: os13.arch(),
|
|
11442
|
+
cpus: os13.cpus().length,
|
|
11405
11443
|
totalMem: memSnap.totalMem,
|
|
11406
11444
|
freeMem: memSnap.freeMem,
|
|
11407
11445
|
availableMem: memSnap.availableMem,
|
|
11408
|
-
loadavg:
|
|
11409
|
-
uptime:
|
|
11410
|
-
release:
|
|
11446
|
+
loadavg: os13.loadavg(),
|
|
11447
|
+
uptime: os13.uptime(),
|
|
11448
|
+
release: os13.release()
|
|
11411
11449
|
},
|
|
11412
11450
|
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
11413
11451
|
timestamp: options.timestamp ?? Date.now(),
|
|
@@ -11427,11 +11465,11 @@ function buildStatusSnapshot(options) {
|
|
|
11427
11465
|
import { execFileSync } from "child_process";
|
|
11428
11466
|
import { spawn as spawn3 } from "child_process";
|
|
11429
11467
|
import * as fs8 from "fs";
|
|
11430
|
-
import * as
|
|
11468
|
+
import * as os14 from "os";
|
|
11431
11469
|
import * as path13 from "path";
|
|
11432
11470
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
11433
11471
|
function getUpgradeLogPath() {
|
|
11434
|
-
const home =
|
|
11472
|
+
const home = os14.homedir();
|
|
11435
11473
|
const dir = path13.join(home, ".adhdev");
|
|
11436
11474
|
fs8.mkdirSync(dir, { recursive: true });
|
|
11437
11475
|
return path13.join(dir, "daemon-upgrade.log");
|
|
@@ -11471,7 +11509,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
11471
11509
|
}
|
|
11472
11510
|
}
|
|
11473
11511
|
function stopSessionHostProcesses(appName) {
|
|
11474
|
-
const pidFile = path13.join(
|
|
11512
|
+
const pidFile = path13.join(os14.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
11475
11513
|
try {
|
|
11476
11514
|
if (fs8.existsSync(pidFile)) {
|
|
11477
11515
|
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -11500,7 +11538,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
11500
11538
|
}
|
|
11501
11539
|
}
|
|
11502
11540
|
function removeDaemonPidFile() {
|
|
11503
|
-
const pidFile = path13.join(
|
|
11541
|
+
const pidFile = path13.join(os14.homedir(), ".adhdev", "daemon.pid");
|
|
11504
11542
|
try {
|
|
11505
11543
|
fs8.unlinkSync(pidFile);
|
|
11506
11544
|
} catch {
|
|
@@ -13010,10 +13048,10 @@ var ProviderInstanceManager = class {
|
|
|
13010
13048
|
// src/providers/version-archive.ts
|
|
13011
13049
|
import * as fs10 from "fs";
|
|
13012
13050
|
import * as path14 from "path";
|
|
13013
|
-
import * as
|
|
13051
|
+
import * as os15 from "os";
|
|
13014
13052
|
import { execSync as execSync5 } from "child_process";
|
|
13015
|
-
import { platform as
|
|
13016
|
-
var ARCHIVE_PATH = path14.join(
|
|
13053
|
+
import { platform as platform7 } from "os";
|
|
13054
|
+
var ARCHIVE_PATH = path14.join(os15.homedir(), ".adhdev", "version-history.json");
|
|
13017
13055
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
13018
13056
|
var VersionArchive = class {
|
|
13019
13057
|
history = {};
|
|
@@ -13038,7 +13076,7 @@ var VersionArchive = class {
|
|
|
13038
13076
|
entries.push({
|
|
13039
13077
|
version,
|
|
13040
13078
|
detectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13041
|
-
os:
|
|
13079
|
+
os: platform7()
|
|
13042
13080
|
});
|
|
13043
13081
|
if (entries.length > MAX_ENTRIES_PER_PROVIDER) {
|
|
13044
13082
|
this.history[type] = entries.slice(-MAX_ENTRIES_PER_PROVIDER);
|
|
@@ -13078,7 +13116,7 @@ function runCommand(cmd, timeout = 1e4) {
|
|
|
13078
13116
|
}
|
|
13079
13117
|
}
|
|
13080
13118
|
function findBinary2(name) {
|
|
13081
|
-
const cmd =
|
|
13119
|
+
const cmd = platform7() === "win32" ? `where ${name}` : `which ${name}`;
|
|
13082
13120
|
const result = runCommand(cmd, 5e3);
|
|
13083
13121
|
return result ? result.split("\n")[0] : null;
|
|
13084
13122
|
}
|
|
@@ -13100,7 +13138,7 @@ function getVersion(binary, versionCommand) {
|
|
|
13100
13138
|
function checkPathExists2(paths) {
|
|
13101
13139
|
for (const p of paths) {
|
|
13102
13140
|
if (p.includes("*")) {
|
|
13103
|
-
const home =
|
|
13141
|
+
const home = os15.homedir();
|
|
13104
13142
|
const resolved = p.replace(/\*/g, home.split(path14.sep).pop() || "");
|
|
13105
13143
|
if (fs10.existsSync(resolved)) return resolved;
|
|
13106
13144
|
} else {
|
|
@@ -13110,7 +13148,7 @@ function checkPathExists2(paths) {
|
|
|
13110
13148
|
return null;
|
|
13111
13149
|
}
|
|
13112
13150
|
function getMacAppVersion(appPath) {
|
|
13113
|
-
if (
|
|
13151
|
+
if (platform7() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
13114
13152
|
const plistPath = path14.join(appPath, "Contents", "Info.plist");
|
|
13115
13153
|
if (!fs10.existsSync(plistPath)) return null;
|
|
13116
13154
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
@@ -13118,7 +13156,7 @@ function getMacAppVersion(appPath) {
|
|
|
13118
13156
|
}
|
|
13119
13157
|
async function detectAllVersions(loader, archive) {
|
|
13120
13158
|
const results = [];
|
|
13121
|
-
const currentOs =
|
|
13159
|
+
const currentOs = platform7();
|
|
13122
13160
|
for (const provider of loader.getAll()) {
|
|
13123
13161
|
const info = {
|
|
13124
13162
|
type: provider.type,
|
|
@@ -15428,7 +15466,7 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
15428
15466
|
// src/daemon/dev-auto-implement.ts
|
|
15429
15467
|
import * as fs13 from "fs";
|
|
15430
15468
|
import * as path17 from "path";
|
|
15431
|
-
import * as
|
|
15469
|
+
import * as os16 from "os";
|
|
15432
15470
|
function getAutoImplPid(ctx) {
|
|
15433
15471
|
const proc = ctx.autoImplProcess;
|
|
15434
15472
|
return proc && typeof proc.pid === "number" && proc.pid > 0 ? proc.pid : null;
|
|
@@ -15631,7 +15669,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
15631
15669
|
});
|
|
15632
15670
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
15633
15671
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
15634
|
-
const tmpDir = path17.join(
|
|
15672
|
+
const tmpDir = path17.join(os16.tmpdir(), "adhdev-autoimpl");
|
|
15635
15673
|
if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
|
|
15636
15674
|
const promptFile = path17.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
15637
15675
|
fs13.writeFileSync(promptFile, prompt, "utf-8");
|
|
@@ -15785,7 +15823,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
15785
15823
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
15786
15824
|
const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
15787
15825
|
let shellCmd;
|
|
15788
|
-
const isWin =
|
|
15826
|
+
const isWin = os16.platform() === "win32";
|
|
15789
15827
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
15790
15828
|
if (command === "claude") {
|
|
15791
15829
|
const args = [...baseArgs, "--dangerously-skip-permissions"];
|
|
@@ -15829,7 +15867,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
15829
15867
|
try {
|
|
15830
15868
|
const pty3 = __require("node-pty");
|
|
15831
15869
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
15832
|
-
const isWin2 =
|
|
15870
|
+
const isWin2 = os16.platform() === "win32";
|
|
15833
15871
|
child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
15834
15872
|
name: "xterm-256color",
|
|
15835
15873
|
cols: 120,
|