@thegitai/cli 1.0.0-preview.59 → 1.0.0-preview.60

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
@@ -69,11 +69,15 @@ again on the next run.
69
69
 
70
70
  ## Models and reasoning effort
71
71
 
72
- Type `/model` to choose a model with **↑ / ↓** and adjust its reasoning effort
73
- with **← / →** in the same panel: **Default / Low / Balanced / Deep**.
72
+ Type `/model` to choose with **↑ / ↓**. The **Auto** options come first: Cost
73
+ Efficient, Fastest and Most Intelligent. Auto picks the model and its reasoning
74
+ effort for each session, and new installs start on Auto (Cost Efficient). The
75
+ named models follow under **Models**; for one of them, adjust its reasoning
76
+ effort with **← / →** in the same panel: **Default / Low / Balanced / Deep**.
74
77
  **Enter** saves the selected model's choice for this project; **Esc** cancels.
75
78
  Each model remembers its own choice across new and resumed sessions.
76
- The picker and footer show the effort beside the model name. The footer labels
79
+ The picker shows a model's effort beside its name when it is not Default, and
80
+ the footer always shows it, except on Auto, which sets its own. The footer labels
77
81
  agent mode separately as `Mode: ...`; narrow terminals place it on the next
78
82
  line, keeping both settings visible while idle and working.
79
83
 
@@ -14,7 +14,13 @@ function sanitizeModelInfo(raw) {
14
14
  if (!Number.isInteger(id) || id <= 0 || !label || !isCostRating(costRating)) {
15
15
  return null;
16
16
  }
17
- return { id, label, costRating, description };
17
+ return {
18
+ id,
19
+ label,
20
+ costRating,
21
+ description,
22
+ ...(value.auto === true ? { auto: true } : {}),
23
+ };
18
24
  }
