@thegitai/cli 1.0.0-preview.66 → 1.0.0-preview.68

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.
@@ -1,7 +1,7 @@
1
1
  import { sessionMcp } from '../mcp-client.js';
2
2
  import { projectModelEffort, readProjectModelEfforts, saveProjectModelEffort } from '../project-model-preferences.js';
3
3
  import { REASONING_EFFORT_LABELS } from '../reasoning-effort.js';
4
- import { basename } from 'node:path';
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
7
  import { AGENT_MODE_LOCKED_STATUS, approvalScrollLimit, buildTuiFrame, formatJobElapsed, formatTodoProgress, pickThinkingFallbackPhrase, renderTranscriptEntryLines, THINKING_FALLBACK_PHRASES, userInputViewportForFrame, } from './tui/build-frame.js';
@@ -10,7 +10,11 @@ import { backendFor, createNotificationQueue, } from './tui/desktop-notification
10
10
  import { readPreferences, writePreferences } from '../preferences.js';
11
11
  import { createTerminalTitleController } from './tui/terminal-title.js';
12
12
  import { captureTerminalWrites, releaseTerminalWrites, } from './tui/terminal-writes.js';
13
- import { getInputCommandToken, getSlashCommandSuggestions, SLASH_COMMANDS, slashCommandMatchesToken, } from './slash-commands.js';
13
+ import { getInputCommandToken, getSlashCommandSuggestions, isSkillSlashCommand, setSkillSlashCommands, SLASH_COMMANDS, slashCommandMatchesToken, } from './slash-commands.js';
14
+ import { buildSkillsPickerItems, SKILLS_ADD_USAGE } from '../skills-command.js';
15
+ import { discoverSkills, personalSkillsRoot, projectSkillsRoot, skillCatalogue, } from '../skills/discovery.js';
16
+ import { installPreparedSkill, parseSkillSource, prepareSkillInstall, preparedSkillHasScripts, } from '../skills/install.js';
17
+ import { BUNDLED_SKILLS } from '../skills/types.js';
14
18
  export { getInputCommandToken, getSlashCommandSuggestions, SLASH_COMMANDS, slashCommandMatchesToken, };
15
19
  import { composerInputWidth, frameContentWidth } from './tui/composer-layout.js';
16
20
  import { agentModeLabel, nextAgentMode, } from '../agent-mode.js';
@@ -746,6 +750,14 @@ export function buildWorkingToolEntry(event, label = event.call.name) {
746
750
  title: call.name === 'shell_job_kill' ? 'Kill job' : 'Job output',
747
751
  };
748
752
  }
753
+ if (call.name === 'use_skill') {
754
+ const name = String(result?.name ?? call.args?.name ?? '').trim().replace(/^\//, '');
755
+ return {
756
+ body: `/${name || 'skill'}${state(result?.alreadyLoaded === true ? ' · already loaded' : ' · loaded')}`,
757
+ kind,
758
+ title: 'Skill',
759
+ };
760
+ }
749
761
  if (call.name === 'run_node_script') {
750
762
  return {
751
763
  body: `node --input-type=module <script via stdin>${state(`\n${formatRunCommandResultState(result)}`)}${error}`,
@@ -1074,6 +1086,9 @@ function createInitialShellState(session, serverModels, debugUi, serverUrl) {
1074
1086
  modelPickerIndex: getDefaultModelPickerIndex(session.modelId, serverModels.models),
1075
1087
  modelPickerOpen: false,
1076
1088
  shortcutsOpen: false,
1089
+ skillsPickerIndex: 0,
1090
+ skillsPickerItems: [],
1091
+ skillsPickerOpen: false,
1077
1092
  transientStatus: null,
1078
1093
  projectRoot: session.rootDir,
1079
1094
  sessionId: session.sessionId,
@@ -1234,15 +1249,17 @@ export function shouldRemountLiveFrameForComposerInputChange(current, nextInput)
1234
1249
  }
1235
1250
  export function applySlashCommandSuggestion(currentInput, suggestion) {
1236
1251
  const token = getInputCommandToken(currentInput);
1252
+ const command = isSkillSlashCommand(suggestion) ? `${suggestion.command} ` : suggestion.command;
1237
1253
  if (!token) {
1238
- return { cursor: suggestion.command.length, input: suggestion.command };
1254
+ return { cursor: command.length, input: command };
1239
1255
  }
1240
1256
  const tokenStart = currentInput.indexOf(token);
1241
1257
  const before = currentInput.slice(0, tokenStart);
1242
1258
  const after = currentInput.slice(tokenStart + token.length);
1259
+ const inserted = after.startsWith(' ') ? suggestion.command : command;
1243
1260
  return {
1244
- cursor: before.length + suggestion.command.length,
1245
- input: `${before}${suggestion.command}${after}`,
1261
+ cursor: before.length + inserted.length,
1262
+ input: `${before}${inserted}${after}`,
1246
1263
  };
1247
1264
  }
1248
1265
  export function insertAtCursor(state, text) {
@@ -1563,7 +1580,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1563
1580
  title: projectLabel,
1564
1581
  body: kind === 'blocked'
1565
1582
  ? 'Waiting for your answer'
1566
- : 'Finished \u2014 your turn',
1583
+ : 'Finished - your turn',
1567
1584
  }, notificationHandle);
1568
1585
  });
