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/index.js CHANGED
@@ -7310,10 +7310,11 @@ async function handleReadChat(h, args) {
7310
7310
  const parsedRecord = parsedStatus && typeof parsedStatus === "object" ? parsedStatus : null;
7311
7311
  const adapterStatus = adapter.getStatus();
7312
7312
  const shouldPreferAdapterMessages = Array.isArray(adapterStatus.messages) && adapterStatus.messages.length > 0 && Array.isArray(parsedRecord?.messages) && adapterStatus.messages.length > parsedRecord.messages.length;
7313
+ const parsedShowsApproval = hasNonEmptyModalButtons(parsedRecord?.activeModal) && parsedRecord?.status === "waiting_approval";
7313
7314
  const status = parsedRecord ? {
7314
7315
  ...parsedRecord,
7315
7316
  messages: shouldPreferAdapterMessages ? adapterStatus.messages : parsedRecord.messages,
7316
- status: adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
7317
+ status: parsedShowsApproval ? parsedRecord.status : adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
7317
7318
  activeModal: parsedRecord.activeModal || adapterStatus.activeModal
7318
7319
  } : adapterStatus;
7319
7320
  const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
@@ -10999,8 +11000,8 @@ function buildCliParseInput(options) {
10999
11000
  scope,
11000
11001
  runtimeSettings
11001
11002
  } = options;
11002
- const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
11003
- const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
11003
+ const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
11004
+ const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
11004
11005
  const screenText = terminalScreenText;
11005
11006
  const recentBuffer = buffer.slice(-1e3) || recentOutputBuffer;
11006
11007
  return {
@@ -11032,8 +11033,8 @@ function summarizeCliTraceMessages(messages, limit = 3) {
11032
11033
  }
11033
11034
  function buildCliTraceParseSnapshot(options) {
11034
11035
  const { accumulatedBuffer, accumulatedRawBuffer, responseBuffer, partialResponse, scope } = options;
11035
- const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
11036
- const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
11036
+ const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
11037
+ const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
11037
11038
  return {
11038
11039
  currentTurnScope: scope || null,
11039
11040
  responseBuffer: summarizeCliTraceText(responseBuffer, 1200),
@@ -11697,6 +11698,7 @@ var init_provider_cli_adapter = __esm({
11697
11698
  looksLikeClaudeGeneratingLine(line) {
11698
11699
  const trimmed = String(line || "").trim();
11699
11700
  if (!trimmed) return false;
11701
+ if (/^⏵⏵\s+accept edits on/i.test(trimmed)) return false;
11700
11702
  if (/esc to (cancel|interrupt|stop)/i.test(trimmed)) return true;
11701
11703
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+\S+.*\b(?:thinking|thought for \d+s?)\b/i.test(trimmed)) return true;
11702
11704
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+[A-Z][A-Za-z-]{3,}ing\b.*(?:…|\.{3})/u.test(trimmed)) return true;
@@ -11906,14 +11908,15 @@ var init_provider_cli_adapter = __esm({
11906
11908
  return;
11907
11909
  }
11908
11910
  const startupModal = this.getStartupConfirmationModal(screenText);
11909
- const modal = this.runParseApproval(tail) || startupModal;
11910
- const rawScriptStatus = this.runDetectStatus(tail);
11911
- const scriptStatus = startupModal ? "waiting_approval" : rawScriptStatus;
11912
11911
  const parsedTranscript = this.parseCurrentTranscript(
11913
11912
  this.committedMessages,
11914
11913
  this.responseBuffer,
11915
11914
  this.currentTurnScope
11916
11915
  );
11916
+ const parsedModal = parsedTranscript?.activeModal && Array.isArray(parsedTranscript.activeModal.buttons) && parsedTranscript.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsedTranscript.activeModal : null;
11917
+ const modal = this.runParseApproval(tail) || parsedModal || startupModal;
11918
+ const rawScriptStatus = this.runDetectStatus(tail);
11919
+ const scriptStatus = startupModal ? "waiting_approval" : parsedModal && parsedTranscript?.status === "waiting_approval" ? "waiting_approval" : rawScriptStatus;
11917
11920
  const parsedMessages = Array.isArray(parsedTranscript?.messages) ? normalizeCliParsedMessages(parsedTranscript.messages, {
11918
11921
  committedMessages: this.committedMessages,
11919
11922
  scope: this.currentTurnScope,
@@ -11923,6 +11926,7 @@ var init_provider_cli_adapter = __esm({
11923
11926
  return;
11924
11927
  }
11925
11928
  const lastParsedAssistant = [...parsedMessages].reverse().find((message) => message.role === "assistant");
11929
+ const parsedShowsLiveAssistantProgress = parsedTranscript?.status === "generating" && !!lastParsedAssistant && parsedMessages.length > this.committedMessages.length;
11926
11930
  const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet || this.currentTurnScope?.prompt || "");
11927
11931
  this.recordTrace("settled", {
11928
11932
  tail: summarizeCliTraceText(tail, 500),
@@ -12009,7 +12013,7 @@ var init_provider_cli_adapter = __esm({
12009
12013
  `[${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)}`
12010
12014
  );
12011
12015
  }
12012
- const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate);
12016
+ const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate) && !(parsedTranscript?.status === "idle" && !!lastParsedAssistant);
12013
12017
  if (shouldHoldGenerating) {
12014
12018
  this.clearIdleFinishCandidate("hold_generating_recent_activity");
12015
12019
  this.setStatus("generating", "recent_activity_hold");
@@ -12077,7 +12081,7 @@ var init_provider_cli_adapter = __esm({
12077
12081
  const effectiveScreenText = screenText || this.accumulatedBuffer;
12078
12082
  const noActiveTurn = !this.currentTurnScope;
12079
12083
  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));
12080
- if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome) {
12084
+ if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome && !parsedShowsLiveAssistantProgress) {
12081
12085
  return;
12082
12086
  }
12083
12087
  if (prevStatus === "waiting_approval") {
@@ -12411,11 +12415,17 @@ var init_provider_cli_adapter = __esm({
12411
12415
  return null;
12412
12416
  }
12413
12417
  }
12418
+ projectEffectiveStatus(startupModal = null) {
12419
+ if (this.parseErrorMessage) return "error";
12420
+ if (startupModal) return "waiting_approval";
12421
+ if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
12422
+ return this.currentStatus;
12423
+ }
12414
12424
  // ─── Public API (CliAdapter) ───────────────────
12415
12425
  getStatus() {
12416
12426
  const screenText = this.terminalScreen.getText() || "";
12417
12427
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
12418
- const effectiveStatus = this.parseErrorMessage ? "error" : startupModal ? "waiting_approval" : this.currentStatus;
12428
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
12419
12429
  return {
12420
12430
  status: effectiveStatus,
12421
12431
  messages: [...this.committedMessages],
@@ -13122,7 +13132,7 @@ ${data.message || ""}`.trim();
13122
13132
  }
13123
13133
  this.setStatus("generating", "approval_resolved");
13124
13134
  this.onStatusChange?.();
13125
- 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 || ""));
13135
+ 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 || ""));
13126
13136
  if (startupTrustModal && buttonIndex in this.approvalKeys) {
13127
13137
  this.ptyProcess.write(`${this.approvalKeys[buttonIndex]}\r`);
13128
13138
  } else if (this.shouldResolveModalWithEnter(modal, buttonIndex)) {
@@ -13148,7 +13158,7 @@ ${data.message || ""}`.trim();
13148
13158
  getDebugState() {
13149
13159
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
13150
13160
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
13151
- const effectiveStatus = startupModal ? "waiting_approval" : this.currentStatus;
13161
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
13152
13162
  const effectiveReady = this.ready || !!startupModal;
13153
13163
  return {
13154
13164
  type: this.cliType,
@@ -37300,6 +37310,10 @@ var init_reporter = __esm({
37300
37310
  }
37301
37311
  }
37302
37312
  onStatusChange() {
37313
+ if (this.deps.p2p?.isConnected) {
37314
+ this.resetP2PHash();
37315
+ this.sendUnifiedStatusReport({ p2pOnly: true, reason: "status-change" }).catch((e) => LOG.warn("Status", `Immediate P2P status send failed: ${e?.message}`));
37316
+ }
37303
37317
  this.throttledReport();
37304
37318
  }
37305
37319
  throttledReport() {
@@ -37397,10 +37411,12 @@ var init_reporter = __esm({
37397
37411
  }
37398
37412
  async sendUnifiedStatusReport(opts) {
37399
37413
  const { serverConn, p2p } = this.deps;
37400
- if (!serverConn?.isConnected()) return;
37414
+ const serverConnected = !!serverConn?.isConnected();
37415
+ const p2pConnected = !!p2p?.isConnected;
37416
+ if (!serverConnected && !p2pConnected) return;
37401
37417
  this.lastStatusSentAt = Date.now();
37402
37418
  const now = this.lastStatusSentAt;
37403
- const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
37419
+ const target = opts?.p2pOnly ? "P2P" : serverConnected ? "P2P+Server" : "P2P";
37404
37420
  const allStates = this.deps.instanceManager.collectAllStates();
37405
37421
  const ideStates = allStates.filter((s) => s.category === "ide");
37406
37422
  const cliStates = allStates.filter((s) => s.category === "cli");
@@ -37479,6 +37495,7 @@ var init_reporter = __esm({
37479
37495
  ...wsPayload,
37480
37496
  timestamp: void 0
37481
37497
  }));
37498
+ if (!serverConnected || !serverConn) return;
37482
37499
  if (!opts?.forceServer && wsHash === this.lastServerStatusHash) {
37483
37500
  LOG.debug("Server", `skip duplicate status_report${opts?.reason ? ` (${opts.reason})` : ""}`);
37484
37501
  return;
@@ -54796,7 +54813,7 @@ var init_adhdev_daemon = __esm({
54796
54813
  init_version();
54797
54814
  init_src();
54798
54815
  init_runtime_defaults();
54799
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.89" });
54816
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.91" });
54800
54817
  AdhdevDaemon = class _AdhdevDaemon {
54801
54818
  localHttpServer = null;
54802
54819
  localWss = null;