adhdev 0.6.12 → 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/cli/index.js +454 -139
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +64 -91
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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:
|
|
22813
|
+
timeout: 12e4,
|
|
22814
22814
|
stdio: ["pipe", "pipe", "pipe"]
|
|
22815
22815
|
});
|
|
22816
22816
|
LOG5.info("Upgrade", `\u2705 Upgraded to v${latest}`);
|
|
@@ -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 (
|
|
26069
|
-
if (
|
|
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"];
|
|
@@ -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 \
|
|
28152
|
-
|
|
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 =
|
|
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("##
|
|
28586
|
-
lines.push(
|
|
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
|
|
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.
|
|
28545
|
+
lines.push(` -d '{"expression": "document.body.innerHTML.substring(0, 1000)", "ideType": "${type}"}'`);
|
|
28606
28546
|
lines.push("```");
|
|
28607
28547
|
lines.push("");
|
|
28608
|
-
lines.push("###
|
|
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
|
|
28615
|
-
lines.push("1.
|
|
28616
|
-
lines.push("2.
|
|
28617
|
-
lines.push(
|
|
28618
|
-
lines.push("4.
|
|
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.");
|
|
28619
28560
|
lines.push("");
|
|
28620
|
-
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`).");
|
|
28569
|
+
lines.push("");
|
|
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) {
|
|
@@ -29611,7 +29561,21 @@ var init_daemon_p2p = __esm({
|
|
|
29611
29561
|
this.nodeDatachannel = esmRequire("node-datachannel");
|
|
29612
29562
|
const keys = Object.keys(this.nodeDatachannel).join(",");
|
|
29613
29563
|
log(`node-datachannel loaded \u2705 (keys: ${keys.substring(0, 100)})`);
|
|
29614
|
-
|
|
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;
|
|
29615
29579
|
} catch (e) {
|
|
29616
29580
|
log(`node-datachannel not found: ${e?.message}
|
|
29617
29581
|
${e?.stack || ""}`);
|
|
@@ -29798,7 +29762,9 @@ ${e?.stack || ""}`);
|
|
|
29798
29762
|
}
|
|
29799
29763
|
let iceServers = [
|
|
29800
29764
|
"stun:stun.cloudflare.com:3478",
|
|
29801
|
-
"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"
|
|
29802
29768
|
];
|
|
29803
29769
|
const serverIceServers = this.serverConn.getIceServers();
|
|
29804
29770
|
if (serverIceServers?.length) {
|
|
@@ -30540,7 +30506,7 @@ var init_adhdev_daemon = __esm({
|
|
|
30540
30506
|
fs2 = __toESM(require("fs"));
|
|
30541
30507
|
path2 = __toESM(require("path"));
|
|
30542
30508
|
import_chalk = __toESM(require("chalk"));
|
|
30543
|
-
pkgVersion = "0.6.
|
|
30509
|
+
pkgVersion = "0.6.13";
|
|
30544
30510
|
if (pkgVersion === "unknown") {
|
|
30545
30511
|
try {
|
|
30546
30512
|
const possiblePaths = [
|
|
@@ -30590,6 +30556,13 @@ var init_adhdev_daemon = __esm({
|
|
|
30590
30556
|
installGlobalInterceptor();
|
|
30591
30557
|
} catch {
|
|
30592
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
|
+
});
|
|
30593
30566
|
this.localPort = options.localPort || import_daemon_core4.DEFAULT_DAEMON_PORT;
|
|
30594
30567
|
const workingDir = options.workingDir || process.cwd();
|
|
30595
30568
|
if (isDaemonRunning()) {
|