1569
1586
  },
@@ -2190,7 +2207,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2190
2207
  body: `${dropped}${buffered.output || '(no output captured)'}`,
2191
2208
  kind: 'system',
2192
2209
  preformatted: true,
2193
- title: `${job.id} output — ${truncate(job.command, 80)}`,
2210
+ title: `${job.id} output - ${truncate(job.command, 80)}`,
2194
2211
  });
2195
2212
  };
2196
2213
  const selectedJobsPickerId = () => {
@@ -2379,7 +2396,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2379
2396
  ...(fellBack
2380
2397
  ? [
2381
2398
  {
2382
- body: `This session's model is no longer available — switched to ${formatModelLabel(resolvedModelId, knownModels.models)}. Conversation history preserved.`,
2399
+ body: `This session's model is no longer available - switched to ${formatModelLabel(resolvedModelId, knownModels.models)}. Conversation history preserved.`,
2383
2400
  kind: 'system',
2384
2401
  title: 'Model',
2385
2402
  },
@@ -2435,8 +2452,8 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2435
2452
  upsertTurnMessage(row, {
2436
2453
  state: 'queued',
2437
2454
  note: autoSubmits
2438
- ? 'not read — sending as the next prompt'
2439
- : 'not read — left in the composer',
2455
+ ? 'not read - sending as the next prompt'
2456
+ : 'not read - left in the composer',
2440
2457
  });
2441
2458
  }
2442
2459
  const existing = store.getState().queuedMessage;
@@ -2533,14 +2550,125 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2533
2550
  });
2534
2551
  }
2535
2552
  catch (error) {
2536
- rollback(`not sent — ${error?.message ?? 'request failed'}`);
2553
+ rollback(`not sent - ${error?.message ?? 'request failed'}`);
2537
2554
  return;
2538
2555
  }
2539
2556
  if (outcome === 'stale') {
2540
- rollback('turn ended — sending as the next prompt');
2557
+ rollback('turn ended - sending as the next prompt');
2541
2558
  }
2542
2559
  };
2543
2560
  const jobWait = createJobWaitTracker(() => session.sessionId);
