@wwkit/harness 1.0.33 → 1.0.34
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/LICENSE +21 -21
- package/README.md +128 -128
- package/agents/scrum.md +206 -186
- package/agents/sprint.md +130 -121
- package/bin/index.js +291 -226
- package/commands/fix.md +87 -87
- package/commands/git-sync.md +217 -217
- package/commands/net-port.md +364 -364
- package/commands/pytest.md +10 -10
- package/commands/resume.md +104 -104
- package/commands/tl.md +11 -11
- package/commands/tsl.md +12 -0
- package/package.json +5 -4
- package/plugin.js +19 -19
- package/readme/development.md +39 -39
- package/readme/publish.md +41 -41
- package/readme/testing.md +44 -44
- package/scripts/postinstall.js +58 -58
- package/skills/better-skill/SKILL.md +192 -124
- package/skills/blame-skill/SKILL.md +148 -201
- package/skills/blame-skill/references/scoring-rules.md +190 -0
- package/skills/blame-sprint-agent/SKILL.md +167 -0
- package/skills/blame-sprint-agent/references/scoring-rules.md +113 -0
- package/skills/blame-sprint-skill/SKILL.md +154 -0
- package/skills/blame-sprint-skill/references/scoring-rules.md +101 -0
- package/skills/extract/SKILL.md +119 -119
- package/skills/extract/references/build-xpath.js +30 -30
- package/skills/extract/references/clean-html.js +90 -90
- package/skills/extract/references/detail.md +54 -54
- package/skills/extract/references/detail.schema.json5 +48 -48
- package/skills/extract/references/extract-detail.js +71 -71
- package/skills/extract/references/extract-regex.js +81 -81
- package/skills/extract/references/extract-sample.js +48 -48
- package/skills/extract/references/list-rule-gen.md +109 -109
- package/skills/extract/references/list.md +134 -134
- package/skills/extract/references/list.schema.json5 +33 -33
- package/skills/extract/references/navi.md +44 -44
- package/skills/extract/references/navi.schema.json5 +23 -23
- package/skills/extract/references/text.md +40 -40
- package/skills/extract/references/text.schema.json5 +21 -21
- package/skills/extract/references/to-text.js +20 -20
- package/skills/extract/references/validate-schema.js +39 -39
- package/skills/jstest/SKILL.md +561 -561
- package/skills/jstest/references/case-create.md +327 -327
- package/skills/jstest/references/case-fix.md +273 -273
- package/skills/jstest/references/config.md +148 -148
- package/skills/jstest/references/coverage-analyze.md +247 -247
- package/skills/jstest/references/env-ensure.md +210 -210
- package/skills/jstest/references/execute.md +168 -168
- package/skills/jstest/references/sample.md +166 -166
- package/skills/jstest/references/scoring-rules.md +75 -75
- package/skills/jstest/references/src/jstest-sample/Calculator.js +80 -80
- package/skills/jstest/references/src/jstest-sample/ConfigManager.js +72 -72
- package/skills/jstest/references/src/jstest-sample/FileProcessor.js +57 -57
- package/skills/jstest/references/src/jstest-sample/OrderService.js +98 -98
- package/skills/jstest/references/src/jstest-sample/TokenGenerator.js +60 -60
- package/skills/jstest/references/src/jstest-sample/UserService.js +56 -56
- package/skills/jstest/references/src/jstest-sample/index.js +6 -6
- package/skills/jstest/references/suitability-check.md +232 -232
- package/skills/jstest/references/test-standards.md +288 -288
- package/skills/lint/SKILL.md +440 -440
- package/skills/lint/references/ai-fix.md +137 -137
- package/skills/lint/references/config-setup.md +102 -102
- package/skills/lint/references/config.md +65 -65
- package/skills/lint/references/detect-language.js +65 -65
- package/skills/lint/references/env-ensure.md +88 -88
- package/skills/lint/references/language-detect.md +75 -75
- package/skills/lint/references/languages/js.md +110 -110
- package/skills/lint/references/languages/py.md +89 -89
- package/skills/lint/references/rules-analyze.md +125 -125
- package/skills/lint/references/suitability-check.md +81 -81
- package/skills/lint/references/tool-fix.md +90 -90
- package/skills/new-skill/SKILL.md +193 -227
- package/skills/pytest/SKILL.md +555 -555
- package/skills/pytest/references/case-create.md +324 -324
- package/skills/pytest/references/case-fix.md +271 -271
- package/skills/pytest/references/config.md +145 -145
- package/skills/pytest/references/coverage-analyze.md +223 -223
- package/skills/pytest/references/env-ensure.md +195 -195
- package/skills/pytest/references/execute.md +152 -152
- package/skills/pytest/references/sample.md +159 -159
- package/skills/pytest/references/scoring-rules.md +57 -57
- package/skills/pytest/references/src/pytest-sample/Calculator.py +67 -67
- package/skills/pytest/references/src/pytest-sample/ConfigManager.py +68 -68
- package/skills/pytest/references/src/pytest-sample/FileProcessor.py +53 -53
- package/skills/pytest/references/src/pytest-sample/OrderService.py +82 -82
- package/skills/pytest/references/src/pytest-sample/TokenGenerator.py +50 -50
- package/skills/pytest/references/src/pytest-sample/UserService.py +45 -45
- package/skills/pytest/references/suitability-check.md +220 -220
- package/skills/pytest/references/test-standards.md +244 -244
- package/skills/query/SKILL.md +71 -71
- package/skills/read-docs/SKILL.md +134 -134
- package/skills/read-docs/references/opencode/agents/cases.md +206 -206
- package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -47
- package/skills/read-docs/references/opencode/agents/detail.md +191 -191
- package/skills/read-docs/references/opencode/agents/examples.md +100 -100
- package/skills/read-docs/references/opencode/agents/index.md +309 -309
- package/skills/read-docs/references/opencode/agents/parallel-dispatch.md +149 -149
- package/skills/read-docs/references/opencode/agents/subagent-internals.md +217 -217
- package/skills/read-docs/references/opencode/agents/workflow.md +161 -161
- package/skills/read-docs/references/opencode/cli/commands/acp.md +31 -31
- package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -16
- package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -20
- package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -37
- package/skills/read-docs/references/opencode/cli/commands/others.md +48 -48
- package/skills/read-docs/references/opencode/cli/commands/plugin.md +12 -12
- package/skills/read-docs/references/opencode/cli/commands/provider.md +43 -43
- package/skills/read-docs/references/opencode/cli/commands/run.md +81 -81
- package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -84
- package/skills/read-docs/references/opencode/cli/commands/session.md +37 -37
- package/skills/read-docs/references/opencode/cli/commands/web.md +14 -14
- package/skills/read-docs/references/opencode/cli/env.md +38 -38
- package/skills/read-docs/references/opencode/cli/index.md +18 -18
- package/skills/read-docs/references/opencode/cli/tui.md +35 -35
- package/skills/read-docs/references/opencode/commands/examples.md +42 -42
- package/skills/read-docs/references/opencode/commands/index.md +185 -185
- package/skills/read-docs/references/opencode/config/provider.md +151 -151
- package/skills/read-docs/references/opencode/formatter/index.md +70 -70
- package/skills/read-docs/references/opencode/guide/config.md +419 -419
- package/skills/read-docs/references/opencode/guide/formatters.md +70 -70
- package/skills/read-docs/references/opencode/guide/index.md +37 -37
- package/skills/read-docs/references/opencode/guide/providers.md +31 -31
- package/skills/read-docs/references/opencode/guide/rules.md +63 -63
- package/skills/read-docs/references/opencode/plugins/examples.md +75 -75
- package/skills/read-docs/references/opencode/plugins/index.md +188 -188
- package/skills/read-docs/references/opencode/reference/index.md +118 -118
- package/skills/read-docs/references/opencode/rule/index.md +77 -77
- package/skills/read-docs/references/opencode/skills/detail.md +113 -113
- package/skills/read-docs/references/opencode/skills/examples.md +141 -141
- package/skills/read-docs/references/opencode/skills/index.md +126 -126
- package/skills/read-docs/references/opencode/skills/workflow.md +146 -146
- package/skills/read-docs/references/opencode/tests/agent.md +9 -9
- package/skills/read-docs/references/opencode/tests/config.md +59 -59
- package/skills/read-docs/references/opencode/tests/file.md +11 -11
- package/skills/read-docs/references/opencode/tests/serve.md +17 -17
- package/skills/read-docs/references/opencode/tests/session.md +30 -30
- package/skills/read-docs/references/opencode/tests/web.md +16 -16
- package/skills/read-docs/references/opencode/tools/arguments.md +305 -305
- package/skills/read-docs/references/opencode/tools/context.md +17 -17
- package/skills/read-docs/references/opencode/tools/custom.md +110 -110
- package/skills/read-docs/references/opencode/tools/detail.md +104 -104
- package/skills/read-docs/references/opencode/tools/examples.md +71 -71
- package/skills/read-docs/references/opencode/tools/index.md +56 -56
- package/skills/read-docs/references/opencode/tools/lsp.md +25 -25
- package/skills/read-docs/references/opencode/tools/mcp.md +132 -132
- package/skills/read-docs/references/opencode/train/README.md +134 -134
- package/skills/read-docs/references/opencode/train/agent-basic.md +771 -771
- package/skills/read-docs/references/opencode/train/command-basic.md +667 -667
- package/skills/read-docs/references/opencode/train/config-basic.md +508 -508
- package/skills/read-docs/references/opencode/train/index.md +163 -163
- package/skills/read-docs/references/opencode/train/practice.md +872 -872
- package/skills/read-docs/references/opencode/train/skill-basic.md +607 -607
- package/skills/read-docs/references/opencode/tui/commands/config.md +31 -31
- package/skills/read-docs/references/opencode/tui/commands/editor.md +46 -46
- package/skills/read-docs/references/opencode/tui/commands/index.md +124 -124
- package/skills/read-docs/references/opencode/tui/commands/init.md +4 -4
- package/skills/read-docs/references/opencode/tui/index.md +26 -26
- package/skills/read-docs/references/superpowers/bootstrap.md +107 -107
- package/skills/read-docs/references/superpowers/comparison.md +77 -77
- package/skills/read-docs/references/superpowers/context.md +71 -71
- package/skills/read-docs/references/superpowers/index.md +58 -58
- package/skills/read-docs/references/superpowers/parallel.md +49 -49
- package/skills/read-docs/references/superpowers/sdd.md +183 -183
- package/skills/read-docs/references/superpowers/skills.md +68 -68
- package/skills/read-docs/references/superpowers/workflow.md +83 -83
- package/skills/revise/SKILL.md +121 -121
- package/skills/revise/references/article.md +36 -36
- package/skills/revise/references/article.schema.json5 +40 -40
- package/skills/revise/references/gallery.md +34 -34
- package/skills/revise/references/gallery.schema.json5 +40 -40
- package/skills/revise/references/question.md +32 -32
- package/skills/revise/references/question.schema.json5 +31 -31
- package/skills/revise/references/status.md +31 -31
- package/skills/revise/references/status.schema.json5 +27 -27
- package/skills/revise/references/validate-schema.js +39 -39
- package/skills/step-extract/SKILL.md +205 -0
- package/skills/tsl/SKILL.md +393 -0
- package/skills/tsl/package.json +10 -0
- package/skills/tsl/references/global-review-rules.md +25 -0
- package/skills/tsl/references/prepare-prompt.md +150 -0
- package/skills/tsl/references/terminology-rules.md +93 -0
- package/skills/tsl/references/translation-guide.md +23 -0
- package/skills/tsl/references/translation-prompt.md +115 -0
- package/skills/tsl/references/translation-rules.md +48 -0
- package/skills/tsl/references/verification-rules.md +58 -0
- package/skills/tsl/scripts/check-boundaries.js +140 -0
- package/skills/tsl/scripts/chunk-text.js +144 -0
- package/skills/tsl/scripts/clean-text.js +121 -0
- package/skills/tsl/scripts/cleanup-glossary.js +160 -0
- package/skills/tsl/scripts/extract-pdf.js +94 -0
- package/skills/tsl/scripts/generate-review.js +179 -0
- package/skills/tsl/scripts/merge-result.js +164 -0
- package/skills/tsl/scripts/verify-chunk.js +170 -0
- package/skills/tsl-format/SKILL.md +298 -0
- package/skills/tsl-format/references/format-prompt.md +103 -0
- package/skills/tsl-format/references/format-rules.md +58 -0
- package/skills/tsl-format/scripts/chunk-bilingual.js +96 -0
- package/skills/tsl-format/scripts/merge-format.js +105 -0
- package/src/config.js +29 -29
- package/src/config.json5 +19 -19
- package/skills/new-skill/references/template.md +0 -53
- package/skills/new-skill/references/workflow-patterns.md +0 -104
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
# 插件(Plugins)
|
|
2
|
-
|
|
3
|
-
插件通过钩入各种事件和自定义行为来扩展 OpenCode。
|
|
4
|
-
|
|
5
|
-
## 使用插件
|
|
6
|
-
|
|
7
|
-
### 从本地文件加载
|
|
8
|
-
|
|
9
|
-
将 JavaScript 或 TypeScript 文件放在插件目录:
|
|
10
|
-
|
|
11
|
-
- `.opencode/plugins/` — 项目级插件
|
|
12
|
-
- `~/.config/opencode/plugins/` — 全局插件
|
|
13
|
-
|
|
14
|
-
这些目录中的文件在启动时自动加载。
|
|
15
|
-
|
|
16
|
-
### 从 npm 加载
|
|
17
|
-
|
|
18
|
-
在配置文件中指定 npm 包:
|
|
19
|
-
|
|
20
|
-
```json
|
|
21
|
-
{
|
|
22
|
-
"$schema": "https://opencode.ai/config.json",
|
|
23
|
-
"plugin": ["opencode-helicone-session", "opencode-wakatime", "@my-org/custom-plugin"]
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
npm 插件使用 Bun 在启动时自动安装,包及其依赖缓存在 `~/.cache/opencode/node_modules/`。
|
|
28
|
-
|
|
29
|
-
### 加载顺序
|
|
30
|
-
|
|
31
|
-
插件从所有来源加载,所有钩子按顺序运行:
|
|
32
|
-
|
|
33
|
-
1. 全局配置(`~/.config/opencode/opencode.json`)
|
|
34
|
-
2. 项目配置(`opencode.json`)
|
|
35
|
-
3. 全局插件目录(`~/.config/opencode/plugins/`)
|
|
36
|
-
4. 项目插件目录(`.opencode/plugins/`)
|
|
37
|
-
|
|
38
|
-
同名同版本的 npm 包只加载一次,但本地插件和 npm 插件即使名称相似也会分别加载。
|
|
39
|
-
|
|
40
|
-
## 创建插件
|
|
41
|
-
|
|
42
|
-
插件是导出一个或多个插件函数的 JavaScript/TypeScript 模块。每个函数接收上下文对象并返回钩子对象。
|
|
43
|
-
|
|
44
|
-
### 基本结构
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
export const MyPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
48
|
-
console.log("Plugin initialized!")
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
// Hook implementations go here
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
插件函数接收的参数:
|
|
57
|
-
|
|
58
|
-
| 参数 | 说明 |
|
|
59
|
-
|------|------|
|
|
60
|
-
| project | 当前项目信息 |
|
|
61
|
-
| directory | 当前工作目录 |
|
|
62
|
-
| worktree | Git 工作树路径 |
|
|
63
|
-
| client | OpenCode SDK 客户端 |
|
|
64
|
-
| $ | Bun 的 Shell API |
|
|
65
|
-
|
|
66
|
-
### 依赖管理
|
|
67
|
-
|
|
68
|
-
本地插件和自定义工具可以使用外部 npm 包,在配置目录添加 `package.json`:
|
|
69
|
-
|
|
70
|
-
```jsonc
|
|
71
|
-
// .opencode/package.json
|
|
72
|
-
{
|
|
73
|
-
"dependencies": {
|
|
74
|
-
"shescape": "^2.1.0"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
OpenCode 启动时自动运行 `bun install` 安装依赖:
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
// .opencode/plugins/my-plugin.ts
|
|
83
|
-
import { escape } from "shescape"
|
|
84
|
-
|
|
85
|
-
export const MyPlugin = async (ctx) => {
|
|
86
|
-
return {
|
|
87
|
-
"tool.execute.before": async (input, output) => {
|
|
88
|
-
if (input.tool === "bash") {
|
|
89
|
-
output.args.command = escape(output.args.command)
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## 事件列表
|
|
97
|
-
|
|
98
|
-
### 命令事件
|
|
99
|
-
|
|
100
|
-
| 事件 | 说明 |
|
|
101
|
-
|------|------|
|
|
102
|
-
| `command.executed` | 命令执行 |
|
|
103
|
-
|
|
104
|
-
### 文件事件
|
|
105
|
-
|
|
106
|
-
| 事件 | 说明 |
|
|
107
|
-
|------|------|
|
|
108
|
-
| `file.edited` | 文件编辑 |
|
|
109
|
-
| `file.watcher.updated` | 文件监视器更新 |
|
|
110
|
-
|
|
111
|
-
### 安装事件
|
|
112
|
-
|
|
113
|
-
| 事件 | 说明 |
|
|
114
|
-
|------|------|
|
|
115
|
-
| `installation.updated` | 安装更新 |
|
|
116
|
-
|
|
117
|
-
### LSP 事件
|
|
118
|
-
|
|
119
|
-
| 事件 | 说明 |
|
|
120
|
-
|------|------|
|
|
121
|
-
| `lsp.client.diagnostics` | LSP 诊断 |
|
|
122
|
-
| `lsp.updated` | LSP 更新 |
|
|
123
|
-
|
|
124
|
-
### 消息事件
|
|
125
|
-
|
|
126
|
-
| 事件 | 说明 |
|
|
127
|
-
|------|------|
|
|
128
|
-
| `message.part.removed` | 消息部分移除 |
|
|
129
|
-
| `message.part.updated` | 消息部分更新 |
|
|
130
|
-
| `message.removed` | 消息移除 |
|
|
131
|
-
| `message.updated` | 消息更新 |
|
|
132
|
-
|
|
133
|
-
### 权限事件
|
|
134
|
-
|
|
135
|
-
| 事件 | 说明 |
|
|
136
|
-
|------|------|
|
|
137
|
-
| `permission.asked` | 权限请求 |
|
|
138
|
-
| `permission.replied` | 权限回复 |
|
|
139
|
-
|
|
140
|
-
### 服务器事件
|
|
141
|
-
|
|
142
|
-
| 事件 | 说明 |
|
|
143
|
-
|------|------|
|
|
144
|
-
| `server.connected` | 服务器连接 |
|
|
145
|
-
|
|
146
|
-
### 会话事件
|
|
147
|
-
|
|
148
|
-
| 事件 | 说明 |
|
|
149
|
-
|------|------|
|
|
150
|
-
| `session.created` | 会话创建 |
|
|
151
|
-
| `session.compacted` | 会话压缩 |
|
|
152
|
-
| `session.deleted` | 会话删除 |
|
|
153
|
-
| `session.diff` | 会话差异 |
|
|
154
|
-
| `session.error` | 会话错误 |
|
|
155
|
-
| `session.idle` | 会话空闲 |
|
|
156
|
-
| `session.status` | 会话状态 |
|
|
157
|
-
| `session.updated` | 会话更新 |
|
|
158
|
-
|
|
159
|
-
### Shell 事件
|
|
160
|
-
|
|
161
|
-
| 事件 | 说明 |
|
|
162
|
-
|------|------|
|
|
163
|
-
| `shell.env` | Shell 环境变量 |
|
|
164
|
-
|
|
165
|
-
### 工具事件
|
|
166
|
-
|
|
167
|
-
| 事件 | 说明 |
|
|
168
|
-
|------|------|
|
|
169
|
-
| `tool.execute.after` | 工具执行后 |
|
|
170
|
-
| `tool.execute.before` | 工具执行前 |
|
|
171
|
-
|
|
172
|
-
### TUI 事件
|
|
173
|
-
|
|
174
|
-
| 事件 | 说明 |
|
|
175
|
-
|------|------|
|
|
176
|
-
| `tui.prompt.append` | TUI 提示追加 |
|
|
177
|
-
| `tui.command.execute` | TUI 命令执行 |
|
|
178
|
-
| `tui.toast.show` | TUI 提示显示 |
|
|
179
|
-
|
|
180
|
-
### Todo 事件
|
|
181
|
-
|
|
182
|
-
| 事件 | 说明 |
|
|
183
|
-
|------|------|
|
|
184
|
-
| `todo.updated` | Todo 更新 |
|
|
185
|
-
|
|
186
|
-
## 更多内容
|
|
187
|
-
|
|
188
|
-
- [插件示例](/plugins/examples) — 通知、环境保护、自定义工具等示例
|
|
1
|
+
# 插件(Plugins)
|
|
2
|
+
|
|
3
|
+
插件通过钩入各种事件和自定义行为来扩展 OpenCode。
|
|
4
|
+
|
|
5
|
+
## 使用插件
|
|
6
|
+
|
|
7
|
+
### 从本地文件加载
|
|
8
|
+
|
|
9
|
+
将 JavaScript 或 TypeScript 文件放在插件目录:
|
|
10
|
+
|
|
11
|
+
- `.opencode/plugins/` — 项目级插件
|
|
12
|
+
- `~/.config/opencode/plugins/` — 全局插件
|
|
13
|
+
|
|
14
|
+
这些目录中的文件在启动时自动加载。
|
|
15
|
+
|
|
16
|
+
### 从 npm 加载
|
|
17
|
+
|
|
18
|
+
在配置文件中指定 npm 包:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"$schema": "https://opencode.ai/config.json",
|
|
23
|
+
"plugin": ["opencode-helicone-session", "opencode-wakatime", "@my-org/custom-plugin"]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
npm 插件使用 Bun 在启动时自动安装,包及其依赖缓存在 `~/.cache/opencode/node_modules/`。
|
|
28
|
+
|
|
29
|
+
### 加载顺序
|
|
30
|
+
|
|
31
|
+
插件从所有来源加载,所有钩子按顺序运行:
|
|
32
|
+
|
|
33
|
+
1. 全局配置(`~/.config/opencode/opencode.json`)
|
|
34
|
+
2. 项目配置(`opencode.json`)
|
|
35
|
+
3. 全局插件目录(`~/.config/opencode/plugins/`)
|
|
36
|
+
4. 项目插件目录(`.opencode/plugins/`)
|
|
37
|
+
|
|
38
|
+
同名同版本的 npm 包只加载一次,但本地插件和 npm 插件即使名称相似也会分别加载。
|
|
39
|
+
|
|
40
|
+
## 创建插件
|
|
41
|
+
|
|
42
|
+
插件是导出一个或多个插件函数的 JavaScript/TypeScript 模块。每个函数接收上下文对象并返回钩子对象。
|
|
43
|
+
|
|
44
|
+
### 基本结构
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
export const MyPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
48
|
+
console.log("Plugin initialized!")
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
// Hook implementations go here
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
插件函数接收的参数:
|
|
57
|
+
|
|
58
|
+
| 参数 | 说明 |
|
|
59
|
+
|------|------|
|
|
60
|
+
| project | 当前项目信息 |
|
|
61
|
+
| directory | 当前工作目录 |
|
|
62
|
+
| worktree | Git 工作树路径 |
|
|
63
|
+
| client | OpenCode SDK 客户端 |
|
|
64
|
+
| $ | Bun 的 Shell API |
|
|
65
|
+
|
|
66
|
+
### 依赖管理
|
|
67
|
+
|
|
68
|
+
本地插件和自定义工具可以使用外部 npm 包,在配置目录添加 `package.json`:
|
|
69
|
+
|
|
70
|
+
```jsonc
|
|
71
|
+
// .opencode/package.json
|
|
72
|
+
{
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"shescape": "^2.1.0"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
OpenCode 启动时自动运行 `bun install` 安装依赖:
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
// .opencode/plugins/my-plugin.ts
|
|
83
|
+
import { escape } from "shescape"
|
|
84
|
+
|
|
85
|
+
export const MyPlugin = async (ctx) => {
|
|
86
|
+
return {
|
|
87
|
+
"tool.execute.before": async (input, output) => {
|
|
88
|
+
if (input.tool === "bash") {
|
|
89
|
+
output.args.command = escape(output.args.command)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 事件列表
|
|
97
|
+
|
|
98
|
+
### 命令事件
|
|
99
|
+
|
|
100
|
+
| 事件 | 说明 |
|
|
101
|
+
|------|------|
|
|
102
|
+
| `command.executed` | 命令执行 |
|
|
103
|
+
|
|
104
|
+
### 文件事件
|
|
105
|
+
|
|
106
|
+
| 事件 | 说明 |
|
|
107
|
+
|------|------|
|
|
108
|
+
| `file.edited` | 文件编辑 |
|
|
109
|
+
| `file.watcher.updated` | 文件监视器更新 |
|
|
110
|
+
|
|
111
|
+
### 安装事件
|
|
112
|
+
|
|
113
|
+
| 事件 | 说明 |
|
|
114
|
+
|------|------|
|
|
115
|
+
| `installation.updated` | 安装更新 |
|
|
116
|
+
|
|
117
|
+
### LSP 事件
|
|
118
|
+
|
|
119
|
+
| 事件 | 说明 |
|
|
120
|
+
|------|------|
|
|
121
|
+
| `lsp.client.diagnostics` | LSP 诊断 |
|
|
122
|
+
| `lsp.updated` | LSP 更新 |
|
|
123
|
+
|
|
124
|
+
### 消息事件
|
|
125
|
+
|
|
126
|
+
| 事件 | 说明 |
|
|
127
|
+
|------|------|
|
|
128
|
+
| `message.part.removed` | 消息部分移除 |
|
|
129
|
+
| `message.part.updated` | 消息部分更新 |
|
|
130
|
+
| `message.removed` | 消息移除 |
|
|
131
|
+
| `message.updated` | 消息更新 |
|
|
132
|
+
|
|
133
|
+
### 权限事件
|
|
134
|
+
|
|
135
|
+
| 事件 | 说明 |
|
|
136
|
+
|------|------|
|
|
137
|
+
| `permission.asked` | 权限请求 |
|
|
138
|
+
| `permission.replied` | 权限回复 |
|
|
139
|
+
|
|
140
|
+
### 服务器事件
|
|
141
|
+
|
|
142
|
+
| 事件 | 说明 |
|
|
143
|
+
|------|------|
|
|
144
|
+
| `server.connected` | 服务器连接 |
|
|
145
|
+
|
|
146
|
+
### 会话事件
|
|
147
|
+
|
|
148
|
+
| 事件 | 说明 |
|
|
149
|
+
|------|------|
|
|
150
|
+
| `session.created` | 会话创建 |
|
|
151
|
+
| `session.compacted` | 会话压缩 |
|
|
152
|
+
| `session.deleted` | 会话删除 |
|
|
153
|
+
| `session.diff` | 会话差异 |
|
|
154
|
+
| `session.error` | 会话错误 |
|
|
155
|
+
| `session.idle` | 会话空闲 |
|
|
156
|
+
| `session.status` | 会话状态 |
|
|
157
|
+
| `session.updated` | 会话更新 |
|
|
158
|
+
|
|
159
|
+
### Shell 事件
|
|
160
|
+
|
|
161
|
+
| 事件 | 说明 |
|
|
162
|
+
|------|------|
|
|
163
|
+
| `shell.env` | Shell 环境变量 |
|
|
164
|
+
|
|
165
|
+
### 工具事件
|
|
166
|
+
|
|
167
|
+
| 事件 | 说明 |
|
|
168
|
+
|------|------|
|
|
169
|
+
| `tool.execute.after` | 工具执行后 |
|
|
170
|
+
| `tool.execute.before` | 工具执行前 |
|
|
171
|
+
|
|
172
|
+
### TUI 事件
|
|
173
|
+
|
|
174
|
+
| 事件 | 说明 |
|
|
175
|
+
|------|------|
|
|
176
|
+
| `tui.prompt.append` | TUI 提示追加 |
|
|
177
|
+
| `tui.command.execute` | TUI 命令执行 |
|
|
178
|
+
| `tui.toast.show` | TUI 提示显示 |
|
|
179
|
+
|
|
180
|
+
### Todo 事件
|
|
181
|
+
|
|
182
|
+
| 事件 | 说明 |
|
|
183
|
+
|------|------|
|
|
184
|
+
| `todo.updated` | Todo 更新 |
|
|
185
|
+
|
|
186
|
+
## 更多内容
|
|
187
|
+
|
|
188
|
+
- [插件示例](/plugins/examples) — 通知、环境保护、自定义工具等示例
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
# reference
|
|
2
|
-
Add local directories and Git repositories as project references.
|
|
3
|
-
|
|
4
|
-
References give OpenCode access to directories outside the current project.Use them to
|
|
5
|
-
- make documentation,
|
|
6
|
-
- shared libraries, examples
|
|
7
|
-
- another repository available while you work.
|
|
8
|
-
|
|
9
|
-
```json
|
|
10
|
-
{
|
|
11
|
-
"$schema": "https://opencode.ai/config.json",
|
|
12
|
-
"references": {
|
|
13
|
-
"docs": {
|
|
14
|
-
"path": "../product-docs",
|
|
15
|
-
"description": "Use for product behavior and documentation conventions",
|
|
16
|
-
},
|
|
17
|
-
"sdk": {
|
|
18
|
-
"repository": "anomalyco/opencode-sdk-js",
|
|
19
|
-
"branch": "main",
|
|
20
|
-
"description": "Use for JavaScript SDK implementation details",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Local directories
|
|
27
|
-
Use `path` to reference a local directory, Paths can be:
|
|
28
|
-
- Relative to the *config file* that defines the reference
|
|
29
|
-
- Absolute, such as `/home/user/docs`
|
|
30
|
-
- Relative to your home directory, such as `~/docs`
|
|
31
|
-
```json
|
|
32
|
-
{
|
|
33
|
-
"references": {
|
|
34
|
-
"docs": {
|
|
35
|
-
"path": "../docs",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
You can also use a string shorthand:
|
|
42
|
-
```json
|
|
43
|
-
{
|
|
44
|
-
"references": {
|
|
45
|
-
"docs": "../docs",
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Git repositories
|
|
51
|
-
Use `repository` to reference a Git repository, accepts:
|
|
52
|
-
- Git URLs,
|
|
53
|
-
- host/path references,
|
|
54
|
-
- GitHub owner/repo shorthand.
|
|
55
|
-
|
|
56
|
-
```json
|
|
57
|
-
{
|
|
58
|
-
"references": {
|
|
59
|
-
"effect": {
|
|
60
|
-
"repository": "Effect-TS/effect",
|
|
61
|
-
"branch": "main",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
The optional `branch` field selects a branch or ref. Without branch, OpenCode uses the repository’s default branch.
|
|
68
|
-
|
|
69
|
-
You can use string shorthand.
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"references": {
|
|
73
|
-
"effect": "Effect-TS/effect",
|
|
74
|
-
},
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Describe usage
|
|
79
|
-
Add `description` to explain when an agent should use a reference.
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"references": {
|
|
83
|
-
"design-system": {
|
|
84
|
-
"path": "../design-system",
|
|
85
|
-
"description": "Use when implementing UI components or design tokens",
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
OpenCode includes references with descriptions in agent context. Descriptions should be short and specific enough to distinguish references with similar content.
|
|
91
|
-
|
|
92
|
-
## Hide autocomplete entries
|
|
93
|
-
Set `hidden` to true to omit a reference from @ autocomplete in the TUI.
|
|
94
|
-
```json
|
|
95
|
-
{
|
|
96
|
-
"references": {
|
|
97
|
-
"internal": {
|
|
98
|
-
"path": "../internal",
|
|
99
|
-
"description": "Use for internal implementation details",
|
|
100
|
-
"hidden": true,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Use references
|
|
107
|
-
Configured references appear in TUI `@` autocomplete. Type `@alias` to attach the reference root, or `@alias/` to search for files inside it.
|
|
108
|
-
```
|
|
109
|
-
Compare this implementation with @sdk/src/client.ts
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Agents also receive the resolved paths and descriptions of configured references that have descriptions in their system context, so they can inspect a reference when it is relevant without you attaching it manually.
|
|
113
|
-
|
|
114
|
-
## Configure fields
|
|
115
|
-
- `path` : local reference dir
|
|
116
|
-
- `repository` : git url, host/path, owener/repo
|
|
117
|
-
- `branch` : optional git branch
|
|
118
|
-
- `description` : guidance desc when to use the reference
|
|
1
|
+
# reference
|
|
2
|
+
Add local directories and Git repositories as project references.
|
|
3
|
+
|
|
4
|
+
References give OpenCode access to directories outside the current project.Use them to
|
|
5
|
+
- make documentation,
|
|
6
|
+
- shared libraries, examples
|
|
7
|
+
- another repository available while you work.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"$schema": "https://opencode.ai/config.json",
|
|
12
|
+
"references": {
|
|
13
|
+
"docs": {
|
|
14
|
+
"path": "../product-docs",
|
|
15
|
+
"description": "Use for product behavior and documentation conventions",
|
|
16
|
+
},
|
|
17
|
+
"sdk": {
|
|
18
|
+
"repository": "anomalyco/opencode-sdk-js",
|
|
19
|
+
"branch": "main",
|
|
20
|
+
"description": "Use for JavaScript SDK implementation details",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Local directories
|
|
27
|
+
Use `path` to reference a local directory, Paths can be:
|
|
28
|
+
- Relative to the *config file* that defines the reference
|
|
29
|
+
- Absolute, such as `/home/user/docs`
|
|
30
|
+
- Relative to your home directory, such as `~/docs`
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"references": {
|
|
34
|
+
"docs": {
|
|
35
|
+
"path": "../docs",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You can also use a string shorthand:
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"references": {
|
|
45
|
+
"docs": "../docs",
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Git repositories
|
|
51
|
+
Use `repository` to reference a Git repository, accepts:
|
|
52
|
+
- Git URLs,
|
|
53
|
+
- host/path references,
|
|
54
|
+
- GitHub owner/repo shorthand.
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"references": {
|
|
59
|
+
"effect": {
|
|
60
|
+
"repository": "Effect-TS/effect",
|
|
61
|
+
"branch": "main",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The optional `branch` field selects a branch or ref. Without branch, OpenCode uses the repository’s default branch.
|
|
68
|
+
|
|
69
|
+
You can use string shorthand.
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"references": {
|
|
73
|
+
"effect": "Effect-TS/effect",
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Describe usage
|
|
79
|
+
Add `description` to explain when an agent should use a reference.
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"references": {
|
|
83
|
+
"design-system": {
|
|
84
|
+
"path": "../design-system",
|
|
85
|
+
"description": "Use when implementing UI components or design tokens",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
OpenCode includes references with descriptions in agent context. Descriptions should be short and specific enough to distinguish references with similar content.
|
|
91
|
+
|
|
92
|
+
## Hide autocomplete entries
|
|
93
|
+
Set `hidden` to true to omit a reference from @ autocomplete in the TUI.
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"references": {
|
|
97
|
+
"internal": {
|
|
98
|
+
"path": "../internal",
|
|
99
|
+
"description": "Use for internal implementation details",
|
|
100
|
+
"hidden": true,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Use references
|
|
107
|
+
Configured references appear in TUI `@` autocomplete. Type `@alias` to attach the reference root, or `@alias/` to search for files inside it.
|
|
108
|
+
```
|
|
109
|
+
Compare this implementation with @sdk/src/client.ts
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Agents also receive the resolved paths and descriptions of configured references that have descriptions in their system context, so they can inspect a reference when it is relevant without you attaching it manually.
|
|
113
|
+
|
|
114
|
+
## Configure fields
|
|
115
|
+
- `path` : local reference dir
|
|
116
|
+
- `repository` : git url, host/path, owener/repo
|
|
117
|
+
- `branch` : optional git branch
|
|
118
|
+
- `description` : guidance desc when to use the reference
|
|
119
119
|
- `hidden` : hide the reference form TUI `@` autocomplete
|