adhdev 0.6.11 → 0.6.13

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 CHANGED
@@ -16732,14 +16732,14 @@ var require_dist = __commonJS({
16732
16732
  ProviderCliAdapter: () => ProviderCliAdapter,
16733
16733
  ProviderInstanceManager: () => ProviderInstanceManager,
16734
16734
  ProviderLoader: () => ProviderLoader,
16735
- VersionArchive: () => VersionArchive2,
16735
+ VersionArchive: () => VersionArchive,
16736
16736
  addCliHistory: () => addCliHistory,
16737
16737
  buildAllManagedEntries: () => buildAllManagedEntries,
16738
16738
  buildManagedAcps: () => buildManagedAcps,
16739
16739
  buildManagedClis: () => buildManagedClis,
16740
16740
  buildManagedIdes: () => buildManagedIdes,
16741
16741
  connectCdpManager: () => connectCdpManager,
16742
- detectAllVersions: () => detectAllVersions2,
16742
+ detectAllVersions: () => detectAllVersions,
16743
16743
  detectCLIs: () => detectCLIs,
16744
16744
  detectIDEs: () => detectIDEs,
16745
16745
  findCdpManager: () => findCdpManager,
@@ -22808,9 +22808,9 @@ var require_dist = __commonJS({
22808
22808
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
22809
22809
  const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
22810
22810
  LOG5.info("Upgrade", `Latest ${pkgName}: v${latest}`);
22811
- execSync7(`npm install -g ${pkgName}@latest`, {
22811
+ execSync7(`npm install -g ${pkgName}@latest --force`, {
22812
22812
  encoding: "utf-8",
22813
- timeout: 6e4,
22813
+ timeout: 12e4,
22814
22814
  stdio: ["pipe", "pipe", "pipe"]
22815
22815
  });
22816
22816
  LOG5.info("Upgrade", `\u2705 Upgraded to v${latest}`);
@@ -25866,7 +25866,7 @@ ${installInfo}`
25866
25866
  var import_os3 = require("os");
25867
25867
  var ARCHIVE_PATH = path11.join(os13.homedir(), ".adhdev", "version-history.json");
25868
25868
  var MAX_ENTRIES_PER_PROVIDER = 20;
25869
- var VersionArchive2 = class {
25869
+ var VersionArchive = class {
25870
25870
  history = {};
25871
25871
  constructor() {
25872
25872
  this.load();
@@ -25967,7 +25967,7 @@ ${installInfo}`
25967
25967
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
25968
25968
  return raw || null;
25969
25969
  }
25970
- async function detectAllVersions2(loader, archive) {
25970
+ async function detectAllVersions(loader, archive) {
25971
25971
  const results = [];
25972
25972
  const currentOs = (0, import_os3.platform)();
25973
25973
  for (const provider of loader.getAll()) {
@@ -26065,8 +26065,10 @@ ${installInfo}`
26065
26065
  if (cli) meta3.cli = cli;
26066
26066
  if (cdpPorts) meta3.cdpPorts = cdpPorts;
26067
26067
  else if (!isExtension) meta3.cdpPorts = [9222, 9223];
26068
- if (processName) meta3.processNames = { darwin: processName };
26069
- if (installPath) meta3.paths = { darwin: [installPath] };
26068
+ if (opts.processNames) meta3.processNames = opts.processNames;
26069
+ else if (processName) meta3.processNames = { darwin: processName };
26070
+ if (opts.osPaths) meta3.paths = opts.osPaths;
26071
+ else if (installPath) meta3.paths = { darwin: [installPath] };
26070
26072
  if (isExtension) {
26071
26073
  meta3.extensionId = extensionId || `publisher.${type}`;
26072
26074
  meta3.extensionIdPattern = `${extensionId || type}`;
@@ -27332,7 +27334,9 @@ async (params) => {
27332
27334
  installPath,
27333
27335
  binary,
27334
27336
  extensionId,
27335
- version: version2
27337
+ version: version2,
27338
+ osPaths,
27339
+ processNames
27336
27340
  } = body;
27337
27341
  if (!type || !name) {
27338
27342
  this.json(res, 400, { error: "type and name required" });
@@ -27351,7 +27355,7 @@ async (params) => {
27351
27355
  return;
27352
27356
  }
27353
27357
  try {
27354
- const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2 });
27358
+ const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
27355
27359
  fs9.mkdirSync(targetDir, { recursive: true });
27356
27360
  fs9.writeFileSync(jsonPath, result["provider.json"], "utf-8");
27357
27361
  const createdFiles = ["provider.json"];
@@ -27372,8 +27376,8 @@ async (params) => {
27372
27376
  // ─── Version Detection ───
27373
27377
  async handleDetectVersions(req, res) {
27374
27378
  try {
27375
- const archive = new VersionArchive2();
27376
- const results = await detectAllVersions2(this.providerLoader, archive);
27379
+ const archive = new VersionArchive();
27380
+ const results = await detectAllVersions(this.providerLoader, archive);
27377
27381
  const installed = results.filter((r) => r.installed);
27378
27382
  const notInstalled = results.filter((r) => !r.installed);
27379
27383
  this.json(res, 200, {
@@ -28148,50 +28152,8 @@ async (params) => {
28148
28152
  return;
28149
28153
  }
28150
28154
  try {
28151
- this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "analyzing", message: "DOM \uAD6C\uC870 \uC218\uC9D1 \uC911..." } });
28152
- let domContext = null;
28153
- const cdp = this.getCdp(type);
28154
- if (cdp) {
28155
- try {
28156
- const domScript = `(() => {
28157
- function fp(el) {
28158
- if (!el || el === document.body) return 'body';
28159
- const parts = [];
28160
- let c = el;
28161
- while (c && c !== document.documentElement) {
28162
- let s = c.tagName.toLowerCase();
28163
- if (c.id) s = '#' + c.id;
28164
- else if (c.className && typeof c.className === 'string') {
28165
- const cls = c.className.trim().split(/\\s+/).filter(x => x && !x.startsWith('_')).slice(0, 2);
28166
- if (cls.length) s += '.' + cls.join('.');
28167
- }
28168
- parts.unshift(s);
28169
- c = c.parentElement;
28170
- }
28171
- return parts.join(' > ');
28172
- }
28173
- const r = {};
28174
- // Content editables
28175
- r.editables = [...document.querySelectorAll('[contenteditable], textarea, input')].filter(e => e.offsetWidth > 0).slice(0, 10).map(e => ({
28176
- selector: fp(e), tag: e.tagName.toLowerCase(), ce: e.getAttribute('contenteditable'), role: e.getAttribute('role'), ph: e.getAttribute('placeholder')
28177
- }));
28178
- // Scroll containers
28179
- r.scrollContainers = [...document.querySelectorAll('div, section')].filter(e => {
28180
- const s = getComputedStyle(e); const b = e.getBoundingClientRect();
28181
- return (s.overflowY === 'auto' || s.overflowY === 'scroll') && b.height > 200 && e.children.length > 2;
28182
- }).slice(0, 5).map(e => ({ selector: fp(e), children: e.children.length, h: Math.round(e.getBoundingClientRect().height) }));
28183
- // Buttons
28184
- r.buttons = [...document.querySelectorAll('button, [role="button"]')].filter(e => e.offsetWidth > 0).slice(0, 20).map(e => ({
28185
- text: (e.textContent||'').trim().substring(0, 60), selector: fp(e), label: e.getAttribute('aria-label')
28186
- }));
28187
- return JSON.stringify(r);
28188
- })()`;
28189
- const raw = await cdp.evaluate(domScript, 1e4);
28190
- domContext = typeof raw === "string" ? JSON.parse(raw) : raw;
28191
- } catch (e) {
28192
- this.log(`DOM context collection failed (non-fatal): ${e.message}`);
28193
- }
28194
- }
28155
+ this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "analyzing", message: "\uC5D0\uC774\uC804\uD2B8 \uCD08\uAE30\uD654 (DOM \uD0D0\uC0C9 \uAD8C\uD55C \uBD80\uC5EC)..." } });
28156
+ const domContext = null;
28195
28157
  this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "loading_reference", message: `\uB808\uD37C\uB7F0\uC2A4 \uC2A4\uD06C\uB9BD\uD2B8 \uB85C\uB4DC \uC911 (${reference})...` } });
28196
28158
  let referenceScripts = {};
28197
28159
  const builtinDir = this.providerLoader.builtinDir || path12.resolve(__dirname, "../providers/_builtin");
@@ -28386,22 +28348,11 @@ async (params) => {
28386
28348
  } else {
28387
28349
  args = [...baseArgs];
28388
28350
  }
28389
- const { execSync: execSync7 } = await import("child_process");
28390
- try {
28391
- execSync7(`which ${command}`, { stdio: "pipe" });
28392
- } catch {
28393
- try {
28394
- fs9.unlinkSync(promptFile);
28395
- } catch {
28396
- }
28397
- this.json(res, 400, { error: `Agent binary '${command}' not found on PATH. Install it first: ${agentProvider?.install || "check provider docs"}` });
28398
- return;
28399
- }
28400
28351
  this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "spawning", message: `\uC5D0\uC774\uC804\uD2B8 \uC2E4\uD589 \uC911: ${command} ${args.join(" ")} (prompt: ${prompt.length} chars)` } });
28401
28352
  this.autoImplStatus = { running: true, type, progress: [] };
28402
28353
  const { spawn: spawnFn } = await import("child_process");
28403
28354
  const escapedArgs = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
28404
- const shellCmd = `cat '${promptFile}' | ${command} ${escapedArgs}`;
28355
+ const shellCmd = `${command} ${escapedArgs} -p "$(cat '${promptFile}')"`;
28405
28356
  this.log(`Auto-implement spawn: ${shellCmd}`);
28406
28357
  const child = spawnFn("sh", ["-c", shellCmd], {
28407
28358
  cwd: providerDir,
@@ -28560,6 +28511,7 @@ async (params) => {
28560
28511
  lines.push("4. Always wrap in try-catch, return `JSON.stringify(result)`");
28561
28512
  lines.push("5. Do NOT modify `scripts.js` router \u2014 only edit individual `*.js` files");
28562
28513
  lines.push("6. All scripts run in the browser (CDP evaluate) \u2014 use DOM APIs only");
28514
+ lines.push('7. **Cross-Platform Compatibility**: If you use ARIA labels that contain keyboard shortcuts (e.g., `Cascade (\u2318L)`), you MUST use substring matches (`aria-label*="Cascade"`) or handle both macOS (`\u2318`, `Cmd`) and Windows (`Ctrl`) so the script does not break on other operating systems.');
28563
28515
  lines.push("");
28564
28516
  lines.push("## Required Return Format");
28565
28517
  lines.push("| Function | Return JSON |");
@@ -28582,42 +28534,40 @@ async (params) => {
28582
28534
  lines.push("2. After editing, TEST each function using the DevConsole API (see below)");
28583
28535
  lines.push("3. If a test fails, fix the implementation and re-test");
28584
28536
  lines.push("");
28585
- lines.push("## DevConsole API (for testing)");
28586
- lines.push(`The DevConsole is running at \`http://127.0.0.1:${DEV_SERVER_PORT}\`. Use these HTTP APIs to test your implementations.`);
28587
- lines.push("");
28588
- lines.push("### Run a script against the live IDE");
28589
- lines.push("```bash");
28590
- lines.push(`curl -X POST http://127.0.0.1:${DEV_SERVER_PORT}/api/providers/${type}/scripts/run \\`);
28591
- lines.push(` -H "Content-Type: application/json" \\`);
28592
- lines.push(` -d '{"script": "readChat"}'`);
28593
- lines.push("```");
28594
- lines.push('Replace `"readChat"` with any function name. For functions with params:');
28595
- lines.push("```bash");
28596
- lines.push(`curl -X POST http://127.0.0.1:${DEV_SERVER_PORT}/api/providers/${type}/scripts/run \\`);
28597
- lines.push(` -H "Content-Type: application/json" \\`);
28598
- lines.push(` -d '{"script": "sendMessage", "params": {"text": "hello"}}'`);
28599
- lines.push("```");
28537
+ lines.push("## YOU MUST EXPLORE THE DOM YOURSELF!");
28538
+ lines.push("I have NOT provided you with the DOM snapshot. You MUST use your command-line tools to discover the IDE structure dynamically!");
28600
28539
  lines.push("");
28601
- lines.push("### Evaluate raw JS in the IDE (CDP)");
28540
+ lines.push("### 1. Evaluate JS to explore IDE DOM");
28541
+ lines.push("Use cURL to run JavaScript inside the IDE:");
28602
28542
  lines.push("```bash");
28603
- lines.push(`curl -X POST http://127.0.0.1:${DEV_SERVER_PORT}/api/cdp/evaluate \\`);
28543
+ lines.push(`curl -sS -X POST http://127.0.0.1:${DEV_SERVER_PORT}/api/cdp/evaluate \\`);
28604
28544
  lines.push(` -H "Content-Type: application/json" \\`);
28605
- lines.push(` -d '{"expression": "document.title", "ideType": "${type}"}'`);
28545
+ lines.push(` -d '{"expression": "document.body.innerHTML.substring(0, 1000)", "ideType": "${type}"}'`);
28606
28546
  lines.push("```");
28607
28547
  lines.push("");
28608
- lines.push("### Reload provider (after editing files)");
28548
+ lines.push("### 2. Test your generated function");
28549
+ lines.push("Once you save the file, test it by running:");
28609
28550
  lines.push("```bash");
28610
28551
  lines.push(`curl -X POST http://127.0.0.1:${DEV_SERVER_PORT}/api/providers/reload`);
28552
+ lines.push(`curl -sS -X POST http://127.0.0.1:${DEV_SERVER_PORT}/api/providers/${type}/scripts/run -H "Content-Type: application/json" -d '{"script": "readChat"}'`);
28611
28553
  lines.push("```");
28612
- lines.push("**IMPORTANT**: After editing script files, you MUST call reload before running scripts.");
28613
28554
  lines.push("");
28614
- lines.push("### Workflow: Edit \u2192 Reload \u2192 Test \u2192 Fix");
28615
- lines.push("1. Edit the `.js` file");
28616
- lines.push("2. `curl POST /api/providers/reload`");
28617
- lines.push(`3. \`curl POST /api/providers/${type}/scripts/run -d '{"script":"readChat"}'\``);
28618
- lines.push("4. Check the response \u2014 if error, fix and repeat from step 1");
28555
+ lines.push("### Task Workflow");
28556
+ lines.push("1. Write bash scripts to `curl` the CDP evaluate API above to find exactly where `.chat-message`, etc., are located.");
28557
+ lines.push("2. Iteratively explore until you are confident in your selectors.");
28558
+ lines.push("3. Edit the `.js` files using the selectors you discovered.");
28559
+ lines.push("4. Reload providers and TEST your script via the API.");
28560
+ lines.push("");
28561
+ lines.push("### \u{1F525} Advanced UI Parsing (CRUCIAL for `readChat`)");
28562
+ lines.push("Your `readChat` must flawlessly parse complex UI elements (tables, code blocks, tool calls, and AI thoughts). The quality must match the `antigravity` reference.");
28563
+ lines.push("To achieve this, you MUST generate a live test scenario:");
28564
+ lines.push("1. Early in your process, send a rich prompt to the IDE using the API:");
28565
+ lines.push(' `curl -sS -X POST http://127.0.0.1:${DEV_SERVER_PORT}/api/providers/${type}/scripts/run -H "Content-Type: application/json" -d \'{"script": "sendMessage", "params": {"text": "Write a python script, draw a markdown table, use a tool, and show your reasoning/thought process"}}\'`');
28566
+ lines.push("2. Wait a few seconds for the IDE AI to generate these elements in the UI.");
28567
+ lines.push("3. Use CDP evaluate to deeply inspect the DOM structure of the newly generated tables, code blocks, thought blocks, and tool calls.");
28568
+ lines.push("4. Ensure `readChat` extracts `content` with precise markdown formatting (especially for tables/code) and assigns correct `kind` tags (`thought`, `tool`, `terminal`).");
28619
28569
  lines.push("");
28620
- lines.push("Start NOW. Edit files, then test each one.");
28570
+ lines.push("Start NOW. Do not ask for permission. Explore the DOM -> Code -> Test.");
28621
28571
  return lines.join("\n");
28622
28572
  }
28623
28573
  handleAutoImplSSE(type, req, res) {
@@ -29143,20 +29093,21 @@ data: ${JSON.stringify(msg.data)}
29143
29093
  }
29144
29094
  providerLoader.loadAll();
29145
29095
  providerLoader.registerToDetector();
29146
- LOG5.info("Init", "Detecting provider versions...");
29147
- const versionArchive = new VersionArchive2();
29096
+ const versionArchive = new VersionArchive();
29148
29097
  providerLoader.setVersionArchive(versionArchive);
29149
- const versionResults = await detectAllVersions2(providerLoader, versionArchive);
29150
- const installedProviders = versionResults.filter((v) => v.installed);
29151
- const withVersion = installedProviders.filter((v) => v.version);
29152
- LOG5.info("Init", `Provider versions: ${installedProviders.length} installed, ${withVersion.length} versioned`);
29153
- for (const v of withVersion) {
29154
- LOG5.info("Init", ` ${v.type} (${v.category}): v${v.version}${v.warning ? " \u26A0 " + v.warning : ""}`);
29155
- }
29156
- const noVersion = installedProviders.filter((v) => !v.version);
29157
- if (noVersion.length > 0) {
29158
- LOG5.warn("Init", ` ${noVersion.length} installed but version unknown: ${noVersion.map((v) => v.type).join(", ")}`);
29159
- }
29098
+ detectAllVersions(providerLoader, versionArchive).then((versionResults) => {
29099
+ const installedProviders = versionResults.filter((v) => v.installed);
29100
+ const withVersion = installedProviders.filter((v) => v.version);
29101
+ LOG5.info("Init", `Provider versions: ${installedProviders.length} installed, ${withVersion.length} versioned`);
29102
+ for (const v of withVersion) {
29103
+ LOG5.info("Init", ` ${v.type} (${v.category}): v${v.version}${v.warning ? " \u26A0 " + v.warning : ""}`);
29104
+ }
29105
+ const noVersion = installedProviders.filter((v) => !v.version);
29106
+ if (noVersion.length > 0) {
29107
+ LOG5.warn("Init", ` ${noVersion.length} installed but version unknown: ${noVersion.map((v) => v.type).join(", ")}`);
29108
+ }
29109
+ }).catch(() => {
29110
+ });
29160
29111
  const instanceManager = new ProviderInstanceManager();
29161
29112
  const cdpManagers = /* @__PURE__ */ new Map();
29162
29113
  const instanceIdMap = /* @__PURE__ */ new Map();
@@ -29610,7 +29561,21 @@ var init_daemon_p2p = __esm({
29610
29561
  this.nodeDatachannel = esmRequire("node-datachannel");
29611
29562
  const keys = Object.keys(this.nodeDatachannel).join(",");
29612
29563
  log(`node-datachannel loaded \u2705 (keys: ${keys.substring(0, 100)})`);
29613
- return;
29564
+ try {
29565
+ const Ctor = this.nodeDatachannel.PeerConnection || this.nodeDatachannel.default?.PeerConnection;
29566
+ if (Ctor) {
29567
+ const testPc = new Ctor("smoke-test", { iceServers: ["stun:stun.cloudflare.com:3478"] });
29568
+ testPc.close();
29569
+ log("PeerConnection smoke test passed \u2705");
29570
+ } else {
29571
+ log("PeerConnection constructor not found \u2014 P2P disabled");
29572
+ this.nodeDatachannel = null;
29573
+ }
29574
+ } catch (smokeErr) {
29575
+ log(`PeerConnection smoke test FAILED: ${smokeErr?.message} \u2014 P2P disabled`);
29576
+ this.nodeDatachannel = null;
29577
+ }
29578
+ if (this.nodeDatachannel) return;
29614
29579
  } catch (e) {
29615
29580
  log(`node-datachannel not found: ${e?.message}
29616
29581
  ${e?.stack || ""}`);
@@ -29797,7 +29762,9 @@ ${e?.stack || ""}`);
29797
29762
  }
29798
29763
  let iceServers = [
29799
29764
  "stun:stun.cloudflare.com:3478",
29800
- "stun:stun.l.google.com:19302"
29765
+ "stun:stun.l.google.com:19302",
29766
+ "stun:stun1.l.google.com:19302",
29767
+ "stun:stun2.l.google.com:19302"
29801
29768
  ];
29802
29769
  const serverIceServers = this.serverConn.getIceServers();
29803
29770
  if (serverIceServers?.length) {
@@ -30539,7 +30506,7 @@ var init_adhdev_daemon = __esm({
30539
30506
  fs2 = __toESM(require("fs"));
30540
30507
  path2 = __toESM(require("path"));
30541
30508
  import_chalk = __toESM(require("chalk"));
30542
- pkgVersion = "0.6.11";
30509
+ pkgVersion = "0.6.13";
30543
30510
  if (pkgVersion === "unknown") {
30544
30511
  try {
30545
30512
  const possiblePaths = [
@@ -30589,6 +30556,13 @@ var init_adhdev_daemon = __esm({
30589
30556
  installGlobalInterceptor();
30590
30557
  } catch {
30591
30558
  }
30559
+ process.on("uncaughtException", (err) => {
30560
+ import_daemon_core4.LOG.error("Daemon", `Uncaught exception: ${err?.message}
30561
+ ${err?.stack || ""}`);
30562
+ });
30563
+ process.on("unhandledRejection", (reason) => {
30564
+ import_daemon_core4.LOG.error("Daemon", `Unhandled rejection: ${reason?.message || reason}`);
30565
+ });
30592
30566
  this.localPort = options.localPort || import_daemon_core4.DEFAULT_DAEMON_PORT;
30593
30567
  const workingDir = options.workingDir || process.cwd();
30594
30568
  if (isDaemonRunning()) {
@@ -30639,14 +30613,6 @@ var init_adhdev_daemon = __esm({
30639
30613
  }
30640
30614
  }
30641
30615
  });
30642
- const versionArchive = new import_daemon_core4.VersionArchive();
30643
- (0, import_daemon_core4.detectAllVersions)(this.components.providerLoader, versionArchive).then((results) => {
30644
- this.components.providerLoader.setVersionArchive(versionArchive);
30645
- for (const info of results) {
30646
- if (info.warning) import_daemon_core4.LOG.warn("Provider", `\u26A0 [${info.name}] ${info.warning}`);
30647
- }
30648
- }).catch(() => {
30649
- });
30650
30616
  this.components.providerLoader.fetchLatest().then(({ updated }) => {
30651
30617
  if (updated) {
30652
30618
  this.components.providerLoader.reload();