19
25
  function isCostRating(value) {
20
26
  return Number.isInteger(value) && value >= 1 && value <= 3;
@@ -1356,16 +1356,23 @@ export function busyElapsedSeconds(state, nowMs) {
1356
1356
  return Math.floor((busyElapsedMs(state, nowMs) ?? 0) / 1000);
1357
1357
  }
1358
1358
  export function buildModelPickerOptions(currentModelId, serverModels) {
1359
- return serverModels.map((model) => ({
1359
+ return [
1360
+ ...serverModels.filter((model) => model.auto),
1361
+ ...serverModels.filter((model) => !model.auto),
1362
+ ].map((model) => ({
1360
1363
  id: model.id,
1361
- label: model.label,
1364
+ label: model.auto ? autoOptionLabel(model.label) : model.label,
1362
1365
  publicId: model.id,
1363
1366
  costRating: model.costRating,
1364
1367
  current: model.id === currentModelId,
1365
1368
  disabled: false,
1369
+ group: model.auto ? 'auto' : 'models',
1366
1370
  note: model.description,
1367
1371
  }));
1368
1372
  }
1373
+ function autoOptionLabel(label) {
1374
+ return /^Auto \((.+)\)$/.exec(label)?.[1] ?? label;
1375
+ }
1369
1376
  function getDefaultModelPickerIndex(currentModelId, serverModels) {
1370
1377
  const options = buildModelPickerOptions(currentModelId, serverModels);
1371
1378
  const currentIndex = options.findIndex((option) => option.id === currentModelId);
@@ -2101,7 +2108,9 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2101
2108
  return;
2102
2109
  syncShellStateFromSession();
2103
2110
  appendStaticEntry({
2104
- body: `${formatModelLabel(selected, fresh.models)} · ${REASONING_EFFORT_LABELS[store.getState().reasoningEffort]} effort${effort === undefined ? '' : '\nSaved for this model in this project.'}`,
2111
+ body: fresh.models.some((model) => model.id === selected && model.auto)
2112
+ ? formatModelLabel(selected, fresh.models)
2113
+ : `${formatModelLabel(selected, fresh.models)} · ${REASONING_EFFORT_LABELS[store.getState().reasoningEffort]} effort${effort === undefined ? '' : '\nSaved for this model in this project.'}`,
2105
2114
  kind: 'system',
2106
2115
  title: 'Model',
2107
2116
  });
@@ -3,7 +3,7 @@ import { projectModelEffort } from '../../project-model-preferences.js';
3
3
  import { REASONING_EFFORTS, REASONING_EFFORT_LABELS, REASONING_EFFORT_DESCRIPTIONS } from '../../reasoning-effort.js';
4
4
  import { agentModeColor, agentModeLabelTiers, agentModeShortLabel, } from '../../agent-mode.js';
5
5
  import { singleLinePreview, truncate } from '../../utils.js';
6
- import { formatClientTokenUsage } from '../repl.js';
6
+ import { buildModelPickerOptions, formatClientTokenUsage } from '../repl.js';
7
7
  import { getHiddenSlashCommandCount, getSlashCommandSuggestions, } from '../slash-commands.js';
8
8
  import { renderFormattedBodyLines, renderPreformattedBodyLines, } from './markdown-render.js';
9
9
  import { displayWidth, line, padToWidth, plainLine, sliceToWidth, span, wrapText, } from './text.js';
@@ -193,17 +193,6 @@ export function formatPromptDirectoryLabel(projectRoot, homeDir = process.env.HO
193
193
  export function formatPromptSessionIdLabel(showSessionId, sessionId) {
194
194
  return showSessionId ? String(sessionId ?? '').trim() : '';
195
195
  }
196
- function buildModelPickerOptions(currentModelId, serverModels) {
197
- return serverModels.map((model) => ({
198
- id: model.id,
199
- label: model.label,
200
- publicId: model.id,
201
- costRating: model.costRating,
202
- current: model.id === currentModelId,
203
- disabled: false,
204
- note: model.description,
205
- }));
206
- }
207
196
  export { getSlashCommandSuggestions };
208
197
  function formatModelLabel(modelId, serverModels) {
209
198
  return serverModels.find((model) => model.id === modelId)?.label ?? 'Unknown model';
@@ -538,7 +527,8 @@ function composerFooterLines(state, contentWidth) {
538
527
  }
539
528
  function composerFooterModeLines(state, contentWidth, modelLabel, usageWidth, usageSpans) {
540
529
  const effort = REASONING_EFFORT_LABELS[state.reasoningEffort ?? 'default'];
541
- const effortText = ` · ${effort} effort`;
530
+ const onAuto = state.serverModels.some((model) => model.id === state.currentModelId && model.auto);
531
+ const effortText = onAuto ? '' : ` · ${effort} effort`;
542
532
  const modeLabels = agentModeLabelTiers(state.agentMode).map((label) => `Mode: ${label}`);
543
533
  const modeWidth = displayWidth(modeLabels[0]);
544
534
  const separateUsage = usageWidth > 0 && modeWidth + usageWidth > contentWidth;
@@ -852,7 +842,7 @@ function modelPickerPanelSideLine(content, innerWidth) {
852
842
  const MODEL_PICKER_COST_WIDTH = 6;
853
843
  const MODEL_PICKER_MODEL_MIN_WIDTH = 42;
854
844
  const MODEL_PICKER_MODEL_MAX_WIDTH = 54;
855
- const MODEL_PICKER_SEPARATOR = ' │ ';
845
+ const MODEL_PICKER_COLUMN_GAP = ' ';
856
846
  const MODEL_PICKER_WIDE_MIN_WIDTH = 78;
857
847
  function modelPickerTopBorder(panelWidth) {
858
848
  const fullTitle = ' TheGitAI - Model Selection ';
@@ -877,17 +867,19 @@ function modelPickerCostText(rating) {
877
867
  return '$'.repeat(steps);
878
868
  }
879
869
  function modelPickerModelWidth(innerWidth) {
880
- return Math.min(MODEL_PICKER_MODEL_MAX_WIDTH, Math.max(MODEL_PICKER_MODEL_MIN_WIDTH, innerWidth - MODEL_PICKER_COST_WIDTH - MODEL_PICKER_SEPARATOR.length * 2 - 18));
870
+ return Math.min(MODEL_PICKER_MODEL_MAX_WIDTH, Math.max(MODEL_PICKER_MODEL_MIN_WIDTH, innerWidth - MODEL_PICKER_COST_WIDTH - MODEL_PICKER_COLUMN_GAP.length * 2 - 18));
881
871
  }
882
872
  function modelPickerNotesWidth(innerWidth) {
883
873
  return Math.max(18, innerWidth -
884
874
  modelPickerModelWidth(innerWidth) -
885
875
  MODEL_PICKER_COST_WIDTH -
886
- MODEL_PICKER_SEPARATOR.length * 2);
876
+ MODEL_PICKER_COLUMN_GAP.length * 2);
887
877
  }
888
878
  function modelPickerModelSpans(option, selected, effort, width, showCurrentTag, labelStyle, selectedStyle) {
889
879
  const tag = option.current && showCurrentTag ? ' (current)' : '';
890
- const effortText = ` · ${REASONING_EFFORT_LABELS[effort]}`;
880
+ const effortText = option.group === 'auto' || effort === 'default'
881
+ ? ''
882
+ : ` · ${REASONING_EFFORT_LABELS[effort]}`;
891
883
  const nameWidth = Math.max(1, width - displayWidth(tag + effortText) - 2);
892
884
  const label = `${selected ? '▶ ' : ' '}${fitModelLabel(option.label, nameWidth)}`;
893
885
  const used = displayWidth(label + effortText + tag);
@@ -920,9 +912,9 @@ function modelPickerItemLines(option, selected, effort, innerWidth) {
920
912
  }
921
913
  const row = [
922
914
  ...modelPickerModelSpans(option, selected, effort, modelPickerModelWidth(innerWidth), true, labelStyle, selectedStyle),
923
- span(MODEL_PICKER_SEPARATOR, { color: 'gray', ...selectedStyle }),
915
+ span(MODEL_PICKER_COLUMN_GAP, selectedStyle),
924
916
  modelPickerCell(cost, MODEL_PICKER_COST_WIDTH, selectedStyle),
925
- span(MODEL_PICKER_SEPARATOR, { color: 'gray', ...selectedStyle }),
917
+ span(MODEL_PICKER_COLUMN_GAP, selectedStyle),
926
918
  modelPickerCell(option.note, modelPickerNotesWidth(innerWidth), {
927
919
  color: 'gray',
928
920
  ...selectedStyle,
@@ -932,50 +924,77 @@ function modelPickerItemLines(option, selected, effort, innerWidth) {
932
924
  modelPickerPanelSideLine(line(...padSpansToInnerWidth(row, innerWidth, selectedStyle)), innerWidth),
933
925
  ];
934
926
  }
935
- function modelPickerHeaderLine(innerWidth) {
927
+ function modelPickerHeadingLine(title, innerWidth, withColumns) {
936
928
  const heading = { color: MODEL_PICKER_ACCENT_COLOR, bold: true };
937
- if (innerWidth < MODEL_PICKER_WIDE_MIN_WIDTH) {
938
- return line(modelPickerCell('Model · effort', Math.max(1, innerWidth), heading));
929
+ if (!withColumns || innerWidth < MODEL_PICKER_WIDE_MIN_WIDTH) {
930
+ return line(modelPickerCell(title, Math.max(1, innerWidth), heading));
939
931
  }
940
- return line(modelPickerCell('Model · effort', modelPickerModelWidth(innerWidth), heading), span(MODEL_PICKER_SEPARATOR, { color: 'gray' }), modelPickerCell('Cost', MODEL_PICKER_COST_WIDTH, heading), span(MODEL_PICKER_SEPARATOR, { color: 'gray' }), modelPickerCell('Notes', modelPickerNotesWidth(innerWidth), heading));
932
+ const muted = { color: 'gray' };
933
+ return line(modelPickerCell(title, modelPickerModelWidth(innerWidth), heading), span(MODEL_PICKER_COLUMN_GAP), modelPickerCell('Cost', MODEL_PICKER_COST_WIDTH, muted), span(MODEL_PICKER_COLUMN_GAP), modelPickerCell('Notes', modelPickerNotesWidth(innerWidth), muted));
934
+ }
935
+ function modelPickerDisplayRows(options) {
936
+ const rows = [];
937
+ const autoIndexes = options.flatMap((option, index) => (option.group === 'auto' ? [index] : []));
938
+ const modelIndexes = options.flatMap((option, index) => (option.group === 'models' ? [index] : []));
939
+ if (autoIndexes.length) {
940
+ rows.push({ kind: 'heading', title: 'Auto', withColumns: true });
941
+ rows.push(...autoIndexes.map((index) => ({ kind: 'option', index })));
942
+ }
943
+ if (modelIndexes.length) {
944
+ if (rows.length)
945
+ rows.push({ kind: 'gap' });
946
+ rows.push({ kind: 'heading', title: 'Models', withColumns: rows.length === 0 });
947
+ rows.push(...modelIndexes.map((index) => ({ kind: 'option', index })));
948
+ }
949
+ return rows;
941
950
  }
942
951
  function buildModelPickerPanel(options, selectedIndex, width, availableHeight, efforts = {}) {
943
952
  const panelWidth = Math.max(28, Math.min(width, MODEL_PICKER_PANEL_MAX_WIDTH));
944
953
  const innerWidth = Math.max(1, panelWidth - 4);
945
- const showEffortDetails = options.length + 10 <= availableHeight;
946
- const fixedLineCount = showEffortDetails ? 10 : 7;
947
- const visibleCount = Math.min(options.length, Math.max(1, availableHeight - fixedLineCount));
948
- const firstVisible = Math.max(0, Math.min(selectedIndex - visibleCount + 1, options.length - visibleCount));
949
- const visibleOptions = options.slice(firstVisible, firstVisible + visibleCount);
950
- const compactBodyLineCount = visibleOptions.length + fixedLineCount;
951
- const spacerLineCount = Math.max(0, visibleOptions.length - 1);
952
- const useRowSpacing = compactBodyLineCount + spacerLineCount <= availableHeight;
953
- const bodyLineCount = compactBodyLineCount + (useRowSpacing ? spacerLineCount : 0);
954
+ const rows = modelPickerDisplayRows(options);
955
+ const showEffortDetails = rows.length + 8 <= availableHeight;
956
+ const fixedLineCount = showEffortDetails ? 8 : 5;
957
+ const visibleCount = Math.min(rows.length, Math.max(1, availableHeight - fixedLineCount));
958
+ const selectedRow = Math.max(0, rows.findIndex((row) => row.kind === 'option' && row.index === selectedIndex));
959
+ const firstVisible = Math.max(0, Math.min(selectedRow - visibleCount + 1, rows.length - visibleCount));
960
+ const visibleRows = rows.slice(firstVisible, firstVisible + visibleCount);
961
+ const bodyLineCount = visibleRows.length + fixedLineCount;
954
962
  const marginLineCount = Math.max(0, Math.min(MODEL_PICKER_PANEL_MARGIN_LINES, Math.floor((availableHeight - bodyLineCount) / 2)));
955
963
  const margin = Array.from({ length: marginLineCount }, () => plainLine(''));
956
- const body = [
957
- modelPickerTopBorder(panelWidth),
958
- modelPickerPanelSideLine(modelPickerHeaderLine(innerWidth), innerWidth),
959
- modelPickerDivider(panelWidth),
960
- ];
961
- visibleOptions.forEach((option, index) => {
962
- body.push(...modelPickerItemLines(option, firstVisible + index === selectedIndex, projectModelEffort(efforts, option.publicId), innerWidth));
963
- if (useRowSpacing && index < visibleOptions.length - 1) {
964
+ const body = [modelPickerTopBorder(panelWidth)];
965
+ for (const row of visibleRows) {
966
+ if (row.kind === 'heading') {
967
+ body.push(modelPickerPanelSideLine(modelPickerHeadingLine(row.title, innerWidth, row.withColumns), innerWidth));
968
+ }
969
+ else if (row.kind === 'gap') {
964
970
  body.push(modelPickerPanelSideLine(plainLine(''), innerWidth));
965
971
  }
966
- });
967
- const selectedEffort = projectModelEffort(efforts, options[selectedIndex]?.publicId ?? 0);
972
+ else {
973
+ const option = options[row.index];
974
+ body.push(...modelPickerItemLines(option, row.index === selectedIndex, projectModelEffort(efforts, option.publicId), innerWidth));
975
+ }
976
+ }
977
+ const selected = options[selectedIndex];
978
+ const selectedEffort = projectModelEffort(efforts, selected?.publicId ?? 0);
979
+ const autoSelected = selected?.group === 'auto';
968
980
  const effortChoices = REASONING_EFFORTS.map((effort) => effort === selectedEffort ? `[${REASONING_EFFORT_LABELS[effort]}]` : REASONING_EFFORT_LABELS[effort]).join(' ');
969
- const fullEffort = `Reasoning effort: ${effortChoices}`;
981
+ const fullEffort = autoSelected ? 'Reasoning effort: Auto Adjusted' : `Reasoning effort: ${effortChoices}`;
970
982
  const effortText = [...fullEffort].length <= innerWidth
971
983
  ? fullEffort
972
- : `Effort: ${REASONING_EFFORT_LABELS[selectedEffort]} ←/→`;
973
- const fullHint = '↑/↓ model • ←/→ effort • Enter select/save • Esc cancel';
974
- const compactHint = '↑↓ · ←→ · Enter · Esc';
984
+ : autoSelected
985
+ ? 'Effort: Auto Adjusted'
986
+ : `Effort: ${REASONING_EFFORT_LABELS[selectedEffort]} ←/→`;
987
+ const effortDescription = autoSelected
988
+ ? 'Auto picks the model and its reasoning effort for each session.'
989
+ : REASONING_EFFORT_DESCRIPTIONS[selectedEffort];
990
+ const fullHint = autoSelected
991
+ ? '↑/↓ model • Enter select • Esc cancel'
992
+ : '↑/↓ model • ←/→ effort • Enter select/save • Esc cancel';
993
+ const compactHint = autoSelected ? '↑↓ · Enter · Esc' : '↑↓ · ←→ · Enter · Esc';
975
994
  const hint = [...fullHint].length <= innerWidth ? fullHint : compactHint;
976
995
  body.push(modelPickerDivider(panelWidth), modelPickerPanelSideLine(plainLine(fitLine(effortText, innerWidth), { color: 'cyan', bold: true }), innerWidth), ...(showEffortDetails ? [
977
996
  modelPickerPanelSideLine(plainLine(''), innerWidth),
978
- modelPickerPanelSideLine(plainLine(fitLine(REASONING_EFFORT_DESCRIPTIONS[selectedEffort], innerWidth), { color: 'gray' }), innerWidth),
997
+ modelPickerPanelSideLine(plainLine(fitLine(effortDescription, innerWidth), { color: 'gray' }), innerWidth),
979
998
  modelPickerPanelSideLine(plainLine(''), innerWidth),
980
999
  ] : []), modelPickerPanelSideLine(plainLine(fitLine(hint, innerWidth), { color: 'gray' }), innerWidth), plainLine(`╰${'─'.repeat(panelWidth - 2)}╯`, { color: MODEL_PICKER_BORDER_COLOR }));
981
1000
  return [...margin, ...body, ...margin];
@@ -376,7 +376,7 @@ export function handleShellKeyEvent(store, handlers, event) {
376
376
  store.update((current) => {
377
377
  const options = buildModelPickerOptions(Number(current.currentModelId ?? 0), current.serverModels ?? []);
378
378
  const model = options[current.modelPickerIndex];
379
- if (!model)
379
+ if (!model || model.group === 'auto')
380
380
  return current;
381
381
  const efforts = current.modelPickerEfforts ?? {};
382
382
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thegitai/cli",
3
- "version": "1.0.0-preview.59",
3
+ "version": "1.0.0-preview.60",
4
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, and verifies the change before handing it back.",
5
5
  "keywords": [
6
6
  "agentic-ai",
@@ -45,11 +45,11 @@
45
45
  "@lydell/node-pty-linux-x64": "1.1.0",
46
46
  "@lydell/node-pty-win32-arm64": "1.1.0",
47
47
  "@lydell/node-pty-win32-x64": "1.1.0",
48
- "@thegitai/tui-darwin-arm64": "1.0.0-preview.59",
49
- "@thegitai/tui-darwin-x64": "1.0.0-preview.59",
50
- "@thegitai/tui-linux-arm64": "1.0.0-preview.59",
51
- "@thegitai/tui-linux-x64": "1.0.0-preview.59",
52
- "@thegitai/tui-win32-x64": "1.0.0-preview.59",
48
+ "@thegitai/tui-darwin-arm64": "1.0.0-preview.60",
49
+ "@thegitai/tui-darwin-x64": "1.0.0-preview.60",
50
+ "@thegitai/tui-linux-arm64": "1.0.0-preview.60",
51
+ "@thegitai/tui-linux-x64": "1.0.0-preview.60",
52
+ "@thegitai/tui-win32-x64": "1.0.0-preview.60",
53
53
  "@vscode/ripgrep": "1.18.0"
54
54
  },
55
55
  "repository": {