deepcode-ai 1.2.12 → 1.2.17

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
@@ -1652,7 +1652,7 @@ var require_cli_spinners = __commonJS({
1652
1652
 
1653
1653
  // ../../packages/cli/dist/index.js
1654
1654
  import { render as render3 } from "ink";
1655
- import React40 from "react";
1655
+ import React42 from "react";
1656
1656
  import { Command as Command2 } from "commander";
1657
1657
 
1658
1658
  // ../../packages/core/dist/index.js
@@ -6579,43 +6579,43 @@ var PermissionGateway = class _PermissionGateway {
6579
6579
  }
6580
6580
  this.pendingApprovals.clear();
6581
6581
  }
6582
- async ensure(check) {
6583
- const decision = await this.check(check);
6582
+ async ensure(check2) {
6583
+ const decision = await this.check(check2);
6584
6584
  if (!decision.allowed) {
6585
- throw new PermissionDeniedError(decision.reason ?? `Operation denied: ${check.operation}`);
6585
+ throw new PermissionDeniedError(decision.reason ?? `Operation denied: ${check2.operation}`);
6586
6586
  }
6587
6587
  }
6588
- async check(check) {
6589
- const pathAccess = check.path ? this.pathSecurity.classify(check.path) : "allowed";
6588
+ async check(check2) {
6589
+ const pathAccess = check2.path ? this.pathSecurity.classify(check2.path) : "allowed";
6590
6590
  if (pathAccess === "blacklisted") {
6591
- await this.audit.log({ operation: check.operation, path: check.path, result: "denied", reason: "path_blacklist" });
6591
+ await this.audit.log({ operation: check2.operation, path: check2.path, result: "denied", reason: "path_blacklist" });
6592
6592
  return { allowed: false, reason: "Path blocked by blacklist (paths.blacklist)." };
6593
6593
  }
6594
- const mode = this.resolveMode(check);
6594
+ const mode = this.resolveMode(check2);
6595
6595
  if (mode === "deny") {
6596
- await this.audit.log({ operation: check.operation, path: check.path, result: "denied", reason: "config" });
6596
+ await this.audit.log({ operation: check2.operation, path: check2.path, result: "denied", reason: "config" });
6597
6597
  this.eventBus.emit("activity", {
6598
6598
  id: createId("activity"),
6599
6599
  type: "permission_denied",
6600
- message: `Permission denied by configuration: ${check.operation} (${check.kind})`,
6601
- metadata: { operation: check.operation, kind: check.kind, reason: "config_deny" },
6600
+ message: `Permission denied by configuration: ${check2.operation} (${check2.kind})`,
6601
+ metadata: { operation: check2.operation, kind: check2.kind, reason: "config_deny" },
6602
6602
  createdAt: nowIso()
6603
6603
  });
6604
- return { allowed: false, reason: configDeniedReason(check) };
6604
+ return { allowed: false, reason: configDeniedReason(check2) };
6605
6605
  }
6606
- const sessionKey = check.path ? `${check.operation}:${check.path}` : `${check.operation}`;
6606
+ const sessionKey = check2.path ? `${check2.operation}:${check2.path}` : `${check2.operation}`;
6607
6607
  if (this.alwaysAllowSet.has(sessionKey)) {
6608
- await this.audit.log({ operation: check.operation, path: check.path, result: "allowed", reason: "always_allow" });
6608
+ await this.audit.log({ operation: check2.operation, path: check2.path, result: "allowed", reason: "always_allow" });
6609
6609
  return { allowed: true };
6610
6610
  }
6611
6611
  if (this.sessionAllowSet.has(sessionKey)) {
6612
- await this.audit.log({ operation: check.operation, path: check.path, result: "allowed", reason: "session_allow" });
6612
+ await this.audit.log({ operation: check2.operation, path: check2.path, result: "allowed", reason: "session_allow" });
6613
6613
  return { allowed: true };
6614
6614
  }
6615
6615
  if (mode === "allow" && pathAccess === "allowed") {
6616
6616
  await this.audit.log({
6617
- operation: check.operation,
6618
- path: check.path,
6617
+ operation: check2.operation,
6618
+ path: check2.path,
6619
6619
  result: "allowed"
6620
6620
  });
6621
6621
  return { allowed: true };
@@ -6623,56 +6623,56 @@ var PermissionGateway = class _PermissionGateway {
6623
6623
  if (mode === "allow" && pathAccess === "outside_whitelist") {
6624
6624
  if (!this.interactive) {
6625
6625
  await this.audit.log({
6626
- operation: check.operation,
6627
- path: check.path,
6626
+ operation: check2.operation,
6627
+ path: check2.path,
6628
6628
  result: "denied",
6629
6629
  reason: "path_outside_whitelist"
6630
6630
  });
6631
6631
  this.eventBus.emit("activity", {
6632
6632
  id: createId("activity"),
6633
6633
  type: "permission_denied",
6634
- message: `Permission denied (path outside whitelist, non-interactive): ${check.operation} (${check.kind})`,
6635
- metadata: { operation: check.operation, kind: check.kind, reason: "path_outside_whitelist" },
6634
+ message: `Permission denied (path outside whitelist, non-interactive): ${check2.operation} (${check2.kind})`,
6635
+ metadata: { operation: check2.operation, kind: check2.kind, reason: "path_outside_whitelist" },
6636
6636
  createdAt: nowIso()
6637
6637
  });
6638
6638
  return {
6639
6639
  allowed: false,
6640
- reason: outsideWhitelistReason(check)
6640
+ reason: outsideWhitelistReason(check2)
6641
6641
  };
6642
6642
  }
6643
6643
  }
6644
6644
  if (!this.interactive) {
6645
6645
  await this.audit.log({
6646
- operation: check.operation,
6647
- path: check.path,
6646
+ operation: check2.operation,
6647
+ path: check2.path,
6648
6648
  result: "denied",
6649
6649
  reason: pathAccess === "outside_whitelist" ? "path_outside_whitelist" : "non_interactive"
6650
6650
  });
6651
6651
  this.eventBus.emit("activity", {
6652
6652
  id: createId("activity"),
6653
6653
  type: "permission_denied",
6654
- message: `Permission denied (non-interactive): ${check.operation} (${check.kind})`,
6655
- metadata: { operation: check.operation, kind: check.kind, reason: pathAccess === "outside_whitelist" ? "path_outside_whitelist" : "non_interactive" },
6654
+ message: `Permission denied (non-interactive): ${check2.operation} (${check2.kind})`,
6655
+ metadata: { operation: check2.operation, kind: check2.kind, reason: pathAccess === "outside_whitelist" ? "path_outside_whitelist" : "non_interactive" },
6656
6656
  createdAt: nowIso()
6657
6657
  });
6658
6658
  return {
6659
6659
  allowed: false,
6660
- reason: pathAccess === "outside_whitelist" ? outsideWhitelistReason(check) : nonInteractiveApprovalReason(check)
6660
+ reason: pathAccess === "outside_whitelist" ? outsideWhitelistReason(check2) : nonInteractiveApprovalReason(check2)
6661
6661
  };
6662
6662
  }
6663
6663
  const request = {
6664
6664
  id: createId("approval"),
6665
- operation: check.operation,
6666
- level: check.kind,
6667
- path: check.path,
6665
+ operation: check2.operation,
6666
+ level: check2.kind,
6667
+ path: check2.path,
6668
6668
  details: {
6669
- ...check.details,
6669
+ ...check2.details,
6670
6670
  ...pathAccess === "outside_whitelist" ? {
6671
6671
  pathPolicy: "outside_whitelist",
6672
6672
  pathMessage: "Path is outside the configured whitelist for this workspace"
6673
6673
  } : {}
6674
6674
  },
6675
- preview: buildApprovalPreview(check),
6675
+ preview: buildApprovalPreview(check2),
6676
6676
  createdAt: nowIso()
6677
6677
  };
6678
6678
  const APPROVAL_TIMEOUT_MS = 5 * 60 * 1e3;
@@ -6688,11 +6688,11 @@ var PermissionGateway = class _PermissionGateway {
6688
6688
  this.pendingApprovals.delete(request.id);
6689
6689
  reject(new Error("Approval check aborted"));
6690
6690
  };
6691
- check.signal?.addEventListener("abort", onAbort, { once: true });
6691
+ check2.signal?.addEventListener("abort", onAbort, { once: true });
6692
6692
  const cleanup = this.eventBus.on("approval:decision", (payload) => {
6693
6693
  if (payload.requestId === request.id) {
6694
6694
  clearTimeout(timeoutId);
6695
- check.signal?.removeEventListener("abort", onAbort);
6695
+ check2.signal?.removeEventListener("abort", onAbort);
6696
6696
  cleanup();
6697
6697
  this.pendingApprovals.delete(request.id);
6698
6698
  resolve3(payload.decision);
@@ -6712,66 +6712,66 @@ var PermissionGateway = class _PermissionGateway {
6712
6712
  this.alwaysAllowSet.add(sessionKey);
6713
6713
  }
6714
6714
  await this.audit.log({
6715
- operation: check.operation,
6716
- path: check.path,
6715
+ operation: check2.operation,
6716
+ path: check2.path,
6717
6717
  result: decision.allowed ? "approved" : "denied",
6718
6718
  reason: decision.reason,
6719
6719
  details: { requestId: request.id }
6720
6720
  });
6721
6721
  return decision;
6722
6722
  }
6723
- resolveMode(check) {
6724
- const agentMode = check.agentMode ?? this.config.agentMode;
6723
+ resolveMode(check2) {
6724
+ const agentMode = check2.agentMode ?? this.config.agentMode;
6725
6725
  const agentPermissions = this.config.agentPermissions?.[agentMode];
6726
6726
  if (agentPermissions) {
6727
- if (agentPermissions.askBeforeExecute && (check.kind === "shell" || check.kind === "dangerous")) {
6727
+ if (agentPermissions.askBeforeExecute && (check2.kind === "shell" || check2.kind === "dangerous")) {
6728
6728
  return "ask";
6729
6729
  }
6730
- if (check.kind === "shell" && agentPermissions.shell) {
6730
+ if (check2.kind === "shell" && agentPermissions.shell) {
6731
6731
  return agentPermissions.shell;
6732
6732
  }
6733
- if (check.kind === "dangerous" && agentPermissions.dangerous) {
6733
+ if (check2.kind === "dangerous" && agentPermissions.dangerous) {
6734
6734
  return agentPermissions.dangerous;
6735
6735
  }
6736
- if (check.kind === "write" && agentPermissions.write) {
6736
+ if (check2.kind === "write" && agentPermissions.write) {
6737
6737
  return agentPermissions.write;
6738
6738
  }
6739
- if (check.kind === "read" && agentPermissions.read) {
6739
+ if (check2.kind === "read" && agentPermissions.read) {
6740
6740
  return agentPermissions.read;
6741
6741
  }
6742
- if (check.kind === "git_local" && agentPermissions.gitLocal) {
6742
+ if (check2.kind === "git_local" && agentPermissions.gitLocal) {
6743
6743
  return agentPermissions.gitLocal;
6744
6744
  }
6745
6745
  }
6746
- if (check.kind === "shell" && isShellWhitelisted(this.config.permissions.allowShell, check.operation)) {
6746
+ if (check2.kind === "shell" && isShellWhitelisted(this.config.permissions.allowShell, check2.operation)) {
6747
6747
  return "allow";
6748
6748
  }
6749
- if (check.kind === "read") return this.config.permissions.read;
6750
- if (check.kind === "write") return this.config.permissions.write;
6751
- if (check.kind === "git_local") return this.config.permissions.gitLocal;
6752
- if (check.kind === "shell") return this.config.permissions.shell;
6749
+ if (check2.kind === "read") return this.config.permissions.read;
6750
+ if (check2.kind === "write") return this.config.permissions.write;
6751
+ if (check2.kind === "git_local") return this.config.permissions.gitLocal;
6752
+ if (check2.kind === "shell") return this.config.permissions.shell;
6753
6753
  return this.config.permissions.dangerous;
6754
6754
  }
6755
6755
  };
6756
- function buildApprovalPreview(check) {
6757
- if (check.kind === "shell" || check.kind === "dangerous") {
6756
+ function buildApprovalPreview(check2) {
6757
+ if (check2.kind === "shell" || check2.kind === "dangerous") {
6758
6758
  return {
6759
6759
  type: "shell_command",
6760
- command: check.operation,
6761
- args: typeof check.details?.command === "string" ? splitCommandPreview(check.details.command) : []
6760
+ command: check2.operation,
6761
+ args: typeof check2.details?.command === "string" ? splitCommandPreview(check2.details.command) : []
6762
6762
  };
6763
6763
  }
6764
- if (check.kind === "git_local") {
6764
+ if (check2.kind === "git_local") {
6765
6765
  return {
6766
6766
  type: "git_operation",
6767
- command: check.operation,
6768
- affectedFiles: typeof check.path === "string" ? [check.path] : []
6767
+ command: check2.operation,
6768
+ affectedFiles: typeof check2.path === "string" ? [check2.path] : []
6769
6769
  };
6770
6770
  }
6771
- if (check.kind === "write") {
6771
+ if (check2.kind === "write") {
6772
6772
  return {
6773
- type: check.operation === "edit_file" ? "file_edit" : "file_write",
6774
- affectedFiles: typeof check.path === "string" ? [check.path] : []
6773
+ type: check2.operation === "edit_file" ? "file_edit" : "file_write",
6774
+ affectedFiles: typeof check2.path === "string" ? [check2.path] : []
6775
6775
  };
6776
6776
  }
6777
6777
  return void 0;
@@ -6788,8 +6788,8 @@ function isShellWhitelisted(allowList, operation) {
6788
6788
  (allowedOperation) => normalizeShellPermissionOperation(allowedOperation) === normalizedOperation
6789
6789
  );
6790
6790
  }
6791
- function configDeniedReason(check) {
6792
- switch (check.kind) {
6791
+ function configDeniedReason(check2) {
6792
+ switch (check2.kind) {
6793
6793
  case "read":
6794
6794
  return 'Denied by configuration (permissions.read=deny). Set `permissions.read` to `"allow"` in `.deepcode/config.json`, for example: `{"permissions":{"read":"allow"}}`.';
6795
6795
  case "write":
@@ -6797,13 +6797,13 @@ function configDeniedReason(check) {
6797
6797
  case "git_local":
6798
6798
  return 'Denied by configuration (permissions.gitLocal=deny). Set `permissions.gitLocal` to `"allow"` in `.deepcode/config.json`, for example: `{"permissions":{"gitLocal":"allow"}}`.';
6799
6799
  case "shell":
6800
- return `Denied by configuration (permissions.shell=deny). Set \`permissions.shell\` to \`"allow"\` in \`.deepcode/config.json\`, or add the exact command to \`permissions.allowShell\`, for example: \`{"permissions":{"allowShell":["${normalizeShellPermissionOperation(check.operation)}"]}}\`.`;
6800
+ return `Denied by configuration (permissions.shell=deny). Set \`permissions.shell\` to \`"allow"\` in \`.deepcode/config.json\`, or add the exact command to \`permissions.allowShell\`, for example: \`{"permissions":{"allowShell":["${normalizeShellPermissionOperation(check2.operation)}"]}}\`.`;
6801
6801
  case "dangerous":
6802
6802
  return 'Denied by configuration (permissions.dangerous=deny). Re-run with `--yes` or set `permissions.dangerous` to `"ask"` in `.deepcode/config.json`, for example: `{"permissions":{"dangerous":"ask"}}`.';
6803
6803
  }
6804
6804
  }
6805
- function nonInteractiveApprovalReason(check) {
6806
- switch (check.kind) {
6805
+ function nonInteractiveApprovalReason(check2) {
6806
+ switch (check2.kind) {
6807
6807
  case "read":
6808
6808
  return 'Read operation requires approval in non-interactive mode. Use the interactive TUI/chat flow or set `permissions.read` to `"allow"` in `.deepcode/config.json`, for example: `{"permissions":{"read":"allow"}}`.';
6809
6809
  case "write":
@@ -6811,18 +6811,18 @@ function nonInteractiveApprovalReason(check) {
6811
6811
  case "git_local":
6812
6812
  return 'Git operation requires approval in non-interactive mode. Re-run with `--yes`, use the interactive TUI/chat flow, or set `permissions.gitLocal` to `"allow"` in `.deepcode/config.json`, for example: `{"permissions":{"gitLocal":"allow"}}`.';
6813
6813
  case "shell":
6814
- return `Shell command requires approval in non-interactive mode. Re-run with \`--yes\`, use the interactive TUI/chat flow, or add the exact command to \`permissions.allowShell\` in \`.deepcode/config.json\`, for example: \`{"permissions":{"allowShell":["${normalizeShellPermissionOperation(check.operation)}"]}}\`.`;
6814
+ return `Shell command requires approval in non-interactive mode. Re-run with \`--yes\`, use the interactive TUI/chat flow, or add the exact command to \`permissions.allowShell\` in \`.deepcode/config.json\`, for example: \`{"permissions":{"allowShell":["${normalizeShellPermissionOperation(check2.operation)}"]}}\`.`;
6815
6815
  case "dangerous":
6816
6816
  return "Dangerous operation requires approval in non-interactive mode. Re-run with `--yes` or use the interactive TUI/chat flow.";
6817
6817
  }
6818
6818
  }
6819
- function outsideWhitelistReason(check) {
6820
- const example = whitelistExampleForPath(check.path);
6819
+ function outsideWhitelistReason(check2) {
6820
+ const example = whitelistExampleForPath(check2.path);
6821
6821
  const base = `Path is outside the configured whitelist (\`paths.whitelist\`) and requires approval. Add a matching entry to \`.deepcode/config.json\`, for example: \`{"paths":{"whitelist":["${example}"]}}\`.`;
6822
- if (check.kind === "read") {
6822
+ if (check2.kind === "read") {
6823
6823
  return `${base} Use the interactive TUI/chat flow or extend the whitelist.`;
6824
6824
  }
6825
- if (check.kind === "shell" || check.kind === "dangerous" || check.kind === "write" || check.kind === "git_local") {
6825
+ if (check2.kind === "shell" || check2.kind === "dangerous" || check2.kind === "write" || check2.kind === "git_local") {
6826
6826
  return `${base} Re-run with \`--yes\`, use the interactive TUI/chat flow, or extend the whitelist.`;
6827
6827
  }
6828
6828
  return `${base} Use the interactive TUI/chat flow or extend the whitelist.`;
@@ -7861,10 +7861,10 @@ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
7861
7861
  import fs2 from "fs";
7862
7862
  import os4 from "os";
7863
7863
  import path62 from "path";
7864
- import fs8 from "fs";
7865
- import path15 from "path";
7866
- import { isValidElement, useCallback as useCallback27, useEffect as useEffect28, useMemo as useMemo19, useRef as useRef18, useState as useState30 } from "react";
7867
- import { Box as Box41, Text as Text49, useInput as useInput6, useStdin as useStdin3 } from "ink";
7864
+ import fs12 from "fs";
7865
+ import path19 from "path";
7866
+ import { isValidElement, useCallback as useCallback28, useEffect as useEffect32, useMemo as useMemo19, useRef as useRef21, useState as useState34 } from "react";
7867
+ import { Box as Box52, Text as Text60, useInput as useInput6, useStdin as useStdin3 } from "ink";
7868
7868
  import os22 from "os";
7869
7869
  import path92 from "path";
7870
7870
  import fs22 from "fs";
@@ -8836,9 +8836,9 @@ import { access as access2, lstat as lstat4, open, readFile as readFile4, stat a
8836
8836
  import * as path82 from "path";
8837
8837
  import { promisify } from "util";
8838
8838
  import { useState as useState3, useRef, useCallback as useCallback3, useMemo as useMemo2 } from "react";
8839
- import { useCallback as useCallback8, useEffect as useEffect14, useMemo as useMemo6, useRef as useRef6, useState as useState12 } from "react";
8840
- import { Box as Box23, Static } from "ink";
8841
- import { Box as Box22, Text as Text25 } from "ink";
8839
+ import { useCallback as useCallback8, useEffect as useEffect15, useMemo as useMemo6, useRef as useRef6, useState as useState13 } from "react";
8840
+ import { Box as Box30, Static } from "ink";
8841
+ import { Box as Box29, Text as Text32 } from "ink";
8842
8842
  import { Box as Box8, Text as Text9 } from "ink";
8843
8843
 
8844
8844
  // ../../node_modules/.pnpm/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
@@ -9781,23 +9781,41 @@ import { Box as Box20, Text as Text23 } from "ink";
9781
9781
  import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
9782
9782
  import React21, { useContext as useContext5 } from "react";
9783
9783
  import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
9784
+ import { Box as Box22, Text as Text25 } from "ink";
9784
9785
  import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
9785
- import { createContext as createContext5, useContext as useContext6 } from "react";
9786
+ import { Box as Box23, Text as Text26 } from "ink";
9786
9787
  import { jsx as jsx28, jsxs as jsxs22 } from "react/jsx-runtime";
9787
- import { Box as Box31, Text as Text39, useIsScreenReaderEnabled as useIsScreenReaderEnabled3 } from "ink";
9788
+ import { Box as Box24, Text as Text27 } from "ink";
9789
+ import { Fragment as Fragment7, jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
9790
+ import { Box as Box25, Text as Text28 } from "ink";
9791
+ import { Fragment as Fragment8, jsx as jsx30, jsxs as jsxs24 } from "react/jsx-runtime";
9792
+ import React23 from "react";
9793
+ import { Box as Box26, Text as Text29 } from "ink";
9794
+ import { useEffect as useEffect14, useState as useState12 } from "react";
9795
+ import { jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
9796
+ import { Box as Box27, Text as Text30 } from "ink";
9797
+ import { jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
9798
+ import React24 from "react";
9799
+ import { Box as Box28, Text as Text31 } from "ink";
9800
+ import { jsx as jsx33, jsxs as jsxs27 } from "react/jsx-runtime";
9801
+ import { jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
9802
+ import { createContext as createContext5, useContext as useContext6 } from "react";
9803
+ import { jsx as jsx35, jsxs as jsxs29 } from "react/jsx-runtime";
9804
+ import { Box as Box31, Text as Text33 } from "ink";
9805
+ import { jsx as jsx36 } from "react/jsx-runtime";
9806
+ import { Box as Box39, Text as Text47, useIsScreenReaderEnabled as useIsScreenReaderEnabled3 } from "ink";
9788
9807
  import { useCallback as useCallback19, useState as useState24 } from "react";
9789
9808
  import { useRef as useRef8 } from "react";
9790
- import { Box as Box24, Text as Text26 } from "ink";
9791
- import { useEffect as useEffect15, useState as useState13 } from "react";
9809
+ import { Box as Box32, Text as Text34 } from "ink";
9792
9810
  import { useEffect as useEffect16, useRef as useRef7, useState as useState14 } from "react";
9793
- import { jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
9811
+ import { jsx as jsx37, jsxs as jsxs30 } from "react/jsx-runtime";
9794
9812
  import { useCallback as useCallback17, useEffect as useEffect23, useMemo as useMemo11, useState as useState21, useRef as useRef13 } from "react";
9795
- import { Box as Box27, Text as Text30 } from "ink";
9796
- import { Box as Box25, Text as Text28 } from "ink";
9797
- import React25 from "react";
9798
- import { Text as Text27 } from "ink";
9799
- import { jsx as jsx30, jsxs as jsxs24 } from "react/jsx-runtime";
9800
- import { jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
9813
+ import { Box as Box35, Text as Text38 } from "ink";
9814
+ import { Box as Box33, Text as Text36 } from "ink";
9815
+ import React27 from "react";
9816
+ import { Text as Text35 } from "ink";
9817
+ import { jsx as jsx38, jsxs as jsxs31 } from "react/jsx-runtime";
9818
+ import { jsx as jsx39, jsxs as jsxs32 } from "react/jsx-runtime";
9801
9819
  import { useState as useState15, useCallback as useCallback9 } from "react";
9802
9820
  import chalk3 from "chalk";
9803
9821
  import { useState as useState16, useEffect as useEffect17, useCallback as useCallback10 } from "react";
@@ -9814,21 +9832,21 @@ import * as path132 from "path";
9814
9832
  import { createContext as createContext6, useContext as useContext7 } from "react";
9815
9833
  import { createContext as createContext7, useContext as useContext8 } from "react";
9816
9834
  import { useCallback as useCallback16 } from "react";
9817
- import { Box as Box26, Text as Text29 } from "ink";
9835
+ import { Box as Box34, Text as Text37 } from "ink";
9818
9836
  import chalk2 from "chalk";
9819
- import { jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
9820
- import { Fragment as Fragment7, jsx as jsx33, jsxs as jsxs27 } from "react/jsx-runtime";
9821
- import { Box as Box28, Text as Text36 } from "ink";
9822
- import { Text as Text31 } from "ink";
9823
- import { Fragment as Fragment8, jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
9824
- import { Text as Text32 } from "ink";
9825
- import { jsx as jsx35, jsxs as jsxs29 } from "react/jsx-runtime";
9826
- import { Text as Text33 } from "ink";
9827
- import { jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
9828
- import { Text as Text34 } from "ink";
9829
- import { jsxs as jsxs31 } from "react/jsx-runtime";
9830
- import { Text as Text35 } from "ink";
9831
- import { jsxs as jsxs32 } from "react/jsx-runtime";
9837
+ import { jsx as jsx40, jsxs as jsxs33 } from "react/jsx-runtime";
9838
+ import { Fragment as Fragment9, jsx as jsx41, jsxs as jsxs34 } from "react/jsx-runtime";
9839
+ import { Box as Box36, Text as Text44 } from "ink";
9840
+ import { Text as Text39 } from "ink";
9841
+ import { Fragment as Fragment10, jsx as jsx42, jsxs as jsxs35 } from "react/jsx-runtime";
9842
+ import { Text as Text40 } from "ink";
9843
+ import { jsx as jsx43, jsxs as jsxs36 } from "react/jsx-runtime";
9844
+ import { Text as Text41 } from "ink";
9845
+ import { jsx as jsx44, jsxs as jsxs37 } from "react/jsx-runtime";
9846
+ import { Text as Text42 } from "ink";
9847
+ import { jsxs as jsxs38 } from "react/jsx-runtime";
9848
+ import { Text as Text43 } from "ink";
9849
+ import { jsxs as jsxs39 } from "react/jsx-runtime";
9832
9850
  import { useState as useState222, useEffect as useEffect24 } from "react";
9833
9851
  import { execFile as execFile22 } from "child_process";
9834
9852
  import os5 from "os";
@@ -9838,43 +9856,70 @@ import {
9838
9856
  useContext as useContext9,
9839
9857
  useState as useState23
9840
9858
  } from "react";
9841
- import { jsx as jsx37 } from "react/jsx-runtime";
9842
- import { jsx as jsx38, jsxs as jsxs33 } from "react/jsx-runtime";
9859
+ import { jsx as jsx45 } from "react/jsx-runtime";
9860
+ import { jsx as jsx46, jsxs as jsxs40 } from "react/jsx-runtime";
9843
9861
  import { useRef as useRef14 } from "react";
9844
- import { Box as Box29, Text as Text37 } from "ink";
9845
- import { jsx as jsx39, jsxs as jsxs34 } from "react/jsx-runtime";
9846
- import { Box as Box30, Text as Text38 } from "ink";
9847
- import { jsx as jsx40, jsxs as jsxs35 } from "react/jsx-runtime";
9848
- import { jsx as jsx41, jsxs as jsxs36 } from "react/jsx-runtime";
9849
- import { Box as Box32, Text as Text40 } from "ink";
9850
- import { jsx as jsx42, jsxs as jsxs37 } from "react/jsx-runtime";
9851
- import { useCallback as useCallback20, useMemo as useMemo12, useRef as useRef15 } from "react";
9852
- import { Box as Box33, Text as Text41 } from "ink";
9853
- import { jsx as jsx43, jsxs as jsxs38 } from "react/jsx-runtime";
9854
- import { useCallback as useCallback21, useMemo as useMemo13, useState as useState25 } from "react";
9855
- import { Box as Box34, Text as Text42, useInput as useInput3 } from "ink";
9856
- import { Fragment as Fragment9, jsx as jsx44, jsxs as jsxs39 } from "react/jsx-runtime";
9857
- import { useCallback as useCallback22, useMemo as useMemo14, useState as useState26 } from "react";
9858
- import { Box as Box35, Text as Text43 } from "ink";
9859
- import { jsx as jsx45, jsxs as jsxs40 } from "react/jsx-runtime";
9860
- import { useCallback as useCallback23, useEffect as useEffect25, useMemo as useMemo15, useRef as useRef16, useState as useState27 } from "react";
9861
- import { Box as Box36, Text as Text44 } from "ink";
9862
- import { jsx as jsx46, jsxs as jsxs41 } from "react/jsx-runtime";
9863
- import { useCallback as useCallback24, useEffect as useEffect26, useMemo as useMemo16, useRef as useRef17, useState as useState28 } from "react";
9864
- import { Box as Box37, Text as Text45, useInput as useInput4 } from "ink";
9865
- import { jsx as jsx47, jsxs as jsxs42 } from "react/jsx-runtime";
9866
- import fs7 from "fs";
9867
- import path142 from "path";
9868
- import { useCallback as useCallback25, useMemo as useMemo17 } from "react";
9862
+ import { Box as Box37, Text as Text45 } from "ink";
9863
+ import { jsx as jsx47, jsxs as jsxs41 } from "react/jsx-runtime";
9869
9864
  import { Box as Box38, Text as Text46 } from "ink";
9870
- import { jsx as jsx48, jsxs as jsxs43 } from "react/jsx-runtime";
9871
- import { useCallback as useCallback26, useEffect as useEffect27, useMemo as useMemo18, useState as useState29 } from "react";
9872
- import { Box as Box39, Text as Text47, useInput as useInput5 } from "ink";
9873
- import { jsx as jsx49, jsxs as jsxs44 } from "react/jsx-runtime";
9865
+ import { jsx as jsx48, jsxs as jsxs42 } from "react/jsx-runtime";
9866
+ import { jsx as jsx49, jsxs as jsxs43 } from "react/jsx-runtime";
9867
+ import { createContext as createContext9, useContext as useContext10 } from "react";
9874
9868
  import { Box as Box40, Text as Text48 } from "ink";
9875
- import { jsx as jsx50, jsxs as jsxs45 } from "react/jsx-runtime";
9876
- import { jsx as jsx51, jsxs as jsxs46 } from "react/jsx-runtime";
9877
- import { jsx as jsx52 } from "react/jsx-runtime";
9869
+ import { useContext as useContext11 } from "react";
9870
+ import { jsx as jsx50, jsxs as jsxs44 } from "react/jsx-runtime";
9871
+ import { Box as Box41, Text as Text49 } from "ink";
9872
+ import os6 from "os";
9873
+ import { useState as useState25, useEffect as useEffect25, useCallback as useCallback20 } from "react";
9874
+ import { execFile as execFile32 } from "child_process";
9875
+ import fs7 from "fs";
9876
+ import fsPromises from "fs/promises";
9877
+ import path142 from "path";
9878
+ import { Fragment as Fragment11, jsx as jsx51, jsxs as jsxs45 } from "react/jsx-runtime";
9879
+ import { memo, useMemo as useMemo12 } from "react";
9880
+ import { Box as Box42, Text as Text50 } from "ink";
9881
+ import { jsx as jsx52, jsxs as jsxs46 } from "react/jsx-runtime";
9882
+ import { useState as useState28, useEffect as useEffect28, useRef as useRef17 } from "react";
9883
+ import { useState as useState26, useEffect as useEffect26, useRef as useRef15 } from "react";
9884
+ import { useState as useState27, useEffect as useEffect27, useRef as useRef16 } from "react";
9885
+ import os7 from "os";
9886
+ import path15 from "path";
9887
+ import fs8 from "fs/promises";
9888
+ import fs9 from "fs";
9889
+ import path16 from "path";
9890
+ import process4 from "process";
9891
+ import fs10 from "fs";
9892
+ import os8 from "os";
9893
+ import path17 from "path";
9894
+ import { Box as Box43, Text as Text51 } from "ink";
9895
+ import { jsx as jsx53, jsxs as jsxs47 } from "react/jsx-runtime";
9896
+ import { useCallback as useCallback21, useMemo as useMemo13, useRef as useRef18 } from "react";
9897
+ import { Box as Box44, Text as Text52 } from "ink";
9898
+ import { jsx as jsx54, jsxs as jsxs48 } from "react/jsx-runtime";
9899
+ import { useCallback as useCallback22, useMemo as useMemo14, useState as useState29 } from "react";
9900
+ import { Box as Box45, Text as Text53, useInput as useInput3 } from "ink";
9901
+ import { Fragment as Fragment12, jsx as jsx55, jsxs as jsxs49 } from "react/jsx-runtime";
9902
+ import { useCallback as useCallback23, useState as useState30 } from "react";
9903
+ import { Box as Box46, Text as Text54 } from "ink";
9904
+ import { jsx as jsx56, jsxs as jsxs50 } from "react/jsx-runtime";
9905
+ import { useCallback as useCallback24, useEffect as useEffect29, useMemo as useMemo15, useRef as useRef19, useState as useState31 } from "react";
9906
+ import { Box as Box47, Text as Text55 } from "ink";
9907
+ import { jsx as jsx57, jsxs as jsxs51 } from "react/jsx-runtime";
9908
+ import { useCallback as useCallback25, useEffect as useEffect30, useMemo as useMemo16, useRef as useRef20, useState as useState32 } from "react";
9909
+ import { Box as Box48, Text as Text56, useInput as useInput4 } from "ink";
9910
+ import { jsx as jsx58, jsxs as jsxs52 } from "react/jsx-runtime";
9911
+ import fs11 from "fs";
9912
+ import path18 from "path";
9913
+ import { useCallback as useCallback26, useMemo as useMemo17 } from "react";
9914
+ import { Box as Box49, Text as Text57 } from "ink";
9915
+ import { jsx as jsx59, jsxs as jsxs53 } from "react/jsx-runtime";
9916
+ import { useCallback as useCallback27, useEffect as useEffect31, useMemo as useMemo18, useState as useState33 } from "react";
9917
+ import { Box as Box50, Text as Text58, useInput as useInput5 } from "ink";
9918
+ import { jsx as jsx60, jsxs as jsxs54 } from "react/jsx-runtime";
9919
+ import { Box as Box51, Text as Text59 } from "ink";
9920
+ import { jsx as jsx61, jsxs as jsxs55 } from "react/jsx-runtime";
9921
+ import { jsx as jsx62, jsxs as jsxs56 } from "react/jsx-runtime";
9922
+ import { jsx as jsx63 } from "react/jsx-runtime";
9878
9923
  async function createRuntime(options) {
9879
9924
  const worktree = path10.resolve(options.cwd);
9880
9925
  const config = await new ConfigLoader().load({ cwd: worktree, configPath: options.configPath });
@@ -10157,10 +10202,10 @@ async function doctorCommand(options) {
10157
10202
  for (const server of runtime.config.lsp.servers) {
10158
10203
  checks.push(await lspCommandCheck(server.command));
10159
10204
  }
10160
- for (const check of checks) {
10161
- await writeStdoutLine(`${check.ok ? "ok" : "fail"} ${check.name}: ${check.detail}`);
10205
+ for (const check2 of checks) {
10206
+ await writeStdoutLine(`${check2.ok ? "ok" : "fail"} ${check2.name}: ${check2.detail}`);
10162
10207
  }
10163
- const failed = checks.filter((check) => !check.ok);
10208
+ const failed = checks.filter((check2) => !check2.ok);
10164
10209
  if (failed.length > 0) {
10165
10210
  process.exitCode = 1;
10166
10211
  }
@@ -10277,10 +10322,10 @@ async function lspCommandCheck(command) {
10277
10322
  ];
10278
10323
  let lastFailure;
10279
10324
  for (const args of attempts) {
10280
- const check = await commandCheck(`lsp:${command}`, args, command);
10281
- if (check.ok) return check;
10282
- if (check.detail.includes("ENOENT")) return check;
10283
- lastFailure = check;
10325
+ const check2 = await commandCheck(`lsp:${command}`, args, command);
10326
+ if (check2.ok) return check2;
10327
+ if (check2.detail.includes("ENOENT")) return check2;
10328
+ lastFailure = check2;
10284
10329
  }
10285
10330
  return lastFailure ?? {
10286
10331
  name: `lsp:${command}`,
@@ -11467,7 +11512,7 @@ function parseVersion(version) {
11467
11512
  if (!match) return null;
11468
11513
  return [Number(match[1]), Number(match[2]), Number(match[3])];
11469
11514
  }
11470
- var VERSION = "1.2.12".length > 0 ? "1.2.12" : "0.0.0-dev";
11515
+ var VERSION = "1.2.17".length > 0 ? "1.2.17" : "0.0.0-dev";
11471
11516
  async function updateCommand() {
11472
11517
  writeStdoutLine(`Current version: ${VERSION}`);
11473
11518
  const update = await checkForUpdate(VERSION, { force: true });
@@ -12048,6 +12093,9 @@ function useHistory() {
12048
12093
  [history, addItem, updateItem, clearItems, loadHistory, truncateToItem]
12049
12094
  );
12050
12095
  }
12096
+ function isTerminalGoalStatusKind(kind) {
12097
+ return kind === "achieved" || kind === "cleared" || kind === "failed" || kind === "aborted";
12098
+ }
12051
12099
  var CSS_NAME_TO_HEX_MAP = {
12052
12100
  aliceblue: "#f0f8ff",
12053
12101
  antiquewhite: "#faebd7",
@@ -15523,6 +15571,7 @@ var OverflowStateContext = createContext(
15523
15571
  var OverflowActionsContext = createContext(
15524
15572
  void 0
15525
15573
  );
15574
+ var useOverflowState = () => useContext(OverflowStateContext);
15526
15575
  var useOverflowActions = () => useContext(OverflowActionsContext);
15527
15576
  var enableDebugLog = false;
15528
15577
  var debugLogger4 = createDebugLogger("MAX_SIZED_BOX");
@@ -20673,13 +20722,13 @@ var getLineRangeOffsets = (startRow, lineCount, lines) => {
20673
20722
  var replaceRangeInternal = (state, startRow, startCol, endRow, endCol, text) => {
20674
20723
  const currentLine = (row) => state.lines[row] || "";
20675
20724
  const currentLineLen = (row) => cpLen(currentLine(row));
20676
- const clamp2 = (value, min, max) => Math.min(Math.max(value, min), max);
20725
+ const clamp3 = (value, min, max) => Math.min(Math.max(value, min), max);
20677
20726
  if (startRow > endRow || startRow === endRow && startCol > endCol || startRow < 0 || startCol < 0 || endRow >= state.lines.length || endRow < state.lines.length && endCol > currentLineLen(endRow)) {
20678
20727
  return state;
20679
20728
  }
20680
20729
  const newLines = [...state.lines];
20681
- const sCol = clamp2(startCol, 0, currentLineLen(startRow));
20682
- const eCol = clamp2(endCol, 0, currentLineLen(endRow));
20730
+ const sCol = clamp3(startCol, 0, currentLineLen(startRow));
20731
+ const eCol = clamp3(endCol, 0, currentLineLen(endRow));
20683
20732
  const prefix = cpSlice(currentLine(startRow), 0, sCol);
20684
20733
  const suffix = cpSlice(currentLine(endRow), eCol);
20685
20734
  const normalisedReplacement = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
@@ -24024,6 +24073,511 @@ var ToolGroupMessage = ({
24024
24073
  }
24025
24074
  );
24026
24075
  };
24076
+ function getCompressionText(compression) {
24077
+ const { isPending, originalTokenCount, newTokenCount, compressionStatus } = compression;
24078
+ if (isPending) return "Comprimindo hist\xF3rico...";
24079
+ const orig = originalTokenCount ?? 0;
24080
+ const next = newTokenCount ?? 0;
24081
+ switch (compressionStatus) {
24082
+ case 1:
24083
+ return `Hist\xF3rico comprimido: ${orig} \u2192 ${next} tokens.`;
24084
+ case 2:
24085
+ return orig < 5e4 ? "Compress\xE3o sem benef\xEDcio para esse tamanho de hist\xF3rico." : "Compress\xE3o n\xE3o reduziu o tamanho. Verifique o prompt de compress\xE3o.";
24086
+ case 3:
24087
+ return "N\xE3o foi poss\xEDvel comprimir: erro na contagem de tokens.";
24088
+ case 5:
24089
+ return "Nada para comprimir.";
24090
+ default:
24091
+ return "";
24092
+ }
24093
+ }
24094
+ function CompressionMessage({
24095
+ compression
24096
+ }) {
24097
+ const text = getCompressionText(compression);
24098
+ return /* @__PURE__ */ jsxs21(Box22, { flexDirection: "row", children: [
24099
+ /* @__PURE__ */ jsx27(Box22, { marginRight: 1, children: compression.isPending ? /* @__PURE__ */ jsx27(build_default, { type: "dots" }) : /* @__PURE__ */ jsx27(Text25, { color: theme.text.accent, children: "\u2726" }) }),
24100
+ /* @__PURE__ */ jsx27(Text25, { color: compression.isPending ? theme.text.accent : theme.status.success, children: text })
24101
+ ] });
24102
+ }
24103
+ function getSummaryText(summary) {
24104
+ if (summary.isPending) {
24105
+ switch (summary.stage) {
24106
+ case "generating":
24107
+ return "Gerando resumo do projeto...";
24108
+ case "saving":
24109
+ return "Salvando resumo...";
24110
+ default:
24111
+ return "Processando resumo...";
24112
+ }
24113
+ }
24114
+ const base = "Resumo gerado e salvo com sucesso!";
24115
+ return summary.filePath ? `${base} Salvo em: ${summary.filePath}` : base;
24116
+ }
24117
+ var SummaryMessage = ({ summary }) => /* @__PURE__ */ jsxs22(Box23, { flexDirection: "row", children: [
24118
+ /* @__PURE__ */ jsx28(Box23, { marginRight: 1, children: summary.isPending ? /* @__PURE__ */ jsx28(build_default, { type: "dots" }) : /* @__PURE__ */ jsx28(Text26, { color: theme.status.success, children: "\u2713" }) }),
24119
+ /* @__PURE__ */ jsx28(Text26, { color: summary.isPending ? theme.text.accent : theme.status.success, children: getSummaryText(summary) })
24120
+ ] });
24121
+ var FILLED = "\u2588";
24122
+ var BUFFER = "\u2592";
24123
+ var EMPTY = "\u2591";
24124
+ var CONTENT_WIDTH = 56;
24125
+ function fmtTokens(n) {
24126
+ if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
24127
+ if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
24128
+ return String(n);
24129
+ }
24130
+ function fmtPct(tokens, total) {
24131
+ if (total <= 0) return "0.0";
24132
+ const p = tokens / total * 100;
24133
+ return p > 100 ? ">100" : p.toFixed(1);
24134
+ }
24135
+ function truncate(s, max) {
24136
+ return s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
24137
+ }
24138
+ var ProgressBar = ({ usedPct, bufferPct, width }) => {
24139
+ const used = Math.round(Math.min(usedPct, 100) / 100 * width);
24140
+ const buffer = Math.round(Math.min(bufferPct, 100 - usedPct) / 100 * width);
24141
+ const free = Math.max(0, width - used - buffer);
24142
+ const usedColor = usedPct > 80 ? theme.status.error : usedPct > 60 ? theme.status.warning : theme.text.accent;
24143
+ return /* @__PURE__ */ jsxs23(Text27, { children: [
24144
+ /* @__PURE__ */ jsx29(Text27, { color: usedColor, children: FILLED.repeat(Math.max(0, used)) }),
24145
+ /* @__PURE__ */ jsx29(Text27, { color: theme.text.secondary, children: EMPTY.repeat(Math.max(0, free)) }),
24146
+ /* @__PURE__ */ jsx29(Text27, { color: theme.status.warning, children: BUFFER.repeat(Math.max(0, buffer)) })
24147
+ ] });
24148
+ };
24149
+ var CategoryRow = ({ symbol, label, tokens, total, symbolColor, overLimit }) => /* @__PURE__ */ jsxs23(Box24, { width: CONTENT_WIDTH, children: [
24150
+ /* @__PURE__ */ jsx29(Box24, { width: 2, children: /* @__PURE__ */ jsx29(Text27, { color: symbolColor ?? theme.text.secondary, children: symbol }) }),
24151
+ /* @__PURE__ */ jsx29(Box24, { width: 24, children: /* @__PURE__ */ jsx29(Text27, { color: theme.text.primary, children: label }) }),
24152
+ /* @__PURE__ */ jsx29(Box24, { flexGrow: 1, justifyContent: "flex-end", children: /* @__PURE__ */ jsxs23(Text27, { color: overLimit ? theme.status.error : theme.text.secondary, children: [
24153
+ fmtTokens(tokens),
24154
+ " tokens (",
24155
+ fmtPct(tokens, total),
24156
+ "%)"
24157
+ ] }) })
24158
+ ] });
24159
+ var DetailRow = ({
24160
+ name,
24161
+ tokens
24162
+ }) => /* @__PURE__ */ jsxs23(Box24, { width: CONTENT_WIDTH, paddingLeft: 2, children: [
24163
+ /* @__PURE__ */ jsxs23(Text27, { color: theme.text.secondary, children: [
24164
+ "\u2514",
24165
+ " "
24166
+ ] }),
24167
+ /* @__PURE__ */ jsx29(Box24, { width: 32, children: /* @__PURE__ */ jsx29(Text27, { color: theme.text.link, children: truncate(name, 30) }) }),
24168
+ /* @__PURE__ */ jsx29(Box24, { flexGrow: 1, justifyContent: "flex-end", children: /* @__PURE__ */ jsxs23(Text27, { color: theme.text.secondary, children: [
24169
+ fmtTokens(tokens),
24170
+ " tokens"
24171
+ ] }) })
24172
+ ] });
24173
+ var ContextUsage = ({
24174
+ modelName,
24175
+ totalTokens,
24176
+ contextWindowSize,
24177
+ breakdown,
24178
+ builtinTools,
24179
+ mcpTools,
24180
+ memoryFiles,
24181
+ skills,
24182
+ isEstimated,
24183
+ showDetails = false
24184
+ }) => {
24185
+ const pct = contextWindowSize > 0 ? totalTokens / contextWindowSize * 100 : 0;
24186
+ const overLimit = pct > 100;
24187
+ const bufferPct = contextWindowSize > 0 ? breakdown.autocompactBuffer / contextWindowSize * 100 : 0;
24188
+ const sortDesc = (arr) => [...arr].sort((a, b) => b.tokens - a.tokens);
24189
+ return /* @__PURE__ */ jsxs23(
24190
+ Box24,
24191
+ {
24192
+ borderStyle: "round",
24193
+ borderColor: theme.border.default,
24194
+ flexDirection: "column",
24195
+ paddingY: 1,
24196
+ paddingX: 2,
24197
+ children: [
24198
+ /* @__PURE__ */ jsx29(Text27, { bold: true, color: theme.text.accent, children: "Uso do Contexto" }),
24199
+ /* @__PURE__ */ jsx29(Box24, { height: 1 }),
24200
+ isEstimated ? /* @__PURE__ */ jsx29(Box24, { marginBottom: 1, children: /* @__PURE__ */ jsx29(Text27, { color: theme.status.warning, italic: true, children: "Estimativa \u2014 envie uma mensagem para ver o uso real." }) }) : /* @__PURE__ */ jsxs23(Fragment7, { children: [
24201
+ /* @__PURE__ */ jsxs23(Box24, { width: CONTENT_WIDTH, marginBottom: 1, children: [
24202
+ /* @__PURE__ */ jsxs23(Text27, { color: theme.text.secondary, children: [
24203
+ "Modelo: ",
24204
+ modelName
24205
+ ] }),
24206
+ /* @__PURE__ */ jsx29(Box24, { flexGrow: 1, justifyContent: "flex-end", children: /* @__PURE__ */ jsxs23(Text27, { color: theme.text.secondary, children: [
24207
+ "Janela: ",
24208
+ fmtTokens(contextWindowSize),
24209
+ " tokens"
24210
+ ] }) })
24211
+ ] }),
24212
+ /* @__PURE__ */ jsx29(Box24, { width: CONTENT_WIDTH, children: /* @__PURE__ */ jsx29(
24213
+ ProgressBar,
24214
+ {
24215
+ usedPct: Math.min(pct, 100),
24216
+ bufferPct,
24217
+ width: CONTENT_WIDTH
24218
+ }
24219
+ ) }),
24220
+ overLimit && /* @__PURE__ */ jsx29(Box24, { marginBottom: 1, children: /* @__PURE__ */ jsx29(Text27, { color: theme.status.error, children: "Contexto excede o limite! Use /compact ou /clear para reduzir." }) }),
24221
+ /* @__PURE__ */ jsx29(Box24, { height: 1 }),
24222
+ /* @__PURE__ */ jsx29(
24223
+ CategoryRow,
24224
+ {
24225
+ symbol: FILLED,
24226
+ label: "Usado",
24227
+ tokens: totalTokens,
24228
+ total: contextWindowSize,
24229
+ symbolColor: overLimit ? theme.status.error : theme.text.accent,
24230
+ overLimit
24231
+ }
24232
+ ),
24233
+ /* @__PURE__ */ jsx29(
24234
+ CategoryRow,
24235
+ {
24236
+ symbol: EMPTY,
24237
+ label: "Livre",
24238
+ tokens: breakdown.freeSpace,
24239
+ total: contextWindowSize,
24240
+ symbolColor: theme.text.secondary
24241
+ }
24242
+ ),
24243
+ /* @__PURE__ */ jsx29(
24244
+ CategoryRow,
24245
+ {
24246
+ symbol: BUFFER,
24247
+ label: "Buffer de compress\xE3o",
24248
+ tokens: breakdown.autocompactBuffer,
24249
+ total: contextWindowSize,
24250
+ symbolColor: theme.status.warning
24251
+ }
24252
+ ),
24253
+ /* @__PURE__ */ jsx29(Box24, { height: 1 }),
24254
+ /* @__PURE__ */ jsx29(Text27, { bold: true, color: theme.text.primary, children: "Por categoria" })
24255
+ ] }),
24256
+ /* @__PURE__ */ jsx29(
24257
+ CategoryRow,
24258
+ {
24259
+ symbol: FILLED,
24260
+ label: "System prompt",
24261
+ tokens: breakdown.systemPrompt,
24262
+ total: contextWindowSize,
24263
+ symbolColor: theme.text.accent
24264
+ }
24265
+ ),
24266
+ breakdown.builtinTools > 0 && /* @__PURE__ */ jsx29(
24267
+ CategoryRow,
24268
+ {
24269
+ symbol: FILLED,
24270
+ label: "Ferramentas built-in",
24271
+ tokens: breakdown.builtinTools,
24272
+ total: contextWindowSize,
24273
+ symbolColor: theme.text.accent
24274
+ }
24275
+ ),
24276
+ breakdown.mcpTools > 0 && /* @__PURE__ */ jsx29(
24277
+ CategoryRow,
24278
+ {
24279
+ symbol: FILLED,
24280
+ label: "Ferramentas MCP",
24281
+ tokens: breakdown.mcpTools,
24282
+ total: contextWindowSize,
24283
+ symbolColor: theme.text.accent
24284
+ }
24285
+ ),
24286
+ breakdown.memoryFiles > 0 && /* @__PURE__ */ jsx29(
24287
+ CategoryRow,
24288
+ {
24289
+ symbol: FILLED,
24290
+ label: "Arquivos de mem\xF3ria",
24291
+ tokens: breakdown.memoryFiles,
24292
+ total: contextWindowSize,
24293
+ symbolColor: theme.text.accent
24294
+ }
24295
+ ),
24296
+ !isEstimated && /* @__PURE__ */ jsx29(
24297
+ CategoryRow,
24298
+ {
24299
+ symbol: FILLED,
24300
+ label: "Mensagens",
24301
+ tokens: breakdown.messages,
24302
+ total: contextWindowSize,
24303
+ symbolColor: theme.text.accent
24304
+ }
24305
+ ),
24306
+ showDetails ? /* @__PURE__ */ jsxs23(Fragment7, { children: [
24307
+ builtinTools.length > 0 && /* @__PURE__ */ jsxs23(Box24, { flexDirection: "column", marginTop: 1, children: [
24308
+ /* @__PURE__ */ jsx29(Text27, { bold: true, color: theme.text.primary, children: "Ferramentas built-in" }),
24309
+ sortDesc(builtinTools).map((t2) => /* @__PURE__ */ jsx29(DetailRow, { name: t2.name, tokens: t2.tokens }, t2.name))
24310
+ ] }),
24311
+ mcpTools.length > 0 && /* @__PURE__ */ jsxs23(Box24, { flexDirection: "column", marginTop: 1, children: [
24312
+ /* @__PURE__ */ jsx29(Text27, { bold: true, color: theme.text.primary, children: "Ferramentas MCP" }),
24313
+ sortDesc(mcpTools).map((t2) => /* @__PURE__ */ jsx29(DetailRow, { name: t2.name, tokens: t2.tokens }, t2.name))
24314
+ ] }),
24315
+ memoryFiles.length > 0 && /* @__PURE__ */ jsxs23(Box24, { flexDirection: "column", marginTop: 1, children: [
24316
+ /* @__PURE__ */ jsx29(Text27, { bold: true, color: theme.text.primary, children: "Arquivos de mem\xF3ria" }),
24317
+ sortDesc(memoryFiles).map((f) => /* @__PURE__ */ jsx29(DetailRow, { name: f.path, tokens: f.tokens }, f.path))
24318
+ ] }),
24319
+ skills.length > 0 && /* @__PURE__ */ jsxs23(Box24, { flexDirection: "column", marginTop: 1, children: [
24320
+ /* @__PURE__ */ jsx29(Text27, { bold: true, color: theme.text.primary, children: "Skills" }),
24321
+ skills.map((sk) => /* @__PURE__ */ jsx29(DetailRow, { name: sk.name, tokens: sk.tokens }, sk.name))
24322
+ ] })
24323
+ ] }) : /* @__PURE__ */ jsx29(Box24, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text27, { color: theme.text.secondary, italic: true, children: "Use /context detail para ver o detalhamento por item." }) })
24324
+ ]
24325
+ }
24326
+ );
24327
+ };
24328
+ var STATUS_ICONS2 = {
24329
+ pass: "\u2713",
24330
+ warn: "\u26A0",
24331
+ fail: "\u2717"
24332
+ };
24333
+ var STATUS_COLORS = {
24334
+ pass: theme.status.success,
24335
+ warn: theme.status.warning,
24336
+ fail: theme.status.error
24337
+ };
24338
+ function groupByCategory(checks) {
24339
+ const groups = /* @__PURE__ */ new Map();
24340
+ for (const check2 of checks) {
24341
+ const arr = groups.get(check2.category) ?? [];
24342
+ arr.push(check2);
24343
+ groups.set(check2.category, arr);
24344
+ }
24345
+ return groups;
24346
+ }
24347
+ var DoctorReport = ({ checks, summary }) => {
24348
+ const groups = groupByCategory(checks);
24349
+ const hasIssues = summary.fail > 0 || summary.warn > 0;
24350
+ return /* @__PURE__ */ jsxs24(Box25, { flexDirection: "column", marginLeft: 2, children: [
24351
+ /* @__PURE__ */ jsx30(Text28, { color: theme.text.secondary, bold: true, children: "DeepCode Doctor" }),
24352
+ Array.from(groups.entries()).map(([category, items]) => /* @__PURE__ */ jsxs24(Box25, { flexDirection: "column", marginTop: 1, children: [
24353
+ /* @__PURE__ */ jsx30(Text28, { color: theme.text.secondary, dimColor: true, children: category }),
24354
+ items.map((check2) => /* @__PURE__ */ jsxs24(Box25, { flexDirection: "column", children: [
24355
+ /* @__PURE__ */ jsxs24(Box25, { flexDirection: "row", children: [
24356
+ /* @__PURE__ */ jsx30(Box25, { width: 2, children: /* @__PURE__ */ jsx30(Text28, { color: STATUS_COLORS[check2.status], children: STATUS_ICONS2[check2.status] }) }),
24357
+ /* @__PURE__ */ jsxs24(Text28, { children: [
24358
+ check2.name,
24359
+ ": ",
24360
+ /* @__PURE__ */ jsx30(Text28, { color: STATUS_COLORS[check2.status], children: check2.message })
24361
+ ] })
24362
+ ] }),
24363
+ check2.detail && /* @__PURE__ */ jsx30(Box25, { marginLeft: 2, children: /* @__PURE__ */ jsx30(Text28, { color: theme.text.secondary, dimColor: true, children: check2.detail }) })
24364
+ ] }, check2.name))
24365
+ ] }, category)),
24366
+ /* @__PURE__ */ jsxs24(Box25, { marginTop: 1, flexDirection: "row", children: [
24367
+ /* @__PURE__ */ jsxs24(Text28, { color: theme.status.success, children: [
24368
+ "\u2713 ",
24369
+ summary.pass,
24370
+ " pass"
24371
+ ] }),
24372
+ summary.warn > 0 && /* @__PURE__ */ jsxs24(Fragment8, { children: [
24373
+ /* @__PURE__ */ jsx30(Text28, { children: " " }),
24374
+ /* @__PURE__ */ jsxs24(Text28, { color: theme.status.warning, children: [
24375
+ "\u26A0 ",
24376
+ summary.warn,
24377
+ " warn"
24378
+ ] })
24379
+ ] }),
24380
+ summary.fail > 0 && /* @__PURE__ */ jsxs24(Fragment8, { children: [
24381
+ /* @__PURE__ */ jsx30(Text28, { children: " " }),
24382
+ /* @__PURE__ */ jsxs24(Text28, { color: theme.status.error, children: [
24383
+ "\u2717 ",
24384
+ summary.fail,
24385
+ " fail"
24386
+ ] })
24387
+ ] }),
24388
+ !hasIssues && /* @__PURE__ */ jsx30(Text28, { color: theme.text.secondary, children: " \u2014 all checks passed" })
24389
+ ] })
24390
+ ] });
24391
+ };
24392
+ function useTerminalSize() {
24393
+ const [size, setSize] = useState12({
24394
+ columns: process.stdout.columns || 80,
24395
+ rows: process.stdout.rows || 24
24396
+ });
24397
+ useEffect14(() => {
24398
+ function updateSize() {
24399
+ setSize({
24400
+ columns: process.stdout.columns || 80,
24401
+ rows: process.stdout.rows || 24
24402
+ });
24403
+ }
24404
+ process.stdout.on("resize", updateSize);
24405
+ return () => {
24406
+ process.stdout.off("resize", updateSize);
24407
+ };
24408
+ }, []);
24409
+ return size;
24410
+ }
24411
+ var BTW_SELF_CHROME = 4;
24412
+ function normalizeCodeFences(text) {
24413
+ return text.replace(/([^\n])(```|~~~)/g, "$1\n$2");
24414
+ }
24415
+ var BtwMessageInternal = ({ btw, containerWidth }) => {
24416
+ const { columns: terminalWidth } = useTerminalSize();
24417
+ const baseWidth = containerWidth ?? terminalWidth;
24418
+ const contentWidth = Math.max(2, baseWidth - BTW_SELF_CHROME);
24419
+ return /* @__PURE__ */ jsxs25(
24420
+ Box26,
24421
+ {
24422
+ flexDirection: "column",
24423
+ borderStyle: "round",
24424
+ borderColor: theme.status.warning,
24425
+ paddingX: 1,
24426
+ width: "100%",
24427
+ children: [
24428
+ /* @__PURE__ */ jsxs25(Box26, { flexDirection: "row", children: [
24429
+ /* @__PURE__ */ jsx31(Text29, { color: theme.status.warning, bold: true, children: "/btw " }),
24430
+ /* @__PURE__ */ jsx31(Text29, { wrap: "wrap", color: theme.status.warning, children: btw.question })
24431
+ ] }),
24432
+ btw.isPending ? /* @__PURE__ */ jsxs25(Box26, { flexDirection: "column", marginTop: 1, children: [
24433
+ /* @__PURE__ */ jsxs25(Box26, { children: [
24434
+ /* @__PURE__ */ jsx31(Text29, { color: theme.status.warning, children: "+ " }),
24435
+ /* @__PURE__ */ jsx31(Text29, { color: theme.status.warning, children: "Respondendo..." })
24436
+ ] }),
24437
+ /* @__PURE__ */ jsx31(Box26, { marginTop: 1, children: /* @__PURE__ */ jsx31(Text29, { dimColor: true, children: "Pressione Esc, Ctrl+C ou Ctrl+D para cancelar" }) })
24438
+ ] }) : /* @__PURE__ */ jsxs25(Box26, { flexDirection: "column", marginTop: 1, children: [
24439
+ /* @__PURE__ */ jsx31(
24440
+ MarkdownDisplay,
24441
+ {
24442
+ text: normalizeCodeFences(btw.answer),
24443
+ isPending: false,
24444
+ contentWidth
24445
+ }
24446
+ ),
24447
+ /* @__PURE__ */ jsx31(Box26, { marginTop: 1, children: /* @__PURE__ */ jsx31(Text29, { dimColor: true, children: "Pressione Espa\xE7o, Enter ou Esc para fechar" }) })
24448
+ ] })
24449
+ ]
24450
+ }
24451
+ );
24452
+ };
24453
+ var BtwMessage = React23.memo(BtwMessageInternal);
24454
+ function fmtTokens2(n) {
24455
+ if (n >= 1e6) return `${(n / 1e6).toFixed(2)}M`;
24456
+ if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
24457
+ return n.toLocaleString("pt-BR");
24458
+ }
24459
+ var StatRow = ({ label, value, valueColor }) => /* @__PURE__ */ jsxs26(Box27, { children: [
24460
+ /* @__PURE__ */ jsx32(Box27, { width: 26, children: /* @__PURE__ */ jsx32(Text30, { color: theme.text.secondary, children: label }) }),
24461
+ /* @__PURE__ */ jsx32(Text30, { color: valueColor ?? theme.text.primary, children: value })
24462
+ ] });
24463
+ var StatsDisplay = ({
24464
+ duration,
24465
+ promptTokens,
24466
+ outputTokens,
24467
+ messageCount
24468
+ }) => /* @__PURE__ */ jsxs26(
24469
+ Box27,
24470
+ {
24471
+ borderStyle: "round",
24472
+ borderColor: theme.border.default,
24473
+ flexDirection: "column",
24474
+ paddingY: 1,
24475
+ paddingX: 2,
24476
+ children: [
24477
+ /* @__PURE__ */ jsx32(Text30, { bold: true, color: theme.text.accent, children: "Estat\xEDsticas da Sess\xE3o" }),
24478
+ /* @__PURE__ */ jsx32(Box27, { height: 1 }),
24479
+ /* @__PURE__ */ jsx32(StatRow, { label: "Tempo de sess\xE3o:", value: duration }),
24480
+ messageCount !== void 0 && /* @__PURE__ */ jsx32(StatRow, { label: "Mensagens:", value: String(messageCount) }),
24481
+ promptTokens !== void 0 && promptTokens > 0 && /* @__PURE__ */ jsx32(
24482
+ StatRow,
24483
+ {
24484
+ label: "\xDAltimo prompt (tokens):",
24485
+ value: fmtTokens2(promptTokens),
24486
+ valueColor: theme.status.warning
24487
+ }
24488
+ ),
24489
+ outputTokens !== void 0 && outputTokens > 0 && /* @__PURE__ */ jsx32(
24490
+ StatRow,
24491
+ {
24492
+ label: "\xDAltima resposta (tokens):",
24493
+ value: fmtTokens2(outputTokens),
24494
+ valueColor: theme.status.warning
24495
+ }
24496
+ )
24497
+ ]
24498
+ }
24499
+ );
24500
+ function pluralTurns(n) {
24501
+ return n === 1 ? "turno" : "turnos";
24502
+ }
24503
+ function assertNever(kind) {
24504
+ throw new Error(`Unexpected goal status kind: ${kind}`);
24505
+ }
24506
+ var GoalStatusMessageInternal = ({
24507
+ kind,
24508
+ condition,
24509
+ iterations,
24510
+ durationMs,
24511
+ lastReason
24512
+ }) => {
24513
+ if (kind === "checking") {
24514
+ const reason = lastReason?.trim();
24515
+ return /* @__PURE__ */ jsxs27(Box28, { flexDirection: "row", children: [
24516
+ /* @__PURE__ */ jsx33(Box28, { width: 2, flexShrink: 0, children: /* @__PURE__ */ jsx33(Text31, { color: theme.text.secondary, children: "\u25CB" }) }),
24517
+ /* @__PURE__ */ jsxs27(Box28, { flexGrow: 1, flexDirection: "column", children: [
24518
+ /* @__PURE__ */ jsxs27(Text31, { color: theme.text.secondary, children: [
24519
+ "Verificando goal",
24520
+ typeof iterations === "number" && iterations > 0 ? ` \xB7 turno ${iterations}` : "",
24521
+ " ",
24522
+ "\xB7 ainda n\xE3o atingido"
24523
+ ] }),
24524
+ /* @__PURE__ */ jsxs27(Text31, { color: theme.text.secondary, wrap: "wrap", children: [
24525
+ "Goal: ",
24526
+ condition
24527
+ ] }),
24528
+ reason ? /* @__PURE__ */ jsxs27(Text31, { color: theme.text.secondary, wrap: "wrap", children: [
24529
+ "Avalia\xE7\xE3o: ",
24530
+ reason
24531
+ ] }) : null
24532
+ ] })
24533
+ ] });
24534
+ }
24535
+ const { prefix, prefixColor, title } = (() => {
24536
+ switch (kind) {
24537
+ case "set":
24538
+ return { prefix: "\u25CE", prefixColor: theme.text.accent, title: "Goal definido" };
24539
+ case "achieved":
24540
+ return { prefix: "\u2713", prefixColor: theme.status.success, title: "Goal atingido" };
24541
+ case "cleared":
24542
+ return { prefix: "\u25CB", prefixColor: theme.text.secondary, title: "Goal removido" };
24543
+ case "failed":
24544
+ return { prefix: "\u2716", prefixColor: theme.status.error, title: "Goal n\xE3o atingido" };
24545
+ case "aborted":
24546
+ return { prefix: "!", prefixColor: theme.status.warning, title: "Goal abortado" };
24547
+ default:
24548
+ return assertNever(kind);
24549
+ }
24550
+ })();
24551
+ const stats = [];
24552
+ if (typeof iterations === "number" && iterations > 0) {
24553
+ stats.push(`${iterations} ${pluralTurns(iterations)}`);
24554
+ }
24555
+ if (typeof durationMs === "number") {
24556
+ stats.push(formatDuration(durationMs, { hideTrailingZeros: true }));
24557
+ }
24558
+ const subtitle = stats.length > 0 ? stats.join(" \xB7 ") : null;
24559
+ return /* @__PURE__ */ jsxs27(Box28, { flexDirection: "row", children: [
24560
+ /* @__PURE__ */ jsx33(Box28, { width: 2, flexShrink: 0, children: /* @__PURE__ */ jsx33(Text31, { color: prefixColor, children: prefix }) }),
24561
+ /* @__PURE__ */ jsxs27(Box28, { flexGrow: 1, flexDirection: "column", children: [
24562
+ /* @__PURE__ */ jsxs27(Text31, { color: prefixColor, children: [
24563
+ title,
24564
+ subtitle ? /* @__PURE__ */ jsxs27(Text31, { color: theme.text.secondary, children: [
24565
+ " \xB7 ",
24566
+ subtitle
24567
+ ] }) : null
24568
+ ] }),
24569
+ /* @__PURE__ */ jsxs27(Box28, { flexDirection: "row", children: [
24570
+ /* @__PURE__ */ jsx33(Box28, { flexShrink: 0, marginRight: 1, children: /* @__PURE__ */ jsx33(Text31, { color: theme.text.secondary, children: "Goal:" }) }),
24571
+ /* @__PURE__ */ jsx33(Box28, { flexGrow: 1, children: /* @__PURE__ */ jsx33(Text31, { wrap: "wrap", children: condition }) })
24572
+ ] }),
24573
+ isTerminalGoalStatusKind(kind) && lastReason?.trim() ? /* @__PURE__ */ jsxs27(Text31, { color: theme.text.secondary, wrap: "wrap", children: [
24574
+ "\xDAltima avalia\xE7\xE3o: ",
24575
+ lastReason.trim()
24576
+ ] }) : null
24577
+ ] })
24578
+ ] });
24579
+ };
24580
+ var GoalStatusMessage = React24.memo(GoalStatusMessageInternal);
24027
24581
  var HistoryItemDisplay = ({
24028
24582
  item,
24029
24583
  availableTerminalHeight,
@@ -24041,10 +24595,10 @@ var HistoryItemDisplay = ({
24041
24595
  const contentWidth = terminalWidth - 4;
24042
24596
  const boxWidth = mainAreaWidth ?? contentWidth;
24043
24597
  const marginTop = safeItem.type === "gemini_content" || safeItem.type === "gemini_thought_content" ? 0 : 1;
24044
- return /* @__PURE__ */ jsxs21(Box22, { flexDirection: "column", marginTop, marginLeft: 2, marginRight: 2, children: [
24045
- safeItem.type === "user" && /* @__PURE__ */ jsx27(UserMessage, { text: safeItem.text }),
24046
- safeItem.type === "user_shell" && /* @__PURE__ */ jsx27(UserShellMessage, { text: safeItem.text }),
24047
- safeItem.type === "gemini" && /* @__PURE__ */ jsx27(
24598
+ return /* @__PURE__ */ jsxs28(Box29, { flexDirection: "column", marginTop, marginLeft: 2, marginRight: 2, children: [
24599
+ safeItem.type === "user" && /* @__PURE__ */ jsx34(UserMessage, { text: safeItem.text }),
24600
+ safeItem.type === "user_shell" && /* @__PURE__ */ jsx34(UserShellMessage, { text: safeItem.text }),
24601
+ safeItem.type === "gemini" && /* @__PURE__ */ jsx34(
24048
24602
  AssistantMessage,
24049
24603
  {
24050
24604
  text: safeItem.text,
@@ -24053,7 +24607,7 @@ var HistoryItemDisplay = ({
24053
24607
  contentWidth
24054
24608
  }
24055
24609
  ),
24056
- safeItem.type === "gemini_content" && /* @__PURE__ */ jsx27(
24610
+ safeItem.type === "gemini_content" && /* @__PURE__ */ jsx34(
24057
24611
  AssistantMessageContent,
24058
24612
  {
24059
24613
  text: safeItem.text,
@@ -24062,7 +24616,7 @@ var HistoryItemDisplay = ({
24062
24616
  contentWidth
24063
24617
  }
24064
24618
  ),
24065
- !compactMode && safeItem.type === "gemini_thought" && /* @__PURE__ */ jsx27(
24619
+ !compactMode && safeItem.type === "gemini_thought" && /* @__PURE__ */ jsx34(
24066
24620
  ThinkMessage,
24067
24621
  {
24068
24622
  text: safeItem.text,
@@ -24071,7 +24625,7 @@ var HistoryItemDisplay = ({
24071
24625
  contentWidth
24072
24626
  }
24073
24627
  ),
24074
- !compactMode && safeItem.type === "gemini_thought_content" && /* @__PURE__ */ jsx27(
24628
+ !compactMode && safeItem.type === "gemini_thought_content" && /* @__PURE__ */ jsx34(
24075
24629
  ThinkMessageContent,
24076
24630
  {
24077
24631
  text: safeItem.text,
@@ -24080,11 +24634,11 @@ var HistoryItemDisplay = ({
24080
24634
  contentWidth
24081
24635
  }
24082
24636
  ),
24083
- safeItem.type === "info" && /* @__PURE__ */ jsx27(InfoMessage, { text: safeItem.text }),
24084
- safeItem.type === "success" && /* @__PURE__ */ jsx27(SuccessMessage, { text: safeItem.text }),
24085
- safeItem.type === "warning" && /* @__PURE__ */ jsx27(WarningMessage, { text: safeItem.text }),
24086
- safeItem.type === "error" && /* @__PURE__ */ jsx27(ErrorMessage, { text: safeItem.text }),
24087
- safeItem.type === "tool_group" && /* @__PURE__ */ jsx27(
24637
+ safeItem.type === "info" && /* @__PURE__ */ jsx34(InfoMessage, { text: safeItem.text }),
24638
+ safeItem.type === "success" && /* @__PURE__ */ jsx34(SuccessMessage, { text: safeItem.text }),
24639
+ safeItem.type === "warning" && /* @__PURE__ */ jsx34(WarningMessage, { text: safeItem.text }),
24640
+ safeItem.type === "error" && /* @__PURE__ */ jsx34(ErrorMessage, { text: safeItem.text }),
24641
+ safeItem.type === "tool_group" && /* @__PURE__ */ jsx34(
24088
24642
  ToolGroupMessage,
24089
24643
  {
24090
24644
  toolCalls: safeItem.tools,
@@ -24101,38 +24655,76 @@ var HistoryItemDisplay = ({
24101
24655
  compactLabel
24102
24656
  }
24103
24657
  ),
24104
- safeItem.type === "tool_use_summary" && (!compactMode || !summaryAbsorbed) && /* @__PURE__ */ jsx27(Box22, { paddingLeft: 1, children: /* @__PURE__ */ jsxs21(Text25, { dimColor: true, children: [
24658
+ safeItem.type === "context_usage" && /* @__PURE__ */ jsx34(
24659
+ ContextUsage,
24660
+ {
24661
+ modelName: safeItem.modelName,
24662
+ totalTokens: safeItem.totalTokens,
24663
+ contextWindowSize: safeItem.contextWindowSize,
24664
+ breakdown: safeItem.breakdown,
24665
+ builtinTools: safeItem.builtinTools,
24666
+ mcpTools: safeItem.mcpTools,
24667
+ memoryFiles: safeItem.memoryFiles,
24668
+ skills: safeItem.skills,
24669
+ isEstimated: safeItem.isEstimated,
24670
+ showDetails: safeItem.showDetails
24671
+ }
24672
+ ),
24673
+ safeItem.type === "doctor" && /* @__PURE__ */ jsx34(DoctorReport, { checks: safeItem.checks, summary: safeItem.summary }),
24674
+ safeItem.type === "stats" && /* @__PURE__ */ jsx34(
24675
+ StatsDisplay,
24676
+ {
24677
+ duration: safeItem.duration,
24678
+ promptTokens: safeItem.promptTokens,
24679
+ outputTokens: safeItem.outputTokens,
24680
+ messageCount: safeItem.messageCount
24681
+ }
24682
+ ),
24683
+ safeItem.type === "btw" && /* @__PURE__ */ jsx34(BtwMessage, { btw: safeItem.btw, containerWidth: boxWidth }),
24684
+ safeItem.type === "goal_status" && /* @__PURE__ */ jsx34(
24685
+ GoalStatusMessage,
24686
+ {
24687
+ kind: safeItem.kind,
24688
+ condition: safeItem.condition,
24689
+ iterations: safeItem.iterations,
24690
+ durationMs: safeItem.durationMs,
24691
+ lastReason: safeItem.lastReason
24692
+ }
24693
+ ),
24694
+ safeItem.type === "compression" && /* @__PURE__ */ jsx34(CompressionMessage, { compression: safeItem.compression }),
24695
+ safeItem.type === "summary" && /* @__PURE__ */ jsx34(SummaryMessage, { summary: safeItem.summary }),
24696
+ safeItem.type === "tool_use_summary" && (!compactMode || !summaryAbsorbed) && /* @__PURE__ */ jsx34(Box29, { paddingLeft: 1, children: /* @__PURE__ */ jsxs28(Text32, { dimColor: true, children: [
24105
24697
  "\u25CF ",
24106
24698
  safeItem.summary
24107
24699
  ] }) }),
24108
- safeItem.type === "retry_countdown" && /* @__PURE__ */ jsx27(WarningMessage, { text: safeItem.text }),
24109
- safeItem.type === "away_recap" && /* @__PURE__ */ jsx27(InfoMessage, { text: safeItem.text }),
24110
- safeItem.type === "memory_saved" && /* @__PURE__ */ jsx27(
24700
+ safeItem.type === "retry_countdown" && /* @__PURE__ */ jsx34(WarningMessage, { text: safeItem.text }),
24701
+ safeItem.type === "away_recap" && /* @__PURE__ */ jsx34(InfoMessage, { text: safeItem.text }),
24702
+ safeItem.type === "memory_saved" && /* @__PURE__ */ jsx34(
24111
24703
  InfoMessage,
24112
24704
  {
24113
24705
  text: `${safeItem.verb ?? "Saved"} ${safeItem.writtenCount} ${safeItem.writtenCount === 1 ? "memory file" : "memory files"}.`
24114
24706
  }
24115
24707
  ),
24116
- shouldRenderFallback(safeItem.type) && safeItem.text && /* @__PURE__ */ jsx27(InfoMessage, { text: safeItem.text }),
24117
- safeItem.type === "quit" && /* @__PURE__ */ jsx27(InfoMessage, { text: `Session ended. Duration: ${safeItem.duration}`, width: boxWidth })
24708
+ shouldRenderFallback(safeItem.type) && safeItem.text && /* @__PURE__ */ jsx34(InfoMessage, { text: safeItem.text }),
24709
+ safeItem.type === "quit" && /* @__PURE__ */ jsx34(InfoMessage, { text: `Session ended. Duration: ${safeItem.duration}`, width: boxWidth })
24118
24710
  ] });
24119
24711
  };
24120
24712
  function shouldRenderFallback(type) {
24121
- return type === "notification" || type === "extensions_list" || type === "model_stats" || type === "tool_stats" || type === "stats";
24713
+ return type === "notification" || type === "extensions_list" || type === "model_stats" || type === "tool_stats";
24122
24714
  }
24123
- var InfoMessage = ({ text }) => /* @__PURE__ */ jsxs21(Text25, { color: theme.text.secondary, children: [
24715
+ var InfoMessage = ({ text }) => /* @__PURE__ */ jsxs28(Text32, { color: theme.text.secondary, children: [
24124
24716
  "\u2139 ",
24125
24717
  text
24126
24718
  ] });
24127
- var SuccessMessage = ({ text }) => /* @__PURE__ */ jsxs21(Text25, { color: theme.status.success, children: [
24719
+ var SuccessMessage = ({ text }) => /* @__PURE__ */ jsxs28(Text32, { color: theme.status.success, children: [
24128
24720
  "\u2713 ",
24129
24721
  text
24130
24722
  ] });
24131
- var WarningMessage = ({ text }) => /* @__PURE__ */ jsxs21(Text25, { color: theme.status.warning, children: [
24723
+ var WarningMessage = ({ text }) => /* @__PURE__ */ jsxs28(Text32, { color: theme.status.warning, children: [
24132
24724
  "\u26A0 ",
24133
24725
  text
24134
24726
  ] });
24135
- var ErrorMessage = ({ text }) => /* @__PURE__ */ jsxs21(Text25, { color: theme.status.error, children: [
24727
+ var ErrorMessage = ({ text }) => /* @__PURE__ */ jsxs28(Text32, { color: theme.status.error, children: [
24136
24728
  "\u2717 ",
24137
24729
  text
24138
24730
  ] });
@@ -24291,7 +24883,7 @@ var MainContent = ({
24291
24883
  );
24292
24884
  const prevHistoryLengthRef = useRef6(history.length);
24293
24885
  const prevMergedLengthRef = useRef6(mergedHistory.length);
24294
- useEffect14(() => {
24886
+ useEffect15(() => {
24295
24887
  if (!compactMode) {
24296
24888
  prevHistoryLengthRef.current = history.length;
24297
24889
  prevMergedLengthRef.current = mergedHistory.length;
@@ -24307,17 +24899,17 @@ var MainContent = ({
24307
24899
  prevHistoryLengthRef.current = currH;
24308
24900
  prevMergedLengthRef.current = currM;
24309
24901
  }, [compactMode, history, mergedHistory, refreshStatic]);
24310
- const [replayCount, setReplayCount] = useState12(
24902
+ const [replayCount, setReplayCount] = useState13(
24311
24903
  () => initialReplayCount(mergedHistory.length)
24312
24904
  );
24313
24905
  const mergedLengthRef = useRef6(mergedHistory.length);
24314
24906
  mergedLengthRef.current = mergedHistory.length;
24315
- const [lastRemountKey, setLastRemountKey] = useState12(historyRemountKey);
24907
+ const [lastRemountKey, setLastRemountKey] = useState13(historyRemountKey);
24316
24908
  if (lastRemountKey !== historyRemountKey) {
24317
24909
  setLastRemountKey(historyRemountKey);
24318
24910
  setReplayCount(initialReplayCount(mergedLengthRef.current));
24319
24911
  }
24320
- useEffect14(() => {
24912
+ useEffect15(() => {
24321
24913
  if (replayCount >= mergedHistory.length) return;
24322
24914
  const remaining = mergedHistory.length - replayCount;
24323
24915
  if (remaining <= PROGRESSIVE_REPLAY_CHUNK_SIZE) {
@@ -24330,8 +24922,8 @@ var MainContent = ({
24330
24922
  return () => clearImmediate(handle);
24331
24923
  }, [replayCount, mergedHistory.length]);
24332
24924
  const visibleHistory = mergedHistory.length - replayCount <= PROGRESSIVE_REPLAY_CHUNK_SIZE ? mergedHistory : mergedHistory.slice(0, replayCount);
24333
- return /* @__PURE__ */ jsxs22(Box23, { flexDirection: "column", flexGrow: 1, children: [
24334
- /* @__PURE__ */ jsx28(Static, { items: visibleHistory, children: (item) => /* @__PURE__ */ jsx28(
24925
+ return /* @__PURE__ */ jsxs29(Box30, { flexDirection: "column", flexGrow: 1, children: [
24926
+ /* @__PURE__ */ jsx35(Static, { items: visibleHistory, children: (item) => /* @__PURE__ */ jsx35(
24335
24927
  HistoryItemDisplay,
24336
24928
  {
24337
24929
  item,
@@ -24344,7 +24936,7 @@ var MainContent = ({
24344
24936
  },
24345
24937
  item.id
24346
24938
  ) }, historyRemountKey),
24347
- pendingAssistantText.trim().length > 0 && /* @__PURE__ */ jsx28(
24939
+ pendingAssistantText.trim().length > 0 && /* @__PURE__ */ jsx35(
24348
24940
  HistoryItemDisplay,
24349
24941
  {
24350
24942
  item: { id: -1, type: "gemini", text: pendingAssistantText },
@@ -24354,7 +24946,7 @@ var MainContent = ({
24354
24946
  isFocused
24355
24947
  }
24356
24948
  ),
24357
- liveToolCalls.length > 0 && /* @__PURE__ */ jsx28(
24949
+ liveToolCalls.length > 0 && /* @__PURE__ */ jsx35(
24358
24950
  HistoryItemDisplay,
24359
24951
  {
24360
24952
  item: { id: -2, type: "tool_group", tools: liveToolCalls },
@@ -24367,25 +24959,14 @@ var MainContent = ({
24367
24959
  )
24368
24960
  ] });
24369
24961
  };
24370
- function useTerminalSize() {
24371
- const [size, setSize] = useState13({
24372
- columns: process.stdout.columns || 80,
24373
- rows: process.stdout.rows || 24
24374
- });
24375
- useEffect15(() => {
24376
- function updateSize() {
24377
- setSize({
24378
- columns: process.stdout.columns || 80,
24379
- rows: process.stdout.rows || 24
24380
- });
24381
- }
24382
- process.stdout.on("resize", updateSize);
24383
- return () => {
24384
- process.stdout.off("resize", updateSize);
24385
- };
24386
- }, []);
24387
- return size;
24388
- }
24962
+ var ShowMoreLines = ({ constrainHeight }) => {
24963
+ const overflowState = useOverflowState();
24964
+ const streamingState = useStreamingContext();
24965
+ if (overflowState === void 0 || overflowState.overflowingIds.size === 0 || !constrainHeight || !(streamingState === "idle" || streamingState === "waiting_for_confirmation")) {
24966
+ return null;
24967
+ }
24968
+ return /* @__PURE__ */ jsx36(Box31, { children: /* @__PURE__ */ jsx36(Text33, { color: theme.text.secondary, wrap: "truncate", children: "Press ctrl-s to show more lines" }) });
24969
+ };
24389
24970
  function useAnimationFrame(watchRef, intervalMs = 50) {
24390
24971
  const [displayValue, setDisplayValue] = useState14(() => watchRef.current);
24391
24972
  const displayRef = useRef7(watchRef.current);
@@ -24466,34 +25047,34 @@ var LoadingIndicator = ({
24466
25047
  time: timeStr,
24467
25048
  tokens: tokenStr
24468
25049
  }) : null;
24469
- return /* @__PURE__ */ jsxs23(Box24, { paddingLeft: 2, flexDirection: "column", children: [
24470
- /* @__PURE__ */ jsxs23(
24471
- Box24,
25050
+ return /* @__PURE__ */ jsxs30(Box32, { paddingLeft: 2, flexDirection: "column", children: [
25051
+ /* @__PURE__ */ jsxs30(
25052
+ Box32,
24472
25053
  {
24473
25054
  width: "100%",
24474
25055
  flexDirection: isNarrow ? "column" : "row",
24475
25056
  alignItems: isNarrow ? "flex-start" : "center",
24476
25057
  children: [
24477
- /* @__PURE__ */ jsxs23(Box24, { children: [
24478
- /* @__PURE__ */ jsx29(Box24, { marginRight: 1, children: /* @__PURE__ */ jsx29(
25058
+ /* @__PURE__ */ jsxs30(Box32, { children: [
25059
+ /* @__PURE__ */ jsx37(Box32, { marginRight: 1, children: /* @__PURE__ */ jsx37(
24479
25060
  GeminiRespondingSpinner,
24480
25061
  {
24481
25062
  nonRespondingDisplay: streamingState === "waiting_for_confirmation" ? "\u280F" : ""
24482
25063
  }
24483
25064
  ) }),
24484
- primaryText && /* @__PURE__ */ jsx29(Text26, { color: theme.text.accent, wrap: "truncate-end", children: primaryText }),
24485
- !isNarrow && cancelAndTimerContent && /* @__PURE__ */ jsxs23(Text26, { color: theme.text.secondary, children: [
25065
+ primaryText && /* @__PURE__ */ jsx37(Text34, { color: theme.text.accent, wrap: "truncate-end", children: primaryText }),
25066
+ !isNarrow && cancelAndTimerContent && /* @__PURE__ */ jsxs30(Text34, { color: theme.text.secondary, children: [
24486
25067
  " ",
24487
25068
  cancelAndTimerContent
24488
25069
  ] })
24489
25070
  ] }),
24490
- !isNarrow && /* @__PURE__ */ jsx29(Box24, { flexGrow: 1 }),
24491
- !isNarrow && rightContent && /* @__PURE__ */ jsx29(Box24, { children: rightContent })
25071
+ !isNarrow && /* @__PURE__ */ jsx37(Box32, { flexGrow: 1 }),
25072
+ !isNarrow && rightContent && /* @__PURE__ */ jsx37(Box32, { children: rightContent })
24492
25073
  ]
24493
25074
  }
24494
25075
  ),
24495
- isNarrow && cancelAndTimerContent && /* @__PURE__ */ jsx29(Box24, { children: /* @__PURE__ */ jsx29(Text26, { color: theme.text.secondary, children: cancelAndTimerContent }) }),
24496
- isNarrow && rightContent && /* @__PURE__ */ jsx29(Box24, { children: rightContent })
25076
+ isNarrow && cancelAndTimerContent && /* @__PURE__ */ jsx37(Box32, { children: /* @__PURE__ */ jsx37(Text34, { color: theme.text.secondary, children: cancelAndTimerContent }) }),
25077
+ isNarrow && rightContent && /* @__PURE__ */ jsx37(Box32, { children: rightContent })
24497
25078
  ] });
24498
25079
  };
24499
25080
  var MAX_WIDTH = 150;
@@ -24507,7 +25088,7 @@ var _PrepareLabel = ({
24507
25088
  const hasMatch = matchedIndex !== void 0 && matchedIndex >= 0 && matchedIndex < label.length && userInput.length > 0;
24508
25089
  if (!hasMatch) {
24509
25090
  const display = isExpanded ? label : label.length > MAX_WIDTH ? label.slice(0, MAX_WIDTH) + "..." : label;
24510
- return /* @__PURE__ */ jsx30(Text27, { wrap: "wrap", color: textColor, children: display });
25091
+ return /* @__PURE__ */ jsx38(Text35, { wrap: "wrap", color: textColor, children: display });
24511
25092
  }
24512
25093
  const matchLength = userInput.length;
24513
25094
  let before = "";
@@ -24546,10 +25127,10 @@ var _PrepareLabel = ({
24546
25127
  after = after.length >= 3 ? after.slice(0, -3) + "..." : "...";
24547
25128
  }
24548
25129
  }
24549
- return /* @__PURE__ */ jsxs24(Text27, { color: textColor, wrap: "wrap", children: [
25130
+ return /* @__PURE__ */ jsxs31(Text35, { color: textColor, wrap: "wrap", children: [
24550
25131
  before,
24551
- match ? match.split(/(\s+)/).map((part, index) => /* @__PURE__ */ jsx30(
24552
- Text27,
25132
+ match ? match.split(/(\s+)/).map((part, index) => /* @__PURE__ */ jsx38(
25133
+ Text35,
24553
25134
  {
24554
25135
  color: theme.background.primary,
24555
25136
  backgroundColor: theme.text.primary,
@@ -24560,7 +25141,7 @@ var _PrepareLabel = ({
24560
25141
  after
24561
25142
  ] });
24562
25143
  };
24563
- var PrepareLabel = React25.memo(_PrepareLabel);
25144
+ var PrepareLabel = React27.memo(_PrepareLabel);
24564
25145
  var MAX_SUGGESTIONS_TO_SHOW = 8;
24565
25146
  function SuggestionsDisplay({
24566
25147
  suggestions,
@@ -24573,7 +25154,7 @@ function SuggestionsDisplay({
24573
25154
  expandedIndex
24574
25155
  }) {
24575
25156
  if (isLoading) {
24576
- return /* @__PURE__ */ jsx31(Box25, { width, children: /* @__PURE__ */ jsx31(Text28, { color: "gray", children: t("Loading suggestions...") }) });
25157
+ return /* @__PURE__ */ jsx39(Box33, { width, children: /* @__PURE__ */ jsx39(Text36, { color: "gray", children: t("Loading suggestions...") }) });
24577
25158
  }
24578
25159
  if (suggestions.length === 0) {
24579
25160
  return null;
@@ -24589,8 +25170,8 @@ function SuggestionsDisplay({
24589
25170
  ...suggestions.map((s) => getFullLabel(s).length)
24590
25171
  );
24591
25172
  const commandColumnWidth = mode === "slash" ? Math.min(maxLabelLength, Math.floor(width * 0.5)) : 0;
24592
- return /* @__PURE__ */ jsxs25(Box25, { flexDirection: "column", width, children: [
24593
- scrollOffset > 0 && /* @__PURE__ */ jsx31(Text28, { color: theme.text.primary, children: "\u25B2" }),
25173
+ return /* @__PURE__ */ jsxs32(Box33, { flexDirection: "column", width, children: [
25174
+ scrollOffset > 0 && /* @__PURE__ */ jsx39(Text36, { color: theme.text.primary, children: "\u25B2" }),
24594
25175
  visibleSuggestions.map((suggestion, index) => {
24595
25176
  const originalIndex = startIndex + index;
24596
25177
  const isActive = originalIndex === activeIndex;
@@ -24603,7 +25184,7 @@ function SuggestionsDisplay({
24603
25184
  width - commandColumnWidth - 2 - expansionIndicatorWidth,
24604
25185
  1
24605
25186
  );
24606
- const labelElement = /* @__PURE__ */ jsx31(
25187
+ const labelElement = /* @__PURE__ */ jsx39(
24607
25188
  PrepareLabel,
24608
25189
  {
24609
25190
  label: displayLabel,
@@ -24613,39 +25194,39 @@ function SuggestionsDisplay({
24613
25194
  isExpanded
24614
25195
  }
24615
25196
  );
24616
- return /* @__PURE__ */ jsxs25(Box25, { flexDirection: "row", children: [
24617
- /* @__PURE__ */ jsx31(
24618
- Box25,
25197
+ return /* @__PURE__ */ jsxs32(Box33, { flexDirection: "row", children: [
25198
+ /* @__PURE__ */ jsx39(
25199
+ Box33,
24619
25200
  {
24620
25201
  ...mode === "slash" ? { width: commandColumnWidth, flexShrink: 0 } : { flexShrink: 1 },
24621
- children: /* @__PURE__ */ jsxs25(Box25, { children: [
25202
+ children: /* @__PURE__ */ jsxs32(Box33, { children: [
24622
25203
  labelElement,
24623
- suggestion.argumentHint && /* @__PURE__ */ jsxs25(Text28, { color: theme.text.secondary, children: [
25204
+ suggestion.argumentHint && /* @__PURE__ */ jsxs32(Text36, { color: theme.text.secondary, children: [
24624
25205
  " ",
24625
25206
  suggestion.argumentHint
24626
25207
  ] }),
24627
- suggestion.sourceBadge && /* @__PURE__ */ jsxs25(Text28, { color: textColor, children: [
25208
+ suggestion.sourceBadge && /* @__PURE__ */ jsxs32(Text36, { color: textColor, children: [
24628
25209
  " ",
24629
25210
  suggestion.sourceBadge
24630
25211
  ] })
24631
25212
  ] })
24632
25213
  }
24633
25214
  ),
24634
- suggestion.description && /* @__PURE__ */ jsx31(
24635
- Box25,
25215
+ suggestion.description && /* @__PURE__ */ jsx39(
25216
+ Box33,
24636
25217
  {
24637
25218
  width: descriptionColumnWidth,
24638
25219
  flexGrow: 1,
24639
25220
  flexShrink: 1,
24640
25221
  paddingLeft: 2,
24641
- children: /* @__PURE__ */ jsx31(Text28, { color: textColor, wrap: "wrap", children: suggestion.description })
25222
+ children: /* @__PURE__ */ jsx39(Text36, { color: textColor, wrap: "wrap", children: suggestion.description })
24642
25223
  }
24643
25224
  ),
24644
- isActive && isLong && /* @__PURE__ */ jsx31(Box25, { children: /* @__PURE__ */ jsx31(Text28, { color: Colors.Gray, children: isExpanded ? " \u2190 " : " \u2192 " }) })
25225
+ isActive && isLong && /* @__PURE__ */ jsx39(Box33, { children: /* @__PURE__ */ jsx39(Text36, { color: Colors.Gray, children: isExpanded ? " \u2190 " : " \u2192 " }) })
24645
25226
  ] }, `${suggestion.value}-${originalIndex}`);
24646
25227
  }),
24647
- endIndex < suggestions.length && /* @__PURE__ */ jsx31(Text28, { color: "gray", children: "\u25BC" }),
24648
- suggestions.length > MAX_SUGGESTIONS_TO_SHOW && /* @__PURE__ */ jsxs25(Text28, { color: "gray", children: [
25228
+ endIndex < suggestions.length && /* @__PURE__ */ jsx39(Text36, { color: "gray", children: "\u25BC" }),
25229
+ suggestions.length > MAX_SUGGESTIONS_TO_SHOW && /* @__PURE__ */ jsxs32(Text36, { color: "gray", children: [
24649
25230
  "(",
24650
25231
  activeIndex + 1,
24651
25232
  "/",
@@ -26063,10 +26644,10 @@ function useExportCompletion(buffer, slashCommands) {
26063
26644
  const cyclingActiveRef = useRef11(false);
26064
26645
  const nextTextChangeWasUserInputRef = useRef11(false);
26065
26646
  const exportFormatSuggestions = useMemo10(() => {
26066
- const exportCommand = slashCommands.find(
26647
+ const exportCommand2 = slashCommands.find(
26067
26648
  (command) => command.name === EXPORT_COMMAND_INPUT.slice(1)
26068
26649
  );
26069
- const subCommands = exportCommand?.subCommands;
26650
+ const subCommands = exportCommand2?.subCommands;
26070
26651
  if (subCommands && subCommands.length > 0) {
26071
26652
  return subCommands.map((command) => ({
26072
26653
  label: command.name,
@@ -26085,8 +26666,8 @@ function useExportCompletion(buffer, slashCommands) {
26085
26666
  nextTextChangeWasUserInputRef.current = true;
26086
26667
  }, []);
26087
26668
  useEffect222(() => {
26088
- const fmt = getExportFormatFromInput(buffer.text, exportCycleFormats);
26089
- if (nextTextChangeWasUserInputRef.current && fmt !== null && !cyclingActiveRef.current) {
26669
+ const fmt2 = getExportFormatFromInput(buffer.text, exportCycleFormats);
26670
+ if (nextTextChangeWasUserInputRef.current && fmt2 !== null && !cyclingActiveRef.current) {
26090
26671
  cyclingActiveRef.current = true;
26091
26672
  }
26092
26673
  nextTextChangeWasUserInputRef.current = false;
@@ -26395,11 +26976,11 @@ function defaultRenderLine({
26395
26976
  showCursor
26396
26977
  }) {
26397
26978
  if (!isOnCursorLine || !showCursor) {
26398
- return /* @__PURE__ */ jsx32(Text29, { children: lineText || " " });
26979
+ return /* @__PURE__ */ jsx40(Text37, { children: lineText || " " });
26399
26980
  }
26400
26981
  const len = cpLen(lineText);
26401
26982
  if (cursorCol >= len) {
26402
- return /* @__PURE__ */ jsxs26(Text29, { children: [
26983
+ return /* @__PURE__ */ jsxs33(Text37, { children: [
26403
26984
  lineText,
26404
26985
  chalk2.inverse(" ") + "\u200B"
26405
26986
  ] });
@@ -26407,7 +26988,7 @@ function defaultRenderLine({
26407
26988
  const before = cpSlice(lineText, 0, cursorCol);
26408
26989
  const cursorChar = cpSlice(lineText, cursorCol, cursorCol + 1);
26409
26990
  const after = cpSlice(lineText, cursorCol + 1);
26410
- return /* @__PURE__ */ jsxs26(Text29, { children: [
26991
+ return /* @__PURE__ */ jsxs33(Text37, { children: [
26411
26992
  before,
26412
26993
  chalk2.inverse(cursorChar),
26413
26994
  after
@@ -26530,15 +27111,15 @@ var BaseTextInput = ({
26530
27111
  const [cursorVisualRow, cursorVisualCol] = buffer.visualCursor;
26531
27112
  const scrollVisualRow = buffer.visualScrollRow;
26532
27113
  const resolvedBorderColor = borderColor ?? theme.border.focused;
26533
- const resolvedPrefix = prefix ?? /* @__PURE__ */ jsx32(Text29, { color: theme.text.accent, children: "> " });
27114
+ const resolvedPrefix = prefix ?? /* @__PURE__ */ jsx40(Text37, { color: theme.text.accent, children: "> " });
26534
27115
  const columns = process.stdout.columns || 80;
26535
27116
  const labelWidth = topRightLabel ? stringWidth(topRightLabel) + 4 : 0;
26536
27117
  const dashCount = Math.max(1, columns - labelWidth);
26537
27118
  const topBorderLine = topRightLabel ? `${"\u2500".repeat(dashCount)} ${topRightLabel} ${"\u2500".repeat(2)}` : "\u2500".repeat(columns);
26538
- return /* @__PURE__ */ jsxs26(Box26, { flexDirection: "column", children: [
26539
- /* @__PURE__ */ jsx32(Text29, { color: resolvedBorderColor, wrap: "truncate-end", children: topBorderLine }),
26540
- /* @__PURE__ */ jsxs26(
26541
- Box26,
27119
+ return /* @__PURE__ */ jsxs33(Box34, { flexDirection: "column", children: [
27120
+ /* @__PURE__ */ jsx40(Text37, { color: resolvedBorderColor, wrap: "truncate-end", children: topBorderLine }),
27121
+ /* @__PURE__ */ jsxs33(
27122
+ Box34,
26542
27123
  {
26543
27124
  borderStyle: "single",
26544
27125
  borderTop: false,
@@ -26548,13 +27129,13 @@ var BaseTextInput = ({
26548
27129
  borderColor: resolvedBorderColor,
26549
27130
  children: [
26550
27131
  resolvedPrefix,
26551
- /* @__PURE__ */ jsx32(Box26, { flexGrow: 1, flexDirection: "column", children: buffer.text.length === 0 && placeholder ? showCursor ? /* @__PURE__ */ jsxs26(Text29, { children: [
27132
+ /* @__PURE__ */ jsx40(Box34, { flexGrow: 1, flexDirection: "column", children: buffer.text.length === 0 && placeholder ? showCursor ? /* @__PURE__ */ jsxs33(Text37, { children: [
26552
27133
  chalk2.inverse(placeholder.slice(0, 1)),
26553
- /* @__PURE__ */ jsx32(Text29, { color: theme.text.secondary, children: placeholder.slice(1) })
26554
- ] }) : /* @__PURE__ */ jsx32(Text29, { color: theme.text.secondary, children: placeholder }) : linesToRender.map((lineText, idx) => {
27134
+ /* @__PURE__ */ jsx40(Text37, { color: theme.text.secondary, children: placeholder.slice(1) })
27135
+ ] }) : /* @__PURE__ */ jsx40(Text37, { color: theme.text.secondary, children: placeholder }) : linesToRender.map((lineText, idx) => {
26555
27136
  const absoluteVisualIndex = scrollVisualRow + idx;
26556
27137
  const isOnCursorLine = absoluteVisualIndex === cursorVisualRow;
26557
- return /* @__PURE__ */ jsx32(Box26, { height: 1, children: renderLine({
27138
+ return /* @__PURE__ */ jsx40(Box34, { height: 1, children: renderLine({
26558
27139
  lineText,
26559
27140
  isOnCursorLine,
26560
27141
  cursorCol: cursorVisualCol,
@@ -27518,7 +28099,7 @@ ${currentText}`);
27518
28099
  }
27519
28100
  const color = seg.type === "command" || seg.type === "file" ? theme.text.accent : theme.text.primary;
27520
28101
  renderedLine.push(
27521
- /* @__PURE__ */ jsx33(Text30, { color, children: display }, `token-${segIdx}`)
28102
+ /* @__PURE__ */ jsx41(Text38, { color, children: display }, `token-${segIdx}`)
27522
28103
  );
27523
28104
  });
27524
28105
  if (isOnCursorLine && cursorVisualColAbsolute === cpLen(lineText)) {
@@ -27526,31 +28107,31 @@ ${currentText}`);
27526
28107
  if (ghostText && showCursorOpt && ghostText.text.length > 0) {
27527
28108
  if (ghostText.showCursorBeforeText) {
27528
28109
  renderedLine.push(
27529
- /* @__PURE__ */ jsx33(Text30, { children: chalk3.inverse(" ") }, "ghost-cursor")
28110
+ /* @__PURE__ */ jsx41(Text38, { children: chalk3.inverse(" ") }, "ghost-cursor")
27530
28111
  );
27531
28112
  renderedLine.push(
27532
- /* @__PURE__ */ jsx33(Text30, { color: theme.text.secondary, children: ghostText.text }, "ghost-rest")
28113
+ /* @__PURE__ */ jsx41(Text38, { color: theme.text.secondary, children: ghostText.text }, "ghost-rest")
27533
28114
  );
27534
28115
  } else {
27535
28116
  const firstChar = ghostText.text[0];
27536
28117
  const rest = ghostText.text.slice(firstChar.length);
27537
28118
  renderedLine.push(
27538
- /* @__PURE__ */ jsx33(Text30, { children: chalk3.inverse(firstChar) }, "ghost-cursor")
28119
+ /* @__PURE__ */ jsx41(Text38, { children: chalk3.inverse(firstChar) }, "ghost-cursor")
27539
28120
  );
27540
28121
  if (rest.length > 0) {
27541
28122
  renderedLine.push(
27542
- /* @__PURE__ */ jsx33(Text30, { color: theme.text.secondary, children: rest }, "ghost-rest")
28123
+ /* @__PURE__ */ jsx41(Text38, { color: theme.text.secondary, children: rest }, "ghost-rest")
27543
28124
  );
27544
28125
  }
27545
28126
  }
27546
- renderedLine.push(/* @__PURE__ */ jsx33(Text30, { children: `\u200B` }, "ghost-zwsp"));
28127
+ renderedLine.push(/* @__PURE__ */ jsx41(Text38, { children: `\u200B` }, "ghost-zwsp"));
27547
28128
  } else {
27548
28129
  renderedLine.push(
27549
- /* @__PURE__ */ jsx33(Text30, { children: showCursorOpt ? chalk3.inverse(" ") + "\u200B" : " \u200B" }, `cursor-end-${cursorVisualColAbsolute}`)
28130
+ /* @__PURE__ */ jsx41(Text38, { children: showCursorOpt ? chalk3.inverse(" ") + "\u200B" : " \u200B" }, `cursor-end-${cursorVisualColAbsolute}`)
27550
28131
  );
27551
28132
  }
27552
28133
  }
27553
- return /* @__PURE__ */ jsx33(Text30, { children: renderedLine });
28134
+ return /* @__PURE__ */ jsx41(Text38, { children: renderedLine });
27554
28135
  },
27555
28136
  [slashCommands]
27556
28137
  );
@@ -27591,25 +28172,25 @@ ${currentText}`);
27591
28172
  statusText = t("Accepting edits");
27592
28173
  }
27593
28174
  const borderColor = isShellFocused && !isEmbeddedShellFocused && !agentTabBarFocused ? statusColor2 ?? theme.border.focused : theme.border.default;
27594
- const prefixNode = /* @__PURE__ */ jsxs27(
27595
- Text30,
28175
+ const prefixNode = /* @__PURE__ */ jsxs34(
28176
+ Text38,
27596
28177
  {
27597
28178
  color: statusColor2 ?? theme.text.accent,
27598
28179
  "aria-label": statusText || void 0,
27599
28180
  children: [
27600
- shellModeActive ? reverseSearchActive ? /* @__PURE__ */ jsxs27(Text30, { color: theme.text.link, "aria-label": SCREEN_READER_USER_PREFIX, children: [
28181
+ shellModeActive ? reverseSearchActive ? /* @__PURE__ */ jsxs34(Text38, { color: theme.text.link, "aria-label": SCREEN_READER_USER_PREFIX, children: [
27601
28182
  "(r:)",
27602
28183
  " "
27603
- ] }) : "!" : commandSearchActive ? /* @__PURE__ */ jsx33(Text30, { color: theme.text.accent, children: "(r:) " }) : showYoloStyling ? "*" : ">",
28184
+ ] }) : "!" : commandSearchActive ? /* @__PURE__ */ jsx41(Text38, { color: theme.text.accent, children: "(r:) " }) : showYoloStyling ? "*" : ">",
27604
28185
  " "
27605
28186
  ]
27606
28187
  }
27607
28188
  );
27608
- return /* @__PURE__ */ jsxs27(Fragment7, { children: [
27609
- attachments.length > 0 && /* @__PURE__ */ jsxs27(Box27, { marginLeft: 2, marginBottom: 0, children: [
27610
- /* @__PURE__ */ jsx33(Text30, { color: theme.text.secondary, children: t("Attachments: ") }),
27611
- attachments.map((att, idx) => /* @__PURE__ */ jsxs27(
27612
- Text30,
28189
+ return /* @__PURE__ */ jsxs34(Fragment9, { children: [
28190
+ attachments.length > 0 && /* @__PURE__ */ jsxs34(Box35, { marginLeft: 2, marginBottom: 0, children: [
28191
+ /* @__PURE__ */ jsx41(Text38, { color: theme.text.secondary, children: t("Attachments: ") }),
28192
+ attachments.map((att, idx) => /* @__PURE__ */ jsxs34(
28193
+ Text38,
27613
28194
  {
27614
28195
  color: isAttachmentMode && idx === selectedAttachmentIndex ? theme.status.success : theme.text.secondary,
27615
28196
  children: [
@@ -27622,7 +28203,7 @@ ${currentText}`);
27622
28203
  att.id
27623
28204
  ))
27624
28205
  ] }),
27625
- /* @__PURE__ */ jsx33(
28206
+ /* @__PURE__ */ jsx41(
27626
28207
  BaseTextInput,
27627
28208
  {
27628
28209
  buffer,
@@ -27637,7 +28218,7 @@ ${currentText}`);
27637
28218
  renderLine: renderLineWithHighlighting
27638
28219
  }
27639
28220
  ),
27640
- shouldShowSuggestions && /* @__PURE__ */ jsx33(Box27, { marginLeft: 2, marginRight: 2, children: /* @__PURE__ */ jsx33(
28221
+ shouldShowSuggestions && /* @__PURE__ */ jsx41(Box35, { marginLeft: 2, marginRight: 2, children: /* @__PURE__ */ jsx41(
27641
28222
  SuggestionsDisplay,
27642
28223
  {
27643
28224
  suggestions: suggestionDisplayProps.suggestions,
@@ -27650,7 +28231,7 @@ ${currentText}`);
27650
28231
  expandedIndex: expandedSuggestionIndex
27651
28232
  }
27652
28233
  ) }),
27653
- attachments.length > 0 && !shouldShowSuggestions && /* @__PURE__ */ jsx33(Box27, { marginLeft: 2, marginRight: 2, children: /* @__PURE__ */ jsx33(Text30, { color: theme.text.secondary, children: isAttachmentMode ? t("\u2190 \u2192 select, Delete to remove, \u2193 to exit") : t("\u2191 to manage attachments") }) })
28234
+ attachments.length > 0 && !shouldShowSuggestions && /* @__PURE__ */ jsx41(Box35, { marginLeft: 2, marginRight: 2, children: /* @__PURE__ */ jsx41(Text38, { color: theme.text.secondary, children: isAttachmentMode ? t("\u2190 \u2192 select, Delete to remove, \u2193 to exit") : t("\u2191 to manage attachments") }) })
27654
28235
  ] });
27655
28236
  };
27656
28237
  function formatPercentageUsed(percentage) {
@@ -27672,12 +28253,12 @@ var ContextUsageDisplay = ({
27672
28253
  const isOverLimit = percentage > 1;
27673
28254
  const label = terminalWidth < 100 ? t("% used") : t("% context used");
27674
28255
  if (isOverLimit) {
27675
- return /* @__PURE__ */ jsx34(Fragment8, { children: /* @__PURE__ */ jsxs28(Text31, { color: theme.status.error, children: [
28256
+ return /* @__PURE__ */ jsx42(Fragment10, { children: /* @__PURE__ */ jsxs35(Text39, { color: theme.status.error, children: [
27676
28257
  percentageUsed,
27677
28258
  label
27678
28259
  ] }) });
27679
28260
  }
27680
- return /* @__PURE__ */ jsxs28(Text31, { color: theme.text.secondary, children: [
28261
+ return /* @__PURE__ */ jsxs35(Text39, { color: theme.text.secondary, children: [
27681
28262
  percentageUsed,
27682
28263
  label
27683
28264
  ] });
@@ -27709,20 +28290,20 @@ var AutoAcceptIndicator = ({
27709
28290
  default:
27710
28291
  break;
27711
28292
  }
27712
- return /* @__PURE__ */ jsxs29(Text32, { color: textColor, children: [
28293
+ return /* @__PURE__ */ jsxs36(Text40, { color: textColor, children: [
27713
28294
  textContent,
27714
- subText && /* @__PURE__ */ jsx35(Text32, { color: theme.text.secondary, children: subText })
28295
+ subText && /* @__PURE__ */ jsx43(Text40, { color: theme.text.secondary, children: subText })
27715
28296
  ] });
27716
28297
  };
27717
- var ShellModeIndicator = () => /* @__PURE__ */ jsxs30(Text33, { color: theme.ui.symbol, children: [
28298
+ var ShellModeIndicator = () => /* @__PURE__ */ jsxs37(Text41, { color: theme.ui.symbol, children: [
27718
28299
  "shell mode enabled",
27719
- /* @__PURE__ */ jsx36(Text33, { color: theme.text.secondary, children: " (esc to disable)" })
28300
+ /* @__PURE__ */ jsx44(Text41, { color: theme.text.secondary, children: " (esc to disable)" })
27720
28301
  ] });
27721
28302
  function BackgroundTasksPill() {
27722
28303
  const { activeSubagents } = useUIState();
27723
28304
  const running = activeSubagents.filter((s) => s.status === "running").length;
27724
28305
  if (running <= 0) return null;
27725
- return /* @__PURE__ */ jsxs31(Text34, { color: theme.text.accent, children: [
28306
+ return /* @__PURE__ */ jsxs38(Text42, { color: theme.text.accent, children: [
27726
28307
  " ",
27727
28308
  running,
27728
28309
  " task",
@@ -27733,32 +28314,36 @@ function MCPHealthPill() {
27733
28314
  const { mcpConnected, mcpTotal } = useUIState();
27734
28315
  if (mcpTotal === 0) return null;
27735
28316
  const color = mcpConnected === mcpTotal ? theme.status.success : theme.status.warning;
27736
- return /* @__PURE__ */ jsxs32(Text35, { color, children: [
28317
+ return /* @__PURE__ */ jsxs39(Text43, { color, children: [
27737
28318
  " MCP ",
27738
28319
  mcpConnected,
27739
28320
  "/",
27740
28321
  mcpTotal
27741
28322
  ] });
27742
28323
  }
28324
+ var GIT_POLL_INTERVAL_MS = 3e4;
27743
28325
  function useStatusLine() {
27744
28326
  const config = useConfig();
27745
28327
  const cwd = config.getWorkingDir();
27746
- const [line, setLine] = useState222(null);
28328
+ const [branch, setBranch] = useState222(null);
27747
28329
  useEffect24(() => {
27748
- let cancelled = false;
27749
- execFile22("git", ["branch", "--show-current"], { cwd }, (err, stdout) => {
27750
- if (cancelled) return;
27751
- const branch = err ? null : stdout.trim();
27752
- if (!branch) return;
27753
- const home = os5.homedir();
27754
- const displayCwd = cwd.startsWith(home) ? `~${cwd.slice(home.length)}` : cwd;
27755
- setLine(`${displayCwd} [${branch}]`);
27756
- });
28330
+ let alive = true;
28331
+ function poll() {
28332
+ execFile22("git", ["branch", "--show-current"], { cwd }, (err, stdout) => {
28333
+ if (alive) setBranch(err ? null : stdout.trim() || null);
28334
+ });
28335
+ }
28336
+ poll();
28337
+ const timer = setInterval(poll, GIT_POLL_INTERVAL_MS);
27757
28338
  return () => {
27758
- cancelled = true;
28339
+ alive = false;
28340
+ clearInterval(timer);
27759
28341
  };
27760
28342
  }, [cwd]);
27761
- return { lines: line ? [line] : [] };
28343
+ if (!branch) return { lines: [] };
28344
+ const home = os5.homedir();
28345
+ const displayCwd = cwd.startsWith(home) ? `~${cwd.slice(home.length)}` : cwd;
28346
+ return { lines: [`${displayCwd} [${branch}]`] };
27762
28347
  }
27763
28348
  function useConfigInitMessage(_isConfigInitialized) {
27764
28349
  return null;
@@ -27778,7 +28363,7 @@ var VimModeProvider = ({
27778
28363
  setVimMode(next ? "NORMAL" : "INSERT");
27779
28364
  return next;
27780
28365
  }, [vimEnabled]);
27781
- return /* @__PURE__ */ jsx37(
28366
+ return /* @__PURE__ */ jsx45(
27782
28367
  VimModeContext.Provider,
27783
28368
  {
27784
28369
  value: { vimEnabled, vimMode, toggleVimEnabled, setVimMode },
@@ -27810,16 +28395,16 @@ var Footer = () => {
27810
28395
  const debugMode = config.getDebugMode();
27811
28396
  const contextWindowSize = config.getContentGeneratorConfig()?.contextWindowSize;
27812
28397
  const suppressHint = statusLineLines.length > 0;
27813
- const leftBottomContent = uiState.ctrlCPressedOnce ? /* @__PURE__ */ jsx38(Text36, { color: theme.status.warning, children: t("Press Ctrl+C again to exit.") }) : uiState.ctrlDPressedOnce ? /* @__PURE__ */ jsx38(Text36, { color: theme.status.warning, children: t("Press Ctrl+D again to exit.") }) : uiState.showEscapePrompt ? /* @__PURE__ */ jsx38(Text36, { color: theme.text.secondary, children: t("Press Esc again to clear.") }) : uiState.rewindEscPending ? /* @__PURE__ */ jsx38(Text36, { color: theme.text.secondary, children: t("Press Esc again to rewind conversation.") }) : vimEnabled && vimMode === "INSERT" ? /* @__PURE__ */ jsx38(Text36, { color: theme.text.secondary, children: "-- INSERT --" }) : uiState.shellModeActive ? /* @__PURE__ */ jsx38(ShellModeIndicator, {}) : configInitMessage ? /* @__PURE__ */ jsxs33(Text36, { color: theme.text.secondary, children: [
27814
- /* @__PURE__ */ jsx38(GeminiSpinner, {}),
28398
+ const leftBottomContent = uiState.ctrlCPressedOnce ? /* @__PURE__ */ jsx46(Text44, { color: theme.status.warning, children: t("Press Ctrl+C again to exit.") }) : uiState.ctrlDPressedOnce ? /* @__PURE__ */ jsx46(Text44, { color: theme.status.warning, children: t("Press Ctrl+D again to exit.") }) : uiState.showEscapePrompt ? /* @__PURE__ */ jsx46(Text44, { color: theme.text.secondary, children: t("Press Esc again to clear.") }) : uiState.rewindEscPending ? /* @__PURE__ */ jsx46(Text44, { color: theme.text.secondary, children: t("Press Esc again to rewind conversation.") }) : vimEnabled && vimMode === "INSERT" ? /* @__PURE__ */ jsx46(Text44, { color: theme.text.secondary, children: "-- INSERT --" }) : uiState.shellModeActive ? /* @__PURE__ */ jsx46(ShellModeIndicator, {}) : configInitMessage ? /* @__PURE__ */ jsxs40(Text44, { color: theme.text.secondary, children: [
28399
+ /* @__PURE__ */ jsx46(GeminiSpinner, {}),
27815
28400
  " ",
27816
28401
  configInitMessage
27817
- ] }) : showAutoAcceptIndicator !== void 0 && showAutoAcceptIndicator !== "default" ? /* @__PURE__ */ jsx38(AutoAcceptIndicator, { approvalMode: showAutoAcceptIndicator }) : suppressHint ? null : /* @__PURE__ */ jsx38(Text36, { color: theme.text.secondary, children: t("? for shortcuts") });
28402
+ ] }) : showAutoAcceptIndicator !== void 0 && showAutoAcceptIndicator !== "default" ? /* @__PURE__ */ jsx46(AutoAcceptIndicator, { approvalMode: showAutoAcceptIndicator }) : suppressHint ? null : /* @__PURE__ */ jsx46(Text44, { color: theme.text.secondary, children: t("? for shortcuts") });
27818
28403
  const rightItems = [];
27819
28404
  if (sandboxInfo) {
27820
28405
  rightItems.push({
27821
28406
  key: "sandbox",
27822
- node: /* @__PURE__ */ jsxs33(Text36, { color: theme.status.success, children: [
28407
+ node: /* @__PURE__ */ jsxs40(Text44, { color: theme.status.success, children: [
27823
28408
  "\u{1F512} ",
27824
28409
  sandboxInfo
27825
28410
  ] })
@@ -27828,13 +28413,13 @@ var Footer = () => {
27828
28413
  if (debugMode) {
27829
28414
  rightItems.push({
27830
28415
  key: "debug",
27831
- node: /* @__PURE__ */ jsx38(Text36, { color: theme.status.warning, children: "Debug Mode" })
28416
+ node: /* @__PURE__ */ jsx46(Text44, { color: theme.status.warning, children: "Debug Mode" })
27832
28417
  });
27833
28418
  }
27834
28419
  if (promptTokenCount > 0 && contextWindowSize) {
27835
28420
  rightItems.push({
27836
28421
  key: "context",
27837
- node: /* @__PURE__ */ jsx38(Text36, { color: theme.text.accent, children: /* @__PURE__ */ jsx38(
28422
+ node: /* @__PURE__ */ jsx46(Text44, { color: theme.text.accent, children: /* @__PURE__ */ jsx46(
27838
28423
  ContextUsageDisplay,
27839
28424
  {
27840
28425
  promptTokenCount,
@@ -27844,8 +28429,8 @@ var Footer = () => {
27844
28429
  ) })
27845
28430
  });
27846
28431
  }
27847
- return /* @__PURE__ */ jsxs33(
27848
- Box28,
28432
+ return /* @__PURE__ */ jsxs40(
28433
+ Box36,
27849
28434
  {
27850
28435
  flexDirection: isNarrow ? "column" : "row",
27851
28436
  justifyContent: isNarrow ? "flex-start" : "space-between",
@@ -27853,16 +28438,16 @@ var Footer = () => {
27853
28438
  paddingX: 2,
27854
28439
  gap: isNarrow ? 0 : 1,
27855
28440
  children: [
27856
- /* @__PURE__ */ jsxs33(Box28, { flexDirection: "column", flexShrink: isNarrow ? 0 : 1, children: [
27857
- statusLineLines.length > 0 && !uiState.ctrlCPressedOnce && !uiState.ctrlDPressedOnce && statusLineLines.map((line, i) => /* @__PURE__ */ jsx38(Text36, { dimColor: true, wrap: "truncate", children: line }, `status-line-${i}`)),
27858
- /* @__PURE__ */ jsxs33(Box28, { flexDirection: "row", flexShrink: 1, children: [
27859
- /* @__PURE__ */ jsx38(Text36, { wrap: "truncate", children: leftBottomContent }),
27860
- /* @__PURE__ */ jsx38(BackgroundTasksPill, {}),
27861
- /* @__PURE__ */ jsx38(MCPHealthPill, {})
28441
+ /* @__PURE__ */ jsxs40(Box36, { flexDirection: "column", flexShrink: isNarrow ? 0 : 1, children: [
28442
+ statusLineLines.length > 0 && !uiState.ctrlCPressedOnce && !uiState.ctrlDPressedOnce && statusLineLines.map((line, i) => /* @__PURE__ */ jsx46(Text44, { dimColor: true, wrap: "truncate", children: line }, `status-line-${i}`)),
28443
+ /* @__PURE__ */ jsxs40(Box36, { flexDirection: "row", flexShrink: 1, children: [
28444
+ /* @__PURE__ */ jsx46(Text44, { wrap: "truncate", children: leftBottomContent }),
28445
+ /* @__PURE__ */ jsx46(BackgroundTasksPill, {}),
28446
+ /* @__PURE__ */ jsx46(MCPHealthPill, {})
27862
28447
  ] })
27863
28448
  ] }),
27864
- /* @__PURE__ */ jsx38(Box28, { flexShrink: 0, gap: 1, alignItems: "flex-start", children: rightItems.map(({ key, node }, index) => /* @__PURE__ */ jsxs33(Box28, { alignItems: "center", children: [
27865
- index > 0 && /* @__PURE__ */ jsx38(Text36, { color: theme.text.secondary, children: " | " }),
28449
+ /* @__PURE__ */ jsx46(Box36, { flexShrink: 0, gap: 1, alignItems: "flex-start", children: rightItems.map(({ key, node }, index) => /* @__PURE__ */ jsxs40(Box36, { alignItems: "center", children: [
28450
+ index > 0 && /* @__PURE__ */ jsx46(Text44, { color: theme.text.secondary, children: " | " }),
27866
28451
  node
27867
28452
  ] }, key)) })
27868
28453
  ]
@@ -27885,17 +28470,17 @@ var QueuedMessageDisplay = ({
27885
28470
  wasEmptyRef.current = false;
27886
28471
  }
27887
28472
  const showHint = hintSeenCountRef.current <= NUM_TIMES_QUEUE_HINT_SHOWN;
27888
- return /* @__PURE__ */ jsxs34(Box29, { flexDirection: "column", marginTop: 1, children: [
28473
+ return /* @__PURE__ */ jsxs41(Box37, { flexDirection: "column", marginTop: 1, children: [
27889
28474
  messageQueue.slice(0, MAX_DISPLAYED_QUEUED_MESSAGES).map((message, index) => {
27890
28475
  const preview = message.replace(/\s+/g, " ");
27891
- return /* @__PURE__ */ jsx39(Box29, { paddingLeft: 2, width: "100%", children: /* @__PURE__ */ jsx39(Text37, { dimColor: true, wrap: "truncate", children: preview }) }, index);
28476
+ return /* @__PURE__ */ jsx47(Box37, { paddingLeft: 2, width: "100%", children: /* @__PURE__ */ jsx47(Text45, { dimColor: true, wrap: "truncate", children: preview }) }, index);
27892
28477
  }),
27893
- messageQueue.length > MAX_DISPLAYED_QUEUED_MESSAGES && /* @__PURE__ */ jsx39(Box29, { paddingLeft: 2, children: /* @__PURE__ */ jsxs34(Text37, { dimColor: true, children: [
28478
+ messageQueue.length > MAX_DISPLAYED_QUEUED_MESSAGES && /* @__PURE__ */ jsx47(Box37, { paddingLeft: 2, children: /* @__PURE__ */ jsxs41(Text45, { dimColor: true, children: [
27894
28479
  "... (+",
27895
28480
  messageQueue.length - MAX_DISPLAYED_QUEUED_MESSAGES,
27896
28481
  " more)"
27897
28482
  ] }) }),
27898
- showHint && /* @__PURE__ */ jsx39(Box29, { paddingLeft: 2, children: /* @__PURE__ */ jsx39(Text37, { dimColor: true, italic: true, children: t("Press \u2191 to edit queued messages") }) })
28483
+ showHint && /* @__PURE__ */ jsx47(Box37, { paddingLeft: 2, children: /* @__PURE__ */ jsx47(Text45, { dimColor: true, italic: true, children: t("Press \u2191 to edit queued messages") }) })
27899
28484
  ] });
27900
28485
  };
27901
28486
  var getNewlineKey = () => process.platform === "win32" ? "ctrl+enter" : "ctrl+j";
@@ -27923,8 +28508,8 @@ var getShortcuts = () => [
27923
28508
  { key: getExternalEditorKey(), description: t("for external editor") },
27924
28509
  { key: "ctrl+o", description: t("to toggle compact mode") }
27925
28510
  ];
27926
- var ShortcutItem = ({ shortcut }) => /* @__PURE__ */ jsxs35(Text38, { color: theme.text.secondary, children: [
27927
- /* @__PURE__ */ jsx40(Text38, { color: theme.text.accent, children: shortcut.key }),
28511
+ var ShortcutItem = ({ shortcut }) => /* @__PURE__ */ jsxs42(Text46, { color: theme.text.secondary, children: [
28512
+ /* @__PURE__ */ jsx48(Text46, { color: theme.text.accent, children: shortcut.key }),
27928
28513
  " ",
27929
28514
  shortcut.description
27930
28515
  ] });
@@ -27965,18 +28550,18 @@ var KeyboardShortcuts = () => {
27965
28550
  columns.push(shortcuts.slice(startIndex, startIndex + count));
27966
28551
  startIndex += count;
27967
28552
  }
27968
- return /* @__PURE__ */ jsx40(
27969
- Box30,
28553
+ return /* @__PURE__ */ jsx48(
28554
+ Box38,
27970
28555
  {
27971
28556
  flexDirection: "row",
27972
28557
  marginLeft: MARGIN_LEFT,
27973
28558
  marginRight: MARGIN_RIGHT,
27974
- children: columns.map((column, colIndex) => /* @__PURE__ */ jsx40(
27975
- Box30,
28559
+ children: columns.map((column, colIndex) => /* @__PURE__ */ jsx48(
28560
+ Box38,
27976
28561
  {
27977
28562
  flexDirection: "column",
27978
28563
  marginRight: colIndex < numColumns - 1 ? COLUMN_GAP : 0,
27979
- children: column.map((shortcut) => /* @__PURE__ */ jsx40(ShortcutItem, { shortcut }, shortcut.key))
28564
+ children: column.map((shortcut) => /* @__PURE__ */ jsx48(ShortcutItem, { shortcut }, shortcut.key))
27980
28565
  },
27981
28566
  colIndex
27982
28567
  ))
@@ -28020,8 +28605,8 @@ var Composer = () => {
28020
28605
  },
28021
28606
  [uiActions]
28022
28607
  );
28023
- return /* @__PURE__ */ jsxs36(Box31, { flexDirection: "column", marginTop: 1, children: [
28024
- !uiState.embeddedShellFocused && !suppressBottomLoadingIndicator && /* @__PURE__ */ jsx41(
28608
+ return /* @__PURE__ */ jsxs43(Box39, { flexDirection: "column", marginTop: 1, children: [
28609
+ !uiState.embeddedShellFocused && !suppressBottomLoadingIndicator && /* @__PURE__ */ jsx49(
28025
28610
  LoadingIndicator,
28026
28611
  {
28027
28612
  thought: uiState.streamingState === "waiting_for_confirmation" || config.getAccessibility()?.enableLoadingPhrases === false ? void 0 : uiState.thought,
@@ -28033,13 +28618,13 @@ var Composer = () => {
28033
28618
  isReceivingContent
28034
28619
  }
28035
28620
  ),
28036
- !uiState.embeddedShellFocused && suppressBottomLoadingIndicator && /* @__PURE__ */ jsx41(Box31, { paddingLeft: 2, children: /* @__PURE__ */ jsxs36(Text39, { color: theme.text.secondary, children: [
28621
+ !uiState.embeddedShellFocused && suppressBottomLoadingIndicator && /* @__PURE__ */ jsx49(Box39, { paddingLeft: 2, children: /* @__PURE__ */ jsxs43(Text47, { color: theme.text.secondary, children: [
28037
28622
  "(",
28038
28623
  t("Esc to cancel"),
28039
28624
  ")"
28040
28625
  ] }) }),
28041
- /* @__PURE__ */ jsx41(QueuedMessageDisplay, { messageQueue: uiState.messageQueue }),
28042
- uiState.isInputActive && /* @__PURE__ */ jsx41(
28626
+ /* @__PURE__ */ jsx49(QueuedMessageDisplay, { messageQueue: uiState.messageQueue }),
28627
+ uiState.isInputActive && /* @__PURE__ */ jsx49(
28043
28628
  InputPrompt,
28044
28629
  {
28045
28630
  buffer: uiState.buffer,
@@ -28067,27 +28652,442 @@ var Composer = () => {
28067
28652
  onPromptSuggestionDismiss: uiState.dismissPromptSuggestion
28068
28653
  }
28069
28654
  ),
28070
- uiState.isInputActive && !showSuggestions && (showShortcuts ? /* @__PURE__ */ jsx41(KeyboardShortcuts, {}) : !isScreenReaderEnabled && /* @__PURE__ */ jsx41(Footer, {}))
28655
+ uiState.isInputActive && !showSuggestions && (showShortcuts ? /* @__PURE__ */ jsx49(KeyboardShortcuts, {}) : !isScreenReaderEnabled && /* @__PURE__ */ jsx49(Footer, {}))
28071
28656
  ] });
28072
28657
  };
28073
- async function diffAction(context) {
28074
- const { config } = context.services;
28075
- if (!config) {
28076
- return {
28077
- type: "message",
28078
- messageType: "error",
28079
- content: t("Configuration not available.")
28080
- };
28081
- }
28082
- const cwd = config.getWorkingDir() || config.getProjectRoot();
28083
- if (!cwd) {
28084
- return {
28085
- type: "message",
28086
- messageType: "error",
28087
- content: t("Could not determine current working directory.")
28658
+ var AppContext = createContext9(null);
28659
+ var Notifications = () => {
28660
+ const appCtx = useContext11(AppContext);
28661
+ const warnings = appCtx?.startupWarnings ?? [];
28662
+ if (warnings.length === 0) return null;
28663
+ return /* @__PURE__ */ jsx50(
28664
+ Box40,
28665
+ {
28666
+ flexDirection: "column",
28667
+ marginLeft: 2,
28668
+ marginRight: 2,
28669
+ marginBottom: 1,
28670
+ children: /* @__PURE__ */ jsx50(
28671
+ Box40,
28672
+ {
28673
+ borderStyle: "round",
28674
+ borderColor: theme.status.warning,
28675
+ paddingX: 1,
28676
+ flexDirection: "column",
28677
+ children: warnings.map((w, i) => /* @__PURE__ */ jsxs44(Text48, { color: theme.status.warning, children: [
28678
+ "\u26A0 ",
28679
+ w
28680
+ ] }, i))
28681
+ }
28682
+ )
28683
+ }
28684
+ );
28685
+ };
28686
+ function gitExec(args, cwd) {
28687
+ return new Promise((resolve3, reject) => {
28688
+ execFile32("git", args, { cwd }, (err, stdout) => {
28689
+ if (err) reject(err);
28690
+ else resolve3(stdout.toString().trim());
28691
+ });
28692
+ });
28693
+ }
28694
+ function useGitBranchName(cwd) {
28695
+ const [branchName, setBranchName] = useState25(void 0);
28696
+ const fetchBranchName = useCallback20(async () => {
28697
+ try {
28698
+ const branch = await gitExec(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
28699
+ if (branch && branch !== "HEAD") {
28700
+ setBranchName(branch);
28701
+ } else {
28702
+ const hash = await gitExec(["rev-parse", "--short", "HEAD"], cwd);
28703
+ setBranchName(hash || void 0);
28704
+ }
28705
+ } catch {
28706
+ setBranchName(void 0);
28707
+ }
28708
+ }, [cwd]);
28709
+ useEffect25(() => {
28710
+ void fetchBranchName();
28711
+ const gitLogsHeadPath = path142.join(cwd, ".git", "logs", "HEAD");
28712
+ let watcher;
28713
+ void fsPromises.access(gitLogsHeadPath, fs7.constants.F_OK).then(() => {
28714
+ watcher = fs7.watch(gitLogsHeadPath, (eventType) => {
28715
+ if (eventType === "change" || eventType === "rename") {
28716
+ void fetchBranchName();
28717
+ }
28718
+ });
28719
+ }).catch(() => {
28720
+ });
28721
+ return () => {
28722
+ watcher?.close();
28088
28723
  };
28724
+ }, [cwd, fetchBranchName]);
28725
+ return branchName;
28726
+ }
28727
+ function tildeify(p) {
28728
+ const home = os6.homedir();
28729
+ return p.startsWith(home) ? `~${p.slice(home.length)}` : p;
28730
+ }
28731
+ function statusLabel(state) {
28732
+ switch (state) {
28733
+ case "responding":
28734
+ return { text: "running", color: theme.status.success };
28735
+ case "waiting_for_confirmation":
28736
+ return { text: "awaiting approval", color: theme.status.warning };
28737
+ default:
28738
+ return { text: "idle", color: theme.text.secondary };
28089
28739
  }
28090
- let result;
28740
+ }
28741
+ function fmt(n) {
28742
+ if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
28743
+ if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
28744
+ return String(n);
28745
+ }
28746
+ var AppHeader = ({
28747
+ version,
28748
+ cwd,
28749
+ providerLabel,
28750
+ mode,
28751
+ iterationInfo
28752
+ }) => {
28753
+ const {
28754
+ streamingState,
28755
+ sessionStats: { lastPromptTokenCount, lastOutputTokenCount, totalPromptTokenCount, totalOutputTokenCount },
28756
+ elapsedTime,
28757
+ terminalWidth
28758
+ } = useUIState();
28759
+ const branchName = useGitBranchName(cwd);
28760
+ const status = statusLabel(streamingState);
28761
+ const displayDir = tildeify(cwd);
28762
+ const hasTokens = lastPromptTokenCount > 0;
28763
+ const hasSessionTokens = totalPromptTokenCount > 0;
28764
+ return /* @__PURE__ */ jsxs45(
28765
+ Box41,
28766
+ {
28767
+ flexDirection: "column",
28768
+ marginLeft: 2,
28769
+ marginRight: 2,
28770
+ marginTop: 1,
28771
+ marginBottom: 1,
28772
+ children: [
28773
+ /* @__PURE__ */ jsxs45(Box41, { flexDirection: "row", flexWrap: "nowrap", width: terminalWidth - 4, children: [
28774
+ /* @__PURE__ */ jsx51(Text49, { bold: true, color: theme.text.accent, children: "DeepCode" }),
28775
+ /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, children: ` v${version}` }),
28776
+ providerLabel && /* @__PURE__ */ jsxs45(Fragment11, { children: [
28777
+ /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, children: " " }),
28778
+ /* @__PURE__ */ jsx51(Text49, { color: theme.text.primary, children: providerLabel })
28779
+ ] }),
28780
+ /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, children: " " }),
28781
+ /* @__PURE__ */ jsx51(
28782
+ Text49,
28783
+ {
28784
+ bold: true,
28785
+ color: mode === "build" ? theme.status.success : theme.status.warning,
28786
+ children: mode.toUpperCase()
28787
+ }
28788
+ ),
28789
+ /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, children: " " }),
28790
+ /* @__PURE__ */ jsxs45(Text49, { color: status.color, children: [
28791
+ status.text,
28792
+ streamingState === "responding" && elapsedTime > 0 ? ` ${elapsedTime}s` : ""
28793
+ ] }),
28794
+ iterationInfo && /* @__PURE__ */ jsxs45(Text49, { color: theme.text.secondary, children: [
28795
+ " ",
28796
+ "iter ",
28797
+ iterationInfo.round,
28798
+ "/",
28799
+ iterationInfo.max
28800
+ ] }),
28801
+ hasTokens && /* @__PURE__ */ jsxs45(Text49, { color: theme.text.secondary, children: [
28802
+ " ",
28803
+ "\u2191",
28804
+ fmt(lastPromptTokenCount),
28805
+ " \u2193",
28806
+ fmt(lastOutputTokenCount)
28807
+ ] })
28808
+ ] }),
28809
+ /* @__PURE__ */ jsxs45(Box41, { flexDirection: "row", children: [
28810
+ /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, dimColor: true, children: displayDir }),
28811
+ branchName && /* @__PURE__ */ jsxs45(Text49, { color: theme.text.accent, dimColor: true, children: [
28812
+ " ",
28813
+ "(",
28814
+ branchName,
28815
+ ")"
28816
+ ] }),
28817
+ hasSessionTokens && /* @__PURE__ */ jsxs45(Text49, { color: theme.text.secondary, dimColor: true, children: [
28818
+ " ",
28819
+ "sess\xE3o \u2191",
28820
+ fmt(totalPromptTokenCount),
28821
+ " \u2193",
28822
+ fmt(totalOutputTokenCount)
28823
+ ] })
28824
+ ] })
28825
+ ]
28826
+ }
28827
+ );
28828
+ };
28829
+ var STICKY_TODO_MAX_VISIBLE_ITEMS = 5;
28830
+ var MIN_HISTORY_ITEMS_AFTER_TODO_BEFORE_STICKY = 2;
28831
+ var STICKY_TODO_ROWS_PER_VISIBLE_ITEM = 5;
28832
+ var STATUS_PRIORITY = {
28833
+ in_progress: 0,
28834
+ pending: 1,
28835
+ completed: 2
28836
+ };
28837
+ function extractTodosFromResultDisplay(resultDisplay) {
28838
+ if (!resultDisplay) return null;
28839
+ if (typeof resultDisplay === "object") {
28840
+ const candidate = resultDisplay;
28841
+ if (candidate["type"] === "todo_list" && Array.isArray(candidate["todos"])) {
28842
+ return candidate["todos"];
28843
+ }
28844
+ }
28845
+ if (typeof resultDisplay === "string") {
28846
+ try {
28847
+ const parsed = JSON.parse(resultDisplay);
28848
+ if (parsed["type"] === "todo_list" && Array.isArray(parsed["todos"])) {
28849
+ return parsed["todos"];
28850
+ }
28851
+ } catch {
28852
+ return null;
28853
+ }
28854
+ }
28855
+ return null;
28856
+ }
28857
+ function findLatestTodoSnapshot(items) {
28858
+ for (let i = items.length - 1; i >= 0; i--) {
28859
+ const item = items[i];
28860
+ if (item.type !== "tool_group") continue;
28861
+ for (let j = item.tools.length - 1; j >= 0; j--) {
28862
+ const tool = item.tools[j];
28863
+ const todos = extractTodosFromResultDisplay(tool.resultDisplay);
28864
+ if (todos) return { itemIndex: i, todos: todos.length > 0 ? todos : null };
28865
+ }
28866
+ }
28867
+ return void 0;
28868
+ }
28869
+ function getStickyTodos(history, pendingHistoryItems) {
28870
+ if (findLatestTodoSnapshot(pendingHistoryItems) !== void 0) return null;
28871
+ const snap = findLatestTodoSnapshot(history);
28872
+ if (!snap || !snap.todos) return null;
28873
+ const itemsAfter = history.length - snap.itemIndex - 1;
28874
+ if (itemsAfter < MIN_HISTORY_ITEMS_AFTER_TODO_BEFORE_STICKY) return null;
28875
+ if (snap.todos.every((t2) => t2.status === "completed")) return null;
28876
+ return snap.todos;
28877
+ }
28878
+ function getOrderedStickyTodos(todos) {
28879
+ return todos.map((todo, index) => ({ todo, index })).sort(
28880
+ (a, b) => STATUS_PRIORITY[a.todo.status] - STATUS_PRIORITY[b.todo.status] || a.index - b.index
28881
+ ).map(({ todo }) => todo);
28882
+ }
28883
+ function getStickyTodosRenderKey(todos) {
28884
+ if (!todos) return "null";
28885
+ return JSON.stringify(todos.map((t2) => [t2.id, t2.content, t2.status]));
28886
+ }
28887
+ function getStickyTodoMaxVisibleItems(terminalHeight) {
28888
+ if (!Number.isFinite(terminalHeight) || terminalHeight <= 0) {
28889
+ return STICKY_TODO_MAX_VISIBLE_ITEMS;
28890
+ }
28891
+ return Math.max(
28892
+ 1,
28893
+ Math.min(
28894
+ STICKY_TODO_MAX_VISIBLE_ITEMS,
28895
+ Math.floor(terminalHeight / STICKY_TODO_ROWS_PER_VISIBLE_ITEM)
28896
+ )
28897
+ );
28898
+ }
28899
+ var STATUS_ICONS3 = {
28900
+ pending: "\u25CB",
28901
+ in_progress: "\u25D0",
28902
+ completed: "\u25CF"
28903
+ };
28904
+ function clamp2(value) {
28905
+ if (!Number.isFinite(value)) return STICKY_TODO_MAX_VISIBLE_ITEMS;
28906
+ return Math.max(1, Math.min(STICKY_TODO_MAX_VISIBLE_ITEMS, Math.floor(value)));
28907
+ }
28908
+ var StickyTodoListComponent = ({
28909
+ todos,
28910
+ width,
28911
+ maxVisibleItems = STICKY_TODO_MAX_VISIBLE_ITEMS
28912
+ }) => {
28913
+ const ordered = useMemo12(() => getOrderedStickyTodos(todos), [todos]);
28914
+ const numberById = useMemo12(
28915
+ () => new Map(todos.map((todo, i) => [todo.id, `${i + 1}.`])),
28916
+ [todos]
28917
+ );
28918
+ if (todos.length === 0) return null;
28919
+ const visibleCount = clamp2(maxVisibleItems);
28920
+ const visible = ordered.slice(0, visibleCount);
28921
+ const hidden = ordered.length - visible.length;
28922
+ const numColWidth = Math.max(...visible.map((t2, i) => (numberById.get(t2.id) ?? `${i + 1}.`).length)) + 1;
28923
+ const contentColWidth = Math.max(1, width - numColWidth - 6);
28924
+ return /* @__PURE__ */ jsxs46(
28925
+ Box42,
28926
+ {
28927
+ marginX: 2,
28928
+ width,
28929
+ flexDirection: "column",
28930
+ borderStyle: "round",
28931
+ borderColor: theme.border.default,
28932
+ paddingX: 1,
28933
+ children: [
28934
+ /* @__PURE__ */ jsx52(Text50, { color: theme.text.secondary, bold: true, children: "Tarefas em andamento" }),
28935
+ visible.map((todo, i) => {
28936
+ const num = numberById.get(todo.id) ?? `${i + 1}.`;
28937
+ const color = todo.status === "in_progress" ? theme.status.success : theme.text.primary;
28938
+ return /* @__PURE__ */ jsxs46(Box42, { flexDirection: "row", height: 1, children: [
28939
+ /* @__PURE__ */ jsx52(Box42, { width: numColWidth, children: /* @__PURE__ */ jsx52(Text50, { color: theme.text.secondary, children: num }) }),
28940
+ /* @__PURE__ */ jsx52(Box42, { width: 2, children: /* @__PURE__ */ jsx52(Text50, { color, children: STATUS_ICONS3[todo.status] }) }),
28941
+ /* @__PURE__ */ jsx52(Box42, { width: contentColWidth, children: /* @__PURE__ */ jsx52(
28942
+ Text50,
28943
+ {
28944
+ color,
28945
+ strikethrough: todo.status === "completed",
28946
+ wrap: "truncate-end",
28947
+ children: todo.content
28948
+ }
28949
+ ) })
28950
+ ] }, todo.id);
28951
+ }),
28952
+ hidden > 0 && /* @__PURE__ */ jsxs46(Box42, { flexDirection: "row", height: 1, children: [
28953
+ /* @__PURE__ */ jsx52(Box42, { width: numColWidth }),
28954
+ /* @__PURE__ */ jsx52(Box42, { width: 2 }),
28955
+ /* @__PURE__ */ jsx52(Box42, { width: contentColWidth, children: /* @__PURE__ */ jsxs46(Text50, { color: theme.text.secondary, wrap: "truncate-end", children: [
28956
+ "... e mais ",
28957
+ hidden
28958
+ ] }) })
28959
+ ] })
28960
+ ]
28961
+ }
28962
+ );
28963
+ };
28964
+ var StickyTodoList = memo(
28965
+ StickyTodoListComponent,
28966
+ (prev, next) => prev.width === next.width && prev.maxVisibleItems === next.maxVisibleItems && getStickyTodosRenderKey(prev.todos) === getStickyTodosRenderKey(next.todos)
28967
+ );
28968
+ var useTimer = (isActive, resetKey) => {
28969
+ const [elapsedTime, setElapsedTime] = useState26(0);
28970
+ const timerRef = useRef15(null);
28971
+ const prevResetKeyRef = useRef15(resetKey);
28972
+ const prevIsActiveRef = useRef15(isActive);
28973
+ useEffect26(() => {
28974
+ let shouldReset = false;
28975
+ if (prevResetKeyRef.current !== resetKey) {
28976
+ shouldReset = true;
28977
+ prevResetKeyRef.current = resetKey;
28978
+ }
28979
+ if (!prevIsActiveRef.current && isActive) {
28980
+ shouldReset = true;
28981
+ }
28982
+ if (shouldReset) setElapsedTime(0);
28983
+ prevIsActiveRef.current = isActive;
28984
+ if (isActive) {
28985
+ if (timerRef.current) clearInterval(timerRef.current);
28986
+ timerRef.current = setInterval(() => {
28987
+ setElapsedTime((prev) => prev + 1);
28988
+ }, 1e3);
28989
+ } else {
28990
+ if (timerRef.current) {
28991
+ clearInterval(timerRef.current);
28992
+ timerRef.current = null;
28993
+ }
28994
+ }
28995
+ return () => {
28996
+ if (timerRef.current) clearInterval(timerRef.current);
28997
+ };
28998
+ }, [isActive, resetKey]);
28999
+ return elapsedTime;
29000
+ };
29001
+ var PHRASE_CHANGE_INTERVAL_MS = 15e3;
29002
+ var DEFAULT_PHRASES = [
29003
+ "Processando...",
29004
+ "Analisando o c\xF3digo...",
29005
+ "Pensando nisso...",
29006
+ "Verificando depend\xEAncias...",
29007
+ "Elaborando solu\xE7\xE3o...",
29008
+ "Checando o contexto...",
29009
+ "Refinando a resposta...",
29010
+ "Quase l\xE1...",
29011
+ "Conectando os pontos...",
29012
+ "Revisando..."
29013
+ ];
29014
+ var usePhraseCycler = (isActive, isWaiting, customPhrases) => {
29015
+ const phrases = customPhrases && customPhrases.length > 0 ? customPhrases : DEFAULT_PHRASES;
29016
+ const [phrase, setPhrase] = useState27(phrases[0] ?? "");
29017
+ const intervalRef = useRef16(null);
29018
+ useEffect27(() => {
29019
+ if (isWaiting) {
29020
+ setPhrase("Aguardando confirma\xE7\xE3o...");
29021
+ if (intervalRef.current) {
29022
+ clearInterval(intervalRef.current);
29023
+ intervalRef.current = null;
29024
+ }
29025
+ return;
29026
+ }
29027
+ if (isActive) {
29028
+ if (intervalRef.current) clearInterval(intervalRef.current);
29029
+ setPhrase(phrases[Math.floor(Math.random() * phrases.length)] ?? "");
29030
+ intervalRef.current = setInterval(() => {
29031
+ setPhrase(phrases[Math.floor(Math.random() * phrases.length)] ?? "");
29032
+ }, PHRASE_CHANGE_INTERVAL_MS);
29033
+ } else {
29034
+ if (intervalRef.current) {
29035
+ clearInterval(intervalRef.current);
29036
+ intervalRef.current = null;
29037
+ }
29038
+ setPhrase(phrases[0] ?? "");
29039
+ }
29040
+ return () => {
29041
+ if (intervalRef.current) clearInterval(intervalRef.current);
29042
+ };
29043
+ }, [isActive, isWaiting]);
29044
+ return phrase;
29045
+ };
29046
+ var useLoadingIndicator = (streamingState, customPhrases) => {
29047
+ const [timerResetKey, setTimerResetKey] = useState28(0);
29048
+ const isTimerActive = streamingState === "responding";
29049
+ const elapsedTimeFromTimer = useTimer(isTimerActive, timerResetKey);
29050
+ const isPhraseCyclingActive = streamingState === "responding";
29051
+ const isWaiting = streamingState === "waiting_for_confirmation";
29052
+ const currentLoadingPhrase = usePhraseCycler(isPhraseCyclingActive, isWaiting, customPhrases);
29053
+ const [retainedElapsedTime, setRetainedElapsedTime] = useState28(0);
29054
+ const prevStateRef = useRef17(null);
29055
+ useEffect28(() => {
29056
+ const prev = prevStateRef.current;
29057
+ if (prev === "waiting_for_confirmation" && streamingState === "responding") {
29058
+ setTimerResetKey((k) => k + 1);
29059
+ setRetainedElapsedTime(0);
29060
+ } else if (streamingState === "idle" && prev === "responding") {
29061
+ setTimerResetKey((k) => k + 1);
29062
+ setRetainedElapsedTime(0);
29063
+ } else if (streamingState === "waiting_for_confirmation") {
29064
+ setRetainedElapsedTime(elapsedTimeFromTimer);
29065
+ }
29066
+ prevStateRef.current = streamingState;
29067
+ }, [streamingState, elapsedTimeFromTimer]);
29068
+ return {
29069
+ elapsedTime: streamingState === "waiting_for_confirmation" ? retainedElapsedTime : elapsedTimeFromTimer,
29070
+ currentLoadingPhrase
29071
+ };
29072
+ };
29073
+ async function diffAction(context) {
29074
+ const { config } = context.services;
29075
+ if (!config) {
29076
+ return {
29077
+ type: "message",
29078
+ messageType: "error",
29079
+ content: t("Configuration not available.")
29080
+ };
29081
+ }
29082
+ const cwd = config.getWorkingDir() || config.getProjectRoot();
29083
+ if (!cwd) {
29084
+ return {
29085
+ type: "message",
29086
+ messageType: "error",
29087
+ content: t("Could not determine current working directory.")
29088
+ };
29089
+ }
29090
+ let result;
28091
29091
  try {
28092
29092
  result = await fetchGitDiff(cwd);
28093
29093
  } catch (error) {
@@ -28256,6 +29256,228 @@ var diffCommand = {
28256
29256
  supportedModes: ["interactive", "non_interactive", "acp"],
28257
29257
  action: diffAction
28258
29258
  };
29259
+ var EXPORT_FORMATS = ["markdown", "json"];
29260
+ function formatTimestamp(iso) {
29261
+ try {
29262
+ return new Date(iso).toLocaleString();
29263
+ } catch {
29264
+ return iso;
29265
+ }
29266
+ }
29267
+ function toMarkdown({ messages, cwd, model }) {
29268
+ const lines = [];
29269
+ const now = (/* @__PURE__ */ new Date()).toISOString();
29270
+ lines.push(`# DeepCode Session Export`);
29271
+ lines.push(``);
29272
+ lines.push(`**Exported:** ${formatTimestamp(now)}`);
29273
+ lines.push(`**Directory:** ${cwd}`);
29274
+ if (model) lines.push(`**Model:** ${model}`);
29275
+ lines.push(``);
29276
+ lines.push(`---`);
29277
+ lines.push(``);
29278
+ for (const msg of messages) {
29279
+ if (msg.source === "ui" || msg.source === "agent_internal") continue;
29280
+ if (msg.role === "system") {
29281
+ lines.push(`> *[system]*`);
29282
+ lines.push(``);
29283
+ continue;
29284
+ }
29285
+ if (msg.role === "user") {
29286
+ lines.push(`## User`);
29287
+ lines.push(``);
29288
+ lines.push(msg.content);
29289
+ lines.push(``);
29290
+ continue;
29291
+ }
29292
+ if (msg.role === "assistant") {
29293
+ lines.push(`## Assistant`);
29294
+ lines.push(``);
29295
+ if (msg.toolCalls && msg.toolCalls.length > 0) {
29296
+ for (const call of msg.toolCalls) {
29297
+ lines.push(`**Tool:** \`${call.name}\``);
29298
+ lines.push(``);
29299
+ try {
29300
+ lines.push("```json");
29301
+ lines.push(JSON.stringify(call.arguments, null, 2));
29302
+ lines.push("```");
29303
+ } catch {
29304
+ lines.push(String(call.arguments));
29305
+ }
29306
+ lines.push(``);
29307
+ }
29308
+ }
29309
+ if (msg.content) {
29310
+ lines.push(msg.content);
29311
+ lines.push(``);
29312
+ }
29313
+ continue;
29314
+ }
29315
+ if (msg.role === "tool") {
29316
+ lines.push(`*[tool result]*`);
29317
+ lines.push(``);
29318
+ const preview = msg.content.slice(0, 500);
29319
+ lines.push("```");
29320
+ lines.push(preview + (msg.content.length > 500 ? "\n\u2026" : ""));
29321
+ lines.push("```");
29322
+ lines.push(``);
29323
+ continue;
29324
+ }
29325
+ }
29326
+ return lines.join("\n");
29327
+ }
29328
+ function toJson({ messages, cwd, model }) {
29329
+ const exportable = messages.filter(
29330
+ (m) => m.source !== "ui" && m.source !== "agent_internal"
29331
+ );
29332
+ return JSON.stringify(
29333
+ {
29334
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
29335
+ cwd,
29336
+ model,
29337
+ messages: exportable
29338
+ },
29339
+ null,
29340
+ 2
29341
+ );
29342
+ }
29343
+ function generateFilename(format, cwd) {
29344
+ const dirName = path15.basename(cwd);
29345
+ const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
29346
+ const ext = format === "markdown" ? "md" : "json";
29347
+ return `deepcode-${dirName}-${ts}.${ext}`;
29348
+ }
29349
+ async function exportSession(opts) {
29350
+ const content = opts.format === "markdown" ? toMarkdown(opts) : toJson(opts);
29351
+ const downloadsDir = path15.join(os7.homedir(), "Downloads");
29352
+ let outputDir = opts.cwd;
29353
+ try {
29354
+ await fs8.access(downloadsDir);
29355
+ outputDir = downloadsDir;
29356
+ } catch {
29357
+ }
29358
+ const filename = generateFilename(opts.format, opts.cwd);
29359
+ const outPath = path15.join(outputDir, filename);
29360
+ await fs8.writeFile(outPath, content, "utf8");
29361
+ return outPath;
29362
+ }
29363
+ var exportCommand = {
29364
+ name: "export",
29365
+ description: "Export session history to a file",
29366
+ kind: "built-in",
29367
+ supportedModes: ["interactive"],
29368
+ subCommands: EXPORT_FORMATS.map((fmt2) => ({
29369
+ name: fmt2,
29370
+ description: fmt2 === "markdown" ? "Markdown (.md)" : "JSON (.json)",
29371
+ kind: "built-in",
29372
+ supportedModes: ["interactive"],
29373
+ action: async () => ({
29374
+ type: "message",
29375
+ messageType: "info",
29376
+ content: `Use /export ${fmt2} from the top-level command.`
29377
+ })
29378
+ })),
29379
+ action: async (context, args) => {
29380
+ const fmt2 = args?.trim() ?? "markdown";
29381
+ if (!EXPORT_FORMATS.includes(fmt2)) {
29382
+ return {
29383
+ type: "message",
29384
+ messageType: "error",
29385
+ content: `Unknown format "${fmt2}". Available: ${EXPORT_FORMATS.join(", ")}`
29386
+ };
29387
+ }
29388
+ const messages = context.ui.getMessages?.() ?? [];
29389
+ const cwd = context.ui.getCwd?.() ?? process.cwd();
29390
+ const model = context.services.session?.getState().model;
29391
+ if (messages.length === 0) {
29392
+ return { type: "message", messageType: "info", content: "Nothing to export yet." };
29393
+ }
29394
+ try {
29395
+ const outPath = await exportSession({ messages, cwd, model, format: fmt2 });
29396
+ return { type: "message", messageType: "info", content: `Exported to: ${outPath}` };
29397
+ } catch (err) {
29398
+ const msg = err instanceof Error ? err.message : String(err);
29399
+ return { type: "message", messageType: "error", content: `Export failed: ${msg}` };
29400
+ }
29401
+ }
29402
+ };
29403
+ var CONTEXT_WINDOW_DEFAULT = 128e3;
29404
+ var AUTOCOMPACT_BUFFER_FRACTION = 0.2;
29405
+ function estimateTokens2(messages) {
29406
+ return Math.ceil(
29407
+ messages.reduce((sum, m) => {
29408
+ let chars = m.content.length;
29409
+ if (m.toolCalls) {
29410
+ chars += m.toolCalls.reduce(
29411
+ (s, tc) => s + tc.name.length + JSON.stringify(tc.arguments).length,
29412
+ 0
29413
+ );
29414
+ }
29415
+ return sum + chars;
29416
+ }, 0) / 4
29417
+ );
29418
+ }
29419
+ function buildContextUsageItem(messages, modelName, showDetails) {
29420
+ const contextWindowSize = CONTEXT_WINDOW_DEFAULT;
29421
+ const autocompactBuffer = Math.round(contextWindowSize * AUTOCOMPACT_BUFFER_FRACTION);
29422
+ const systemMsgs = messages.filter(
29423
+ (m) => m.role === "system" || m.source === "agent_internal"
29424
+ );
29425
+ const conversationMsgs = messages.filter(
29426
+ (m) => m.role !== "system" && m.source !== "agent_internal" && m.source !== "ui"
29427
+ );
29428
+ const systemTokens = estimateTokens2(systemMsgs);
29429
+ const conversationTokens = estimateTokens2(conversationMsgs);
29430
+ const totalTokens = systemTokens + conversationTokens;
29431
+ const freeSpace = Math.max(0, contextWindowSize - totalTokens - autocompactBuffer);
29432
+ const breakdown = {
29433
+ systemPrompt: systemTokens,
29434
+ builtinTools: 0,
29435
+ mcpTools: 0,
29436
+ memoryFiles: 0,
29437
+ skills: 0,
29438
+ messages: conversationTokens,
29439
+ freeSpace,
29440
+ autocompactBuffer
29441
+ };
29442
+ return {
29443
+ type: "context_usage",
29444
+ modelName: modelName || "(desconhecido)",
29445
+ totalTokens,
29446
+ contextWindowSize,
29447
+ breakdown,
29448
+ builtinTools: [],
29449
+ mcpTools: [],
29450
+ memoryFiles: [],
29451
+ skills: [],
29452
+ isEstimated: true,
29453
+ showDetails
29454
+ };
29455
+ }
29456
+ var contextCommand = {
29457
+ name: "context",
29458
+ description: "Exibe o uso estimado da janela de contexto",
29459
+ kind: "built-in",
29460
+ supportedModes: ["interactive"],
29461
+ subCommands: [
29462
+ {
29463
+ name: "detail",
29464
+ description: "Exibe o detalhamento por categoria",
29465
+ kind: "built-in",
29466
+ supportedModes: ["interactive"],
29467
+ action: async (context) => {
29468
+ const messages = context.ui.getMessages?.() ?? [];
29469
+ const model = context.services.session?.getState().model ?? "";
29470
+ context.ui.addItem(buildContextUsageItem(messages, model, true), Date.now());
29471
+ }
29472
+ }
29473
+ ],
29474
+ action: async (context, args) => {
29475
+ const showDetails = args?.trim() === "detail";
29476
+ const messages = context.ui.getMessages?.() ?? [];
29477
+ const model = context.services.session?.getState().model ?? "";
29478
+ context.ui.addItem(buildContextUsageItem(messages, model, showDetails), Date.now());
29479
+ }
29480
+ };
28259
29481
  var clearCommand = {
28260
29482
  name: "clear",
28261
29483
  get description() {
@@ -28312,6 +29534,138 @@ var compactCommand = {
28312
29534
  await context.ui.compact();
28313
29535
  }
28314
29536
  };
29537
+ function check(category, name, status, message, detail) {
29538
+ return { category, name, status, message, detail };
29539
+ }
29540
+ function semverAtLeast(version, major) {
29541
+ const [maj] = version.replace(/^v/, "").split(".").map(Number);
29542
+ return (maj ?? 0) >= major;
29543
+ }
29544
+ function runEnvironmentChecks(cwd) {
29545
+ const results = [];
29546
+ const nodeVersion = process4.versions.node ?? "0.0.0";
29547
+ results.push(
29548
+ semverAtLeast(nodeVersion, 22) ? check("Ambiente", "Node.js", "pass", `v${nodeVersion}`) : check("Ambiente", "Node.js", "fail", `v${nodeVersion} \u2014 requer \u2265 22`, "Instale Node.js 22 ou superior")
29549
+ );
29550
+ try {
29551
+ fs9.accessSync(cwd, fs9.constants.R_OK | fs9.constants.W_OK);
29552
+ results.push(check("Ambiente", "Diret\xF3rio de trabalho", "pass", "acess\xEDvel e grav\xE1vel"));
29553
+ } catch {
29554
+ results.push(check("Ambiente", "Diret\xF3rio de trabalho", "fail", "sem acesso de leitura/escrita", cwd));
29555
+ }
29556
+ const gitDir = path16.join(cwd, ".git");
29557
+ results.push(
29558
+ fs9.existsSync(gitDir) ? check("Workspace", "Reposit\xF3rio Git", "pass", "encontrado") : check("Workspace", "Reposit\xF3rio Git", "warn", "n\xE3o encontrado", "Algumas funcionalidades requerem um reposit\xF3rio git")
29559
+ );
29560
+ const deepcodeDir = path16.join(cwd, ".deepcode");
29561
+ results.push(
29562
+ fs9.existsSync(deepcodeDir) ? check("Workspace", "Config DeepCode", "pass", ".deepcode encontrado") : check("Workspace", "Config DeepCode", "warn", ".deepcode ausente", "Execute deepcode para criar")
29563
+ );
29564
+ return results;
29565
+ }
29566
+ function runRuntimeChecks(diagnostics) {
29567
+ const results = [];
29568
+ results.push(check("Runtime", "Provider", "pass", diagnostics.provider));
29569
+ results.push(
29570
+ diagnostics.model ? check("Runtime", "Modelo", "pass", diagnostics.model) : check("Runtime", "Modelo", "warn", "n\xE3o configurado", `Execute /model para configurar um modelo para ${diagnostics.provider}`)
29571
+ );
29572
+ results.push(
29573
+ diagnostics.hasApiKey ? check("Runtime", "API Key", "pass", "configurada") : check("Runtime", "API Key", "fail", "n\xE3o configurada", `Defina a chave em /provider ou na configura\xE7\xE3o`)
29574
+ );
29575
+ if (diagnostics.mcpTotal > 0) {
29576
+ const allConnected = diagnostics.mcpConnected === diagnostics.mcpTotal;
29577
+ results.push(
29578
+ allConnected ? check("Runtime", "MCP", "pass", `${diagnostics.mcpConnected}/${diagnostics.mcpTotal} conectados`) : check("Runtime", "MCP", "warn", `${diagnostics.mcpConnected}/${diagnostics.mcpTotal} conectados`, "Alguns servidores MCP n\xE3o est\xE3o dispon\xEDveis")
29579
+ );
29580
+ }
29581
+ results.push(check("Runtime", "Modo", "pass", diagnostics.agentMode));
29582
+ return results;
29583
+ }
29584
+ var doctorCommand2 = {
29585
+ name: "doctor",
29586
+ description: "Diagn\xF3stico de ambiente e configura\xE7\xE3o do DeepCode",
29587
+ kind: "built-in",
29588
+ supportedModes: ["interactive"],
29589
+ action: (context) => {
29590
+ const cwd = context.ui.getCwd?.() ?? process4.cwd();
29591
+ const diagnostics = context.ui.getRuntimeDiagnostics?.() ?? null;
29592
+ const checks = [
29593
+ ...runEnvironmentChecks(cwd),
29594
+ ...diagnostics ? runRuntimeChecks(diagnostics) : []
29595
+ ];
29596
+ const summary = {
29597
+ pass: checks.filter((c) => c.status === "pass").length,
29598
+ warn: checks.filter((c) => c.status === "warn").length,
29599
+ fail: checks.filter((c) => c.status === "fail").length
29600
+ };
29601
+ context.ui.addItem({ type: "doctor", checks, summary }, Date.now());
29602
+ }
29603
+ };
29604
+ var DEFAULT_SHOW = 5;
29605
+ var historyCommand = {
29606
+ name: "history",
29607
+ description: "Mostra o resumo e \xFAltimos prompts da sess\xE3o atual",
29608
+ kind: "built-in",
29609
+ supportedModes: ["interactive"],
29610
+ action: (context, args) => {
29611
+ const messages = context.ui.getMessages?.() ?? [];
29612
+ const userMessages = messages.filter((m) => m.role === "user");
29613
+ const assistantMessages = messages.filter((m) => m.role === "assistant");
29614
+ const total = messages.length;
29615
+ const showN = Math.min(Number.parseInt(args?.trim() || String(DEFAULT_SHOW), 10) || DEFAULT_SHOW, userMessages.length);
29616
+ const lines = [
29617
+ `Sess\xE3o: ${total} mensagens (${userMessages.length} do usu\xE1rio, ${assistantMessages.length} do assistente)`,
29618
+ ""
29619
+ ];
29620
+ if (userMessages.length === 0) {
29621
+ lines.push("Nenhuma mensagem ainda.");
29622
+ } else {
29623
+ lines.push(`\xDAltimos ${showN} prompt${showN !== 1 ? "s" : ""}:`);
29624
+ const slice = userMessages.slice(-showN);
29625
+ for (let i = 0; i < slice.length; i++) {
29626
+ const msg = slice[i];
29627
+ const raw = msg.content;
29628
+ const content = typeof raw === "string" ? raw : Array.isArray(raw) ? raw.filter((p) => typeof p === "object" && p !== null && p["type"] === "text").map((p) => p.text).join(" ") : String(raw);
29629
+ const preview = content.replace(/\n+/g, " ").trim().slice(0, 80);
29630
+ const n = userMessages.length - showN + i + 1;
29631
+ lines.push(` ${n}. ${preview}${content.length > 80 ? "\u2026" : ""}`);
29632
+ }
29633
+ }
29634
+ context.ui.addItem({ type: "info", text: lines.join("\n") }, Date.now());
29635
+ }
29636
+ };
29637
+ function formatDurationSecs(ms) {
29638
+ const totalSecs = Math.floor(ms / 1e3);
29639
+ if (totalSecs < 60) return `${totalSecs}s`;
29640
+ const mins = Math.floor(totalSecs / 60);
29641
+ const secs = totalSecs % 60;
29642
+ if (mins < 60) return `${mins}m ${secs}s`;
29643
+ const hrs = Math.floor(mins / 60);
29644
+ return `${hrs}h ${mins % 60}m`;
29645
+ }
29646
+ var statsCommand = {
29647
+ name: "stats",
29648
+ description: "Exibe estat\xEDsticas da sess\xE3o atual (tokens, mensagens, tempo)",
29649
+ kind: "built-in",
29650
+ supportedModes: ["interactive"],
29651
+ action: (context) => {
29652
+ const messages = context.ui.getMessages?.() ?? [];
29653
+ const tokenStats = context.ui.getTokenStats?.();
29654
+ const now = Date.now();
29655
+ const startedAt = tokenStats?.sessionStartedAt ?? now;
29656
+ const duration = formatDurationSecs(now - startedAt);
29657
+ context.ui.addItem(
29658
+ {
29659
+ type: "stats",
29660
+ duration,
29661
+ promptTokens: tokenStats?.lastPromptTokens,
29662
+ outputTokens: tokenStats?.lastOutputTokens,
29663
+ messageCount: messages.length
29664
+ },
29665
+ now
29666
+ );
29667
+ }
29668
+ };
28315
29669
  var updateCommand2 = {
28316
29670
  name: "update",
28317
29671
  description: "Check published DeepCode versions",
@@ -28338,6 +29692,84 @@ var updateCommand2 = {
28338
29692
  return { type: "message", messageType: "info", content: lines.join("\n") };
28339
29693
  }
28340
29694
  };
29695
+ function memoryIndexPath(cwd) {
29696
+ const slug = cwd.replace(/\//g, "-");
29697
+ return path17.join(os8.homedir(), ".claude", "projects", slug, "memory", "MEMORY.md");
29698
+ }
29699
+ function memoryDirPath(cwd) {
29700
+ const slug = cwd.replace(/\//g, "-");
29701
+ return path17.join(os8.homedir(), ".claude", "projects", slug, "memory");
29702
+ }
29703
+ var memoryCommand = {
29704
+ name: "memory",
29705
+ description: "Mostra o \xEDndice de mem\xF3ria do projeto atual",
29706
+ kind: "built-in",
29707
+ supportedModes: ["interactive"],
29708
+ action: (context) => {
29709
+ const cwd = context.ui.getCwd?.() ?? process.cwd();
29710
+ const indexPath = memoryIndexPath(cwd);
29711
+ const memDir = memoryDirPath(cwd);
29712
+ let content;
29713
+ try {
29714
+ content = fs10.readFileSync(indexPath, "utf8").trim();
29715
+ } catch {
29716
+ const dirExists = fs10.existsSync(memDir);
29717
+ const msg = dirExists ? `Mem\xF3ria existe mas MEMORY.md n\xE3o foi encontrado em:
29718
+ ${indexPath}` : `Nenhuma mem\xF3ria encontrada para este projeto.
29719
+ Esperado em: ${indexPath}`;
29720
+ context.ui.addItem({ type: "info", text: msg }, Date.now());
29721
+ return;
29722
+ }
29723
+ if (!content) {
29724
+ context.ui.addItem({ type: "info", text: "MEMORY.md est\xE1 vazio." }, Date.now());
29725
+ return;
29726
+ }
29727
+ const fileRefs = (content.match(/\[.*?\]\(.*?\.md\)/g) ?? []).length;
29728
+ const header = `Mem\xF3ria do projeto (${fileRefs} entr${fileRefs !== 1 ? "adas" : "ada"}):
29729
+ `;
29730
+ context.ui.addItem({ type: "info", text: header + content }, Date.now());
29731
+ }
29732
+ };
29733
+ var YOLO_MODES = {
29734
+ read: "allow",
29735
+ write: "allow",
29736
+ gitLocal: "allow",
29737
+ shell: "allow",
29738
+ dangerous: "allow"
29739
+ };
29740
+ var SAFE_MODES = {
29741
+ read: "allow",
29742
+ write: "ask",
29743
+ gitLocal: "allow",
29744
+ shell: "ask",
29745
+ dangerous: "ask"
29746
+ };
29747
+ var yoloCommand = {
29748
+ name: "yolo",
29749
+ description: "Define todas as permiss\xF5es como 'allow' (sem confirma\xE7\xF5es)",
29750
+ kind: "built-in",
29751
+ supportedModes: ["interactive"],
29752
+ action: (context) => {
29753
+ context.ui.setPermissions?.(YOLO_MODES);
29754
+ context.ui.addItem(
29755
+ { type: "info", text: "Modo YOLO ativado: todas as ferramentas aprovadas automaticamente." },
29756
+ Date.now()
29757
+ );
29758
+ }
29759
+ };
29760
+ var safeCommand = {
29761
+ name: "safe",
29762
+ description: "Restaura permiss\xF5es padr\xE3o (write e shell pedem confirma\xE7\xE3o)",
29763
+ kind: "built-in",
29764
+ supportedModes: ["interactive"],
29765
+ action: (context) => {
29766
+ context.ui.setPermissions?.(SAFE_MODES);
29767
+ context.ui.addItem(
29768
+ { type: "info", text: "Permiss\xF5es restauradas: escrita e shell voltam a pedir confirma\xE7\xE3o." },
29769
+ Date.now()
29770
+ );
29771
+ }
29772
+ };
28341
29773
  function sessionNotReady() {
28342
29774
  return {
28343
29775
  type: "message",
@@ -28541,15 +29973,15 @@ var CommandDialog = ({
28541
29973
  title,
28542
29974
  lines,
28543
29975
  footerText = "Press Esc or Enter to close."
28544
- }) => /* @__PURE__ */ jsx42(Box32, { marginLeft: 2, marginRight: 2, marginTop: 1, flexDirection: "column", children: /* @__PURE__ */ jsxs37(Box32, { borderStyle: "round", borderColor: theme.border.default, padding: 1, flexDirection: "column", children: [
28545
- /* @__PURE__ */ jsx42(Text40, { bold: true, color: theme.text.accent, children: title }),
28546
- /* @__PURE__ */ jsx42(Box32, { marginTop: 1, flexDirection: "column", children: lines.map((line, index) => /* @__PURE__ */ jsx42(Text40, { color: theme.text.primary, children: line }, index)) }),
28547
- /* @__PURE__ */ jsx42(Box32, { marginTop: 1, children: /* @__PURE__ */ jsx42(Text40, { color: theme.text.secondary, children: footerText }) })
29976
+ }) => /* @__PURE__ */ jsx53(Box43, { marginLeft: 2, marginRight: 2, marginTop: 1, flexDirection: "column", children: /* @__PURE__ */ jsxs47(Box43, { borderStyle: "round", borderColor: theme.border.default, padding: 1, flexDirection: "column", children: [
29977
+ /* @__PURE__ */ jsx53(Text51, { bold: true, color: theme.text.accent, children: title }),
29978
+ /* @__PURE__ */ jsx53(Box43, { marginTop: 1, flexDirection: "column", children: lines.map((line, index) => /* @__PURE__ */ jsx53(Text51, { color: theme.text.primary, children: line }, index)) }),
29979
+ /* @__PURE__ */ jsx53(Box43, { marginTop: 1, children: /* @__PURE__ */ jsx53(Text51, { color: theme.text.secondary, children: footerText }) })
28548
29980
  ] }) });
28549
29981
  var ThemeDialog = ({ onSelect, onClose, onPreview }) => {
28550
- const originalTheme = useRef15(themeManager.getActiveTheme().name);
28551
- const available = useMemo12(() => themeManager.getAvailableThemes(), []);
28552
- const items = useMemo12(
29982
+ const originalTheme = useRef18(themeManager.getActiveTheme().name);
29983
+ const available = useMemo13(() => themeManager.getAvailableThemes(), []);
29984
+ const items = useMemo13(
28553
29985
  () => available.map((entry) => ({
28554
29986
  key: entry.name,
28555
29987
  value: entry.name,
@@ -28563,7 +29995,7 @@ var ThemeDialog = ({ onSelect, onClose, onPreview }) => {
28563
29995
  0,
28564
29996
  available.findIndex((entry) => entry.name === originalTheme.current)
28565
29997
  );
28566
- const handleEscape = useCallback20(
29998
+ const handleEscape = useCallback21(
28567
29999
  (key) => {
28568
30000
  if (key.name === "escape") {
28569
30001
  themeManager.setActiveTheme(originalTheme.current);
@@ -28574,15 +30006,15 @@ var ThemeDialog = ({ onSelect, onClose, onPreview }) => {
28574
30006
  [onClose, onPreview]
28575
30007
  );
28576
30008
  useKeypress(handleEscape, { isActive: true });
28577
- const handleHighlight = useCallback20(
30009
+ const handleHighlight = useCallback21(
28578
30010
  (themeName) => {
28579
30011
  themeManager.setActiveTheme(themeName);
28580
30012
  onPreview();
28581
30013
  },
28582
30014
  [onPreview]
28583
30015
  );
28584
- return /* @__PURE__ */ jsxs38(
28585
- Box33,
30016
+ return /* @__PURE__ */ jsxs48(
30017
+ Box44,
28586
30018
  {
28587
30019
  flexDirection: "column",
28588
30020
  borderStyle: "round",
@@ -28591,8 +30023,8 @@ var ThemeDialog = ({ onSelect, onClose, onPreview }) => {
28591
30023
  marginLeft: 2,
28592
30024
  marginRight: 2,
28593
30025
  children: [
28594
- /* @__PURE__ */ jsx43(Text41, { bold: true, color: theme.text.accent, children: "Select theme" }),
28595
- /* @__PURE__ */ jsx43(
30026
+ /* @__PURE__ */ jsx54(Text52, { bold: true, color: theme.text.accent, children: "Select theme" }),
30027
+ /* @__PURE__ */ jsx54(
28596
30028
  RadioButtonSelect,
28597
30029
  {
28598
30030
  items,
@@ -28602,7 +30034,7 @@ var ThemeDialog = ({ onSelect, onClose, onPreview }) => {
28602
30034
  isFocused: true
28603
30035
  }
28604
30036
  ),
28605
- /* @__PURE__ */ jsx43(Text41, { color: theme.text.secondary, children: "\u2191\u2193 navigate \xB7 Enter apply \xB7 Esc cancel" })
30037
+ /* @__PURE__ */ jsx54(Text52, { color: theme.text.secondary, children: "\u2191\u2193 navigate \xB7 Enter apply \xB7 Esc cancel" })
28606
30038
  ]
28607
30039
  }
28608
30040
  );
@@ -28639,17 +30071,17 @@ var ProviderDialog = ({
28639
30071
  onTestProvider,
28640
30072
  onClose
28641
30073
  }) => {
28642
- const [phase, setPhase] = useState25("providers");
28643
- const [selectedProvider, setSelectedProvider] = useState25(currentProvider);
28644
- const [apiKeyInput, setApiKeyInput] = useState25("");
28645
- const [isBusy, setIsBusy] = useState25(false);
28646
- const [status, setStatus] = useState25(null);
28647
- const [testLatencyMs, setTestLatencyMs] = useState25(void 0);
30074
+ const [phase, setPhase] = useState29("providers");
30075
+ const [selectedProvider, setSelectedProvider] = useState29(currentProvider);
30076
+ const [apiKeyInput, setApiKeyInput] = useState29("");
30077
+ const [isBusy, setIsBusy] = useState29(false);
30078
+ const [status, setStatus] = useState29(null);
30079
+ const [testLatencyMs, setTestLatencyMs] = useState29(void 0);
28648
30080
  const isLocal = CREDENTIAL_FREE_PROVIDERS.has(selectedProvider);
28649
30081
  const keyIsSet = hasApiKey(selectedProvider);
28650
30082
  const keyHint = getProviderKeyHint(selectedProvider);
28651
30083
  const canTest = keyIsSet || isLocal;
28652
- const providerItems = useMemo13(
30084
+ const providerItems = useMemo14(
28653
30085
  () => providers.map((p) => ({
28654
30086
  key: p,
28655
30087
  value: p,
@@ -28660,7 +30092,7 @@ var ProviderDialog = ({
28660
30092
  })),
28661
30093
  [currentProvider, hasApiKey, providers]
28662
30094
  );
28663
- const actionItems = useMemo13(
30095
+ const actionItems = useMemo14(
28664
30096
  () => [
28665
30097
  {
28666
30098
  key: "use",
@@ -28703,7 +30135,7 @@ var ProviderDialog = ({
28703
30135
  ],
28704
30136
  [canTest, currentProvider, isLocal, selectedProvider]
28705
30137
  );
28706
- const selectProvider = useCallback21(
30138
+ const selectProvider = useCallback22(
28707
30139
  (provider) => {
28708
30140
  setSelectedProvider(provider);
28709
30141
  setStatus(null);
@@ -28712,7 +30144,7 @@ var ProviderDialog = ({
28712
30144
  },
28713
30145
  []
28714
30146
  );
28715
- const runTest = useCallback21(async () => {
30147
+ const runTest = useCallback22(async () => {
28716
30148
  setIsBusy(true);
28717
30149
  setTestLatencyMs(void 0);
28718
30150
  setStatus({ text: `Testing ${selectedProvider}\u2026`, ok: true });
@@ -28734,7 +30166,7 @@ var ProviderDialog = ({
28734
30166
  setIsBusy(false);
28735
30167
  }
28736
30168
  }, [onTestProvider, selectedProvider]);
28737
- const selectAction = useCallback21(
30169
+ const selectAction = useCallback22(
28738
30170
  (action) => {
28739
30171
  if (isBusy) return;
28740
30172
  if (action === "editKey") {
@@ -28775,7 +30207,7 @@ var ProviderDialog = ({
28775
30207
  },
28776
30208
  [isBusy, onClose, onSelectProvider, onSetDefaultProvider, runTest, selectedProvider]
28777
30209
  );
28778
- const saveApiKey = useCallback21(async () => {
30210
+ const saveApiKey = useCallback22(async () => {
28779
30211
  const normalized2 = apiKeyInput.trim();
28780
30212
  if (!normalized2) {
28781
30213
  setStatus({ text: "Type a key before saving.", ok: false });
@@ -28832,8 +30264,8 @@ var ProviderDialog = ({
28832
30264
  );
28833
30265
  const statusColor2 = status ? status.ok ? status.text.startsWith("\u2713") ? theme.status.success : theme.text.secondary : theme.status.error : void 0;
28834
30266
  const footer = phase === "apiKey" ? "Enter save Ctrl+U clear Esc cancel" : phase === "providers" ? "\u2191\u2193 navigate Enter select Esc close" : "\u2191\u2193 navigate Enter confirm Esc back";
28835
- return /* @__PURE__ */ jsxs39(
28836
- Box34,
30267
+ return /* @__PURE__ */ jsxs49(
30268
+ Box45,
28837
30269
  {
28838
30270
  flexDirection: "column",
28839
30271
  borderStyle: "round",
@@ -28844,19 +30276,19 @@ var ProviderDialog = ({
28844
30276
  marginRight: 2,
28845
30277
  minWidth: 44,
28846
30278
  children: [
28847
- /* @__PURE__ */ jsxs39(Box34, { marginBottom: 1, gap: 1, children: [
28848
- /* @__PURE__ */ jsx44(Text42, { bold: true, color: theme.text.accent, children: "Providers" }),
28849
- phase !== "providers" && /* @__PURE__ */ jsxs39(Fragment9, { children: [
28850
- /* @__PURE__ */ jsx44(Text42, { color: theme.text.secondary, children: "\u203A" }),
28851
- /* @__PURE__ */ jsx44(Text42, { bold: true, color: theme.text.primary, children: selectedProvider })
30279
+ /* @__PURE__ */ jsxs49(Box45, { marginBottom: 1, gap: 1, children: [
30280
+ /* @__PURE__ */ jsx55(Text53, { bold: true, color: theme.text.accent, children: "Providers" }),
30281
+ phase !== "providers" && /* @__PURE__ */ jsxs49(Fragment12, { children: [
30282
+ /* @__PURE__ */ jsx55(Text53, { color: theme.text.secondary, children: "\u203A" }),
30283
+ /* @__PURE__ */ jsx55(Text53, { bold: true, color: theme.text.primary, children: selectedProvider })
28852
30284
  ] }),
28853
- phase === "providers" && currentModel && /* @__PURE__ */ jsxs39(Text42, { color: theme.text.secondary, children: [
30285
+ phase === "providers" && currentModel && /* @__PURE__ */ jsxs49(Text53, { color: theme.text.secondary, children: [
28854
30286
  " (",
28855
30287
  currentModel,
28856
30288
  ")"
28857
30289
  ] })
28858
30290
  ] }),
28859
- phase === "providers" && /* @__PURE__ */ jsx44(
30291
+ phase === "providers" && /* @__PURE__ */ jsx55(
28860
30292
  BaseSelectionList,
28861
30293
  {
28862
30294
  items: providerItems,
@@ -28866,25 +30298,25 @@ var ProviderDialog = ({
28866
30298
  maxItemsToShow: 8,
28867
30299
  renderItem: (item, { titleColor }) => {
28868
30300
  const { icon, color, label } = getStatusMark(item.provider, item.keyIsSet);
28869
- return /* @__PURE__ */ jsxs39(Box34, { gap: 1, children: [
28870
- /* @__PURE__ */ jsx44(Text42, { color, children: icon }),
28871
- /* @__PURE__ */ jsx44(Text42, { color: titleColor, bold: item.isCurrent, children: item.provider.padEnd(12) }),
28872
- /* @__PURE__ */ jsx44(Text42, { color, dimColor: !item.keyIsSet && !item.isLocal, children: label }),
28873
- item.isCurrent && /* @__PURE__ */ jsx44(Text42, { color: theme.text.accent, children: "\u25B6" })
30301
+ return /* @__PURE__ */ jsxs49(Box45, { gap: 1, children: [
30302
+ /* @__PURE__ */ jsx55(Text53, { color, children: icon }),
30303
+ /* @__PURE__ */ jsx55(Text53, { color: titleColor, bold: item.isCurrent, children: item.provider.padEnd(12) }),
30304
+ /* @__PURE__ */ jsx55(Text53, { color, dimColor: !item.keyIsSet && !item.isLocal, children: label }),
30305
+ item.isCurrent && /* @__PURE__ */ jsx55(Text53, { color: theme.text.accent, children: "\u25B6" })
28874
30306
  ] });
28875
30307
  }
28876
30308
  }
28877
30309
  ),
28878
- phase === "actions" && /* @__PURE__ */ jsxs39(Fragment9, { children: [
28879
- /* @__PURE__ */ jsxs39(Box34, { marginBottom: 1, gap: 1, children: [
28880
- /* @__PURE__ */ jsx44(Text42, { color: theme.ui.comment, children: "session" }),
28881
- /* @__PURE__ */ jsx44(Text42, { color: selectedProvider === currentProvider ? theme.text.accent : theme.text.secondary, children: selectedProvider === currentProvider ? "active" : `still using ${currentProvider}` })
30310
+ phase === "actions" && /* @__PURE__ */ jsxs49(Fragment12, { children: [
30311
+ /* @__PURE__ */ jsxs49(Box45, { marginBottom: 1, gap: 1, children: [
30312
+ /* @__PURE__ */ jsx55(Text53, { color: theme.ui.comment, children: "session" }),
30313
+ /* @__PURE__ */ jsx55(Text53, { color: selectedProvider === currentProvider ? theme.text.accent : theme.text.secondary, children: selectedProvider === currentProvider ? "active" : `still using ${currentProvider}` })
28882
30314
  ] }),
28883
- /* @__PURE__ */ jsxs39(Box34, { marginBottom: 1, gap: 1, children: [
28884
- /* @__PURE__ */ jsx44(Text42, { color: theme.ui.comment, children: "key" }),
28885
- isLocal ? /* @__PURE__ */ jsx44(Text42, { color: theme.text.accent, children: "no key required" }) : keyHint ? /* @__PURE__ */ jsx44(Text42, { color: theme.text.secondary, children: keyHint }) : /* @__PURE__ */ jsx44(Text42, { color: theme.ui.comment, dimColor: true, children: "not configured" })
30315
+ /* @__PURE__ */ jsxs49(Box45, { marginBottom: 1, gap: 1, children: [
30316
+ /* @__PURE__ */ jsx55(Text53, { color: theme.ui.comment, children: "key" }),
30317
+ isLocal ? /* @__PURE__ */ jsx55(Text53, { color: theme.text.accent, children: "no key required" }) : keyHint ? /* @__PURE__ */ jsx55(Text53, { color: theme.text.secondary, children: keyHint }) : /* @__PURE__ */ jsx55(Text53, { color: theme.ui.comment, dimColor: true, children: "not configured" })
28886
30318
  ] }),
28887
- /* @__PURE__ */ jsx44(
30319
+ /* @__PURE__ */ jsx55(
28888
30320
  BaseSelectionList,
28889
30321
  {
28890
30322
  items: actionItems,
@@ -28892,10 +30324,10 @@ var ProviderDialog = ({
28892
30324
  isFocused: !isBusy,
28893
30325
  showNumbers: false,
28894
30326
  maxItemsToShow: 6,
28895
- renderItem: (item, { titleColor }) => /* @__PURE__ */ jsxs39(Box34, { gap: 1, children: [
28896
- /* @__PURE__ */ jsx44(Text42, { color: titleColor, children: item.icon }),
28897
- /* @__PURE__ */ jsx44(Text42, { color: titleColor, children: item.label }),
28898
- item.hint && /* @__PURE__ */ jsxs39(Text42, { color: theme.ui.comment, dimColor: true, children: [
30327
+ renderItem: (item, { titleColor }) => /* @__PURE__ */ jsxs49(Box45, { gap: 1, children: [
30328
+ /* @__PURE__ */ jsx55(Text53, { color: titleColor, children: item.icon }),
30329
+ /* @__PURE__ */ jsx55(Text53, { color: titleColor, children: item.label }),
30330
+ item.hint && /* @__PURE__ */ jsxs49(Text53, { color: theme.ui.comment, dimColor: true, children: [
28899
30331
  "(",
28900
30332
  item.hint,
28901
30333
  ")"
@@ -28904,26 +30336,26 @@ var ProviderDialog = ({
28904
30336
  }
28905
30337
  )
28906
30338
  ] }),
28907
- phase === "apiKey" && /* @__PURE__ */ jsxs39(Box34, { flexDirection: "column", gap: 1, marginBottom: 1, children: [
28908
- /* @__PURE__ */ jsxs39(Box34, { gap: 1, children: [
28909
- /* @__PURE__ */ jsx44(Text42, { color: theme.ui.comment, children: "current" }),
28910
- isLocal ? /* @__PURE__ */ jsx44(Text42, { color: theme.text.accent, children: "no key required" }) : keyHint ? /* @__PURE__ */ jsx44(Text42, { color: theme.text.secondary, children: keyHint }) : /* @__PURE__ */ jsx44(Text42, { color: theme.ui.comment, dimColor: true, children: "not set" })
30339
+ phase === "apiKey" && /* @__PURE__ */ jsxs49(Box45, { flexDirection: "column", gap: 1, marginBottom: 1, children: [
30340
+ /* @__PURE__ */ jsxs49(Box45, { gap: 1, children: [
30341
+ /* @__PURE__ */ jsx55(Text53, { color: theme.ui.comment, children: "current" }),
30342
+ isLocal ? /* @__PURE__ */ jsx55(Text53, { color: theme.text.accent, children: "no key required" }) : keyHint ? /* @__PURE__ */ jsx55(Text53, { color: theme.text.secondary, children: keyHint }) : /* @__PURE__ */ jsx55(Text53, { color: theme.ui.comment, dimColor: true, children: "not set" })
28911
30343
  ] }),
28912
- /* @__PURE__ */ jsxs39(Box34, { gap: 1, children: [
28913
- /* @__PURE__ */ jsx44(Text42, { color: theme.ui.comment, children: "new key" }),
28914
- /* @__PURE__ */ jsx44(Box34, { borderStyle: "single", borderColor: theme.border.focused, paddingX: 1, children: /* @__PURE__ */ jsx44(Text42, { color: theme.text.accent, children: apiKeyInput.length > 0 ? maskApiKeyInput(apiKeyInput.length) : /* @__PURE__ */ jsx44(Text42, { color: theme.ui.comment, dimColor: true, children: "paste or type\u2026" }) }) })
30344
+ /* @__PURE__ */ jsxs49(Box45, { gap: 1, children: [
30345
+ /* @__PURE__ */ jsx55(Text53, { color: theme.ui.comment, children: "new key" }),
30346
+ /* @__PURE__ */ jsx55(Box45, { borderStyle: "single", borderColor: theme.border.focused, paddingX: 1, children: /* @__PURE__ */ jsx55(Text53, { color: theme.text.accent, children: apiKeyInput.length > 0 ? maskApiKeyInput(apiKeyInput.length) : /* @__PURE__ */ jsx55(Text53, { color: theme.ui.comment, dimColor: true, children: "paste or type\u2026" }) }) })
28915
30347
  ] })
28916
30348
  ] }),
28917
- status && /* @__PURE__ */ jsx44(Box34, { marginTop: 1, children: /* @__PURE__ */ jsx44(Text42, { color: statusColor2, children: status.text }) }),
28918
- phase === "actions" && testLatencyMs !== void 0 && /* @__PURE__ */ jsxs39(Box34, { marginTop: 0, gap: 1, children: [
28919
- /* @__PURE__ */ jsxs39(Text42, { color: getLatencyColor(testLatencyMs), bold: true, children: [
30349
+ status && /* @__PURE__ */ jsx55(Box45, { marginTop: 1, children: /* @__PURE__ */ jsx55(Text53, { color: statusColor2, children: status.text }) }),
30350
+ phase === "actions" && testLatencyMs !== void 0 && /* @__PURE__ */ jsxs49(Box45, { marginTop: 0, gap: 1, children: [
30351
+ /* @__PURE__ */ jsxs49(Text53, { color: getLatencyColor(testLatencyMs), bold: true, children: [
28920
30352
  testLatencyMs,
28921
30353
  "ms"
28922
30354
  ] }),
28923
- /* @__PURE__ */ jsx44(Text42, { color: theme.text.secondary, children: testLatencyMs < 300 ? "excellent" : testLatencyMs < 800 ? "good" : "slow" })
30355
+ /* @__PURE__ */ jsx55(Text53, { color: theme.text.secondary, children: testLatencyMs < 300 ? "excellent" : testLatencyMs < 800 ? "good" : "slow" })
28924
30356
  ] }),
28925
- /* @__PURE__ */ jsx44(
28926
- Box34,
30357
+ /* @__PURE__ */ jsx55(
30358
+ Box45,
28927
30359
  {
28928
30360
  marginTop: 1,
28929
30361
  borderStyle: "single",
@@ -28932,7 +30364,7 @@ var ProviderDialog = ({
28932
30364
  borderLeft: false,
28933
30365
  borderRight: false,
28934
30366
  borderColor: theme.ui.comment,
28935
- children: /* @__PURE__ */ jsxs39(Text42, { color: theme.ui.comment, dimColor: true, children: [
30367
+ children: /* @__PURE__ */ jsxs49(Text53, { color: theme.ui.comment, dimColor: true, children: [
28936
30368
  footer,
28937
30369
  phase === "actions" && " Test does not change the session."
28938
30370
  ] })
@@ -28950,58 +30382,64 @@ var PERMISSION_KEYS = [
28950
30382
  "dangerous"
28951
30383
  ];
28952
30384
  var MODE_CYCLE = ["allow", "ask", "deny"];
28953
- var SAVE_VALUE = "__save__";
28954
- var CANCEL_VALUE = "__cancel__";
30385
+ var ACTIONS3 = ["save", "cancel"];
30386
+ var ALL_ROWS = [...PERMISSION_KEYS, ...ACTIONS3];
28955
30387
  function nextMode(mode) {
28956
30388
  const index = MODE_CYCLE.indexOf(mode);
28957
30389
  return MODE_CYCLE[(index + 1) % MODE_CYCLE.length];
28958
30390
  }
30391
+ function modeColor(mode) {
30392
+ if (mode === "allow") return theme.status.success;
30393
+ if (mode === "deny") return theme.status.error;
30394
+ return theme.status.warning;
30395
+ }
30396
+ var KEY_LABEL = {
30397
+ read: "read",
30398
+ write: "write",
30399
+ gitLocal: "git local",
30400
+ shell: "shell",
30401
+ dangerous: "dangerous"
30402
+ };
28959
30403
  var PermissionsDialog = ({
28960
30404
  current,
28961
30405
  onSave,
28962
30406
  onClose
28963
30407
  }) => {
28964
- const [modes, setModes] = useState26(current);
28965
- const dirty = useMemo14(
28966
- () => PERMISSION_KEYS.some((key) => modes[key] !== current[key]),
28967
- [modes, current]
28968
- );
28969
- const items = useMemo14(() => {
28970
- const rows = PERMISSION_KEYS.map((key) => ({
28971
- key,
28972
- value: key,
28973
- label: `${key.padEnd(10)} ${modes[key]}`
28974
- }));
28975
- rows.push({ key: SAVE_VALUE, value: SAVE_VALUE, label: dirty ? "Save changes" : "Save changes (no edits)" });
28976
- rows.push({ key: CANCEL_VALUE, value: CANCEL_VALUE, label: "Cancel" });
28977
- return rows;
28978
- }, [modes, dirty]);
28979
- const handleSelect = useCallback22(
28980
- (value) => {
28981
- if (value === SAVE_VALUE) {
28982
- onSave(modes);
30408
+ const [modes, setModes] = useState30(current);
30409
+ const [focusIndex, setFocusIndex] = useState30(0);
30410
+ const dirty = PERMISSION_KEYS.some((k) => modes[k] !== current[k]);
30411
+ const handleKey = useCallback23(
30412
+ (key) => {
30413
+ if (key.name === "escape") {
30414
+ onClose();
28983
30415
  return;
28984
30416
  }
28985
- if (value === CANCEL_VALUE) {
28986
- onClose();
30417
+ if (key.name === "up" || key.ctrl && key.name === "p") {
30418
+ setFocusIndex((i) => (i - 1 + ALL_ROWS.length) % ALL_ROWS.length);
28987
30419
  return;
28988
30420
  }
28989
- const key = value;
28990
- setModes((prev) => ({ ...prev, [key]: nextMode(prev[key]) }));
28991
- },
28992
- [modes, onClose, onSave]
28993
- );
28994
- const handleEscape = useCallback22(
28995
- (key) => {
28996
- if (key.name === "escape") {
28997
- onClose();
30421
+ if (key.name === "down" || key.ctrl && key.name === "n") {
30422
+ setFocusIndex((i) => (i + 1) % ALL_ROWS.length);
30423
+ return;
30424
+ }
30425
+ if (key.name === "return") {
30426
+ const row = ALL_ROWS[focusIndex];
30427
+ if (row === "save") {
30428
+ onSave(modes);
30429
+ return;
30430
+ }
30431
+ if (row === "cancel") {
30432
+ onClose();
30433
+ return;
30434
+ }
30435
+ setModes((prev) => ({ ...prev, [row]: nextMode(prev[row]) }));
28998
30436
  }
28999
30437
  },
29000
- [onClose]
30438
+ [focusIndex, modes, onClose, onSave]
29001
30439
  );
29002
- useKeypress(handleEscape, { isActive: true });
29003
- return /* @__PURE__ */ jsxs40(
29004
- Box35,
30440
+ useKeypress(handleKey, { isActive: true });
30441
+ return /* @__PURE__ */ jsxs50(
30442
+ Box46,
29005
30443
  {
29006
30444
  flexDirection: "column",
29007
30445
  borderStyle: "round",
@@ -29010,9 +30448,25 @@ var PermissionsDialog = ({
29010
30448
  marginLeft: 2,
29011
30449
  marginRight: 2,
29012
30450
  children: [
29013
- /* @__PURE__ */ jsx45(Text43, { bold: true, color: theme.text.accent, children: "Permission policy" }),
29014
- /* @__PURE__ */ jsx45(RadioButtonSelect, { items, onSelect: handleSelect, isFocused: true, showNumbers: false }),
29015
- /* @__PURE__ */ jsx45(Text43, { color: theme.text.secondary, children: "\u2191\u2193 navigate \xB7 Enter cycles allow/ask/deny \xB7 Esc cancel" })
30451
+ /* @__PURE__ */ jsx56(Text54, { bold: true, color: theme.text.accent, children: "Permission policy" }),
30452
+ PERMISSION_KEYS.map((key, i) => {
30453
+ const focused = focusIndex === i;
30454
+ const mode = modes[key];
30455
+ return /* @__PURE__ */ jsxs50(Box46, { flexDirection: "row", gap: 1, children: [
30456
+ /* @__PURE__ */ jsx56(Text54, { color: focused ? theme.text.accent : theme.text.secondary, children: focused ? "\u203A" : " " }),
30457
+ /* @__PURE__ */ jsx56(Text54, { color: focused ? theme.text.primary : theme.text.secondary, bold: focused, children: KEY_LABEL[key].padEnd(10) }),
30458
+ /* @__PURE__ */ jsx56(Text54, { color: modeColor(mode), bold: focused, children: mode })
30459
+ ] }, key);
30460
+ }),
30461
+ /* @__PURE__ */ jsx56(Box46, { marginTop: 1, flexDirection: "column", children: ACTIONS3.map((action, i) => {
30462
+ const focused = focusIndex === PERMISSION_KEYS.length + i;
30463
+ const label = action === "save" ? dirty ? "Save changes" : "Save changes (no edits)" : "Cancel";
30464
+ return /* @__PURE__ */ jsxs50(Box46, { flexDirection: "row", gap: 1, children: [
30465
+ /* @__PURE__ */ jsx56(Text54, { color: focused ? theme.text.accent : theme.text.secondary, children: focused ? "\u203A" : " " }),
30466
+ /* @__PURE__ */ jsx56(Text54, { color: focused ? theme.text.primary : theme.text.secondary, bold: focused, children: label })
30467
+ ] }, action);
30468
+ }) }),
30469
+ /* @__PURE__ */ jsx56(Text54, { color: theme.text.secondary, dimColor: true, children: "\u2191\u2193 navigate \xB7 Enter cycles allow/ask/deny or selects action \xB7 Esc cancel" })
29016
30470
  ]
29017
30471
  }
29018
30472
  );
@@ -29027,10 +30481,10 @@ var AuthDialog = ({
29027
30481
  onPersistToken,
29028
30482
  onClose
29029
30483
  }) => {
29030
- const [phase, setPhase] = useState27("menu");
29031
- const [deviceCode, setDeviceCode] = useState27(null);
29032
- const [message, setMessage] = useState27("");
29033
- const abortRef = useRef16(null);
30484
+ const [phase, setPhase] = useState31("menu");
30485
+ const [deviceCode, setDeviceCode] = useState31(null);
30486
+ const [message, setMessage] = useState31("");
30487
+ const abortRef = useRef19(null);
29034
30488
  const items = useMemo15(
29035
30489
  () => [
29036
30490
  { key: "login", value: "login", label: "Login with GitHub" },
@@ -29039,7 +30493,7 @@ var AuthDialog = ({
29039
30493
  ],
29040
30494
  [hasToken]
29041
30495
  );
29042
- const startLogin = useCallback23(async () => {
30496
+ const startLogin = useCallback24(async () => {
29043
30497
  if (!clientId) {
29044
30498
  setMessage(
29045
30499
  "No OAuth client configured. Set github.oauthClientId in .deepcode/config.json, or run `deepcode github login` in a terminal."
@@ -29083,7 +30537,7 @@ var AuthDialog = ({
29083
30537
  abortRef.current = null;
29084
30538
  }
29085
30539
  }, [clientId, enterpriseUrl, onPersistToken, scopes, worktree]);
29086
- const clearToken = useCallback23(async () => {
30540
+ const clearToken = useCallback24(async () => {
29087
30541
  try {
29088
30542
  await onPersistToken(void 0);
29089
30543
  setPhase("done");
@@ -29093,7 +30547,7 @@ var AuthDialog = ({
29093
30547
  setMessage(error instanceof Error ? error.message : String(error));
29094
30548
  }
29095
30549
  }, [onPersistToken]);
29096
- const handleSelect = useCallback23(
30550
+ const handleSelect = useCallback24(
29097
30551
  (value) => {
29098
30552
  if (value === "login") {
29099
30553
  void startLogin();
@@ -29105,10 +30559,10 @@ var AuthDialog = ({
29105
30559
  },
29106
30560
  [clearToken, onClose, startLogin]
29107
30561
  );
29108
- useEffect25(() => () => {
30562
+ useEffect29(() => () => {
29109
30563
  abortRef.current?.abort();
29110
30564
  }, []);
29111
- const handleEscape = useCallback23(
30565
+ const handleEscape = useCallback24(
29112
30566
  (key) => {
29113
30567
  if (key.name !== "escape") return;
29114
30568
  if (phase === "running") {
@@ -29120,8 +30574,8 @@ var AuthDialog = ({
29120
30574
  [onClose, phase]
29121
30575
  );
29122
30576
  useKeypress(handleEscape, { isActive: true });
29123
- return /* @__PURE__ */ jsxs41(
29124
- Box36,
30577
+ return /* @__PURE__ */ jsxs51(
30578
+ Box47,
29125
30579
  {
29126
30580
  flexDirection: "column",
29127
30581
  borderStyle: "round",
@@ -29130,32 +30584,32 @@ var AuthDialog = ({
29130
30584
  marginLeft: 2,
29131
30585
  marginRight: 2,
29132
30586
  children: [
29133
- /* @__PURE__ */ jsx46(Text44, { bold: true, color: theme.text.accent, children: "GitHub authentication" }),
29134
- /* @__PURE__ */ jsx46(Text44, { color: theme.text.secondary, children: statusSummary }),
29135
- phase === "menu" && /* @__PURE__ */ jsx46(RadioButtonSelect, { items, onSelect: handleSelect, isFocused: true, showNumbers: false }),
29136
- deviceCode && phase === "running" && /* @__PURE__ */ jsxs41(Box36, { flexDirection: "column", marginTop: 1, children: [
29137
- /* @__PURE__ */ jsxs41(Text44, { children: [
30587
+ /* @__PURE__ */ jsx57(Text55, { bold: true, color: theme.text.accent, children: "GitHub authentication" }),
30588
+ /* @__PURE__ */ jsx57(Text55, { color: theme.text.secondary, children: statusSummary }),
30589
+ phase === "menu" && /* @__PURE__ */ jsx57(RadioButtonSelect, { items, onSelect: handleSelect, isFocused: true, showNumbers: false }),
30590
+ deviceCode && phase === "running" && /* @__PURE__ */ jsxs51(Box47, { flexDirection: "column", marginTop: 1, children: [
30591
+ /* @__PURE__ */ jsxs51(Text55, { children: [
29138
30592
  "Open: ",
29139
- /* @__PURE__ */ jsx46(Text44, { color: theme.text.accent, children: deviceCode.verificationUri })
30593
+ /* @__PURE__ */ jsx57(Text55, { color: theme.text.accent, children: deviceCode.verificationUri })
29140
30594
  ] }),
29141
- /* @__PURE__ */ jsxs41(Text44, { children: [
30595
+ /* @__PURE__ */ jsxs51(Text55, { children: [
29142
30596
  "Code: ",
29143
- /* @__PURE__ */ jsx46(Text44, { bold: true, color: theme.text.accent, children: deviceCode.userCode })
30597
+ /* @__PURE__ */ jsx57(Text55, { bold: true, color: theme.text.accent, children: deviceCode.userCode })
29144
30598
  ] }),
29145
- /* @__PURE__ */ jsxs41(Text44, { color: theme.text.secondary, children: [
30599
+ /* @__PURE__ */ jsxs51(Text55, { color: theme.text.secondary, children: [
29146
30600
  "Expires in ",
29147
30601
  Math.round(deviceCode.expiresIn / 60),
29148
30602
  " minutes."
29149
30603
  ] })
29150
30604
  ] }),
29151
- message && /* @__PURE__ */ jsx46(
29152
- Text44,
30605
+ message && /* @__PURE__ */ jsx57(
30606
+ Text55,
29153
30607
  {
29154
30608
  color: phase === "error" ? theme.status.error : phase === "done" ? theme.status.success : theme.text.secondary,
29155
30609
  children: message
29156
30610
  }
29157
30611
  ),
29158
- /* @__PURE__ */ jsx46(Text44, { color: theme.text.secondary, children: phase === "running" ? "Esc cancel login" : phase === "menu" ? "\u2191\u2193 navigate \xB7 Enter select \xB7 Esc close" : "Esc close" })
30612
+ /* @__PURE__ */ jsx57(Text55, { color: theme.text.secondary, children: phase === "running" ? "Esc cancel login" : phase === "menu" ? "\u2191\u2193 navigate \xB7 Enter select \xB7 Esc close" : "Esc close" })
29159
30613
  ]
29160
30614
  }
29161
30615
  );
@@ -29201,13 +30655,13 @@ var ModelDialog = ({
29201
30655
  onSelectModel,
29202
30656
  onClose
29203
30657
  }) => {
29204
- const [loadState, setLoadState] = useState28("loading");
29205
- const [models, setModels] = useState28([]);
29206
- const [errorMsg, setErrorMsg] = useState28("");
29207
- const [search, setSearch] = useState28("");
29208
- const [activeSelIndex, setActiveSelIndex] = useState28(0);
29209
- const abortRef = useRef17(null);
29210
- useEffect26(() => {
30658
+ const [loadState, setLoadState] = useState32("loading");
30659
+ const [models, setModels] = useState32([]);
30660
+ const [errorMsg, setErrorMsg] = useState32("");
30661
+ const [search, setSearch] = useState32("");
30662
+ const [activeSelIndex, setActiveSelIndex] = useState32(0);
30663
+ const abortRef = useRef20(null);
30664
+ useEffect30(() => {
29211
30665
  const ctrl = new AbortController();
29212
30666
  abortRef.current = ctrl;
29213
30667
  onFetchModels(currentProvider, ctrl.signal).then((fetched) => {
@@ -29227,7 +30681,7 @@ var ModelDialog = ({
29227
30681
  );
29228
30682
  const selectableCount = rows.filter((r) => r.kind === "item").length;
29229
30683
  const clampedIndex = Math.min(activeSelIndex, Math.max(0, selectableCount - 1));
29230
- useEffect26(() => {
30684
+ useEffect30(() => {
29231
30685
  setActiveSelIndex(0);
29232
30686
  }, [search]);
29233
30687
  const activeRowPos = useMemo16(
@@ -29239,7 +30693,7 @@ var ModelDialog = ({
29239
30693
  [activeRowPos, rows.length]
29240
30694
  );
29241
30695
  const visibleRows = rows.slice(scrollTop, scrollTop + MAX_VISIBLE);
29242
- const confirm = useCallback24(() => {
30696
+ const confirm = useCallback25(() => {
29243
30697
  const row = rows.find((r) => r.kind === "item" && r.selIndex === clampedIndex);
29244
30698
  if (row?.kind === "item") onSelectModel(row.model.id);
29245
30699
  }, [rows, clampedIndex, onSelectModel]);
@@ -29282,8 +30736,8 @@ var ModelDialog = ({
29282
30736
  }, { isActive: true });
29283
30737
  const canScrollUp = scrollTop > 0;
29284
30738
  const canScrollDown = scrollTop + MAX_VISIBLE < rows.length;
29285
- return /* @__PURE__ */ jsxs42(
29286
- Box37,
30739
+ return /* @__PURE__ */ jsxs52(
30740
+ Box48,
29287
30741
  {
29288
30742
  flexDirection: "column",
29289
30743
  borderStyle: "round",
@@ -29294,80 +30748,80 @@ var ModelDialog = ({
29294
30748
  marginRight: 1,
29295
30749
  minWidth: 58,
29296
30750
  children: [
29297
- /* @__PURE__ */ jsxs42(Box37, { justifyContent: "space-between", marginBottom: 1, children: [
29298
- /* @__PURE__ */ jsxs42(Box37, { gap: 1, children: [
29299
- /* @__PURE__ */ jsx47(Text45, { bold: true, color: theme.text.primary, children: "Select model" }),
29300
- /* @__PURE__ */ jsx47(Text45, { color: theme.text.secondary, children: "for" }),
29301
- /* @__PURE__ */ jsx47(Text45, { color: theme.text.accent, children: currentProvider })
30751
+ /* @__PURE__ */ jsxs52(Box48, { justifyContent: "space-between", marginBottom: 1, children: [
30752
+ /* @__PURE__ */ jsxs52(Box48, { gap: 1, children: [
30753
+ /* @__PURE__ */ jsx58(Text56, { bold: true, color: theme.text.primary, children: "Select model" }),
30754
+ /* @__PURE__ */ jsx58(Text56, { color: theme.text.secondary, children: "for" }),
30755
+ /* @__PURE__ */ jsx58(Text56, { color: theme.text.accent, children: currentProvider })
29302
30756
  ] }),
29303
- /* @__PURE__ */ jsx47(Text45, { color: theme.ui.comment, dimColor: true, children: "esc" })
30757
+ /* @__PURE__ */ jsx58(Text56, { color: theme.ui.comment, dimColor: true, children: "esc" })
29304
30758
  ] }),
29305
- /* @__PURE__ */ jsxs42(
29306
- Box37,
30759
+ /* @__PURE__ */ jsxs52(
30760
+ Box48,
29307
30761
  {
29308
30762
  borderStyle: "single",
29309
30763
  borderColor: search ? theme.border.focused : theme.ui.comment,
29310
30764
  paddingX: 1,
29311
30765
  marginBottom: 1,
29312
30766
  children: [
29313
- /* @__PURE__ */ jsx47(Text45, { color: theme.ui.comment, children: "\u2315 " }),
29314
- search ? /* @__PURE__ */ jsxs42(Text45, { color: theme.text.primary, children: [
30767
+ /* @__PURE__ */ jsx58(Text56, { color: theme.ui.comment, children: "\u2315 " }),
30768
+ search ? /* @__PURE__ */ jsxs52(Text56, { color: theme.text.primary, children: [
29315
30769
  search,
29316
- /* @__PURE__ */ jsx47(Text45, { color: theme.text.accent, children: "\u258C" })
29317
- ] }) : /* @__PURE__ */ jsxs42(Text45, { color: theme.ui.comment, dimColor: true, children: [
30770
+ /* @__PURE__ */ jsx58(Text56, { color: theme.text.accent, children: "\u258C" })
30771
+ ] }) : /* @__PURE__ */ jsxs52(Text56, { color: theme.ui.comment, dimColor: true, children: [
29318
30772
  "Search",
29319
- /* @__PURE__ */ jsx47(Text45, { color: theme.text.accent, children: "\u258C" })
30773
+ /* @__PURE__ */ jsx58(Text56, { color: theme.text.accent, children: "\u258C" })
29320
30774
  ] })
29321
30775
  ]
29322
30776
  }
29323
30777
  ),
29324
- loadState === "loading" && /* @__PURE__ */ jsx47(Box37, { marginY: 1, children: /* @__PURE__ */ jsx47(Text45, { color: theme.text.secondary, children: "Loading models\u2026" }) }),
29325
- loadState === "error" && /* @__PURE__ */ jsxs42(Box37, { flexDirection: "column", marginY: 1, children: [
29326
- /* @__PURE__ */ jsx47(Text45, { color: theme.status.error, children: "\u2717 Could not load models" }),
29327
- /* @__PURE__ */ jsx47(Text45, { color: theme.ui.comment, dimColor: true, children: errorMsg })
30778
+ loadState === "loading" && /* @__PURE__ */ jsx58(Box48, { marginY: 1, children: /* @__PURE__ */ jsx58(Text56, { color: theme.text.secondary, children: "Loading models\u2026" }) }),
30779
+ loadState === "error" && /* @__PURE__ */ jsxs52(Box48, { flexDirection: "column", marginY: 1, children: [
30780
+ /* @__PURE__ */ jsx58(Text56, { color: theme.status.error, children: "\u2717 Could not load models" }),
30781
+ /* @__PURE__ */ jsx58(Text56, { color: theme.ui.comment, dimColor: true, children: errorMsg })
29328
30782
  ] }),
29329
- loadState === "ready" && selectableCount === 0 && /* @__PURE__ */ jsx47(Box37, { marginY: 1, children: /* @__PURE__ */ jsxs42(Text45, { color: theme.ui.comment, dimColor: true, children: [
30783
+ loadState === "ready" && selectableCount === 0 && /* @__PURE__ */ jsx58(Box48, { marginY: 1, children: /* @__PURE__ */ jsxs52(Text56, { color: theme.ui.comment, dimColor: true, children: [
29330
30784
  'No models match "',
29331
30785
  search,
29332
30786
  '"'
29333
30787
  ] }) }),
29334
- loadState === "ready" && selectableCount > 0 && /* @__PURE__ */ jsxs42(Box37, { flexDirection: "column", children: [
29335
- canScrollUp && /* @__PURE__ */ jsx47(Text45, { color: theme.ui.comment, dimColor: true, children: " \u2191" }),
30788
+ loadState === "ready" && selectableCount > 0 && /* @__PURE__ */ jsxs52(Box48, { flexDirection: "column", children: [
30789
+ canScrollUp && /* @__PURE__ */ jsx58(Text56, { color: theme.ui.comment, dimColor: true, children: " \u2191" }),
29336
30790
  visibleRows.map((row, i) => {
29337
30791
  if (row.kind === "header") {
29338
- return /* @__PURE__ */ jsx47(Box37, { marginTop: i === 0 ? 0 : 1, children: /* @__PURE__ */ jsx47(Text45, { color: theme.text.accent, bold: true, children: row.label }) }, `h${i}`);
30792
+ return /* @__PURE__ */ jsx58(Box48, { marginTop: i === 0 ? 0 : 1, children: /* @__PURE__ */ jsx58(Text56, { color: theme.text.accent, bold: true, children: row.label }) }, `h${i}`);
29339
30793
  }
29340
30794
  const { model, selIndex } = row;
29341
30795
  const isActive = selIndex === clampedIndex;
29342
30796
  const isCurrent = model.id === currentModel;
29343
30797
  const free = isFree(model);
29344
30798
  const group = providerGroup(model);
29345
- return /* @__PURE__ */ jsxs42(Box37, { gap: 1, children: [
29346
- /* @__PURE__ */ jsx47(Text45, { color: isActive ? theme.text.accent : theme.ui.comment, children: isCurrent ? "\u25CF" : isActive ? "\u203A" : " " }),
29347
- /* @__PURE__ */ jsxs42(Box37, { flexGrow: 1, gap: 1, children: [
29348
- /* @__PURE__ */ jsx47(
29349
- Text45,
30799
+ return /* @__PURE__ */ jsxs52(Box48, { gap: 1, children: [
30800
+ /* @__PURE__ */ jsx58(Text56, { color: isActive ? theme.text.accent : theme.ui.comment, children: isCurrent ? "\u25CF" : isActive ? "\u203A" : " " }),
30801
+ /* @__PURE__ */ jsxs52(Box48, { flexGrow: 1, gap: 1, children: [
30802
+ /* @__PURE__ */ jsx58(
30803
+ Text56,
29350
30804
  {
29351
30805
  color: isActive ? theme.text.primary : theme.text.secondary,
29352
30806
  bold: isActive,
29353
30807
  children: model.name
29354
30808
  }
29355
30809
  ),
29356
- /* @__PURE__ */ jsx47(Text45, { color: theme.text.accent, dimColor: true, children: group })
30810
+ /* @__PURE__ */ jsx58(Text56, { color: theme.text.accent, dimColor: true, children: group })
29357
30811
  ] }),
29358
- free && /* @__PURE__ */ jsx47(Text45, { color: theme.status.success, dimColor: !isActive, children: "Free" })
30812
+ free && /* @__PURE__ */ jsx58(Text56, { color: theme.status.success, dimColor: !isActive, children: "Free" })
29359
30813
  ] }, model.id);
29360
30814
  }),
29361
- canScrollDown && /* @__PURE__ */ jsx47(Text45, { color: theme.ui.comment, dimColor: true, children: " \u2193" })
30815
+ canScrollDown && /* @__PURE__ */ jsx58(Text56, { color: theme.ui.comment, dimColor: true, children: " \u2193" })
29362
30816
  ] }),
29363
- loadState === "ready" && /* @__PURE__ */ jsx47(Box37, { marginTop: 1, children: /* @__PURE__ */ jsxs42(Text45, { color: theme.ui.comment, dimColor: true, children: [
30817
+ loadState === "ready" && /* @__PURE__ */ jsx58(Box48, { marginTop: 1, children: /* @__PURE__ */ jsxs52(Text56, { color: theme.ui.comment, dimColor: true, children: [
29364
30818
  selectableCount,
29365
30819
  " model",
29366
30820
  selectableCount !== 1 ? "s" : "",
29367
30821
  search ? ` \xB7 "${search}"` : ""
29368
30822
  ] }) }),
29369
- /* @__PURE__ */ jsx47(
29370
- Box37,
30823
+ /* @__PURE__ */ jsx58(
30824
+ Box48,
29371
30825
  {
29372
30826
  marginTop: 1,
29373
30827
  borderStyle: "single",
@@ -29376,7 +30830,7 @@ var ModelDialog = ({
29376
30830
  borderLeft: false,
29377
30831
  borderRight: false,
29378
30832
  borderColor: theme.ui.comment,
29379
- children: /* @__PURE__ */ jsx47(Text45, { color: theme.ui.comment, dimColor: true, children: "\u2191\u2193 navigate type to search Enter use for session Esc close" })
30833
+ children: /* @__PURE__ */ jsx58(Text56, { color: theme.ui.comment, dimColor: true, children: "\u2191\u2193 navigate type to search Enter use for session Esc close" })
29380
30834
  }
29381
30835
  )
29382
30836
  ]
@@ -29390,13 +30844,13 @@ var RATINGS = [
29390
30844
  { rating: 2, label: "Poor" },
29391
30845
  { rating: 1, label: "Very poor" }
29392
30846
  ];
29393
- var CANCEL_VALUE2 = "__cancel__";
30847
+ var CANCEL_VALUE = "__cancel__";
29394
30848
  function appendFeedbackEntry(cwd, rating, label) {
29395
- const file = path142.join(cwd, ".deepcode", "feedback.log");
30849
+ const file = path18.join(cwd, ".deepcode", "feedback.log");
29396
30850
  const entry = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), rating, label });
29397
30851
  try {
29398
- fs7.mkdirSync(path142.dirname(file), { recursive: true });
29399
- fs7.appendFileSync(file, `${entry}
30852
+ fs11.mkdirSync(path18.dirname(file), { recursive: true });
30853
+ fs11.appendFileSync(file, `${entry}
29400
30854
  `, "utf8");
29401
30855
  } catch {
29402
30856
  }
@@ -29409,13 +30863,13 @@ var FeedbackDialog = ({ cwd, onClose }) => {
29409
30863
  value: String(rating),
29410
30864
  label: `${rating} ${label}`
29411
30865
  })),
29412
- { key: CANCEL_VALUE2, value: CANCEL_VALUE2, label: "Cancel" }
30866
+ { key: CANCEL_VALUE, value: CANCEL_VALUE, label: "Cancel" }
29413
30867
  ],
29414
30868
  []
29415
30869
  );
29416
- const handleSelect = useCallback25(
30870
+ const handleSelect = useCallback26(
29417
30871
  (value) => {
29418
- if (value !== CANCEL_VALUE2) {
30872
+ if (value !== CANCEL_VALUE) {
29419
30873
  const opt = RATINGS.find((r) => String(r.rating) === value);
29420
30874
  if (opt) appendFeedbackEntry(cwd, opt.rating, opt.label);
29421
30875
  }
@@ -29423,15 +30877,15 @@ var FeedbackDialog = ({ cwd, onClose }) => {
29423
30877
  },
29424
30878
  [cwd, onClose]
29425
30879
  );
29426
- const handleEscape = useCallback25(
30880
+ const handleEscape = useCallback26(
29427
30881
  (key) => {
29428
30882
  if (key.name === "escape") onClose();
29429
30883
  },
29430
30884
  [onClose]
29431
30885
  );
29432
30886
  useKeypress(handleEscape, { isActive: true });
29433
- return /* @__PURE__ */ jsxs43(
29434
- Box38,
30887
+ return /* @__PURE__ */ jsxs53(
30888
+ Box49,
29435
30889
  {
29436
30890
  flexDirection: "column",
29437
30891
  borderStyle: "round",
@@ -29440,25 +30894,42 @@ var FeedbackDialog = ({ cwd, onClose }) => {
29440
30894
  marginLeft: 2,
29441
30895
  marginRight: 2,
29442
30896
  children: [
29443
- /* @__PURE__ */ jsx48(Text46, { bold: true, color: theme.text.accent, children: "How useful was DeepCode in this session?" }),
29444
- /* @__PURE__ */ jsx48(RadioButtonSelect, { items, onSelect: handleSelect, isFocused: true, showNumbers: false }),
29445
- /* @__PURE__ */ jsx48(Text46, { color: theme.text.secondary, children: "\u2191\u2193 navigate \xB7 Enter submit \xB7 Esc cancel" })
30897
+ /* @__PURE__ */ jsx59(Text57, { bold: true, color: theme.text.accent, children: "How useful was DeepCode in this session?" }),
30898
+ /* @__PURE__ */ jsx59(RadioButtonSelect, { items, onSelect: handleSelect, isFocused: true, showNumbers: false }),
30899
+ /* @__PURE__ */ jsx59(Text57, { color: theme.text.secondary, children: "\u2191\u2193 navigate \xB7 Enter submit \xB7 Esc cancel" })
29446
30900
  ]
29447
30901
  }
29448
30902
  );
29449
30903
  };
29450
30904
  var MAX_VISIBLE2 = 12;
30905
+ function relativeTime(iso) {
30906
+ const diffMs = Date.now() - new Date(iso).getTime();
30907
+ const diffSecs = Math.floor(diffMs / 1e3);
30908
+ if (diffSecs < 60) return "agora";
30909
+ const diffMins = Math.floor(diffSecs / 60);
30910
+ if (diffMins < 60) return `h\xE1 ${diffMins} min`;
30911
+ const diffHours = Math.floor(diffMins / 60);
30912
+ if (diffHours < 24) return `h\xE1 ${diffHours}h`;
30913
+ const diffDays = Math.floor(diffHours / 24);
30914
+ if (diffDays === 1) return "ontem";
30915
+ if (diffDays < 7) return `h\xE1 ${diffDays} dias`;
30916
+ const diffWeeks = Math.floor(diffDays / 7);
30917
+ if (diffWeeks === 1) return "h\xE1 1 semana";
30918
+ if (diffWeeks < 5) return `h\xE1 ${diffWeeks} semanas`;
30919
+ const diffMonths = Math.floor(diffDays / 30);
30920
+ return `h\xE1 ${diffMonths} m\xEAs${diffMonths !== 1 ? "es" : ""}`;
30921
+ }
29451
30922
  function sessionLabel2(session) {
29452
30923
  const name = typeof session.metadata["name"] === "string" ? session.metadata["name"] : void 0;
29453
30924
  const firstUser = session.messages.find((m) => m.role === "user");
29454
30925
  return name ?? firstUser?.content?.slice(0, 55) ?? "(no messages)";
29455
30926
  }
29456
30927
  var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29457
- const [loadState, setLoadState] = useState29("loading");
29458
- const [allSessions, setAllSessions] = useState29([]);
29459
- const [search, setSearch] = useState29("");
29460
- const [activeIndex, setActiveIndex] = useState29(0);
29461
- useEffect27(() => {
30928
+ const [loadState, setLoadState] = useState33("loading");
30929
+ const [allSessions, setAllSessions] = useState33([]);
30930
+ const [search, setSearch] = useState33("");
30931
+ const [activeIndex, setActiveIndex] = useState33(0);
30932
+ useEffect31(() => {
29462
30933
  const manager = new SessionManager(cwd);
29463
30934
  manager.loadAll().then((loaded) => {
29464
30935
  const sorted = [...loaded].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
@@ -29466,7 +30937,7 @@ var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29466
30937
  setLoadState("ready");
29467
30938
  }).catch(() => setLoadState("error"));
29468
30939
  }, [cwd]);
29469
- useEffect27(() => {
30940
+ useEffect31(() => {
29470
30941
  setActiveIndex(0);
29471
30942
  }, [search]);
29472
30943
  const sessions = useMemo18(() => {
@@ -29480,7 +30951,7 @@ var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29480
30951
  [clampedIndex, sessions.length]
29481
30952
  );
29482
30953
  const visibleSessions = sessions.slice(scrollTop, scrollTop + MAX_VISIBLE2);
29483
- const confirm = useCallback26(() => {
30954
+ const confirm = useCallback27(() => {
29484
30955
  const session = sessions[clampedIndex];
29485
30956
  if (session) onSelect(session.id);
29486
30957
  }, [sessions, clampedIndex, onSelect]);
@@ -29523,8 +30994,8 @@ var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29523
30994
  }, { isActive: true });
29524
30995
  const canScrollUp = scrollTop > 0;
29525
30996
  const canScrollDown = scrollTop + MAX_VISIBLE2 < sessions.length;
29526
- return /* @__PURE__ */ jsxs44(
29527
- Box39,
30997
+ return /* @__PURE__ */ jsxs54(
30998
+ Box50,
29528
30999
  {
29529
31000
  flexDirection: "column",
29530
31001
  borderStyle: "round",
@@ -29535,47 +31006,47 @@ var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29535
31006
  marginRight: 1,
29536
31007
  minWidth: 60,
29537
31008
  children: [
29538
- /* @__PURE__ */ jsxs44(Box39, { justifyContent: "space-between", marginBottom: 1, children: [
29539
- /* @__PURE__ */ jsx49(Text47, { bold: true, color: theme.text.primary, children: "Resume session" }),
29540
- /* @__PURE__ */ jsx49(Text47, { color: theme.ui.comment, dimColor: true, children: "esc" })
31009
+ /* @__PURE__ */ jsxs54(Box50, { justifyContent: "space-between", marginBottom: 1, children: [
31010
+ /* @__PURE__ */ jsx60(Text58, { bold: true, color: theme.text.primary, children: "Resume session" }),
31011
+ /* @__PURE__ */ jsx60(Text58, { color: theme.ui.comment, dimColor: true, children: "esc" })
29541
31012
  ] }),
29542
- /* @__PURE__ */ jsxs44(
29543
- Box39,
31013
+ /* @__PURE__ */ jsxs54(
31014
+ Box50,
29544
31015
  {
29545
31016
  borderStyle: "single",
29546
31017
  borderColor: search ? theme.border.focused : theme.ui.comment,
29547
31018
  paddingX: 1,
29548
31019
  marginBottom: 1,
29549
31020
  children: [
29550
- /* @__PURE__ */ jsx49(Text47, { color: theme.ui.comment, children: "\u2315 " }),
29551
- search ? /* @__PURE__ */ jsxs44(Text47, { color: theme.text.primary, children: [
31021
+ /* @__PURE__ */ jsx60(Text58, { color: theme.ui.comment, children: "\u2315 " }),
31022
+ search ? /* @__PURE__ */ jsxs54(Text58, { color: theme.text.primary, children: [
29552
31023
  search,
29553
- /* @__PURE__ */ jsx49(Text47, { color: theme.text.accent, children: "\u258C" })
29554
- ] }) : /* @__PURE__ */ jsxs44(Text47, { color: theme.ui.comment, dimColor: true, children: [
31024
+ /* @__PURE__ */ jsx60(Text58, { color: theme.text.accent, children: "\u258C" })
31025
+ ] }) : /* @__PURE__ */ jsxs54(Text58, { color: theme.ui.comment, dimColor: true, children: [
29555
31026
  "Search",
29556
- /* @__PURE__ */ jsx49(Text47, { color: theme.text.accent, children: "\u258C" })
31027
+ /* @__PURE__ */ jsx60(Text58, { color: theme.text.accent, children: "\u258C" })
29557
31028
  ] })
29558
31029
  ]
29559
31030
  }
29560
31031
  ),
29561
- loadState === "loading" && /* @__PURE__ */ jsx49(Box39, { marginY: 1, children: /* @__PURE__ */ jsx49(Text47, { color: theme.text.secondary, children: "Loading sessions\u2026" }) }),
29562
- loadState === "error" && /* @__PURE__ */ jsx49(Box39, { marginY: 1, children: /* @__PURE__ */ jsx49(Text47, { color: theme.status.error, children: "\u2717 Could not load sessions" }) }),
29563
- loadState === "ready" && sessions.length === 0 && /* @__PURE__ */ jsx49(Box39, { marginY: 1, children: /* @__PURE__ */ jsx49(Text47, { color: theme.ui.comment, dimColor: true, children: search ? `No sessions match "${search}"` : "No sessions found in .deepcode/sessions/" }) }),
29564
- loadState === "ready" && sessions.length > 0 && /* @__PURE__ */ jsxs44(Box39, { flexDirection: "column", children: [
29565
- canScrollUp && /* @__PURE__ */ jsx49(Text47, { color: theme.ui.comment, dimColor: true, children: " \u2191" }),
31032
+ loadState === "loading" && /* @__PURE__ */ jsx60(Box50, { marginY: 1, children: /* @__PURE__ */ jsx60(Text58, { color: theme.text.secondary, children: "Loading sessions\u2026" }) }),
31033
+ loadState === "error" && /* @__PURE__ */ jsx60(Box50, { marginY: 1, children: /* @__PURE__ */ jsx60(Text58, { color: theme.status.error, children: "\u2717 Could not load sessions" }) }),
31034
+ loadState === "ready" && sessions.length === 0 && /* @__PURE__ */ jsx60(Box50, { marginY: 1, children: /* @__PURE__ */ jsx60(Text58, { color: theme.ui.comment, dimColor: true, children: search ? `No sessions match "${search}"` : "No sessions found in .deepcode/sessions/" }) }),
31035
+ loadState === "ready" && sessions.length > 0 && /* @__PURE__ */ jsxs54(Box50, { flexDirection: "column", children: [
31036
+ canScrollUp && /* @__PURE__ */ jsx60(Text58, { color: theme.ui.comment, dimColor: true, children: " \u2191" }),
29566
31037
  visibleSessions.map((session, visIdx) => {
29567
31038
  const globalIdx = scrollTop + visIdx;
29568
31039
  const isActive = globalIdx === clampedIndex;
29569
31040
  const shortId = session.id.slice(-8);
29570
- const date = new Date(session.updatedAt).toLocaleString();
31041
+ const date = relativeTime(session.updatedAt);
29571
31042
  const target = session.model ? `${session.provider}/${session.model}` : session.provider;
29572
31043
  const msgCount = session.messages.length;
29573
31044
  const preview = sessionLabel2(session);
29574
- return /* @__PURE__ */ jsxs44(Box39, { flexDirection: "column", children: [
29575
- /* @__PURE__ */ jsxs44(Box39, { gap: 1, children: [
29576
- /* @__PURE__ */ jsx49(Text47, { color: isActive ? theme.text.accent : theme.ui.comment, children: isActive ? "\u203A" : " " }),
29577
- /* @__PURE__ */ jsx49(
29578
- Text47,
31045
+ return /* @__PURE__ */ jsxs54(Box50, { flexDirection: "column", children: [
31046
+ /* @__PURE__ */ jsxs54(Box50, { gap: 1, children: [
31047
+ /* @__PURE__ */ jsx60(Text58, { color: isActive ? theme.text.accent : theme.ui.comment, children: isActive ? "\u203A" : " " }),
31048
+ /* @__PURE__ */ jsx60(
31049
+ Text58,
29579
31050
  {
29580
31051
  color: isActive ? theme.text.primary : theme.text.secondary,
29581
31052
  bold: isActive,
@@ -29584,7 +31055,7 @@ var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29584
31055
  }
29585
31056
  )
29586
31057
  ] }),
29587
- isActive && /* @__PURE__ */ jsx49(Box39, { paddingLeft: 2, children: /* @__PURE__ */ jsxs44(Text47, { color: theme.ui.comment, dimColor: true, children: [
31058
+ isActive && /* @__PURE__ */ jsx60(Box50, { paddingLeft: 2, children: /* @__PURE__ */ jsxs54(Text58, { color: theme.ui.comment, dimColor: true, children: [
29588
31059
  shortId,
29589
31060
  " ",
29590
31061
  target,
@@ -29595,16 +31066,16 @@ var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29595
31066
  ] }) })
29596
31067
  ] }, session.id);
29597
31068
  }),
29598
- canScrollDown && /* @__PURE__ */ jsx49(Text47, { color: theme.ui.comment, dimColor: true, children: " \u2193" }),
29599
- /* @__PURE__ */ jsx49(Box39, { marginTop: 1, children: /* @__PURE__ */ jsxs44(Text47, { color: theme.ui.comment, dimColor: true, children: [
31069
+ canScrollDown && /* @__PURE__ */ jsx60(Text58, { color: theme.ui.comment, dimColor: true, children: " \u2193" }),
31070
+ /* @__PURE__ */ jsx60(Box50, { marginTop: 1, children: /* @__PURE__ */ jsxs54(Text58, { color: theme.ui.comment, dimColor: true, children: [
29600
31071
  sessions.length,
29601
31072
  " session",
29602
31073
  sessions.length !== 1 ? "s" : "",
29603
31074
  search ? ` \xB7 "${search}"` : ""
29604
31075
  ] }) })
29605
31076
  ] }),
29606
- /* @__PURE__ */ jsx49(
29607
- Box39,
31077
+ /* @__PURE__ */ jsx60(
31078
+ Box50,
29608
31079
  {
29609
31080
  marginTop: 1,
29610
31081
  borderStyle: "single",
@@ -29613,7 +31084,7 @@ var SessionsDialog = ({ cwd, onSelect, onClose }) => {
29613
31084
  borderLeft: false,
29614
31085
  borderRight: false,
29615
31086
  borderColor: theme.ui.comment,
29616
- children: /* @__PURE__ */ jsx49(Text47, { color: theme.ui.comment, dimColor: true, children: "\u2191\u2193 navigate type to search Enter resume Esc close" })
31087
+ children: /* @__PURE__ */ jsx60(Text58, { color: theme.ui.comment, dimColor: true, children: "\u2191\u2193 navigate type to search Enter resume Esc close" })
29617
31088
  }
29618
31089
  )
29619
31090
  ]
@@ -29634,8 +31105,8 @@ var SubagentsPanel = ({ subagents, mainAreaWidth }) => {
29634
31105
  if (subagents.length === 0) return null;
29635
31106
  const running = subagents.filter((s) => s.status === "running").length;
29636
31107
  const title = running > 0 ? `Subagents (${running} running)` : `Subagents (${subagents.length} finishing\u2026)`;
29637
- return /* @__PURE__ */ jsxs45(
29638
- Box40,
31108
+ return /* @__PURE__ */ jsxs55(
31109
+ Box51,
29639
31110
  {
29640
31111
  flexDirection: "column",
29641
31112
  borderStyle: "round",
@@ -29645,25 +31116,25 @@ var SubagentsPanel = ({ subagents, mainAreaWidth }) => {
29645
31116
  marginTop: 1,
29646
31117
  width: Math.min(mainAreaWidth, 80),
29647
31118
  children: [
29648
- /* @__PURE__ */ jsx50(Box40, { paddingX: 1, children: /* @__PURE__ */ jsx50(Text48, { bold: true, color: theme.text.accent, children: title }) }),
29649
- subagents.map((entry) => /* @__PURE__ */ jsxs45(Box40, { flexDirection: "column", paddingX: 1, children: [
29650
- /* @__PURE__ */ jsxs45(Box40, { flexDirection: "row", gap: 1, children: [
29651
- /* @__PURE__ */ jsx50(Text48, { color: statusColor(entry), children: statusIcon(entry) }),
29652
- /* @__PURE__ */ jsxs45(Text48, { wrap: "truncate", color: theme.text.primary, children: [
31119
+ /* @__PURE__ */ jsx61(Box51, { paddingX: 1, children: /* @__PURE__ */ jsx61(Text59, { bold: true, color: theme.text.accent, children: title }) }),
31120
+ subagents.map((entry) => /* @__PURE__ */ jsxs55(Box51, { flexDirection: "column", paddingX: 1, children: [
31121
+ /* @__PURE__ */ jsxs55(Box51, { flexDirection: "row", gap: 1, children: [
31122
+ /* @__PURE__ */ jsx61(Text59, { color: statusColor(entry), children: statusIcon(entry) }),
31123
+ /* @__PURE__ */ jsxs55(Text59, { wrap: "truncate", color: theme.text.primary, children: [
29653
31124
  entry.prompt,
29654
31125
  entry.prompt.length >= 50 ? "\u2026" : ""
29655
31126
  ] })
29656
31127
  ] }),
29657
- entry.status === "running" && entry.currentTool && /* @__PURE__ */ jsxs45(Text48, { color: theme.text.secondary, dimColor: true, children: [
31128
+ entry.status === "running" && entry.currentTool && /* @__PURE__ */ jsxs55(Text59, { color: theme.text.secondary, dimColor: true, children: [
29658
31129
  " ",
29659
31130
  "using ",
29660
31131
  entry.currentTool
29661
31132
  ] }),
29662
- entry.status === "running" && !entry.currentTool && entry.currentOutput && /* @__PURE__ */ jsxs45(Text48, { color: theme.text.secondary, dimColor: true, wrap: "truncate", children: [
31133
+ entry.status === "running" && !entry.currentTool && entry.currentOutput && /* @__PURE__ */ jsxs55(Text59, { color: theme.text.secondary, dimColor: true, wrap: "truncate", children: [
29663
31134
  " ",
29664
31135
  entry.currentOutput.trimStart()
29665
31136
  ] }),
29666
- entry.status === "failed" && entry.error && /* @__PURE__ */ jsxs45(Text48, { color: theme.status.error, dimColor: true, wrap: "truncate", children: [
31137
+ entry.status === "failed" && entry.error && /* @__PURE__ */ jsxs55(Text59, { color: theme.status.error, dimColor: true, wrap: "truncate", children: [
29667
31138
  " ",
29668
31139
  entry.error.slice(0, 60)
29669
31140
  ] })
@@ -29900,70 +31371,78 @@ function formatModelCatalogSummary2(result) {
29900
31371
  return "model catalog unavailable";
29901
31372
  }
29902
31373
  var APPROVAL_ENTER_ARM_DELAY_MS = 350;
29903
- var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31374
+ var AppContainer = ({ cwd, config, provider, model, resumeSessionId, startupWarnings = [] }) => {
29904
31375
  const historyManager = useHistory();
29905
31376
  const addHistoryItem = historyManager.addItem;
29906
- const [initError, setInitError] = useState30(null);
29907
- const [isInitializing, setIsInitializing] = useState30(true);
29908
- const [isRunning, setIsRunning] = useState30(false);
29909
- const [pendingAssistantText, setPendingAssistantText] = useState30("");
29910
- const [approvalQueue, setApprovalQueue] = useState30([]);
29911
- const [providerLabel, setProviderLabel] = useState30("(unconfigured)");
29912
- const [targetSource, setTargetSource] = useState30("config");
29913
- const [currentModel, setCurrentModel] = useState30("(unconfigured)");
29914
- const [agentMode, setAgentMode] = useState30("build");
29915
- const [streamingState, setStreamingState] = useState30(
31377
+ const [initError, setInitError] = useState34(null);
31378
+ const [isInitializing, setIsInitializing] = useState34(true);
31379
+ const [isRunning, setIsRunning] = useState34(false);
31380
+ const [pendingAssistantText, setPendingAssistantText] = useState34("");
31381
+ const [approvalQueue, setApprovalQueue] = useState34([]);
31382
+ const [providerLabel, setProviderLabel] = useState34("(unconfigured)");
31383
+ const [targetSource, setTargetSource] = useState34("config");
31384
+ const [currentModel, setCurrentModel] = useState34("(unconfigured)");
31385
+ const [agentMode, setAgentMode] = useState34("build");
31386
+ const [streamingState, setStreamingState] = useState34(
29916
31387
  "idle"
29917
31388
  /* Idle */
29918
31389
  );
29919
- const [compactMode, setCompactMode] = useState30(true);
29920
- const [shellModeActive, setShellModeActive] = useState30(false);
29921
- const [showEscapePrompt, setShowEscapePrompt] = useState30(false);
29922
- const [messageQueue, setMessageQueue] = useState30([]);
29923
- const [historyRemountKey, setHistoryRemountKey] = useState30(0);
29924
- const [pendingItem, setPendingItem] = useState30(null);
29925
- const [lastPromptTokenCount, setLastPromptTokenCount] = useState30(0);
29926
- const [lastOutputTokenCount, setLastOutputTokenCount] = useState30(0);
29927
- const [elapsedTime, setElapsedTime] = useState30(0);
29928
- const [isReceivingContent, setIsReceivingContent] = useState30(false);
29929
- const [iterationInfo, setIterationInfo] = useState30(null);
29930
- const [liveToolCalls, setLiveToolCalls] = useState30([]);
29931
- const [recentSlashCommandsState, setRecentSlashCommandsState] = useState30(/* @__PURE__ */ new Map());
29932
- const [activeDialog, setActiveDialog] = useState30(null);
29933
- const [themeName, setThemeName] = useState30("(unknown)");
29934
- const [permissionSummary, setPermissionSummary] = useState30("(unknown)");
29935
- const [authSummary, setAuthSummary] = useState30("(unknown)");
29936
- const [permissionModes, setPermissionModes] = useState30({
31390
+ const [compactMode, setCompactMode] = useState34(true);
31391
+ const [constrainHeight, setConstrainHeight] = useState34(true);
31392
+ const [shellModeActive, setShellModeActive] = useState34(false);
31393
+ const [showEscapePrompt, setShowEscapePrompt] = useState34(false);
31394
+ const [messageQueue, setMessageQueue] = useState34([]);
31395
+ const [historyRemountKey, setHistoryRemountKey] = useState34(0);
31396
+ const [pendingItem, setPendingItem] = useState34(null);
31397
+ const [lastPromptTokenCount, setLastPromptTokenCount] = useState34(0);
31398
+ const [lastOutputTokenCount, setLastOutputTokenCount] = useState34(0);
31399
+ const [totalPromptTokenCount, setTotalPromptTokenCount] = useState34(0);
31400
+ const [totalOutputTokenCount, setTotalOutputTokenCount] = useState34(0);
31401
+ const [isReceivingContent, setIsReceivingContent] = useState34(false);
31402
+ const [iterationInfo, setIterationInfo] = useState34(null);
31403
+ const [liveToolCalls, setLiveToolCalls] = useState34([]);
31404
+ const [recentSlashCommandsState, setRecentSlashCommandsState] = useState34(/* @__PURE__ */ new Map());
31405
+ const [activeDialog, setActiveDialog] = useState34(null);
31406
+ const [themeName, setThemeName] = useState34("(unknown)");
31407
+ const [permissionSummary, setPermissionSummary] = useState34("(unknown)");
31408
+ const [authSummary, setAuthSummary] = useState34("(unknown)");
31409
+ const [permissionModes, setPermissionModes] = useState34({
29937
31410
  read: "allow",
29938
31411
  write: "ask",
29939
31412
  gitLocal: "allow",
29940
31413
  shell: "ask",
29941
31414
  dangerous: "ask"
29942
31415
  });
29943
- const [providerConfigVersion, setProviderConfigVersion] = useState30(0);
29944
- const [, setThemeVersion] = useState30(0);
29945
- const [mcpConnected, setMcpConnected] = useState30(0);
29946
- const [mcpTotal, setMcpTotal] = useState30(0);
29947
- const [subagentMap, setSubagentMap] = useState30(/* @__PURE__ */ new Map());
29948
- const [, setDrainTick] = useState30(0);
29949
- const [pendingCommandConfirmation, setPendingCommandConfirmation] = useState30(null);
29950
- const runtimeRef = useRef18(null);
29951
- const sessionRef = useRef18(null);
29952
- const configAdapterRef = useRef18(null);
29953
- const abortRef = useRef18(null);
29954
- const unsubscribeRef = useRef18([]);
29955
- const lastSubmittedPromptRef = useRef18(null);
29956
- const runStartedAtRef = useRef18(null);
29957
- const streamingResponseLengthRef = useRef18(0);
29958
- const pendingTextBufferRef = useRef18("");
29959
- const liveToolCallsBufferRef = useRef18([]);
29960
- const subagentChunkBufferRef = useRef18(/* @__PURE__ */ new Map());
29961
- const subagentToolBufferRef = useRef18([]);
29962
- const drainingQueueRef = useRef18(false);
29963
- const messageQueueRef = useRef18([]);
29964
- const sessionShellAllowlistRef = useRef18(/* @__PURE__ */ new Set());
29965
- const mainControlsRef = useRef18(null);
29966
- const approvalPromptVisibleAtRef = useRef18(null);
31416
+ const [sessionDisplayName, setSessionDisplayName] = useState34("");
31417
+ const [providerConfigVersion, setProviderConfigVersion] = useState34(0);
31418
+ const [, setThemeVersion] = useState34(0);
31419
+ const [mcpConnected, setMcpConnected] = useState34(0);
31420
+ const [mcpTotal, setMcpTotal] = useState34(0);
31421
+ const [subagentMap, setSubagentMap] = useState34(/* @__PURE__ */ new Map());
31422
+ const [, setDrainTick] = useState34(0);
31423
+ const [pendingCommandConfirmation, setPendingCommandConfirmation] = useState34(null);
31424
+ const appContextValue = useMemo19(
31425
+ () => ({ version: VERSION, startupWarnings }),
31426
+ [startupWarnings]
31427
+ );
31428
+ const sessionStartedAtRef = useRef21(Date.now());
31429
+ const runtimeRef = useRef21(null);
31430
+ const sessionRef = useRef21(null);
31431
+ const configAdapterRef = useRef21(null);
31432
+ const abortRef = useRef21(null);
31433
+ const unsubscribeRef = useRef21([]);
31434
+ const lastSubmittedPromptRef = useRef21(null);
31435
+ const runStartedAtRef = useRef21(null);
31436
+ const streamingResponseLengthRef = useRef21(0);
31437
+ const pendingTextBufferRef = useRef21("");
31438
+ const liveToolCallsBufferRef = useRef21([]);
31439
+ const subagentChunkBufferRef = useRef21(/* @__PURE__ */ new Map());
31440
+ const subagentToolBufferRef = useRef21([]);
31441
+ const drainingQueueRef = useRef21(false);
31442
+ const messageQueueRef = useRef21([]);
31443
+ const sessionShellAllowlistRef = useRef21(/* @__PURE__ */ new Set());
31444
+ const mainControlsRef = useRef21(null);
31445
+ const approvalPromptVisibleAtRef = useRef21(null);
29967
31446
  const { stdin, setRawMode } = useStdin3();
29968
31447
  const { columns: terminalWidth, rows: terminalHeight } = useTerminalSize();
29969
31448
  const mainAreaWidth = Math.min(Math.max(terminalWidth - 4, 20), 120);
@@ -29984,14 +31463,14 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
29984
31463
  []
29985
31464
  );
29986
31465
  const configAdapter = configAdapterRef.current ?? new DeepCodeConfigAdapter(cwd);
29987
- const isValidPath = useCallback27(
31466
+ const isValidPath = useCallback28(
29988
31467
  (candidate) => {
29989
- const resolved = path15.resolve(cwd, candidate);
29990
- const relative2 = path15.relative(cwd, resolved);
29991
- if (relative2.startsWith("..") || path15.isAbsolute(relative2)) {
31468
+ const resolved = path19.resolve(cwd, candidate);
31469
+ const relative2 = path19.relative(cwd, resolved);
31470
+ if (relative2.startsWith("..") || path19.isAbsolute(relative2)) {
29992
31471
  return false;
29993
31472
  }
29994
- return fs8.existsSync(resolved);
31473
+ return fs12.existsSync(resolved);
29995
31474
  },
29996
31475
  [cwd]
29997
31476
  );
@@ -30010,6 +31489,14 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30010
31489
  () => historyManager.history.filter((item) => item.type === "user").map((item) => item.text),
30011
31490
  [historyManager.history]
30012
31491
  );
31492
+ const approvalMode = useMemo19(() => {
31493
+ const vals = Object.values(permissionModes);
31494
+ if (vals.every((m) => m === "allow")) return "yolo";
31495
+ if (permissionModes.write === "allow" && permissionModes.read === "allow" && permissionModes.gitLocal === "allow") {
31496
+ return "auto-edit";
31497
+ }
31498
+ return "default";
31499
+ }, [permissionModes]);
30013
31500
  const slashCommands = useMemo19(
30014
31501
  () => [
30015
31502
  helpCommand,
@@ -30017,6 +31504,14 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30017
31504
  undoCommand,
30018
31505
  compactCommand,
30019
31506
  diffCommand,
31507
+ exportCommand,
31508
+ contextCommand,
31509
+ doctorCommand2,
31510
+ historyCommand,
31511
+ statsCommand,
31512
+ memoryCommand,
31513
+ yoloCommand,
31514
+ safeCommand,
30020
31515
  providerCommand,
30021
31516
  modelCommand,
30022
31517
  modeCommand,
@@ -30035,9 +31530,9 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30035
31530
  () => recentSlashCommandsState,
30036
31531
  [recentSlashCommandsState]
30037
31532
  );
30038
- const [promptSuggestion, setPromptSuggestion] = useState30(null);
30039
- const dismissPromptSuggestion = useCallback27(() => setPromptSuggestion(null), []);
30040
- const registerSlashCommandUsage = useCallback27((name) => {
31533
+ const [promptSuggestion, setPromptSuggestion] = useState34(null);
31534
+ const dismissPromptSuggestion = useCallback28(() => setPromptSuggestion(null), []);
31535
+ const registerSlashCommandUsage = useCallback28((name) => {
30041
31536
  setRecentSlashCommandsState((prev) => {
30042
31537
  const next = new Map(prev);
30043
31538
  const existing = next.get(name);
@@ -30049,8 +31544,8 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30049
31544
  return next;
30050
31545
  });
30051
31546
  }, []);
30052
- const listAvailableProviders = useCallback27(() => PROVIDER_IDS, []);
30053
- const getSessionCommandState = useCallback27(() => {
31547
+ const listAvailableProviders = useCallback28(() => PROVIDER_IDS, []);
31548
+ const getSessionCommandState = useCallback28(() => {
30054
31549
  const runtime = runtimeRef.current;
30055
31550
  const session = sessionRef.current;
30056
31551
  const fallbackProvider = runtime?.config.defaultProvider ?? PROVIDER_IDS[0];
@@ -30062,7 +31557,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30062
31557
  mode: agentMode
30063
31558
  };
30064
31559
  }, [agentMode]);
30065
- const setSessionProvider = useCallback27((provider2) => {
31560
+ const setSessionProvider = useCallback28((provider2) => {
30066
31561
  const runtime = runtimeRef.current;
30067
31562
  const session = sessionRef.current;
30068
31563
  if (!runtime || !session) return;
@@ -30084,7 +31579,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30084
31579
  );
30085
31580
  }
30086
31581
  }, [cwd, historyManager]);
30087
- const setSessionModel = useCallback27((model2) => {
31582
+ const setSessionModel = useCallback28((model2) => {
30088
31583
  const runtime = runtimeRef.current;
30089
31584
  const session = sessionRef.current;
30090
31585
  if (!runtime || !session) return;
@@ -30097,7 +31592,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30097
31592
  setCurrentModel(session.model ?? "(unconfigured)");
30098
31593
  setProviderLabel(formatProviderLabel(session.provider, session.model));
30099
31594
  }, [cwd]);
30100
- const setSessionMode = useCallback27((mode) => {
31595
+ const setSessionMode = useCallback28((mode) => {
30101
31596
  setAgentMode(mode);
30102
31597
  const runtime = runtimeRef.current;
30103
31598
  const session = sessionRef.current;
@@ -30108,7 +31603,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30108
31603
  });
30109
31604
  }
30110
31605
  }, []);
30111
- const setSessionName = useCallback27((name) => {
31606
+ const setSessionName = useCallback28((name) => {
30112
31607
  const runtime = runtimeRef.current;
30113
31608
  const session = sessionRef.current;
30114
31609
  if (!runtime || !session) return;
@@ -30135,13 +31630,13 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30135
31630
  setSessionProvider
30136
31631
  ]
30137
31632
  );
30138
- const handleUndo = useCallback27(async () => {
31633
+ const handleUndo = useCallback28(async () => {
30139
31634
  const runtime = runtimeRef.current;
30140
31635
  const session = sessionRef.current;
30141
31636
  if (!runtime || !session) return null;
30142
31637
  return runtime.agent.undo(session.id);
30143
31638
  }, []);
30144
- const handleCompact = useCallback27(async () => {
31639
+ const handleCompact = useCallback28(async () => {
30145
31640
  const runtime = runtimeRef.current;
30146
31641
  const session = sessionRef.current;
30147
31642
  if (!runtime || !session) return;
@@ -30190,18 +31685,39 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30190
31685
  reloadCommands: () => {
30191
31686
  },
30192
31687
  undo: handleUndo,
30193
- compact: handleCompact
31688
+ compact: handleCompact,
31689
+ getMessages: () => sessionRef.current?.messages ?? [],
31690
+ getCwd: () => cwd,
31691
+ getRuntimeDiagnostics: () => {
31692
+ const runtime = runtimeRef.current;
31693
+ const session = sessionRef.current;
31694
+ if (!runtime || !session) return null;
31695
+ return {
31696
+ provider: session.provider,
31697
+ model: session.model,
31698
+ hasApiKey: Boolean(runtime.config.providers[session.provider]?.apiKey?.trim()),
31699
+ mcpConnected,
31700
+ mcpTotal,
31701
+ agentMode
31702
+ };
31703
+ },
31704
+ getTokenStats: () => ({
31705
+ lastPromptTokens: lastPromptTokenCount,
31706
+ lastOutputTokens: lastOutputTokenCount,
31707
+ sessionStartedAt: sessionStartedAtRef.current
31708
+ }),
31709
+ setPermissions: (modes) => setPermissionModes((prev) => ({ ...prev, ...modes }))
30194
31710
  },
30195
31711
  session: {
30196
31712
  sessionShellAllowlist: sessionShellAllowlistRef.current
30197
31713
  }
30198
31714
  }),
30199
- [configAdapter, handleCompact, handleUndo, historyManager, pendingItem, sessionCommandServices]
31715
+ [agentMode, configAdapter, cwd, handleCompact, handleUndo, historyManager, lastOutputTokenCount, lastPromptTokenCount, mcpConnected, mcpTotal, pendingItem, sessionCommandServices, setPermissionModes]
30200
31716
  );
30201
- useEffect28(() => {
31717
+ useEffect32(() => {
30202
31718
  messageQueueRef.current = messageQueue;
30203
31719
  }, [messageQueue]);
30204
- useEffect28(() => {
31720
+ useEffect32(() => {
30205
31721
  if (approvalQueue.length > 0) {
30206
31722
  approvalPromptVisibleAtRef.current ??= Date.now();
30207
31723
  setStreamingState(
@@ -30223,23 +31739,24 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30223
31739
  /* Idle */
30224
31740
  );
30225
31741
  }, [approvalQueue.length, isRunning]);
30226
- useEffect28(() => {
31742
+ useEffect32(() => {
30227
31743
  if (!isRunning) {
30228
31744
  runStartedAtRef.current = null;
30229
- setElapsedTime(0);
30230
31745
  setIsReceivingContent(false);
30231
- return;
31746
+ } else {
31747
+ runStartedAtRef.current = Date.now();
30232
31748
  }
30233
- runStartedAtRef.current = Date.now();
30234
- setElapsedTime(0);
30235
- const interval = setInterval(() => {
30236
- if (!runStartedAtRef.current) return;
30237
- const seconds = Math.floor((Date.now() - runStartedAtRef.current) / 1e3);
30238
- setElapsedTime(seconds);
30239
- }, 250);
30240
- return () => clearInterval(interval);
30241
31749
  }, [isRunning]);
30242
- useEffect28(() => {
31750
+ const { elapsedTime, currentLoadingPhrase: hookPhrase } = useLoadingIndicator(streamingState);
31751
+ const stickyTodos = useMemo19(
31752
+ () => getStickyTodos(historyManager.history, pendingGeminiHistoryItems),
31753
+ [historyManager.history, pendingGeminiHistoryItems]
31754
+ );
31755
+ const stickyTodoMaxItems = useMemo19(
31756
+ () => getStickyTodoMaxVisibleItems(terminalHeight),
31757
+ [terminalHeight]
31758
+ );
31759
+ useEffect32(() => {
30243
31760
  const id = setInterval(() => {
30244
31761
  const text = pendingTextBufferRef.current;
30245
31762
  if (text) {
@@ -30272,7 +31789,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30272
31789
  }, 50);
30273
31790
  return () => clearInterval(id);
30274
31791
  }, []);
30275
- useEffect28(() => {
31792
+ useEffect32(() => {
30276
31793
  let mounted = true;
30277
31794
  const initialize = async () => {
30278
31795
  try {
@@ -30436,6 +31953,9 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30436
31953
  })
30437
31954
  );
30438
31955
  unsubscribeRef.current = unsubscribers;
31956
+ if (typeof session.metadata["name"] === "string" && session.metadata["name"]) {
31957
+ setSessionDisplayName(session.metadata["name"]);
31958
+ }
30439
31959
  if (resumed) {
30440
31960
  restoreHistoryFromSession(session, (item) => addHistoryItem(item, Date.now()));
30441
31961
  addHistoryItem(
@@ -30492,7 +32012,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30492
32012
  unsubscribeRef.current = [];
30493
32013
  };
30494
32014
  }, [addHistoryItem, config, cwd, model, provider, resumeSessionId]);
30495
- const resolveApproval = useCallback27(
32015
+ const resolveApproval = useCallback28(
30496
32016
  (decision) => {
30497
32017
  const runtime = runtimeRef.current;
30498
32018
  const current = approvalQueue[0];
@@ -30505,7 +32025,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30505
32025
  },
30506
32026
  [approvalQueue]
30507
32027
  );
30508
- const appendTurnItems = useCallback27(
32028
+ const appendTurnItems = useCallback28(
30509
32029
  (items) => {
30510
32030
  const base = Date.now();
30511
32031
  for (const item of items) {
@@ -30514,7 +32034,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30514
32034
  },
30515
32035
  [historyManager]
30516
32036
  );
30517
- const runPrompt = useCallback27(
32037
+ const runPrompt = useCallback28(
30518
32038
  async (rawPrompt) => {
30519
32039
  const runtime = runtimeRef.current;
30520
32040
  const session = sessionRef.current;
@@ -30551,6 +32071,8 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30551
32071
  onUsage: (inputTokens, outputTokens) => {
30552
32072
  setLastPromptTokenCount(inputTokens);
30553
32073
  setLastOutputTokenCount(outputTokens);
32074
+ setTotalPromptTokenCount((prev) => prev + inputTokens);
32075
+ setTotalOutputTokenCount((prev) => prev + outputTokens);
30554
32076
  },
30555
32077
  onIteration: (round, max) => {
30556
32078
  setIterationInfo({ round, max });
@@ -30580,6 +32102,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30580
32102
  rt.sessions.save(sess);
30581
32103
  rt.sessions.persist(sess.id).catch(() => {
30582
32104
  });
32105
+ setSessionDisplayName(name);
30583
32106
  }
30584
32107
  }).catch(() => {
30585
32108
  });
@@ -30616,7 +32139,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30616
32139
  },
30617
32140
  [agentMode, appendTurnItems, historyManager]
30618
32141
  );
30619
- const executeClientToolCommand = useCallback27(
32142
+ const executeClientToolCommand = useCallback28(
30620
32143
  async (toolName, toolArgs) => {
30621
32144
  const runtime = runtimeRef.current;
30622
32145
  const session = sessionRef.current;
@@ -30711,7 +32234,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30711
32234
  },
30712
32235
  [agentMode, historyManager]
30713
32236
  );
30714
- const applySlashCommandResult = useCallback27(
32237
+ const applySlashCommandResult = useCallback28(
30715
32238
  async (result, _rawInvocation) => {
30716
32239
  if (!result) return;
30717
32240
  switch (result.type) {
@@ -30772,7 +32295,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30772
32295
  },
30773
32296
  [appendTurnItems, executeClientToolCommand, historyManager, runPrompt]
30774
32297
  );
30775
- const executeSlashCommand = useCallback27(
32298
+ const executeSlashCommand = useCallback28(
30776
32299
  async (rawInput, overwriteConfirmed = false) => {
30777
32300
  const trimmed = rawInput.trim();
30778
32301
  if (!trimmed.startsWith("/")) return false;
@@ -30845,7 +32368,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30845
32368
  slashCommands
30846
32369
  ]
30847
32370
  );
30848
- const executeSubmission = useCallback27(
32371
+ const executeSubmission = useCallback28(
30849
32372
  async (value) => {
30850
32373
  const trimmed = value.trim();
30851
32374
  if (!trimmed) return;
@@ -30855,7 +32378,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30855
32378
  },
30856
32379
  [executeSlashCommand, runPrompt]
30857
32380
  );
30858
- const handleFinalSubmit = useCallback27(
32381
+ const handleFinalSubmit = useCallback28(
30859
32382
  (value) => {
30860
32383
  const prompt = value.trim();
30861
32384
  if (!prompt) return;
@@ -30881,7 +32404,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30881
32404
  isRunning
30882
32405
  ]
30883
32406
  );
30884
- const handleRetryLastPrompt = useCallback27(() => {
32407
+ const handleRetryLastPrompt = useCallback28(() => {
30885
32408
  const lastPrompt = lastSubmittedPromptRef.current;
30886
32409
  if (!lastPrompt) {
30887
32410
  historyManager.addItem(
@@ -30896,7 +32419,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30896
32419
  }
30897
32420
  void runPrompt(lastPrompt);
30898
32421
  }, [approvalQueue.length, historyManager, isInitializing, isRunning, runPrompt]);
30899
- const resolveCommandConfirmation = useCallback27(
32422
+ const resolveCommandConfirmation = useCallback28(
30900
32423
  (confirmed) => {
30901
32424
  const pending = pendingCommandConfirmation;
30902
32425
  if (!pending) return;
@@ -30927,7 +32450,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30927
32450
  pendingCommandConfirmation
30928
32451
  ]
30929
32452
  );
30930
- const persistConfig = useCallback27(
32453
+ const persistConfig = useCallback28(
30931
32454
  async (mutate) => {
30932
32455
  const loader = new ConfigLoader();
30933
32456
  const options = { cwd, configPath: config };
@@ -30936,7 +32459,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30936
32459
  },
30937
32460
  [config, cwd]
30938
32461
  );
30939
- const handleSelectTheme = useCallback27(
32462
+ const handleSelectTheme = useCallback28(
30940
32463
  (nextThemeName) => {
30941
32464
  themeManager.setActiveTheme(nextThemeName);
30942
32465
  setThemeName(themeManager.getActiveTheme().name);
@@ -30957,7 +32480,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30957
32480
  },
30958
32481
  [cwd, historyManager]
30959
32482
  );
30960
- const handleSavePermissions = useCallback27(
32483
+ const handleSavePermissions = useCallback28(
30961
32484
  (modes) => {
30962
32485
  setPermissionModes(modes);
30963
32486
  setPermissionSummary(formatPermissionSummary(modes));
@@ -30986,7 +32509,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30986
32509
  },
30987
32510
  [historyManager, persistConfig]
30988
32511
  );
30989
- const handlePersistToken = useCallback27(
32512
+ const handlePersistToken = useCallback28(
30990
32513
  async (token) => {
30991
32514
  await persistConfig((cfg) => ({
30992
32515
  ...cfg,
@@ -31000,12 +32523,12 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31000
32523
  },
31001
32524
  [persistConfig]
31002
32525
  );
31003
- const providerHasApiKey = useCallback27((provider2) => {
32526
+ const providerHasApiKey = useCallback28((provider2) => {
31004
32527
  const runtime = runtimeRef.current;
31005
32528
  void providerConfigVersion;
31006
32529
  return Boolean(runtime?.config.providers[provider2]?.apiKey?.trim());
31007
32530
  }, [providerConfigVersion]);
31008
- const getProviderKeyHint = useCallback27((provider2) => {
32531
+ const getProviderKeyHint = useCallback28((provider2) => {
31009
32532
  const runtime = runtimeRef.current;
31010
32533
  void providerConfigVersion;
31011
32534
  const key = runtime?.config.providers[provider2]?.apiKey?.trim();
@@ -31013,7 +32536,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31013
32536
  if (key.length <= 8) return "\u25CF".repeat(key.length);
31014
32537
  return `${key.slice(0, 6)}\u25CF\u25CF\u25CF\u25CF${key.slice(-4)}`;
31015
32538
  }, [providerConfigVersion]);
31016
- const handleSaveProviderApiKey = useCallback27(
32539
+ const handleSaveProviderApiKey = useCallback28(
31017
32540
  async (provider2, apiKey) => {
31018
32541
  await persistConfig((cfg) => ({
31019
32542
  ...cfg,
@@ -31038,7 +32561,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31038
32561
  },
31039
32562
  [historyManager, persistConfig]
31040
32563
  );
31041
- const handleSetDefaultProvider = useCallback27(
32564
+ const handleSetDefaultProvider = useCallback28(
31042
32565
  async (provider2) => {
31043
32566
  const runtime = runtimeRef.current;
31044
32567
  const session = sessionRef.current;
@@ -31082,7 +32605,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31082
32605
  },
31083
32606
  [cwd, historyManager, persistConfig]
31084
32607
  );
31085
- const handleTestProvider = useCallback27(
32608
+ const handleTestProvider = useCallback28(
31086
32609
  async (provider2) => {
31087
32610
  const runtime = runtimeRef.current;
31088
32611
  const session = sessionRef.current;
@@ -31130,7 +32653,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31130
32653
  },
31131
32654
  []
31132
32655
  );
31133
- const handleFetchModels = useCallback27(
32656
+ const handleFetchModels = useCallback28(
31134
32657
  async (provider2, signal) => {
31135
32658
  const runtime = runtimeRef.current;
31136
32659
  if (!runtime) throw new Error("Runtime not ready.");
@@ -31138,14 +32661,14 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31138
32661
  },
31139
32662
  []
31140
32663
  );
31141
- const handleSelectModel = useCallback27(
32664
+ const handleSelectModel = useCallback28(
31142
32665
  (modelId) => {
31143
32666
  setSessionModel(modelId);
31144
32667
  setActiveDialog(null);
31145
32668
  },
31146
32669
  [setSessionModel]
31147
32670
  );
31148
- const handleSelectSession = useCallback27(
32671
+ const handleSelectSession = useCallback28(
31149
32672
  async (sessionId) => {
31150
32673
  const runtime = runtimeRef.current;
31151
32674
  if (!runtime) return;
@@ -31163,6 +32686,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31163
32686
  setCurrentModel(existing.model ?? "(unconfigured)");
31164
32687
  setProviderLabel(formatProviderLabel(existing.provider, existing.model));
31165
32688
  setTargetSource("session");
32689
+ setSessionDisplayName(typeof existing.metadata["name"] === "string" ? existing.metadata["name"] : "");
31166
32690
  historyManager.clearItems();
31167
32691
  setHistoryRemountKey((k) => k + 1);
31168
32692
  restoreHistoryFromSession(existing, (item) => historyManager.addItem(item, Date.now()));
@@ -31174,9 +32698,9 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31174
32698
  },
31175
32699
  [historyManager]
31176
32700
  );
31177
- const closeDialog = useCallback27(() => setActiveDialog(null), []);
31178
- const previewTheme = useCallback27(() => setThemeVersion((version) => version + 1), []);
31179
- useEffect28(() => {
32701
+ const closeDialog = useCallback28(() => setActiveDialog(null), []);
32702
+ const previewTheme = useCallback28(() => setThemeVersion((version) => version + 1), []);
32703
+ useEffect32(() => {
31180
32704
  if (drainingQueueRef.current || isRunning || isInitializing || Boolean(initError) || approvalQueue.length > 0 || messageQueue.length === 0) {
31181
32705
  return;
31182
32706
  }
@@ -31228,6 +32752,13 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31228
32752
  setCompactMode((prev) => !prev);
31229
32753
  return;
31230
32754
  }
32755
+ if (key.ctrl && input === "s") {
32756
+ setConstrainHeight(false);
32757
+ return;
32758
+ }
32759
+ if (!constrainHeight) {
32760
+ setConstrainHeight(true);
32761
+ }
31231
32762
  if (approvalQueue.length > 0) {
31232
32763
  const pressed = input.toLowerCase();
31233
32764
  const enterArmed = approvalPromptVisibleAtRef.current !== null && Date.now() - approvalPromptVisibleAtRef.current >= APPROVAL_ENTER_ARM_DELAY_MS;
@@ -31291,7 +32822,8 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31291
32822
  themeName,
31292
32823
  permissionSummary,
31293
32824
  authSummary,
31294
- commandNames: slashCommands.map((command) => `/${command.name}`)
32825
+ commandNames: slashCommands.map((command) => `/${command.name}`),
32826
+ commands: slashCommands.map((command) => ({ name: command.name, description: command.description }))
31295
32827
  }),
31296
32828
  [
31297
32829
  activeDialog,
@@ -31318,7 +32850,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31318
32850
  quittingMessages: null,
31319
32851
  streamingState,
31320
32852
  thought: null,
31321
- currentLoadingPhrase: iterationInfo ? `Iteration ${iterationInfo.round}/${iterationInfo.max}` : "",
32853
+ currentLoadingPhrase: iterationInfo ? `Iteration ${iterationInfo.round}/${iterationInfo.max}` : hookPhrase,
31322
32854
  elapsedTime,
31323
32855
  streamingResponseLengthRef,
31324
32856
  isReceivingContent,
@@ -31346,13 +32878,15 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31346
32878
  availableTerminalHeight: void 0,
31347
32879
  staticAreaMaxItemHeight: 200,
31348
32880
  mainControlsRef,
31349
- constrainHeight: false,
32881
+ constrainHeight,
31350
32882
  currentModel,
31351
- sessionName: path15.basename(cwd),
32883
+ sessionName: sessionDisplayName || path19.basename(cwd),
31352
32884
  isConfigInitialized: !isInitializing && !initError,
31353
32885
  sessionStats: {
31354
32886
  lastPromptTokenCount,
31355
- lastOutputTokenCount
32887
+ lastOutputTokenCount,
32888
+ totalPromptTokenCount,
32889
+ totalOutputTokenCount
31356
32890
  },
31357
32891
  dialogsVisible: activeDialog !== null || pendingCommandConfirmation !== null,
31358
32892
  isHelpDialogOpen: activeDialog === "help",
@@ -31362,23 +32896,26 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31362
32896
  isProviderDialogOpen: activeDialog === "provider",
31363
32897
  isPermissionsDialogOpen: activeDialog === "permissions",
31364
32898
  isFeedbackDialogOpen: false,
31365
- showAutoAcceptIndicator: "default",
32899
+ showAutoAcceptIndicator: approvalMode,
31366
32900
  mcpConnected,
31367
32901
  mcpTotal,
31368
32902
  activeSubagents
31369
32903
  }),
31370
32904
  [
32905
+ approvalMode,
31371
32906
  approvalQueue.length,
31372
32907
  subagentMap,
31373
32908
  activeDialog,
31374
32909
  buffer,
31375
32910
  commandContext,
31376
32911
  compactMode,
32912
+ constrainHeight,
31377
32913
  currentModel,
31378
32914
  cwd,
31379
32915
  dismissPromptSuggestion,
31380
32916
  promptSuggestion,
31381
32917
  elapsedTime,
32918
+ sessionDisplayName,
31382
32919
  historyManager,
31383
32920
  historyRemountKey,
31384
32921
  initError,
@@ -31387,6 +32924,8 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31387
32924
  iterationInfo,
31388
32925
  lastOutputTokenCount,
31389
32926
  lastPromptTokenCount,
32927
+ totalOutputTokenCount,
32928
+ totalPromptTokenCount,
31390
32929
  mainAreaWidth,
31391
32930
  mcpConnected,
31392
32931
  mcpTotal,
@@ -31405,62 +32944,38 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31405
32944
  userMessages
31406
32945
  ]
31407
32946
  );
31408
- return /* @__PURE__ */ jsx51(CompactModeProvider, { value: { compactMode }, children: /* @__PURE__ */ jsx51(ConfigContext.Provider, { value: configAdapter, children: /* @__PURE__ */ jsx51(SettingsContext.Provider, { value: loadedSettings, children: /* @__PURE__ */ jsx51(StreamingContext.Provider, { value: streamingState, children: /* @__PURE__ */ jsx51(VimModeProvider, { initialVimEnabled: loadedSettings.merged.general?.vimMode ?? false, children: /* @__PURE__ */ jsx51(KeypressProvider, { kittyProtocolEnabled: false, config: configAdapter, children: /* @__PURE__ */ jsx51(ShellFocusContext.Provider, { value: true, children: /* @__PURE__ */ jsx51(AgentViewProvider, { children: /* @__PURE__ */ jsx51(BackgroundTaskViewProvider, { children: /* @__PURE__ */ jsx51(UIStateContext.Provider, { value: uiState, children: /* @__PURE__ */ jsx51(UIActionsContext.Provider, { value: uiActions, children: /* @__PURE__ */ jsxs46(Box41, { flexDirection: "column", flexGrow: 1, children: [
31409
- /* @__PURE__ */ jsxs46(Box41, { marginLeft: 2, marginRight: 2, marginTop: 1, marginBottom: 1, children: [
31410
- /* @__PURE__ */ jsx51(Text49, { bold: true, color: theme.text.accent, children: "DeepCode" }),
31411
- /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, children: " Target: " }),
31412
- /* @__PURE__ */ jsx51(Text49, { color: theme.text.primary, children: providerLabel }),
31413
- /* @__PURE__ */ jsxs46(Text49, { color: theme.text.secondary, children: [
31414
- " (",
31415
- targetSource,
31416
- ")"
31417
- ] }),
31418
- /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, children: " Mode: " }),
31419
- /* @__PURE__ */ jsx51(
31420
- Text49,
32947
+ return /* @__PURE__ */ jsx62(AppContext.Provider, { value: appContextValue, children: /* @__PURE__ */ jsx62(CompactModeProvider, { value: { compactMode }, children: /* @__PURE__ */ jsx62(ConfigContext.Provider, { value: configAdapter, children: /* @__PURE__ */ jsx62(SettingsContext.Provider, { value: loadedSettings, children: /* @__PURE__ */ jsx62(StreamingContext.Provider, { value: streamingState, children: /* @__PURE__ */ jsx62(VimModeProvider, { initialVimEnabled: loadedSettings.merged.general?.vimMode ?? false, children: /* @__PURE__ */ jsx62(KeypressProvider, { kittyProtocolEnabled: false, config: configAdapter, children: /* @__PURE__ */ jsx62(ShellFocusContext.Provider, { value: true, children: /* @__PURE__ */ jsx62(AgentViewProvider, { children: /* @__PURE__ */ jsx62(BackgroundTaskViewProvider, { children: /* @__PURE__ */ jsx62(UIStateContext.Provider, { value: uiState, children: /* @__PURE__ */ jsx62(UIActionsContext.Provider, { value: uiActions, children: /* @__PURE__ */ jsxs56(Box52, { flexDirection: "column", flexGrow: 1, children: [
32948
+ /* @__PURE__ */ jsx62(
32949
+ AppHeader,
32950
+ {
32951
+ version: VERSION,
32952
+ cwd,
32953
+ providerLabel,
32954
+ mode: agentMode,
32955
+ iterationInfo
32956
+ }
32957
+ ),
32958
+ initError ? /* @__PURE__ */ jsx62(Box52, { marginLeft: 2, marginRight: 2, children: /* @__PURE__ */ jsxs56(Text60, { color: theme.status.error, children: [
32959
+ "Failed to initialize runtime: ",
32960
+ initError
32961
+ ] }) }) : /* @__PURE__ */ jsxs56(Box52, { flexDirection: "column", flexGrow: 1, children: [
32962
+ /* @__PURE__ */ jsx62(
32963
+ MainContent,
31421
32964
  {
31422
- bold: true,
31423
- color: agentMode === "build" ? theme.status.success : theme.status.warning,
31424
- children: agentMode.toUpperCase()
32965
+ history: historyManager.history,
32966
+ historyRemountKey,
32967
+ pendingAssistantText,
32968
+ liveToolCalls,
32969
+ terminalWidth,
32970
+ mainAreaWidth,
32971
+ isFocused: approvalQueue.length === 0
31425
32972
  }
31426
32973
  ),
31427
- /* @__PURE__ */ jsxs46(Text49, { color: theme.text.secondary, children: [
31428
- " ",
31429
- streamingState === "responding" ? "running" : streamingState === "waiting_for_confirmation" ? "waiting-approval" : "idle"
31430
- ] }),
31431
- iterationInfo && /* @__PURE__ */ jsxs46(Text49, { color: theme.text.secondary, children: [
31432
- " ",
31433
- "iter ",
31434
- iterationInfo.round,
31435
- "/",
31436
- iterationInfo.max
31437
- ] }),
31438
- lastPromptTokenCount > 0 && /* @__PURE__ */ jsxs46(Text49, { color: theme.text.secondary, children: [
31439
- " ",
31440
- "\u2191",
31441
- formatTokenCount(lastPromptTokenCount),
31442
- " \u2193",
31443
- formatTokenCount(lastOutputTokenCount)
31444
- ] })
32974
+ /* @__PURE__ */ jsx62(ShowMoreLines, { constrainHeight })
31445
32975
  ] }),
31446
- initError ? /* @__PURE__ */ jsx51(Box41, { marginLeft: 2, marginRight: 2, children: /* @__PURE__ */ jsxs46(Text49, { color: theme.status.error, children: [
31447
- "Failed to initialize runtime: ",
31448
- initError
31449
- ] }) }) : /* @__PURE__ */ jsx51(
31450
- MainContent,
31451
- {
31452
- history: historyManager.history,
31453
- historyRemountKey,
31454
- pendingAssistantText,
31455
- liveToolCalls,
31456
- terminalWidth,
31457
- mainAreaWidth,
31458
- isFocused: approvalQueue.length === 0
31459
- }
31460
- ),
31461
- approvalQueue.length > 0 && /* @__PURE__ */ jsx51(Box41, { marginLeft: 2, marginRight: 2, marginTop: 1, children: /* @__PURE__ */ jsx51(ApprovalPrompt, { request: approvalQueue[0] }) }),
31462
- dialogModel && /* @__PURE__ */ jsx51(CommandDialog, { title: dialogModel.title, lines: dialogModel.lines }),
31463
- activeDialog === "provider" && /* @__PURE__ */ jsx51(
32976
+ approvalQueue.length > 0 && /* @__PURE__ */ jsx62(Box52, { marginLeft: 2, marginRight: 2, marginTop: 1, children: /* @__PURE__ */ jsx62(ApprovalPrompt, { request: approvalQueue[0] }) }),
32977
+ dialogModel && /* @__PURE__ */ jsx62(CommandDialog, { title: dialogModel.title, lines: dialogModel.lines }),
32978
+ activeDialog === "provider" && /* @__PURE__ */ jsx62(
31464
32979
  ProviderDialog,
31465
32980
  {
31466
32981
  providers: listAvailableProviders(),
@@ -31475,7 +32990,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31475
32990
  onClose: closeDialog
31476
32991
  }
31477
32992
  ),
31478
- activeDialog === "model" && /* @__PURE__ */ jsx51(
32993
+ activeDialog === "model" && /* @__PURE__ */ jsx62(
31479
32994
  ModelDialog,
31480
32995
  {
31481
32996
  currentProvider: getSessionCommandState().provider,
@@ -31485,7 +33000,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31485
33000
  onClose: closeDialog
31486
33001
  }
31487
33002
  ),
31488
- activeDialog === "theme" && /* @__PURE__ */ jsx51(
33003
+ activeDialog === "theme" && /* @__PURE__ */ jsx62(
31489
33004
  ThemeDialog,
31490
33005
  {
31491
33006
  onSelect: handleSelectTheme,
@@ -31493,7 +33008,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31493
33008
  onPreview: previewTheme
31494
33009
  }
31495
33010
  ),
31496
- activeDialog === "permissions" && /* @__PURE__ */ jsx51(
33011
+ activeDialog === "permissions" && /* @__PURE__ */ jsx62(
31497
33012
  PermissionsDialog,
31498
33013
  {
31499
33014
  current: permissionModes,
@@ -31501,7 +33016,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31501
33016
  onClose: closeDialog
31502
33017
  }
31503
33018
  ),
31504
- activeDialog === "auth" && runtimeRef.current && /* @__PURE__ */ jsx51(
33019
+ activeDialog === "auth" && runtimeRef.current && /* @__PURE__ */ jsx62(
31505
33020
  AuthDialog,
31506
33021
  {
31507
33022
  clientId: runtimeRef.current.config.github.oauthClientId,
@@ -31514,8 +33029,8 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31514
33029
  onClose: closeDialog
31515
33030
  }
31516
33031
  ),
31517
- activeDialog === "feedback" && /* @__PURE__ */ jsx51(FeedbackDialog, { cwd, onClose: closeDialog }),
31518
- activeDialog === "sessions" && /* @__PURE__ */ jsx51(
33032
+ activeDialog === "feedback" && /* @__PURE__ */ jsx62(FeedbackDialog, { cwd, onClose: closeDialog }),
33033
+ activeDialog === "sessions" && /* @__PURE__ */ jsx62(
31519
33034
  SessionsDialog,
31520
33035
  {
31521
33036
  cwd,
@@ -31523,7 +33038,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31523
33038
  onClose: closeDialog
31524
33039
  }
31525
33040
  ),
31526
- pendingCommandConfirmation && /* @__PURE__ */ jsx51(
33041
+ pendingCommandConfirmation && /* @__PURE__ */ jsx62(
31527
33042
  CommandDialog,
31528
33043
  {
31529
33044
  title: "Confirm action",
@@ -31535,15 +33050,24 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31535
33050
  footerText: "Press y or Enter to confirm. Press n or Esc to cancel."
31536
33051
  }
31537
33052
  ),
31538
- /* @__PURE__ */ jsx51(
33053
+ /* @__PURE__ */ jsx62(
31539
33054
  SubagentsPanel,
31540
33055
  {
31541
33056
  subagents: Array.from(subagentMap.values()),
31542
33057
  mainAreaWidth
31543
33058
  }
31544
33059
  ),
31545
- /* @__PURE__ */ jsx51(Composer, {})
31546
- ] }) }) }) }) }) }) }) }) }) }) }) });
33060
+ stickyTodos && /* @__PURE__ */ jsx62(
33061
+ StickyTodoList,
33062
+ {
33063
+ todos: stickyTodos,
33064
+ width: mainAreaWidth,
33065
+ maxVisibleItems: stickyTodoMaxItems
33066
+ }
33067
+ ),
33068
+ /* @__PURE__ */ jsx62(Notifications, {}),
33069
+ /* @__PURE__ */ jsx62(Composer, {})
33070
+ ] }) }) }) }) }) }) }) }) }) }) }) }) });
31547
33071
  };
31548
33072
  function formatProviderLabel(provider, model) {
31549
33073
  return model ? `${provider} \u203A ${model}` : `${provider} \u203A (model unset)`;
@@ -31585,11 +33109,11 @@ function isInteractiveDialog(dialog) {
31585
33109
  return dialog === "theme" || dialog === "permissions" || dialog === "auth" || dialog === "provider" || dialog === "model" || dialog === "feedback" || dialog === "sessions";
31586
33110
  }
31587
33111
  function tuiThemeFilePath(cwd) {
31588
- return path15.join(cwd, ".deepcode", "tui-theme.json");
33112
+ return path19.join(cwd, ".deepcode", "tui-theme.json");
31589
33113
  }
31590
33114
  function readSavedTheme(cwd) {
31591
33115
  try {
31592
- const parsed = JSON.parse(fs8.readFileSync(tuiThemeFilePath(cwd), "utf8"));
33116
+ const parsed = JSON.parse(fs12.readFileSync(tuiThemeFilePath(cwd), "utf8"));
31593
33117
  return typeof parsed.theme === "string" ? parsed.theme : null;
31594
33118
  } catch {
31595
33119
  return null;
@@ -31597,16 +33121,16 @@ function readSavedTheme(cwd) {
31597
33121
  }
31598
33122
  function writeSavedTheme(cwd, themeName) {
31599
33123
  const file = tuiThemeFilePath(cwd);
31600
- fs8.mkdirSync(path15.dirname(file), { recursive: true });
31601
- fs8.writeFileSync(file, `${JSON.stringify({ theme: themeName }, null, 2)}
33124
+ fs12.mkdirSync(path19.dirname(file), { recursive: true });
33125
+ fs12.writeFileSync(file, `${JSON.stringify({ theme: themeName }, null, 2)}
31602
33126
  `);
31603
33127
  }
31604
33128
  function tuiProviderFilePath(cwd) {
31605
- return path15.join(cwd, ".deepcode", "tui-provider.json");
33129
+ return path19.join(cwd, ".deepcode", "tui-provider.json");
31606
33130
  }
31607
33131
  function readSavedProvider(cwd) {
31608
33132
  try {
31609
- const parsed = JSON.parse(fs8.readFileSync(tuiProviderFilePath(cwd), "utf8"));
33133
+ const parsed = JSON.parse(fs12.readFileSync(tuiProviderFilePath(cwd), "utf8"));
31610
33134
  const result = ProviderIdSchema.safeParse(parsed.provider);
31611
33135
  if (!result.success) return null;
31612
33136
  return {
@@ -31619,8 +33143,8 @@ function readSavedProvider(cwd) {
31619
33143
  }
31620
33144
  function writeSavedProvider(cwd, provider, model) {
31621
33145
  const file = tuiProviderFilePath(cwd);
31622
- fs8.mkdirSync(path15.dirname(file), { recursive: true });
31623
- fs8.writeFileSync(file, `${JSON.stringify({ provider, model }, null, 2)}
33146
+ fs12.mkdirSync(path19.dirname(file), { recursive: true });
33147
+ fs12.writeFileSync(file, `${JSON.stringify({ provider, model }, null, 2)}
31624
33148
  `);
31625
33149
  }
31626
33150
  function errorMessage(error) {
@@ -31629,12 +33153,13 @@ function errorMessage(error) {
31629
33153
  function buildDialogModel(dialog, options) {
31630
33154
  if (!dialog) return null;
31631
33155
  if (dialog === "help") {
33156
+ const maxNameLen = Math.max(...options.commands.map((c) => c.name.length + 1));
31632
33157
  return {
31633
- title: "Help",
31634
- lines: [
31635
- "Available commands:",
31636
- ...options.commandNames
31637
- ]
33158
+ title: "Comandos dispon\xEDveis",
33159
+ lines: options.commands.map((c) => {
33160
+ const label = `/${c.name}`.padEnd(maxNameLen + 1);
33161
+ return `${label} ${c.description}`;
33162
+ })
31638
33163
  };
31639
33164
  }
31640
33165
  if (dialog === "settings") {
@@ -31666,22 +33191,22 @@ function formatAuthSummary(config) {
31666
33191
  var ApprovalPrompt = ({ request }) => {
31667
33192
  if (!request) return null;
31668
33193
  const operationLabel = formatApprovalOperationLabel(request);
31669
- return /* @__PURE__ */ jsxs46(Box41, { flexDirection: "column", marginTop: 1, children: [
31670
- /* @__PURE__ */ jsxs46(Text49, { color: theme.status.warning, children: [
33194
+ return /* @__PURE__ */ jsxs56(Box52, { flexDirection: "column", marginTop: 1, children: [
33195
+ /* @__PURE__ */ jsxs56(Text60, { color: theme.status.warning, children: [
31671
33196
  "\u26A0 Allow ",
31672
33197
  operationLabel,
31673
33198
  "?"
31674
33199
  ] }),
31675
- request.path && /* @__PURE__ */ jsxs46(Text49, { color: theme.text.secondary, children: [
33200
+ request.path && /* @__PURE__ */ jsxs56(Text60, { color: theme.text.secondary, children: [
31676
33201
  " ",
31677
33202
  request.path
31678
33203
  ] }),
31679
- request.preview?.command && /* @__PURE__ */ jsxs46(Text49, { color: theme.text.secondary, children: [
33204
+ request.preview?.command && /* @__PURE__ */ jsxs56(Text60, { color: theme.text.secondary, children: [
31680
33205
  " $ ",
31681
33206
  request.preview.command,
31682
33207
  request.preview.args?.length ? ` ${request.preview.args.join(" ")}` : ""
31683
33208
  ] }),
31684
- /* @__PURE__ */ jsx51(Text49, { color: theme.text.secondary, children: " [\u21B5/y] once [s] session [a] always [n] deny" })
33209
+ /* @__PURE__ */ jsx62(Text60, { color: theme.text.secondary, children: " [\u21B5/y] once [s] session [a] always [n] deny" })
31685
33210
  ] });
31686
33211
  };
31687
33212
  function formatApprovalOperationLabel(request) {
@@ -31742,7 +33267,7 @@ var DeepCodeConfigAdapter = class {
31742
33267
  }
31743
33268
  };
31744
33269
  function App(props) {
31745
- return /* @__PURE__ */ jsx52(
33270
+ return /* @__PURE__ */ jsx63(
31746
33271
  AppContainer,
31747
33272
  {
31748
33273
  cwd: props.cwd,
@@ -31938,7 +33463,7 @@ function createProgram() {
31938
33463
  });
31939
33464
  program.command("chat", { isDefault: true }).description("open the terminal UI").option("--provider <provider>", "provider override for this chat session").option("--model <model>", "model override for this chat session (or <provider>/<model>)").option("--resume <id>", "resume a previous session by ID").action((options) => {
31940
33465
  render3(
31941
- React40.createElement(App, {
33466
+ React42.createElement(App, {
31942
33467
  cwd: program.opts().cwd,
31943
33468
  config: program.opts().config,
31944
33469
  provider: options.provider,