Add composer suggestions and git action overlay

- Suggest files, skills, and commands from composer triggers
- Show git action progress, success, and error feedback
This commit is contained in:
Julius Marminge committed 2026-04-14 00:02:56 -07:00
1 parent 99190d7742
commit fbcf04a2a3
13 files changed
+1000 -188

No files matched your search

+13 -89
View File
@@ -1,16 +1,18 @@
import {
detectComposerTrigger as detectComposerTriggerBase,
type ComposerTrigger,
type ComposerTriggerKind,
type ComposerSlashCommand,
} from "@t3tools/shared/composerTrigger";
export {
replaceTextRange,
parseStandaloneComposerSlashCommand,
} from "@t3tools/shared/composerTrigger";
export type { ComposerTrigger, ComposerTriggerKind, ComposerSlashCommand };
import { splitPromptIntoComposerSegments } from "./composer-editor-mentions";
import { INLINE_TERMINAL_CONTEXT_PLACEHOLDER } from "./lib/terminalContext";
export type ComposerTriggerKind = "path" | "slash-command" | "slash-model" | "skill";
export type ComposerSlashCommand = "model" | "plan" | "default";
export interface ComposerTrigger {
kind: ComposerTriggerKind;
query: string;
rangeStart: number;
rangeEnd: number;
}
const isInlineTokenSegment = (
segment:
| { type: "text"; text: string }
@@ -216,83 +218,5 @@ export function isCollapsedCursorAdjacentToInlineToken(
export const isCollapsedCursorAdjacentToMention = isCollapsedCursorAdjacentToInlineToken;
export function detectComposerTrigger(text: string, cursorInput: number): ComposerTrigger | null {
const cursor = clampCursor(text, cursorInput);
const lineStart = text.lastIndexOf("\n", Math.max(0, cursor - 1)) + 1;
const linePrefix = text.slice(lineStart, cursor);
if (linePrefix.startsWith("/")) {
const commandMatch = /^\/(\S*)$/.exec(linePrefix);
if (commandMatch) {
const commandQuery = commandMatch[1] ?? "";
if (commandQuery.toLowerCase() === "model") {
return {
kind: "slash-model",
query: "",
rangeStart: lineStart,
rangeEnd: cursor,
};
}
return {
kind: "slash-command",
query: commandQuery,
rangeStart: lineStart,
rangeEnd: cursor,
};
}
const modelMatch = /^\/model(?:\s+(.*))?$/.exec(linePrefix);
if (modelMatch) {
return {
kind: "slash-model",
query: (modelMatch[1] ?? "").trim(),
rangeStart: lineStart,
rangeEnd: cursor,
};
}
}
const tokenStart = tokenStartForCursor(text, cursor);
const token = text.slice(tokenStart, cursor);
if (token.startsWith("$")) {
return {
kind: "skill",
query: token.slice(1),
rangeStart: tokenStart,
rangeEnd: cursor,
};
}
if (!token.startsWith("@")) {
return null;
}
return {
kind: "path",
query: token.slice(1),
rangeStart: tokenStart,
rangeEnd: cursor,
};
}
export function parseStandaloneComposerSlashCommand(
text: string,
): Exclude<ComposerSlashCommand, "model"> | null {
const match = /^\/(plan|default)\s*$/i.exec(text.trim());
if (!match) {
return null;
}
const command = match[1]?.toLowerCase();
if (command === "plan") return "plan";
return "default";
}
export function replaceTextRange(
text: string,
rangeStart: number,
rangeEnd: number,
replacement: string,
): { text: string; cursor: number } {
const safeStart = Math.max(0, Math.min(text.length, rangeStart));
const safeEnd = Math.max(safeStart, Math.min(text.length, rangeEnd));
const nextText = `${text.slice(0, safeStart)}${replacement}${text.slice(safeEnd)}`;
return { text: nextText, cursor: safeStart + replacement.length };
return detectComposerTriggerBase(text, cursorInput, isWhitespace);
}