adhdev 0.5.60 → 0.5.62

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 CHANGED
@@ -21250,6 +21250,8 @@ var require_dist = __commonJS({
21250
21250
  }
21251
21251
  async handleRefreshScripts(_args) {
21252
21252
  if (this._ctx.providerLoader) {
21253
+ await this._ctx.providerLoader.fetchLatest().catch(() => {
21254
+ });
21253
21255
  this._ctx.providerLoader.reload();
21254
21256
  return { success: true };
21255
21257
  }
@@ -23276,13 +23278,12 @@ var require_dist = __commonJS({
23276
23278
  /Always\s*allow/i,
23277
23279
  /\(y\/n\)/i,
23278
23280
  /\[Y\/n\]/i,
23279
- /Run\s*this\s*command/i,
23280
- /Allow\s*tool/i,
23281
- // Claude Code v2 approval
23281
+ /Run\s+\w+\s+command/i,
23282
+ // "Run bash command" etc — requires surrounding words to avoid false matches
23282
23283
  /Yes,?\s*don'?t\s*ask/i,
23283
23284
  // "Yes, don't ask again" (Claude Code)
23284
- /Deny/i
23285
- // Deny button presence = approval dialog
23285
+ /\bDeny\b/i
23286
+ // Word-boundary match avoids "allow & deny" in /permissions menu text
23286
23287
  ];
23287
23288
  function defaultCleanOutput(raw, _lastUserInput) {
23288
23289
  return stripAnsi(raw).trim();
@@ -23311,7 +23312,7 @@ var require_dist = __commonJS({
23311
23312
  this.timeouts = {
23312
23313
  ptyFlush: t.ptyFlush ?? 50,
23313
23314
  dialogAccept: t.dialogAccept ?? 300,
23314
- approvalCooldown: t.approvalCooldown ?? 500,
23315
+ approvalCooldown: t.approvalCooldown ?? 3e3,
23315
23316
  generatingIdle: t.generatingIdle ?? 6e3,
23316
23317
  idleFinish: t.idleFinish ?? 5e3,
23317
23318
  maxResponse: t.maxResponse ?? 3e5,
@@ -30496,7 +30497,7 @@ var init_adhdev_daemon = __esm({
30496
30497
  fs2 = __toESM(require("fs"));
30497
30498
  path2 = __toESM(require("path"));
30498
30499
  import_chalk = __toESM(require("chalk"));
30499
- pkgVersion = "0.5.60";
30500
+ pkgVersion = "0.5.62";
30500
30501
  if (pkgVersion === "unknown") {
30501
30502
  try {
30502
30503
  const possiblePaths = [
@@ -31220,6 +31221,124 @@ ${import_chalk2.default.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u
31220
31221
  }
31221
31222
  });
31222
31223
 
31224
+ // src/cli/cdp-utils.ts
31225
+ var cdp_utils_exports = {};
31226
+ __export(cdp_utils_exports, {
31227
+ directCdpEval: () => directCdpEval,
31228
+ sendDaemonCommand: () => sendDaemonCommand
31229
+ });
31230
+ async function sendDaemonCommand(cmd, args = {}, port = 19222) {
31231
+ const WebSocket2 = (await import("ws")).default;
31232
+ const { DAEMON_WS_PATH } = await Promise.resolve().then(() => __toESM(require_dist()));
31233
+ return new Promise((resolve, reject) => {
31234
+ const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH || "/daemon"}`;
31235
+ const ws = new WebSocket2(wsUrl);
31236
+ const timeout = setTimeout(() => {
31237
+ ws.close();
31238
+ reject(new Error("Timeout: no response from daemon after 15s"));
31239
+ }, 15e3);
31240
+ ws.on("open", () => {
31241
+ ws.send(JSON.stringify({
31242
+ type: "ext:register",
31243
+ payload: {
31244
+ ideType: "cli-debug",
31245
+ ideVersion: "1.0.0",
31246
+ extensionVersion: "1.0.0",
31247
+ instanceId: `cli-debug-${Date.now()}`,
31248
+ machineId: "cli"
31249
+ }
31250
+ }));
31251
+ setTimeout(() => {
31252
+ ws.send(JSON.stringify({
31253
+ type: "ext:command",
31254
+ payload: { command: cmd, args, messageId: `cli-${Date.now()}` }
31255
+ }));
31256
+ }, 200);
31257
+ });
31258
+ ws.on("message", (data) => {
31259
+ try {
31260
+ const msg = JSON.parse(data.toString());
31261
+ if (msg.type === "daemon:command_result" || msg.type === "command_result") {
31262
+ clearTimeout(timeout);
31263
+ ws.close();
31264
+ resolve(msg.payload?.result || msg.payload || msg);
31265
+ }
31266
+ } catch {
31267
+ }
31268
+ });
31269
+ ws.on("error", (e) => {
31270
+ clearTimeout(timeout);
31271
+ reject(new Error(`Cannot connect to daemon at port ${port}: ${e.message}
31272
+ Is 'adhdev daemon' running?`));
31273
+ });
31274
+ ws.on("close", () => {
31275
+ clearTimeout(timeout);
31276
+ });
31277
+ });
31278
+ }
31279
+ async function directCdpEval(expression, port = 9222) {
31280
+ const http = await import("http");
31281
+ const targets = await new Promise((resolve, reject) => {
31282
+ http.get(`http://127.0.0.1:${port}/json`, (res) => {
31283
+ let data = "";
31284
+ res.on("data", (c) => data += c);
31285
+ res.on("end", () => {
31286
+ try {
31287
+ resolve(JSON.parse(data));
31288
+ } catch {
31289
+ reject(new Error("Invalid JSON"));
31290
+ }
31291
+ });
31292
+ }).on("error", (e) => reject(new Error(`Cannot reach CDP at port ${port}: ${e.message}`)));
31293
+ });
31294
+ const isNonMain = (title) => !title || /extension-output|ADHDev CDP|Debug Console|Output\s*$|Launchpad/i.test(title);
31295
+ const pages = targets.filter((t) => (t.type === "page" || t.type === "Page") && t.webSocketDebuggerUrl);
31296
+ const mainPages = pages.filter((t) => !isNonMain(t.title || ""));
31297
+ const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
31298
+ if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
31299
+ const WebSocket2 = (await import("ws")).default;
31300
+ return new Promise((resolve, reject) => {
31301
+ const ws = new WebSocket2(target.webSocketDebuggerUrl);
31302
+ const timeout = setTimeout(() => {
31303
+ ws.close();
31304
+ reject(new Error("CDP timeout"));
31305
+ }, 15e3);
31306
+ let id = 1;
31307
+ ws.on("open", () => {
31308
+ const stripped = expression.replace(/\/\*[\s\S]*?\*\//g, "").trimStart();
31309
+ const isAsync = stripped.startsWith("(async");
31310
+ ws.send(JSON.stringify({
31311
+ id: id++,
31312
+ method: "Runtime.evaluate",
31313
+ params: { expression, returnByValue: true, awaitPromise: isAsync }
31314
+ }));
31315
+ });
31316
+ ws.on("message", (data) => {
31317
+ const msg = JSON.parse(data.toString());
31318
+ if (msg.id) {
31319
+ clearTimeout(timeout);
31320
+ ws.close();
31321
+ if (msg.result?.result?.value !== void 0) {
31322
+ resolve(msg.result.result.value);
31323
+ } else if (msg.result?.exceptionDetails) {
31324
+ reject(new Error(msg.result.exceptionDetails.text));
31325
+ } else {
31326
+ resolve(msg.result);
31327
+ }
31328
+ }
31329
+ });
31330
+ ws.on("error", (e) => {
31331
+ clearTimeout(timeout);
31332
+ reject(new Error(`CDP connection failed: ${e.message}`));
31333
+ });
31334
+ });
31335
+ }
31336
+ var init_cdp_utils = __esm({
31337
+ "src/cli/cdp-utils.ts"() {
31338
+ "use strict";
31339
+ }
31340
+ });
31341
+
31223
31342
  // src/cli/index.ts
31224
31343
  var import_commander = require("commander");
31225
31344
  var import_chalk6 = __toESM(require("chalk"));
@@ -31679,116 +31798,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
31679
31798
 
31680
31799
  // src/cli/provider-commands.ts
31681
31800
  var import_chalk5 = __toESM(require("chalk"));
31682
-
31683
- // src/cli/cdp-utils.ts
31684
- async function sendDaemonCommand(cmd, args = {}, port = 19222) {
31685
- const WebSocket2 = (await import("ws")).default;
31686
- const { DAEMON_WS_PATH } = await Promise.resolve().then(() => __toESM(require_dist()));
31687
- return new Promise((resolve, reject) => {
31688
- const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH || "/daemon"}`;
31689
- const ws = new WebSocket2(wsUrl);
31690
- const timeout = setTimeout(() => {
31691
- ws.close();
31692
- reject(new Error("Timeout: no response from daemon after 15s"));
31693
- }, 15e3);
31694
- ws.on("open", () => {
31695
- ws.send(JSON.stringify({
31696
- type: "ext:register",
31697
- payload: {
31698
- ideType: "cli-debug",
31699
- ideVersion: "1.0.0",
31700
- extensionVersion: "1.0.0",
31701
- instanceId: `cli-debug-${Date.now()}`,
31702
- machineId: "cli"
31703
- }
31704
- }));
31705
- setTimeout(() => {
31706
- ws.send(JSON.stringify({
31707
- type: "ext:command",
31708
- payload: { command: cmd, args, messageId: `cli-${Date.now()}` }
31709
- }));
31710
- }, 200);
31711
- });
31712
- ws.on("message", (data) => {
31713
- try {
31714
- const msg = JSON.parse(data.toString());
31715
- if (msg.type === "daemon:command_result" || msg.type === "command_result") {
31716
- clearTimeout(timeout);
31717
- ws.close();
31718
- resolve(msg.payload?.result || msg.payload || msg);
31719
- }
31720
- } catch {
31721
- }
31722
- });
31723
- ws.on("error", (e) => {
31724
- clearTimeout(timeout);
31725
- reject(new Error(`Cannot connect to daemon at port ${port}: ${e.message}
31726
- Is 'adhdev daemon' running?`));
31727
- });
31728
- ws.on("close", () => {
31729
- clearTimeout(timeout);
31730
- });
31731
- });
31732
- }
31733
- async function directCdpEval(expression, port = 9222) {
31734
- const http = await import("http");
31735
- const targets = await new Promise((resolve, reject) => {
31736
- http.get(`http://127.0.0.1:${port}/json`, (res) => {
31737
- let data = "";
31738
- res.on("data", (c) => data += c);
31739
- res.on("end", () => {
31740
- try {
31741
- resolve(JSON.parse(data));
31742
- } catch {
31743
- reject(new Error("Invalid JSON"));
31744
- }
31745
- });
31746
- }).on("error", (e) => reject(new Error(`Cannot reach CDP at port ${port}: ${e.message}`)));
31747
- });
31748
- const isNonMain = (title) => !title || /extension-output|ADHDev CDP|Debug Console|Output\s*$|Launchpad/i.test(title);
31749
- const pages = targets.filter((t) => (t.type === "page" || t.type === "Page") && t.webSocketDebuggerUrl);
31750
- const mainPages = pages.filter((t) => !isNonMain(t.title || ""));
31751
- const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
31752
- if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
31753
- const WebSocket2 = (await import("ws")).default;
31754
- return new Promise((resolve, reject) => {
31755
- const ws = new WebSocket2(target.webSocketDebuggerUrl);
31756
- const timeout = setTimeout(() => {
31757
- ws.close();
31758
- reject(new Error("CDP timeout"));
31759
- }, 15e3);
31760
- let id = 1;
31761
- ws.on("open", () => {
31762
- const stripped = expression.replace(/\/\*[\s\S]*?\*\//g, "").trimStart();
31763
- const isAsync = stripped.startsWith("(async");
31764
- ws.send(JSON.stringify({
31765
- id: id++,
31766
- method: "Runtime.evaluate",
31767
- params: { expression, returnByValue: true, awaitPromise: isAsync }
31768
- }));
31769
- });
31770
- ws.on("message", (data) => {
31771
- const msg = JSON.parse(data.toString());
31772
- if (msg.id) {
31773
- clearTimeout(timeout);
31774
- ws.close();
31775
- if (msg.result?.result?.value !== void 0) {
31776
- resolve(msg.result.result.value);
31777
- } else if (msg.result?.exceptionDetails) {
31778
- reject(new Error(msg.result.exceptionDetails.text));
31779
- } else {
31780
- resolve(msg.result);
31781
- }
31782
- }
31783
- });
31784
- ws.on("error", (e) => {
31785
- clearTimeout(timeout);
31786
- reject(new Error(`CDP connection failed: ${e.message}`));
31787
- });
31788
- });
31789
- }
31790
-
31791
- // src/cli/provider-commands.ts
31801
+ init_cdp_utils();
31792
31802
  function registerProviderCommands(program2) {
31793
31803
  const provider = program2.command("provider").description("\u{1F50C} Provider management \u2014 list, test, reload providers");
31794
31804
  provider.command("list").description("List all loaded providers").option("-j, --json", "Output raw JSON").action(async (options) => {
@@ -31831,49 +31841,63 @@ function registerProviderCommands(program2) {
31831
31841
  process.exit(1);
31832
31842
  }
31833
31843
  });
31834
- provider.command("reload").description("Hot-reload all providers (requires daemon --dev)").action(async () => {
31844
+ provider.command("reload").description("Hot-reload all providers from upstream and restart daemon provider state").action(async () => {
31835
31845
  try {
31836
- const http = await import("http");
31837
- const result = await new Promise((resolve, reject) => {
31838
- const req = http.request({
31839
- hostname: "127.0.0.1",
31840
- port: 19280,
31841
- path: "/api/providers/reload",
31842
- method: "POST",
31843
- headers: { "Content-Type": "application/json", "Content-Length": "2" }
31844
- }, (res) => {
31845
- let data = "";
31846
- res.on("data", (c) => data += c);
31847
- res.on("end", () => {
31848
- try {
31849
- resolve(JSON.parse(data));
31850
- } catch {
31851
- resolve({ raw: data });
31852
- }
31853
- });
31854
- });
31855
- req.on("error", () => reject(new Error("DevServer not reachable. Run: adhdev daemon --dev")));
31856
- req.write("{}");
31857
- req.end();
31858
- });
31859
- if (result.reloaded) {
31860
- console.log(import_chalk5.default.green(`
31861
- \u2713 Providers reloaded: ${result.providers?.length || 0} loaded
31846
+ const { sendDaemonCommand: sendDaemonCommand2 } = await Promise.resolve().then(() => (init_cdp_utils(), cdp_utils_exports));
31847
+ const result = await sendDaemonCommand2("refresh_scripts", {});
31848
+ console.log(import_chalk5.default.green(`
31849
+ \u2713 Providers reloaded
31862
31850
  `));
31863
- for (const p of result.providers || []) {
31851
+ if (result?.providers?.length) {
31852
+ for (const p of result.providers) {
31864
31853
  console.log(` ${import_chalk5.default.green("\u2713")} ${p.type} (${p.category}) \u2014 ${p.name}`);
31865
31854
  }
31866
31855
  console.log();
31867
- } else {
31868
- console.log(import_chalk5.default.red(`
31856
+ }
31857
+ } catch {
31858
+ try {
31859
+ const http = await import("http");
31860
+ const result = await new Promise((resolve, reject) => {
31861
+ const req = http.request({
31862
+ hostname: "127.0.0.1",
31863
+ port: 19280,
31864
+ path: "/api/providers/reload",
31865
+ method: "POST",
31866
+ headers: { "Content-Type": "application/json", "Content-Length": "2" }
31867
+ }, (res) => {
31868
+ let data = "";
31869
+ res.on("data", (c) => data += c);
31870
+ res.on("end", () => {
31871
+ try {
31872
+ resolve(JSON.parse(data));
31873
+ } catch {
31874
+ resolve({ raw: data });
31875
+ }
31876
+ });
31877
+ });
31878
+ req.on("error", () => reject(new Error("Daemon not reachable. Is adhdev daemon running?")));
31879
+ req.write("{}");
31880
+ req.end();
31881
+ });
31882
+ if (result.reloaded) {
31883
+ console.log(import_chalk5.default.green(`
31884
+ \u2713 Providers reloaded: ${result.providers?.length || 0} loaded
31885
+ `));
31886
+ for (const p of result.providers || []) {
31887
+ console.log(` ${import_chalk5.default.green("\u2713")} ${p.type} (${p.category}) \u2014 ${p.name}`);
31888
+ }
31889
+ console.log();
31890
+ } else {
31891
+ console.log(import_chalk5.default.red(`
31869
31892
  \u2717 Reload failed: ${result.error || "unknown"}
31870
31893
  `));
31871
- }
31872
- } catch (e) {
31873
- console.error(import_chalk5.default.red(`
31894
+ }
31895
+ } catch (e) {
31896
+ console.error(import_chalk5.default.red(`
31874
31897
  \u2717 ${e.message}
31875
31898
  `));
31876
- process.exit(1);
31899
+ process.exit(1);
31900
+ }
31877
31901
  }
31878
31902
  });
31879
31903
  provider.command("create <type>").description("Scaffold a new provider.js from template").option("-n, --name <name>", "Display name").option("-c, --category <cat>", "Category: ide, extension, cli", "ide").option("--builtin", "Create in builtin directory (default: ~/.adhdev/providers/)").action(async (type, options) => {