@thegitai/cli 1.4.1 → 1.5.0

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/README.md CHANGED
@@ -22,8 +22,8 @@ This package is the CLI. The same agent is also available as a
22
22
  when a request calls for it, or when you type `/<name>`.
23
23
  - **MCP servers** - connect local or remote MCP servers with `ai mcp add`.
24
24
  - **Memory and project rules** - it remembers your corrections and preferences
25
- between sessions, in files on your computer, and follows your `AGENTS.md` or
26
- `CLAUDE.md` on every request.
25
+ between sessions, in files on your computer, and follows your `AGENTS.md` on
26
+ every request.
27
27
  - **Git and pull requests** - it reads history and diffs, commits on a branch,
28
28
  and opens and reviews pull requests with the GitHub CLI.
29
29
  - **Beyond source code** - reads PDF, Word and Excel files, edits Word
@@ -315,7 +315,7 @@ files can also be edited in any text editor.
315
315
 
316
316
  ## Project instructions
317
317
 
318
- TheGitAI follows the `AGENTS.md`, `AGENT.md` or `CLAUDE.md` at your project's
318
+ TheGitAI follows the `AGENTS.md` or `AGENT.md` at your project's
319
319
  root on every request, so your project's rules apply without repeating them.
320
320
 
321
321
  ## Notifications
@@ -369,6 +369,16 @@ readable when the session is resumed. Default, Bypass all permissions, and Plan
369
369
  modes all support the form; Bypass all permissions does not choose answers for
370
370
  you.
371
371
 
372
+ ## Progress updates
373
+
374
+ While it works, the agent posts short updates in the conversation: how it will
375
+ approach the request, then what it found, a change of plan, or a blocker. Under
376
+ each update, the reads and searches it did next fold into one muted line, such
377
+ as `Read 5 files · searched 2 patterns`, and each command it ran is listed as
378
+ `$ npm test`. File edits keep their own diff rows, the latest steps and the
379
+ running command's output still show live above **Working**, and the updates stay
380
+ in the transcript after the answer.
381
+
372
382
  ## Visible to-do list
373
383
 
374
384
  For larger multi-step tasks, the agent keeps a compact to-do list on screen so
