adhdev 0.6.49 → 0.6.51

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
@@ -321,14 +321,26 @@ function addCliHistory(entry) {
321
321
  const config2 = loadConfig();
322
322
  const history = config2.cliHistory || [];
323
323
  const argsKey = (entry.cliArgs || []).join(" ");
324
+ const category = entry.category || "cli";
325
+ const workspaceKey = entry.workspace || "";
326
+ const modelKey = entry.model || "";
324
327
  const filtered = history.filter((h) => {
325
328
  const hArgsKey = (h.cliArgs || []).join(" ");
326
- return !(h.cliType === entry.cliType && h.dir === entry.dir && hArgsKey === argsKey);
329
+ return !((h.category || "cli") === category && h.cliType === entry.cliType && h.dir === entry.dir && hArgsKey === argsKey && (h.workspace || "") === workspaceKey && (h.model || "") === modelKey);
327
330
  });
328
331
  filtered.unshift({
329
332
  ...entry,
333
+ category,
330
334
  timestamp: Date.now(),
331
- label: entry.label || `${entry.cliType} \xB7 ${entry.dir.split("/").filter(Boolean).pop() || "root"}${argsKey ? ` (${argsKey})` : ""}`
335
+ label: entry.label || (() => {
336
+ const base = `${entry.cliType} \xB7 ${entry.dir.split("/").filter(Boolean).pop() || "root"}`;
337
+ const suffix = [];
338
+ if (entry.workspace && entry.workspace !== entry.dir) suffix.push(entry.workspace.split("/").filter(Boolean).pop() || entry.workspace);
339
+ if (entry.model) suffix.push(`model=${entry.model}`);
340
+ if (argsKey) suffix.push(argsKey);
341
+ if (entry.newWindow) suffix.push("new window");
342
+ return suffix.length > 0 ? `${base} (${suffix.join(" \xB7 ")})` : base;
343
+ })()
332
344
  });
333
345
  config2.cliHistory = filtered.slice(0, 20);
334
346
  saveConfig(config2);
@@ -6627,6 +6639,7 @@ var init_router = __esm({
6627
6639
  init_config();
6628
6640
  init_workspaces();
6629
6641
  init_workspace_activity();
6642
+ init_config();
6630
6643
  init_ide_detector();
6631
6644
  init_logger();
6632
6645
  init_command_log();
@@ -6758,6 +6771,18 @@ var init_router = __esm({
6758
6771
  };
6759
6772
  LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
6760
6773
  const result = await launchWithCdp(launchArgs);
6774
+ if (result.success && (result.ideId || ideKey)) {
6775
+ try {
6776
+ addCliHistory({
6777
+ category: "ide",
6778
+ cliType: result.ideId || ideKey,
6779
+ dir: resolvedWorkspace || "",
6780
+ workspace: resolvedWorkspace || "",
6781
+ newWindow: args?.newWindow === true
6782
+ });
6783
+ } catch {
6784
+ }
6785
+ }
6761
6786
  if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
6762
6787
  const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
6763
6788
  const provider = this.deps.providerLoader.getMeta(result.ideId);
@@ -7331,6 +7356,9 @@ var init_provider_cli_adapter = __esm({
7331
7356
  idleTimeout = null;
7332
7357
  ready = false;
7333
7358
  startupBuffer = "";
7359
+ /** After spawn: briefly skip generating/settle so splash/redraw does not flip status; not used to gate sendMessage */
7360
+ startupParseGate = false;
7361
+ spawnAt = 0;
7334
7362
  // PTY I/O
7335
7363
  onPtyDataCallback = null;
7336
7364
  ptyOutputBuffer = "";
@@ -7444,9 +7472,15 @@ var init_provider_cli_adapter = __esm({
7444
7472
  this.ptyProcess = null;
7445
7473
  this.setStatus("stopped", "pty_exit");
7446
7474
  this.ready = false;
7475
+ this.startupParseGate = false;
7476
+ this.spawnAt = 0;
7447
7477
  this.onStatusChange?.();
7448
7478
  });
7449
- this.setStatus("starting", "spawn");
7479
+ this.spawnAt = Date.now();
7480
+ this.startupParseGate = true;
7481
+ this.startupBuffer = "";
7482
+ this.ready = true;
7483
+ this.setStatus("idle", "pty_ready");
7450
7484
  this.onStatusChange?.();
7451
7485
  }
7452
7486
  // ─── Output state machine ────────────────────────────
@@ -7462,7 +7496,7 @@ var init_provider_cli_adapter = __esm({
7462
7496
  }
7463
7497
  }
7464
7498
  this.recentOutputBuffer = (this.recentOutputBuffer + cleanData).slice(-1e3);
7465
- if (!this.ready) {
7499
+ if (this.startupParseGate) {
7466
7500
  this.startupBuffer += cleanData;
7467
7501
  LOG.info("CLI", `[${this.cliType}] startup chunk (${cleanData.length} chars): ${cleanData.slice(0, 200).replace(/\n/g, "\\n")}`);
7468
7502
  const dialogPatterns = [
@@ -7477,13 +7511,19 @@ var init_provider_cli_adapter = __esm({
7477
7511
  this.startupBuffer = "";
7478
7512
  return;
7479
7513
  }
7480
- if (patterns.prompt.some((p) => p.test(this.startupBuffer))) {
7481
- this.ready = true;
7482
- this.setStatus("idle", "prompt_matched");
7483
- LOG.info("CLI", `[${this.cliType}] \u2713 Ready`);
7484
- this.onStatusChange?.();
7514
+ const elapsed = Date.now() - this.spawnAt;
7515
+ const bufCap = this.startupBuffer.length > 12e3;
7516
+ const promptMatched = patterns.prompt.some((p) => p.test(this.startupBuffer));
7517
+ if (promptMatched || elapsed > 8e3 || bufCap) {
7518
+ this.startupParseGate = false;
7519
+ if (promptMatched) {
7520
+ LOG.info("CLI", `[${this.cliType}] \u2713 Startup gate end (prompt matched)`);
7521
+ } else {
7522
+ LOG.info("CLI", `[${this.cliType}] startup gate end (${elapsed}ms, cap=${bufCap}, prompt=${promptMatched})`);
7523
+ }
7524
+ } else {
7525
+ return;
7485
7526
  }
7486
- return;
7487
7527
  }
7488
7528
  if (cleanData.trim().length > 5) {
7489
7529
  LOG.debug("CLI", `[${this.cliType}] output chunk (${cleanData.length}): ${cleanData.slice(0, 300).replace(/\n/g, "\\n")}`);
@@ -7691,6 +7731,8 @@ var init_provider_cli_adapter = __esm({
7691
7731
  this.ptyProcess = null;
7692
7732
  this.setStatus("stopped", "stop_cmd");
7693
7733
  this.ready = false;
7734
+ this.startupParseGate = false;
7735
+ this.spawnAt = 0;
7694
7736
  this.onStatusChange?.();
7695
7737
  }, this.timeouts.shutdownGrace);
7696
7738
  }
@@ -7737,16 +7779,29 @@ var init_provider_cli_adapter = __esm({
7737
7779
  * Used by DevServer /api/cli/debug endpoint.
7738
7780
  */
7739
7781
  getDebugState() {
7782
+ const sb = this.startupBuffer;
7783
+ const testOnStartup = (p) => {
7784
+ const flags = p.flags.includes("g") ? p.flags.replace(/g/g, "") : p.flags;
7785
+ return new RegExp(p.source, flags).test(sb);
7786
+ };
7787
+ const promptDiagnostics = this.provider.patterns.prompt.map((p) => ({
7788
+ pattern: p.toString(),
7789
+ matchedAgainstStartupBuffer: testOnStartup(p)
7790
+ }));
7740
7791
  return {
7741
7792
  type: this.cliType,
7742
7793
  name: this.cliName,
7743
7794
  status: this.currentStatus,
7744
7795
  ready: this.ready,
7796
+ startupParseGate: this.startupParseGate,
7797
+ spawnAt: this.spawnAt,
7745
7798
  workingDir: this.workingDir,
7746
7799
  messages: this.messages.slice(-20),
7747
7800
  messageCount: this.messages.length,
7748
- // Buffers
7749
- startupBuffer: this.startupBuffer.slice(-500),
7801
+ // Buffers (longer tails here than in periodic logs — for matching provider.json patterns)
7802
+ startupBuffer: sb.slice(-4e3),
7803
+ startupBufferLength: sb.length,
7804
+ promptDiagnostics,
7750
7805
  recentOutputBuffer: this.recentOutputBuffer.slice(-500),
7751
7806
  settledBuffer: this.settledBuffer.slice(-500),
7752
7807
  responseBuffer: this.responseBuffer.slice(-500),
@@ -25342,7 +25397,7 @@ ${installInfo}`
25342
25397
  }
25343
25398
  }
25344
25399
  try {
25345
- addCliHistory({ cliType: normalizedType, dir: resolvedDir, cliArgs });
25400
+ addCliHistory({ category: "acp", cliType: normalizedType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
25346
25401
  } catch (e) {
25347
25402
  LOG.warn("CLI", `ACP history save failed: ${e?.message}`);
25348
25403
  }
@@ -25431,7 +25486,7 @@ ${installInfo}`
25431
25486
  console.log(import_chalk.default.green(` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
25432
25487
  }
25433
25488
  try {
25434
- addCliHistory({ cliType, dir: resolvedDir, cliArgs });
25489
+ addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
25435
25490
  } catch (e) {
25436
25491
  LOG.warn("CLI", `CLI history save failed: ${e?.message}`);
25437
25492
  }
@@ -31329,7 +31384,7 @@ var init_adhdev_daemon = __esm({
31329
31384
  fs11 = __toESM(require("fs"));
31330
31385
  path14 = __toESM(require("path"));
31331
31386
  import_chalk2 = __toESM(require("chalk"));
31332
- pkgVersion = "0.6.49";
31387
+ pkgVersion = "0.6.51";
31333
31388
  if (pkgVersion === "unknown") {
31334
31389
  try {
31335
31390
  const possiblePaths = [