Repository navigation
Description
In Session Chat on a v2 server, a skill is an inline /name pill that can sit anywhere in the prompt, several skills can go in one message, and the prompt keeps its wording and its @ mentions when it is sent.
Why
Today a skill only works as one leading /name token: the suggestion overlay opens only when the whole draft is /xxx, picking a suggestion replaces the draft, and on send the token is cut off and any @agent / @file mentions in that prompt are dropped. The v2 prompt API never required that. POST /api/session/{id}/prompt takes skills: [{ id, mention?: { start, end, text } }]; the server resolves every entry, prepends each skill's content ahead of the user text, and ignores where the mention sits. The official composer treats skills as atomic @ pills that stay in the text, sends several at once, and skips duplicates (TUI) or allows them (web).
Scope
Trigger and pills
/opens skill and command suggestions at the cursor when it starts the draft or follows whitespace, like the existing@trigger (ComposerMentionRouting.atSuggestionQuery). The whole-text^/(\S*)$match goes away.- Picking a skill inserts a
/namespan at the cursor plus a trailing space, replacing the typed/query, and leaves the rest of the draft alone. Add askillkind to the sharedMentionSpanreconcile so the span shifts with edits and deletes as one unit, same as agent and file mentions. - Picking a skill from the Commands sheet Skills tile (OPE-218: v2 Commands sheet Skills tile #628) inserts the span at the cursor instead of replacing the draft.
- A skill already in the draft is not offered again (TUI behaviour). No cap on count.
- Style the span with the same
syntaxTypecolour as@mentions; a pill background is a follow-up if the Design System adds one.
Send
ComposerSubmitIntentgains a prompt variant that carries[skill span]next to agent and file mentions. The skill text stays intext; nothing is stripped.trimForSendre-bases skill offsets like the others.- Wire: each skill goes out as
{ id, mention: { start, end, text: "/name" } }onPOST /api/session/{id}/prompt. Agents and files keep their mention parts in the same request. - A draft that is a server command (
/cmd argswithcmdinGET /api/command) still routes toPOST /api/session/{id}/command; skills in that draft ride along in that route'sskillsarray. - v1 is unchanged:
GET /commandstill inlines skills as commands, a single leading/skillstill goes toPOST command, and the v1 prompt route carries no skills. Do not remove or skip any v1 path.
History and display
- Read
skillsback from the v2 user message DTO so a reloaded session can highlight them. - Optimistic row and timeline bubble highlight every skill span, not only a leading
[/name]token (CommandInvocationCollapser,attributedCommandDisplayText/commandTokenHighlightRange). Server-command rows keep the current leading-token collapse.
Out of scope
- Listing skills under the
@trigger (official web does that; our product keeps/). - A pill background component in the Design System.
- Skill autoinvoke metadata,
opencode/slashfrontmatter.
Acceptance criteria
- Typing
/after whitespace mid-draft opens the suggestion overlay filtered to skills and commands on both platforms; typing/inside a word does not - Two or more skills can be placed anywhere in one draft; each is an atomic span that deletes as a unit and survives edits around it
- Sending
fix @reviewer /tdd the login flow /security-checksendstextverbatim,skillswith two entries carrying correctmentionoffsets, and theagentsmention intact - Skills sheet tile and
/suggestion both insert at the cursor, never replace the draft - Duplicate skill is not offered while already in the draft
- A server command draft still goes to the command route, with any skill spans in its
skillsarray - v1 profiles behave exactly as before, covered by the existing v1 routing tests
- Reloaded v2 history highlights skill spans in user messages
- Unit coverage on iOS and Android: trigger, insert, reconcile, submit routing,
PromptJSONBodyWriter/PromptJsonBodyWriterskills with mention, user DTO round-trip - Scenario harness check on v2 with two skills in one prompt shows both skill content blocks reaching the model
Plan
iOS: Domain/Command/ComposerSubmitRouting.swift, Domain/Agent/ComposerMentionRouting.swift (+ AgentModels.swift for a SkillMention), UI/SessionChat/Region/SessionChatComposer.swift (selectSlashSuggestion, sendPrompt), Domain/Message/MessageModels.swift (PromptSendOptions), Domain/Message/Remote/MessageDomainAdapter.swift (v2PromptRequest, projectV2User), Data/Remote/MessageDTOs.swift, Data/Remote/V2MessageDTOs.swift, Data/Remote/PromptJSONBodyWriter.swift, Domain/Command/CommandInvocationCollapser.swift, Components/Chat/OpenCodeOutgoingMessage.swift, Components/Input/OpenCodeMentionTextView.swift.
Android: domain/command/ComposerSubmitRouting.kt, domain/agent/ComposerMentionRouting.kt (+ AgentModels.kt), ui/sessionchat/region/SessionChatComposer.kt, domain/message/MessageModels.kt, domain/message/remote/MessageDomainAdapter.kt, data/remote/dto/MessageDtos.kt, network/PromptJsonBodyWriter.kt, domain/command/CommandInvocationCollapser.kt, domain/command/CommandTokenHighlight.kt, ui/components/chat/OpenCodeOutgoingMessage.kt, ui/components/input/OpenCodeSessionComposer.kt (MentionVisualTransformation).
Server reference: packages/schema/src/prompt-input.ts (SkillAttachment), packages/core/src/session/prompt.ts, packages/core/src/session/runner/to-llm-message.ts, packages/app/src/composer/request.ts and editor/actions.ts for the official insert and submit shape.
Related: #628 (Skills tile), #569 (agent mentions, span infrastructure), #413 (file mentions), #567 (server slash commands).
Remaining:
- iOS: cursor-aware
/trigger, skill span kind, insert at cursor, duplicate skip - iOS: submit keeps text and mentions, sends
skills[].mention, command route carries skills - iOS: user DTO reads
skills; multi-span highlight in optimistic row and timeline - Android: cursor-aware
/trigger, skill span kind, insert at cursor, duplicate skip - Android: submit keeps text and mentions, sends
skills[].mention, command route carries skills - Android: user DTO reads
skills; multi-span highlight in optimistic row and timeline - Tests on both platforms per acceptance criteria; v1 routing tests still green
- Scenario harness evidence on v2 with two inline skills
Activity
#797 Inline skill mentions, several per prompt (#801)
Merge main into fix/796-retire-optimistic-sends-by-client-id
ivanfenenko commentedon Oct 25, 2026
Scenario-harness evidence: two inline skills on v2 (iOS + Android)
Apps built from
main@ 742bf87, run against the scenario harness with real opencode v2dev(4d5965762e) and the scripted model. The throwaway project has two skills,tdd-checkandsecurity-check. Each SKILL.md carries a unique marker so its content can be found in the model request./after whitespace mid-draft opens skill suggestions; picking one inserts a highlighted span at the caretPOST /api/session/{id}/promptstorestextverbatim with twoskills[].mentionentries whose offsets slice to/tdd-checkand/security-checkALPHAandBRAVOboth in the model request's user content)[/tdd-check]and[/security-check]highlighted/tdd-check,/security-checkModel request check (full request bodies logged at the fake model):
(The Android draft reads "he login flow" because the emulator dropped one keystroke. It doesn't affect the check.)
iOS gap: the server returns
skillswith correct mentions (Android renders the same message correctly), but the iOS user bubble shows the raw text both live and after reload. Likely cause, not yet confirmed:DisplayFrame.buildattaches the message's root markdown to the sole text block (attachSoleTextMarkdown). A user bubble withrenderedMarkdownthen renders the original text and skips the[/name]collapse fromcollapseSkillMentions. The iOS highlight items stay open until this is fixed.#797 Keep skill spans on iOS user messages after live updates (#826)
Evidence for #797: iOS skill spans after fix (#826)
ivanfenenko commentedon Oct 25, 2026
iOS skill highlight fixed in #826 and #829
The iOS gap from the earlier harness run had two causes:
session.inbox.enqueuedprojection dropped the prompt's skills.promptSkills.#826 (merged) fixes the reload path. #829 fixes the live path; it was pushed after #826 had already been squash-merged. Together they add 7 tests, and the full iOS suite passes on the combined tree (2691 tests).
Rechecked on the scenario harness (v2
dev, two inline skills, iPhone 16 Pro Max, build with both fixes): both the sent bubble and the reloaded history show highlighted[/tdd-check]and[/security-check]. The draft reads "Can" instead of "fix" because of simulator autocorrect.All acceptance items are now checked on both platforms. Closing. The live-send part ships when #829 merges.
#797 Project v2 prompt skills from the inbox event on iOS (#829)