Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

feat(tui): clarify slash command autocomplete (#474)

Sebastian Müller45be55c8e1aa
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index 2f75f212b8..a5ad06e7cc 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -2,6 +2,7 @@
## [Unreleased]
+- Changed slash-command autocomplete to separate argument hints and resource provenance, show only the selected command description, and summarize hidden results directionally.
- Fixed cancelled extension commands remaining alive when spawned processes ignored SIGTERM ([#458](https://github.com/PrimeIntellect-ai/prime-agent/pull/458) by [@snimu](https://github.com/snimu)).
- Fixed OAuth browser launch URLs being interpreted by the system shell.
- Changed long live session opens to render a bounded recent transcript tail while preserving full prompt history ([#343](https://github.com/PrimeIntellect-ai/prime-agent/pull/343) by [@sethkarten](https://github.com/sethkarten)).
diff --git a/packages/coding-agent/src/core/prompt-templates.ts b/packages/coding-agent/src/core/prompt-templates.ts
index 8527f9111d..8a4400e9ed 100644
--- a/packages/coding-agent/src/core/prompt-templates.ts
+++ b/packages/coding-agent/src/core/prompt-templates.ts
@@ -104,12 +104,12 @@ export function substituteArgs(content: string, args: string[]): string {
function loadTemplateFromFile(filePath: string, sourceInfo: SourceInfo): PromptTemplate | null {
try {
const rawContent = readFileSync(filePath, "utf-8");
- const { frontmatter, body } = parseFrontmatter<Record<string, string>>(rawContent);
+ const { frontmatter, body } = parseFrontmatter(rawContent);
const name = basename(filePath).replace(/\.md$/, "");
// Get description from frontmatter or first non-empty line
- let description = frontmatter.description || "";
+ let description = typeof frontmatter.description === "string" ? frontmatter.description : "";
if (!description) {
const firstLine = body.split("\n").find((line) => line.trim());
if (firstLine) {
@@ -118,11 +118,12 @@ function loadTemplateFromFile(filePath: string, sourceInfo: SourceInfo): PromptT
if (firstLine.length > 60) description += "...";
}
}
+ const argumentHint = typeof frontmatter["argument-hint"] === "string" ? frontmatter["argument-hint"] : undefined;
return {
name,
description,
- ...(frontmatter["argument-hint"] && { argumentHint: frontmatter["argument-hint"] }),
+ ...(argumentHint && { argumentHint }),
content: body,
sourceInfo,
filePath,
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index bfe7b30fab..643b512925 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -1139,7 +1139,8 @@ export class InteractiveMode {
return undefined;
}
- const scopePrefix = sourceInfo.scope === "user" ? "u" : sourceInfo.scope === "project" ? "p" : "t";
+ const scopePrefix =
+ sourceInfo.scope === "user" ? "user" : sourceInfo.scope === "project" ? "project" : "temporary";
const source = sourceInfo.source.trim();
if (source === "builtin") {
@@ -1163,15 +1164,9 @@ export class InteractiveMode {
return scopePrefix;
}
- private prefixAutocompleteDescription(
- description: string | undefined,
- sourceInfo?: AgentConnectionSourceInfo,
- ): string | undefined {
+ private getAutocompleteSourceLabel(sourceInfo?: AgentConnectionSourceInfo): string | undefined {
const sourceTag = this.getAutocompleteSourceTag(sourceInfo);
- if (!sourceTag) {
- return description;
- }
- return description ? `[${sourceTag}] ${description}` : `[${sourceTag}]`;
+ return sourceTag ? `#${sourceTag}` : undefined;
}
private getBuiltInCommandConflictDiagnostics(
@@ -1229,7 +1224,8 @@ export class InteractiveMode {
.filter((cmd) => cmd.source === "prompt")
.map((cmd) => ({
name: cmd.name,
- description: this.prefixAutocompleteDescription(cmd.description, cmd.sourceInfo),
+ description: cmd.description,
+ sourceTag: this.getAutocompleteSourceLabel(cmd.sourceInfo),
...(cmd.argumentHint && { argumentHint: cmd.argumentHint }),
}));
@@ -1239,7 +1235,8 @@ export class InteractiveMode {
.filter((cmd) => !isBuiltinSlashCommandName(cmd.name))
.map((cmd) => ({
name: cmd.name,
- description: this.prefixAutocompleteDescription(cmd.description, cmd.sourceInfo),
+ description: cmd.description,
+ sourceTag: this.getAutocompleteSourceLabel(cmd.sourceInfo),
getArgumentCompletions: this.bindLocalSessionExtensions
? this.getLocalSessionHost().getExtensionRunner().getCommand(cmd.name)?.getArgumentCompletions
: undefined,
@@ -1253,7 +1250,8 @@ export class InteractiveMode {
const commandName = skill.name;
skillCommandList.push({
name: commandName,
- description: this.prefixAutocompleteDescription(skill.description, skill.sourceInfo),
+ description: skill.description,
+ sourceTag: this.getAutocompleteSourceLabel(skill.sourceInfo),
});
}
}
diff --git a/packages/coding-agent/src/modes/interactive/theme/theme.ts b/packages/coding-agent/src/modes/interactive/theme/theme.ts
index 7cd2b9bd0a..a6e48bed73 100644
--- a/packages/coding-agent/src/modes/interactive/theme/theme.ts
+++ b/packages/coding-agent/src/modes/interactive/theme/theme.ts
@@ -1259,6 +1259,8 @@ export function getSelectListTheme(): SelectListTheme {
selectedPrefix: (text: string) => theme.fg("accent", text),
selectedText: (text: string) => theme.fg("accent", text),
description: (text: string) => theme.fg("muted", text),
+ argumentHint: (text: string) => theme.fg("mdCode", text),
+ sourceTag: (text: string) => theme.fg("dim", text),
scrollInfo: (text: string) => theme.fg("muted", text),
noMatch: (text: string) => theme.fg("muted", text),
};
diff --git a/packages/coding-agent/test/prompt-templates.test.ts b/packages/coding-agent/test/prompt-templates.test.ts
index 67be0da4e2..7a70f9949b 100644
--- a/packages/coding-agent/test/prompt-templates.test.ts
+++ b/packages/coding-agent/test/prompt-templates.test.ts
@@ -485,6 +485,31 @@ Do something`,
expect(tmpl!.argumentHint).toBeUndefined();
});
+ test("should ignore non-string frontmatter metadata", () => {
+ writeTemplate(
+ "invalid-metadata",
+ `---
+description:
+ - not
+ - a string
+argument-hint: [temporary-value]
+---
+Fallback description from the template body`,
+ );
+
+ const templates = loadPromptTemplates({
+ cwd: process.cwd(),
+ agentDir: getAgentDir(),
+ promptPaths: [testDir],
+ includeDefaults: false,
+ });
+
+ const tmpl = templates.find((t) => t.name === "invalid-metadata");
+ expect(tmpl).toBeDefined();
+ expect(tmpl!.argumentHint).toBeUndefined();
+ expect(tmpl!.description).toBe("Fallback description from the template body");
+ });
+
test("should preserve argument-hint with special characters", () => {
writeTemplate(
"is",
diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md
index 0e8f4c4ce4..d0c52dbcc2 100644
--- a/packages/tui/CHANGELOG.md
+++ b/packages/tui/CHANGELOG.md
@@ -2,6 +2,8 @@
## [Unreleased]
+- Changed slash-command autocomplete to show argument hints and source tags inline, selected descriptions separately, and directional hidden-result counts.
+
## [0.3.2] - 2026-07-20
- Removed the fullscreen image fallback instruction and kept fullscreen overlays from emitting terminal graphics ([#437](https://github.com/PrimeIntellect-ai/prime-agent/pull/437) by [@snimu](https://github.com/snimu)).
diff --git a/packages/tui/src/autocomplete.ts b/packages/tui/src/autocomplete.ts
index aba5fa101d..bc11f530e4 100644
--- a/packages/tui/src/autocomplete.ts
+++ b/packages/tui/src/autocomplete.ts
@@ -221,6 +221,8 @@ export interface AutocompleteItem {
value: string;
label: string;
description?: string;
+ argumentHint?: string;
+ sourceTag?: string;
takesArgument?: boolean;
}
@@ -231,6 +233,7 @@ export interface SlashCommand {
aliases?: readonly string[];
description?: string;
argumentHint?: string;
+ sourceTag?: string;
takesArgument?: boolean;
// Function to get argument completions for this command
// Returns null if no argument completion is available
@@ -314,15 +317,16 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
const commandItems = this.commands.map((cmd) => {
const name = "name" in cmd ? cmd.name : cmd.value;
const aliases = "aliases" in cmd && cmd.aliases ? cmd.aliases : [];
- const hint = "argumentHint" in cmd && cmd.argumentHint ? cmd.argumentHint : undefined;
- const desc = cmd.description ?? "";
- const fullDesc = hint ? (desc ? `${hint} — ${desc}` : hint) : desc;
+ const argumentHint = "argumentHint" in cmd && cmd.argumentHint ? cmd.argumentHint : undefined;
+ const sourceTag = "sourceTag" in cmd && cmd.sourceTag ? cmd.sourceTag : undefined;
const takesArgument = "takesArgument" in cmd ? cmd.takesArgument === true : false;
return {
name,
searchText: [name, ...aliases].join(" "),
label: name,
- description: fullDesc || undefined,
+ description: cmd.description,
+ argumentHint,
+ sourceTag,
takesArgument,
};
});
@@ -331,6 +335,8 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
value: item.name,
label: item.label,
...(item.description && { description: item.description }),
+ ...(item.argumentHint && { argumentHint: item.argumentHint }),
+ ...(item.sourceTag && { sourceTag: item.sourceTag }),
...(item.takesArgument && { takesArgument: true }),
}));
diff --git a/packages/tui/src/components/editor.ts b/packages/tui/src/components/editor.ts
index 52a8e58243..b066f007c8 100644
--- a/packages/tui/src/components/editor.ts
+++ b/packages/tui/src/components/editor.ts
@@ -245,6 +245,8 @@ export interface EditorOptions {
const SLASH_COMMAND_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {
minPrimaryColumnWidth: 12,
maxPrimaryColumnWidth: 32,
+ showItemMetadata: true,
+ showDirectionalScrollInfo: true,
showSelectedDescription: true,
};
diff --git a/packages/tui/src/components/select-list.ts b/packages/tui/src/components/select-list.ts
index 1993bb524e..0da8a8cf17 100644
--- a/packages/tui/src/components/select-list.ts
+++ b/packages/tui/src/components/select-list.ts
@@ -13,6 +13,8 @@ export interface SelectItem {
value: string;
label: string;
description?: string;
+ argumentHint?: string;
+ sourceTag?: string;
takesArgument?: boolean;
}
@@ -20,6 +22,8 @@ export interface SelectListTheme {
selectedPrefix: (text: string) => string;
selectedText: (text: string) => string;
description: (text: string) => string;
+ argumentHint?: (text: string) => string;
+ sourceTag?: (text: string) => string;
scrollInfo: (text: string) => string;
noMatch: (text: string) => string;
}
@@ -36,6 +40,8 @@ export interface SelectListLayoutOptions {
minPrimaryColumnWidth?: number;
maxPrimaryColumnWidth?: number;
truncatePrimary?: (context: SelectListTruncatePrimaryContext) => string;
+ showItemMetadata?: boolean;
+ showDirectionalScrollInfo?: boolean;
showSelectedDescription?: boolean;
}
@@ -101,10 +107,10 @@ export class SelectList implements Component {
lines.push(this.renderItem(item, isSelected, width, descriptionSingleLine, primaryColumnWidth));
}
- // Add scroll indicators if needed
if (startIndex > 0 || endIndex < this.filteredItems.length) {
- const scrollText = ` (${this.selectedIndex + 1}/${this.filteredItems.length})`;
- // Truncate if too long for terminal
+ const scrollText = this.layout.showDirectionalScrollInfo
+ ? this.formatDirectionalScrollInfo(startIndex, this.filteredItems.length - endIndex)
+ : ` (${this.selectedIndex + 1}/${this.filteredItems.length})`;
lines.push(this.theme.scrollInfo(truncateToWidth(scrollText, width - 2, "")));
}
@@ -152,6 +158,10 @@ export class SelectList implements Component {
const prefix = isSelected ? "→ " : " ";
const prefixWidth = visibleWidth(prefix);
+ if (this.layout.showItemMetadata) {
+ return this.renderMetadataItem(item, isSelected, width, primaryColumnWidth, prefix, prefixWidth);
+ }
+
if (descriptionSingleLine && width > 40) {
const effectivePrimaryColumnWidth = Math.max(1, Math.min(primaryColumnWidth, width - prefixWidth - 4));
const maxPrimaryWidth = Math.max(1, effectivePrimaryColumnWidth - PRIMARY_COLUMN_GAP);
@@ -181,6 +191,58 @@ export class SelectList implements Component {
return prefix + truncatedValue;
}
+ private formatDirectionalScrollInfo(hiddenAbove: number, hiddenBelow: number): string {
+ const indicators = [
+ hiddenAbove > 0 ? `↑ ${hiddenAbove} more` : undefined,
+ hiddenBelow > 0 ? `↓ ${hiddenBelow} more` : undefined,
+ ].filter((indicator): indicator is string => indicator !== undefined);
+ return ` ${indicators.join(" ")}`;
+ }
+
+ private renderMetadataItem(
+ item: SelectItem,
+ isSelected: boolean,
+ width: number,
+ primaryColumnWidth: number,
+ prefix: string,
+ prefixWidth: number,
+ ): string {
+ const argumentHint = item.argumentHint ? normalizeToSingleLine(item.argumentHint) : undefined;
+ const sourceTag = item.sourceTag ? normalizeToSingleLine(item.sourceTag) : undefined;
+ const hasMetadata = Boolean(argumentHint || sourceTag);
+ const contentWidth = Math.max(1, width - prefixWidth - 2);
+ const showMetadata = hasMetadata && contentWidth > primaryColumnWidth;
+ const effectivePrimaryColumnWidth = showMetadata ? primaryColumnWidth : contentWidth;
+ const maxPrimaryWidth = showMetadata
+ ? Math.max(1, effectivePrimaryColumnWidth - PRIMARY_COLUMN_GAP)
+ : effectivePrimaryColumnWidth;
+ const primary = this.truncatePrimary(item, isSelected, maxPrimaryWidth, effectivePrimaryColumnWidth);
+ const styledPrefix = isSelected ? this.theme.selectedPrefix(prefix) : prefix;
+ const styledPrimary = isSelected ? this.theme.selectedText(primary) : primary;
+ if (!showMetadata) {
+ return truncateToWidth(`${styledPrefix}${styledPrimary}`, width, "");
+ }
+
+ const spacing = " ".repeat(Math.max(1, effectivePrimaryColumnWidth - visibleWidth(primary)));
+ let remainingWidth = Math.max(0, width - prefixWidth - visibleWidth(primary) - spacing.length - 2);
+ const metadata: string[] = [];
+ if (argumentHint && remainingWidth > 0) {
+ const truncatedArgumentHint = truncateToWidth(argumentHint, remainingWidth, "…");
+ metadata.push((this.theme.argumentHint ?? this.theme.description)(truncatedArgumentHint));
+ remainingWidth -= visibleWidth(truncatedArgumentHint);
+ }
+ if (sourceTag && remainingWidth > (metadata.length > 0 ? PRIMARY_COLUMN_GAP : 0)) {
+ if (metadata.length > 0) {
+ metadata.push(" ".repeat(PRIMARY_COLUMN_GAP));
+ remainingWidth -= PRIMARY_COLUMN_GAP;
+ }
+ metadata.push(
+ (this.theme.sourceTag ?? this.theme.description)(truncateToWidth(sourceTag, remainingWidth, "…")),
+ );
+ }
+ return truncateToWidth(`${styledPrefix}${styledPrimary}${spacing}${metadata.join("")}`, width, "");
+ }
+
private getPrimaryColumnWidth(): number {
const { min, max } = this.getPrimaryColumnBounds();
const widestPrimary = this.filteredItems.reduce((widest, item) => {
diff --git a/packages/tui/test/autocomplete.test.ts b/packages/tui/test/autocomplete.test.ts
index b7df453b01..d85300a04d 100644
--- a/packages/tui/test/autocomplete.test.ts
+++ b/packages/tui/test/autocomplete.test.ts
@@ -124,6 +124,41 @@ describe("CombinedAutocompleteProvider", () => {
assert.deepStrictEqual(fresh?.items, [{ value: "new", label: "new", description: "Start a new session" }]);
});
+ it("keeps argument hints and source tags separate from descriptions", async () => {
+ const provider = new CombinedAutocompleteProvider(
+ [
+ {
+ name: "compact",
+ description: "Compact the session context",
+ argumentHint: "[instructions]",
+ },
+ {
+ name: "skill:compact",
+ description: "Check context usage",
+ sourceTag: "#builtin",
+ },
+ ],
+ "/tmp",
+ );
+
+ const result = await getSuggestions(provider, ["/compact"], 0, 8);
+
+ assert.deepStrictEqual(result?.items, [
+ {
+ value: "compact",
+ label: "compact",
+ description: "Compact the session context",
+ argumentHint: "[instructions]",
+ },
+ {
+ value: "skill:compact",
+ label: "skill:compact",
+ description: "Check context usage",
+ sourceTag: "#builtin",
+ },
+ ]);
+ });
+
it("suggests skill commands for inline references", async () => {
const provider = new CombinedAutocompleteProvider(
[{ name: "skill:brainstorm", description: "Brainstorm approaches" }],
diff --git a/packages/tui/test/select-list.test.ts b/packages/tui/test/select-list.test.ts
index 3133610c18..ee5524bc91 100644
--- a/packages/tui/test/select-list.test.ts
+++ b/packages/tui/test/select-list.test.ts
@@ -88,6 +88,113 @@ describe("SelectList", () => {
assert.equal(shortSelection.at(-1)?.trim(), "Short description");
});
+ it("shows slash metadata in rows and only the selected description below", () => {
+ const items = [
+ {
+ value: "compact",
+ label: "compact",
+ description: "Compact the session context",
+ argumentHint: "[instructions]",
+ },
+ {
+ value: "skill:compact",
+ label: "skill:compact",
+ description: "Check context usage and compact the conversation",
+ sourceTag: "#builtin",
+ },
+ ];
+ const list = new SelectList(items, 5, testTheme, {
+ minPrimaryColumnWidth: 12,
+ maxPrimaryColumnWidth: 32,
+ showItemMetadata: true,
+ showSelectedDescription: true,
+ });
+
+ const rendered = list.render(80);
+
+ assert.match(rendered[0] ?? "", /compact\s+\[instructions\]/);
+ assert.match(rendered[1] ?? "", /skill:compact\s+#builtin/);
+ assert.ok(!rendered[0]?.includes("Compact the session context"));
+ assert.equal(
+ rendered
+ .slice(3)
+ .map((line) => line.trim())
+ .join(" "),
+ "Compact the session context",
+ );
+ });
+
+ it("bounds styled Unicode metadata rows at narrow widths", () => {
+ const items = [
+ {
+ value: "技能:圧縮",
+ label: "技能:圧縮",
+ argumentHint: "[非常に長い指示]",
+ sourceTag: "#builtin",
+ },
+ ];
+ const styledTheme = {
+ ...testTheme,
+ selectedPrefix: (text: string) => `\x1b[36m${text}\x1b[39m`,
+ selectedText: (text: string) => `\x1b[35m${text}\x1b[39m`,
+ argumentHint: (text: string) => `\x1b[33m${text}\x1b[39m`,
+ sourceTag: (text: string) => `\x1b[32m${text}\x1b[39m`,
+ };
+ const list = new SelectList(items, 5, styledTheme, {
+ minPrimaryColumnWidth: 12,
+ maxPrimaryColumnWidth: 32,
+ showItemMetadata: true,
+ });
+
+ for (const width of [1, 2, 3, 4, 8, 12, 20, 40]) {
+ const rendered = list.render(width);
+ assert.ok(
+ rendered.every((line) => visibleWidth(line) <= width),
+ `render exceeded width ${width}`,
+ );
+ }
+ });
+
+ it("normalizes multiline metadata to a single row", () => {
+ const list = new SelectList(
+ [
+ {
+ value: "review",
+ label: "review",
+ argumentHint: "<first>\n<second>",
+ sourceTag: "#project\nscope",
+ },
+ ],
+ 5,
+ testTheme,
+ {
+ minPrimaryColumnWidth: 12,
+ maxPrimaryColumnWidth: 32,
+ showItemMetadata: true,
+ },
+ );
+
+ const rendered = list.render(80);
+
+ assert.equal(rendered.length, 1);
+ assert.doesNotMatch(rendered[0] ?? "", /[\r\n]/);
+ assert.match(rendered[0] ?? "", /review\s+<first> <second>\s+#project scope/);
+ });
+
+ it("shows directional hidden counts at the top, middle, and bottom", () => {
+ const items = Array.from({ length: 12 }, (_, index) => ({
+ value: `item-${index}`,
+ label: `item-${index}`,
+ }));
+ const list = new SelectList(items, 5, testTheme, { showDirectionalScrollInfo: true });
+
+ assert.equal(list.render(80).at(-1)?.trim(), "↓ 7 more");
+ list.setSelectedIndex(6);
+ assert.equal(list.render(80).at(-1)?.trim(), "↑ 4 more ↓ 3 more");
+ list.setSelectedIndex(11);
+ assert.equal(list.render(80).at(-1)?.trim(), "↑ 7 more");
+ });
+
it("keeps descriptions aligned when the primary text is truncated", () => {
const items = [
{ value: "short", label: "short", description: "short description" },