2561
+ const refreshSkillCommands = () => {
2562
+ try {
2563
+ const local = skillCatalogue(discoverSkills(session.rootDir, session.env));
2564
+ const names = new Set(local.map((skill) => skill.name));
2565
+ setSkillSlashCommands([
2566
+ ...local,
2567
+ ...BUNDLED_SKILLS.filter((skill) => !names.has(skill.name)),
2568
+ ]);
2569
+ }
2570
+ catch {
2571
+ setSkillSlashCommands([]);
2572
+ }
2573
+ };
2574
+ const runSkillsCommand = async (args) => {
2575
+ const builtinCommands = SLASH_COMMANDS.flatMap((option) => [
2576
+ option.command,
2577
+ ...(option.aliases ?? []),
2578
+ ]);
2579
+ if (!args || args === 'list') {
2580
+ refreshSkillCommands();
2581
+ store.update((current) => ({
2582
+ ...current,
2583
+ commandCursor: 0,
2584
+ skillsPickerIndex: 0,
2585
+ skillsPickerItems: buildSkillsPickerItems(session.rootDir, session.env, builtinCommands),
2586
+ skillsPickerOpen: true,
2587
+ }));
2588
+ scheduleLiveFrameRemount();
2589
+ return;
2590
+ }
2591
+ const addMatch = args.match(/^add(?:\s+([\s\S]*))?$/);
2592
+ const project = /(^|\s)--project(\s|$)/.test(args);
2593
+ const sourceText = String(addMatch?.[1] ?? '')
2594
+ .replace(/(^|\s)--project(?=\s|$)/g, ' ')
2595
+ .trim();
2596
+ const source = addMatch && sourceText ? parseSkillSource(sourceText, session.rootDir) : null;
2597
+ if (!source) {
2598
+ appendStaticEntry({
2599
+ body: `Usage: /skills to list skills, or ${SKILLS_ADD_USAGE}`,
2600
+ kind: 'system',
2601
+ title: 'Skills',
2602
+ });
2603
+ return;
2604
+ }
2605
+ const controller = new AbortController();
2606
+ activeTurnAbort = controller;
2607
+ store.update((current) => ({
2608
+ ...current,
2609
+ busy: true,
2610
+ status: 'Fetching skill...',
2611
+ activeTurnInput: `/skills add ${sourceText}`,
2612
+ }));
2613
+ try {
2614
+ const prepared = await prepareSkillInstall(source, session.env, globalThis.fetch, controller.signal);
2615
+ if (!prepared.ok) {
2616
+ appendStaticEntry({
2617
+ body: controller.signal.aborted ? 'Skill install cancelled.' : prepared.error,
2618
+ kind: 'system',
2619
+ title: 'Skills',
2620
+ });
2621
+ return;
2622
+ }
2623
+ const skill = prepared.skill;
2624
+ const targetRoot = project
2625
+ ? projectSkillsRoot(session.rootDir)
2626
+ : personalSkillsRoot(session.env);
2627
+ const destination = joinPath(targetRoot, skill.name);
2628
+ const files = skill.files.map((file) => file.relPath);
2629
+ const shownFiles = files.slice(0, 12).join(', ') + (files.length > 12 ? `, and ${files.length - 12} more` : '');
2630
+ const decision = await openApprovalPrompt({
2631
+ bucket: 'create',
2632
+ title: `Install skill /${skill.name}?`,
2633
+ body: [
2634
+ skill.description,
2635
+ '',
2636
+ `From: ${skill.origin}`,
2637
+ `To: ${destination}`,
2638
+ `Files (${files.length}): ${shownFiles}`,
2639
+ ...(preparedSkillHasScripts(skill)
2640
+ ? ['', 'It includes scripts. Nothing runs now, and the agent still asks before running any command.']
2641
+ : []),
2642
+ ].join('\n'),
2643
+ options: [
2644
+ { label: 'Install', decision: { kind: 'once' } },
2645
+ { label: 'Cancel', decision: { kind: 'deny' } },
2646
+ ],
2647
+ }, controller.signal);
2648
+ if (decision.kind === 'deny') {
2649
+ appendStaticEntry({ body: 'Skill not installed.', kind: 'system', title: 'Skills' });
2650
+ return;
2651
+ }
2652
+ const installed = installPreparedSkill(skill, targetRoot);
2653
+ if (!installed.ok) {
2654
+ appendStaticEntry({ body: installed.error, kind: 'system', title: 'Skills' });
2655
+ return;
2656
+ }
2657
+ refreshSkillCommands();
2658
+ appendStaticEntry({
2659
+ body: `Installed /${skill.name} in ${installed.dir}.\nThe agent can use it from your next message, or run it yourself with /${skill.name}.`,
2660
+ kind: 'system',
2661
+ title: 'Skills',
2662
+ });
2663
+ }
2664
+ finally {
2665
+ if (activeTurnAbort === controller)
2666
+ activeTurnAbort = null;
2667
+ store.update((current) => ({ ...current, busy: false, activeTurnInput: '', status: '' }));
2668
+ await remountTui();
2669
+ await flushQueuedMessage();
2670
+ }
2671
+ };
2544
2672
  const handleSubmit = async (rawInput, { jobFollowUp = false } = {}) => {
2545
2673
  const chunks = jobFollowUp ? [] : store.getState().pastedChunks;
2546
2674
  const expanded = chunks.length
@@ -2548,6 +2676,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2548
2676
  : String(rawInput ?? '');
2549
2677
  const input = expanded.trim();
2550
2678
  const preformatted = chunks.length > 0;
2679
+ refreshSkillCommands();
2551
2680
  if (store.getState().busy) {
2552
2681
  if (!input || exiting)
2553
2682
  return;
@@ -2640,6 +2769,10 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2640
2769
  requestExit();
2641
2770
  return;
2642
2771
  }
2772
+ if (input === '/skills' || input.startsWith('/skills ')) {
2773
+ await runSkillsCommand(input.slice('/skills'.length).trim());
2774
+ return;
2775
+ }
2643
2776
  if (input === '/mcp') {
2644
2777
  const connections = sessionMcp(session);
2645
2778
  const controller = new AbortController();
@@ -2719,7 +2852,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
2719
2852
  return;
2720
2853
  }
2721
2854
  appendStaticEntry({
2722
- body: 'Usage: /jobs — open the jobs picker · /jobs output <id> — full output · /jobs kill <id> — kill one',
2855
+ body: 'Usage: /jobs - open the jobs picker · /jobs output <id> - full output · /jobs kill <id> - kill one',
2723
2856
  kind: 'system',
2724
2857
  title: 'Background jobs',
2725
2858
  });
@@ -3226,6 +3359,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3226
3359
  scheduleJobFollowUp();
3227
3360
  }
3228
3361
  });
3362
+ refreshSkillCommands();
3229
3363
  session.requestSudoPassword = async ({ command, prompt, signal }) => openSudoPasswordPrompt(command, prompt, signal);
3230
3364
  session.requestUserInput = async (request, signal) => openUserInputPrompt(request.questions, signal);
