Skip to content

Commit 94b4710

Browse files
committed
feat(opencode-api)!: download the OpenAPI spec at run time instead of shipping it
The ~1 MB spec was over the Claude plugin directory's 256 KiB file limit. api_lookup.py now fetches https://opencode.ai/docs/openapi.json on first use into $XDG_CACHE_HOME/opencode-dev-plugin/opencode-api/ (ETag re-check after 7 days, stale copy used offline, --spec for a local file, --refresh). refresh_references.py becomes fetch_spec.py and writes to that cache. opencode-api 0.3.0. BREAKING CHANGE: references/openapi.json and scripts/refresh_references.py are gone; the first lookup needs network access to opencode.ai (or --spec). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QT6szy26vmHpCXcLaDEDSy
1 parent 862b612 commit 94b4710

11 files changed

Lines changed: 155 additions & 31542 deletions

File tree

‎.skillspector/opencode-api.yaml‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
# rules to one file so a new gap still fails CI. Format: upstream
77
# docs/SUPPRESSION.md.
88
version: 2
9-
rules:
10-
- id: "AE1"
11-
path: "SKILL.md"
12-
message: "*references/openapi.json (partial)*"
13-
reason: "Coverage gap: SkillSpector's bounded static parser (tool-misuse analyzer) stops on long expressions in this file; scanner limit, not a finding in the file (vendored OpenAPI spec)"
14-
- id: "AS2"
15-
path: "references/openapi.json"
16-
reason: "Vendored upstream docs (references/ is downloaded, never hand-edited): the opencode server's /mcp endpoint description 'List MCP servers', not an access to MCP config"
9+
# The two rules for the shipped references/openapi.json were dropped when the
10+
# spec moved to a run-time download (2026-11-28).
11+
rules: []

‎AGENTS.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ applies. It ships four skills for opencode v2, moved here with their history fro
3434
the page `X.md` they supplement. Maintenance details are in the skill's `MAINTAINING.md`.
3535
- `opencode-cli` - opencode v2 CLI docs (commands, `cli.json`, keybinds, themes, web UI, ACP)
3636
cached the same way, with its own refresh script copy and `ERRATA.md`.
37-
- `opencode-api` - the server's published OpenAPI spec cached in `references/openapi.json`,
38-
searched with `scripts/api_lookup.py` (too large to read whole).
37+
- `opencode-api` - the server's published OpenAPI spec, searched with `scripts/api_lookup.py`
38+
(too large to read whole). Not shipped (about 1 MB, over the Claude plugin directory's 256 KiB
39+
file limit): `scripts/fetch_spec.py` downloads it into a per-user cache on first use and
40+
re-checks it weekly (the user, 2026-11-28).
3941
- `opencode-console` - OpenCode Console docs cached like `opencode-cli`, with every dollar
4042
amount except `$0` replaced by `[check-api]` at download; `SKILL.md` says how to look prices
4143
up live. Our own `CLI.md` and `API.md` sit beside `SKILL.md`, not in `references/`.

