feat: prompts

This commit is contained in:
Gab
2026-03-28 16:48:01 +11:00
parent 3cc0f7401a
commit 5b9cc6c0de
17 changed files with 237 additions and 69 deletions

View File

@@ -30,8 +30,18 @@ export const DialogSelectPrompt: Component = () => {
const prompts = createMemo(() => {
const all = promptsQuery.data ?? []
const agentId = tfAgentId()
console.log("[DialogSelectPrompt] All prompts:", all.length, "agentId:", agentId, "all:", all)
if (!agentId) return []
return all.filter((p) => p.available_to_agents?.includes(agentId))
const filtered = all.filter((p) => p.available_to_agents?.includes(agentId))
console.log(
"[DialogSelectPrompt] Filtered prompts:",
filtered.length,
"for agentId:",
agentId,
"filtered:",
filtered,
)
return filtered
})
const applyPrompt = (p: { interpolation_string: string }) => {

View File

@@ -617,6 +617,17 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
source: cmd.source,
}))
console.log("[slashCommands] builtin:", builtin.length, "custom:", custom.length)
const promptsBuiltin = builtin.filter((c) => c.trigger === "prompts")
const promptsCustom = custom.filter((c) => c.trigger === "prompts")
if (promptsBuiltin.length > 0) console.log("[slashCommands] promptsBuiltin:", promptsBuiltin)
if (promptsCustom.length > 0) console.log("[slashCommands] promptsCustom:", promptsCustom)
if (sync.data.command.length > 0)
console.log(
"[slashCommands] sync.data.command:",
sync.data.command.map((c) => ({ name: c.name, source: c.source })),
)
return [...custom, ...builtin]
})

View File

@@ -14,7 +14,7 @@ export interface SlashCommand {
description?: string
keybind?: string
type: "builtin" | "custom"
source?: "command" | "mcp" | "skill"
source?: "command" | "mcp" | "skill" | "prompt"
}
type PromptPopoverProps = {
@@ -122,7 +122,9 @@ export const PromptPopover: Component<PromptPopoverProps> = (props) => {
? props.t("prompt.slash.badge.skill")
: cmd.source === "mcp"
? props.t("prompt.slash.badge.mcp")
: props.t("prompt.slash.badge.custom")}
: cmd.source === "prompt"
? props.t("prompt.slash.badge.prompt")
: props.t("prompt.slash.badge.custom")}
</span>
</Show>
<Show when={props.commandKeybind(cmd.id)}>

View File

@@ -150,7 +150,12 @@ export async function bootstrapDirectory(input: {
Promise.all([
input.sdk.path.get().then((x) => input.setStore("path", x.data!)),
input.sdk.command.list().then((x) => input.setStore("command", x.data ?? [])),
input.sdk.command.list().then((x) => {
console.log("[bootstrap] command.list result:", x.data?.length, "commands")
const promptsCmd = x.data?.find((c) => c.name === "prompts")
if (promptsCmd) console.log("[bootstrap] Found 'prompts' command in server response:", promptsCmd)
return input.setStore("command", x.data ?? [])
}),
input.sdk.session.status().then((x) => input.setStore("session_status", x.data!)),
input.loadSessions(input.directory),
input.sdk.mcp.status().then((x) => input.setStore("mcp", x.data!)),

View File

@@ -274,6 +274,7 @@ export const dict = {
"prompt.slash.badge.custom": "custom",
"prompt.slash.badge.skill": "skill",
"prompt.slash.badge.mcp": "mcp",
"prompt.slash.badge.prompt": "prompt",
"prompt.context.active": "active",
"prompt.context.includeActiveFile": "Include active file",
"prompt.context.removeActiveFile": "Remove active file from context",