GeezerVison is showing github.com — fix(server): OpenCode steers keep their $skill mentions (#42141) · pingdotgg/t3code@94190c6
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/orchestration-v2/Adapters packages/provider-opencode/src/server/v2
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts +50Lines changed: 50 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4137,6 +4137,56 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => { | 4137 | 4137 | }), | 4138 | 4138 | ); | 4139 | 4139 |
| | 4140 | + it.effect("sends a $skill named in a message that steers the running turn", () => | | 4141 | + Effect.gen(function* () { | | 4142 | + const prompts: Array<unknown> = []; | | 4143 | + const steerId = "msg_recorded_steer_skill"; | | 4144 | + const greet = { | | 4145 | + id: "greet", | | 4146 | + name: "greet", | | 4147 | + path: `${WORK}/.opencode/skills/greet/SKILL.md`, | | 4148 | + content: "Say hello.", | | 4149 | + }; | | 4150 | + const { runtime, thread } = yield* resumed( | | 4151 | + [ | | 4152 | + out("session.prompt", { sessionID: SESSION, text: "<any>" }), | | 4153 | + promptAccepted, | | 4154 | + event("session.execution.started", { sessionID: SESSION }), | | 4155 | + out("skill.list", { "location[directory]": WORK }), | | 4156 | + reply("skill.list", { location: { directory: WORK }, data: [greet] }), | | 4157 | + out("session.prompt", { sessionID: SESSION, id: steerId, delivery: "steer" }), | | 4158 | + replyData("session.prompt", { | | 4159 | + id: steerId, | | 4160 | + sessionID: SESSION, | | 4161 | + time: { created: 1790656601500 }, | | 4162 | + type: "user", | | 4163 | + payload: { text: "$greet first" }, | | 4164 | + delivery: "steer", | | 4165 | + }), | | 4166 | + event("session.inbox.delivered", { sessionID: SESSION, inboxID: steerId }), | | 4167 | + event("session.execution.succeeded", { sessionID: SESSION }), | | 4168 | + ], | | 4169 | + { onPrompt: (input) => prompts.push(input) }, | | 4170 | + ); | | 4171 | + const terminal = yield* terminalOf(runtime).pipe(Effect.forkScoped); | | 4172 | + const input = turnInput(thread); | | 4173 | + yield* runtime.startTurn(input); | | 4174 | + yield* runtime.steerTurn({ | | 4175 | + threadId, | | 4176 | + runId: input.runId, | | 4177 | + providerThread: thread, | | 4178 | + providerTurnId: yield* providerTurnId, | | 4179 | + message: { | | 4180 | + ...input.message, | | 4181 | + messageId: MessageId.make("message:opencode2-adapter:steer"), | | 4182 | + text: "$greet first", | | 4183 | + }, | | 4184 | + }); | | 4185 | + assert.equal((yield* Fiber.join(terminal))?.status, "completed"); | | 4186 | + assert.deepInclude(prompts[1], { delivery: "steer", skills: [{ id: "greet" }] }); | | 4187 | + }), | | 4188 | + ); | | 4189 | + | 4140 | 4190 | it.effect.each([ | 4141 | 4191 | { | 4142 | 4192 | server: "an external server keeps rejecting requests", | |
Collapse file Copy file name to clipboardExpand all lines: packages/provider-opencode/src/server/v2/adapter.ts +13-5Lines changed: 13 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4741,8 +4741,10 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr | 4741 | 4741 | // OpenCode 2.2.5 answers its model list only once the scan has ended (observed, not documented). | 4742 | 4742 | const skillsMentioned = Effect.fnUntraced(function* ( | 4743 | 4743 | location: { readonly directory: string }, | 4744 | | - mentions: ReadonlyArray<string>, | | 4744 | + text: string, | 4745 | 4745 | ) { | | 4746 | + const mentions = skillMentions(text); | | 4747 | + if (mentions.length === 0) return []; | 4746 | 4748 | const known = yield* listSkills(location); | 4747 | 4749 | if (mentions.some((name) => !known.has(name))) { | 4748 | 4750 | yield* readModels(location.directory); | @@ -4846,8 +4848,7 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr | 4846 | 4848 | ); | 4847 | 4849 | } | 4848 | 4850 | } | 4849 | | - const mentions = skillMentions(text); | 4850 | | - const skills = mentions.length === 0 ? [] : yield* skillsMentioned(location, mentions); | | 4851 | + const skills = yield* skillsMentioned(location, text); | 4851 | 4852 | const files = yield* promptFiles(turnInput.message.attachments); | 4852 | 4853 | const messageText = turnInput.resume ? "" : yield* promptText(turnInput); | 4853 | 4854 | if (!sending()) return; | @@ -5187,15 +5188,19 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr | 5187 | 5188 | if (turn.settledInbox.has(inboxID)) return; | 5188 | 5189 | turn.steers.add(inboxID); | 5189 | 5190 | state.strandedSteers.delete(inboxID); | 5190 | | - const { files, messageText } = yield* Effect.gen(function* () { | | 5191 | + const { files, messageText, skills } = yield* Effect.gen(function* () { | 5191 | 5192 | const files = yield* promptFiles(steerInput.message.attachments); | 5192 | 5193 | const messageText = (yield* providerMessageTextWithAttachmentPaths({ | 5193 | 5194 | text: steerInput.message.text, | 5194 | 5195 | attachments: steerInput.message.attachments, | 5195 | 5196 | resolveAttachmentPath: host.resolveAttachmentPath, | 5196 | 5197 | resolveExtractedTextPath: host.resolveExtractedTextPath, | 5197 | 5198 | })).trim(); | 5198 | | - return { files, messageText }; | | 5199 | + const skills = yield* skillsMentioned( | | 5200 | + { directory: directoryOf(turn.input.runtimePolicy.cwd) }, | | 5201 | + steerInput.message.text, | | 5202 | + ); | | 5203 | + return { files, messageText, skills }; | 5199 | 5204 | }).pipe( | 5200 | 5205 | Effect.onInterrupt(() => | 5201 | 5206 | lock.withPermit( | @@ -5232,6 +5237,9 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr | 5232 | 5237 | id: inboxID, | 5233 | 5238 | text: messageText, | 5234 | 5239 | ...(files.length === 0 ? {} : { files }), | | 5240 | + ...(skills.length === 0 | | 5241 | + ? {} | | 5242 | + : { skills: skills.map((id) => ({ id: Skill.ID.make(id) })) }), | 5235 | 5243 | delivery: "steer", | 5236 | 5244 | }) | 5237 | 5245 | .pipe( | |
|