Imported from grikomsn/opencode-copilot-chat (
AGENTS.md). Install upstream withnpx skills add grikomsn/opencode-copilot-chat. Copyright stays with the author.
Repository guide
Project shape
This is a small, strict-TypeScript VS Code extension that exposes OpenCode Zen, OpenCode Go, and OpenCode Console as native Copilot Chat language-model providers. It targets Node.js 22+ and VS Code 1.125+.
src/extension.ts: activation and dependency wiringsrc/commands/: sign-in, management, diagnostics, connection, and model commandssrc/provider.ts: language-model provider facade, model discovery, request lifecycle, and usage capturesrc/provider/: message conversion, request construction, and VS Code response projectionsrc/auth/: API-key and Console device-code authentication; credentials live in VS CodeSecretStoragesrc/models/: model catalog and model-specific reasoning configurationsrc/models/metadata.ts: shared persisted models.dev enrichment for Zen and Go discoverysrc/transport/: OpenCode request identity plus Chat Completions, Messages, Responses, Google, and SSE dialectssrc/tools/: caller-executed VS Code function declarationssrc/usage/: token usage parsing and display helperssrc/vscode/: proposed VS Code API type augmentations- Tests are colocated as
src/**/*.test.tsusingnode:testandnode:assert/strict package.json: extension manifest, public commands/settings, and scripts
Working conventions
- Match the existing style: 2-space indentation, double quotes, semicolons, trailing commas, and explicit types at module/API boundaries.
- Keep changes focused. Prefer pure helpers for parsing, conversion, and formatting so behavior is easy to test without a VS Code host.
- Add or update colocated tests whenever behavior changes. Cover fragmented streams, malformed external data, cancellation, retries, and fallback paths where relevant.
- Keep
package.json, README/setup documentation, and command/configuration handling synchronized when public commands, settings, requirements, or workflows change. - Treat authentication and provider changes as security-sensitive: never log prompts or tokens, never persist credentials outside
SecretStorage, and keep Console account synchronization defensive. - Preserve cancellation and streaming behavior. Do not buffer a response that can be handled incrementally, and retain the single forced token refresh/retry on HTTP 401.
- Do not commit generated
out/, source maps,node_modules/, or.vsixfiles.
Validation
Use the repository scripts rather than ad hoc build commands:
npm ci # clean dependency install
npm test # clean compile, then all node:test suites
npm run package # full validation plus VSIX packaging
Run npm test for code changes. Also run npm run package when changing the
manifest, packaging rules, dependencies, or release-facing content. The CI
matrix uses Node 22, 24, and 26.
Release hygiene
- Add a Changeset with
npm run changesetfor user-visible behavior changes. - Documentation-only, test-only, and repository-maintenance changes do not need a Changeset.
- Do not manually bump the version or edit release output unless explicitly performing the release workflow.