@wwkit/harness 1.0.33 → 1.0.35
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-agents/SKILL.md +300 -0
- package/skills/better-agents/references/evidence-map.md +102 -0
- package/skills/better-agents/references/format-spec.md +91 -0
- package/skills/better-agents/references/section-template.md +116 -0
- package/skills/better-skill/SKILL.md +319 -124
- package/skills/better-skill/references/new-mode.md +126 -0
- package/skills/blame-agents/SKILL.md +270 -0
- package/skills/blame-agents/references/check-agents.js +364 -0
- package/skills/blame-agents/references/scoring-rules.md +259 -0
- package/skills/blame-skill/SKILL.md +163 -201
- package/skills/blame-skill/references/scoring-rules.md +190 -0
- package/skills/blame-sprint-agent/SKILL.md +172 -0
- package/skills/blame-sprint-agent/references/scoring-rules.md +113 -0
- package/skills/blame-sprint-skill/SKILL.md +165 -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/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/SKILL.md +0 -227
- package/skills/new-skill/references/template.md +0 -53
- package/skills/new-skill/references/workflow-patterns.md +0 -104
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# 格式化器
|
|
2
|
-
|
|
3
|
-
OpenCode 可以在文件写入或编辑后使用语言特定的格式化器自动格式化代码。
|
|
4
|
-
|
|
5
|
-
格式化器默认禁用,需在配置中启用。
|
|
6
|
-
|
|
7
|
-
## 内置格式化器
|
|
8
|
-
|
|
9
|
-
| 格式化器 | 支持的文件类型 |
|
|
10
|
-
|----------|---------------|
|
|
11
|
-
| prettier | `.js`, `.jsx`, `.ts`, `.tsx`, `.html`, `.css`, `.md`, `.json`, `.yaml` |
|
|
12
|
-
| uv | `.py`, `.pyi` |
|
|
13
|
-
|
|
14
|
-
启用后,如果项目 `package.json` 中包含 prettier 依赖,OpenCode 将自动使用 prettier 格式化匹配的文件。
|
|
15
|
-
|
|
16
|
-
## 工作原理
|
|
17
|
-
|
|
18
|
-
当 OpenCode 写入或编辑文件且格式化器启用时:
|
|
19
|
-
|
|
20
|
-
1. 检查文件扩展名是否匹配已启用的格式化器
|
|
21
|
-
2. 运行对应的格式化器命令
|
|
22
|
-
3. 应用格式化变更
|
|
23
|
-
4. 此过程在后台自动进行
|
|
24
|
-
|
|
25
|
-
## 启用格式化器
|
|
26
|
-
|
|
27
|
-
```json
|
|
28
|
-
{
|
|
29
|
-
"$schema": "https://opencode.ai/config.json",
|
|
30
|
-
"formatter": true
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
禁用特定格式化器:
|
|
35
|
-
|
|
36
|
-
```json
|
|
37
|
-
{
|
|
38
|
-
"$schema": "https://opencode.ai/config.json",
|
|
39
|
-
"formatter": {
|
|
40
|
-
"prettier": {
|
|
41
|
-
"disabled": true
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## 自定义格式化器
|
|
48
|
-
|
|
49
|
-
可以配置内置格式化器的选项,或添加自定义格式化器:
|
|
50
|
-
|
|
51
|
-
```json
|
|
52
|
-
{
|
|
53
|
-
"$schema": "https://opencode.ai/config.json",
|
|
54
|
-
"formatter": {
|
|
55
|
-
"prettier": {
|
|
56
|
-
"command": ["npx", "prettier", "--write", "$FILE"],
|
|
57
|
-
"environment": {
|
|
58
|
-
"NODE_ENV": "development"
|
|
59
|
-
},
|
|
60
|
-
"extensions": [".js", ".ts", ".jsx", ".tsx"]
|
|
61
|
-
},
|
|
62
|
-
"custom-markdown-formatter": {
|
|
63
|
-
"command": ["deno", "fmt", "$FILE"],
|
|
64
|
-
"extensions": [".md"]
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
命令中的 `$FILE` 占位符将被替换为正在格式化的文件路径。
|
|
1
|
+
# 格式化器
|
|
2
|
+
|
|
3
|
+
OpenCode 可以在文件写入或编辑后使用语言特定的格式化器自动格式化代码。
|
|
4
|
+
|
|
5
|
+
格式化器默认禁用,需在配置中启用。
|
|
6
|
+
|
|
7
|
+
## 内置格式化器
|
|
8
|
+
|
|
9
|
+
| 格式化器 | 支持的文件类型 |
|
|
10
|
+
|----------|---------------|
|
|
11
|
+
| prettier | `.js`, `.jsx`, `.ts`, `.tsx`, `.html`, `.css`, `.md`, `.json`, `.yaml` |
|
|
12
|
+
| uv | `.py`, `.pyi` |
|
|
13
|
+
|
|
14
|
+
启用后,如果项目 `package.json` 中包含 prettier 依赖,OpenCode 将自动使用 prettier 格式化匹配的文件。
|
|
15
|
+
|
|
16
|
+
## 工作原理
|
|
17
|
+
|
|
18
|
+
当 OpenCode 写入或编辑文件且格式化器启用时:
|
|
19
|
+
|
|
20
|
+
1. 检查文件扩展名是否匹配已启用的格式化器
|
|
21
|
+
2. 运行对应的格式化器命令
|
|
22
|
+
3. 应用格式化变更
|
|
23
|
+
4. 此过程在后台自动进行
|
|
24
|
+
|
|
25
|
+
## 启用格式化器
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"$schema": "https://opencode.ai/config.json",
|
|
30
|
+
"formatter": true
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
禁用特定格式化器:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"$schema": "https://opencode.ai/config.json",
|
|
39
|
+
"formatter": {
|
|
40
|
+
"prettier": {
|
|
41
|
+
"disabled": true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 自定义格式化器
|
|
48
|
+
|
|
49
|
+
可以配置内置格式化器的选项,或添加自定义格式化器:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"$schema": "https://opencode.ai/config.json",
|
|
54
|
+
"formatter": {
|
|
55
|
+
"prettier": {
|
|
56
|
+
"command": ["npx", "prettier", "--write", "$FILE"],
|
|
57
|
+
"environment": {
|
|
58
|
+
"NODE_ENV": "development"
|
|
59
|
+
},
|
|
60
|
+
"extensions": [".js", ".ts", ".jsx", ".tsx"]
|
|
61
|
+
},
|
|
62
|
+
"custom-markdown-formatter": {
|
|
63
|
+
"command": ["deno", "fmt", "$FILE"],
|
|
64
|
+
"extensions": [".md"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
命令中的 `$FILE` 占位符将被替换为正在格式化的文件路径。
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
# OpenCode 指南
|
|
2
|
-
|
|
3
|
-
OpenCode 是一个 AI 驱动的编码助手,支持自定义配置、技能扩展和多种 AI 模型。
|
|
4
|
-
|
|
5
|
-
## 快速开始
|
|
6
|
-
|
|
7
|
-
1. 安装 OpenCode
|
|
8
|
-
2. 运行 `opencode` 启动交互式会话
|
|
9
|
-
3. 使用 `/init` 命令初始化项目配置
|
|
10
|
-
|
|
11
|
-
## 核心概念
|
|
12
|
-
|
|
13
|
-
| 概念 | 说明 | 文档 |
|
|
14
|
-
|------|------|------|
|
|
15
|
-
| 配置 | JSON/JSONC 配置文件管理所有设置 | [配置](/guide/config) |
|
|
16
|
-
| 格式化器 | 自动格式化写入和编辑的代码 | [格式化器](/guide/formatters) |
|
|
17
|
-
| Provider | 配置 AI 模型提供商和 API 密钥 | [Provider](/guide/providers) |
|
|
18
|
-
| 规则 | 通过 AGENTS.md 提供自定义指令 | [规则](/guide/rules) |
|
|
19
|
-
| 技能 | 可复用的行为定义(SKILL.md) | [技能](/skills/) |
|
|
20
|
-
| Agent | 专门的 AI 助手 | [Agent](/agents/) |
|
|
21
|
-
| 命令 | 自定义快捷命令 | [命令](/commands/) |
|
|
22
|
-
| 插件 | 扩展 OpenCode 功能 | [插件](/plugins/) |
|
|
23
|
-
| 工具 | LLM 可调用的操作 | [工具](/tools/) |
|
|
24
|
-
|
|
25
|
-
## 内置 Agent
|
|
26
|
-
|
|
27
|
-
| Agent | 类型 | 说明 |
|
|
28
|
-
|-------|------|------|
|
|
29
|
-
| build | 主 Agent | 默认 Agent,所有工具启用 |
|
|
30
|
-
| plan | 主 Agent | 规划和分析,文件编辑和 bash 需审批 |
|
|
31
|
-
| general | 子 Agent | 通用多步骤任务,完整工具访问 |
|
|
32
|
-
| explore | 子 Agent | 快速只读代码探索 |
|
|
33
|
-
| scout | 子 Agent | 外部文档和依赖研究 |
|
|
34
|
-
|
|
35
|
-
## 资源文件
|
|
36
|
-
|
|
37
|
-
<SrcTree />
|
|
1
|
+
# OpenCode 指南
|
|
2
|
+
|
|
3
|
+
OpenCode 是一个 AI 驱动的编码助手,支持自定义配置、技能扩展和多种 AI 模型。
|
|
4
|
+
|
|
5
|
+
## 快速开始
|
|
6
|
+
|
|
7
|
+
1. 安装 OpenCode
|
|
8
|
+
2. 运行 `opencode` 启动交互式会话
|
|
9
|
+
3. 使用 `/init` 命令初始化项目配置
|
|
10
|
+
|
|
11
|
+
## 核心概念
|
|
12
|
+
|
|
13
|
+
| 概念 | 说明 | 文档 |
|
|
14
|
+
|------|------|------|
|
|
15
|
+
| 配置 | JSON/JSONC 配置文件管理所有设置 | [配置](/guide/config) |
|
|
16
|
+
| 格式化器 | 自动格式化写入和编辑的代码 | [格式化器](/guide/formatters) |
|
|
17
|
+
| Provider | 配置 AI 模型提供商和 API 密钥 | [Provider](/guide/providers) |
|
|
18
|
+
| 规则 | 通过 AGENTS.md 提供自定义指令 | [规则](/guide/rules) |
|
|
19
|
+
| 技能 | 可复用的行为定义(SKILL.md) | [技能](/skills/) |
|
|
20
|
+
| Agent | 专门的 AI 助手 | [Agent](/agents/) |
|
|
21
|
+
| 命令 | 自定义快捷命令 | [命令](/commands/) |
|
|
22
|
+
| 插件 | 扩展 OpenCode 功能 | [插件](/plugins/) |
|
|
23
|
+
| 工具 | LLM 可调用的操作 | [工具](/tools/) |
|
|
24
|
+
|
|
25
|
+
## 内置 Agent
|
|
26
|
+
|
|
27
|
+
| Agent | 类型 | 说明 |
|
|
28
|
+
|-------|------|------|
|
|
29
|
+
| build | 主 Agent | 默认 Agent,所有工具启用 |
|
|
30
|
+
| plan | 主 Agent | 规划和分析,文件编辑和 bash 需审批 |
|
|
31
|
+
| general | 子 Agent | 通用多步骤任务,完整工具访问 |
|
|
32
|
+
| explore | 子 Agent | 快速只读代码探索 |
|
|
33
|
+
| scout | 子 Agent | 外部文档和依赖研究 |
|
|
34
|
+
|
|
35
|
+
## 资源文件
|
|
36
|
+
|
|
37
|
+
<SrcTree />
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# Providers
|
|
2
|
-
|
|
3
|
-
添加 Provider 需要两步:
|
|
4
|
-
|
|
5
|
-
1. 使用 `/connect` 命令添加 Provider 的 API 密钥
|
|
6
|
-
2. 在 OpenCode 配置中配置 Provider
|
|
7
|
-
|
|
8
|
-
## 凭证管理
|
|
9
|
-
|
|
10
|
-
通过 `/connect` 命令添加的 API 密钥存储在 `~/.local/share/opencode/auth.json` 中。
|
|
11
|
-
|
|
12
|
-
## 配置 Provider
|
|
13
|
-
|
|
14
|
-
在 OpenCode 配置的 `provider` 部分自定义 Provider:
|
|
15
|
-
|
|
16
|
-
```jsonc
|
|
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
|
-
## OpenCode Zen
|
|
30
|
-
|
|
31
|
-
OpenCode Zen 是 OpenCode 团队提供的经过测试验证的模型列表,可确保与 OpenCode 良好配合。
|
|
1
|
+
# Providers
|
|
2
|
+
|
|
3
|
+
添加 Provider 需要两步:
|
|
4
|
+
|
|
5
|
+
1. 使用 `/connect` 命令添加 Provider 的 API 密钥
|
|
6
|
+
2. 在 OpenCode 配置中配置 Provider
|
|
7
|
+
|
|
8
|
+
## 凭证管理
|
|
9
|
+
|
|
10
|
+
通过 `/connect` 命令添加的 API 密钥存储在 `~/.local/share/opencode/auth.json` 中。
|
|
11
|
+
|
|
12
|
+
## 配置 Provider
|
|
13
|
+
|
|
14
|
+
在 OpenCode 配置的 `provider` 部分自定义 Provider:
|
|
15
|
+
|
|
16
|
+
```jsonc
|
|
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
|
+
## OpenCode Zen
|
|
30
|
+
|
|
31
|
+
OpenCode Zen 是 OpenCode 团队提供的经过测试验证的模型列表,可确保与 OpenCode 良好配合。
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# 规则(Rules)
|
|
2
|
-
|
|
3
|
-
通过创建 `AGENTS.md` 文件为 OpenCode 提供自定义指令。
|
|
4
|
-
|
|
5
|
-
## 初始化
|
|
6
|
-
|
|
7
|
-
在 OpenCode 中运行 `/init` 命令创建 `AGENTS.md` 文件:
|
|
8
|
-
|
|
9
|
-
- `/init` 扫描项目中的重要文件,可能提出针对性问题
|
|
10
|
-
- 如果已有 `AGENTS.md`,`/init` 会原地改进而非盲目替换
|
|
11
|
-
|
|
12
|
-
## 示例
|
|
13
|
-
|
|
14
|
-
手动创建 `AGENTS.md`:
|
|
15
|
-
|
|
16
|
-
```md
|
|
17
|
-
# SST v3 Monorepo Project
|
|
18
|
-
|
|
19
|
-
This is an SST v3 monorepo with TypeScript. The project uses bun workspaces for package management.
|
|
20
|
-
|
|
21
|
-
## Project Structure
|
|
22
|
-
|
|
23
|
-
- `packages/` - Contains all workspace packages (functions, core, web, etc.)
|
|
24
|
-
- `infra/` - Infrastructure definitions split by service (storage.ts, api.ts, web.ts)
|
|
25
|
-
- `sst.config.ts` - Main SST configuration with dynamic imports
|
|
26
|
-
|
|
27
|
-
## Code Standards
|
|
28
|
-
|
|
29
|
-
- Use TypeScript with strict mode enabled
|
|
30
|
-
- Shared code goes in `packages/core/` with proper exports configuration
|
|
31
|
-
- Functions go in `packages/functions/`
|
|
32
|
-
- Infrastructure should be split into logical files in `infra/`
|
|
33
|
-
|
|
34
|
-
## Monorepo Conventions
|
|
35
|
-
|
|
36
|
-
- Import shared modules using workspace names: `@my-app/core/example`
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## 项目级规则
|
|
40
|
-
|
|
41
|
-
在项目根目录放置 `AGENTS.md`,仅对该项目生效。
|
|
42
|
-
|
|
43
|
-
## 全局规则
|
|
44
|
-
|
|
45
|
-
在 `~/.config/opencode/AGENTS.md` 放置全局规则,对所有 OpenCode 会话生效。
|
|
46
|
-
|
|
47
|
-
## 加载优先级
|
|
48
|
-
|
|
49
|
-
OpenCode 启动时按以下顺序查找规则文件:
|
|
50
|
-
|
|
51
|
-
1. 本地文件:从当前目录向上遍历查找 `AGENTS.md`
|
|
52
|
-
2. 全局文件:`~/.config/opencode/AGENTS.md`
|
|
53
|
-
|
|
54
|
-
## 自定义指令文件
|
|
55
|
-
|
|
56
|
-
在 `opencode.json` 或全局 `~/.config/opencode/opencode.json` 中指定自定义指令文件:
|
|
57
|
-
|
|
58
|
-
```jsonc
|
|
59
|
-
{
|
|
60
|
-
"$schema": "https://opencode.ai/config.json",
|
|
61
|
-
"instructions": ["CONTRIBUTING.md", "docs/guidelines.md", ".cursor/rules/*.md"]
|
|
62
|
-
}
|
|
63
|
-
```
|
|
1
|
+
# 规则(Rules)
|
|
2
|
+
|
|
3
|
+
通过创建 `AGENTS.md` 文件为 OpenCode 提供自定义指令。
|
|
4
|
+
|
|
5
|
+
## 初始化
|
|
6
|
+
|
|
7
|
+
在 OpenCode 中运行 `/init` 命令创建 `AGENTS.md` 文件:
|
|
8
|
+
|
|
9
|
+
- `/init` 扫描项目中的重要文件,可能提出针对性问题
|
|
10
|
+
- 如果已有 `AGENTS.md`,`/init` 会原地改进而非盲目替换
|
|
11
|
+
|
|
12
|
+
## 示例
|
|
13
|
+
|
|
14
|
+
手动创建 `AGENTS.md`:
|
|
15
|
+
|
|
16
|
+
```md
|
|
17
|
+
# SST v3 Monorepo Project
|
|
18
|
+
|
|
19
|
+
This is an SST v3 monorepo with TypeScript. The project uses bun workspaces for package management.
|
|
20
|
+
|
|
21
|
+
## Project Structure
|
|
22
|
+
|
|
23
|
+
- `packages/` - Contains all workspace packages (functions, core, web, etc.)
|
|
24
|
+
- `infra/` - Infrastructure definitions split by service (storage.ts, api.ts, web.ts)
|
|
25
|
+
- `sst.config.ts` - Main SST configuration with dynamic imports
|
|
26
|
+
|
|
27
|
+
## Code Standards
|
|
28
|
+
|
|
29
|
+
- Use TypeScript with strict mode enabled
|
|
30
|
+
- Shared code goes in `packages/core/` with proper exports configuration
|
|
31
|
+
- Functions go in `packages/functions/`
|
|
32
|
+
- Infrastructure should be split into logical files in `infra/`
|
|
33
|
+
|
|
34
|
+
## Monorepo Conventions
|
|
35
|
+
|
|
36
|
+
- Import shared modules using workspace names: `@my-app/core/example`
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 项目级规则
|
|
40
|
+
|
|
41
|
+
在项目根目录放置 `AGENTS.md`,仅对该项目生效。
|
|
42
|
+
|
|
43
|
+
## 全局规则
|
|
44
|
+
|
|
45
|
+
在 `~/.config/opencode/AGENTS.md` 放置全局规则,对所有 OpenCode 会话生效。
|
|
46
|
+
|
|
47
|
+
## 加载优先级
|
|
48
|
+
|
|
49
|
+
OpenCode 启动时按以下顺序查找规则文件:
|
|
50
|
+
|
|
51
|
+
1. 本地文件:从当前目录向上遍历查找 `AGENTS.md`
|
|
52
|
+
2. 全局文件:`~/.config/opencode/AGENTS.md`
|
|
53
|
+
|
|
54
|
+
## 自定义指令文件
|
|
55
|
+
|
|
56
|
+
在 `opencode.json` 或全局 `~/.config/opencode/opencode.json` 中指定自定义指令文件:
|
|
57
|
+
|
|
58
|
+
```jsonc
|
|
59
|
+
{
|
|
60
|
+
"$schema": "https://opencode.ai/config.json",
|
|
61
|
+
"instructions": ["CONTRIBUTING.md", "docs/guidelines.md", ".cursor/rules/*.md"]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
# 插件示例
|
|
2
|
-
|
|
3
|
-
## 发送通知
|
|
4
|
-
|
|
5
|
-
在特定事件发生时发送通知:
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
// .opencode/plugins/notification.js
|
|
9
|
-
export const NotificationPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
10
|
-
return {
|
|
11
|
-
event: async ({ event }) => {
|
|
12
|
-
if (event.type === "session.idle") {
|
|
13
|
-
await $`osascript -e 'display notification "Session completed!" with title "opencode"'`
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## .env 文件保护
|
|
21
|
-
|
|
22
|
-
防止 OpenCode 读取 .env 文件:
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
// .opencode/plugins/env-protection.js
|
|
26
|
-
export const EnvProtection = async ({ project, client, $, directory, worktree }) => {
|
|
27
|
-
return {
|
|
28
|
-
"tool.execute.before": async (input, output) => {
|
|
29
|
-
if (input.tool === "read" && output.args.filePath.includes(".env")) {
|
|
30
|
-
throw new Error("Do not read .env files")
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## 注入环境变量
|
|
38
|
-
|
|
39
|
-
向所有 Shell 执行注入环境变量:
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
export const InjectEnvPlugin = async () => {
|
|
43
|
-
return {
|
|
44
|
-
"shell.env": async (input, output) => {
|
|
45
|
-
output.env.MY_API_KEY = "secret"
|
|
46
|
-
output.env.PROJECT_ROOT = input.cwd
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## 自定义工具
|
|
53
|
-
|
|
54
|
-
插件也可以向 OpenCode 添加自定义工具:
|
|
55
|
-
|
|
56
|
-
```js
|
|
57
|
-
import { type Plugin, tool } from "@opencode-ai/plugin"
|
|
58
|
-
|
|
59
|
-
export const CustomToolsPlugin: Plugin = async (ctx) => {
|
|
60
|
-
return {
|
|
61
|
-
tool: {
|
|
62
|
-
mytool: tool({
|
|
63
|
-
description: "This is a custom tool",
|
|
64
|
-
args: {
|
|
65
|
-
foo: tool.schema.string(),
|
|
66
|
-
},
|
|
67
|
-
async execute(args, context) {
|
|
68
|
-
const { directory, worktree } = context
|
|
69
|
-
return `Hello ${args.foo} from ${directory} (worktree: ${worktree})`
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
```
|
|
1
|
+
# 插件示例
|
|
2
|
+
|
|
3
|
+
## 发送通知
|
|
4
|
+
|
|
5
|
+
在特定事件发生时发送通知:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
// .opencode/plugins/notification.js
|
|
9
|
+
export const NotificationPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
10
|
+
return {
|
|
11
|
+
event: async ({ event }) => {
|
|
12
|
+
if (event.type === "session.idle") {
|
|
13
|
+
await $`osascript -e 'display notification "Session completed!" with title "opencode"'`
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## .env 文件保护
|
|
21
|
+
|
|
22
|
+
防止 OpenCode 读取 .env 文件:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
// .opencode/plugins/env-protection.js
|
|
26
|
+
export const EnvProtection = async ({ project, client, $, directory, worktree }) => {
|
|
27
|
+
return {
|
|
28
|
+
"tool.execute.before": async (input, output) => {
|
|
29
|
+
if (input.tool === "read" && output.args.filePath.includes(".env")) {
|
|
30
|
+
throw new Error("Do not read .env files")
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 注入环境变量
|
|
38
|
+
|
|
39
|
+
向所有 Shell 执行注入环境变量:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
export const InjectEnvPlugin = async () => {
|
|
43
|
+
return {
|
|
44
|
+
"shell.env": async (input, output) => {
|
|
45
|
+
output.env.MY_API_KEY = "secret"
|
|
46
|
+
output.env.PROJECT_ROOT = input.cwd
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 自定义工具
|
|
53
|
+
|
|
54
|
+
插件也可以向 OpenCode 添加自定义工具:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { type Plugin, tool } from "@opencode-ai/plugin"
|
|
58
|
+
|
|
59
|
+
export const CustomToolsPlugin: Plugin = async (ctx) => {
|
|
60
|
+
return {
|
|
61
|
+
tool: {
|
|
62
|
+
mytool: tool({
|
|
63
|
+
description: "This is a custom tool",
|
|
64
|
+
args: {
|
|
65
|
+
foo: tool.schema.string(),
|
|
66
|
+
},
|
|
67
|
+
async execute(args, context) {
|
|
68
|
+
const { directory, worktree } = context
|
|
69
|
+
return `Hello ${args.foo} from ${directory} (worktree: ${worktree})`
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|