3231
3365
  session.requestPermission = async (request) => {
@@ -8,6 +8,7 @@ export const SLASH_COMMANDS = [
8
8
  },
9
9
  { command: '/new', description: 'start a new conversation; this session remains saved' },
10
10
  { command: '/mcp', description: 'Check MCP connections and available tools' },
11
+ { command: '/skills', description: 'List installed skills, or add one: /skills add <source>' },
11
12
  { command: '/jobs', description: 'Background jobs: pick to view output or kill' },
12
13
  {
13
14
  command: '/notify',
@@ -19,6 +20,23 @@ export const SLASH_COMMANDS = [
19
20
  { command: '/exit', description: 'Quit the current session', aliases: ['/quit'] },
20
21
  ];
21
22
  export const SLASH_COMMAND_SUGGESTION_LIMIT = 5;
23
+ let skillCommands = [];
24
+ export function setSkillSlashCommands(skills) {
25
+ const builtins = new Set(SLASH_COMMANDS.flatMap((option) => [option.command, ...(option.aliases ?? [])]));
26
+ skillCommands = skills
27
+ .filter((skill) => !builtins.has(`/${skill.name}`))
28
+ .map((skill) => ({
29
+ command: `/${skill.name}`,
30
+ description: skill.argumentHint ? `${skill.argumentHint} · ${skill.description}` : skill.description,
31
+ skill: true,
32
+ }));
33
+ }
34
+ export function isSkillSlashCommand(option) {
35
+ return option.skill === true;
36
+ }
37
+ function allSlashCommands() {
38
+ return skillCommands.length ? [...SLASH_COMMANDS, ...skillCommands] : SLASH_COMMANDS;
39
+ }
22
40
  export function getInputCommandToken(input) {
23
41
  const trimmed = String(input ?? '').trimStart();
24
42
  const match = trimmed.match(/^\/[^\s]*/);
@@ -105,7 +123,7 @@ function rankSlashCommands(input) {
105
123
  const token = getInputCommandToken(input).toLowerCase();
106
124
  if (!token)
107
125
  return [];
108
- return SLASH_COMMANDS.map((option, order) => ({
126
+ return allSlashCommands().map((option, order) => ({
109
127
  option,
110
128
  order,
111
129
  score: scoreSlashCommand(option, token),
@@ -9,6 +9,7 @@ import { renderFormattedBodyLines, renderPreformattedBodyLines, } from './markdo
9
9
  import { displayWidth, line, padToWidth, plainLine, sliceToWidth, span, wrapText, } from './text.js';
10
10
  import { isDarkTerminalBackground, mutedColor, mutedStyle } from './terminal-theme.js';
11
11
  import { buildShortcutGroups, shortcutsPanelAvailable, } from './shortcuts.js';
12
+ import { SKILLS_PICKER_ADD_HINT, SKILLS_PICKER_GROUP_TITLES, } from '../../skills-command.js';
12
13
  import { buildUserInputOverlayLines, } from './user-input.js';
13
14
  import { composerPromptLabel, frameContentWidth, splitComposerInput, } from './composer-layout.js';
14
15
  const WORKING_CLOCK_ICON = '◷';
@@ -26,7 +27,7 @@ const APPROVAL_PADDING_MIN_ROWS = 30;
26
27
  const APPROVAL_SCROLLBAR_COLUMNS = 2;
27
28
  const APPROVAL_ACCENT_COLOR = 'cyan';
28
29
  const SUDO_PASSWORD_ASSURANCE = 'The model never sees this. Your password goes straight to sudo on this ' +
29
- 'computer, then is discarded — never sent to our servers, saved, or logged.';
30
+ 'computer, then is discarded - never sent to our servers, saved, or logged.';
30
31
  const SUDO_ASSURANCE_COLOR = 'ansi256(248)';
31
32
  const APPROVAL_SCROLL_STATUS_COLOR = 'ansi256(248)';
32
33
  const APPROVAL_SCROLLBAR_THUMB = '█';
@@ -58,7 +59,7 @@ const MODEL_PICKER_PANEL_MAX_WIDTH = 144;
58
59
  const MODEL_PICKER_PANEL_MARGIN_LINES = 2;
59
60
  const MODEL_PICKER_BORDER_COLOR = 'cyan';
60
61
  const MODEL_PICKER_ACCENT_COLOR = 'cyan';
61
- const MODEL_PICKER_HIGHLIGHT_BG = 'ansi256(87)';
62
+ const MODEL_PICKER_LOCKED_COLOR = 'ansi256(247)';
62
63
  const MODEL_PICKER_META_INDENT = ' ';
63
64
  const COMPOSER_MARKER_PATTERN = /\[Image #\d+\]|\[Pasted Text: [^\]\n]*\]/g;
64
65
  function composerMarkerMask(text) {
@@ -836,12 +837,12 @@ function buildOverlayPanel(rows, width, color, height = Number.POSITIVE_INFINITY
836
837
  ...margin,
837
838
  ];
838
839
  }
839
- function padSpansToInnerWidth(spans, innerWidth, fill) {
840
+ function padSpansToInnerWidth(spans, innerWidth) {
840
841
  const used = spans.reduce((total, part) => total + displayWidth(part.text), 0);
841
842
  const pad = Math.max(0, innerWidth - used);
842
843
  if (pad === 0)
843
844
  return spans;
844
- return [...spans, span(' '.repeat(pad), fill)];
845
+ return [...spans, span(' '.repeat(pad))];
845
846
  }
846
847
  function modelPickerPanelSideLine(content, innerWidth) {
847
848
  return overlayPanelLine(content, innerWidth, MODEL_PICKER_BORDER_COLOR);
@@ -852,8 +853,9 @@ const MODEL_PICKER_MODEL_MAX_WIDTH = 54;
852
853
  const MODEL_PICKER_COLUMN_GAP = ' ';
853
854
  const MODEL_PICKER_WIDE_MIN_WIDTH = 78;
854
855
  function modelPickerTopBorder(panelWidth) {
855
- const fullTitle = ' TheGitAI - Model Selection ';
856
- const compactTitle = ' Model Selection ';
856
+ return pickerTopBorder(panelWidth, ' TheGitAI - Model Selection ', ' Model Selection ');
857
+ }
858
+ function pickerTopBorder(panelWidth, fullTitle, compactTitle) {
857
859
  const title = panelWidth >= fullTitle.length + 4 ? fullTitle : compactTitle;
858
860
  const available = Math.max(0, panelWidth - 2 - [...title].length);
859
861
  const left = Math.floor(available / 2);
@@ -882,7 +884,7 @@ function modelPickerNotesWidth(innerWidth) {
882
884
  MODEL_PICKER_COST_WIDTH -
883
885
  MODEL_PICKER_COLUMN_GAP.length * 2);
884
886
  }
885
- function modelPickerModelSpans(option, selected, effort, width, showCurrentTag, labelStyle, selectedStyle) {
887
+ function modelPickerModelSpans(option, selected, effort, width, showCurrentTag, labelStyle) {
886
888
  const tag = option.current && showCurrentTag ? ' (current)' : '';
887
889
  const effortText = option.group === 'auto' || effort === 'default'
888
890
  ? ''
@@ -890,45 +892,39 @@ function modelPickerModelSpans(option, selected, effort, width, showCurrentTag,
890
892
  const nameWidth = Math.max(1, width - displayWidth(tag + effortText) - 2);
891
893
  const label = `${selected ? '▶ ' : ' '}${fitModelLabel(option.label, nameWidth)}`;
892
894
  const used = displayWidth(label + effortText + tag);
895
+ const locked = option.disabled ? { color: MODEL_PICKER_LOCKED_COLOR } : null;
893
896
  return [
894
- span(label, { ...labelStyle, ...selectedStyle }),
895
- span(effortText, { color: mutedColor(), bold: selected, ...selectedStyle }),
896
- span(tag, { color: 'gray', ...selectedStyle }),
897
- span(' '.repeat(Math.max(0, width - used)), selectedStyle),
897
+ span(label, labelStyle),
898
+ span(effortText, locked ?? { color: mutedColor(), bold: selected }),
899
+ span(tag, locked ?? { color: 'gray' }),
900
+ span(' '.repeat(Math.max(0, width - used))),
898
901
  ];
899
902
  }
900
903
  function modelPickerItemLines(option, selected, effort, innerWidth) {
901
- const selectedStyle = selected ? { bgColor: MODEL_PICKER_HIGHLIGHT_BG } : {};
902
- const labelStyle = option.disabled
903
- ? { color: 'ansi256(247)' }
904
- : selected
905
- ? { color: 'cyan', bold: true }
906
- : {};
904
+ const lockedStyle = option.disabled ? { color: MODEL_PICKER_LOCKED_COLOR } : undefined;
905
+ const labelStyle = lockedStyle ?? (selected ? { color: 'cyan', bold: true } : {});
907
906
  const cost = modelPickerCostText(option.costRating);
908
907
  if (innerWidth < MODEL_PICKER_WIDE_MIN_WIDTH) {
909
908
  const costWidth = 3;
910
909
  const modelWidth = Math.max(12, innerWidth - costWidth - 2);
911
910
  const row = [
912
- ...modelPickerModelSpans(option, selected, effort, modelWidth, false, labelStyle, selectedStyle),
913
- span(' ', selectedStyle),
914
- modelPickerCell(cost, costWidth, selectedStyle),
911
+ ...modelPickerModelSpans(option, selected, effort, modelWidth, false, labelStyle),
912
+ span(' '),
913
+ modelPickerCell(cost, costWidth, lockedStyle),
915
914
  ];
916
915
  return [
917
- modelPickerPanelSideLine(line(...padSpansToInnerWidth(row, innerWidth, selectedStyle)), innerWidth),
916
+ modelPickerPanelSideLine(line(...padSpansToInnerWidth(row, innerWidth)), innerWidth),
918
917
  ];
919
918
  }
920
919
  const row = [
921
- ...modelPickerModelSpans(option, selected, effort, modelPickerModelWidth(innerWidth), true, labelStyle, selectedStyle),
922
- span(MODEL_PICKER_COLUMN_GAP, selectedStyle),
923
- modelPickerCell(cost, MODEL_PICKER_COST_WIDTH, selectedStyle),
924
- span(MODEL_PICKER_COLUMN_GAP, selectedStyle),
925
- modelPickerCell(option.note, modelPickerNotesWidth(innerWidth), {
926
- color: 'gray',
927
- ...selectedStyle,
928
- }),
920
+ ...modelPickerModelSpans(option, selected, effort, modelPickerModelWidth(innerWidth), true, labelStyle),
921
+ span(MODEL_PICKER_COLUMN_GAP),
922
+ modelPickerCell(cost, MODEL_PICKER_COST_WIDTH, lockedStyle),
923
+ span(MODEL_PICKER_COLUMN_GAP),
924
+ modelPickerCell(option.note, modelPickerNotesWidth(innerWidth), lockedStyle ?? { color: 'gray' }),
929
925
  ];
930
926
  return [
931
- modelPickerPanelSideLine(line(...padSpansToInnerWidth(row, innerWidth, selectedStyle)), innerWidth),
927
+ modelPickerPanelSideLine(line(...padSpansToInnerWidth(row, innerWidth)), innerWidth),
932
928
  ];
933
929
  }
934
930
  function modelPickerHeadingLine(title, innerWidth, withColumns) {
@@ -1019,16 +1015,68 @@ function buildModelPickerPanel(options, selectedIndex, width, availableHeight, e
1019
1015
  ] : []), modelPickerPanelSideLine(plainLine(fitLine(hint, innerWidth), { color: 'gray' }), innerWidth), plainLine(`╰${'─'.repeat(panelWidth - 2)}╯`, { color: MODEL_PICKER_BORDER_COLOR }));
1020
1016
  return [...margin, ...body, ...margin];
1021
1017
  }
1018
+ const SKILLS_PICKER_PANEL_MAX_WIDTH = 96;
1019
+ const SKILLS_PICKER_DESCRIPTION_LINES = 3;
1020
+ function skillsPickerDetailLines(item, innerWidth) {
1021
+ const wrapped = wrapText(item.description, innerWidth);
1022
+ const description = wrapped.length > SKILLS_PICKER_DESCRIPTION_LINES
1023
+ ? [
1024
+ ...wrapped.slice(0, SKILLS_PICKER_DESCRIPTION_LINES - 1),
1025
+ fitLine(wrapped.slice(SKILLS_PICKER_DESCRIPTION_LINES - 1).join(' '), innerWidth),
1026
+ ]
1027
+ : wrapped;
1028
+ const descriptionStyle = item.group === 'not-loaded' ? { color: 'yellow', bold: true } : {};
1029
+ return [
1030
+ ...description.map((text) => plainLine(text, descriptionStyle)),
1031
+ ...(item.path ? [plainLine(fitLine(item.path, innerWidth), { color: 'gray' })] : []),
1032
+ ...(item.notes.length ? [plainLine(fitLine(item.notes.join('; '), innerWidth), { color: 'gray' })] : []),
1033
+ ];
1034
+ }
1035
+ export function buildSkillsPickerPanel(items, selectedIndex, width, availableHeight) {
1036
+ const panelWidth = Math.max(28, Math.min(width, SKILLS_PICKER_PANEL_MAX_WIDTH));
1037
+ const innerWidth = Math.max(1, panelWidth - 4);
1038
+ const side = (row) => modelPickerPanelSideLine(row, innerWidth);
1039
+ const rows = [];
1040
+ items.forEach((item, index) => {
1041
+ if (items[index - 1]?.group !== item.group) {
1042
+ rows.push({ kind: 'heading', title: SKILLS_PICKER_GROUP_TITLES[item.group] });
1043
+ }
1044
+ rows.push({ kind: 'item', index });
1045
+ });
1046
+ const detailHeight = Math.max(0, ...items.map((item) => skillsPickerDetailLines(item, innerWidth).length));
1047
+ const selected = items[selectedIndex];
1048
+ const detail = selected ? skillsPickerDetailLines(selected, innerWidth) : [];
1049
+ const addHint = wrapText(SKILLS_PICKER_ADD_HINT, innerWidth);
1050
+ const fullHint = '↑/↓ move • Enter use • Esc close';
1051
+ const hint = [...fullHint].length <= innerWidth ? fullHint : '↑↓ · Enter · Esc';
1052
+ const fixedLineCount = 4 + detailHeight + addHint.length + 1;
1053
+ const visibleCount = Math.min(rows.length, Math.max(1, availableHeight - fixedLineCount));
1054
+ const selectedRow = Math.max(0, rows.findIndex((row) => row.kind === 'item' && row.index === selectedIndex));
1055
+ const firstVisible = Math.max(0, Math.min(selectedRow - visibleCount + 1, rows.length - visibleCount));
1056
+ const body = [pickerTopBorder(panelWidth, ' TheGitAI - Skills ', ' Skills ')];
1057
+ for (const row of rows.slice(firstVisible, firstVisible + visibleCount)) {
1058
+ if (row.kind === 'heading') {
1059
+ body.push(side(modelPickerHeadingLine(row.title, innerWidth, false)));
1060
+ continue;
1061
+ }
1062
+ const item = items[row.index];
1063
+ const isSelected = row.index === selectedIndex;
1064
+ const style = !item.usable
1065
+ ? { color: MODEL_PICKER_LOCKED_COLOR }
1066
+ : isSelected
1067
+ ? { color: 'cyan', bold: true }
1068
+ : {};
1069
+ body.push(side(plainLine(fitLine(`${isSelected ? '▶ ' : ' '}/${item.name}`, innerWidth), style)));
1070
+ }
1071
+ body.push(modelPickerDivider(panelWidth), ...detail.map(side), ...Array.from({ length: detailHeight - detail.length }, () => side(plainLine(''))), side(plainLine('')), ...addHint.map((text) => side(plainLine(text, { color: 'gray' }))), side(plainLine(fitLine(hint, innerWidth), { color: 'gray' })), plainLine(`╰${'─'.repeat(panelWidth - 2)}╯`, { color: MODEL_PICKER_BORDER_COLOR }));
1072
+ const marginLineCount = Math.max(0, Math.min(MODEL_PICKER_PANEL_MARGIN_LINES, Math.floor((availableHeight - body.length) / 2)));
1073
+ const margin = Array.from({ length: marginLineCount }, () => plainLine(''));
1074
+ return [...margin, ...body, ...margin];
1075
+ }
1022
1076
  const SHORTCUTS_PANEL_MAX_WIDTH = 96;
1023
1077
  const SHORTCUTS_KEY_COLUMN_MIN = 10;
1024
1078
  function shortcutsTopBorder(panelWidth) {
1025
- const fullTitle = ' TheGitAI - Keyboard & mouse ';
1026
- const compactTitle = ' Shortcuts ';
1027
- const title = panelWidth >= fullTitle.length + 4 ? fullTitle : compactTitle;
1028
- const available = Math.max(0, panelWidth - 2 - [...title].length);
1029
- const left = Math.floor(available / 2);
1030
- const right = available - left;
1031
- return line(span(`╭${'─'.repeat(left)}`, { color: MODEL_PICKER_BORDER_COLOR }), span(title, { color: MODEL_PICKER_ACCENT_COLOR, bold: true }), span(`${'─'.repeat(right)}╮`, { color: MODEL_PICKER_BORDER_COLOR }));
1079
+ return pickerTopBorder(panelWidth, ' TheGitAI - Keyboard & mouse ', ' Shortcuts ');
1032
1080
  }
1033
1081
  export function buildShortcutsPanel(groups, width, availableHeight) {
1034
1082
  const panelWidth = Math.max(28, Math.min(width, SHORTCUTS_PANEL_MAX_WIDTH));
@@ -1094,31 +1142,26 @@ function commandPaletteSeparatorLine(innerWidth) {
1094
1142
  return modelPickerPanelSideLine(line(span('┈'.repeat(Math.max(1, innerWidth)), { color: 'gray', dim: true })), innerWidth);
1095
1143
  }
1096
1144
  function commandPaletteItemLines(option, selected, innerWidth) {
1097
- const highlight = { bgColor: MODEL_PICKER_HIGHLIGHT_BG };
1098
1145
  if (selected) {
1099
1146
  const titleSpans = padSpansToInnerWidth([
1100
1147
  span('▌', {
1101
1148
  color: MODEL_PICKER_ACCENT_COLOR,
1102
1149
  bold: true,
1103
- ...highlight,
1104
1150
  }),
1105
1151
  span('▶ ', {
1106
1152
  color: MODEL_PICKER_ACCENT_COLOR,
1107
1153
  bold: true,
1108
- ...highlight,
1109
1154
  }),
1110
1155
  span(option.command, {
1111
1156
  color: MODEL_PICKER_ACCENT_COLOR,
1112
1157
  bold: true,
1113
- ...highlight,
1114
1158
  }),
1115
- ], innerWidth, highlight);
1159
+ ], innerWidth);
1116
1160
  const metaSpans = padSpansToInnerWidth([
1117
- span(`${MODEL_PICKER_META_INDENT}${option.description}`, {
1161
+ span(fitLine(`${MODEL_PICKER_META_INDENT}${option.description}`, innerWidth), {
1118
1162
  color: 'gray',
1119
- ...highlight,
1120
1163
  }),
1121
- ], innerWidth, highlight);
1164
+ ], innerWidth);
1122
1165
  return [
1123
1166
  modelPickerPanelSideLine(line(...titleSpans), innerWidth),
1124
1167
  modelPickerPanelSideLine(line(...metaSpans), innerWidth),
@@ -1126,7 +1169,7 @@ function commandPaletteItemLines(option, selected, innerWidth) {
1126
1169
  }
1127
1170
  return [
1128
1171
  modelPickerPanelSideLine(line(span(' ', { color: 'gray' }), span(option.command, { color: MODEL_PICKER_ACCENT_COLOR })), innerWidth),
1129
- modelPickerPanelSideLine(line(span(`${MODEL_PICKER_META_INDENT}${option.description}`, { color: 'gray' })), innerWidth),
1172
+ modelPickerPanelSideLine(line(span(fitLine(`${MODEL_PICKER_META_INDENT}${option.description}`, innerWidth), { color: 'gray' })), innerWidth),
1130
1173
  ];
1131
1174
  }
1132
1175
  function buildCommandPalettePanel(suggestions, selectedIndex, hiddenCount, width) {
@@ -1335,6 +1378,9 @@ function buildOverlayLines(state, width, height, nowMs) {
1335
1378
  if (state.shortcutsOpen) {
1336
1379
  lines.push(...buildShortcutsPanel(buildShortcutGroups(), width, height));
1337
1380
  }
1381
+ if (state.skillsPickerOpen) {
1382
+ lines.push(...buildSkillsPickerPanel(state.skillsPickerItems ?? [], state.skillsPickerIndex ?? 0, width, height));
1383
+ }
1338
1384
  if (state.modelPickerOpen) {
1339
1385
  const options = buildModelPickerOptions(state.currentModelId, state.serverModels);
1340
1386
  lines.push(...buildModelPickerPanel(options, state.modelPickerIndex, width, height, state.modelPickerEfforts, pausedModelCount(state.serverModels)));
@@ -1399,6 +1445,7 @@ function buildOverlayLines(state, width, height, nowMs) {
1399
1445
  if (!state.busy &&
1400
1446
  !state.exiting &&
1401
1447
  !state.modelPickerOpen &&
1448
+ !state.skillsPickerOpen &&
1402
1449
  !state.resumePickerOpen &&
1403
1450
  state.input.trimStart().startsWith('/') &&
1404
1451
  !state.input.includes(' ') &&
@@ -1453,6 +1500,7 @@ export function buildTuiFrame(state, cols, rows, spinnerFrame, elapsedSeconds, n
1453
1500
  !state.modelPickerOpen &&
1454
1501
  !state.jobsPickerOpen &&
1455
1502
  !state.shortcutsOpen &&
1503
+ !state.skillsPickerOpen &&
1456
1504
  !overlayActive) {
1457
1505
  const composerLines = [];
1458
1506
  if (state.busy && state.status === 'Starting a new conversation...') {
@@ -1484,7 +1532,7 @@ export function buildTuiFrame(state, cols, rows, spinnerFrame, elapsedSeconds, n
1484
1532
  }
1485
1533
  const overlayHeight = state.userInputPrompt
1486
1534
  ? Math.max(0, rows - countSectionLines(sections))
1487
- : state.jobsPickerOpen || state.shortcutsOpen || state.modelPickerOpen
1535
+ : state.jobsPickerOpen || state.shortcutsOpen || state.modelPickerOpen || state.skillsPickerOpen
1488
1536
  ? Math.max(Math.min(rows, JOBS_PICKER_MIN_ROWS), rows - countSectionLines(sections))
1489
1537
  : rows;
1490
1538
  const overlayLines = buildOverlayLines(state, contentWidth, overlayHeight, nowMs);
@@ -54,7 +54,8 @@ function shouldShowCommandPalette(state) {
54
54
  state.exiting ||
55
55
  state.jobsPickerOpen ||
56
56
  state.modelPickerOpen ||
57
- state.resumePickerOpen) {
57
+ state.resumePickerOpen ||
58
+ state.skillsPickerOpen) {
58
59
  return false;
59
60
  }
60
61
  const token = getInputCommandToken(state.input);
@@ -103,6 +104,7 @@ function pasteTextFromClipboard(store, handlers) {
103
104
  current.jobsPickerOpen ||
104
105
  current.modelPickerOpen ||
105
106
  current.resumePickerOpen ||
107
+ current.skillsPickerOpen ||
106
108
  current.sudoPrompt) {
107
109
  return;
108
110
  }
@@ -437,6 +439,36 @@ export function handleShellKeyEvent(store, handlers, event) {
437
439
  }
438
440
  return;
439
441
  }
442
+ if (state.skillsPickerOpen) {
443
+ if (key.escape) {
444
+ handlers.onLiveFrameShapeChange();
445
+ store.update((current) => ({ ...current, skillsPickerOpen: false }));
446
+ return;
447
+ }
448
+ if (key.upArrow || key.downArrow) {
449
+ store.update((current) => {
450
+ const count = (current.skillsPickerItems ?? []).length;
451
+ const next = (current.skillsPickerIndex ?? 0) + (key.upArrow ? -1 : 1);
452
+ return { ...current, skillsPickerIndex: Math.max(0, Math.min(next, count - 1)) };
453
+ });
454
+ return;
455
+ }
456
+ if (key.returnKey) {
457
+ const item = (state.skillsPickerItems ?? [])[state.skillsPickerIndex ?? 0];
458
+ if (!item?.usable)
459
+ return;
460
+ const input = `/${item.name} `;
461
+ handlers.onLiveFrameShapeChange();
462
+ store.update((current) => ({
463
+ ...current,
464
+ commandCursor: 0,
465
+ cursor: input.length,
466
+ input,
467
+ skillsPickerOpen: false,
468
+ }));
469
+ }
470
+ return;
471
+ }
440
472
  if (state.shortcutsOpen) {
441
473
  if (key.escape || key.returnKey || key.input === '?' || key.input === 'q') {
442
474
  handlers.onLiveFrameShapeChange();
@@ -22,11 +22,11 @@ export function buildShortcutGroups(platform = process.platform) {
22
22
  keys: 'Shift+Tab',
23
23
  description: `Cycle ${agentModeCycleSequence()} (between turns)`,
24
24
  },
25
- { keys: '/', description: 'Slash commands — /help lists them all' },
25
+ { keys: '/', description: 'Slash commands - /help lists them all' },
26
26
  { keys: '↑ / ↓', description: 'Earlier prompts' },
27
27
  { keys: 'Esc', description: 'Clear the composer' },
28
28
  { keys: 'Ctrl+C', description: 'Clear the composer, or quit when empty' },
29
- { keys: 'Ctrl+G', description: 'Desktop notifications — toggle on or off' },
29
+ { keys: 'Ctrl+G', description: 'Desktop notifications - toggle on or off' },
30
30
  ],
31
31
  },
32
32
  {
@@ -50,7 +50,7 @@ export function buildShortcutGroups(platform = process.platform) {
50
50
  {
51
51
  title: 'Transcript',
52
52
  rows: [
53
- { keys: 'PageUp / PageDown', description: 'Scroll — the mouse wheel works too' },
53
+ { keys: 'PageUp / PageDown', description: 'Scroll - the mouse wheel works too' },
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' },