adhdev 0.8.89 → 0.8.91

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
@@ -7830,10 +7830,11 @@ async function handleReadChat(h, args) {
7830
7830
  const parsedRecord = parsedStatus && typeof parsedStatus === "object" ? parsedStatus : null;
7831
7831
  const adapterStatus = adapter.getStatus();
7832
7832
  const shouldPreferAdapterMessages = Array.isArray(adapterStatus.messages) && adapterStatus.messages.length > 0 && Array.isArray(parsedRecord?.messages) && adapterStatus.messages.length > parsedRecord.messages.length;
7833
+ const parsedShowsApproval = hasNonEmptyModalButtons(parsedRecord?.activeModal) && parsedRecord?.status === "waiting_approval";
7833
7834
  const status = parsedRecord ? {
7834
7835
  ...parsedRecord,
7835
7836
  messages: shouldPreferAdapterMessages ? adapterStatus.messages : parsedRecord.messages,
7836
- status: adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
7837
+ status: parsedShowsApproval ? parsedRecord.status : adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
7837
7838
  activeModal: parsedRecord.activeModal || adapterStatus.activeModal
7838
7839
  } : adapterStatus;
7839
7840
  const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
@@ -11940,8 +11941,8 @@ function buildCliParseInput(options) {
11940
11941
  scope,
11941
11942
  runtimeSettings
11942
11943
  } = options;
11943
- const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
11944
- const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
11944
+ const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
11945
+ const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
11945
11946
  const screenText = terminalScreenText;
11946
11947
  const recentBuffer = buffer.slice(-1e3) || recentOutputBuffer;
11947
11948
  return {
@@ -11973,8 +11974,8 @@ function summarizeCliTraceMessages(messages, limit = 3) {
11973
11974
  }
11974
11975
  function buildCliTraceParseSnapshot(options) {
11975
11976
  const { accumulatedBuffer, accumulatedRawBuffer, responseBuffer, partialResponse, scope } = options;
11976
- const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
11977
- const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
11977
+ const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
11978
+ const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
11978
11979
  return {
11979
11980
  currentTurnScope: scope || null,
11980
11981
  responseBuffer: summarizeCliTraceText(responseBuffer, 1200),
@@ -12638,6 +12639,7 @@ var init_provider_cli_adapter = __esm({
12638
12639
  looksLikeClaudeGeneratingLine(line) {
12639
12640
  const trimmed = String(line || "").trim();
12640
12641
  if (!trimmed) return false;
12642
+ if (/^⏵⏵\s+accept edits on/i.test(trimmed)) return false;
12641
12643
  if (/esc to (cancel|interrupt|stop)/i.test(trimmed)) return true;
12642
12644
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+\S+.*\b(?:thinking|thought for \d+s?)\b/i.test(trimmed)) return true;
12643
12645
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+[A-Z][A-Za-z-]{3,}ing\b.*(?:…|\.{3})/u.test(trimmed)) return true;
@@ -12847,14 +12849,15 @@ var init_provider_cli_adapter = __esm({
12847
12849
  return;
12848
12850
  }
12849
12851
  const startupModal = this.getStartupConfirmationModal(screenText);
12850
- const modal = this.runParseApproval(tail) || startupModal;
12851
- const rawScriptStatus = this.runDetectStatus(tail);
12852
- const scriptStatus = startupModal ? "waiting_approval" : rawScriptStatus;
12853
12852
  const parsedTranscript = this.parseCurrentTranscript(
12854
12853
  this.committedMessages,
12855
12854
  this.responseBuffer,
12856
12855
  this.currentTurnScope
12857
12856
  );
12857
+ const parsedModal = parsedTranscript?.activeModal && Array.isArray(parsedTranscript.activeModal.buttons) && parsedTranscript.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsedTranscript.activeModal : null;
12858
+ const modal = this.runParseApproval(tail) || parsedModal || startupModal;
12859
+ const rawScriptStatus = this.runDetectStatus(tail);
12860
+ const scriptStatus = startupModal ? "waiting_approval" : parsedModal && parsedTranscript?.status === "waiting_approval" ? "waiting_approval" : rawScriptStatus;
12858
12861
  const parsedMessages = Array.isArray(parsedTranscript?.messages) ? normalizeCliParsedMessages(parsedTranscript.messages, {
12859
12862
  committedMessages: this.committedMessages,
12860
12863
  scope: this.currentTurnScope,
@@ -12864,6 +12867,7 @@ var init_provider_cli_adapter = __esm({
12864
12867
  return;
12865
12868
  }
12866
12869
  const lastParsedAssistant = [...parsedMessages].reverse().find((message) => message.role === "assistant");
12870
+ const parsedShowsLiveAssistantProgress = parsedTranscript?.status === "generating" && !!lastParsedAssistant && parsedMessages.length > this.committedMessages.length;
12867
12871
  const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet || this.currentTurnScope?.prompt || "");
12868
12872
  this.recordTrace("settled", {
12869
12873
  tail: summarizeCliTraceText(tail, 500),
@@ -12950,7 +12954,7 @@ var init_provider_cli_adapter = __esm({
12950
12954
  `[${this.cliType}] settled diagnostics prompt=${JSON.stringify(this.currentTurnScope.prompt).slice(0, 140)} scriptStatus=${String(scriptStatus || "")} parsedStatus=${String(parsedTranscript?.status || "")} parsedMsgCount=${parsedMessages.length} lastParsedAssistant=${JSON.stringify(summarizeCliTraceText(lastParsedAssistant?.content || "", 120)).slice(0, 160)} visibleIdlePrompt=${String(visibleIdlePrompt)} visibleAssistantCandidate=${String(visibleAssistantCandidate)} responseBuffer=${JSON.stringify(summarizeCliTraceText(this.responseBuffer, 160)).slice(0, 220)} screen=${JSON.stringify(summarizeCliTraceText(screenText, 160)).slice(0, 220)}`
12951
12955
  );
12952
12956
  }
12953
- const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate);
12957
+ const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate) && !(parsedTranscript?.status === "idle" && !!lastParsedAssistant);
12954
12958
  if (shouldHoldGenerating) {
12955
12959
  this.clearIdleFinishCandidate("hold_generating_recent_activity");
12956
12960
  this.setStatus("generating", "recent_activity_hold");
@@ -13018,7 +13022,7 @@ var init_provider_cli_adapter = __esm({
13018
13022
  const effectiveScreenText = screenText || this.accumulatedBuffer;
13019
13023
  const noActiveTurn = !this.currentTurnScope;
13020
13024
  const looksIdleChrome = /(^|\n)\s*[❯›>]\s*(?:\n|$)/m.test(effectiveScreenText) || /accept edits on/i.test(effectiveScreenText) && (/Update available!/i.test(screenText) || /\/effort/i.test(screenText) || /^.*➜\s+\S+/m.test(effectiveScreenText));
13021
- if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome) {
13025
+ if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome && !parsedShowsLiveAssistantProgress) {
13022
13026
  return;
13023
13027
  }
13024
13028
  if (prevStatus === "waiting_approval") {
@@ -13352,11 +13356,17 @@ var init_provider_cli_adapter = __esm({
13352
13356
  return null;
13353
13357
  }
13354
13358
  }
13359
+ projectEffectiveStatus(startupModal = null) {
13360
+ if (this.parseErrorMessage) return "error";
13361
+ if (startupModal) return "waiting_approval";
13362
+ if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
13363
+ return this.currentStatus;
13364
+ }
13355
13365
  // ─── Public API (CliAdapter) ───────────────────
13356
13366
  getStatus() {
13357
13367
  const screenText = this.terminalScreen.getText() || "";
13358
13368
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
13359
- const effectiveStatus = this.parseErrorMessage ? "error" : startupModal ? "waiting_approval" : this.currentStatus;
13369
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
13360
13370
  return {
13361
13371
  status: effectiveStatus,
13362
13372
  messages: [...this.committedMessages],
@@ -14063,7 +14073,7 @@ ${data.message || ""}`.trim();
14063
14073
  }
14064
14074
  this.setStatus("generating", "approval_resolved");
14065
14075
  this.onStatusChange?.();
14066
- const startupTrustModal = /Quick safety check|project trust|trust (?:this project|the contents of this directory|the files in this folder)/i.test(String(modal?.message || ""));
14076
+ const startupTrustModal = /Quick safety check|project trust|Confirm Claude Code project trust|trust (?:this project|the contents of this directory|the files in this folder)/i.test(String(modal?.message || ""));
14067
14077
  if (startupTrustModal && buttonIndex in this.approvalKeys) {
14068
14078
  this.ptyProcess.write(`${this.approvalKeys[buttonIndex]}\r`);
14069
14079
  } else if (this.shouldResolveModalWithEnter(modal, buttonIndex)) {
@@ -14089,7 +14099,7 @@ ${data.message || ""}`.trim();
14089
14099
  getDebugState() {
14090
14100
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
14091
14101
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
14092
- const effectiveStatus = startupModal ? "waiting_approval" : this.currentStatus;
14102
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
14093
14103
  const effectiveReady = this.ready || !!startupModal;
14094
14104
  return {
14095
14105
  type: this.cliType,
@@ -38241,6 +38251,10 @@ var init_reporter = __esm({
38241
38251
  }
38242
38252
  }
38243
38253
  onStatusChange() {
38254
+ if (this.deps.p2p?.isConnected) {
38255
+ this.resetP2PHash();
38256
+ this.sendUnifiedStatusReport({ p2pOnly: true, reason: "status-change" }).catch((e) => LOG.warn("Status", `Immediate P2P status send failed: ${e?.message}`));
38257
+ }
38244
38258
  this.throttledReport();
38245
38259
  }
38246
38260
  throttledReport() {
@@ -38338,10 +38352,12 @@ var init_reporter = __esm({
38338
38352
  }
38339
38353
  async sendUnifiedStatusReport(opts) {
38340
38354
  const { serverConn, p2p } = this.deps;
38341
- if (!serverConn?.isConnected()) return;
38355
+ const serverConnected = !!serverConn?.isConnected();
38356
+ const p2pConnected = !!p2p?.isConnected;
38357
+ if (!serverConnected && !p2pConnected) return;
38342
38358
  this.lastStatusSentAt = Date.now();
38343
38359
  const now = this.lastStatusSentAt;
38344
- const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
38360
+ const target = opts?.p2pOnly ? "P2P" : serverConnected ? "P2P+Server" : "P2P";
38345
38361
  const allStates = this.deps.instanceManager.collectAllStates();
38346
38362
  const ideStates = allStates.filter((s) => s.category === "ide");
38347
38363
  const cliStates = allStates.filter((s) => s.category === "cli");
@@ -38420,6 +38436,7 @@ var init_reporter = __esm({
38420
38436
  ...wsPayload,
38421
38437
  timestamp: void 0
38422
38438
  }));
38439
+ if (!serverConnected || !serverConn) return;
38423
38440
  if (!opts?.forceServer && wsHash === this.lastServerStatusHash) {
38424
38441
  LOG.debug("Server", `skip duplicate status_report${opts?.reason ? ` (${opts.reason})` : ""}`);
38425
38442
  return;
@@ -86501,7 +86518,7 @@ var init_adhdev_daemon = __esm({
86501
86518
  init_version();
86502
86519
  init_src();
86503
86520
  init_runtime_defaults();
86504
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.89" });
86521
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.91" });
86505
86522
  AdhdevDaemon = class _AdhdevDaemon {
86506
86523
  localHttpServer = null;
86507
86524
  localWss = null;