Skip to content

feat(files): a skill's virtual file opens in the file tab (opencode#66201) - #1226

Merged
Hona merged 5 commits into
devfrom
upstream-g/skill-files
Nov 25, 2026
Merged

Hona merged 5 commits into
devfrom
upstream-g/skill-files

Conversation

@Hona

@Hona Hona commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Port of the app part of official anomalyco/opencode#66201 (df79010bc6, "load skills from MCP servers"), with the two older official changes it stands on, which ours never had: #60464 (78f8dffd48) and #60921 (69269e4ebe). A skill's virtual file, skill://<id>/<file>, opens in the file tab. The fallback read is proved by a run; the new route is by reading only (the server the cases run on is from before it). Official paths are under packages/.

flowchart LR
  A["a skill's row in Details<br/>a link in a reply or a file"] --> C["links::classify<br/>Link::Skill"]
  C --> V["file tab"]
  V --> R{"path"}
  R -- "skill://id/file" --> E["GET /api/experimental/skill/id/file/path"]
  E -- "404: no such route or file" --> L
  R -- "/builtin/file" --> L["GET /api/skill: the inline body"]
Loading

What it does

Behaviour Official Ours before Ours now
skill://<id>/<file> is read with GET /api/experimental/skill/<id>/file/<path>?location=... and shown as any file app/src/workspaces/files/model.tsx:257-264, client/src/promise/generated/client.ts (experimental.skill.file) not read at all features/files/src/data.rs fetch_skill_file
A legacy /builtin/ path shows the inline content of /api/skill model.tsx:266-268 read as a file of folder /builtin, which is not there the same function
Such a path is absolute: a link to it is a file link, with :12 and :12-20 gui-plugins/src/file/resolve-link.ts:27-29, :109-120; gui-plugins/src/file/renderer.tsx:705-706; app/src/workspaces/files/path.ts:128 taken for a web or app address (features/files/src/links.rs:43 on dev), so no tab: the address is copied, or offered as an app link (apps/desktop/src/surfaces/browser/links.rs:229-256) links.rs Link::Skill, classify
No "Open in" for it gui-plugins/src/file/open-in-app.tsx:101-107 not reachable features/files/src/viewer/toolbar.rs
Inline code that names one is not a link (any x:// is not a path) session-ui/src/components/markdown-inline-code-kind.ts already so (code_paths.rs reads_as_path) no change
  • Ours only, said plainly: a skill:// path on a server that has no such route (older than 24 Nov) falls back to the skills list's inline body, which is where official itself read it until #66201 (model.tsx at 69269e4ebe). On a server with the route the result is official's: a skill or file the server does not have reads as not found.
  • A skill's virtual file is in no tree and is not watched (ops.rs, watch.rs), has no "Show in folder", and its "Copy path" copies the skill:// path.
  • The name goes whole through the file tab's id: normalize_path (crates/opencode-search/src/file_rank.rs) made skill://<id>/<file> into skill:/<id>/<file>, which the tab's id and Workspace:OpenDocument carry, so the tab would have read a file of the folder by that name and said it was not found. Found by reading after the first push, corrected in the third commit; the first two commits had this fault. The correction missed one place, which the first run found: Workspace:OpenDocument normalized the path with another function of the same name (crates/opencode-code-view/src/data/review.rs), so the tab still opened as not found, and the tree gained a skill: row. Corrected in 043c15009 (apps/desktop/src/plugin_host/native/files.rs).
  • The Files header's Open in button (ui.openInButton, apps/desktop/src/workspace/system/open_in.rs) is not offered for such a file either.
  • A fixture file's file_contents may hold a skill:// key: it has a body and is in no tree (data.rs load_fixture_workspace, ops.rs).
  • No plugin contract, manifest, lock or profile change. The skills' rows in Details already open their path as a link (plugins/details/lists.luau:602).

Cases to run (headless, on this PR's Windows x64 build; before = a build without the change)

A. With no server: a fixture file

The file: the app's own apps/desktop/assets/fixture.json with two changes. (1) The last reply of the session it opens ends with one more paragraph: See [the skill](skill://opencode/SKILL.md:3), [its notes](skill://opencode/docs/notes.md) and [one that is not there](skill://opencode/nope.md). (2) file_contents gains skill://opencode/SKILL.md = # OpenCode\n\nQuestions about OpenCode itself.\n\nSee [the notes](docs/notes.md).\n and skill://opencode/docs/notes.md = # Notes\n\nA second file of the same skill. Back to [the skill](../SKILL.md).\n. Start with --fixture <that file>; the before build takes the same file.

These run everything but the read: the file's body comes from the fixture, not from a server.

  • A1. A link in a reply. Press "the skill". See: a file tab titled SKILL.md (not "not found"), in the source view at line 3 ("Questions about OpenCode itself."); the Files tree has no skill: row; the Files header shows no Open in button; the tab's menu has "Copy path" and neither "Open in" nor "Show in folder". Before: no file tab.
  • A2. A relative link in a skill's file. Press "its notes": a tab notes.md, rendered. In it press "the skill": the SKILL.md tab of A1 is shown, not a second one. Then in SKILL.md's rendered view press "the notes": the notes.md tab.
  • A3. A file that is not there. Press "one that is not there". See: a toast naming skill://opencode/nope.md, no tab.

B. With a server (waits for memory)

A server from before df79010bc6 (24 Nov) has no skill-file route: there the port takes its fallback (the route's 404, then the skills list's inline body). Cases B1 to B3 run on either; say which requests the server got.

  • B1. A built-in skill opens. A session on a server that lists a skill whose path is skill://<id>/SKILL.md (ask GET /api/skill). Open Details, Skills, press that skill. See: a file tab titled SKILL.md with the skill's text. Before: no tab opens.
  • B2. A link in a reply. A reply holding [the skill](skill://<id>/SKILL.md:3). Press it. See: the same tab, at line 3 in the source view. Before: no tab.
  • B3. A file that is not there. A link to skill://<id>/nope.md. See: a toast naming the path, no tab.
  • B4. The route itself (a server at or past df79010bc6): B1 again; the server gets GET /api/experimental/skill/<id>/file/SKILL.md and answers 200; no /api/skill read follows for it.
  • B5. An MCP server's skill (the same newer server, its mcp_skills flag, and an MCP server that serves a skill): its row in Details opens its SKILL.md, whose body the list does not carry.

What has run

Headless, on this PR's Windows x64 CI build, the fixture file of section A, no server. The before build is the Rune pin bump's own PR build (#1192, run 45629508899, head cc991c6505): dev at the new pin.

Case Head it ran on Result
A1 043c15009 holds: a tab SKILL.md in the source view with its text, line 3 marked; its id //skill://opencode/SKILL.md; no skill: row in the tree; no Open in on the Files header. On d23a6bb6d it did not hold (the tab said "File not found: SKILL.md" and the tree had a skill: row): the fault above
A2 043c15009 holds: a tab notes.md, rendered, no skill: row; the link inside it opens SKILL.md under the same tab id as A1's, rendered. Not run: SKILL.md's own link to the notes (the same step the other way)
A3 043c15009, and d23a6bb6d before it holds: a toast "File not found" naming skill://opencode/nope.md, no tab
Before, the three presses cc991c6505 no tab; the address is copied and a toast says "Copied"
B1 043c15009, with the test server (from before df79010bc6) holds: Details, Skills, "OpenCode" pressed: one file tab SKILL.md with the skill's text, rendered; the card closes. The server was asked the file route once (404), then /api/skill (200): the fallback. Before: no tab; "Copied"
B2 043c15009, the same server holds: the reply's link skill://opencode/SKILL.md:3 opens the same tab in the source view, line 3's number in the accent colour. The same two requests. Before: no tab; "Copied"
B3 043c15009, the same server holds: a toast "File not found" naming skill://opencode/nope.md, no tab. The route once (404), then the list (200)
B4, B5 NOT RUN: need a server at or past df79010bc6 the new route answering 200, and an MCP server's skill: by reading only

Seen at the server, beside the cases: in its first second for a folder, /api/skill answered 200 with an empty list; two seconds later it listed the skills. On the fallback path ours reads that list once: a skill opened in that first second would read as not found, and opens on the next press. By reading; what official's read did in that second before #66201 is not read.

Not run (by reading)

  • The new route is by reading only. B4 and B5 cannot run on the server the cases run on (it is from before df79010bc6): there B1 to B3 prove the fallback. The route is one GET at official's URL (client/src/promise/generated/client.ts, experimental.skill.file), and its answer goes through the same bytes-to-viewer function as every other file (data.rs payload).
  • A /builtin/ path: no current server lists one (official kept the branch for older ones). Its tab's id drops the leading slash, as any absolute path's with one does (file_rank.rs file_tab_id): by reading such a tab reads a file of the folder instead. Not changed here.
  • A relative link inside a skill's rendered file names another file of that skill (links.rs classify). Official, by reading, joins the two into skill:/<id>/... with one slash (gui-plugins/src/file/artifact.ts:123-143 from renderer.tsx:708), which its own isVirtualSkill does not match: a fault there, not copied.

Hona added 2 commits November 25, 2026 23:53
…6201)

skill://<id>/<file> is read through GET /api/experimental/skill/<id>/file/<path>; a /builtin/ path, and a skill:// one on a server without that endpoint, from the skills list's inline body. Such a file is a link to the viewer, is in no tree, is not watched and opens in no app.
Hona added 3 commits November 26, 2026 00:18
normalize_path collapsed skill://<id>/<file> to skill:/<id>/<file>, the name the file tab's id and Workspace:OpenDocument carry, so the tab would have read a file of the folder by that name. The Files header's Open in is not offered for such a file. A fixture's file_contents may hold one: it has a body and is in no tree.
It normalized the tab's path with the review's own normalize_path (crates/opencode-code-view/src/data/review.rs), not the one the tab's id is made with, so skill://<id>/<file> became skill:/<id>/<file> again: the tab opened and said the file was not found, and the tree gained a skill: row. Found by the run of the no-server cases.
@Hona
Hona marked this pull request as ready for review November 25, 2026 20:14
@Hona
Hona merged commit 7c3c9ed into dev Nov 25, 2026
7 checks passed
@Hona
Hona deleted the upstream-g/skill-files branch November 25, 2026 20:14
Hona added a commit that referenced this pull request Nov 25, 2026
…-path

With #1226 (a skill's virtual file): the document's path keeps both a leading / and skill://; the tree, the fixture loader and the Files header's Open in take a file outside the folder and a skill's virtual file alike (data::is_outside).
Hona added a commit that referenced this pull request Nov 25, 2026
…90d (#1267)

Two new official commits since 2b296cabc8, neither the desktop's: 35c35d3d80 (the data app's tests) and 57551d990d (ai: freeform tools sent as JSON); both skipped. UP-218 (a skill's virtual file opens in the file tab) is ported by #1226: the row has what ran (the fallback read with a test server from before the new route, and a fixture file) and what is by reading only (the new route answering 200, an MCP server's skill).
@Hona

Hona commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

Follow-up verification against a server at badd3ea1cd (which includes GET /api/experimental/skill/:id/file/*):

  • Route 200 (skill://opencode/SKILL.md:3): GET /api/experimental/skill/opencode/file/SKILL.md returned 200 (6,933 bytes, zero fallback to /api/skill), opened SKILL.md in the source viewer with line 3 marked, and kept Open in / Show in folder hidden.
  • Missing skill file 404 (skill://opencode/nope.md): GET /api/experimental/skill/opencode/file/nope.md returned 404, showed the File not found toast for skill://opencode/nope.md, and opened no tab.
  • Details > Skills > OpenCode: requested GET /api/experimental/skill/opencode/file/SKILL.md (200) and opened SKILL.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant