@wwkit/harness 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/extract.md +2 -14
- package/agents/lint.md +367 -0
- package/agents/pyit.md +361 -0
- package/agents/pyut.md +347 -0
- package/agents/query.md +2 -14
- package/agents/revise.md +2 -14
- package/agents/work.md +151 -0
- package/commands/git-sync.md +218 -0
- package/commands/net-port.md +364 -0
- package/commands/pyit.md +6 -0
- package/commands/pyut.md +6 -0
- package/commands/resume.md +104 -0
- package/package.json +2 -2
- package/skills/better-skill/SKILL.md +124 -0
- package/skills/blame-skill/SKILL.md +201 -0
- package/skills/lint-ai-fix/SKILL.md +141 -0
- package/skills/lint-config-setup/SKILL.md +106 -0
- package/skills/lint-config-setup/references/languages/js.md +110 -0
- package/skills/lint-config-setup/references/languages/py.md +89 -0
- package/skills/lint-env-ensure/SKILL.md +92 -0
- package/skills/lint-env-ensure/references/config.md +65 -0
- package/skills/lint-language-detect/SKILL.md +79 -0
- package/skills/lint-language-detect/references/detect-language.js +65 -0
- package/skills/lint-rules-analyze/SKILL.md +129 -0
- package/skills/lint-suitability-check/SKILL.md +84 -0
- package/skills/lint-tool-fix/SKILL.md +94 -0
- package/skills/new-skill/SKILL.md +227 -0
- package/skills/new-skill/references/template.md +53 -0
- package/skills/new-skill/references/workflow-patterns.md +104 -0
- package/skills/pytest-case-create/SKILL.md +327 -0
- package/skills/pytest-case-create/references/test-standards.md +244 -0
- package/skills/pytest-case-fix/SKILL.md +274 -0
- package/skills/pytest-coverage-analyze/SKILL.md +226 -0
- package/skills/pytest-coverage-analyze/references/scoring-rules.md +57 -0
- package/skills/pytest-env-ensure/SKILL.md +198 -0
- package/skills/pytest-env-ensure/references/config.md +145 -0
- package/skills/pytest-execute/SKILL.md +155 -0
- package/skills/pytest-sample/SKILL.md +164 -0
- package/skills/pytest-sample/references/src/pytest-sample/Calculator.py +67 -0
- package/skills/pytest-sample/references/src/pytest-sample/ConfigManager.py +68 -0
- package/skills/pytest-sample/references/src/pytest-sample/FileProcessor.py +53 -0
- package/skills/pytest-sample/references/src/pytest-sample/OrderService.py +82 -0
- package/skills/pytest-sample/references/src/pytest-sample/TokenGenerator.py +50 -0
- package/skills/pytest-sample/references/src/pytest-sample/UserService.py +45 -0
- package/skills/pytest-sample/references/src/pytest-sample/__init__.py +0 -0
- package/skills/pytest-suitability-check/SKILL.md +224 -0
- package/skills/read-docs/SKILL.md +134 -0
- package/skills/read-docs/references/opencode/agents/cases.md +206 -0
- package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -0
- package/skills/read-docs/references/opencode/agents/detail.md +191 -0
- package/skills/read-docs/references/opencode/agents/examples.md +100 -0
- package/skills/read-docs/references/opencode/agents/index.md +307 -0
- package/skills/read-docs/references/opencode/agents/workflow.md +161 -0
- package/skills/read-docs/references/opencode/cli/commands/acp.md +32 -0
- package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -0
- package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -0
- package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -0
- package/skills/read-docs/references/opencode/cli/commands/others.md +49 -0
- package/skills/read-docs/references/opencode/cli/commands/plugin.md +13 -0
- package/skills/read-docs/references/opencode/cli/commands/provider.md +44 -0
- package/skills/read-docs/references/opencode/cli/commands/run.md +81 -0
- package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -0
- package/skills/read-docs/references/opencode/cli/commands/session.md +38 -0
- package/skills/read-docs/references/opencode/cli/commands/web.md +15 -0
- package/skills/read-docs/references/opencode/cli/env.md +39 -0
- package/skills/read-docs/references/opencode/cli/index.md +19 -0
- package/skills/read-docs/references/opencode/cli/tui.md +35 -0
- package/skills/read-docs/references/opencode/commands/examples.md +42 -0
- package/skills/read-docs/references/opencode/commands/index.md +185 -0
- package/skills/read-docs/references/opencode/config/provider.md +152 -0
- package/skills/read-docs/references/opencode/formatter/index.md +71 -0
- package/skills/read-docs/references/opencode/guide/config.md +419 -0
- package/skills/read-docs/references/opencode/guide/formatters.md +70 -0
- package/skills/read-docs/references/opencode/guide/index.md +37 -0
- package/skills/read-docs/references/opencode/guide/providers.md +31 -0
- package/skills/read-docs/references/opencode/guide/rules.md +63 -0
- package/skills/read-docs/references/opencode/plugins/examples.md +75 -0
- package/skills/read-docs/references/opencode/plugins/index.md +188 -0
- package/skills/read-docs/references/opencode/reference/index.md +119 -0
- package/skills/read-docs/references/opencode/rule/index.md +78 -0
- package/skills/read-docs/references/opencode/skills/detail.md +113 -0
- package/skills/read-docs/references/opencode/skills/examples.md +141 -0
- package/skills/read-docs/references/opencode/skills/index.md +126 -0
- package/skills/read-docs/references/opencode/skills/workflow.md +146 -0
- package/skills/read-docs/references/opencode/tests/agent.md +10 -0
- package/skills/read-docs/references/opencode/tests/config.md +60 -0
- package/skills/read-docs/references/opencode/tests/file.md +12 -0
- package/skills/read-docs/references/opencode/tests/serve.md +18 -0
- package/skills/read-docs/references/opencode/tests/session.md +31 -0
- package/skills/read-docs/references/opencode/tests/web.md +17 -0
- package/skills/read-docs/references/opencode/tools/arguments.md +305 -0
- package/skills/read-docs/references/opencode/tools/context.md +18 -0
- package/skills/read-docs/references/opencode/tools/custom.md +111 -0
- package/skills/read-docs/references/opencode/tools/detail.md +104 -0
- package/skills/read-docs/references/opencode/tools/examples.md +71 -0
- package/skills/read-docs/references/opencode/tools/index.md +56 -0
- package/skills/read-docs/references/opencode/tools/lsp.md +26 -0
- package/skills/read-docs/references/opencode/tools/mcp.md +132 -0
- package/skills/read-docs/references/opencode/train/README.md +135 -0
- package/skills/read-docs/references/opencode/train/agent-basic.md +772 -0
- package/skills/read-docs/references/opencode/train/command-basic.md +668 -0
- package/skills/read-docs/references/opencode/train/config-basic.md +509 -0
- package/skills/read-docs/references/opencode/train/index.md +164 -0
- package/skills/read-docs/references/opencode/train/practice.md +873 -0
- package/skills/read-docs/references/opencode/train/skill-basic.md +608 -0
- package/skills/read-docs/references/opencode/tui/commands/config.md +32 -0
- package/skills/read-docs/references/opencode/tui/commands/editor.md +47 -0
- package/skills/read-docs/references/opencode/tui/commands/index.md +125 -0
- package/skills/read-docs/references/opencode/tui/commands/init.md +5 -0
- package/skills/read-docs/references/opencode/tui/index.md +26 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# run
|
|
2
|
+
Run opencode in `non-interactive` mode by passing a prompt directly.
|
|
3
|
+
```
|
|
4
|
+
opencode run [message..]
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## run --attach
|
|
8
|
+
You can also attach to a running `opencode serve` instance to avoid MCP server cold boot times on every run:
|
|
9
|
+
```
|
|
10
|
+
opencode serve --port 4096
|
|
11
|
+
opencode run --attach http://localhost:4096 "Explain async/await in JavaScript"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
冷启动与attach:
|
|
15
|
+
- `opencode run`每次执行都要:启动进程 → 加载 MCP Server → 初始化模型 → 执行 → 退出。MCP Server 启动可能需要数秒,频繁执行时浪费时间。
|
|
16
|
+
|
|
17
|
+
解决方案:
|
|
18
|
+
- 终端1:启动常驻服务器(一次性冷启动)
|
|
19
|
+
```
|
|
20
|
+
opencode serve --port 4096
|
|
21
|
+
```
|
|
22
|
+
- 终端n:多任务复用同一个服务器(跳过冷启动)
|
|
23
|
+
```
|
|
24
|
+
opencode run --attach http://localhost:4096 "Explain async/await"
|
|
25
|
+
opencode run --attach http://localhost:4096 "Fix the bug in main.ts"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Flags
|
|
29
|
+
### Model and Perm
|
|
30
|
+
- `--model` `-m` : Model to use in the form of `provider/model`
|
|
31
|
+
- `--auto` : Auto-approve permissions that are not explicitly denied
|
|
32
|
+
|
|
33
|
+
### Invoke
|
|
34
|
+
- `--command` : The command to run, use message for args
|
|
35
|
+
- `--agent` : Agent to use
|
|
36
|
+
|
|
37
|
+
### Attach
|
|
38
|
+
- `--attach` : Attach to a running opencode server (e.g., `http://localhost:4096`)
|
|
39
|
+
- `--port` : Port for the local server (defaults to random port)
|
|
40
|
+
- `--password` `-p` : Basic auth password (defaults to `OPENCODE_SERVER_PASSWORD`)
|
|
41
|
+
- `--username` `-u` : Basic auth username (defaults to `OPENCODE_SERVER_USERNAME` or `opencode`)
|
|
42
|
+
|
|
43
|
+
### IO
|
|
44
|
+
- `--dir` : Directory to run in, or path on the remote server when attaching
|
|
45
|
+
- `--file` `-f` : File(s) to attach to message
|
|
46
|
+
- `--format` : Format: default (formatted) or json (raw JSON events)
|
|
47
|
+
|
|
48
|
+
### Session
|
|
49
|
+
- `--continue` `-c` : Continue the last session
|
|
50
|
+
- `--session` `-s` : Session ID to continue
|
|
51
|
+
- `--fork` : Fork the session when continuing (use with --continue or --session)
|
|
52
|
+
- `--share` : Share the session
|
|
53
|
+
- `--title` : Title for the session (uses truncated prompt if no value provided)
|
|
54
|
+
|
|
55
|
+
### Thinking
|
|
56
|
+
- `--variant` : Model variant (provider-specific reasoning effort)
|
|
57
|
+
- `--thinking` : Show thinking blocks
|
|
58
|
+
|
|
59
|
+
## Fork
|
|
60
|
+
- 原会话不变
|
|
61
|
+
- sessions列表新增一个会话
|
|
62
|
+
- 复制快照后独立发展
|
|
63
|
+
|
|
64
|
+
## File
|
|
65
|
+
文件内容会作为用户消息的一部分发送给模型。适合指令较长或需要复用的场景。
|
|
66
|
+
```
|
|
67
|
+
// 不需要额外 message
|
|
68
|
+
opencode run -f instructions.md
|
|
69
|
+
|
|
70
|
+
// 或文件内容 + 简短补充
|
|
71
|
+
opencode run -f instructions.md -- "注意优先处理错误处理部分"
|
|
72
|
+
|
|
73
|
+
// multi files
|
|
74
|
+
opencode run -f instructions.md instructions.md -- "注意优先处理错误处理部分"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Variant
|
|
78
|
+
控制模型推理努力程度,类似OpenAI的reasoning effort参数
|
|
79
|
+
- `low` : 低推理,快速响应
|
|
80
|
+
- `medium` : 中等推理(默认)
|
|
81
|
+
- `high` : 高推理(深度思考,适合复杂任务)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# serve
|
|
2
|
+
Start a headless OpenCode server for API access without the TUI interface.
|
|
3
|
+
```
|
|
4
|
+
opencode serve [--port <number>] [--hostname <string>] [--cors <origin>]
|
|
5
|
+
|
|
6
|
+
opencode serve --cors http://localhost:5173 --cors https://app.example.com
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Flags
|
|
10
|
+
- `--port` : Port to listen on, default `4096`
|
|
11
|
+
- `--hostname` : Hostname to listen on, default `127.0.0.1`
|
|
12
|
+
- `--mdns` : Enable mDNS discovery, default `false`
|
|
13
|
+
- `--mdns-domain` : Custom mDNS domain name, default `opencode.local`
|
|
14
|
+
- `--cors` : Additional browser origin to allow CORS, defualt `[]`
|
|
15
|
+
- can be passed multiple time
|
|
16
|
+
|
|
17
|
+
## Authentication
|
|
18
|
+
Set `OPENCODE_SERVER_PASSWORD` to protect the server with HTTP basic auth.
|
|
19
|
+
- The username defaults to `opencode`, or set `OPENCODE_SERVER_USERNAME` to override it.
|
|
20
|
+
- This applies to both `opencode serve` and `opencode web`.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
OPENCODE_SERVER_PASSWORD=your-password opencode serve
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## How it works
|
|
27
|
+
When you run opencode it starts a TUI and a server. You can run opencode serve to start a standalone server.
|
|
28
|
+
|
|
29
|
+
#### Connect to an existing server
|
|
30
|
+
When you start the TUI it randomly assigns a port and hostname. You can instead pass in the `--hostname` and `--port` flags. Then use this to connect to its server.
|
|
31
|
+
|
|
32
|
+
## Spec
|
|
33
|
+
The server publishes an OpenAPI 3.1 spec that can be viewed at:
|
|
34
|
+
```
|
|
35
|
+
http://<hostname>:<port>/doc
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For example, http://localhost:4096/doc. Use the spec to generate clients or inspect request and response types. Or view it in a Swagger explorer.
|
|
39
|
+
|
|
40
|
+
## APIs
|
|
41
|
+
The opencode server exposes the following APIs.
|
|
42
|
+
|
|
43
|
+
### Global
|
|
44
|
+
- `/global/health` : Get server health and version, `{healthy:true,version:string}`
|
|
45
|
+
- `/global/event` : Get global events (SSE stream)
|
|
46
|
+
|
|
47
|
+
### Project
|
|
48
|
+
- `/project` : list all projects, `Project[]`
|
|
49
|
+
- `/project/current` : Get the current project, `Project`
|
|
50
|
+
|
|
51
|
+
### Path & VCS
|
|
52
|
+
- `/path` : Get the current path, `Path`
|
|
53
|
+
- `/vcs` : Get VCS info for the current project, `VcsInfo`
|
|
54
|
+
|
|
55
|
+
### Instance
|
|
56
|
+
- `/instance/dispose` : Dispose the current instance, `boolean`
|
|
57
|
+
|
|
58
|
+
## Config
|
|
59
|
+
|
|
60
|
+
## Provider
|
|
61
|
+
|
|
62
|
+
## Sessions
|
|
63
|
+
|
|
64
|
+
## Messages
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
## Files
|
|
69
|
+
|
|
70
|
+
## Tools
|
|
71
|
+
|
|
72
|
+
## LSP
|
|
73
|
+
|
|
74
|
+
## Agents
|
|
75
|
+
|
|
76
|
+
## Logging
|
|
77
|
+
|
|
78
|
+
## TUI
|
|
79
|
+
|
|
80
|
+
## Auth
|
|
81
|
+
|
|
82
|
+
## Evetns
|
|
83
|
+
|
|
84
|
+
## Docs
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# session
|
|
2
|
+
Manage sessions
|
|
3
|
+
```
|
|
4
|
+
// list all sessions
|
|
5
|
+
opencode session list
|
|
6
|
+
|
|
7
|
+
// delete an session
|
|
8
|
+
opencode session delete <sessionID>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Flags:
|
|
12
|
+
- `--max-count` `-n` : limit to N most recent sessions
|
|
13
|
+
- `--format` : Output format : table or json
|
|
14
|
+
|
|
15
|
+
# export
|
|
16
|
+
Export session data as JSON
|
|
17
|
+
```
|
|
18
|
+
opencode export [sessionID]
|
|
19
|
+
|
|
20
|
+
# write to a file
|
|
21
|
+
opencode export ses_0cadb81d5ffernOJ0n2SD1FZ6S > ses_0cadb81d5ffernOJ0n2SD1FZ6S.json
|
|
22
|
+
```
|
|
23
|
+
If you don’t provide a session ID, you’ll be prompted to select from available sessions.
|
|
24
|
+
|
|
25
|
+
## Flags
|
|
26
|
+
- `--sanitize` : Redact sensitive transcript/file data
|
|
27
|
+
|
|
28
|
+
# import
|
|
29
|
+
Import session data from a JSON file or share URL.
|
|
30
|
+
```
|
|
31
|
+
opencode import <file>
|
|
32
|
+
|
|
33
|
+
// local file
|
|
34
|
+
opencode import session.json
|
|
35
|
+
|
|
36
|
+
// share url
|
|
37
|
+
opencode import https://opncd.ai/s/abc123
|
|
38
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# web
|
|
2
|
+
Start a headless OpenCode server with a web interface.
|
|
3
|
+
```
|
|
4
|
+
opencode web
|
|
5
|
+
```
|
|
6
|
+
This starts an HTTP server and opens a web browser to access OpenCode through a web interface.
|
|
7
|
+
|
|
8
|
+
Set `OPENCODE_SERVER_PASSWORD` to enable HTTP basic auth (username defaults to `opencode`).
|
|
9
|
+
|
|
10
|
+
## Flags
|
|
11
|
+
- `--port` : Port to listen on
|
|
12
|
+
- `--hostname` : Hostname to listen on
|
|
13
|
+
- `--mdns`
|
|
14
|
+
- `--mdns-domain`
|
|
15
|
+
- `--cors`
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Environment variables
|
|
2
|
+
OpenCode can be configured using environment variables.
|
|
3
|
+
|
|
4
|
+
## path
|
|
5
|
+
- `OPENCODE_GIT_BASH_PATH` : `string` Path to git bash executable on Windows
|
|
6
|
+
- `OPENCODE_TUI_CONFIG` : `string` Path to TUI config file
|
|
7
|
+
- `OPENCODE_CONFIG` : `string` Path to config file
|
|
8
|
+
- `OPENCODE_CONFIG_DIR` : `string` Path to config directory
|
|
9
|
+
- `OPENCODE_MODELS_URL` : `string` Custom URL for fetching models configuration
|
|
10
|
+
|
|
11
|
+
设置`OPENCODE_CONFIG`的会与全局`~/.config/opencode`合并。
|
|
12
|
+
|
|
13
|
+
## config
|
|
14
|
+
- `OPENCODE_CONFIG_CONTENT` : `string` Inline json config content
|
|
15
|
+
- `OPENCODE_PERMISSION` : `string` Inline json permission config
|
|
16
|
+
|
|
17
|
+
## session
|
|
18
|
+
- `OPENCODE_AUTO_SHARE` : `boolean` Automatically share sessions
|
|
19
|
+
|
|
20
|
+
## server
|
|
21
|
+
- `OPENCODE_SERVER_PASSWORD` : `string` Enable basic auth for serve/web
|
|
22
|
+
- `OPENCODE_SERVER_USERNAME` : `string` Override basic auth username (default opencode)
|
|
23
|
+
|
|
24
|
+
## enable
|
|
25
|
+
- `OPENCODE_ENABLE_EXPERIMENTAL_MODELS` : `boolean` Enable experimental models
|
|
26
|
+
- `OPENCODE_ENABLE_EXA` : `boolean` Enable Exa web search tools
|
|
27
|
+
|
|
28
|
+
## disable
|
|
29
|
+
- `OPENCODE_DISABLE_AUTOUPDATE` : `boolean` Disable automatic udpate checks
|
|
30
|
+
- `OPENCODE_DISABLE_PRUNE` : `boolean` Disable pruning of old data
|
|
31
|
+
- `OPENCODE_DISABLE_TERMINAL_TITLE` : `boolean` Disable automatic terminal title updates
|
|
32
|
+
- `OPENCODE_DISABLE_DEFAULT_PLUGINS` : `boolean` Disable default plugins
|
|
33
|
+
- `OPENCODE_DISABLE_LSP_DOWNLOAD` : `boolean` Disable automatic LSP server downloads
|
|
34
|
+
- `OPENCODE_DISABLE_AUTOCOMPACT` : `boolean` Disable automatic context compaction
|
|
35
|
+
- `OPENCODE_DISABLE_CLAUDE_CODE` : `boolean` Disable reading from `.claude` (prompt + skills)
|
|
36
|
+
- `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` : `boolean` Disable reading `~/.claude/CLAUDE.md`
|
|
37
|
+
- `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` : `boolean` Disable loading `.claude/skills`
|
|
38
|
+
- `OPENCODE_DISABLE_MODELS_FETCH` : `boolean` Disable fetching models from remote sources
|
|
39
|
+
- `OPENCODE_DISABLE_MOUSE` : `boolean` Disable mouse capture in the TUI
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CLI
|
|
2
|
+
OpenCode CLI options and commands.
|
|
3
|
+
|
|
4
|
+
The OpenCode CLI by default starts the TUI when run without any arguments.
|
|
5
|
+
```
|
|
6
|
+
opencode
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
But it also accepts commands as documented on this page. This allows you to interact with OpenCode programmatically.
|
|
10
|
+
```
|
|
11
|
+
opencode run "Explain how closures work in JavaScript"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Global Flags
|
|
15
|
+
- `--help` `-h` : Display help
|
|
16
|
+
- `--version` `-v` : Print version number
|
|
17
|
+
- `--print-logs` : Print logs to stderr
|
|
18
|
+
- `--log-level` : Log Level, DEBUG,INFO,WARN,ERROR
|
|
19
|
+
- `--pure` : Run without external plugins
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# TUI
|
|
2
|
+
The OpenCode CLI by default starts the TUI when run without any arguments.
|
|
3
|
+
```
|
|
4
|
+
opencode
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## Flags
|
|
8
|
+
- `--continue` `-c` : Continue the last session
|
|
9
|
+
- `--session` `-s` : Session ID to continue
|
|
10
|
+
- `--model` `-m` : Model to use in the form of `provider/model`
|
|
11
|
+
- `--agent` : Agent to use
|
|
12
|
+
- `--auto` : Auto-approve permissions that are not explicitly denied
|
|
13
|
+
|
|
14
|
+
### --auto
|
|
15
|
+
结合 opencode.json 中的 permission 配置理解:
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"permission": {
|
|
19
|
+
"skill": { "*": "allow" }, // 技能调用:全部允许
|
|
20
|
+
"agent": { "*": "allow" }, // Agent 调用:全部允许
|
|
21
|
+
"command": { "*": "deny" } // 命令执行:拒绝
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
- permission 中设为 "allow" 的 → 始终自动批准
|
|
26
|
+
- permission 中设为 "deny" 的 → 始终拒绝
|
|
27
|
+
- 未在 permission 中配置的 → 默认需手动确认,但 --auto 会将其自动批准
|
|
28
|
+
简单说:--auto = 免确认模式,适合自动化流水线或信任当前操作环境的场景。
|
|
29
|
+
|
|
30
|
+
### web服务配置
|
|
31
|
+
- `--hostname 0.0.0.0` : Hostname to listen on,默认`localhost`仅本机可访问
|
|
32
|
+
- `--port 8081` : Port to listen on, 默认`3000`
|
|
33
|
+
- `--mdns` : 启动 mDNS 局域网,默认关闭
|
|
34
|
+
- `--mdns-domain opencode.local` : 自定义mDNS域名
|
|
35
|
+
- `--cors http://myapp.com` : 允许跨域浏览器来源,,默认仅本机
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 命令示例
|
|
2
|
+
|
|
3
|
+
## review — 代码审查
|
|
4
|
+
|
|
5
|
+
位置:`.opencode/command/review.md`,执行:`/review src/main.ts`
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
---
|
|
9
|
+
description: 审查指定文件的代码质量
|
|
10
|
+
agent: plan
|
|
11
|
+
---
|
|
12
|
+
@$1
|
|
13
|
+
请审查这个文件的代码质量,重点关注:
|
|
14
|
+
1. 代码规范和命名
|
|
15
|
+
2. 潜在 Bug
|
|
16
|
+
3. 性能问题
|
|
17
|
+
4. 可维护性
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## commit — 生成提交消息
|
|
21
|
+
|
|
22
|
+
```md
|
|
23
|
+
---
|
|
24
|
+
description: 根据变更生成 Commit 消息
|
|
25
|
+
---
|
|
26
|
+
根据以下变更生成 commit 消息:
|
|
27
|
+
!`git diff --staged`
|
|
28
|
+
要求:
|
|
29
|
+
- 遵循 Conventional Commits 规范
|
|
30
|
+
- 简洁明了,说明"为什么"而非"做了什么"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## translate — 翻译为中文
|
|
34
|
+
|
|
35
|
+
```md
|
|
36
|
+
---
|
|
37
|
+
description: 翻译为中文
|
|
38
|
+
subtask: true
|
|
39
|
+
---
|
|
40
|
+
请将以下内容翻译为中文:
|
|
41
|
+
$ARGUMENTS
|
|
42
|
+
```
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# 命令(Commands)
|
|
2
|
+
|
|
3
|
+
自定义命令让你在 TUI 中执行预设的提示词:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
/my-command
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
可以通过 OpenCode 配置或在 `commands/` 目录创建 Markdown 文件添加自定义命令。
|
|
10
|
+
|
|
11
|
+
## 创建命令文件
|
|
12
|
+
|
|
13
|
+
在 `commands/` 目录创建 Markdown 文件:
|
|
14
|
+
|
|
15
|
+
- 全局:`~/.config/opencode/commands/`
|
|
16
|
+
- 项目级:`.opencode/commands/`
|
|
17
|
+
|
|
18
|
+
```md
|
|
19
|
+
---
|
|
20
|
+
description: Run tests with coverage
|
|
21
|
+
agent: build
|
|
22
|
+
model: anthropic/claude-3-5-sonnet-20241022
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Run the full test suite with coverage report and show any failures.
|
|
26
|
+
Focus on the failing tests and suggest fixes.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Frontmatter 定义命令属性,正文内容成为模板。
|
|
30
|
+
|
|
31
|
+
使用命令:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
/test
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 提示词配置
|
|
38
|
+
|
|
39
|
+
### 参数传递
|
|
40
|
+
|
|
41
|
+
使用 `$ARGUMENTS` 占位符传递参数:
|
|
42
|
+
|
|
43
|
+
```md
|
|
44
|
+
---
|
|
45
|
+
description: Create a new component
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
Create a new React component named $ARGUMENTS with TypeScript support.
|
|
49
|
+
Include proper typing and basic structure.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
运行:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
/component Button
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
使用位置参数:
|
|
59
|
+
|
|
60
|
+
- `$1`:第一个参数
|
|
61
|
+
- `$2`:第二个参数
|
|
62
|
+
- 以此类推
|
|
63
|
+
|
|
64
|
+
```md
|
|
65
|
+
---
|
|
66
|
+
description: Create a new file with content
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
Create a file named $1 in the directory $2
|
|
70
|
+
with the following content: $3
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
运行:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
/create-file config.json src "{ \"key\": \"value\" }"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Shell 输出
|
|
80
|
+
|
|
81
|
+
使用 `` !`command` `` 注入 bash 命令输出:
|
|
82
|
+
|
|
83
|
+
```md
|
|
84
|
+
---
|
|
85
|
+
description: Analyze test coverage
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
Here are the current test results:
|
|
89
|
+
!`npm test`
|
|
90
|
+
|
|
91
|
+
Based on these results, suggest improvements to increase coverage.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 文件引用
|
|
95
|
+
|
|
96
|
+
使用 `@` 引用文件:
|
|
97
|
+
|
|
98
|
+
```md
|
|
99
|
+
---
|
|
100
|
+
description: Review component
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
Review the component in @src/components/Button.tsx.
|
|
104
|
+
Check for performance issues and suggest improvements.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 配置选项
|
|
108
|
+
|
|
109
|
+
### Template(必需)
|
|
110
|
+
|
|
111
|
+
定义命令执行时发送给 LLM 的提示词:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"command": {
|
|
116
|
+
"test": {
|
|
117
|
+
"template": "Run the full test suite with coverage report and show any failures.\nFocus on the failing tests and suggest fixes."
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Description
|
|
124
|
+
|
|
125
|
+
命令的简要描述,在 TUI 中输入命令时显示:
|
|
126
|
+
|
|
127
|
+
```jsonc
|
|
128
|
+
{
|
|
129
|
+
"command": {
|
|
130
|
+
"test": {
|
|
131
|
+
"description": "Run tests with coverage"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Agent
|
|
138
|
+
|
|
139
|
+
指定执行此命令的 Agent(可选,默认为当前 Agent):
|
|
140
|
+
|
|
141
|
+
```jsonc
|
|
142
|
+
{
|
|
143
|
+
"command": {
|
|
144
|
+
"review": {
|
|
145
|
+
"agent": "plan"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Subtask
|
|
152
|
+
|
|
153
|
+
强制命令触发子代理调用:
|
|
154
|
+
|
|
155
|
+
```jsonc
|
|
156
|
+
{
|
|
157
|
+
"command": {
|
|
158
|
+
"analyze": {
|
|
159
|
+
"subtask": true
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Model
|
|
166
|
+
|
|
167
|
+
覆盖命令的默认模型:
|
|
168
|
+
|
|
169
|
+
```jsonc
|
|
170
|
+
{
|
|
171
|
+
"command": {
|
|
172
|
+
"analyze": {
|
|
173
|
+
"model": "anthropic/claude-3-5-sonnet-20241022"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 内置命令
|
|
180
|
+
|
|
181
|
+
OpenCode 包含以下内置命令:`/init`、`/undo`、`/redo`、`/share`、`/help`。
|
|
182
|
+
|
|
183
|
+
## 更多内容
|
|
184
|
+
|
|
185
|
+
- [命令示例](/commands/examples) — 实用命令示例
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Providers
|
|
2
|
+
To add a provider you need to:
|
|
3
|
+
- Add the API keys for the provider using the `/connect` command.
|
|
4
|
+
- Configure the provider in your OpenCode config.
|
|
5
|
+
|
|
6
|
+
## Credentials
|
|
7
|
+
When you add a provider’s API keys with the `/connect` command, they are stored in `~/.local/share/opencode/auth.json`.
|
|
8
|
+
|
|
9
|
+
## Config
|
|
10
|
+
You can customize the providers through the provider section in your OpenCode config.
|
|
11
|
+
|
|
12
|
+
### Base URL
|
|
13
|
+
You can customize the base URL for any provider by setting the baseURL option.
|
|
14
|
+
- This is useful when using proxy services or custom endpoints.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"$schema": "https://opencode.ai/config.json",
|
|
19
|
+
"provider": {
|
|
20
|
+
"anthropic": {
|
|
21
|
+
"options": {
|
|
22
|
+
"baseURL": "https://api.anthropic.com/v1"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Hiding models
|
|
30
|
+
Both options take an array of model IDs — the same IDs shown in the `/models` picker.
|
|
31
|
+
- `blacklist` removes the listed models from the picker.
|
|
32
|
+
- `whitelist` keeps only the listed models and hides the rest.
|
|
33
|
+
|
|
34
|
+
You can combine them: whitelist narrows the set, then blacklist removes entries from it.
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"$schema": "https://opencode.ai/config.json",
|
|
38
|
+
"provider": {
|
|
39
|
+
"anthropic": {
|
|
40
|
+
"blacklist": ["claude-opus-4-20250514"],
|
|
41
|
+
"whitelist": ["claude-sonnet-4-20250514"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## OpenCode Zen
|
|
48
|
+
OpenCode Zen is a list of models provided by the OpenCode team that have been tested and verified to work well with OpenCode.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Run the /connect command in the TUI, select OpenCode Zen, and head to opencode.ai/auth.
|
|
52
|
+
```
|
|
53
|
+
/connect
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Run /models in the TUI to see the list of models we recommend.
|
|
57
|
+
```
|
|
58
|
+
/models
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## OpenCode Go
|
|
62
|
+
OpenCode Go is a low cost subscription plan that provides reliable access to popular open coding models provided by the OpenCode team that have been tested and verified to work well with OpenCode.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## Custom provider
|
|
66
|
+
To add any OpenAI-compatible provider that’s not listed in the /connect command.
|
|
67
|
+
|
|
68
|
+
Create or update your opencode.json file in your project directory:
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"$schema": "https://opencode.ai/config.json",
|
|
72
|
+
"provider": {
|
|
73
|
+
"myprovider": {
|
|
74
|
+
"npm": "@ai-sdk/openai-compatible",
|
|
75
|
+
"name": "My AI ProviderDisplay Name",
|
|
76
|
+
"options": {
|
|
77
|
+
"baseURL": "https://api.myprovider.com/v1"
|
|
78
|
+
},
|
|
79
|
+
"models": {
|
|
80
|
+
"my-model-name": {
|
|
81
|
+
"name": "My Model Display Name"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Configuration options:
|
|
90
|
+
- npm: AI SDK package to use:
|
|
91
|
+
- `@ai-sdk/openai-compatible` for OpenAI-compatible providers (for `/v1/chat/completions`).
|
|
92
|
+
- `@ai-sdk/openai` for `/v1/responses`
|
|
93
|
+
- name: Display name in UI.
|
|
94
|
+
- models: Available models.
|
|
95
|
+
- options.baseURL: API endpoint URL.
|
|
96
|
+
- options.apiKey: Optionally set the API key, if not using auth.
|
|
97
|
+
- support `env` variable syntax
|
|
98
|
+
- options.headers: Optionally set custom headers.
|
|
99
|
+
- limit.context: Maximum input tokens the model accepts.
|
|
100
|
+
- limit.output: Maximum tokens the model can generate.
|
|
101
|
+
|
|
102
|
+
### Demo 1:
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"$schema": "https://opencode.ai/config.json",
|
|
106
|
+
"provider": {
|
|
107
|
+
"llmproxy": {
|
|
108
|
+
"npm": "@ai-sdk/openai-compatible",
|
|
109
|
+
"name": "llmproxy",
|
|
110
|
+
"options": {
|
|
111
|
+
"baseURL": "http://127.0.0.1:31943/v1",
|
|
112
|
+
"apiKey": "sk-123",
|
|
113
|
+
"headers":{}
|
|
114
|
+
},
|
|
115
|
+
"models": {
|
|
116
|
+
"MiniMax-M2.7": {
|
|
117
|
+
"name": "MiniMax-M2.7"
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Demo 2:
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"$schema": "https://opencode.ai/config.json",
|
|
129
|
+
"provider": {
|
|
130
|
+
"myprovider": {
|
|
131
|
+
"npm": "@ai-sdk/openai-compatible",
|
|
132
|
+
"name": "My AI ProviderDisplay Name",
|
|
133
|
+
"options": {
|
|
134
|
+
"baseURL": "https://api.myprovider.com/v1",
|
|
135
|
+
"apiKey": "{env:ANTHROPIC_API_KEY}",
|
|
136
|
+
"headers": {
|
|
137
|
+
"Authorization": "Bearer custom-token"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"models": {
|
|
141
|
+
"my-model-name": {
|
|
142
|
+
"name": "My Model Display Name",
|
|
143
|
+
"limit": {
|
|
144
|
+
"context": 200000,
|
|
145
|
+
"output": 65536
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|