Allow OpenCode to directly get infomation from the tool's source code by integrating Better Context CLI
  • Nix 53.3%
  • TypeScript 46.7%
Find a file
2026-06-28 12:07:16 +02:00
.config/opencode Move the btca.nix file to home-manager folder for clarity 2026-04-15 12:19:17 -07:00
home-manager Move the btca.nix file to home-manager folder for clarity 2026-04-15 12:19:17 -07:00
.editorconfig Update for Nix files 2026-04-15 12:10:50 -07:00
.gitignore build(ts): Add tsconfig and gitignore 2026-01-19 01:29:50 -08:00
LICENSE Initial commit 2026-01-18 20:38:18 -08:00
README.md Update README.md 2026-06-28 12:07:16 +02:00
tsconfig.json build(ts): Add tsconfig and gitignore 2026-01-19 01:29:50 -08:00

OpenCode BTCA

Allow OpenCode to directly retrieve information from source files by integrating BTCA as OpenCode tools.

Demo

I asked OpenCode about the Zig programming language using the BTCA tools. Check out the video on YouTube.

Contents

Files

Note

Combine the files with your existing configuration. You don't need to use all the files.

.config/opencode/tools/btca.ts

Allow OpenCode agents to invoke BTCA commands as standard command-line tools (for example, ls or grep). The tool supports these BTCA CLI commands:

  • btca ask: supports single and multiple sources
  • btca connect: the CLI does not exit automatically, so a timeout is used as a workaround
  • btca resources
  • btca add
  • btca remove
  • btca clear

Reference:

home-manager/btca.nix

Nix Home Manager version of .config/opencode/tools/btca.ts. You only need to use either of the two. Please properly import this file and make sure you have set the config.home.homeDirectory by yourself. An older Home Manager version may not require that. Official documentation reference Since this points to the @opencode-ai/plugin/dist/index.js, this is kind of hacky, and might have breakages upon the entry file change on OpenCode.

Reference:

.config/opencode/opencode.jsonc

Set permissions for the BTCA tools. Explicit permissions are recommended for destructive commands such as btca clear, although they are not strictly required.

Reference:

Contributions

  • Open issues or pull requests for bug reports, feature requests, or improvements.
  • Create branches from dev and target dev when opening a pull request.
  • Consider starring the repository if it is useful!

LLM Disclaimer

I used LLM to write the scripts in this repository (especially for the original TypeScript script). This is because I'm not familier with TypeScript/JavaScript, but it was the most natural to use TypeScript for OpenCode tools script. The code logic was reviewed heavily, but the type reference and syntax might be wrong. Please make an issue or a PR to report anything to improve the code as needed.