Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): add inline TUI argument completion (#3637)

OwenKephart513262593b79
diff --git a/.changeset/inline-tui-argument-completion.md b/.changeset/inline-tui-argument-completion.md
new file mode 100644
index 000000000..06c1b5471
--- /dev/null
+++ b/.changeset/inline-tui-argument-completion.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Add inline, keyboard-navigable catalog completions for `/model` and `/add` in the development TUI.
diff --git a/packages/eve/src/cli/dev/tui/argument-typeahead.test.ts b/packages/eve/src/cli/dev/tui/argument-typeahead.test.ts
new file mode 100644
index 000000000..b77a7c48d
--- /dev/null
+++ b/packages/eve/src/cli/dev/tui/argument-typeahead.test.ts
@@ -0,0 +1,121 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ argumentTypeaheadCompletion,
+ argumentTypeaheadFor,
+ argumentTypeaheadQuery,
+ moveArgumentTypeaheadSelection,
+ renderArgumentSuggestions,
+ selectedArgumentSuggestion,
+} from "./argument-typeahead.js";
+import { stripAnsi } from "#cli/ui/terminal-text.js";
+import { createTheme } from "./theme.js";
+
+const models = [
+ {
+ value: "anthropic/claude-sonnet",
+ label: "Claude Sonnet",
+ hint: "Anthropic",
+ next: [
+ { value: "default", label: "default" },
+ { value: "high", label: "high" },
+ ],
+ },
+ { value: "openai/gpt-5", label: "GPT-5", hint: "OpenAI" },
+];
+
+describe("argumentTypeaheadQuery", () => {
+ it("parses a model's active model or reasoning token", () => {
+ expect(argumentTypeaheadQuery("/model ant")).toEqual({
+ command: "model",
+ argument: "ant",
+ completed: [],
+ argumentStart: 7,
+ });
+ expect(argumentTypeaheadQuery("/model anthropic/claude-sonnet ")).toEqual({
+ command: "model",
+ argument: "",
+ completed: ["anthropic/claude-sonnet"],
+ argumentStart: 31,
+ });
+ expect(argumentTypeaheadQuery("/add channel/slack")).toEqual({
+ command: "add",
+ argument: "channel/slack",
+ completed: [],
+ argumentStart: 6,
+ });
+ expect(argumentTypeaheadQuery("/add channel/slack ")).toBeUndefined();
+ expect(argumentTypeaheadQuery("/model anthropic/claude-sonnet high ")).toBeUndefined();
+ expect(argumentTypeaheadQuery("/add one two")).toBeUndefined();
+ expect(argumentTypeaheadQuery("hello")).toBeUndefined();
+ });
+});
+
+describe("argumentTypeaheadFor", () => {
+ it("filters models, then offers their reasoning levels", () => {
+ let state = argumentTypeaheadFor(
+ { command: "model", argument: "anth", completed: [], argumentStart: 7 },
+ models,
+ );
+ expect(state.suggestions).toHaveLength(1);
+ expect(argumentTypeaheadCompletion(state, selectedArgumentSuggestion(state)!)).toBe(
+ "/model anthropic/claude-sonnet",
+ );
+
+ state = argumentTypeaheadFor(
+ {
+ command: "model",
+ argument: "h",
+ completed: ["anthropic/claude-sonnet"],
+ argumentStart: 31,
+ },
+ models,
+ );
+ expect(state.suggestions.map((suggestion) => suggestion.value)).toEqual(["high"]);
+ expect(argumentTypeaheadCompletion(state, selectedArgumentSuggestion(state)!)).toBe(
+ "/model anthropic/claude-sonnet high",
+ );
+ });
+
+ it("preserves the selected suggestion", () => {
+ let state = argumentTypeaheadFor(
+ { command: "model", argument: "", completed: [], argumentStart: 7 },
+ models,
+ );
+ state = moveArgumentTypeaheadSelection(state, 1);
+ expect(selectedArgumentSuggestion(state)).toMatchObject({ value: "openai/gpt-5" });
+ });
+
+ it("sanitizes catalog text before it can render or complete", () => {
+ const state = argumentTypeaheadFor(
+ { command: "model", argument: "", completed: [], argumentStart: 7 },
+ [{ value: "openai/\u001b]52;c;clipboard\u0007gpt", label: "GPT", hint: "\u001b[31mred" }],
+ );
+ expect(state.suggestions[0]).toMatchObject({ value: "openai/gpt", hint: "red" });
+ expect(argumentTypeaheadCompletion(state, selectedArgumentSuggestion(state)!)).toBe(
+ "/model openai/gpt",
+ );
+ });
+
+ it("keeps the selected item visible in an eight-row window", () => {
+ const suggestions = Array.from({ length: 9 }, (_, index) => ({
+ value: `provider/model-${index}`,
+ label: `Model ${index}`,
+ }));
+ const state = {
+ ...argumentTypeaheadFor(
+ { command: "model", argument: "", completed: [], argumentStart: 7 },
+ suggestions,
+ ),
+ selectedIndex: 8,
+ };
+ const rows = renderArgumentSuggestions(
+ state,
+ createTheme({ color: false, unicode: true }),
+ 80,
+ ).map(stripAnsi);
+ expect(rows).toHaveLength(8);
+ expect(rows.some((row) => row.includes("model-8"))).toBe(true);
+ expect(rows.some((row) => row.includes("model-0"))).toBe(false);
+ });
+});
diff --git a/packages/eve/src/cli/dev/tui/argument-typeahead.ts b/packages/eve/src/cli/dev/tui/argument-typeahead.ts
new file mode 100644
index 000000000..12bd31e6c
--- /dev/null
+++ b/packages/eve/src/cli/dev/tui/argument-typeahead.ts
@@ -0,0 +1,158 @@
+import { sanitizeForTerminal } from "#cli/ui/output.js";
+import { sliceVisible, visibleLength } from "#cli/ui/terminal-text.js";
+
+import type { Theme } from "./theme.js";
+
+export interface PromptArgumentSuggestion {
+ readonly value: string;
+ readonly label: string;
+ readonly hint?: string;
+ /** Follow-up values available after selecting this exact value. */
+ readonly next?: readonly PromptArgumentSuggestion[];
+}
+
+export type ArgumentTypeaheadCommand = "model" | "add";
+
+export interface ArgumentTypeaheadQuery {
+ readonly command: ArgumentTypeaheadCommand;
+ readonly argument: string;
+ /** Complete arguments before the one currently being typed. */
+ readonly completed: readonly string[];
+ /** Offset of the current argument in the composer draft. */
+ readonly argumentStart: number;
+}
+
+export interface ArgumentTypeaheadState extends ArgumentTypeaheadQuery {
+ readonly suggestions: readonly PromptArgumentSuggestion[];
+ readonly selectedIndex: number;
+}
+
+const ARGUMENT_LIMIT: Record<ArgumentTypeaheadCommand, number> = { add: 1, model: 2 };
+
+export function isArgumentTypeaheadCommand(command: string): command is ArgumentTypeaheadCommand {
+ return command === "model" || command === "add";
+}
+
+export function argumentTypeaheadLoadingLabel(command: ArgumentTypeaheadCommand): string {
+ return command === "model" ? "models" : "registry";
+}
+
+/**
+ * Parses the active token in an inline command drawer. The command grammar
+ * deliberately uses literal spaces, matching slash-command dispatch.
+ */
+export function argumentTypeaheadQuery(text: string): ArgumentTypeaheadQuery | undefined {
+ if (!text.startsWith("/")) return undefined;
+ const commandEnd = text.indexOf(" ");
+ if (commandEnd < 0) return undefined;
+ const command = text.slice(1, commandEnd);
+ if (!isArgumentTypeaheadCommand(command)) return undefined;
+
+ const tokens: { value: string; start: number }[] = [];
+ let cursor = commandEnd;
+ while (cursor < text.length) {
+ while (text[cursor] === " ") cursor += 1;
+ if (cursor === text.length) break;
+ const start = cursor;
+ while (cursor < text.length && text[cursor] !== " ") cursor += 1;
+ tokens.push({ value: text.slice(start, cursor), start });
+ }
+ const argumentCount = tokens.length + (text.endsWith(" ") ? 1 : 0);
+ if (text.slice(commandEnd).includes("\n") || argumentCount > ARGUMENT_LIMIT[command]) {
+ return undefined;
+ }
+ const active = tokens.at(-1);
+ const completed = tokens.map((token) => token.value);
+ if (!text.endsWith(" ") && active !== undefined) completed.pop();
+ return {
+ command,
+ argument: text.endsWith(" ") ? "" : (active?.value ?? ""),
+ completed,
+ argumentStart: text.endsWith(" ") ? text.length : (active?.start ?? text.length),
+ };
+}
+
+function sanitizeSuggestion(suggestion: PromptArgumentSuggestion): PromptArgumentSuggestion {
+ const sanitized: {
+ value: string;
+ label: string;
+ hint?: string;
+ next?: readonly PromptArgumentSuggestion[];
+ } = {
+ value: sanitizeForTerminal(suggestion.value),
+ label: sanitizeForTerminal(suggestion.label),
+ };
+ if (suggestion.hint !== undefined) sanitized.hint = sanitizeForTerminal(suggestion.hint);
+ if (suggestion.next !== undefined) sanitized.next = suggestion.next.map(sanitizeSuggestion);
+ return sanitized;
+}
+
+/** Filters catalog entries case-insensitively across their visible labels and ids. */
+export function argumentTypeaheadFor(
+ query: ArgumentTypeaheadQuery,
+ catalog: readonly PromptArgumentSuggestion[],
+ previous?: ArgumentTypeaheadState,
+): ArgumentTypeaheadState {
+ const root = catalog.map(sanitizeSuggestion);
+ const candidates =
+ query.completed.length === 0
+ ? root
+ : (root.find((suggestion) => suggestion.value === query.completed[0])?.next ?? []);
+ const normalized = query.argument.toLowerCase();
+ const suggestions = candidates.filter(
+ (suggestion) =>
+ suggestion.value.toLowerCase().includes(normalized) ||
+ suggestion.label.toLowerCase().includes(normalized) ||
+ (suggestion.hint?.toLowerCase().includes(normalized) ?? false),
+ );
+ const selected = previous?.suggestions[previous.selectedIndex];
+ const selectedIndex =
+ selected === undefined ? -1 : suggestions.findIndex((item) => item.value === selected.value);
+ return { ...query, suggestions, selectedIndex: selectedIndex >= 0 ? selectedIndex : 0 };
+}
+
+export function moveArgumentTypeaheadSelection(
+ state: ArgumentTypeaheadState,
+ delta: 1 | -1,
+): ArgumentTypeaheadState {
+ if (state.suggestions.length === 0) return state;
+ return {
+ ...state,
+ selectedIndex:
+ (state.selectedIndex + delta + state.suggestions.length) % state.suggestions.length,
+ };
+}
+
+export function selectedArgumentSuggestion(
+ state: ArgumentTypeaheadState,
+): PromptArgumentSuggestion | undefined {
+ return state.suggestions[state.selectedIndex];
+}
+
+/** Replaces only the active argument, retaining selected preceding model tokens. */
+export function argumentTypeaheadCompletion(
+ state: ArgumentTypeaheadState,
+ suggestion: PromptArgumentSuggestion,
+): string {
+ return `/${state.command} ${[...state.completed, suggestion.value].join(" ")}`;
+}
+
+/** Paints canonical catalog values under the command's active argument column. */
+export function renderArgumentSuggestions(
+ state: ArgumentTypeaheadState,
+ theme: Theme,
+ width: number,
+): string[] {
+ const c = theme.colors;
+ const viewSize = Math.min(8, state.suggestions.length);
+ const start = Math.max(
+ 0,
+ Math.min(state.selectedIndex - Math.floor(viewSize / 2), state.suggestions.length - viewSize),
+ );
+ return state.suggestions.slice(start, start + viewSize).map((suggestion, index) => {
+ const value =
+ start + index === state.selectedIndex ? c.bold(suggestion.value) : c.dim(suggestion.value);
+ const row = `${" ".repeat(state.argumentStart + 2)}${value}`;
+ return visibleLength(row) > width ? sliceVisible(row, width) : row;
+ });
+}
diff --git a/packages/eve/src/cli/dev/tui/blocks.ts b/packages/eve/src/cli/dev/tui/blocks.ts
index 641065b9e..a9977f6d6 100644
--- a/packages/eve/src/cli/dev/tui/blocks.ts
+++ b/packages/eve/src/cli/dev/tui/blocks.ts
@@ -439,7 +439,7 @@ function paintCommands(line: string, theme: Theme): string {
function renderCommand(block: Block, theme: Theme): string[] {
const c = theme.colors;
const status = block.status === "error" ? `${c.red(theme.glyph.error)} ` : "";
- return [`${c.cyan(theme.glyph.user)} ${status}${c.blue(block.body ?? "")}`];
+ return [`${c.cyan(theme.glyph.user)} ${status}${c.bold(block.body ?? "")}`];
}
/**
diff --git a/packages/eve/src/cli/dev/tui/model-picker.test.ts b/packages/eve/src/cli/dev/tui/model-picker.test.ts
deleted file mode 100644
index d34d6e5f1..000000000
--- a/packages/eve/src/cli/dev/tui/model-picker.test.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import type { ModelSettingsRequest } from "#setup/flows/model.js";
-
-import { initialModelPickerState, transitionModelPicker } from "./model-picker.js";
-
-const request: ModelSettingsRequest = {
- model: {
- kind: "pick",
- current: "anthropic/claude-sonnet",
- options: [
- { value: "anthropic/claude-sonnet", label: "Claude Sonnet" },
- { value: "openai/gpt", label: "GPT" },
- ],
- },
- reasoning: null,
- serviceTier: { kind: "standard" },
- settingsEditable: false,
- externalRouting: false,
- capabilitiesFor: () => undefined,
-};
-
-describe("transitionModelPicker", () => {
- it("deletes the previous word from the model search", () => {
- const initial = initialModelPickerState(request);
- const transition = transitionModelPicker(
- { ...initial, select: { ...initial.select, filter: "claude sonnet" } },
- { type: "delete-word-backward" },
- request,
- );
-
- expect(transition).toMatchObject({
- kind: "render",
- state: { select: { filter: "claude " } },
- });
- });
-});
diff --git a/packages/eve/src/cli/dev/tui/model-picker.ts b/packages/eve/src/cli/dev/tui/model-picker.ts
deleted file mode 100644
index c922f2a51..000000000
--- a/packages/eve/src/cli/dev/tui/model-picker.ts
+++ /dev/null
@@ -1,307 +0,0 @@
-import { ALL_REASONING_LEVELS, type ReasoningLevel } from "#setup/boxes/model-capabilities.js";
-import {
- filterOptions,
- initialSelectState,
- reduceSelect,
- selectValueAtCursor,
- type SelectState,
-} from "#setup/cli/select-state.js";
-import type { ModelSettingsRequest, ModelSettingsResult } from "#setup/flows/model.js";
-import type { SelectOption } from "#setup/prompter.js";
-
-import { renderSelectQuestion } from "./setup-panel.js";
-import type { Theme } from "./theme.js";
-
-type ModelPickerStep = "model" | "speed" | "reasoning";
-
-interface ModelPickerDraft {
- model: string | null;
- speed: "standard" | "priority";
- reasoning: "default" | ReasoningLevel;
-}
-
-interface ModelPickerPage {
- step: ModelPickerStep;
- select: SelectState;
- draft: ModelPickerDraft;
-}
-
-export interface ModelPickerState extends ModelPickerPage {
- history: readonly Pick<ModelPickerPage, "step" | "select">[];
-}
-
-export type ModelPickerEvent =
- | { type: "up" }
- | { type: "down" }
- | { type: "back" }
- | { type: "cancel" }
- | { type: "submit" }
- | { type: "backspace" }
- | { type: "delete-word-backward" }
- | { type: "char"; char: string };
-
-export type ModelPickerTransition =
- | { kind: "render"; state: ModelPickerState }
- | { kind: "cancel" }
- | { kind: "settle"; result: ModelSettingsResult };
-
-const SPEED_OPTIONS: readonly SelectOption<ModelPickerDraft["speed"]>[] = [
- { value: "standard", label: "Standard", hint: "Normal speed and pricing" },
- { value: "priority", label: "Fast", hint: "Priority processing, higher cost" },
-];
-
-const REASONING_COPY: Record<ReasoningLevel, { label: string; hint: string }> = {
- none: { label: "None", hint: "No reasoning" },
- minimal: { label: "Minimal", hint: "The least thinking" },
- low: { label: "Low", hint: "Less thinking, quicker answers" },
- medium: { label: "Medium", hint: "Balance thinking and response time" },
- high: { label: "High", hint: "More thinking for harder tasks" },
- xhigh: { label: "Extra high", hint: "The most thinking, slower answers" },
-};
-
-const REASONING_OPTIONS: readonly SelectOption<ModelPickerDraft["reasoning"]>[] = [
- { value: "default", label: "Provider default", hint: "Use the model's default reasoning" },
- ...ALL_REASONING_LEVELS.map((value) => ({ value, ...REASONING_COPY[value] })),
-];
-
-function modelOptions(request: ModelSettingsRequest): readonly SelectOption<string>[] {
- if (request.model.kind === "fixed") {
- return [{ value: "fixed", label: request.model.current ?? "Configured in agent.ts" }];
- }
- const { options, current } = request.model;
- if (current === null || options.some((option) => option.value === current)) return options;
- // A saved model can outlive its catalog listing; Enter must not silently replace it.
- return [{ value: current, label: current, hint: "Current model" }, ...options];
-}
-
-function stepOptions(
- request: ModelSettingsRequest,
- draft: ModelPickerDraft,
- step: ModelPickerStep,
-): readonly SelectOption<string>[] {
- switch (step) {
- case "model":
- return modelOptions(request);
- case "speed":
- return SPEED_OPTIONS;
- case "reasoning": {
- const levels = reasoningLevels(request, draft);
- return REASONING_OPTIONS.filter(
- (option) => option.value === "default" || levels.includes(option.value),
- );
- }
- }
-}
-
-function reasoningLevels(
- request: ModelSettingsRequest,
- draft: ModelPickerDraft,
-): readonly ReasoningLevel[] {
- const capabilities = request.capabilitiesFor(draft.model);
- if (capabilities !== undefined) return capabilities.reasoning ? capabilities.reasoningLevels : [];
- // Without catalog evidence, only keep or clear a setting already authored for this model.
- return draft.model === request.model.current && request.reasoning !== null
- ? [request.reasoning]
- : [];
-}
-
-function nextStep(
- request: ModelSettingsRequest,
- draft: ModelPickerDraft,
- step: ModelPickerStep,
-): Exclude<ModelPickerStep, "model"> | undefined {
- if (!request.settingsEditable) return undefined;
- const capabilities = request.capabilitiesFor(draft.model);
- if (
- step === "model" &&
- !request.externalRouting &&
- request.serviceTier.kind !== "custom" &&
- (capabilities?.fastMode ||
- (capabilities === undefined &&
- draft.model === request.model.current &&
- request.serviceTier.kind === "priority"))
- ) {
- return "speed";
- }
- if (step !== "reasoning" && reasoningLevels(request, draft).length > 0) {
- return "reasoning";
- }
- return undefined;
-}
-
-export function initialModelPickerState(request: ModelSettingsRequest): ModelPickerState {
- const draft: ModelPickerDraft = {
- model: request.model.current,
- speed: request.serviceTier.kind === "priority" ? "priority" : "standard",
- reasoning: request.reasoning ?? "default",
- };
- return {
- step: "model",
- draft,
- select: initialSelectState({
- options: modelOptions(request),
- defaultValue: draft.model ?? undefined,
- }),
- history: [],
- };
-}
-
-function selectionDraft(
- request: ModelSettingsRequest,
- state: ModelPickerState,
- value: string,
-): ModelPickerDraft {
- const draft = { ...state.draft };
- switch (state.step) {
- case "model": {
- if (request.model.kind === "fixed") return draft;
- draft.model = value;
- const capabilities = request.capabilitiesFor(value);
- if (capabilities !== undefined) {
- if (!capabilities.fastMode) draft.speed = "standard";
- if (
- draft.reasoning !== "default" &&
- (!capabilities.reasoning || !capabilities.reasoningLevels.includes(draft.reasoning))
- ) {
- draft.reasoning = "default";
- }
- }
- return draft;
- }
- case "speed":
- draft.speed = SPEED_OPTIONS.find((option) => option.value === value)!.value;
- return draft;
- case "reasoning":
- draft.reasoning = REASONING_OPTIONS.find((option) => option.value === value)!.value;
- return draft;
- }
-}
-
-function selectionResult(
- request: ModelSettingsRequest,
- draft: ModelPickerDraft,
-): ModelSettingsResult {
- const result: ModelSettingsResult = {};
- if (
- request.model.kind === "pick" &&
- draft.model !== null &&
- draft.model !== request.model.current
- ) {
- result.model = draft.model;
- }
- if (request.settingsEditable) {
- if (draft.reasoning !== (request.reasoning ?? "default")) result.reasoning = draft.reasoning;
- const originalSpeed = request.serviceTier.kind === "priority" ? "priority" : "standard";
- if (
- !request.externalRouting &&
- request.serviceTier.kind !== "custom" &&
- draft.speed !== originalSpeed
- ) {
- result.serviceTier = draft.speed;
- }
- }
- return result;
-}
-
-export function transitionModelPicker(
- state: ModelPickerState,
- event: ModelPickerEvent,
- request: ModelSettingsRequest,
-): ModelPickerTransition {
- if (event.type === "cancel") return { kind: "cancel" };
- if (event.type === "back") {
- const previous = state.history.at(-1);
- return previous === undefined
- ? { kind: "cancel" }
- : {
- kind: "render",
- state: { ...previous, draft: state.draft, history: state.history.slice(0, -1) },
- };
- }
- const options = stepOptions(request, state.draft, state.step);
- if (event.type !== "submit") {
- if (
- (state.step !== "model" || request.model.kind !== "pick") &&
- (event.type === "char" || event.type === "backspace" || event.type === "delete-word-backward")
- ) {
- return { kind: "render", state };
- }
- return {
- kind: "render",
- state: { ...state, select: reduceSelect(state.select, event, { options }) },
- };
- }
- const value = selectValueAtCursor(
- filterOptions(options, state.select.filter),
- state.select.cursor,
- );
- if (value === undefined) return { kind: "render", state };
- const draft = selectionDraft(request, state, value);
- const step = nextStep(request, draft, state.step);
- if (step === undefined) return { kind: "settle", result: selectionResult(request, draft) };
- return {
- kind: "render",
- state: {
- step,
- draft,
- select: initialSelectState({
- options: stepOptions(request, draft, step),
- defaultValue: draft[step],
- }),
- history: [...state.history, { step: state.step, select: state.select }],
- },
- };
-}
-
-export function modelPickerTitle(state: ModelPickerState): string {
- return { model: "Select model", speed: "Select speed", reasoning: "Select reasoning" }[
- state.step
- ];
-}
-
-export function renderModelPicker(
- request: ModelSettingsRequest,
- state: ModelPickerState,
- theme: Theme,
- width: number,
-): string[] {
- const options = stepOptions(request, state.draft, state.step);
- const value = selectValueAtCursor(
- filterOptions(options, state.select.filter),
- state.select.cursor,
- );
- const draft = value === undefined ? state.draft : selectionDraft(request, state, value);
- const last = nextStep(request, draft, state.step) === undefined;
- const model =
- modelOptions(request).find((option) => option.value === state.draft.model)?.label ??
- state.draft.model;
- const context =
- state.step === "model"
- ? request.model.kind === "fixed"
- ? request.model.reason
- : undefined
- : [
- model,
- ...(state.step === "reasoning" && state.history.some((page) => page.step === "speed")
- ? [state.draft.speed === "priority" ? "Fast" : "Standard"]
- : []),
- ]
- .filter(Boolean)
- .join(" · ");
- return renderSelectQuestion(
- {
- kind: state.step === "model" && request.model.kind === "pick" ? "search" : "single",
- message: "",
- description: context,
- options,
- select: state.select,
- footerHints: [
- "↑/↓ move",
- last ? "Enter apply" : "Enter next",
- state.history.length > 0 ? "Esc/← back" : "Esc cancel",
- ],
- },
- theme,
- width,
- );
-}
diff --git a/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts b/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts
index 4c68c8aa1..d1d794fbf 100644
--- a/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts
+++ b/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts
@@ -54,7 +54,6 @@ function setupFlowRenderer() {
readSelect: vi.fn(async () => undefined),
readEditableSelect: vi.fn(async () => undefined),
readProviderPicker: vi.fn(async () => undefined),
- readModelPicker: vi.fn(async () => undefined),
readText: vi.fn(async () => undefined),
readAcknowledge: vi.fn(async () => {}),
readChoice: vi.fn(() => ({ choice: Promise.resolve(undefined), close: vi.fn() })),
@@ -114,7 +113,7 @@ describe("createPromptCommandHandler", () => {
expect(applyModel).not.toHaveBeenCalled();
});
- it("sends a bare /model down the setup-flow path, not a bespoke picker", async () => {
+ it("requires the inline drawer to complete a bare /model", async () => {
const applyModel = vi.fn(async () => ({ kind: "rejected", message: "unused" }) as const);
const readInputQuestion = vi.fn(async () => ({ optionId: "openai/gpt-5" }));
const handler = createPromptCommandHandler({
@@ -122,14 +121,12 @@ describe("createPromptCommandHandler", () => {
applyModel,
});
- // No setupFlow on the renderer: the flow path reports itself instead of
- // falling back to the old readInputQuestion picker.
await expect(
handler.handle(
{ type: "extension", name: "model", argument: "" },
context({ readInputQuestion }),
),
- ).resolves.toEqual({ message: "/model is not supported by this renderer." });
+ ).resolves.toEqual({ message: "Choose a model from the inline /model suggestions." });
expect(readInputQuestion).not.toHaveBeenCalled();
expect(applyModel).not.toHaveBeenCalled();
});
@@ -146,43 +143,6 @@ describe("createPromptCommandHandler", () => {
});
});
- it("forwards automatic provider entry and model-access changes", async () => {
- const runTuiSetupCommand = vi.fn(async () => ({
- message: "AI Gateway via API key selected.",
- preserveFlowDiagnostics: false,
- effect: { kind: "model-access-changed", reload: true } as const,
- }));
- vi.doMock("./setup-commands.js", () => ({
- SETUP_FLOW_CONFIG: {
- model: { title: "Configure the agent model", indicator: "pulse" },
- },
- runTuiSetupCommand,
- }));
-
- try {
- const setupFlow = setupFlowRenderer();
- const handler = createPromptCommandHandler({ target: LOCAL_TARGET });
-
- await expect(
- handler.handle(
- { type: "extension", name: "model", argument: "" },
- { ...context({ setupFlow }), initialModelStep: "provider" },
- ),
- ).resolves.toEqual({
- message: "AI Gateway via API key selected.",
- effect: { kind: "model-access-changed", reload: true },
- });
- expect(runTuiSetupCommand).toHaveBeenCalledWith(
- expect.objectContaining({ initialModelStep: "provider" }),
- );
- expect(setupFlow.begin).toHaveBeenCalledWith("Configure the agent model", "pulse");
- expect(setupFlow.end).toHaveBeenCalledWith({ preserveDiagnostics: false });
- } finally {
- vi.doUnmock("./setup-commands.js");
- vi.resetModules();
- }
- });
-
it("routes a /add argument to the registry flow's initial address", async () => {
const runTuiSetupCommand = vi.fn(async () => ({
message: "Added Slack",
@@ -201,19 +161,10 @@ describe("createPromptCommandHandler", () => {
{ type: "extension", name: "add", argument: "channel/slack" },
context({ setupFlow }),
);
- await handler.handle(
- { type: "extension", name: "add", argument: "" },
- context({ setupFlow }),
- );
-
- expect(runTuiSetupCommand).toHaveBeenNthCalledWith(
- 1,
+ expect(runTuiSetupCommand).toHaveBeenCalledOnce();
+ expect(runTuiSetupCommand).toHaveBeenCalledWith(
expect.objectContaining({ command: "add", initialRegistryAddress: "channel/slack" }),
);
- expect(runTuiSetupCommand).toHaveBeenNthCalledWith(
- 2,
- expect.not.objectContaining({ initialRegistryAddress: expect.anything() }),
- );
} finally {
vi.doUnmock("./setup-commands.js");
vi.resetModules();
@@ -308,9 +259,12 @@ describe("createPromptCommandHandler", () => {
});
await expect(
- handler.handle({ type: "extension", name: "model", argument: "" }, context({ setupFlow })),
+ handler.handle(
+ { type: "extension", name: "add", argument: "channel/slack" },
+ context({ setupFlow }),
+ ),
).resolves.toEqual({
- message: expect.stringMatching(/^\/model failed: /),
+ message: expect.stringMatching(/^\/add failed: /),
});
expect(setupFlow.begin).not.toHaveBeenCalled();
} finally {
diff --git a/packages/eve/src/cli/dev/tui/prompt-command-handler.ts b/packages/eve/src/cli/dev/tui/prompt-command-handler.ts
index e4d3a7f1d..3ebd22115 100644
--- a/packages/eve/src/cli/dev/tui/prompt-command-handler.ts
+++ b/packages/eve/src/cli/dev/tui/prompt-command-handler.ts
@@ -1,4 +1,5 @@
import type { ApplyModelOutcome } from "#setup/flows/model-source-change.js";
+import type { AgentReasoningDefinition } from "#shared/agent-definition.js";
import { toErrorMessage } from "#shared/errors.js";
import type {
@@ -40,9 +41,12 @@ export function createPromptCommandHandler(
};
}
- // `/model <slug>` applies directly; only the bare command opens the
- // configure menu flow below.
- if (command.name === "model" && command.argument.length > 0) {
+ // Model selection is owned by the inline command drawer. Once the
+ // drawer submits, this is the command's single apply path.
+ if (command.name === "model") {
+ if (command.argument.length === 0) {
+ return { message: "Choose a model from the inline /model suggestions." };
+ }
if (target.kind !== "local") {
return {
message:
@@ -53,8 +57,26 @@ export function createPromptCommandHandler(
// Package-loading failures are command outcomes at this CLI boundary.
try {
const { modelChangeRefusalForUneditableModel } = await import("#setup/flows/model.js");
- const { changeAgentModel, formatApplyModelOutcome } =
- await import("#setup/flows/model-source-change.js");
+ const {
+ changeAgentModel,
+ changeAgentModelSettings,
+ formatApplyModelOutcome,
+ formatApplyModelSettingsOutcome,
+ } = await import("#setup/flows/model-source-change.js");
+ const [slug, reasoning, ...extra] = command.argument.split(/\s+/u);
+ if (slug === undefined || extra.length > 0) {
+ return {
+ message: "Use `/model provider/model [default|none|minimal|low|medium|high|xhigh]`.",
+ };
+ }
+ if (
+ reasoning !== undefined &&
+ !["default", "none", "minimal", "low", "medium", "high", "xhigh"].includes(reasoning)
+ ) {
+ return {
+ message: "Use `/model provider/model [default|none|minimal|low|medium|high|xhigh]`.",
+ };
+ }
// A source-backed model (an SDK model call) isn't a string literal eve
// can rewrite; refuse with a clear reason rather than silently no-op.
const checkRefusal = options.modelChangeRefusal ?? modelChangeRefusalForUneditableModel;
@@ -62,10 +84,25 @@ export function createPromptCommandHandler(
if (refusal !== null) {
return { message: refusal };
}
+ if (reasoning !== undefined) {
+ return {
+ message: formatApplyModelSettingsOutcome(
+ await changeAgentModelSettings({
+ appRoot,
+ patch: {
+ model: { kind: "set", value: slug },
+ reasoning:
+ reasoning === "default"
+ ? { kind: "remove" }
+ : { kind: "set", value: reasoning as AgentReasoningDefinition },
+ gatewayServiceTier: { kind: "keep" },
+ },
+ }),
+ ),
+ };
+ }
const applyModel = options.applyModel ?? changeAgentModel;
- return {
- message: formatApplyModelOutcome(await applyModel({ appRoot, slug: command.argument })),
- };
+ return { message: formatApplyModelOutcome(await applyModel({ appRoot, slug })) };
} catch (error) {
return {
message: `Couldn't change the model: ${toErrorMessage(error)}`,
@@ -73,6 +110,10 @@ export function createPromptCommandHandler(
}
}
+ if (command.name === "add" && command.argument.length === 0) {
+ return { message: "Choose an integration from the inline /add suggestions." };
+ }
+
const flow = context.renderer.setupFlow;
if (flow === undefined) {
return { message: `/${command.name} is not supported by this renderer.` };
@@ -103,10 +144,7 @@ export function createPromptCommandHandler(
if (context.onOnboardingScreen !== undefined) {
commandInput.onOnboardingScreen = context.onOnboardingScreen;
}
- // `/add <item>` confirms and installs that address; bare `/add` opens the planner.
- if (command.name === "add" && command.argument.length > 0) {
- commandInput.initialRegistryAddress = command.argument;
- }
+ if (command.name === "add") commandInput.initialRegistryAddress = command.argument;
if (options.flows !== undefined) commandInput.flows = options.flows;
const result = await runTuiSetupCommand(commandInput);
preserveFlowDiagnostics = result.preserveFlowDiagnostics;
diff --git a/packages/eve/src/cli/dev/tui/runner.test.ts b/packages/eve/src/cli/dev/tui/runner.test.ts
index 832aacdc0..a05ccae61 100644
--- a/packages/eve/src/cli/dev/tui/runner.test.ts
+++ b/packages/eve/src/cli/dev/tui/runner.test.ts
@@ -562,7 +562,6 @@ function idleSetupFlow(): SetupFlowRenderer {
readSelect: vi.fn(async () => undefined),
readEditableSelect: vi.fn(async () => undefined),
readProviderPicker: vi.fn(async () => undefined),
- readModelPicker: vi.fn(async () => undefined),
readText: vi.fn(async () => undefined),
readAcknowledge: vi.fn(async () => {}),
readChoice: vi.fn(() => ({ choice: Promise.resolve(undefined), close: vi.fn() })),
diff --git a/packages/eve/src/cli/dev/tui/runner.ts b/packages/eve/src/cli/dev/tui/runner.ts
index 0b0affda8..ef5690d4d 100644
--- a/packages/eve/src/cli/dev/tui/runner.ts
+++ b/packages/eve/src/cli/dev/tui/runner.ts
@@ -62,6 +62,7 @@ import {
type PromptCommand,
type PromptCommandSpec,
} from "./prompt-commands.js";
+import type { PromptArgumentSuggestion } from "./argument-typeahead.js";
import {
createRemoteConnectionController,
type RemoteConnectionController,
@@ -470,6 +471,8 @@ export type EveTUIRunnerOptions = TuiDisplayOptions & {
promptCommandHandler?: PromptCommandHandler;
/** Commands shown in discovery for this local or remote session. */
availablePromptCommands?: readonly PromptCommandSpec[];
+ /** Catalog entries available to inline `/model` and `/add` completion. */
+ argumentSuggestions?: (command: "model" | "add") => Promise<readonly PromptArgumentSuggestion[]>;
/** Gives setup subprocesses exclusive terminal and development-host ownership. */
withExclusiveTerminal?: <T>(task: () => Promise<T>) => Promise<T>;
/** Remote target and mutable OIDC token source, when connected through `--url`. */
@@ -2069,6 +2072,7 @@ function createRenderer(options: EveTUIRunnerOptions): AgentTUIRenderer {
contextSize: options.contextSize,
logs: options.logs,
availablePromptCommands: options.availablePromptCommands,
+ argumentSuggestions: options.argumentSuggestions,
input: options.userInput,
output: options.screen,
diagnostics: options.diagnostics,
diff --git a/packages/eve/src/cli/dev/tui/setup-commands.test.ts b/packages/eve/src/cli/dev/tui/setup-commands.test.ts
index f1f69c9ee..2513af62d 100644
--- a/packages/eve/src/cli/dev/tui/setup-commands.test.ts
+++ b/packages/eve/src/cli/dev/tui/setup-commands.test.ts
@@ -26,7 +26,6 @@ function fakePanelRenderer(): TuiSetupCommandRenderer & {
readSelect: vi.fn(async () => []),
readEditableSelect: vi.fn(async () => undefined),
readProviderPicker: vi.fn(async () => undefined),
- readModelPicker: vi.fn(async () => undefined),
readText: vi.fn(async () => ""),
readAcknowledge: vi.fn(async () => {}),
readChoice: vi.fn(() => ({ choice: Promise.resolve(undefined), close: vi.fn() })),
@@ -61,11 +60,6 @@ function fakeFlows(overrides: Partial<TuiSetupFlows> = {}): TuiSetupFlows {
runInstallVercelCliFlow: vi.fn<TuiSetupFlows["runInstallVercelCliFlow"]>(async () => ({
kind: "installed",
})),
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => ({
- kind: "done",
- accessChanged: true,
- modelMessage: "Model changed to openai/gpt-5.5. Live on your next prompt.",
- })),
runRegistryFlow: vi.fn<TuiSetupFlows["runRegistryFlow"]>(async () => registryResult()),
runDeployFlow: vi.fn<TuiSetupFlows["runDeployFlow"]>(async () => ({
kind: "deployed",
@@ -76,7 +70,7 @@ function fakeFlows(overrides: Partial<TuiSetupFlows> = {}): TuiSetupFlows {
}
function run(input: {
- command: "model" | "add" | "deploy";
+ command: "add" | "deploy";
flows: TuiSetupFlows;
renderer?: TuiSetupCommandRenderer;
initialModelStep?: "provider";
@@ -186,253 +180,11 @@ describe("runTuiSetupCommand", () => {
),
).toEqual({
login: "pulse",
- model: "pulse",
add: "pulse",
deploy: "spinner",
});
});
- it("surfaces the model flow's apply line as the outcome", async () => {
- const flows = fakeFlows();
- await expect(run({ command: "model", flows })).resolves.toEqual({
- message: "Model changed to openai/gpt-5.5. Live on your next prompt.",
- preserveFlowDiagnostics: false,
- effect: { kind: "model-access-changed", reload: true },
- });
- expect(flows.runModelFlow).toHaveBeenCalledWith(
- expect.objectContaining({
- appRoot: APP_ROOT,
- deps: expect.objectContaining({ pickModelSettings: expect.any(Function) }),
- }),
- );
- });
-
- it("edits the selected workspace agent while configuring project-level provider access", async () => {
- const flows = fakeFlows();
-
- await run({
- command: "model",
- flows,
- agentRoot: "/tmp/project/agents/researcher",
- });
-
- expect(flows.runModelFlow).toHaveBeenCalledWith(
- expect.objectContaining({
- appRoot: "/tmp/project/agents/researcher",
- environmentRoot: APP_ROOT,
- }),
- );
- });
-
- it("does not rebuild model access after a rejected edit", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => ({
- kind: "done",
- accessChanged: false,
- modelMessage: "Couldn't confirm the id.",
- })),
- });
-
- await expect(run({ command: "model", flows })).resolves.toEqual({
- message: "Couldn't confirm the id.",
- preserveFlowDiagnostics: false,
- });
- });
-
- it("keeps model setup attached to the TUI panel", async () => {
- const renderer = fakePanelRenderer();
- renderer.withInheritedStdio = vi.fn(async (task) => task());
- const exclusiveCalls = vi.fn();
- const withExclusiveTerminal = async <T>(task: () => Promise<T>): Promise<T> => {
- exclusiveCalls();
- return task();
- };
- const flows = fakeFlows();
-
- await run({ command: "model", flows, renderer, withExclusiveTerminal });
-
- expect(flows.runModelFlow).toHaveBeenCalledWith(
- expect.not.objectContaining({ withExclusiveTerminal: expect.anything() }),
- );
- expect(renderer.withInheritedStdio).not.toHaveBeenCalled();
- expect(exclusiveCalls).not.toHaveBeenCalled();
- });
-
- it("forwards an automatic provider entry to the model flow", async () => {
- const flows = fakeFlows();
-
- await run({ command: "model", flows, initialModelStep: "provider" });
-
- expect(flows.runModelFlow).toHaveBeenCalledWith(
- expect.objectContaining({ appRoot: APP_ROOT, initialStep: "provider" }),
- );
- });
-
- it("stacks the model and provider selection lines when both menu actions ran", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => ({
- kind: "done",
- accessChanged: true,
- modelMessage: "Model changed to openai/gpt-5.5. Live on your next prompt.",
- providerSelection: "ai-gateway-project",
- })),
- });
- await expect(run({ command: "model", flows })).resolves.toEqual({
- message:
- "Model changed to openai/gpt-5.5. Live on your next prompt.\n" +
- "AI Gateway via Project selected.",
- preserveFlowDiagnostics: false,
- effect: { kind: "model-access-changed", reload: true },
- });
- });
-
- it("reports a provider-only model session with the provider selection", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => ({
- kind: "done",
- accessChanged: true,
- providerSelection: "ai-gateway-project",
- })),
- });
- await expect(run({ command: "model", flows })).resolves.toEqual({
- message: "AI Gateway via Project selected.",
- preserveFlowDiagnostics: false,
- effect: { kind: "model-access-changed", reload: true },
- });
- });
-
- it("reports the selected API-key provider without claiming a connection", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => ({
- kind: "done",
- accessChanged: true,
- providerSelection: "ai-gateway-key",
- })),
- });
- await expect(run({ command: "model", flows })).resolves.toEqual({
- message: "AI Gateway via API key selected.",
- preserveFlowDiagnostics: false,
- effect: { kind: "model-access-changed", reload: true },
- });
- });
-
- it("reports the selected ChatGPT subscription", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => ({
- kind: "done",
- accessChanged: true,
- providerSelection: "chatgpt",
- })),
- });
- await expect(run({ command: "model", flows })).resolves.toEqual({
- message: "ChatGPT subscription selected.",
- preserveFlowDiagnostics: false,
- effect: { kind: "model-access-changed", reload: true },
- });
- });
-
- it("reports a cancelled model pick", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => ({ kind: "cancelled" })),
- });
- await expect(run({ command: "model", flows })).resolves.toEqual({
- message: "",
- cancelled: true,
- preserveFlowDiagnostics: false,
- });
- });
-
- it("prompts to upgrade an old Vercel CLI when setup reports it unsupported", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => {
- throw new HumanActionRequiredError({
- kind: "vercel-cli-upgrade",
- command: "vercel upgrade",
- reason: "The installed Vercel CLI does not support the required team-list options.",
- });
- }),
- runInstallVercelCliFlow: vi.fn<TuiSetupFlows["runInstallVercelCliFlow"]>(async () => ({
- kind: "installed",
- })),
- });
-
- await expect(run({ command: "model", flows, upgradeChoice: "upgrade" })).resolves.toEqual({
- message: "Upgraded the Vercel CLI. Retry /model.",
- tone: "error",
- preserveFlowDiagnostics: false,
- });
- expect(flows.runInstallVercelCliFlow).toHaveBeenCalledWith(
- expect.objectContaining({
- appRoot: APP_ROOT,
- upgrade: true,
- }),
- );
- });
-
- it("gives the manual upgrade command when the old-CLI prompt is declined", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => {
- throw new HumanActionRequiredError({
- kind: "vercel-cli-upgrade",
- command: "vercel upgrade",
- reason: "The installed Vercel CLI does not support the required team-list options.",
- });
- }),
- });
-
- await expect(run({ command: "model", flows, upgradeChoice: "later" })).resolves.toEqual({
- message: "The Vercel CLI needs an update — run `vercel upgrade`, then retry /model.",
- tone: "error",
- preserveFlowDiagnostics: true,
- });
- expect(flows.runInstallVercelCliFlow).not.toHaveBeenCalled();
- });
-
- it("prints a thrown upgrade error with the manual command", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => {
- throw new HumanActionRequiredError({
- kind: "vercel-cli-upgrade",
- command: "vercel upgrade",
- reason: "The installed Vercel CLI does not support the required team-list options.",
- });
- }),
- runInstallVercelCliFlow: vi.fn<TuiSetupFlows["runInstallVercelCliFlow"]>(async () => {
- throw new Error("package manager failed");
- }),
- });
-
- await expect(run({ command: "model", flows, upgradeChoice: "upgrade" })).resolves.toEqual({
- message:
- "Couldn't upgrade the Vercel CLI (package manager failed) — run `vercel upgrade`, then retry /model.",
- tone: "error",
- preserveFlowDiagnostics: true,
- });
- });
-
- it("prints the native CLI failure reason with the manual command", async () => {
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(async () => {
- throw new HumanActionRequiredError({
- kind: "vercel-cli-upgrade",
- command: "vercel upgrade",
- reason: "The installed Vercel CLI does not support the required team-list options.",
- });
- }),
- runInstallVercelCliFlow: vi.fn<TuiSetupFlows["runInstallVercelCliFlow"]>(async () => ({
- kind: "failed",
- reason: "ERR_PNPM_NO_GLOBAL_BIN_DIR Unable to find the global bin directory",
- })),
- });
-
- await expect(run({ command: "model", flows, upgradeChoice: "upgrade" })).resolves.toEqual({
- message:
- "Couldn't upgrade the Vercel CLI (ERR_PNPM_NO_GLOBAL_BIN_DIR Unable to find the global bin directory) — run `vercel upgrade`, then retry /model.",
- tone: "error",
- preserveFlowDiagnostics: true,
- });
- });
-
it.each([
[
"added",
@@ -627,38 +379,6 @@ describe("runTuiSetupCommand", () => {
});
});
- it("preserves model access refreshes when provider setup is interrupted", async () => {
- const renderer = fakePanelRenderer();
- const flows = fakeFlows({
- runModelFlow: vi.fn<TuiSetupFlows["runModelFlow"]>(
- ({ signal }) =>
- new Promise((resolve) => {
- signal?.addEventListener(
- "abort",
- () =>
- resolve({
- kind: "done",
- accessChanged: true,
- providerSelection: "ai-gateway-key",
- }),
- { once: true },
- );
- }),
- ),
- });
-
- const result = run({ command: "model", flows, renderer });
- renderer.fireInterrupt();
-
- await expect(result).resolves.toEqual({
- message: "",
- cancelled: true,
- tone: undefined,
- preserveFlowDiagnostics: false,
- effect: { kind: "model-access-changed", reload: true },
- });
- });
-
it("routes a vercel-login action error without dropping completed registry items", async () => {
const cause = new HumanActionRequiredError({
kind: "vercel-login",
diff --git a/packages/eve/src/cli/dev/tui/setup-commands.ts b/packages/eve/src/cli/dev/tui/setup-commands.ts
index dcb9bc6d7..baa21b881 100644
--- a/packages/eve/src/cli/dev/tui/setup-commands.ts
+++ b/packages/eve/src/cli/dev/tui/setup-commands.ts
@@ -7,8 +7,6 @@ import {
type InstallVercelCliResult,
} from "#setup/flows/install-vercel-cli.js";
-import { runModelFlow } from "#setup/flows/model.js";
-import type { ProviderSelection } from "#setup/provider-settings.js";
import { RegistryFlowFailedError, runRegistryFlow } from "#setup/flows/registry.js";
import type { Prompter } from "#setup/prompter.js";
import { WizardCancelledError } from "#setup/step.js";
@@ -23,7 +21,7 @@ import type { PromptCommandExtensionName } from "./prompt-commands.js";
import type { SetupFlowIndicator, SetupFlowRenderer } from "./setup-flow.js";
import type { VercelStatusEffect } from "./vercel-status.js";
-export type TuiSetupCommand = PromptCommandExtensionName;
+export type TuiSetupCommand = Exclude<PromptCommandExtensionName, "model">;
/**
* Panel title and loading indicator per command. The bordered panel never
@@ -32,19 +30,15 @@ export type TuiSetupCommand = PromptCommandExtensionName;
*/
export const SETUP_FLOW_CONFIG = {
login: { title: "Connecting your model", indicator: "pulse" },
- model: { title: "Configure the agent model", indicator: "pulse" },
add: { title: "Add to your agent", indicator: "pulse" },
deploy: { title: "Deploy to Vercel", indicator: "spinner" },
} satisfies Record<TuiSetupCommand, { title: string; indicator: SetupFlowIndicator }>;
export type TuiSetupCommandRenderer = TuiPrompterRenderer &
- Pick<
- SetupFlowRenderer,
- "readProviderPicker" | "readModelPicker" | "setNavigation" | "waitForInterrupt"
- >;
+ Pick<SetupFlowRenderer, "readProviderPicker" | "setNavigation" | "waitForInterrupt">;
type MuteableSetupRenderer = TuiPrompterRenderer &
- Pick<SetupFlowRenderer, "readProviderPicker" | "readModelPicker" | "setNavigation">;
+ Pick<SetupFlowRenderer, "readProviderPicker" | "setNavigation">;
export type OnboardingScreenEvent = {
screen:
@@ -83,7 +77,6 @@ export interface TuiSetupCommandInput {
export interface TuiSetupFlows {
runModelLogin?: typeof runModelLogin;
runInstallVercelCliFlow: typeof runInstallVercelCliFlow;
- runModelFlow: typeof runModelFlow;
runRegistryFlow: typeof runRegistryFlow;
runDeployFlow: typeof runDeployFlow;
}
@@ -119,8 +112,6 @@ function muteableRenderer(
isMuted() ? Promise.resolve(undefined) : renderer.readEditableSelect(options),
readProviderPicker: (options) =>
isMuted() ? Promise.resolve(undefined) : renderer.readProviderPicker(options),
- readModelPicker: (options) =>
- isMuted() ? Promise.resolve(undefined) : renderer.readModelPicker(options),
readText: (options) => (isMuted() ? Promise.resolve(undefined) : renderer.readText(options)),
readAcknowledge: (options) =>
isMuted() ? Promise.resolve() : renderer.readAcknowledge(options),
@@ -245,7 +236,6 @@ async function executeSetupCommand(
const { command, appRoot } = input;
const flows: TuiSetupFlows = {
runInstallVercelCliFlow,
- runModelFlow,
runRegistryFlow,
runDeployFlow,
...input.flows,
@@ -278,46 +268,6 @@ async function executeSetupCommand(
preserveFlowDiagnostics: false,
};
}
- case "model": {
- const modelInput: Parameters<TuiSetupFlows["runModelFlow"]>[0] = {
- appRoot: input.agentRoot ?? appRoot,
- environmentRoot: appRoot,
- prompter,
- signal,
- chatGptAccountLabel: input.chatGptAccountLabel,
- deps: {
- pickModelSettings: (request) => renderer.readModelPicker(request),
- },
- };
- if (input.initialModelStep !== undefined) {
- modelInput.initialStep = input.initialModelStep;
- }
- if (input.onOnboardingScreen !== undefined) {
- modelInput.onScreen = (screen) => input.onOnboardingScreen?.({ screen });
- }
- const result = await flows.runModelFlow(modelInput);
- if (result.kind === "cancelled") {
- return cancelledSetupResult();
- }
- // One line per completed menu action: the apply line (it already
- // distinguishes success from a rejected slug), then the provider
- // selection when that sub-flow also ran.
- const lines: string[] = [];
- if (result.modelMessage !== undefined) lines.push(result.modelMessage);
- if (result.providerSelection !== undefined) {
- lines.push(providerSelectionMessage(result.providerSelection));
- }
- const outcome: TuiSetupCommandResult = {
- message: lines.join("\n"),
- preserveFlowDiagnostics: false,
- };
- // A model edit can also move routing between AI Gateway and ChatGPT.
- // The runner rebuilds authored artifacts before refreshing model access.
- if (result.accessChanged) {
- outcome.effect = { kind: "model-access-changed", reload: true };
- }
- return outcome;
- }
case "add": {
const flow = await flows.runRegistryFlow({
appRoot,
@@ -548,10 +498,3 @@ function vercelActionMessage(kind: string, command: string): string | undefined
return undefined;
}
}
-
-function providerSelectionMessage(selection: ProviderSelection): string {
- if (selection === "chatgpt") return "ChatGPT subscription selected.";
- return selection === "ai-gateway-project"
- ? "AI Gateway via Project selected."
- : "AI Gateway via API key selected.";
-}
diff --git a/packages/eve/src/cli/dev/tui/setup-flow.ts b/packages/eve/src/cli/dev/tui/setup-flow.ts
index 7fe793235..c611ea08d 100644
--- a/packages/eve/src/cli/dev/tui/setup-flow.ts
+++ b/packages/eve/src/cli/dev/tui/setup-flow.ts
@@ -1,6 +1,5 @@
import type { ChannelSetupChoice, ChannelSetupChoiceOptions } from "#setup/cli/index.js";
import type { SearchActionOption } from "#setup/cli/select-state.js";
-import type { ModelSettingsRequest, ModelSettingsResult } from "#setup/flows/model.js";
import type { ProviderPickerChoice, ProviderPickerRequest } from "#setup/flows/provider.js";
import type { PlannerNavigation, SelectMetadata, SelectNotice } from "#setup/prompter.js";
@@ -93,8 +92,6 @@ export interface SetupFlowRenderer {
}): Promise<SetupEditableSelectResult | undefined>;
/** Provider-only picker with masked async validation. Not part of Prompter. */
readProviderPicker(options: ProviderPickerRequest): Promise<ProviderPickerChoice | undefined>;
- /** Model, speed, and reasoning picker. Not part of Prompter. */
- readModelPicker(options: ModelSettingsRequest): Promise<ModelSettingsResult | undefined>;
readText(options: {
message: string;
placeholder?: string;
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
index 9df0500a0..2c70226a4 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
@@ -3114,13 +3114,14 @@ describe("TerminalRenderer (inline scrollback)", () => {
renderer.shutdown();
});
- it("paints a fully typed known command blue in the input line", async () => {
+ it("paints a fully typed known command bold in the input line", async () => {
const { screen, input, renderer } = makeRenderer();
const prompt = renderer.readPrompt();
input.type("/add");
- // The ANSI blue open (34) wraps the typed command in the painted row.
- expect(screen.rawOutput()).toContain("/add");
+ // Bold confirms command dispatch without competing with status color.
+ expect(screen.rawOutput()).toContain("/add");
+ expect(screen.rawOutput()).not.toContain("/add");
input.enter();
await prompt;
renderer.shutdown();
@@ -3133,7 +3134,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
// Never passes through a known command, even if painted per keystroke
// ("/li…" is not a known command).
input.type("/lin is not a command");
- expect(screen.rawOutput()).not.toContain("");
+ expect(screen.rawOutput()).not.toContain("/lin is not a command");
input.enter();
await prompt;
renderer.shutdown();
@@ -5241,6 +5242,116 @@ describe("TerminalRenderer command typeahead", () => {
renderer.shutdown();
});
+ it("shows loading before model argument suggestions arrive", async () => {
+ const screen = new MockScreen({ columns: 80, rows: 30 });
+ const input = new MockUserInput();
+ const suggestions = Promise.withResolvers<
+ readonly {
+ value: string;
+ label: string;
+ hint?: string;
+ }[]
+ >();
+ const renderer = new TerminalRenderer({
+ input,
+ output: screen,
+ captureForeignOutput: false,
+ unicode: true,
+ argumentSuggestions: async () => suggestions.promise,
+ });
+
+ const prompt = renderer.readPrompt();
+ input.type("/model ");
+ expect(screen.snapshot()).toContain("Loading models…");
+ suggestions.resolve([{ value: "openai/gpt-5", label: "GPT-5" }]);
+ await vi.waitFor(() => expect(screen.snapshot()).toContain("openai/gpt-5"));
+ input.enter();
+ await prompt;
+ renderer.shutdown();
+ });
+
+ it("advances to reasoning after selecting a model with reasoning choices", async () => {
+ const screen = new MockScreen({ columns: 80, rows: 30 });
+ const input = new MockUserInput();
+ const renderer = new TerminalRenderer({
+ input,
+ output: screen,
+ captureForeignOutput: false,
+ unicode: true,
+ argumentSuggestions: async () => [
+ {
+ value: "openai/gpt-6-sol",
+ label: "openai/gpt-6-sol",
+ next: [{ value: "high", label: "high" }],
+ },
+ ],
+ });
+
+ const prompt = renderer.readPrompt();
+ input.type("/model sol");
+ await vi.waitFor(() => expect(screen.snapshot()).toContain("openai/gpt-6-sol"));
+ input.enter();
+ expect(screen.snapshot()).toContain("❯ /model openai/gpt-6-sol ");
+ expect(screen.snapshot()).toContain("high");
+ input.enter();
+
+ expect(await prompt).toBe("/model openai/gpt-6-sol high");
+ renderer.shutdown();
+ });
+
+ it("completes a model argument from its inline catalog", async () => {
+ const screen = new MockScreen({ columns: 80, rows: 30 });
+ const input = new MockUserInput();
+ const renderer = new TerminalRenderer({
+ input,
+ output: screen,
+ captureForeignOutput: false,
+ unicode: true,
+ argumentSuggestions: async (command) =>
+ command === "model"
+ ? [
+ {
+ value: "anthropic/claude-sonnet-5",
+ label: "Claude Sonnet 5",
+ hint: "Anthropic",
+ },
+ ]
+ : [],
+ });
+
+ const prompt = renderer.readPrompt();
+ input.type("/model claude");
+ await vi.waitFor(() => expect(screen.snapshot()).toContain("anthropic/claude-sonnet-5"));
+ input.enter();
+
+ expect(await prompt).toBe("/model anthropic/claude-sonnet-5");
+ renderer.shutdown();
+ });
+
+ it("completes an add argument from its inline registry catalog", async () => {
+ const screen = new MockScreen({ columns: 80, rows: 30 });
+ const input = new MockUserInput();
+ const renderer = new TerminalRenderer({
+ input,
+ output: screen,
+ captureForeignOutput: false,
+ unicode: true,
+ argumentSuggestions: async (command) =>
+ command === "add"
+ ? [{ value: "channel/slack", label: "Slack", hint: "Slack channel" }]
+ : [],
+ });
+
+ const prompt = renderer.readPrompt();
+ input.type("/add slack");
+ await vi.waitFor(() => expect(screen.snapshot()).toContain("channel/slack"));
+ input.send("\t");
+ input.enter();
+
+ expect(await prompt).toBe("/add channel/slack");
+ renderer.shutdown();
+ });
+
it("tab completes the highlighted command without submitting", async () => {
const { input, renderer } = makeRenderer();
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
index a53359527..3c1978a70 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
@@ -18,6 +18,17 @@ import type {
SubagentToolUpdate,
} from "./runner.js";
import { interruptedError } from "./errors.js";
+import {
+ argumentTypeaheadCompletion,
+ argumentTypeaheadFor,
+ argumentTypeaheadLoadingLabel,
+ argumentTypeaheadQuery,
+ moveArgumentTypeaheadSelection,
+ renderArgumentSuggestions,
+ selectedArgumentSuggestion,
+ type ArgumentTypeaheadState,
+ type PromptArgumentSuggestion,
+} from "./argument-typeahead.js";
import {
dismissTypeahead,
inlineCommandHint,
@@ -49,13 +60,6 @@ import {
type SetupPanelOption,
type SetupSelectPanelState,
} from "./setup-panel.js";
-import {
- initialModelPickerState,
- transitionModelPicker,
- renderModelPicker,
- modelPickerTitle,
- type ModelPickerEvent,
-} from "./model-picker.js";
import type {
SetupEditableSelectResult,
SetupFlowIndicator,
@@ -66,7 +70,6 @@ import type {
SetupSelectResult,
} from "./setup-flow.js";
import type { PlannerNavigation, SelectNotice } from "#setup/prompter.js";
-import type { ModelSettingsRequest, ModelSettingsResult } from "#setup/flows/model.js";
import type { ProviderPickerChoice, ProviderPickerRequest } from "#setup/flows/provider.js";
import {
initialSelectState,
@@ -289,6 +292,8 @@ export type TerminalRendererOptions = {
diagnostics?: DevDiagnostics;
/** Slash commands available in this local or remote session. */
availablePromptCommands?: readonly PromptCommandSpec[];
+ /** Catalog entries available to inline `/model` and `/add` completion. */
+ argumentSuggestions?: (command: "model" | "add") => Promise<readonly PromptArgumentSuggestion[]>;
onExitRequest?: () => void;
};
@@ -471,6 +476,12 @@ export class TerminalRenderer implements AgentTUIRenderer {
* a `/`-prefixed freeform answer must never sprout suggestions.
*/
#typeahead?: CommandTypeaheadState;
+ #argumentTypeahead?: ArgumentTypeaheadState;
+ readonly #argumentSuggestions?: TerminalRendererOptions["argumentSuggestions"];
+ readonly #argumentCatalogs = new Map<
+ ArgumentTypeaheadState["command"],
+ { kind: "loading" } | { kind: "ready"; suggestions: readonly PromptArgumentSuggestion[] }
+ >();
/**
* Whether the empty input row invites with a rotating placeholder. Only
* the main chat prompt turns this on — a freeform question's empty input
@@ -620,7 +631,6 @@ export class TerminalRenderer implements AgentTUIRenderer {
readSelect: (options) => this.#readSetupSelect(options),
readEditableSelect: (options) => this.#readSetupEditableSelect(options),
readProviderPicker: (options) => this.#readProviderPicker(options),
- readModelPicker: (options) => this.#readModelPicker(options),
readText: (options) => this.#readSetupText(options),
readAcknowledge: (options) => this.#readSetupAcknowledge(options),
readChoice: (options) => this.#readSetupChoice(options),
@@ -661,10 +671,65 @@ export class TerminalRenderer implements AgentTUIRenderer {
this.#captureForeignOutput = options?.captureForeignOutput ?? this.#output === process.stdout;
this.#diagnostics = options?.diagnostics;
this.#onExitRequest = options?.onExitRequest;
+ this.#argumentSuggestions = options?.argumentSuggestions;
this.#logs = options?.logs ?? "none";
this.#availablePromptCommands = options?.availablePromptCommands ?? PROMPT_COMMANDS;
}
+ #syncTypeahead(text: string): void {
+ this.#typeahead = typeaheadFor(this.#availablePromptCommands, text, this.#typeahead);
+ const query = argumentTypeaheadQuery(text);
+ if (query === undefined || this.#argumentSuggestions === undefined) {
+ this.#argumentTypeahead = undefined;
+ return;
+ }
+ const catalog = this.#argumentCatalogs.get(query.command);
+ if (catalog === undefined) {
+ this.#argumentCatalogs.set(query.command, { kind: "loading" });
+ void this.#argumentSuggestions(query.command)
+ .catch(() => [])
+ .then((suggestions) => {
+ this.#argumentCatalogs.set(query.command, { kind: "ready", suggestions });
+ if (this.#inputActive) this.#syncTypeahead(this.#inputText);
+ this.#paint();
+ });
+ this.#argumentTypeahead = undefined;
+ return;
+ }
+ if (catalog.kind === "loading") {
+ this.#argumentTypeahead = undefined;
+ return;
+ }
+ this.#argumentTypeahead = argumentTypeaheadFor(
+ query,
+ catalog.suggestions,
+ this.#argumentTypeahead,
+ );
+ }
+
+ #typeaheadDrawerRows(width: number): string[] {
+ const query = argumentTypeaheadQuery(this.#inputText);
+ const catalog = query === undefined ? undefined : this.#argumentCatalogs.get(query.command);
+ if (catalog?.kind === "loading" && query !== undefined) {
+ return [
+ clip(
+ this.#theme.colors.dim(`Loading ${argumentTypeaheadLoadingLabel(query.command)}…`),
+ width,
+ ),
+ ];
+ }
+ if (this.#argumentTypeahead !== undefined) {
+ return renderArgumentSuggestions(this.#argumentTypeahead, this.#theme, width);
+ }
+ const inlineHint =
+ this.#typeahead === undefined ? undefined : inlineCommandHint(this.#typeahead);
+ return inlineHint === undefined &&
+ this.#typeahead !== undefined &&
+ isTypeaheadOpen(this.#typeahead)
+ ? renderCommandSuggestions(this.#typeahead, this.#theme, width)
+ : [];
+ }
+
setStartupPhase(phase: "starting" | "connecting" | "updating" | undefined): void {
this.#startupPhase = phase;
if (phase === undefined) this.#stopTicker();
@@ -808,7 +873,7 @@ export class TerminalRenderer implements AgentTUIRenderer {
this.#streamDraft = EMPTY_LINE;
this.#promptHistory.begin(editor.text);
this.#syncInput(editor);
- this.#typeahead = typeaheadFor(this.#availablePromptCommands, editor.text);
+ this.#syncTypeahead(editor.text);
this.#startCaretBlink();
this.#paint();
@@ -818,7 +883,7 @@ export class TerminalRenderer implements AgentTUIRenderer {
editor = next;
this.#showCaret();
this.#syncInput(editor);
- this.#typeahead = typeaheadFor(this.#availablePromptCommands, next.text, this.#typeahead);
+ this.#syncTypeahead(next.text);
this.#paint();
};
const recall = (entry: string | undefined) => {
@@ -834,6 +899,8 @@ export class TerminalRenderer implements AgentTUIRenderer {
this.#typeahead !== undefined && isTypeaheadOpen(this.#typeahead)
? this.#typeahead
: undefined;
+ const argumentSuggestions = () =>
+ this.#argumentTypeahead?.suggestions.length ? this.#argumentTypeahead : undefined;
const highlighted = () => {
const open = suggestions();
return open === undefined ? undefined : selectedTypeaheadCommand(open);
@@ -854,6 +921,12 @@ export class TerminalRenderer implements AgentTUIRenderer {
switch (key.type) {
case "up":
case "ctrl-p": {
+ const argumentOpen = argumentSuggestions();
+ if (argumentOpen !== undefined) {
+ this.#argumentTypeahead = moveArgumentTypeaheadSelection(argumentOpen, -1);
+ this.#paint();
+ break;
+ }
const open = suggestions();
if (open !== undefined) {
this.#typeahead = moveTypeaheadSelection(open, -1);
@@ -869,6 +942,12 @@ export class TerminalRenderer implements AgentTUIRenderer {
}
case "down":
case "ctrl-n": {
+ const argumentOpen = argumentSuggestions();
+ if (argumentOpen !== undefined) {
+ this.#argumentTypeahead = moveArgumentTypeaheadSelection(argumentOpen, 1);
+ this.#paint();
+ break;
+ }
const open = suggestions();
if (open !== undefined) {
this.#typeahead = moveTypeaheadSelection(open, 1);
@@ -881,11 +960,23 @@ export class TerminalRenderer implements AgentTUIRenderer {
break;
}
case "tab": {
+ const argumentOpen = argumentSuggestions();
+ const argumentSelected =
+ argumentOpen === undefined ? undefined : selectedArgumentSuggestion(argumentOpen);
+ if (argumentOpen !== undefined && argumentSelected !== undefined) {
+ apply(lineOf(argumentTypeaheadCompletion(argumentOpen, argumentSelected)));
+ break;
+ }
const selected = highlighted();
if (selected !== undefined) apply(lineOf(typeaheadCompletion(selected)));
break;
}
case "escape": {
+ if (this.#argumentTypeahead !== undefined) {
+ this.#argumentTypeahead = undefined;
+ this.#paint();
+ break;
+ }
const open = suggestions();
if (open !== undefined) {
this.#typeahead = dismissTypeahead(open);
@@ -894,17 +985,42 @@ export class TerminalRenderer implements AgentTUIRenderer {
break;
}
case "enter": {
+ const argumentOpen = argumentSuggestions();
+ const argumentSelected =
+ argumentOpen === undefined ? undefined : selectedArgumentSuggestion(argumentOpen);
const selected = highlighted();
// Complete only genuine prefixes: a draft that already parses
// (exact name, alias, or argument form) submits verbatim, so
// /quit echoes as the user typed it.
+ if (
+ argumentOpen !== undefined &&
+ argumentSelected?.next !== undefined &&
+ argumentOpen.completed.length === 0
+ ) {
+ apply(lineOf(`${argumentTypeaheadCompletion(argumentOpen, argumentSelected)} `));
+ break;
+ }
+ // `/add` and `/model` share their inline drawer whether the
+ // command was typed exactly or reached through slash completion.
+ if (
+ argumentOpen === undefined &&
+ selected !== undefined &&
+ this.#argumentSuggestions !== undefined &&
+ (selected.name === "add" || selected.name === "model")
+ ) {
+ apply(lineOf(typeaheadCompletion(selected)));
+ break;
+ }
const prompt =
- selected !== undefined && parsePromptCommand(editor.text) === null
- ? typeaheadCompletion(selected).trimEnd()
- : editor.text;
+ argumentOpen !== undefined && argumentSelected !== undefined
+ ? argumentTypeaheadCompletion(argumentOpen, argumentSelected)
+ : selected !== undefined && parsePromptCommand(editor.text) === null
+ ? typeaheadCompletion(selected).trimEnd()
+ : editor.text;
// An empty (or whitespace-only) buffer never submits.
if (prompt.trim().length === 0) break;
this.#typeahead = undefined;
+ this.#argumentTypeahead = undefined;
this.#promptHistory.add(prompt);
this.#inputActive = false;
this.#stopCaretBlink();
@@ -2444,68 +2560,6 @@ export class TerminalRenderer implements AgentTUIRenderer {
return await question.promise;
}
- async #readModelPicker(opts: ModelSettingsRequest): Promise<ModelSettingsResult | undefined> {
- let interaction = initialModelPickerState(opts);
- const flow = this.#beginSetupQuestion(modelPickerTitle(interaction));
- flow.question = (width) => renderModelPicker(opts, interaction, this.#theme, width);
- this.#paint();
-
- const question = this.#captureSetupQuestion<ModelSettingsResult | undefined>((key, settle) => {
- const dispatch = (event: ModelPickerEvent): void => {
- const transition = transitionModelPicker(interaction, event, opts);
- switch (transition.kind) {
- case "render":
- if (interaction === transition.state) return;
- interaction = transition.state;
- flow.questionTitle = modelPickerTitle(interaction);
- this.#paint();
- return;
- case "cancel":
- settle(undefined);
- return;
- case "settle":
- settle(transition.result);
- return;
- }
- };
-
- if (key.type === "ctrl-c") {
- dispatch({ type: "cancel" });
- return;
- }
- if (key.type === "escape" || key.type === "left") {
- dispatch({ type: "back" });
- return;
- }
- const intent = setupSelectionIntent(key);
- switch (intent?.kind) {
- case "move":
- dispatch({ type: intent.direction });
- return;
- case "submit":
- dispatch({ type: "submit" });
- return;
- case "repaint":
- this.#paint();
- return;
- }
- if (key.type === "backspace") {
- dispatch({ type: "backspace" });
- return;
- }
- if (key.type === "alt-backspace") {
- dispatch({ type: "delete-word-backward" });
- return;
- }
- if (key.type === "text") {
- for (const char of key.value.replaceAll("\n", " ")) {
- if (char >= " " && char !== "\u007f") dispatch({ type: "char", char });
- }
- }
- });
- return await question.promise;
- }
-
/**
* Asks one text question through the bordered setup panel. `mask` renders
* bullets (passwords); `validate` paints its message red inside the panel
@@ -4351,13 +4405,7 @@ export class TerminalRenderer implements AgentTUIRenderer {
// still open the list above the input.
const inlineHint =
this.#typeahead !== undefined ? inlineCommandHint(this.#typeahead) : undefined;
- if (
- inlineHint === undefined &&
- this.#typeahead !== undefined &&
- isTypeaheadOpen(this.#typeahead)
- ) {
- rows.push(...renderCommandSuggestions(this.#typeahead, this.#theme, width));
- }
+ const typeaheadRows = this.#typeaheadDrawerRows(width);
if (this.#exitArmed) {
rows.push(clip(c.dim("Press Ctrl+C again to exit"), width), "");
}
@@ -4370,7 +4418,16 @@ export class TerminalRenderer implements AgentTUIRenderer {
// Keep one transcript row above the footer and one separator below the
// prompt. Everything already in `rows` has higher-level footer ownership
// (attention or typeahead), so the prompt receives only what remains.
- const maxPromptRows = Math.max(1, this.#height() - 1 - rows.length - 1 - statusRows.length);
+ const maxPromptRows = Math.max(
+ 1,
+ this.#height() -
+ 1 -
+ rows.length -
+ 1 -
+ typeaheadRows.length -
+ statusRows.length -
+ (typeaheadRows.length > 0 ? 2 : 0),
+ );
const promptRows: Parameters<typeof promptInputRows>[0] = {
text: this.#inputText,
cursor: this.#inputCursor,
@@ -4391,7 +4448,16 @@ export class TerminalRenderer implements AgentTUIRenderer {
? ""
: "Send a message…";
}
- rows.push(...promptInputRows(promptRows));
+ const renderedPromptRows = promptInputRows(promptRows);
+ // The prompt helper ends with a footer spacer; a drawer owns that gap.
+ if (typeaheadRows.length > 0 && renderedPromptRows.at(-1) === "") renderedPromptRows.pop();
+ rows.push(...renderedPromptRows);
+ // Keep menus beneath the composer so opening them never moves the caret.
+ if (typeaheadRows.length > 0) rows.push(c.dim(this.#theme.glyph.dash.repeat(width)));
+ rows.push(...typeaheadRows);
+ if (typeaheadRows.length > 0 && statusRows.length > 0) {
+ rows.push(c.dim(this.#theme.glyph.dash.repeat(width)));
+ }
rows.push(...statusRows);
return rows;
}
@@ -4952,7 +5018,7 @@ interface PromptInputRowsInput {
readonly width: number;
readonly theme: Theme;
readonly caretVisible: boolean;
- /** A fully typed known command paints blue, confirming it will dispatch as a command. */
+ /** A fully typed known command is bold, confirming it will dispatch as a command. */
readonly isCommand: boolean;
readonly ghost: string;
readonly maxRows: number;
@@ -5004,7 +5070,7 @@ function promptInputRows({
const style = (segment: string): string => {
const rendered = renderInputText(segment);
- return isCommand && rendered.length > 0 ? c.blue(rendered) : rendered;
+ return isCommand && rendered.length > 0 ? c.bold(rendered) : rendered;
};
const layout = layoutPromptInput({ text, cursor });
diff --git a/packages/eve/src/cli/dev/tui/test/fake-setup-flow-renderer.ts b/packages/eve/src/cli/dev/tui/test/fake-setup-flow-renderer.ts
index 263e553ef..38a32f9a4 100644
--- a/packages/eve/src/cli/dev/tui/test/fake-setup-flow-renderer.ts
+++ b/packages/eve/src/cli/dev/tui/test/fake-setup-flow-renderer.ts
@@ -3,18 +3,13 @@ import type { SetupFlowRenderer } from "../setup-flow.js";
export function createFakeSetupFlowRenderer(
overrides: Partial<SetupFlowRenderer> = {},
): SetupFlowRenderer {
- const {
- readProviderPicker = async () => undefined,
- readModelPicker = async () => undefined,
- ...rest
- } = overrides;
+ const { readProviderPicker = async () => undefined, ...rest } = overrides;
return {
begin: () => {},
end: () => {},
readSelect: async () => undefined,
readEditableSelect: async () => undefined,
readProviderPicker,
- readModelPicker,
readText: async () => undefined,
readAcknowledge: async () => {},
readChoice: () => ({ choice: Promise.resolve(undefined), close: () => {} }),
diff --git a/packages/eve/src/cli/dev/tui/tui.ts b/packages/eve/src/cli/dev/tui/tui.ts
index f6d3831d8..031943f41 100644
--- a/packages/eve/src/cli/dev/tui/tui.ts
+++ b/packages/eve/src/cli/dev/tui/tui.ts
@@ -24,6 +24,7 @@ import { formatRemoteAuthChallengeMessage } from "./remote-auth-result.js";
import { probeMcpConnection } from "./mcp-connection-status.js";
import { EveTUIRunner, type EveTUIRunnerOptions } from "./runner.js";
import { TerminalRenderer } from "./terminal-renderer.js";
+import type { PromptArgumentSuggestion } from "./argument-typeahead.js";
import { remoteHost, type DevelopmentTuiTarget, type RemoteDevelopmentTarget } from "./target.js";
import type { TuiDisplayOptions } from "./types.js";
@@ -50,6 +51,40 @@ export interface RunDevelopmentTuiInput extends TuiDisplayOptions {
startup?: DevelopmentTuiStartup;
}
+function inlineArgumentSuggestions(appRoot: string) {
+ return async (command: "model" | "add"): Promise<readonly PromptArgumentSuggestion[]> => {
+ if (command === "model") {
+ const { gatewayModelCapabilities } = await import("#setup/boxes/model-capabilities.js");
+ const { fetchGatewayCatalog, modelOptionsFromCatalog } =
+ await import("#setup/boxes/select-model.js");
+ const catalog = await fetchGatewayCatalog().catch(() => undefined);
+ return modelOptionsFromCatalog(catalog).map((option) => {
+ const reasoning = gatewayModelCapabilities(catalog, option.value)?.reasoningLevels;
+ return {
+ value: option.value,
+ label: option.value,
+ hint: option.hint,
+ ...(reasoning === undefined || reasoning.length === 0
+ ? {}
+ : {
+ next: [
+ { value: "default", label: "default" },
+ ...reasoning.map((value) => ({ value, label: value })),
+ ],
+ }),
+ };
+ });
+ }
+ const { browseRegistryCatalog } = await import("#cli/commands/registry.js");
+ const catalog = await browseRegistryCatalog(appRoot);
+ return catalog.items.map((item) => ({
+ value: item.address,
+ label: item.name,
+ hint: item.description ?? item.address,
+ }));
+ };
+}
+
export interface DevelopmentTuiStartup {
readonly diagnostics: DevDiagnostics | undefined;
readonly renderer: TerminalRenderer;
@@ -68,6 +103,7 @@ export async function startDevelopmentTuiStartup(
const renderer = new TerminalRenderer({
...input,
diagnostics,
+ argumentSuggestions: inlineArgumentSuggestions(input.appRoot),
onExitRequest: input.onExitRequest,
});
renderer.beginStartupDraft({
@@ -173,6 +209,9 @@ export async function runDevelopmentTui(input: RunDevelopmentTuiInput): Promise<
serverUrl,
promptCommandHandler: createPromptCommandHandler({ target }),
availablePromptCommands: promptCommandsFor(target.kind),
+ ...(target.kind === "local"
+ ? { argumentSuggestions: inlineArgumentSuggestions(target.workspaceRoot) }
+ : {}),
formatTransportError: (error) =>
isVercelAuthChallenge(error)
? formatRemoteAuthChallengeMessage(serverUrl)
diff --git a/packages/eve/src/setup/flows/model.test.ts b/packages/eve/src/setup/flows/model.test.ts
deleted file mode 100644
index 02e8dab06..000000000
--- a/packages/eve/src/setup/flows/model.test.ts
+++ /dev/null
@@ -1,150 +0,0 @@
-import { describe, expect, it, vi } from "vitest";
-import { createFakePrompter } from "#internal/testing/fake-prompter.js";
-import { runModelFlow, type CurrentAgentModel, type ModelFlowDeps } from "./model.js";
-
-const provenance = vi.hoisted(() => ({ inspect: vi.fn(), authored: vi.fn(), models: vi.fn() }));
-vi.mock("#services/inspect-application.js", () => ({ inspectApplication: provenance.inspect }));
-vi.mock("./model-source-change.js", async (original) => ({
- ...(await original<typeof import("./model-source-change.js")>()),
- readAuthoredModelSelection: provenance.authored,
-}));
-vi.mock("#internal/model-auth/available-models.js", () => ({
- availableHelperModels: provenance.models,
-}));
-
-function deps(overrides: Partial<ModelFlowDeps> = {}): Partial<ModelFlowDeps> {
- return {
- readCurrentModel: vi.fn(async (): Promise<CurrentAgentModel> => ({
- id: "openai/gpt-5.6-luna-fast",
- routing: { kind: "gateway", target: "openai" },
- reasoning: null,
- serviceTier: { kind: "standard" },
- editable: true,
- settingsEditable: true,
- })),
- selectModel: { fetchModels: vi.fn(async () => []) },
- pickModelSettings: vi.fn(async () => ({ model: "anthropic/claude-sonnet-5" })),
- applySettings: vi.fn(async () => ({ kind: "changed", changed: ["model"] }) as const),
- ...overrides,
- };
-}
-
-describe("runModelFlow", () => {
- it("opens settings directly and applies a selection without a review or provider prompt", async () => {
- const fake = createFakePrompter();
- const flow = deps();
- const result = await runModelFlow({ appRoot: "/agent", prompter: fake.prompter, deps: flow });
- expect(fake.selectMessages).toEqual([]);
- expect(flow.applySettings).toHaveBeenCalledWith({
- appRoot: "/agent",
- patch: {
- model: { kind: "set", value: "anthropic/claude-sonnet-5" },
- reasoning: { kind: "keep" },
- gatewayServiceTier: { kind: "keep" },
- },
- });
- expect(result).toMatchObject({ kind: "done", accessChanged: true });
- });
- it("cancels without touching authored settings", async () => {
- const flow = deps({ pickModelSettings: vi.fn(async () => undefined) });
- expect(
- await runModelFlow({
- appRoot: "/agent",
- prompter: createFakePrompter().prompter,
- deps: flow,
- }),
- ).toEqual({ kind: "cancelled" });
- expect(flow.applySettings).not.toHaveBeenCalled();
- });
- it("reports a rejected edit without claiming a change", async () => {
- const flow = deps({
- applySettings: vi.fn(
- async () => ({ kind: "rejected", message: "Edit agent.ts manually." }) as const,
- ),
- });
- expect(
- await runModelFlow({
- appRoot: "/agent",
- prompter: createFakePrompter().prompter,
- deps: flow,
- }),
- ).toEqual({ kind: "done", accessChanged: false, modelMessage: "Edit agent.ts manually." });
- });
- it("removes default reasoning and standard service tier rather than writing sentinels", async () => {
- const flow = deps({
- pickModelSettings: vi.fn(
- async () => ({ reasoning: "default", serviceTier: "standard" }) as const,
- ),
- });
- await runModelFlow({ appRoot: "/agent", prompter: createFakePrompter().prompter, deps: flow });
- expect(flow.applySettings).toHaveBeenCalledWith(
- expect.objectContaining({
- patch: {
- model: { kind: "keep" },
- reasoning: { kind: "remove" },
- gatewayServiceTier: { kind: "remove" },
- },
- }),
- );
- });
-});
-
-it.each(["openai", "anthropic"])(
- "keeps a foreign %s call fixed without requesting eve credentials",
- async (provider) => {
- provenance.models.mockClear();
- provenance.authored.mockResolvedValue(undefined);
- provenance.inspect.mockResolvedValue({
- compiledState: {
- manifest: {
- config: {
- source: {},
- model: { id: "custom-model", source: {}, routing: { kind: "external", provider } },
- },
- },
- },
- });
- const picker = vi.fn(async () => undefined);
- await runModelFlow({
- appRoot: "/agent",
- prompter: createFakePrompter().prompter,
- deps: { pickModelSettings: picker, selectModel: { fetchModels: async () => [] } },
- });
- expect(picker).toHaveBeenCalledWith(
- expect.objectContaining({
- model: expect.objectContaining({ kind: "fixed", current: "custom-model" }),
- }),
- );
- expect(provenance.models).not.toHaveBeenCalled();
- },
-);
-it("loads a proven eve helper's model catalog", async () => {
- provenance.authored.mockResolvedValue("openai-api/custom-model");
- provenance.models.mockResolvedValue(["custom-model"]);
- provenance.inspect.mockResolvedValue({
- compiledState: {
- manifest: {
- config: {
- source: {},
- model: {
- id: "custom-model",
- source: {},
- routing: { kind: "external", provider: "openai" },
- },
- },
- },
- },
- });
- const picker = vi.fn(async () => undefined);
- await runModelFlow({
- appRoot: "/agent",
- prompter: createFakePrompter().prompter,
- deps: { pickModelSettings: picker, selectModel: { fetchModels: async () => [] } },
- });
- expect(provenance.models).toHaveBeenCalledWith("openai", undefined);
- expect(picker).toHaveBeenCalledWith(
- expect.objectContaining({
- model: expect.objectContaining({ kind: "pick", current: "openai-api/custom-model" }),
- }),
- );
-});
diff --git a/packages/eve/src/setup/flows/model.ts b/packages/eve/src/setup/flows/model.ts
index 1464208ff..f4abee74c 100644
--- a/packages/eve/src/setup/flows/model.ts
+++ b/packages/eve/src/setup/flows/model.ts
@@ -1,214 +1,12 @@
-import { availableHelperModels } from "#internal/model-auth/available-models.js";
-import type { ModelHelper } from "#shared/model-helper.js";
-import { MODEL_HELPERS, parseModelHelper } from "#shared/model-helper.js";
+import type { ModelRouting } from "#shared/agent-definition.js";
+import { parseModelHelper } from "#shared/model-helper.js";
import { inspectApplication } from "#services/inspect-application.js";
-import type { ProviderSelection } from "#setup/provider-settings.js";
-import type { AgentModelSettingsPatch } from "#source-change/apply-agent-model-settings.js";
-import {
- fetchGatewayCatalog,
- modelOptionsFromCatalog,
- type SelectModelDeps,
-} from "../boxes/select-model.js";
-import {
- gatewayModelCapabilities,
- type GatewayModelCapabilities,
- type ReasoningLevel,
-} from "../boxes/model-capabilities.js";
-import type { AgentReasoningDefinition, ModelRouting } from "#shared/agent-definition.js";
-import {
- readGatewayServiceTier,
- type GatewayServiceTierState,
-} from "#shared/gateway-service-tier.js";
-import type { Prompter, SelectOption } from "../prompter.js";
-import { withSpinner } from "../with-spinner.js";
-import {
- changeAgentModelSettings,
- readAuthoredModelSelection,
- formatApplyModelSettingsOutcome,
- type ApplyModelSettingsOutcome,
-} from "./model-source-change.js";
+import { readAuthoredModelSelection } from "./model-source-change.js";
-/** The current model id, its routing, and whether `/model` can rewrite it. */
-export interface CurrentAgentModel {
- id: string | null;
- helper?: ModelHelper;
- routing: ModelRouting | null;
- reasoning: AgentReasoningDefinition | null;
- serviceTier: GatewayServiceTierState;
- /**
- * The authored `model` is a string the source editor can rewrite. False for a
- * source-backed SDK model call (`gateway(...)`, `anthropic(...)`), which is
- * not a string literal — independent of how the model routes.
- */
- editable: boolean;
- /** Whether the top-level agent config object can carry reasoning/tier edits. */
- settingsEditable: boolean;
-}
-
-export type { GatewayServiceTierState };
-
-/**
- * The model picker inputs, resolved before it opens. The first step is a
- * searchable catalog, or a fixed model when
- * the authored model is a source-backed SDK call `/model` cannot rewrite.
- */
-export interface ModelSettingsRequest {
- model:
- | { kind: "pick"; options: readonly SelectOption<string>[]; current: string | null }
- | { kind: "fixed"; current: string | null; reason: string };
- /** Authored reasoning effort; null means the provider default. */
- reasoning: ReasoningLevel | null;
- /** Authored Gateway service tier. */
- serviceTier: GatewayServiceTierState;
- /** Whether the agent config object can carry reasoning/tier edits. */
- settingsEditable: boolean;
- /** True for a direct external provider, where Gateway tiers do not apply. */
- externalRouting: boolean;
- /** Capability lookup over the already-fetched catalog; called on every pick. */
- capabilitiesFor(modelId: string | null): GatewayModelCapabilities | undefined;
-}
-
-/**
- * A completed model or setting selection. Each field is present only when it differs from
- * the authored value; `"default"` and `"standard"` mean "remove the setting".
- */
-export interface ModelSettingsResult {
- model?: string;
- reasoning?: "default" | ReasoningLevel;
- serviceTier?: "standard" | "priority";
-}
-
-/** Renderer-owned model picker; only the dev TUI implements this. */
-export type ModelSettingsPicker = (
- request: ModelSettingsRequest,
-) => Promise<ModelSettingsResult | undefined>;
-
-/** Injected for tests; defaults to the real reads, fetches, and source edit. */
-export interface ModelFlowDeps {
- /**
- * Reads the model the runtime currently serves and how it routes; both null
- * before the first compile.
- */
- readCurrentModel: (appRoot: string) => Promise<CurrentAgentModel>;
- /** Applies one completed `/model` draft to authored source. */
- applySettings: (input: {
- appRoot: string;
- patch: AgentModelSettingsPatch;
- }) => Promise<ApplyModelSettingsOutcome>;
- /** Catalog fetch behind the shared model picker. */
- selectModel?: SelectModelDeps;
- /** The model picker; the dev TUI renderer implements it. */
- pickModelSettings?: ModelSettingsPicker;
-}
-
-export type ModelFlowResult =
- | {
- kind: "cancelled";
- /** Whether an incomplete selection was discarded. */
- discardedDraft?: boolean;
- }
- | {
- kind: "done";
- /** Whether authored source, auth, or Gateway selection committed. */
- accessChanged: boolean;
- /** The last apply line, when the model was changed this session. */
- modelMessage?: string;
- /** The provider selected in a completed provider sub-flow. */
- providerSelection?: ProviderSelection;
- };
-
-/** Selects a model, speed, and reasoning, then applies the completed selection together. */
-export async function runModelFlow(input: {
- /** Selected agent root whose authored model settings are edited. */
- appRoot: string;
- /** Project root for shared provider configuration and Vercel credentials. */
- environmentRoot?: string;
- prompter: Prompter;
- /** Opens provider setup before the root menu when runtime evidence requires it. */
- initialStep?: "provider";
- onScreen?: (screen: "model_provider" | "model_settings") => void;
- signal?: AbortSignal;
- /** Live ChatGPT identity shown in this configuration flow only. */
- chatGptAccountLabel?: string;
- deps?: Partial<ModelFlowDeps>;
-}): Promise<ModelFlowResult> {
- const { appRoot, prompter, signal } = input;
- const deps: ModelFlowDeps = {
- readCurrentModel: readCurrentAgentModel,
- applySettings: changeAgentModelSettings,
- ...input.deps,
- };
-
- const [currentModel, catalog] = await withSpinner(prompter, "Loading models…", () =>
- Promise.all([
- deps.readCurrentModel(appRoot),
- (deps.selectModel?.fetchModels ?? fetchGatewayCatalog)(signal).catch(() => undefined),
- ]),
- );
- const helper =
- currentModel.helper === undefined
- ? undefined
- : ([currentModel.helper, MODEL_HELPERS[currentModel.helper]] as const);
- const options = helper
- ? (await availableHelperModels(helper[0], signal)).map((id) => ({
- value: helper[1].prefix + id,
- label: id,
- }))
- : modelOptionsFromCatalog(catalog);
- if (!deps.pickModelSettings) throw new Error("The model picker is unavailable.");
- const result = await deps.pickModelSettings({
- model: currentModel.editable
- ? {
- kind: "pick",
- options,
- current:
- helper && currentModel.id
- ? helper[1].prefix + currentModel.id.replace(/^[^/]+\//u, "")
- : currentModel.id,
- }
- : {
- kind: "fixed",
- current: currentModel.id,
- reason: "This model is configured in agent.ts.",
- },
- reasoning: currentModel.reasoning === "provider-default" ? null : currentModel.reasoning,
- serviceTier: currentModel.serviceTier,
- settingsEditable: currentModel.settingsEditable,
- externalRouting: currentModel.routing?.kind === "external",
- capabilitiesFor: (id) =>
- gatewayModelCapabilities(
- catalog,
- helper && id
- ? `${helper[0] === "chatgpt" ? "openai" : helper[0]}/${id.slice(helper[1].prefix.length)}`
- : id,
- ),
- });
- if (!result) return { kind: "cancelled" };
- signal?.throwIfAborted();
- const applied = await deps.applySettings({
- appRoot,
- patch: {
- model: result.model === undefined ? { kind: "keep" } : { kind: "set", value: result.model },
- reasoning:
- result.reasoning === undefined
- ? { kind: "keep" }
- : result.reasoning === "default"
- ? { kind: "remove" }
- : { kind: "set", value: result.reasoning },
- gatewayServiceTier:
- result.serviceTier === undefined
- ? { kind: "keep" }
- : result.serviceTier === "standard"
- ? { kind: "remove" }
- : { kind: "set", value: "priority" },
- },
- });
- return {
- kind: "done",
- accessChanged: applied.kind === "changed",
- modelMessage: formatApplyModelSettingsOutcome(applied),
- };
+interface CurrentAgentModel {
+ readonly editable: boolean;
+ readonly routing: ModelRouting | null;
}
/**
@@ -225,25 +23,13 @@ async function readCurrentAgentModel(appRoot: string): Promise<CurrentAgentModel
model?.source === undefined ? undefined : await readAuthoredModelSelection(appRoot);
const helper = authored === undefined ? undefined : parseModelHelper(authored)?.helper;
return {
- id:
- helper && model !== undefined
- ? `${MODEL_HELPERS[helper].prefix}${model.id}`
- : (model?.id ?? null),
- helper,
routing: model?.routing ?? null,
- reasoning: config?.reasoning ?? null,
- serviceTier: readGatewayServiceTier(model?.providerOptions),
editable: model !== undefined && (model.source === undefined || helper !== undefined),
- settingsEditable: config?.source !== undefined,
};
} catch {
return {
- id: null,
routing: null,
- reasoning: null,
- serviceTier: { kind: "standard" },
editable: false,
- settingsEditable: false,
};
}
}