ShtukbaseStandard
包文件→ .shtukbase/packages/harness-opencode/adapter.ts

adapter.ts

19 行, 1.2 KB.

文件按包中的原样显示:代码及其注释不做翻译。

  1. // OpenCode: `opencode run <message>` answers once and exits. Permissions come from inline config
  2. // (OPENCODE_CONFIG_CONTENT): edits allowed only with access: write, shell denied, web denied unless network: true,
  3. // folders outside the working folder denied. --pure: no external plugins.
  4. import type { Adapter } from '../harness/lib/harness.ts';
  5. export const adapter: Adapter = {
  6. id: 'opencode', pkg: 'harness-opencode', bin: 'opencode', title: 'OpenCode', defaultModel: 'opencode-go/deepseek-v4.1-flash',
  7. install: 'curl -fsSL https://opencode.ai/install | bash, then opencode auth login (the OpenCode Go subscription)',
  8. build(s) {
  9. const web = s.network ? 'allow' : 'deny';
  10. const permission = { edit: s.access === 'write' ? 'allow' : 'deny', bash: 'deny', webfetch: web, websearch: web, external_directory: 'deny' };
  11. return {
  12. exe: 'opencode',
  13. args: ['run', '--pure', '--dir', s.cwd, '-m', s.model, ...(s.effort ? ['--variant', s.effort] : []), '--', s.prompt],
  14. env: { OPENCODE_CONFIG_CONTENT: JSON.stringify({ permission }) },
  15. notes: ['the shell (bash) of an OpenCode agent is always off: otherwise the file and network rights cannot be held'],
  16. };
  17. },
  18. };