adhdev 0.1.39 → 0.1.41

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.
Files changed (2) hide show
  1. package/dist/index.js +51 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2092,7 +2092,8 @@ var init_claude_cli = __esm({
2092
2092
  };
2093
2093
  }
2094
2094
  async sendMessage(text) {
2095
- if (!this.ptyProcess || !this.ready) return;
2095
+ if (!this.ptyProcess) throw new Error("Claude Code PTY process not running");
2096
+ if (!this.ready) throw new Error(`Claude Code not ready (status: ${this.currentStatus}). Startup may still be in progress.`);
2096
2097
  this.messages.push({ role: "user", content: text, timestamp: Date.now() });
2097
2098
  this.isWaitingForResponse = true;
2098
2099
  this.currentStatus = "generating";
@@ -4311,8 +4312,8 @@ var init_daemon_commands = __esm({
4311
4312
  const cliMatch = raw.match(/:cli:(.+)$/);
4312
4313
  if (ideMatch) raw = ideMatch[1];
4313
4314
  else if (cliMatch) raw = cliMatch[1];
4314
- const parts = raw.split("_");
4315
- if (parts.length >= 2) return parts[0];
4315
+ const lastUnderscore = raw.lastIndexOf("_");
4316
+ if (lastUnderscore > 0) return raw.substring(0, lastUnderscore);
4316
4317
  }
4317
4318
  return void 0;
4318
4319
  }
@@ -5335,12 +5336,23 @@ var init_daemon_commands = __esm({
5335
5336
  if (!data) return { success: false, error: "data required" };
5336
5337
  if (this.ctx.adapters) {
5337
5338
  const targetCli = cliType || "gemini-cli";
5339
+ const directAdapter = this.ctx.adapters.get(targetCli);
5340
+ if (directAdapter && typeof directAdapter.writeRaw === "function") {
5341
+ directAdapter.writeRaw(data);
5342
+ return { success: true };
5343
+ }
5338
5344
  for (const [, adapter] of this.ctx.adapters) {
5339
5345
  if (adapter.cliType === targetCli && typeof adapter.writeRaw === "function") {
5340
5346
  adapter.writeRaw(data);
5341
5347
  return { success: true };
5342
5348
  }
5343
5349
  }
5350
+ for (const [key, adapter] of this.ctx.adapters) {
5351
+ if ((key.startsWith(targetCli) || targetCli.startsWith(adapter.cliType)) && typeof adapter.writeRaw === "function") {
5352
+ adapter.writeRaw(data);
5353
+ return { success: true };
5354
+ }
5355
+ }
5344
5356
  }
5345
5357
  return { success: false, error: `CLI adapter not found: ${cliType}` };
5346
5358
  }
@@ -5349,8 +5361,18 @@ var init_daemon_commands = __esm({
5349
5361
  if (!cols || !rows) return { success: false, error: "cols and rows required" };
5350
5362
  if (this.ctx.adapters) {
5351
5363
  const targetCli = cliType || "gemini-cli";
5352
- for (const [, adapter] of this.ctx.adapters) {
5353
- if (adapter.cliType === targetCli && typeof adapter.resize === "function") {
5364
+ const directAdapter = this.ctx.adapters.get(targetCli);
5365
+ if (directAdapter && typeof directAdapter.resize === "function") {
5366
+ if (force) {
5367
+ directAdapter.resize(cols - 1, rows);
5368
+ setTimeout(() => directAdapter.resize(cols, rows), 50);
5369
+ } else {
5370
+ directAdapter.resize(cols, rows);
5371
+ }
5372
+ return { success: true };
5373
+ }
5374
+ for (const [key, adapter] of this.ctx.adapters) {
5375
+ if ((adapter.cliType === targetCli || key.startsWith(targetCli) || targetCli.startsWith(adapter.cliType)) && typeof adapter.resize === "function") {
5354
5376
  if (force) {
5355
5377
  adapter.resize(cols - 1, rows);
5356
5378
  setTimeout(() => adapter.resize(cols, rows), 50);
@@ -6463,12 +6485,23 @@ var init_adhdev_daemon = __esm({
6463
6485
  }
6464
6486
  case "agent_command": {
6465
6487
  const agentType = args?.agentType || args?.cliType;
6466
- const dir = args?.dir || process.cwd();
6488
+ const dir = args?.dir;
6467
6489
  const action = args?.action;
6468
6490
  if (!agentType || !action) throw new Error("agentType and action required");
6469
- const key = this.getCliKey(agentType, dir);
6470
- const adapter = this.adapters.get(key);
6471
- if (!adapter) throw new Error(`CLI agent not running for ${key}`);
6491
+ let adapter;
6492
+ if (dir) {
6493
+ const key = this.getCliKey(agentType, dir);
6494
+ adapter = this.adapters.get(key);
6495
+ }
6496
+ if (!adapter) {
6497
+ for (const [k, a] of this.adapters) {
6498
+ if (a.cliType === agentType || k.startsWith(agentType)) {
6499
+ adapter = a;
6500
+ break;
6501
+ }
6502
+ }
6503
+ }
6504
+ if (!adapter) throw new Error(`CLI agent not running: ${agentType}`);
6472
6505
  if (action === "send_chat") {
6473
6506
  const message = args.message || args.text;
6474
6507
  if (!message) throw new Error("message required for send_chat");
@@ -6480,7 +6513,14 @@ var init_adhdev_daemon = __esm({
6480
6513
  }
6481
6514
  this.sendResult(msg, true, { cleared: true });
6482
6515
  } else if (action === "stop") {
6483
- await this.stopCliSession(key);
6516
+ let adapterKey;
6517
+ for (const [k, a] of this.adapters) {
6518
+ if (a === adapter) {
6519
+ adapterKey = k;
6520
+ break;
6521
+ }
6522
+ }
6523
+ if (adapterKey) await this.stopCliSession(adapterKey);
6484
6524
  this.sendResult(msg, true, { stopped: true });
6485
6525
  } else {
6486
6526
  throw new Error(`Unknown action: ${action}`);
@@ -6749,14 +6789,7 @@ var init_adhdev_daemon = __esm({
6749
6789
  adapter.setOnStatusChange(() => this.sendUnifiedStatusReport());
6750
6790
  if (typeof adapter.setOnPtyData === "function") {
6751
6791
  adapter.setOnPtyData((data) => {
6752
- const sentViaP2P = this.p2p?.broadcastPtyOutput(key, data);
6753
- if (!sentViaP2P && this.bridge) {
6754
- this.bridge.sendMessage("pty_output", {
6755
- cliType: key,
6756
- // adapter key (cliType_hash)
6757
- data
6758
- });
6759
- }
6792
+ this.p2p?.broadcastPtyOutput(key, data);
6760
6793
  });
6761
6794
  }
6762
6795
  this.adapters.set(key, adapter);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adhdev",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "ADHDev CLI — Detect, install and configure your IDE + AI agent extensions",
5
5
  "main": "dist/index.js",
6
6
  "bin": {