@adhdev/daemon-core 0.8.88 → 0.8.90

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.mjs CHANGED
@@ -1662,8 +1662,8 @@ function buildCliParseInput(options) {
1662
1662
  scope,
1663
1663
  runtimeSettings
1664
1664
  } = options;
1665
- const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
1666
- const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
1665
+ const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
1666
+ const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
1667
1667
  const screenText = terminalScreenText;
1668
1668
  const recentBuffer = buffer.slice(-1e3) || recentOutputBuffer;
1669
1669
  return {
@@ -1695,8 +1695,8 @@ function summarizeCliTraceMessages(messages, limit = 3) {
1695
1695
  }
1696
1696
  function buildCliTraceParseSnapshot(options) {
1697
1697
  const { accumulatedBuffer, accumulatedRawBuffer, responseBuffer, partialResponse, scope } = options;
1698
- const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
1699
- const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
1698
+ const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
1699
+ const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
1700
1700
  return {
1701
1701
  currentTurnScope: scope || null,
1702
1702
  responseBuffer: summarizeCliTraceText(responseBuffer, 1200),
@@ -2359,6 +2359,7 @@ var init_provider_cli_adapter = __esm({
2359
2359
  looksLikeClaudeGeneratingLine(line) {
2360
2360
  const trimmed = String(line || "").trim();
2361
2361
  if (!trimmed) return false;
2362
+ if (/^⏵⏵\s+accept edits on/i.test(trimmed)) return false;
2362
2363
  if (/esc to (cancel|interrupt|stop)/i.test(trimmed)) return true;
2363
2364
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+\S+.*\b(?:thinking|thought for \d+s?)\b/i.test(trimmed)) return true;
2364
2365
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+[A-Z][A-Za-z-]{3,}ing\b.*(?:…|\.{3})/u.test(trimmed)) return true;
@@ -2459,8 +2460,7 @@ var init_provider_cli_adapter = __esm({
2459
2460
  const buttons = Array.isArray(modal.buttons) ? modal.buttons : [];
2460
2461
  if (buttons.length !== 1) return false;
2461
2462
  const buttonLabel = String(buttons[0] || "").trim();
2462
- const modalText = `${modal.message || ""} ${buttonLabel}`.trim();
2463
- return looksLikeConfirmOnlyLabel(buttonLabel) || /Quick safety check|project trust|trust (?:this project|the contents of this directory|the files in this folder)|Enter to confirm/i.test(modalText);
2463
+ return looksLikeConfirmOnlyLabel(buttonLabel);
2464
2464
  }
2465
2465
  async waitForInteractivePrompt(maxWaitMs = 5e3) {
2466
2466
  const startedAt = Date.now();
@@ -2672,7 +2672,7 @@ var init_provider_cli_adapter = __esm({
2672
2672
  `[${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)}`
2673
2673
  );
2674
2674
  }
2675
- const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate);
2675
+ const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate) && !(parsedTranscript?.status === "idle" && !!lastParsedAssistant);
2676
2676
  if (shouldHoldGenerating) {
2677
2677
  this.clearIdleFinishCandidate("hold_generating_recent_activity");
2678
2678
  this.setStatus("generating", "recent_activity_hold");
@@ -3074,13 +3074,22 @@ var init_provider_cli_adapter = __esm({
3074
3074
  return null;
3075
3075
  }
3076
3076
  }
3077
+ projectEffectiveStatus(startupModal = null) {
3078
+ if (this.parseErrorMessage) return "error";
3079
+ if (startupModal) return "waiting_approval";
3080
+ if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
3081
+ return this.currentStatus;
3082
+ }
3077
3083
  // ─── Public API (CliAdapter) ───────────────────
3078
3084
  getStatus() {
3085
+ const screenText = this.terminalScreen.getText() || "";
3086
+ const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
3087
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
3079
3088
  return {
3080
- status: this.parseErrorMessage ? "error" : this.currentStatus,
3089
+ status: effectiveStatus,
3081
3090
  messages: [...this.committedMessages],
3082
3091
  workingDir: this.workingDir,
3083
- activeModal: this.activeModal,
3092
+ activeModal: startupModal || this.activeModal,
3084
3093
  errorMessage: this.parseErrorMessage || void 0,
3085
3094
  errorReason: this.parseErrorMessage ? "parse_error" : void 0
3086
3095
  };
@@ -3134,7 +3143,8 @@ var init_provider_cli_adapter = __esm({
3134
3143
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
3135
3144
  }));
3136
3145
  const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
3137
- const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && this.currentStatus === "idle" && parsedHydratedMessages.length > committedHydratedMessages.length && !!parsedLastAssistant;
3146
+ const visibleIdlePrompt = this.looksLikeVisibleIdlePrompt(screenText);
3147
+ const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedHydratedMessages.length > committedHydratedMessages.length && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
3138
3148
  if (shouldAdoptParsedIdleReplay) {
3139
3149
  this.committedMessages = normalizeCliParsedMessages(parsed.messages, {
3140
3150
  committedMessages: this.committedMessages,
@@ -3142,6 +3152,18 @@ var init_provider_cli_adapter = __esm({
3142
3152
  lastOutputAt: this.lastOutputAt
3143
3153
  });
3144
3154
  this.syncMessageViews();
3155
+ if (this.currentStatus !== "idle" || this.isWaitingForResponse) {
3156
+ this.responseBuffer = "";
3157
+ this.isWaitingForResponse = false;
3158
+ this.responseSettleIgnoreUntil = 0;
3159
+ this.submitRetryUsed = false;
3160
+ this.submitRetryPromptSnippet = "";
3161
+ this.finishRetryCount = 0;
3162
+ this.currentTurnScope = null;
3163
+ this.activeModal = null;
3164
+ this.setStatus("idle", "parsed_idle_replay_commit");
3165
+ this.onStatusChange?.();
3166
+ }
3145
3167
  }
3146
3168
  const effectiveCommittedHydratedMessages = shouldAdoptParsedIdleReplay ? this.committedMessages.map((message, index) => buildChatMessage({
3147
3169
  ...message,
@@ -3752,8 +3774,9 @@ ${data.message || ""}`.trim();
3752
3774
  this.ptyProcess?.write(data);
3753
3775
  }
3754
3776
  resolveModal(buttonIndex) {
3755
- if (!this.ptyProcess || this.currentStatus !== "waiting_approval" && !this.activeModal) return;
3756
- const modal = this.activeModal;
3777
+ const screenText = this.terminalScreen.getText() || "";
3778
+ const modal = this.activeModal || this.getStartupConfirmationModal(screenText);
3779
+ if (!this.ptyProcess || this.currentStatus !== "waiting_approval" && !modal) return;
3757
3780
  this.clearIdleFinishCandidate("resolve_modal");
3758
3781
  this.recordTrace("resolve_modal", {
3759
3782
  buttonIndex,
@@ -3768,7 +3791,10 @@ ${data.message || ""}`.trim();
3768
3791
  }
3769
3792
  this.setStatus("generating", "approval_resolved");
3770
3793
  this.onStatusChange?.();
3771
- if (this.shouldResolveModalWithEnter(modal, buttonIndex)) {
3794
+ 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 || ""));
3795
+ if (startupTrustModal && buttonIndex in this.approvalKeys) {
3796
+ this.ptyProcess.write(`${this.approvalKeys[buttonIndex]}\r`);
3797
+ } else if (this.shouldResolveModalWithEnter(modal, buttonIndex)) {
3772
3798
  this.ptyProcess.write("\r");
3773
3799
  } else if (buttonIndex in this.approvalKeys) {
3774
3800
  this.ptyProcess.write(this.approvalKeys[buttonIndex]);
@@ -3789,20 +3815,24 @@ ${data.message || ""}`.trim();
3789
3815
  }
3790
3816
  }
3791
3817
  getDebugState() {
3818
+ const screenText = sanitizeTerminalText(this.terminalScreen.getText());
3819
+ const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
3820
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
3821
+ const effectiveReady = this.ready || !!startupModal;
3792
3822
  return {
3793
3823
  type: this.cliType,
3794
3824
  name: this.cliName,
3795
3825
  providerResolution: this.providerResolutionMeta,
3796
- status: this.currentStatus,
3797
- ready: this.ready,
3826
+ status: effectiveStatus,
3827
+ ready: effectiveReady,
3798
3828
  startupParseGate: this.startupParseGate,
3799
3829
  spawnAt: this.spawnAt,
3800
3830
  workingDir: this.workingDir,
3801
- messages: this.messages.slice(-20),
3802
- committedMessages: this.committedMessages.slice(-20),
3803
- structuredMessages: this.structuredMessages.slice(-20),
3831
+ messages: this.messages,
3832
+ committedMessages: this.committedMessages,
3833
+ structuredMessages: this.structuredMessages,
3804
3834
  messageCount: this.committedMessages.length,
3805
- screenText: sanitizeTerminalText(this.terminalScreen.getText()).slice(-4e3),
3835
+ screenText: screenText.slice(-4e3),
3806
3836
  currentTurnScope: this.currentTurnScope,
3807
3837
  startupBuffer: this.startupBuffer.slice(-4e3),
3808
3838
  recentOutputBuffer: this.recentOutputBuffer.slice(-500),
@@ -3817,7 +3847,7 @@ ${data.message || ""}`.trim();
3817
3847
  lastScreenChangeAt: this.lastScreenChangeAt,
3818
3848
  lastScreenSnapshot: this.lastScreenSnapshot.slice(-500),
3819
3849
  isWaitingForResponse: this.isWaitingForResponse,
3820
- activeModal: this.activeModal,
3850
+ activeModal: startupModal || this.activeModal,
3821
3851
  lastApprovalResolvedAt: this.lastApprovalResolvedAt,
3822
3852
  sendDelayMs: this.sendDelayMs,
3823
3853
  sendKey: this.sendKey,