Load subagent names from agents/ markdown files - #117
Conversation
OpenCode also defines agents as *.md files under the config agents directory, so readSubagentNames now merges those definitions with opencode.json agents. Co-authored-by: Cursor <cursoragent@cursor.com>
|
FYI, three follow-ups that align this with how OpenCode itself loads agents (
Commits to follow. Thanks for kicking this off. |
Read from both `agent/` and `agents/` (OpenCode globs {agent,agents}/**/*.md),
scan recursively with path-based names, and parse quoted/alternate frontmatter
values (`mode: "subagent"`, `disable: "true"`, `disable: yes`).
Adds unit tests plus a real-filesystem test exercising both directories and
nested agents on disk.
|
Pushed the three fixes as a commit on top. Covered by unit tests and a real-filesystem test that writes Still needs a live check before merge: confirm that in a running OpenCode session the discovered names actually reach the |
OpenCode deletes JSON agents marked `disable: true` (agent/agent.ts). The loader passed them through, so markdown `disable` worked but JSON `disable` did not. Filter disabled JSON agents to match, with a regression test.
|
Update: the live OpenCode check changed the implementation direction, so I have pushed five commits on top of Omar's branch. I kept the original Why the implementation changedOpenCode resolves The plugin uses the Task description OpenCode sends with each request. I removed Task bridgeCursor Agent cannot call OpenCode's Task tool through its native tool enum. The patch gives it one strict JSON envelope: {"name":"task","arguments":{"description":"Run proof","prompt":"Do the work","subagent_type":"project-proof"}}The plugin converts that envelope into an OpenAI The stream detector covers split deltas, cumulative snapshots, fences, malformed JSON, native tool boundaries, and stream-end flushes. Both Bun and Node use the same detector. A valid envelope produces one Task call and does not leak into assistant text. Mixed thinking and text events keep their reasoning while the detector buffers the JSON. Write behaviourThe detector treats ordinary prose as the start of an assistant response. A later Write envelope remains text until a native tool event starts a new phase. This removes the old last-line extraction heuristic. A JSON candidate followed by prose stays buffered until the next boundary or stream end, then returns verbatim. Verification
I also ran a live isolated session with @OZoneGuy, the main review point is the change from filesystem discovery to OpenCode-owned runtime metadata. It removes most of the original loader code while preserving the feature the PR set out to add. Thanks for starting this. |
|
Thanks for following up on this! |
Summary
Test plan
Made with Cursor
I have my agents defined in markdown files for opencode, https://opencode.ai/docs/agents/#markdown, and they are not picked up by the plugin. Adding code to pick up the markdown agents.