@@ -584,6 +584,12 @@ async function runTurnStream({ openStream, config, session, input, request, reco
584
584
  onInterjectionDelivered?.(delivered);
585
585
  break;
586
586
  }
587
+ case 'progress': {
588
+ const text = String(data?.text ?? '').trim();
589
+ if (text)
590
+ session.onProgressUpdate?.(text);
591
+ break;
592
+ }
587
593
  case 'status': {
588
594
  const status = (data ?? {});
589
595
  if (status.phase === 'analyzing_image') {
@@ -624,7 +630,11 @@ async function runTurnStream({ openStream, config, session, input, request, reco
624
630
  case 'tool-result': {
625
631
  const toolResult = data;
626
632
  if (toolResult?.call?.name) {
627
- session.onToolEvent?.({ call: toolResult.call, result: toolResult.result });
633
+ session.onToolEvent?.({
634
+ call: toolResult.call,
635
+ result: toolResult.result,
636
+ reportedByServer: true,
637
+ });
628
638
  }
629
639
  break;
630
640
  }
@@ -1,4 +1,7 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { homedir } from 'node:os';
3
+ import { join, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
2
5
  export function resolveOpenUrlCommand(url, platform = process.platform) {
3
6
  const parsed = new URL(url);
4
7
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
@@ -30,3 +33,36 @@ export async function openUrl(url, platform = process.platform) {
30
33
  child.once('exit', (code) => finish(code === 0));
31
34
  });
32
35
  }
36
+ export function isWebLink(url) {
37
+ return /^https?:\/\//i.test(String(url ?? '').trim());
38
+ }
39
+ export function localLinkPath(target, projectRoot) {
40
+ let raw = String(target ?? '').trim();
41
+ let lineSuffix = '';
42
+ const hash = raw.indexOf('#');
43
+ if (hash !== -1) {
44
+ const line = /^L(\d+)/.exec(raw.slice(hash + 1));
45
+ if (line)
46
+ lineSuffix = `:${line[1]}`;
47
+ raw = raw.slice(0, hash);
48
+ }
49
+ if (/^file:/i.test(raw)) {
50
+ try {
51
+ return fileURLToPath(raw) + lineSuffix;
52
+ }
53
+ catch {
54
+ return raw + lineSuffix;
55
+ }
56
+ }
57
+ let path = raw;
58
+ try {
59
+ path = decodeURIComponent(raw);
60
+ }
61
+ catch {
62
+ path = raw;
63
+ }
64
+ if (path === '~' || path.startsWith('~/')) {
65
+ path = join(homedir(), path.slice(1));
66
+ }
67
+ return resolve(projectRoot, path) + lineSuffix;
68
+ }
@@ -203,6 +203,9 @@ export async function strReplace(context, args) {
203
203
  const color = changed ? chalk.green : chalk.yellow;
204
204
  console.log(color(` ✏️ ${actionLabel}: ${filePath} (${originalLines} → ${nextLines} lines, ${replacements} replacement(s))`));
205
205
  }
206
+ const startLine = changed && replacements === 1
207
+ ? originalContent.slice(0, originalContent.indexOf(oldString)).split('\n').length
208
+ : undefined;
206
209
  return {
207
210
  ok: true,
208
211
  filePath,
@@ -210,6 +213,7 @@ export async function strReplace(context, args) {
210
213
  operation: 'str_replace',
211
214
  ...(scratchPath ? { scratch: true } : {}),
212
215
  replacements,
216
+ ...(startLine ? { startLine } : {}),
213
217
  bytesWritten: Buffer.byteLength(nextContent, 'utf-8'),
214
218
  diagnostics,
215
219
  message: changed ? undefined : 'The provided replacement resulted in no changes to the file content.',
@@ -4,7 +4,7 @@ import { REASONING_EFFORT_LABELS } from '../reasoning-effort.js';
4
4
  import { basename, join as joinPath } from 'node:path';
5
5
  import { createRatatuiBridge } from './tui/bridge.js';
6
6
  import { bucketActionLabel, } from '../permissions.js';
7
- import { AGENT_MODE_LOCKED_STATUS, approvalScrollLimit, buildTuiFrame, modelPickerPageSize, formatJobElapsed, formatTodoProgress, pickThinkingFallbackPhrase, renderTranscriptEntryLines, THINKING_FALLBACK_PHRASES, userInputViewportForFrame, } from './tui/build-frame.js';
7
+ import { AGENT_MODE_LOCKED_STATUS, approvalScrollLimit, buildTuiFrame, modelPickerPageSize, formatJobElapsed, formatTodoProgress, pickThinkingFallbackPhrase, renderTranscriptEntryLines, transcriptLiveRowCount, THINKING_FALLBACK_PHRASES, userInputViewportForFrame, } from './tui/build-frame.js';
8
8
  import { createAttentionController, INITIAL_TERMINAL_FOCUS, } from './tui/attention.js';
9
9
  import { backendFor, createNotificationQueue, } from './tui/desktop-notification.js';
10
10
  import { readPreferences, writePreferences } from '../preferences.js';
@@ -39,8 +39,10 @@ import { collectBackgroundJobUiKillMutations, collectBackgroundJobUiOutputMutati
39
39
  import { startNewConversation, } from '../session.js';
40
40
  import { applySessionSnapshot, listSessionMetadata, loadSessionSnapshot, saveSessionState, sessionHasUserMessage, } from '../session-store.js';
41
41
  import { truncate } from '../utils.js';
42
+ import { TOOL_MAP } from '../tools/index.js';
43
+ import { countStep, EMPTY_TURN_STEPS, turnStepFields, } from './turn-steps.js';
42
44
  import { writeClipboardText } from '../core/clipboard.js';
43
- import { openUrl } from '../core/open-url.js';
45
+ import { isWebLink, localLinkPath, openUrl } from '../core/open-url.js';
44
46
  import { formatAboutCard, formatInteractiveHelpText } from '../help-text.js';
45
47
  import { expandPastedChunks, } from './paste-collapse.js';
46
48
  import { loadPromptHistory, MAX_PROMPT_HISTORY_ENTRIES, } from './prompt-history-store.js';
@@ -184,6 +186,8 @@ function getEntryColor(kind) {
184
186
  return 'yellow';
185
187
  case 'tool':
186
188
  return 'blue';
189
+ case 'update':
190
+ return 'green';
187
191
  case 'user':
188
192
  return 'cyan';
189
193
  }
@@ -493,10 +497,12 @@ function splitDiffLines(text) {
493
497
  ? lines.slice(0, -1)
494
498
  : lines;
495
499
  }
496
- function buildStrReplaceDiff(oldString, newString) {
500
+ function buildStrReplaceDiff(oldString, newString, startLine) {
497
501
  const oldLines = splitDiffLines(String(oldString ?? ''));
498
502
  const newLines = splitDiffLines(String(newString ?? ''));
499
- const lines = [`@@ -1,${oldLines.length} +1,${newLines.length} @@`];
503
+ const lines = startLine && startLine > 0
504
+ ? [`@@ -${startLine},${oldLines.length} +${startLine},${newLines.length} @@`]
505
+ : [];
500
506
  if (oldLines.length > 0)
501
507
  lines.push(oldLines.map((line) => `-${line}`).join('\n'));
502
508
  if (newLines.length > 0)
@@ -585,6 +591,26 @@ function formatToolArgs(call, result) {
585
591
  }
586
592
  return '';
587
593
  }
594
+ export function mergeFileEdit(previous, next) {
595
+ if (previous?.kind !== 'diff' || next.kind !== 'diff')
596
+ return null;
597
+ if (!previous.filePath || previous.filePath !== next.filePath)
598
+ return null;
599
+ if (!previous.title.startsWith('Edited ') || !next.title.startsWith('Edited '))
600
+ return null;
601
+ if (!previous.diffPreview || !next.diffPreview)
602
+ return null;
603
+ const added = previous.diffPreview.added + next.diffPreview.added;
604
+ const removed = previous.diffPreview.removed + next.diffPreview.removed;
605
+ const nextLines = next.diffPreview.lines[0]?.kind === 'hunk'
606
+ ? next.diffPreview.lines
607
+ : [{ kind: 'hunk', lineNumber: null, content: '@@ -0,0 +0,0 @@' }, ...next.diffPreview.lines];
608
+ return {
609
+ ...previous,
610
+ title: `Edited ${previous.filePath} (+${added} -${removed})`,
611
+ diffPreview: { added, removed, lines: [...previous.diffPreview.lines, ...nextLines] },
612
+ };
613
+ }
588
614
  function buildFileChangeEntry(event) {
589
615
  const { call, result } = event;
590
616
  const filePath = getToolFilePath(call, result) || '(unknown file)';
@@ -710,7 +736,7 @@ function buildFileChangeEntry(event) {
710
736
  : typeof call.args?.newString === 'string'
711
737
  ? call.args.newString
712
738
  : '';
713
- diffText = buildStrReplaceDiff(oldString, newString);
739
+ diffText = buildStrReplaceDiff(oldString, newString, typeof result?.startLine === 'number' ? result.startLine : undefined);
714
740
  }
715
741
  const preview = diffText ? parseDiffPreview(diffText) : undefined;
716
742
  const summary = preview ? ` (+${preview.added} -${preview.removed})` : '';
@@ -857,12 +883,27 @@ export function buildTranscriptFromSessionHistory(history) {
857
883
  const pendingUserInputRequests = new Map();
858
884
  let turnMemory = [];
859
885
  let turnResponse = null;
886
+ let openUpdate = null;
887
+ let openSteps = EMPTY_TURN_STEPS;
860
888
  const settleTurnMemory = () => {
861
889
  const note = memoryUpdatedNote(turnMemory);
862
890
  if (note && turnResponse)
863
891
  turnResponse.note = note;
864
892
  turnMemory = [];
865
893
  turnResponse = null;
894
+ openUpdate = null;
895
+ openSteps = EMPTY_TURN_STEPS;
896
+ };
897
+ const countHistoryStep = (call, result) => {
898
+ const next = countStep(openSteps, call, result);
899
+ if (next === openSteps)
900
+ return;
901
+ openSteps = next;
902
+ if (!openUpdate) {
903
+ openUpdate = { body: '', kind: 'update', title: '' };
904
+ entries.push(openUpdate);
905
+ }
906
+ Object.assign(openUpdate, turnStepFields(openSteps));
866
907
  };
867
908
  for (const entry of history) {
868
909
  if (!entry?.parts?.length)
@@ -919,12 +960,21 @@ export function buildTranscriptFromSessionHistory(history) {
919
960
  turnMemory.push(String(saved.topic ?? call.args?.topic ?? '').trim());
920
961
  continue;
921
962
  }
963
+ if (call)
964
+ countHistoryStep(call, functionResponse.response);
922
965
  if (!call || !isFileChangeTool(call.name))
923
966
  continue;
924
967
  const result = (functionResponse.response ?? {});
925
968
  if (result.ok !== true && result.skipped !== true)
926
969
  continue;
927
- entries.push(buildFileChangeEntry({ call, result }));
970
+ const change = buildFileChangeEntry({ call, result });
971
+ const merged = mergeFileEdit(entries.at(-1), change);
972
+ if (merged)
973
+ entries[entries.length - 1] = merged;
974
+ else
975
+ entries.push(change);
976
+ openUpdate = null;
977
+ openSteps = EMPTY_TURN_STEPS;
928
978
  }
929
979
  if (entry.role === 'user' && entry.kind === 'turnStart') {
930
980
  settleTurnMemory();
@@ -953,6 +1003,21 @@ export function buildTranscriptFromSessionHistory(history) {
953
1003
  }
954
1004
  if (turnResponse?.body === text)
955
1005
  continue;
1006
+ const calls = entry.parts.filter((part) => part?.functionCall?.name);
1007
+ if (calls.length > 0 &&
1008
+ !calls.every((part) => part.functionCall.name === 'remember')) {
1009
+ openUpdate = { body: text, kind: 'update', title: '' };
1010
+ openSteps = EMPTY_TURN_STEPS;
1011
+ entries.push(openUpdate);
1012
+ continue;
1013
+ }
1014
+ const echoed = openUpdate;
1015
+ if (echoed && echoed.body === text) {
1016
+ if (echoed.steps || echoed.commands?.length)
1017
+ echoed.body = '';
1018
+ else
1019
+ entries.splice(entries.indexOf(echoed), 1);
1020
+ }
956
1021
  turnResponse = { body: text, kind: 'assistant', title: 'Response' };
957
1022
  entries.push(turnResponse);
958
1023
  }
@@ -1022,7 +1087,7 @@ export function createShellStore(initialState) {
1022
1087
  notify();
1023
1088
  return id;
1024
1089
  },
1025
- appendEntries: (entries) => {
1090
+ appendEntries: (entries, scrollOffset = 0, changes = {}) => {
1026
1091
  if (entries.length === 0)
1027
1092
  return [];
1028
1093
  const appended = entries.map((entry) => ({
@@ -1031,12 +1096,22 @@ export function createShellStore(initialState) {
1031
1096
  }));
1032
1097
  state = {
1033
1098
  ...state,
1099
+ ...changes,
1034
1100
  transcript: [...state.transcript, ...appended],
1035
- transcriptScrollOffset: 0,
1101
+ transcriptScrollOffset: scrollOffset,
1036
1102
  };
1037
1103
  notify();
1038
1104
  return appended.map((entry) => entry.id);
1039
1105
  },
1106
+ removeEntry: (id) => {
1107
+ if (!state.transcript.some((entry) => entry.id === id))
1108
+ return;
1109
+ state = {
1110
+ ...state,
1111
+ transcript: state.transcript.filter((entry) => entry.id !== id),
1112
+ };
1113
+ notify();
1114
+ },
1040
1115
  appendWorkingTool: (entry) => {
1041
1116
  const lastEntry = state.workingTools.at(-1);
1042
1117
  const isDuplicate = sameTranscriptDraft(lastEntry, entry);
@@ -1061,7 +1136,7 @@ export function createShellStore(initialState) {
1061
1136
  };
1062
1137
  notify();
1063
1138
  },
1064
- updateEntry: (id, changes) => {
1139
+ updateEntry: (id, changes, scrollOffset) => {
1065
1140
  const index = state.transcript.findIndex((entry) => entry.id === id);
1066
1141
  if (index === -1)
1067
1142
  return;
@@ -1069,12 +1144,20 @@ export function createShellStore(initialState) {
1069
1144
  const next = { ...current, ...changes };
1070
1145
  if (current.body === next.body &&
1071
1146
  current.kind === next.kind &&
1072
- current.title === next.title) {
1147
+ current.title === next.title &&
1148
+ current.steps === next.steps &&
1149
+ current.diffPreview === next.diffPreview &&
1150
+ current.commands === next.commands &&
1151
+ current.moreCommands === next.moreCommands) {
1073
1152
  return;
1074
1153
  }
1075
1154
  const nextTranscript = [...state.transcript];
1076
1155
  nextTranscript[index] = next;
1077
- state = { ...state, transcript: nextTranscript };
1156
+ state = {
1157
+ ...state,
1158
+ transcript: nextTranscript,
1159
+ transcriptScrollOffset: scrollOffset ?? state.transcriptScrollOffset,
1160
+ };
1078
1161
  notify();
1079
1162
  },
1080
1163
  };
@@ -1526,6 +1609,9 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1526
1609
  let latestUsageSummary = null;
1527
1610
  const usageNotice = createUsageNoticeTracker();
1528
1611
  let pendingTurnEntries = [];
1612
+ let turnSteps = EMPTY_TURN_STEPS;
1613
+ let openStepsId = null;
1614
+ let turnInTranscript = false;
1529
1615
  let activeTurnAbort = null;
1530
1616
  let activeTurnImageAttachments = [];
1531
1617
  let activeServerTurnId = null;
@@ -1637,10 +1723,21 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1637
1723
  focused: state.terminalFocused,
1638
1724
  }, state.notificationsEnabled);
1639
1725
  };
1726
+ let lastLiveRows = 0;
1640
1727
  const renderCurrentFrame = () => {
1641
1728
  if (!tuiReady)
1642
1729
  return;
1643
1730
  const state = store.getState();
1731
+ const liveRows = transcriptLiveRowCount(state, terminalCols, spinnerFrame, busyElapsedSeconds(state, Date.now()), Date.now());
1732
+ const liveGrowth = liveRows - lastLiveRows;
1733
+ lastLiveRows = liveRows;
1734
+ if (liveGrowth !== 0 && state.transcriptScrollOffset > 0) {
1735
+ store.update((current) => ({
1736
+ ...current,
1737
+ transcriptScrollOffset: Math.max(0, current.transcriptScrollOffset + liveGrowth),
1738
+ }));
1739
+ return;
1740
+ }
1644
1741
  syncTerminalTitle();
1645
1742
  syncAttention();
1646
1743
  const elapsedSeconds = busyElapsedSeconds(state, Date.now());
@@ -1672,7 +1769,14 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1672
1769
  const queueTurnEntry = (entry) => {
1673
1770
  if (sameTranscriptDraft(pendingTurnEntries.at(-1), entry))
1674
1771
  return;
1772
+ const merged = mergeFileEdit(pendingTurnEntries.at(-1), entry);
1773
+ if (merged) {
1774
+ pendingTurnEntries = [...pendingTurnEntries.slice(0, -1), merged];
1775
+ return;
1776
+ }
1675
1777
  pendingTurnEntries = [...pendingTurnEntries, entry];
1778
+ if (!turnInTranscript)
1779
+ turnSteps = EMPTY_TURN_STEPS;
1676
1780
  };
1677
1781
  const appendTurnAwareEntry = (entry) => {
1678
1782
  if (store.getState().busy) {
@@ -1719,6 +1823,88 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1719
1823
  pendingTurnEntries = [];
1720
1824
  return entries;
1721
1825
  };
1826
+ const resetTurnProgress = () => {
1827
+ turnSteps = EMPTY_TURN_STEPS;
1828
+ openStepsId = null;
1829
+ turnInTranscript = false;
1830
+ };
1831
+ const transcriptEntryHeight = (entry) => renderTranscriptEntryLines(entry, Math.max(1, frameContentWidth(terminalCols) - 2)).length;
1832
+ const heldScrollOffset = (addedLines) => {
1833
+ const offset = store.getState().transcriptScrollOffset;
1834
+ return offset > 0 ? Math.max(0, offset + addedLines()) : 0;
1835
+ };
1836
+ const commitTurnEntries = (extra, collectsSteps) => {
1837
+ const last = store.getState().transcript.at(-1);
1838
+ const merged = pendingTurnEntries.length === 0 && extra.length === 1 && last
1839
+ ? mergeFileEdit(last, extra[0])
1840
+ : null;
1841
+ if (last && merged) {
1842
+ turnSteps = EMPTY_TURN_STEPS;
1843
+ openStepsId = collectsSteps ? last.id : null;
1844
+ store.updateEntry(last.id, { title: merged.title, diffPreview: merged.diffPreview }, heldScrollOffset(() => transcriptEntryHeight(merged) - transcriptEntryHeight(last)));
1845
+ return;
1846
+ }
1847
+ const entries = [...takePendingTurnEntries(), ...extra];
1848
+ turnSteps = EMPTY_TURN_STEPS;
1849
+ turnInTranscript = true;
1850
+ const ids = store.appendEntries(entries, heldScrollOffset(() => entries.reduce((sum, entry) => sum + transcriptEntryHeight(entry) + 1, 0)), {
1851
+ activeTurnInput: '',
1852
+ activeTurnInputPreformatted: false,
1853
+ commandLog: [],
1854
+ usageNotice: null,
1855
+ workingTools: [],
1856
+ });
1857
+ openStepsId = collectsSteps ? (ids.at(-1) ?? null) : null;
1858
+ };
1859
+ const countTurnStep = (event) => {
1860
+ if (!store.getState().busy)
1861
+ return;
1862
+ if (event.reportedByServer && Object.hasOwn(TOOL_MAP, event.call.name))
1863
+ return;
1864
+ const next = countStep(turnSteps, event.call, event.result);
1865
+ if (next === turnSteps)
1866
+ return;
1867
+ turnSteps = next;
1868
+ const fields = turnStepFields(turnSteps);
1869
+ if (!turnInTranscript) {
1870
+ const last = pendingTurnEntries.at(-1);
1871
+ const entry = { body: '', kind: 'update', title: '', ...fields };
1872
+ pendingTurnEntries =
1873
+ last && last.kind === 'update' && !last.body
1874
+ ? [...pendingTurnEntries.slice(0, -1), entry]
1875
+ : [...pendingTurnEntries, entry];
1876
+ return;
1877
+ }
1878
+ const id = openStepsId;
1879
+ const open = id === null
1880
+ ? undefined
1881
+ : store.getState().transcript.find((entry) => entry.id === id);
1882
+ if (id === null || !open) {
1883
+ const entry = { body: '', kind: 'update', title: '', ...fields };
1884
+ openStepsId =
1885
+ store
1886
+ .appendEntries([entry], heldScrollOffset(() => transcriptEntryHeight(entry) + 1))
1887
+ .at(-1) ?? null;
1888
+ return;
1889
+ }
1890
+ store.updateEntry(id, fields, heldScrollOffset(() => transcriptEntryHeight({ ...open, ...fields }) - transcriptEntryHeight(open)));
1891
+ };
1892
+ const takeSettledTurnEntries = (responseText = '') => {
1893
+ const entries = takePendingTurnEntries();
1894
+ const id = openStepsId;
1895
+ const open = id === null
1896
+ ? undefined
1897
+ : store.getState().transcript.find((entry) => entry.id === id);
1898
+ const response = responseText.trim();
1899
+ if (id !== null && open?.body && response && open.body.trim() === response) {
1900
+ if (open.steps || open.commands?.length)
1901
+ store.updateEntry(id, { body: '' });
1902
+ else
1903
+ store.removeEntry(id);
1904
+ }
1905
+ resetTurnProgress();
1906
+ return entries;
1907
+ };
1722
1908
  const appendError = (message) => {
1723
1909
  appendStaticEntry({
1724
1910
  body: message,
@@ -1730,9 +1916,15 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1730
1916
  void writeClipboardText(text).then(() => showTransientStatus('Copied selection'), (error) => appendError(`Selection copy failed: ${error.message}`));
1731
1917
  };
1732
1918
  const handleLinkCopy = (url) => {
1733
- void writeClipboardText(url).then(() => showTransientStatus('Copied link'), (error) => appendError(`Link copy failed: ${error.message}`));
1919
+ const web = isWebLink(url);
1920
+ const text = web ? url : localLinkPath(url, store.getState().projectRoot);
1921
+ void writeClipboardText(text).then(() => showTransientStatus(web ? 'Copied link' : 'Copied path'), (error) => appendError(`Link copy failed: ${error.message}`));
1734
1922
  };
1735
1923
  const handleLinkOpen = async (url) => {
1924
+ if (!isWebLink(url)) {
1925
+ handleLinkCopy(url);
1926
+ return;
1927
+ }
1736
1928
  try {
1737
1929
  const opened = await openUrl(url);
1738
1930
  showTransientStatus(opened ? 'Opened link' : 'Could not open link');
@@ -1815,7 +2007,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1815
2007
  const restoredAttachments = composerAttachmentsAfterCancel(queued ? queued.imageAttachments : [], activeTurnImageAttachments);
1816
2008
  activeTurnImageAttachments = [];
1817
2009
  const cancelledEntries = [
1818
- ...takePendingTurnEntries(),
2010
+ ...takeSettledTurnEntries(),
1819
2011
  {
1820
2012
  body: 'Turn cancelled.',
1821
2013
  kind: 'error',
@@ -3056,6 +3248,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3056
3248
  title: 'You',
3057
3249
  };
3058
3250
  pendingTurnEntries = [];
3251
+ resetTurnProgress();
3059
3252
  if (!jobFollowUp)
3060
3253
  queueTurnEntry(userEntry);
3061
3254
  resetThinkingPacer();
@@ -3112,7 +3305,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3112
3305
  if (turnGeneration !== activeTurnGeneration)
3113
3306
  return;
3114
3307
  latestUsageSummary = result.usageSummary ?? null;
3115
- const turnEntries = takePendingTurnEntries();
3308
+ const turnEntries = takeSettledTurnEntries(result.text ?? '');
3116
3309
  if (!(await saveActiveSession()))
3117
3310
  return;
3118
3311
  syncShellStateFromSession();
@@ -3203,7 +3396,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3203
3396
  tokenUsage: formatClientTokenUsage(Date.now() - turnStartedAt, latestUsageSummary),
3204
3397
  workingTools: [],
3205
3398
  }));
3206
- const turnEntries = takePendingTurnEntries();
3399
+ const turnEntries = takeSettledTurnEntries();
3207
3400
  if (cancelled) {
3208
3401
  appendStaticEntries([
3209
3402
  ...turnEntries,
@@ -3315,8 +3508,14 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3315
3508
  tokenUsage: formatClientTokenUsage(busyElapsedMs(current, Date.now()), latestUsageSummary),
3316
3509
  }));
3317
3510
  };
3511
+ session.onProgressUpdate = (text) => {
3512
+ if (!store.getState().busy)
3513
+ return;
3514
+ commitTurnEntries([{ body: text, kind: 'update', title: '' }], true);
3515
+ };
3318
3516
  session.onToolEvent = (event) => {
3319
3517
  syncShellStateFromSession();
3518
+ countTurnStep(event);
3320
3519
  if (event.call.name === 'update_todos') {
3321
3520
  syncTodosState();
3322
3521
  if (event.result?.ok === true) {
@@ -3332,9 +3531,14 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3332
3531
  }
3333
3532
  if (isFileChangeTool(event.call.name)) {
3334
3533
  const entry = buildFileChangeEntry(event);
3335
- store.appendWorkingTool(entry);
3336
3534
  const result = event.result;
3337
- if (result?.ok === true || result?.skipped === true)
3535
+ const applied = result?.ok === true || result?.skipped === true;
3536
+ if (applied && turnInTranscript && store.getState().busy) {
3537
+ commitTurnEntries([entry], false);
3538
+ return;
3539
+ }
3540
+ store.appendWorkingTool(entry);
3541
+ if (applied)
3338
3542
  appendTurnAwareEntry(entry);
3339
3543
  return;
3340
3544
  }
@@ -143,6 +143,8 @@ function getEntryColor(kind) {
143
143
  return 'yellow';
144
144
  case 'tool':
145
145
  return 'blue';
146
+ case 'update':
147
+ return 'green';
146
148
  case 'user':
147
149
  return 'cyan';
148
150
  }
@@ -335,14 +337,50 @@ export function renderTodoListLines(items, width, { header = false, progressTick
335
337
  }
336
338
  return lines;
337
339
  }
340
+ function bulletedBodyLines(body, width, kind) {
341
+ const color = getEntryColor(kind);
342
+ if (!body)
343
+ return [line(span('●', { color }))];
344
+ const bodyLines = renderFormattedBodyLines(body, width, kind);
345
+ const first = bodyLines[0];
346
+ if (first && first.spans[0]?.text === ' ') {
347
+ return [{ spans: [span('● ', { color }), ...first.spans.slice(1)] }, ...bodyLines.slice(1)];
348
+ }
349
+ return [line(span('●', { color })), ...bodyLines];
350
+ }
351
+ function renderUpdateEntryLines(entry, width) {
352
+ const body = entry.body.trim();
353
+ const lines = body ? bulletedBodyLines(body, width, 'update') : [];
354
+ if (lines.length > 0 && (entry.steps || entry.commands?.length || entry.moreCommands)) {
355
+ lines.push(plainLine(''));
356
+ }
357
+ if (entry.steps) {
358
+ for (const row of wrapText(entry.steps, Math.max(1, width - 2))) {
359
+ lines.push(plainLine(` ${row}`, mutedStyle()));
360
+ }
361
+ }
362
+ for (const command of entry.commands ?? []) {
363
+ const style = command.failed ? { color: 'yellow' } : mutedStyle();
364
+ lines.push(line(span(' $ ', mutedStyle()), span(fitLine(command.text, Math.max(8, width - 4)), style)));
365
+ }
366
+ if (entry.moreCommands) {
367
+ lines.push(plainLine(` + ${entry.moreCommands} more ${entry.moreCommands === 1 ? 'command' : 'commands'}`, mutedStyle()));
368
+ }
369
+ return lines;
370
+ }
338
371
  export function renderTranscriptEntryLines(entry, width) {
372
+ if (entry.kind === 'update')
373
+ return renderUpdateEntryLines(entry, width);
339
374
  const color = getEntryColor(entry.kind);
340
- const lines = [
341
- line(span('● ', { color }), span(entry.title, { color, bold: true })),
342
- ];
343
- lines.push(...(entry.preformatted
344
- ? renderPreformattedBodyLines(entry.body, width, entry.kind)
345
- : renderFormattedBodyLines(entry.body, width, entry.kind)));
375
+ const answer = entry.kind === 'assistant' && entry.title === 'Response' && !entry.preformatted;
376
+ const lines = answer
377
+ ? bulletedBodyLines(entry.body.trim(), width, entry.kind)
378
+ : [line(span('● ', { color }), span(entry.title, { color, bold: true }))];
379
+ if (!answer) {
380
+ lines.push(...(entry.preformatted
381
+ ? renderPreformattedBodyLines(entry.body, width, entry.kind)
382
+ : renderFormattedBodyLines(entry.body, width, entry.kind)));
383
+ }
346
384
  if (entry.diffPreview) {
347
385
  lines.push(...renderDiffPreviewLines(entry.diffPreview, width));
348
386
  }
@@ -373,15 +411,38 @@ function cachedTranscriptEntryLines(entry, width) {
373
411
  byWidth.set(width, lines);
374
412
  return lines;
375
413
  }
376
- function renderDiffPreviewLines(preview, width, maxDiffLines = TRANSCRIPT_DIFF_PREVIEW_LINES) {
377
- return [
378
- plainLine(` Added ${preview.added} line${preview.added === 1 ? '' : 's'}, removed ${preview.removed} line${preview.removed === 1 ? '' : 's'}`, { color: 'gray' }),
379
- ...preview.lines.slice(0, maxDiffLines).map((diffLine) => line(span(`${diffLinePrefix(diffLine.kind)} `, {
380
- color: diffLineColor(diffLine.kind),
381
- }), span(fitLine(diffLine.content || ' ', width - 4), {
382
- color: diffLineColor(diffLine.kind),
383
- }))),
384
- ];
414
+ function renderDiffPreviewLines(preview, width, maxDiffLines = TRANSCRIPT_DIFF_PREVIEW_LINES, { summary = false } = {}) {
415
+ const lines = [];
416
+ if (summary) {
417
+ lines.push(plainLine(` Added ${preview.added} line${preview.added === 1 ? '' : 's'}, removed ${preview.removed} line${preview.removed === 1 ? '' : 's'}`, { color: 'gray' }));
418
+ }
419
+ const shown = preview.lines.slice(0, maxDiffLines);
420
+ const numberWidth = Math.max(0, ...shown.map((diffLine) => (diffLine.lineNumber == null ? 0 : String(diffLine.lineNumber).length)));
421
+ const pad = numberWidth ? ` ${''.padStart(numberWidth)}` : ' ';
422
+ const gutter = (value) => span(numberWidth ? ` ${(value == null ? '' : String(value)).padStart(numberWidth)} ` : ' ', mutedStyle());
423
+ let sawChange = false;
424
+ for (const diffLine of shown) {
425
+ if (diffLine.kind === 'hunk') {
426
+ if (/^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/.test(diffLine.content)) {
427
+ if (sawChange)
428
+ lines.push(line(span(`${pad} ⋮`, mutedStyle())));
429
+ }
430
+ else {
431
+ const note = diffLine.content.replace(/^@@\s*|\s*@@$/g, '').trim();
432
+ if (note)
433
+ lines.push(line(span(`${pad} ${note}`, mutedStyle())));
434
+ }
435
+ continue;
436
+ }
437
+ sawChange = true;
438
+ const color = diffLineColor(diffLine.kind);
439
+ lines.push(line(gutter(diffLine.lineNumber), span(`${diffLinePrefix(diffLine.kind)} `, { color }), span(fitLine(diffLine.content || ' ', Math.max(8, width - (numberWidth ? numberWidth + 5 : 4))), { color })));
440
+ }
441
+ const hidden = preview.lines.slice(maxDiffLines).filter((diffLine) => diffLine.kind !== 'hunk').length;
442
+ if (hidden > 0) {
443
+ lines.push(line(span(`${pad} … +${hidden} more ${hidden === 1 ? 'line' : 'lines'}`, mutedStyle())));
444
+ }
445
+ return lines;
385
446
  }
386
447
  function tokenUsageLines(usage) {
387
448
  const match = usage.match(/^Session tokens • in ([^•]+) • out ([^•]+)(?: • think ([^•]+))? • cache ([^•]+)(?: • write ([^•]+))?$/);
@@ -412,7 +473,7 @@ function footerTransientStatus(status) {
412
473
  if (text === AGENT_MODE_LOCKED_STATUS) {
413
474
  return { color: 'yellow', text, icon: '!' };
414
475
  }
415
- if (text === 'Copied selection' || text === 'Copied link') {
476
+ if (text === 'Copied selection' || text === 'Copied link' || text === 'Copied path') {
416
477
  return { color: 'green', text, icon: '✓' };
417
478
  }
418
479
  if (text === 'Opened link') {
@@ -810,7 +871,6 @@ function buildLiveLines(state, width, spinnerFrame, elapsedSeconds, nowMs) {
810
871
  }
811
872
  }
812
873
  }
813
- lines.push(plainLine(''));
814
874
  return lines;
815
875
  }
816
876
  function lineCharCount(row) {
@@ -1268,7 +1328,7 @@ export function approvalPreviewBudget(height) {
1268
1328
  export function approvalPreviewRows(prompt, innerWidth) {
1269
1329
  const previewWidth = Math.max(8, innerWidth - APPROVAL_SCROLLBAR_COLUMNS);
1270
1330
  if (prompt.diffPreview) {
1271
- return renderDiffPreviewLines(prompt.diffPreview, previewWidth, prompt.diffPreview.lines.length);
1331
+ return renderDiffPreviewLines(prompt.diffPreview, previewWidth, prompt.diffPreview.lines.length, { summary: true });
1272
1332
  }
1273
1333
  return wrapText(prompt.body, previewWidth).map((text) => plainLine(text, { color: OVERLAY_BORDER_COLOR }));
1274
1334
  }
@@ -1502,9 +1562,26 @@ function buildOverlayLines(state, width, height, nowMs) {
1502
1562
  function countSectionLines(sections) {
1503
1563
  return sections.reduce((sum, section) => sum + section.lines.length, 0);
1504
1564
  }
1565
+ function livePanelPinned(state) {
1566
+ return Boolean(state.approvalPrompt ||
1567
+ state.sudoPrompt ||
1568
+ state.userInputPrompt ||
1569
+ state.jobsPickerOpen ||
1570
+ state.shortcutsOpen ||
1571
+ state.modelPickerOpen ||
1572
+ state.skillsPickerOpen ||
1573
+ state.resumePickerOpen);
1574
+ }
1575
+ export function transcriptLiveRowCount(state, cols, spinnerFrame, elapsedSeconds, nowMs = 0) {
1576
+ if (livePanelPinned(state))
1577
+ return 0;
1578
+ return buildLiveLines(state, Math.max(1, frameContentWidth(cols) - 2), spinnerFrame, elapsedSeconds, nowMs).length;
1579
+ }
1505
1580
  export function userInputViewportForFrame(state, cols, rows, spinnerFrame, elapsedSeconds, nowMs = 0) {
1506
1581
  const contentWidth = frameContentWidth(cols);
1507
- const liveRows = buildLiveLines(state, contentWidth, spinnerFrame, elapsedSeconds, nowMs).length;
1582
+ const liveRows = livePanelPinned(state)
1583
+ ? buildLiveLines(state, contentWidth, spinnerFrame, elapsedSeconds, nowMs).length
1584
+ : 0;
1508
1585
  const overlayHeight = Math.max(0, rows - liveRows - composerFooterLines(state, contentWidth).length);
1509
1586
  return {
1510
1587
  width: userInputPanelInnerWidth(contentWidth),
@@ -1532,13 +1609,22 @@ export function buildTuiFrame(state, cols, rows, spinnerFrame, elapsedSeconds, n
1532
1609
  }
1533
1610
  lines.push(...block);
1534
1611
  });
1612
+ if (!livePanelPinned(state)) {
1613
+ lines.push(...buildLiveLines(state, wrapWidth, spinnerFrame, elapsedSeconds, nowMs));
1614
+ }
1535
1615
  return lines;
1536
1616
  };
1537
1617
  let transcriptLines = buildTranscriptLines(contentWidth);
1538
1618
  const sections = [];
1539
- const liveLines = buildLiveLines(state, contentWidth, spinnerFrame, elapsedSeconds, nowMs);
1540
- if (liveLines.length > 0) {
1541
- sections.push({ kind: 'live', lines: liveLines });
1619
+ if (livePanelPinned(state)) {
1620
+ const liveLines = buildLiveLines(state, contentWidth, spinnerFrame, elapsedSeconds, nowMs);
1621
+ const answering = Boolean(state.approvalPrompt || state.sudoPrompt || state.userInputPrompt);
1622
+ if (liveLines.length > 0) {
1623
+ sections.push({
1624
+ kind: 'live',
1625
+ lines: answering ? liveLines : [...liveLines, plainLine('')],
1626
+ });
1627
+ }
1542
1628
  }
1543
1629
  const overlayActive = Boolean(state.approvalPrompt || state.sudoPrompt || state.userInputPrompt);
1544
1630
  if (!state.resumePickerOpen &&
@@ -1585,13 +1671,8 @@ export function buildTuiFrame(state, cols, rows, spinnerFrame, elapsedSeconds, n
1585
1671
  sections.push({ kind: 'overlay', lines: overlayLines });
1586
1672
  }
1587
1673
  const reservedLines = countSectionLines(sections.filter((section) => section.kind !== 'transcript'));
1588
- const composerReserve = state.resumePickerOpen ||
1589
- state.approvalPrompt ||
1590
- state.sudoPrompt ||
1591
- state.userInputPrompt
1592
- ? 0
1593
- : 4;
1594
- const transcriptBudget = Math.max(1, rows - reservedLines - composerReserve - 1);
1674
+ const composerGap = sections.some((section) => section.kind === 'composer') ? 1 : 0;
1675
+ const transcriptBudget = Math.max(1, rows - reservedLines - composerGap - 1);
1595
1676
  let transcriptScrollLimit = Math.max(0, transcriptLines.length - transcriptBudget);
1596
1677
  if (transcriptScrollLimit > 0 && contentWidth > 2) {
1597
1678
  transcriptLines = buildTranscriptLines(contentWidth - 2);
@@ -12,10 +12,14 @@ function parseInlineSegments(text) {
12
12
  const labelEnd = source.indexOf('](', cursor + 1);
13
13
  const urlEnd = labelEnd === -1 ? -1 : source.indexOf(')', labelEnd + 2);
14
14
  if (labelEnd > cursor + 1 && urlEnd > labelEnd + 2) {
15
- const url = normalizeLinkUrl(source.slice(labelEnd + 2, urlEnd));
16
- if (url) {
15
+ const target = source.slice(labelEnd + 2, urlEnd);
16
+ const url = normalizeLinkUrl(target);
17
+ const file = url ? null : normalizeFileLinkTarget(target);
18
+ if (url || file) {
17
19
  const label = source.slice(cursor + 1, labelEnd);
18
- segments.push({ kind: 'link', text: label || url, url });
20
+ segments.push(url
21
+ ? { kind: 'link', text: label || url, url }
22
+ : { kind: 'fileLink', text: label || file, url: file });
19
23
  cursor = urlEnd + 1;
20
24
  continue;
21
25
  }
@@ -66,6 +70,23 @@ function normalizeLinkUrl(value) {
66
70
  return null;
67
71
  }
68
72
  }
73
+ export function normalizeFileLinkTarget(value) {
74
+ let target = String(value ?? '').trim();
75
+ const bracketed = target.startsWith('<') && target.endsWith('>');
76
+ if (bracketed)
77
+ target = target.slice(1, -1).trim();
78
+ if (!target || (!bracketed && /\s/.test(target)))
79
+ return null;
80
+ if (/^file:/i.test(target))
81
+ return target;
82
+ if (/^[a-z][a-z0-9+.-]*:/i.test(target) && !/^[a-z]:[\\/]/i.test(target))
83
+ return null;
84
+ if (target.startsWith('#'))
85
+ return null;
86
+ if (!/[\\/.~]/.test(target))
87
+ return null;
88
+ return target;
89
+ }
69
90
  function isEscapedMarkdownPipe(source, pipeIndex) {
70
91
  let slashCount = 0;
71
92
  for (let index = pipeIndex - 1; index >= 0 && source[index] === '\\'; index--) {
@@ -107,7 +128,7 @@ function isMarkdownTableSeparator(line) {
107
128
  }
108
129
  function stripInlineFormattingForWidth(text) {
109
130
  return String(text ?? '')
110
- .replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, '$1')
131
+ .replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, label, target) => normalizeLinkUrl(target) || normalizeFileLinkTarget(target) ? label : match)
111
132
  .replace(/`([^`]*)`/g, '$1')
112
133
  .replace(/\*\*([^*]+)\*\*/g, '$1');
113
134
  }
@@ -255,6 +276,9 @@ function segmentStyle(segment, bodyColor) {
255
276
  if (segment.kind === 'link') {
256
277
  return { color: 'cyan', underline: true, linkUrl: segment.url };
257
278
  }
279
+ if (segment.kind === 'fileLink') {
280
+ return { color: bodyColor, underline: true, linkUrl: segment.url };
281
+ }
258
282
  return { color: bodyColor };
259
283
  }
260
284
  function styleFromSpan(part) {
@@ -279,6 +303,10 @@ function wrapInlineToLines(text, width, bodyColor, prefix = '') {
279
303
  while (remaining.length > 0) {
280
304
  const limit = safeWidth - (rows.length === 1 && indent ? displayWidth(prefix) : 0);
281
305
  const room = limit - rowWidth;
306
+ if (rowWidth === 0 && rows.length > 1 && /^\s+$/.test(remaining)) {
307
+ remaining = '';
308
+ break;
309
+ }
282
310
  if (room <= 0) {
283
311
  startRow();
284
312
  current = rows[rows.length - 1];
@@ -370,6 +398,8 @@ function getEntryColor(kind) {
370
398
  return 'yellow';
371
399
  case 'tool':
372
400
  return 'blue';
401
+ case 'update':
402
+ return 'green';
373
403
  case 'user':
374
404
  return 'cyan';
375
405
  }
@@ -54,7 +54,7 @@ export function buildShortcutGroups(platform = process.platform) {
54
54
  { keys: 'Drag', description: 'Select and copy' },
55
55
  { keys: 'Double-click', description: 'Copy a word' },
56
56
  { keys: 'Triple-click', description: 'Copy a whole row' },
57
- { keys: 'Left-click', description: 'Open a link' },
57
+ { keys: 'Left-click', description: "Open a web link, or copy a file link's path" },
58
58
  ],
59
59
  },
60
60
  ];
@@ -0,0 +1,175 @@
1
+ export const EMPTY_TURN_STEPS = Object.freeze({
2
+ counts: Object.freeze({}),
3
+ order: Object.freeze([]),
4
+ commands: Object.freeze([]),
5
+ single: '',
6
+ total: 0,
7
+ });
8
+ export const LISTED_COMMANDS = 3;
9
+ const SINGLE_STEP_MAX_CHARS = 96;
10
+ const COMMAND_MAX_CHARS = 200;
11
+ const STEP_KINDS = {
12
+ read_file: 'read',
13
+ read_document: 'read',
14
+ read_image_file: 'read',
15
+ list_files: 'list',
16
+ list_directories: 'list',
17
+ grep_code: 'search',
18
+ search_code: 'search',
19
+ run_node_script: 'script',
20
+ thegitai_web_search: 'webSearch',
21
+ thegitai_web_fetch: 'webPage',
22
+ get_diagnostics: 'check',
23
+ generate_image: 'image',
24
+ use_skill: 'skill',
25
+ recall: 'memory',
26
+ };
27
+ const UNCOUNTED_TOOLS = new Set([
28
+ 'patch_file',
29
+ 'str_replace',
30
+ 'write_file',
31
+ 'delete_file',
32
+ 'undo_edit',
33
+ 'replace_document_text',
34
+ 'update_todos',
35
+ 'remember',
36
+ 'request_user_input',
37
+ 'shell_job_output',
38
+ 'shell_job_kill',
39
+ ]);
40
+ export function stepKindForTool(name) {
41
+ if (UNCOUNTED_TOOLS.has(name) || name === 'run_command')
42
+ return null;
43
+ const known = STEP_KINDS[name];
44
+ if (known)
45
+ return known;
46
+ if (name === 'browser' || name.startsWith('browser_'))
47
+ return 'browser';
48
+ if (name.startsWith('computer_'))
49
+ return 'computer';
50
+ return 'tool';
51
+ }
52
+ function clip(text, max = SINGLE_STEP_MAX_CHARS) {
53
+ const flat = text.replace(/\s+/g, ' ').trim();
54
+ return flat.length > max ? `${flat.slice(0, max - 1).trimEnd()}…` : flat;
55
+ }
56
+ function stepTarget(call, result) {
57
+ return String(call.args?.filePath ?? call.args?.file_path ?? result?.filePath ?? '').trim();
58
+ }
59
+ function describeSingleStep(kind, call, result) {
60
+ const target = stepTarget(call, result);
61
+ switch (kind) {
62
+ case 'read':
63
+ return target ? clip(`Read ${target}`) : '';
64
+ case 'list': {
65
+ const pattern = String(call.args?.pattern ?? '').trim();
66
+ return pattern ? clip(`Listed ${pattern}`) : 'Listed files';
67
+ }
68
+ case 'search': {
69
+ const pattern = String(call.args?.query ?? call.args?.pattern ?? '').trim();
70
+ return pattern ? clip(`Searched "${pattern}"`) : '';
71
+ }
72
+ case 'webSearch': {
73
+ const query = String(call.args?.query ?? '').trim();
74
+ return query ? clip(`Searched the web for "${query}"`) : '';
75
+ }
76
+ case 'webPage': {
77
+ const url = String(call.args?.url ?? '').trim();
78
+ return url ? clip(`Read ${url}`) : '';
79
+ }
80
+ default:
81
+ return '';
82
+ }
83
+ }
84
+ function stepRan(kind, result) {
85
+ if (result?.skipped === true)
86
+ return false;
87
+ if (kind === 'script')
88
+ return true;
89
+ return result?.ok === true;
90
+ }
91
+ function commandStep(call, result) {
92
+ if (result?.skipped === true)
93
+ return null;
94
+ const text = String(call.args?.command ?? result?.command ?? '')
95
+ .split('\n')
96
+ .map((part) => part.trim())
97
+ .filter(Boolean)
98
+ .join(' ↵ ');
99
+ if (!text)
100
+ return null;
101
+ return { text: clip(text, COMMAND_MAX_CHARS), failed: result?.ok !== true };
102
+ }
103
+ export function countStep(steps, call, result) {
104
+ const name = String(call?.name ?? '');
105
+ if (name === 'run_command') {
106
+ const command = commandStep(call, result);
107
+ if (!command)
108
+ return steps;
109
+ return { ...steps, commands: [...steps.commands, command], total: steps.total + 1 };
110
+ }
111
+ const kind = stepKindForTool(name);
112
+ if (!kind || !stepRan(kind, result))
113
+ return steps;
114
+ const seen = steps.counts[kind] ?? 0;
115
+ return {
116
+ ...steps,
117
+ counts: { ...steps.counts, [kind]: seen + 1 },
118
+ order: seen > 0 ? steps.order : [...steps.order, kind],
119
+ single: steps.order.length === 0 ? describeSingleStep(kind, call, result) : '',
120
+ total: steps.total + 1,
121
+ };
122
+ }
123
+ function plural(count, one, many) {
124
+ return count === 1 ? one : many;
125
+ }
126
+ function stepPhrase(kind, count) {
127
+ switch (kind) {
128
+ case 'read':
129
+ return `read ${count} ${plural(count, 'file', 'files')}`;
130
+ case 'list':
131
+ return count === 1 ? 'listed files' : `listed files ${count} times`;
132
+ case 'search':
133
+ return `searched ${count} ${plural(count, 'pattern', 'patterns')}`;
134
+ case 'script':
135
+ return `ran ${count} ${plural(count, 'script', 'scripts')}`;
136
+ case 'webSearch':
137
+ return count === 1 ? 'searched the web' : `searched the web ${count} times`;
138
+ case 'webPage':
139
+ return `read ${count} web ${plural(count, 'page', 'pages')}`;
140
+ case 'browser':
141
+ return `${count} browser ${plural(count, 'step', 'steps')}`;
142
+ case 'computer':
143
+ return `${count} computer ${plural(count, 'step', 'steps')}`;
144
+ case 'check':
145
+ return `ran ${count} ${plural(count, 'check', 'checks')}`;
146
+ case 'image':
147
+ return `generated ${count} ${plural(count, 'image', 'images')}`;
148
+ case 'skill':
149
+ return `loaded ${count} ${plural(count, 'skill', 'skills')}`;
150
+ case 'memory':
151
+ return count === 1 ? 'searched memory' : `searched memory ${count} times`;
152
+ case 'tool':
153
+ return `used ${count} ${plural(count, 'tool', 'tools')}`;
154
+ }
155
+ }
156
+ export function formatTurnSteps(steps) {
157
+ if (steps.order.length === 0)
158
+ return '';
159
+ const counted = steps.order.reduce((sum, kind) => sum + (steps.counts[kind] ?? 0), 0);
160
+ if (counted === 1 && steps.single)
161
+ return steps.single;
162
+ const text = steps.order
163
+ .map((kind) => stepPhrase(kind, steps.counts[kind] ?? 0))
164
+ .join(' · ');
165
+ return text.charAt(0).toUpperCase() + text.slice(1);
166
+ }
167
+ export function turnStepFields(steps) {
168
+ const listed = steps.commands.slice(0, LISTED_COMMANDS);
169
+ const more = steps.commands.length - listed.length;
170
+ return {
171
+ steps: formatTurnSteps(steps) || undefined,
172
+ commands: listed.length ? listed : undefined,
173
+ moreCommands: more > 0 ? more : undefined,
174
+ };
175
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@thegitai/cli",
3
- "version": "1.4.1",
4
- "description": "TheGitAI is an agentic AI coding tool for your terminal. It reads and searches your repository, writes and edits files, runs your tests, verifies the change before handing it back, and remembers your corrections between sessions.",
3
+ "version": "1.5.0",
4
+ "description": "TheGitAI is an AI coding agent. It reads and searches your repository, writes and edits files, runs your tests, verifies the change before handing it back, and remembers your corrections between sessions.",
5
5
  "keywords": [
6
6
  "agentic-ai",
7
7
  "ai-coding-agent",
@@ -46,11 +46,11 @@
46
46
  "@lydell/node-pty-linux-x64": "1.1.0",
47
47
  "@lydell/node-pty-win32-arm64": "1.1.0",
48
48
  "@lydell/node-pty-win32-x64": "1.1.0",
49
- "@thegitai/tui-darwin-arm64": "1.4.1",
50
- "@thegitai/tui-darwin-x64": "1.4.1",
51
- "@thegitai/tui-linux-arm64": "1.4.1",
52
- "@thegitai/tui-linux-x64": "1.4.1",
53
- "@thegitai/tui-win32-x64": "1.4.1",
49
+ "@thegitai/tui-darwin-arm64": "1.5.0",
50
+ "@thegitai/tui-darwin-x64": "1.5.0",
51
+ "@thegitai/tui-linux-arm64": "1.5.0",
52
+ "@thegitai/tui-linux-x64": "1.5.0",
53
+ "@thegitai/tui-win32-x64": "1.5.0",
54
54
  "@vscode/ripgrep": "1.18.0"
55
55
  },
56
56
  "repository": {