diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 706ab2989e15..398639538113 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -7,7 +7,7 @@ on: jobs: generate: - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: ubuntu-latest permissions: contents: write pull-requests: write diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69a3a1a2d13f..9476400fd523 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,9 +28,9 @@ jobs: matrix: settings: - name: linux - host: blacksmith-4vcpu-ubuntu-2404 + host: ubuntu-latest - name: windows - host: blacksmith-4vcpu-windows-2025 + host: windows-latest runs-on: ${{ matrix.settings.host }} defaults: run: @@ -95,9 +95,9 @@ jobs: matrix: settings: - name: linux - host: blacksmith-4vcpu-ubuntu-2404 + host: ubuntu-latest - name: windows - host: blacksmith-4vcpu-windows-2025 + host: windows-latest runs-on: ${{ matrix.settings.host }} env: PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.playwright-browsers diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index b247d24b40db..09b919429385 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -9,7 +9,7 @@ on: jobs: typecheck: - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/AGENTS.md b/AGENTS.md index a7895c831f12..f9a7430a071b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,3 +1,5 @@ +- This is a fork; see `PATCH.md` for fork-specific changes. + - Update `PATCH.md` for every custom change made in this fork. - To regenerate the JavaScript SDK, run `./packages/sdk/js/script/build.ts`. - ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE. - The default branch in this repo is `dev`. diff --git a/PATCH.md b/PATCH.md new file mode 100644 index 000000000000..9a84850d7297 --- /dev/null +++ b/PATCH.md @@ -0,0 +1,39 @@ +# Fork Additions + +## Inline Skill Autocomplete + +Type `/` mid-prompt (after whitespace) to trigger skill-only autocomplete. Skills can be inserted inline without replacing the entire prompt. + +## Skill Configuration Options + +```ts +skills: { + slash?: boolean // Show skills as slash commands (default: false) + inline?: boolean // Inline full skill content on invocation (default: true) +} +``` + +## `/skills` Command + +Browse and select skills via dialog. Hidden when `skills.slash` is enabled. + +## UI Changes + +- `DialogSelectSkill` component for skill browser +- Skill category in command palette +- i18n keys for skill UI + +## Disabled Workflows + +Upstream workflows disabled for this fork: + +- close-issues, containers, deploy, docs-locale-sync +- nix-eval, nix-hashes, pr-management, pr-standards +- publish, release-github-action, storybook +- vouch-check-pr, vouch-manage-by-issue + +Kept: test, typecheck, generate + +## CI Runners + +Changed from Blacksmith to GitHub-hosted runners (`ubuntu-latest`, `windows-latest`). diff --git a/packages/app/src/components/dialog-select-skill.tsx b/packages/app/src/components/dialog-select-skill.tsx new file mode 100644 index 000000000000..3f1c9717c885 --- /dev/null +++ b/packages/app/src/components/dialog-select-skill.tsx @@ -0,0 +1,53 @@ +import { Component, createMemo, createResource, Show } from "solid-js" +import { useSDK } from "@/context/sdk" +import { useDialog } from "@opencode-ai/ui/context/dialog" +import { Dialog } from "@opencode-ai/ui/dialog" +import { List } from "@opencode-ai/ui/list" +import { Tag } from "@opencode-ai/ui/tag" +import { useLanguage } from "@/context/language" + +export const DialogSelectSkill: Component<{ onSelect: (skill: string) => void }> = (props) => { + const sdk = useSDK() + const dialog = useDialog() + const language = useLanguage() + + const [skills] = createResource(async () => { + const result = await sdk.client.app.skills() + return result.data ?? [] + }) + + const items = createMemo(() => + (skills() ?? []) + .map((s) => ({ name: s.name, description: s.description })) + .sort((a, b) => a.name.localeCompare(b.name)), + ) + + return ( + + x?.name ?? ""} + items={items} + filterKeys={["name", "description"]} + sortBy={(a, b) => a.name.localeCompare(b.name)} + onSelect={(x) => { + if (!x) return + props.onSelect(x.name) + dialog.close() + }} + > + {(i) => ( +
+
+ {i.name} + + {i.description} + +
+
+ )} +
+
+ ) +} diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx index 156b0b3a4a22..be819771b525 100644 --- a/packages/app/src/components/prompt-input.tsx +++ b/packages/app/src/components/prompt-input.tsx @@ -251,6 +251,8 @@ export const PromptInput: Component = (props) => { const [store, setStore] = createStore<{ popover: "at" | "slash" | null + inline: boolean + slashStart: number historyIndex: number savedPrompt: PromptHistoryEntry | null placeholder: number @@ -259,6 +261,8 @@ export const PromptInput: Component = (props) => { applyingHistory: boolean }>({ popover: null, + inline: false, + slashStart: 0, historyIndex: -1, savedPrompt: null as PromptHistoryEntry | null, placeholder: Math.floor(Math.random() * EXAMPLES.length), @@ -634,6 +638,7 @@ export const PromptInput: Component = (props) => { description: cmd.description, type: "custom" as const, source: cmd.source, + slash: cmd.slash, })) return [...custom, ...builtin] @@ -641,10 +646,32 @@ export const PromptInput: Component = (props) => { const handleSlashSelect = (cmd: SlashCommand | undefined) => { if (!cmd) return + const inline = store.inline + const start = store.slashStart closePopover() const images = imageAttachments() if (cmd.type === "custom") { + if (inline) { + // Replace just the /partial text with /{trigger} + const selection = window.getSelection() + if (selection && selection.rangeCount > 0) { + const range = selection.getRangeAt(0) + if (editorRef.contains(range.startContainer)) { + const cursorPosition = getCursorPosition(editorRef) + setRangeEdge(editorRef, range, "start", start) + setRangeEdge(editorRef, range, "end", cursorPosition) + range.deleteContents() + const text = `/${cmd.trigger} ` + range.insertNode(document.createTextNode(text)) + range.collapse(false) + selection.removeAllRanges() + selection.addRange(range) + } + } + handleInput() + return + } const text = `/${cmd.trigger} ` setEditorText(text) prompt.set([{ type: "text", content: text, start: 0, end: text.length }, ...images], text.length) @@ -652,6 +679,7 @@ export const PromptInput: Component = (props) => { return } + if (inline) return clearEditor() prompt.set([...DEFAULT_PROMPT, ...images], 0) command.trigger(cmd.id, "slash") @@ -886,11 +914,23 @@ export const PromptInput: Component = (props) => { if (atMatch) { atOnInput(atMatch[1]) setStore("popover", "at") + setStore("inline", false) } else if (slashMatch) { slashOnInput(slashMatch[1]) setStore("popover", "slash") + setStore("inline", false) } else { - closePopover() + // Check for inline / after whitespace — triggers skill-only autocomplete + const textBefore = rawText.substring(0, cursorPosition) + const inlineMatch = textBefore.match(/(?:^|\s)\/(\S*)$/) + if (inlineMatch) { + slashOnInput(inlineMatch[1]) + setStore("popover", "slash") + setStore("inline", true) + setStore("slashStart", cursorPosition - inlineMatch[1].length - 1) + } else { + closePopover() + } } } else { closePopover() @@ -1270,7 +1310,18 @@ export const PromptInput: Component = (props) => { atKey={atKey} setAtActive={setAtActive} onAtSelect={handleAtSelect} - slashFlat={slashFlat()} + slashFlat={ + store.inline + ? slashFlat().filter((cmd) => { + if (cmd.source !== "skill") return false + const text = prompt + .current() + .map((p) => ("content" in p ? p.content : "")) + .join("") + return !text.includes(`/${cmd.trigger} `) + }) + : slashFlat().filter((cmd) => cmd.slash !== false) + } slashActive={slashActive() ?? undefined} setSlashActive={setSlashActive} onSlashSelect={handleSlashSelect} diff --git a/packages/app/src/components/prompt-input/slash-popover.tsx b/packages/app/src/components/prompt-input/slash-popover.tsx index 0c8c95923493..098ad08ff4a1 100644 --- a/packages/app/src/components/prompt-input/slash-popover.tsx +++ b/packages/app/src/components/prompt-input/slash-popover.tsx @@ -15,6 +15,7 @@ export interface SlashCommand { keybind?: string type: "builtin" | "custom" source?: "command" | "mcp" | "skill" + slash?: boolean } type PromptPopoverProps = { diff --git a/packages/app/src/i18n/en.ts b/packages/app/src/i18n/en.ts index c6bcc37b116f..0c7b8d515f7e 100644 --- a/packages/app/src/i18n/en.ts +++ b/packages/app/src/i18n/en.ts @@ -15,6 +15,7 @@ export const dict = { "command.category.agent": "Agent", "command.category.permissions": "Permissions", "command.category.workspace": "Workspace", + "command.category.skill": "Skill", "command.category.settings": "Settings", "theme.scheme.system": "System", @@ -65,6 +66,8 @@ export const dict = { "command.model.choose.description": "Select a different model", "command.mcp.toggle": "Toggle MCPs", "command.mcp.toggle.description": "Toggle MCPs", + "command.skill.choose": "Browse skills", + "command.skill.choose.description": "Select a skill to invoke", "command.agent.cycle": "Cycle agent", "command.agent.cycle.description": "Switch to the next agent", "command.agent.cycle.reverse": "Cycle agent backwards", @@ -298,6 +301,9 @@ export const dict = { "dialog.mcp.description": "{{enabled}} of {{total}} enabled", "dialog.mcp.empty": "No MCPs configured", + "dialog.skill.title": "Skills", + "dialog.skill.empty": "No skills available", + "dialog.lsp.empty": "LSPs auto-detected from file types", "dialog.plugins.empty": "Plugins configured in opencode.json", diff --git a/packages/app/src/pages/session/use-session-commands.tsx b/packages/app/src/pages/session/use-session-commands.tsx index b5d25446368e..695250a63624 100644 --- a/packages/app/src/pages/session/use-session-commands.tsx +++ b/packages/app/src/pages/session/use-session-commands.tsx @@ -11,6 +11,8 @@ import { usePrompt } from "@/context/prompt" import { useSDK } from "@/context/sdk" import { useSync } from "@/context/sync" import { useTerminal } from "@/context/terminal" +import { DialogSelectMcp } from "@/components/dialog-select-mcp" +import { DialogSelectSkill } from "@/components/dialog-select-skill" import { showToast } from "@opencode-ai/ui/toast" import { findLast } from "@opencode-ai/shared/util/array" import { createSessionTabs } from "@/pages/session/helpers" @@ -116,6 +118,7 @@ export const useSessionCommands = (actions: SessionCommandContext) => { const terminalCommand = withCategory(language.t("command.category.terminal")) const modelCommand = withCategory(language.t("command.category.model")) const mcpCommand = withCategory(language.t("command.category.mcp")) + const skillCommand = withCategory(language.t("command.category.skill")) const agentCommand = withCategory(language.t("command.category.agent")) const permissionsCommand = withCategory(language.t("command.category.permissions")) @@ -529,6 +532,24 @@ export const useSessionCommands = (actions: SessionCommandContext) => { }), ] + const skillCmds = () => [ + skillCommand({ + id: "skill.choose", + title: language.t("command.skill.choose"), + description: language.t("command.skill.choose.description"), + slash: "skills", + disabled: !!sync.data.config.skills?.slash, + onSelect: () => + dialog.show(() => ( + { + prompt.set([{ type: "text" as const, content: `/${skill} `, start: 0, end: skill.length + 2 }]) + }} + /> + )), + }), + ] + const agentCmds = () => [ agentCommand({ id: "agent.cycle", @@ -569,6 +590,7 @@ export const useSessionCommands = (actions: SessionCommandContext) => { ...messageCmds(), ...modelCmds(), ...mcpCmds(), + ...skillCmds(), ...agentCmds(), ...permissionsCmds(), ]) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx index 305d07622392..590ad3eccbb8 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx @@ -357,10 +357,43 @@ export function Autocomplete(props: { }) const commands = createMemo((): AutocompleteOption[] => { + const inline = store.visible === "/" && store.index > 0 + + // When inline, only show skill-sourced commands + if (inline) { + const text = props.input().plainText + const results: AutocompleteOption[] = [] + for (const serverCommand of sync.data.command) { + if (serverCommand.source !== "skill") continue + if (text.includes(`/${serverCommand.name} `)) continue + results.push({ + display: "/" + serverCommand.name, + description: serverCommand.description, + onSelect: () => { + const input = props.input() + const newText = "/" + serverCommand.name + " " + const cursor = input.logicalCursor + input.cursorOffset = store.index + const start = input.logicalCursor + input.cursorOffset = cursor.col + cursor.row * 1000 + input.deleteRange(start.row, start.col, cursor.row, cursor.col) + input.insertText(newText) + }, + }) + } + results.sort((a, b) => a.display.localeCompare(b.display)) + const max = firstBy(results, [(x) => x.display.length, "desc"])?.display.length + if (!max) return results + return results.map((item) => ({ + ...item, + display: item.display.padEnd(max + 2), + })) + } + const results: AutocompleteOption[] = [...command.slashes()] for (const serverCommand of sync.data.command) { - if (serverCommand.source === "skill") continue + if (serverCommand.slash === false) continue const label = serverCommand.source === "mcp" ? ":mcp" : "" results.push({ display: "/" + serverCommand.name + label, @@ -488,7 +521,7 @@ export function Autocomplete(props: { function hide() { const text = props.input().plainText - if (store.visible === "/" && !text.endsWith(" ") && text.startsWith("/")) { + if (store.visible === "/" && store.index === 0 && !text.endsWith(" ") && text.startsWith("/")) { const cursor = props.input().logicalCursor props.input().deleteRange(0, 0, cursor.row, cursor.col) // Sync the prompt store immediately since onContentChange is async @@ -512,8 +545,8 @@ export function Autocomplete(props: { props.input().cursorOffset <= store.index || // There is a space between the trigger and the cursor props.input().getTextRange(store.index, props.input().cursorOffset).match(/\s/) || - // "/" is not the sole content - (store.visible === "/" && value.match(/^\S+\s+\S+\s*$/)) + // "/" is not the sole content (only for position-0 slash) + (store.visible === "/" && store.index === 0 && value.match(/^\S+\s+\S+\s*$/)) ) { hide() } @@ -531,6 +564,19 @@ export function Autocomplete(props: { return } + // Check for inline "/" trigger - reopen skill autocomplete + const slashText = value.slice(0, offset) + const slashIdx = slashText.lastIndexOf("/") + if (slashIdx > 0) { + const beforeSlash = value[slashIdx - 1] + const between = slashText.slice(slashIdx) + if (/\s/.test(beforeSlash) && !between.match(/\s/)) { + show("/") + setStore("index", slashIdx) + return + } + } + // Check for "@" trigger - find the nearest "@" before cursor with no whitespace between const text = value.slice(0, offset) const idx = text.lastIndexOf("@") @@ -593,7 +639,13 @@ export function Autocomplete(props: { } if (e.name === "/") { - if (props.input().cursorOffset === 0) show("/") + if (props.input().cursorOffset === 0) { + show("/") + } else { + const offset = props.input().cursorOffset + const before = props.input().getTextRange(offset - 1, offset) + if (/\s/.test(before)) show("/") + } } } }, diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 82c4a7222f26..09d87de1c483 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -379,6 +379,7 @@ export function Prompt(props: PromptProps) { title: "Skills", value: "prompt.skills", category: "Prompt", + hidden: !!sync.data.config.skills?.slash, slash: { name: "skills", }, diff --git a/packages/opencode/src/command/index.ts b/packages/opencode/src/command/index.ts index 27ba357ecc9a..aa2275fb067c 100644 --- a/packages/opencode/src/command/index.ts +++ b/packages/opencode/src/command/index.ts @@ -38,6 +38,7 @@ export const Info = z // https://zod.dev/v4/changelog?id=zfunction template: z.promise(z.string()).or(z.string()), subtask: z.boolean().optional(), + slash: z.boolean().optional(), hints: z.array(z.string()), }) .meta({ @@ -151,6 +152,7 @@ export const layer = Layer.effect( name: item.name, description: item.description, source: "skill", + slash: cfg.skills?.slash ?? false, get template() { return item.content }, diff --git a/packages/opencode/src/config/skills.ts b/packages/opencode/src/config/skills.ts index bdc63f5d6ac3..5ef3da56a863 100644 --- a/packages/opencode/src/config/skills.ts +++ b/packages/opencode/src/config/skills.ts @@ -7,6 +7,11 @@ export namespace ConfigSkills { .array(z.string()) .optional() .describe("URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)"), + slash: z.boolean().optional().describe("Show individual skills as slash commands in autocomplete (default: false)"), + inline: z + .boolean() + .optional() + .describe("Inline full skill content into prompt on slash command invocation (default: true)"), }) export type Info = z.infer diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index 004ee19abebb..480005d25c29 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -1,6 +1,7 @@ import path from "path" import os from "os" import z from "zod" +import { Config } from "@/config" import { SessionID, MessageID, PartID } from "./schema" import { MessageV2 } from "./message-v2" import { Log } from "../util" @@ -40,10 +41,10 @@ import { Permission } from "@/permission" import { SessionStatus } from "./status" import { LLM } from "./llm" import { Shell } from "@/shell/shell" -import { AppFileSystem } from "@opencode-ai/shared/filesystem" import { Truncate } from "@/tool" import { decodeDataUrl } from "@/util/data-url" import { Process } from "@/util" +import { AppFileSystem } from "@opencode-ai/shared/filesystem" import { Cause, Effect, Exit, Layer, Option, Scope, Context } from "effect" import { EffectLogger } from "@/effect" import { InstanceState } from "@/effect" @@ -91,6 +92,7 @@ export namespace SessionPrompt { const compaction = yield* SessionCompaction.Service const plugin = yield* Plugin.Service const commands = yield* Command.Service + const config = yield* Config.Service const permission = yield* Permission.Service const fsys = yield* AppFileSystem.Service const mcp = yield* MCP.Service @@ -1566,7 +1568,10 @@ NOTE: At any point in time through this workflow you should feel free to ask the const raw = input.arguments.match(argsRegex) ?? [] const args = raw.map((arg) => arg.replace(quoteTrimRegex, "")) - const templateCommand = yield* Effect.promise(async () => cmd.template) + const cfg = yield* config.get() + const inline = cfg.skills?.inline !== false + const templateCommand = + cmd.source === "skill" && !inline ? `/${input.command}` : yield* Effect.promise(async () => cmd.template) const placeholders = templateCommand.match(placeholderRegex) ?? [] let last = 0 @@ -1699,6 +1704,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the Layer.provide(Session.defaultLayer), Layer.provide(SessionRevert.defaultLayer), Layer.provide(SessionSummary.defaultLayer), + Layer.provide(Config.defaultLayer), Layer.provide( Layer.mergeAll( Agent.defaultLayer, diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts index a6d09db3e9ff..1e8efd73b0a5 100644 --- a/packages/sdk/js/src/v2/gen/types.gen.ts +++ b/packages/sdk/js/src/v2/gen/types.gen.ts @@ -1497,6 +1497,14 @@ export type Config = { * URLs to fetch skills from (e.g., https://example.com/.well-known/skills/) */ urls?: Array + /** + * Show individual skills as slash commands in autocomplete (default: false) + */ + slash?: boolean + /** + * Inline full skill content into prompt on slash command invocation (default: true) + */ + inline?: boolean } watcher?: { ignore?: Array @@ -2128,6 +2136,7 @@ export type Command = { source?: "command" | "mcp" | "skill" template: string subtask?: boolean + slash?: boolean hints: Array }