feat(init): add opencode as a fifth editor target#217
Merged
Conversation
Wire opencode into the shared EditorTarget abstraction. Agent files are installed at user scope (~/.config/opencode/agents or %APPDATA%\opencode\agents) via an authenticated tarball download from the plugins service — no files land in the project tree, keeping the proprietary agent prompts out of consumer repos. - Add opencodeAgentsDir() with XDG/APPDATA resolution (ARCH-009 compliant) - Add isOpencodeCliAvailable() and installOpencodePlugin() using Bun.spawn for tar extraction (ARCH-007) - Extend EditorTarget union, EDITOR_LABELS, EDITOR_DIRS, SIGNUP_EDITORS - Extend --editor choices in init, plugin install, and plugin url - Plugin install aliases to the init writer (no network for repeated installs once the tarball has been fetched — each call re-fetches authenticated) - Document the "add a new editor" checklist in cli/CLAUDE.md so future contributors hit every wire-up point up front Depends on: plugins service endpoint /api/opencode (follow-up) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deploying archgate-cli with
|
| Latest commit: |
820fc3f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1c183c80.archgate-cli.pages.dev |
| Branch Preview URL: | https://feat-opencode-editor-support.archgate-cli.pages.dev |
- guides/opencode-integration.mdx (EN + PT-BR) documenting the user-scope install behaviour, the five agents, and the developer workflow - reference/cli/init.mdx and plugin.mdx updated to list opencode in --editor choices and describe the tarball/user-scope install path - astro.config.mjs sidebar entry for the new guide - docs/public/llms-full.txt regenerated by the docs build Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
opencode locates its user-scope config via the `xdg-basedir` npm package, which falls back to `~/.config` on every platform including Windows — it does NOT read `%APPDATA%`. My earlier implementation guessed at the standard Windows convention and would have written files under `%APPDATA%\opencode\agents\` where opencode would never look for them. - `opencodeAgentsDir()` now honors `$XDG_CONFIG_HOME` when set and falls back to `$HOME/.config/opencode/agents` on every platform. On Windows this resolves to `C:\Users\<user>\.config\opencode\agents` via `os.homedir()` / `$USERPROFILE`, matching what opencode actually reads. - Drop the now-unused `isWindows` import. - Update the opencode integration guide (EN + PT-BR) and the `archgate init` reference (EN + PT-BR) with the corrected path and an explanation of why Windows doesn't use `%APPDATA%`. - Extend the "add a new editor" checklist in CLAUDE.md with a note to verify the editor's path helper in its source before writing the resolver — this bug was a guess-the-convention mistake. - Regenerated llms-full.txt from the updated docs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Every other editor's install path checks `is<Editor>CliAvailable()` before
writing files or invoking the editor's plugin subcommand. The opencode path
skipped that check and would write `archgate-*.md` files into
`~/.config/opencode/agents/` even on machines that don't have opencode
installed — leaving stale files in a directory nothing reads.
- `tryInstallPlugin("opencode")` now calls `isOpencodeCliAvailable()`
first and returns a `cli-not-found` sentinel when the binary is missing.
- `printManualInstructions("opencode", "cli-not-found")` tells the user to
install opencode from https://opencode.ai/docs/ and re-run
`archgate plugin install --editor opencode`. Existing failure branch
(download/extract error) is preserved for other `detail` values.
- `archgate plugin install --editor opencode` mirrors the same guard so
the direct install command doesn't silently write files either.
- Tests: add `isOpencodeCliAvailable` boolean smoke test (mirrors the
existing pattern for claude/copilot/vscode).
- Docs (EN + PT-BR guide, both reference pages): document the prerequisite
and regenerate llms-full.txt.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EditorTargetabstraction alongside Claude Code, Cursor, VS Code, and Copilot CLI~/.config/opencode/agents/on POSIX,%APPDATA%\opencode\agents\on Windows) rather than into the project tree, so the proprietary agent prompts stay out of consumer repos.vsixflow)archgate init --editor opencodeandarchgate plugin install --editor opencodeto cover the new targetImplementation notes
paths.ts::opencodeAgentsDir()resolves XDG/APPDATA with the same defensive env handling asarchgateHomeDir()(ARCH-009 compliant — goes throughisWindows()fromhelpers/platform.ts)plugin-install.ts::installOpencodePlugin()downloads/api/opencode, extracts viaBun.spawn(["tar", "-xzf", ...])(ARCH-007), cleans up the staging archive in afinallyplugin/url.tsprints a "N/A — run authenticated install" hint for opencode instead of a marketplace URLtryInstallPluginroutes throughprintManualInstructions("opencode", detail)so the user sees a retry +archgate login refreshhintcli/CLAUDE.mdgains an "Adding a New Editor Target" checklist documenting the 7-file + 3-test wire-up surface (captured from this session — three tests failed on first run because their expectedargChoicesarray didn't include the new entry)Depends on
archgate/pluginscompanion PR adding the agent source files underopencode/plugins/archgate/agents/GET https://plugins.archgate.dev/api/opencodereturning a.tar.gzof the fivearchgate-*.mdfiles (Bearer auth, same 401 behavior as/api/vscode)Test plan
bun run validate— 639 pass / 0 fail, 21/21 ADR rules pass, build-check succeedsbun test tests/commands/plugin tests/helpers/editor-detect.test.ts— choice-list assertions updated to includeopencode/api/opencodeis live:archgate init --editor opencode --install-pluginwrites the five files toopencodeAgentsDir()and does not touch the project treearchgate plugin install --editor opencodere-runs the install idempotentlyarchgate login refreshhintopencodein a test project; confirmarchgate-developeris selectable as primary and@archgate-architect/@archgate-quality-manager/@archgate-adr-author/@archgate-cli-referenceresolve as subagents%APPDATA%\opencode\agents\Known caveat (pre-existing, not addressed here)
Architect review flagged one ARCH-012 warning: the outer
registerPluginInstallCommandaction body is not fully wrapped in try/catch — only the per-editor install loop is. Pre-looploadCredentials()errors would fall through tomain().catch()(exit 2) instead oflogError+ exit 1. Not introduced by this change; worth a follow-up.🤖 Generated with Claude Code