Skip to content

Latest commit

 

History

History
108 lines (96 loc) · 9.03 KB

opencode.md

File metadata and controls

108 lines (96 loc) · 9.03 KB

OpenCode adapter

Verification: 1d265df3cfae49026ec4202fe88e9cce83ad1ca9 and accompanying changes; upstream inspected at v1.18.34 (aec0b9a6d8898f68f923aaf08b7306d931fd9d76). Re-read cited sources when changing behavior.

[FACT] The embedded opencode profile requires opencode and github, launches opencode --auto, and uses opencode-ai for npm versions/update commands. --auto approves requests not explicitly denied by OpenCode configuration; OpenShell supplies confinement. The existing tab icon is OC. 1 2 3 4

[FACT] The feature installs ripgrep and opencode-ai@latest at the managed npm prefix. Upstream postinstall selects the platform/CPU package and copies or hardlinks its native binary to opencode-ai/bin/opencode.exe, including Linux. Consequently network.opencode attributes egress to that executable, not Node. The compiled Bun binary can also execute JavaScript with BUN_BE_BUN=1: this is a process-path grant, not an assertion that only trusted agent code can use it. 5 6 7 8

[FACT] The capability grants HTTPS to registry.npmjs.org, opencode.ai, api.anthropic.com, api.openai.com, auth.openai.com, chatgpt.com, generativelanguage.googleapis.com and openrouter.ai. This covers Zen and common provider APIs, ChatGPT OAuth and npm plugins; it is not arbitrary web egress. Custom registries/providers require explicit capabilities. Shell PTYs remain opt-in. Policy goldens cover isolated, GitHub and read-only compositions. 7 8 9 10

[FACT] The account's OpenCode leaf binds at /home/sandbox/.local/share/opencode. XDG data retains that conventional path; launch overrides place config, cache, state and npm's download cache beneath that leaf. Config is config/opencode/opencode.json there. Credentials (auth.json), SQLite sessions and agent settings therefore use the account mount. Temporary files under /tmp/opencode are disposable. Import copies only the entire credential file, including all stored providers; it does not copy host configuration. 1 11 12 13 23

[FACT] Optional auth.import_home_dir chooses the host directory relative to home; absent it, import retains ~/<basename(state_container_path)>. Preferred import_files still precede credential_file, with duplicates removed. OpenCode selects .local/share/opencode; custom host XDG roots require --file. Validation rejects absolute/escaping directories. Active consumers prevent import; status establishes native-file presence, not provider acceptance. 2 13 14

[FACT] Declared account secrets are OPENCODE_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY and OPENROUTER_API_KEY. They use supervisor environment delivery, never launch argv. Changed secrets need box recreation. ChatGPT offers a headless device method through opencode auth login --provider openai --method 'ChatGPT Pro/Plus (headless)'; yoloctl box create opencode-login --agent opencode --account NAME --no-attach prepares a named box; box exec opencode-login -- opencode auth login ... runs that explicit login and writes native state. Exec forwards the supplied argv; managed-session profile environment is not implicitly added. 1 9 15 16

[FACT] Managed launch disables self-updates, model-catalog fetching and automatic LSP downloads, configures sharing disabled, and exempts loopback from proxies. The bundled model catalog remains available and updates with the CLI. Embedded auth plugins stay enabled. Operator guidance is discovered through the existing ~/.agents/skills mount. These settings do not grant more network destinations. 1 17 18 19 21 22

[FACT] Upstream installs @opencode-ai/plugin in configuration directories and resolves configured npm plugins through bundled Arborist in the native process. The registry grant permits encoded slashes used by scoped package URLs. npm lifecycle scripts remain disabled by upstream's ignoreScripts: true; loaded plugin hooks run within the agent's existing authority. NPM_CONFIG_CACHE keeps downloads in the account leaf. The fixture requires SDK installation and a local plugin hook. 1 20 24 25 26 27

[FACT] smoke-opencode tests installation, attributed HTTPS, secret replacement, import refusal and native state across box/VM replacement. Its local provider fixture runs the real CLI, checks plugin loading, a shell tool without new PTYs, operator skill discovery and saved-session resumption. Optional OpenAI credentials enable a real provider request. These definitions do not establish live image/VM or OAuth validation; first login, token refresh and interactive terminal behavior require separate checks. 8 20

Sources

  1. Embedded profile — launch, state and secrets.
  2. Adapter tests — launch, install, import and completion.
  3. Upstream TUI CLI — auto approval.
  4. Icon table — OpenCode defaults.
  5. Feature recipe — installation.
  6. Upstream installer — native selection and target.
  7. Capabilities — network.opencode.
  8. Isolated smoke — binary/runtime/persistence checks.
  9. Upstream ChatGPT auth — headless device flow and endpoints.
  10. Policy tests — compositions and attribution.
  11. Upstream XDG paths — persistent and temporary directories.
  12. Upstream auth storage — credential file.
  13. Import implementation — defaultHostAuthPaths and import.
  14. Profile validation — validateAuth.
  15. Secret projection tests — declared keys and argv/label isolation.
  16. Confined exec — explicit argv through OpenShell SSH.
  17. Upstream catalog — snapshot and fetch control.
  18. Upstream skills — external skills.
  19. Upstream config — inline config merge.
  20. Local provider fixture — real CLI/tool/session checks without real keys.
  21. Upstream runtime flags — default plugins and LSP control.
  22. Upstream flag parsing — update and model-fetch flags.
  23. Upstream database path — SQLite under data.
  24. Upstream dependency bootstrap — background plugin-SDK installation.
  25. Upstream npm service — Arborist, script suppression, package resolution and dependency installation.
  26. Endpoint compiler — REST configuration and encoded slash permission.
  27. Upstream npm configuration — environment and npm settings.