‎TODO.md‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ Settled by superpowers (no test needed):
6767
- [ ] SkillSpector CI: `.skillspector/<skill>.yaml` baselines came over from `rjstone/agent-skills`,
6868
but this repo has no SkillSpector workflow yet. Port `skillspector.yml` and
6969
`scripts/skillspector_ci.py` from there, or run the scan by hand before releases.
70-
- [ ] `skills/opencode-api/references/openapi.json` is about 930 KiB. The Claude plugin directory
71-
limits files to 256 KiB (the local `--profile directory` check doesn't flag it). Decide before
72-
submitting there: split it, compress it, or fetch it at refresh time only.
7370
- [ ] Tag the first release `v0.1.0` (the maintainer: cloud sessions can't push tags), then add
7471
the plugin to `rjstone/plugin-marketplace`.
7572
- [ ] `opencode-console`: still missing upstream (checked 2026-11-08, still true 2026-11-22): a

‎skills/index.json‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
"skills": [
33
{
44
"name": "opencode-api",
5-
"version": "0.2.2",
5+
"version": "0.3.0",
66
"files": [
77
"ERRATA.md",
88
"SKILL.md",
9-
"references/manifest.json",
10-
"references/openapi.json",
119
"scripts/api_lookup.py",
12-
"scripts/refresh_references.py"
10+
"scripts/fetch_spec.py"
1311
]
1412
},
1513
{

‎skills/opencode-api/ERRATA.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Errata: mistakes in the cached opencode OpenAPI spec
22

3-
`references/openapi.json` is overwritten by `scripts/refresh_references.py`;
3+
The downloaded spec is overwritten by `scripts/fetch_spec.py`;
44
corrections live here instead. When a refresh changes the spec, the script
55
prints `re-check errata: <ids>`: re-verify each, then update or delete it.
66

‎skills/opencode-api/SKILL.md‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
name: opencode-api
33
description: Use when calling or scripting the opencode server's HTTP API - sessions, prompts, messages, the event stream, PTYs and shells, files, MCP, config, permissions, worktrees, integrations - with curl, opencode api or another HTTP client, when reading the server's OpenAPI spec, or when unsure whether an opencode endpoint is v1 (/session, /event, /global/...) or v2 (/api/...).
4-
compatibility: Refreshing references/openapi.json (scripts/refresh_references.py) needs network access to opencode.ai; calls need a running opencode server.
4+
compatibility: The first lookup downloads the OpenAPI spec (about 1 MB) from opencode.ai into a per-user cache, so it needs network access once; calls need a running opencode server.
55
license: MIT
66
metadata:
77
author: Robert Stone
88
source: https://github.com/rjstone/opencode-dev-plugin
9-
version: "0.2.2"
9+
version: "0.3.0"
1010
---
1111

1212
# opencode server API (v2)
@@ -17,8 +17,12 @@ opencode v2 moved every server route under `/api/` (`POST /api/session`,
1717
`GET /api/event`, `GET /api/info`), so the v1 routes you remember (`/session`,
1818
`/event`, `/global/health`, `/doc`) are probably wrong. **Do not write opencode
1919
API calls from memory.** Look each one up in the cached OpenAPI spec,
20-
`references/openapi.json` (~880 KB, 170 operations): search it with the script
21-
instead of reading it.
20+
opencode OpenAPI spec (about 1 MB, 170+ operations): search it with the script
21+
instead of reading it. The first run downloads the spec into a per-user
22+
cache (`$XDG_CACHE_HOME/opencode-dev-plugin/opencode-api/`, default
23+
`~/.cache/...`) and re-checks it weekly; offline, it uses the cached copy.
24+
No network at all? Download https://opencode.ai/docs/openapi.json yourself
25+
and add `--spec <file>` to each command.
2226

2327
```bash
2428
python scripts/api_lookup.py --tags # areas and operation counts
@@ -49,7 +53,7 @@ disagree, `ERRATA.md` wins.
4953
cheap first call to check the connection.
5054
- The running server does not serve its own spec (no route for it; v1's
5155
`/doc` is gone, checked 2026-11-08). The published copy is
52-
https://opencode.ai/docs/openapi.json, cached here.
56+
https://opencode.ai/docs/openapi.json, which `api_lookup.py` downloads.
5357
- Events: `GET /api/event` (`event.subscribe`) is a `text/event-stream`;
5458
filter with the `types` query parameter. It is volatile: a slow reader is
5559
dropped, and events during a disconnect are lost.
@@ -76,9 +80,10 @@ disagree, `ERRATA.md` wins.
7680

7781
## Keeping it current
7882

79-
- `references/openapi.json` is a verbatim copy; **never edit it**. Refresh with
80-
`python scripts/refresh_references.py` (`--check` reports staleness without
81-
writing). The docs page https://opencode.ai/docs/api/ is generated from the
83+
- The cached spec is a verbatim download; **never edit it**. Re-check it now
84+
with `python scripts/api_lookup.py --refresh --tags`, or
85+
`python scripts/fetch_spec.py` (`--check` reports staleness without
86+
writing, `--dir` picks another folder). The docs page https://opencode.ai/docs/api/ is generated from the
8287
same file.
8388
- Found a mistake (the spec contradicts the running server)? Add an entry to
8489
`ERRATA.md` with the request, the response and the date.

‎skills/opencode-api/references/manifest.json‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)