@wwkit/harness 1.0.32 → 1.0.33
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 +186 -180
- package/agents/sprint.md +121 -118
- package/bin/index.js +226 -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/package.json +3 -3
- 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 +124 -124
- package/skills/blame-skill/SKILL.md +201 -201
- 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 +227 -227
- package/skills/new-skill/references/template.md +53 -53
- package/skills/new-skill/references/workflow-patterns.md +104 -104
- 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/src/config.js +29 -29
- package/src/config.json5 +19 -19
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 macair15m3
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 macair15m3
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
# harness
|
|
2
|
-
|
|
3
|
-
> `wwkit` monorepo 下的子包(`packages/harness`),原为 `webwork-ability`。
|
|
4
|
-
|
|
5
|
-
WebWork abilities for opencode — 提供内容提取(extract)、内容创作(revise)等技能与代理,让 opencode 具备从网页提取结构化内容、基于素材二次创作等能力。
|
|
6
|
-
|
|
7
|
-
## 前提
|
|
8
|
-
|
|
9
|
-
技能依赖 `node` 运行辅助脚本(如 `references/validate-schema.js`)。调用 opencode 的环境需确保 `node` 在 PATH 中(opencode 的 bash 工具会继承其启动时的环境)。若用 Python 等子进程方式调用,请在 spawn 前把 node 所在目录加入 PATH:
|
|
10
|
-
|
|
11
|
-
```python
|
|
12
|
-
import shutil, os
|
|
13
|
-
node = shutil.which("node") or os.path.expanduser("~/.nvm/versions/node/*/bin/node")
|
|
14
|
-
os.environ["PATH"] = f"{os.path.dirname(node)}:{os.environ.get('PATH', '')}"
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## 安装
|
|
18
|
-
|
|
19
|
-
本包位于 `wwkit` pnpm monorepo 的 `packages/harness`。在仓库根目录安装依赖:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
cd wwkit
|
|
23
|
-
pnpm install
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### 在 opencode 中使用(发布为 npm 包后)
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
cd ~/.config/opencode
|
|
30
|
-
npm install @wwkit/harness
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## 引入方式
|
|
34
|
-
|
|
35
|
-
本包提供两种引入方式,按需选择一种:
|
|
36
|
-
|
|
37
|
-
| 方式 | 配置 | 提供内容 | 适用 |
|
|
38
|
-
|------|------|---------|------|
|
|
39
|
-
| **A. 插件模式(仅技能)** | 在 `~/.config/opencode/opencode.jsonc` 注册插件 | 仅 `extract`/`revise` **技能** | 只需要技能能力 |
|
|
40
|
-
| **B. 环境变量模式(完整,推荐)** | 设置 `OPENCODE_CONFIG_DIR` 指向包目录 | **代理 + 技能 + 命令**(原生扫描 `agents/`、`skills/`、`commands/`) | 需要完整能力 |
|
|
41
|
-
|
|
42
|
-
### 方式 A:插件模式(仅技能)
|
|
43
|
-
|
|
44
|
-
在 `~/.config/opencode/opencode.jsonc` 中注册插件:
|
|
45
|
-
|
|
46
|
-
```jsonc
|
|
47
|
-
{
|
|
48
|
-
"plugin": ["node_modules/@wwkit/harness"]
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
该模式仅注册技能(`extract`/`revise`)。opencode 不支持通过插件注册代理或命令(`agents.paths`/`commands.paths` 字段不存在),因此**方式 A 不含代理与命令**。
|
|
53
|
-
|
|
54
|
-
### 方式 B:环境变量模式(完整,推荐)
|
|
55
|
-
|
|
56
|
-
将 `OPENCODE_CONFIG_DIR` 指向包的安装目录,opencode 会把它当作配置目录,原生发现其中的 `agents/`、`skills/`、`commands/`:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
echo 'export OPENCODE_CONFIG_DIR="$HOME/.config/opencode/node_modules/@wwkit/harness"' >> ~/.zshrc
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
说明:
|
|
63
|
-
- 需在**启动 opencode 前**设置环境变量;
|
|
64
|
-
- 与用户原有配置目录是**叠加**关系,不覆盖已有代理/技能/命令;
|
|
65
|
-
- 该变量为**单一路径**,同时只能指向一个目录;
|
|
66
|
-
- 若之前注册过插件(方式 A),改用方式 B 时请移除 `opencode.jsonc` 中的 `plugin` 项,避免技能重复扫描。
|
|
67
|
-
|
|
68
|
-
## 功能
|
|
69
|
-
|
|
70
|
-
### Agents(代理)
|
|
71
|
-
|
|
72
|
-
| Agent | 作用 |
|
|
73
|
-
|-------|------|
|
|
74
|
-
| `extract` | 从网页 HTML/文本/JSON 提取结构化内容(列表/详情/纯文本/导航),写入输出文件 |
|
|
75
|
-
| `revise` | 基于原始素材二次创作(问题/文章/图集/动态),写入输出文件 |
|
|
76
|
-
| `query` | 根据 prompt 生成内容,支持 source/language/output |
|
|
77
|
-
|
|
78
|
-
### Skills(技能)
|
|
79
|
-
|
|
80
|
-
| Skill | 作用 |
|
|
81
|
-
|-------|------|
|
|
82
|
-
| `extract` | 按 format(list/detail/text/navi)从 HTML/文本/JSON 提取内容 |
|
|
83
|
-
| `revise` | 按 format(question/status/gallery/article)二次创作内容 |
|
|
84
|
-
|
|
85
|
-
### Commands(命令)
|
|
86
|
-
|
|
87
|
-
| Command | 作用 |
|
|
88
|
-
|---------|------|
|
|
89
|
-
| `/tl` | 中英互译:中文→英文附关键词解析(Keywords & Phrases),英文→中文 |
|
|
90
|
-
|
|
91
|
-
## 使用方式
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
# 使用 extract skill:从 HTML 或文本提取列表(通过 general agent 调用)
|
|
95
|
-
opencode run --agent general '请用 skill 工具加载 extract 技能(name=extract),将以下参数传给它执行提取:{"format": "list", "source": "<html/文本或路径>", "output": "/tmp/list.json"}'
|
|
96
|
-
|
|
97
|
-
# 使用 extract skill:提取单条详情
|
|
98
|
-
opencode run --agent general '请用 skill 工具加载 extract 技能(name=extract),将以下参数传给它执行提取:{"format": "detail", "source": "<html或路径>", "output": "/tmp/result.json"}'
|
|
99
|
-
|
|
100
|
-
# 使用 revise skill:基于素材创作文章(通过 general agent 调用)
|
|
101
|
-
opencode run --agent general '请用 skill 工具加载 revise 技能(name=revise),将以下参数传给它执行创作:{"format": "article", "source": "<素材>", "output": "/tmp/article.json"}'
|
|
102
|
-
|
|
103
|
-
# 使用 query skill:直接生成内容(通过 general agent 调用)
|
|
104
|
-
opencode run --agent general '请用 skill 工具加载 query 技能(name=query),将以下参数传给它执行生成:{"prompt": "写一篇关于AI的文章"}'
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
未提供 `output` 时,结果直接输出到 stdout。
|
|
108
|
-
|
|
109
|
-
## 使用命令(Commands)
|
|
110
|
-
|
|
111
|
-
命令由 opencode 原生加载(需方式 B:`OPENCODE_CONFIG_DIR` 指向本包),在 TUI 内输入命令名即可调用:
|
|
112
|
-
|
|
113
|
-
```text
|
|
114
|
-
/tl <要翻译的文本> # 中英互译;中文→英文附关键词解析,英文→中文
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## 用本包配置启动 opencode(pnpm 脚本)
|
|
118
|
-
|
|
119
|
-
在包目录 `packages/harness` 下执行 pnpm 脚本 `opencode`,它会先设置 `OPENCODE_CONFIG_DIR` 为本包目录,再启动 opencode(从而加载本包的技能/代理/命令):
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
pnpm run opencode # 在当前工作目录启动
|
|
123
|
-
pnpm run opencode -- /path/to/project # 指定 cwd:以该目录为项目目录启动
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
- `opencode` 脚本定义:`"opencode": "OPENCODE_CONFIG_DIR=$(pwd) opencode"`;
|
|
127
|
-
- 不带参数时 `opencode` 以当前工作目录启动;带参数时以参数目录为项目目录启动(opencode 位置参数即项目目录);
|
|
128
|
-
- 在 monorepo 根目录可用 `pnpm --filter harness run opencode`,或 `pnpm --dir packages/harness run opencode`。
|
|
1
|
+
# harness
|
|
2
|
+
|
|
3
|
+
> `wwkit` monorepo 下的子包(`packages/harness`),原为 `webwork-ability`。
|
|
4
|
+
|
|
5
|
+
WebWork abilities for opencode — 提供内容提取(extract)、内容创作(revise)等技能与代理,让 opencode 具备从网页提取结构化内容、基于素材二次创作等能力。
|
|
6
|
+
|
|
7
|
+
## 前提
|
|
8
|
+
|
|
9
|
+
技能依赖 `node` 运行辅助脚本(如 `references/validate-schema.js`)。调用 opencode 的环境需确保 `node` 在 PATH 中(opencode 的 bash 工具会继承其启动时的环境)。若用 Python 等子进程方式调用,请在 spawn 前把 node 所在目录加入 PATH:
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
import shutil, os
|
|
13
|
+
node = shutil.which("node") or os.path.expanduser("~/.nvm/versions/node/*/bin/node")
|
|
14
|
+
os.environ["PATH"] = f"{os.path.dirname(node)}:{os.environ.get('PATH', '')}"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
本包位于 `wwkit` pnpm monorepo 的 `packages/harness`。在仓库根目录安装依赖:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
cd wwkit
|
|
23
|
+
pnpm install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 在 opencode 中使用(发布为 npm 包后)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cd ~/.config/opencode
|
|
30
|
+
npm install @wwkit/harness
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 引入方式
|
|
34
|
+
|
|
35
|
+
本包提供两种引入方式,按需选择一种:
|
|
36
|
+
|
|
37
|
+
| 方式 | 配置 | 提供内容 | 适用 |
|
|
38
|
+
|------|------|---------|------|
|
|
39
|
+
| **A. 插件模式(仅技能)** | 在 `~/.config/opencode/opencode.jsonc` 注册插件 | 仅 `extract`/`revise` **技能** | 只需要技能能力 |
|
|
40
|
+
| **B. 环境变量模式(完整,推荐)** | 设置 `OPENCODE_CONFIG_DIR` 指向包目录 | **代理 + 技能 + 命令**(原生扫描 `agents/`、`skills/`、`commands/`) | 需要完整能力 |
|
|
41
|
+
|
|
42
|
+
### 方式 A:插件模式(仅技能)
|
|
43
|
+
|
|
44
|
+
在 `~/.config/opencode/opencode.jsonc` 中注册插件:
|
|
45
|
+
|
|
46
|
+
```jsonc
|
|
47
|
+
{
|
|
48
|
+
"plugin": ["node_modules/@wwkit/harness"]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
该模式仅注册技能(`extract`/`revise`)。opencode 不支持通过插件注册代理或命令(`agents.paths`/`commands.paths` 字段不存在),因此**方式 A 不含代理与命令**。
|
|
53
|
+
|
|
54
|
+
### 方式 B:环境变量模式(完整,推荐)
|
|
55
|
+
|
|
56
|
+
将 `OPENCODE_CONFIG_DIR` 指向包的安装目录,opencode 会把它当作配置目录,原生发现其中的 `agents/`、`skills/`、`commands/`:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
echo 'export OPENCODE_CONFIG_DIR="$HOME/.config/opencode/node_modules/@wwkit/harness"' >> ~/.zshrc
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
说明:
|
|
63
|
+
- 需在**启动 opencode 前**设置环境变量;
|
|
64
|
+
- 与用户原有配置目录是**叠加**关系,不覆盖已有代理/技能/命令;
|
|
65
|
+
- 该变量为**单一路径**,同时只能指向一个目录;
|
|
66
|
+
- 若之前注册过插件(方式 A),改用方式 B 时请移除 `opencode.jsonc` 中的 `plugin` 项,避免技能重复扫描。
|
|
67
|
+
|
|
68
|
+
## 功能
|
|
69
|
+
|
|
70
|
+
### Agents(代理)
|
|
71
|
+
|
|
72
|
+
| Agent | 作用 |
|
|
73
|
+
|-------|------|
|
|
74
|
+
| `extract` | 从网页 HTML/文本/JSON 提取结构化内容(列表/详情/纯文本/导航),写入输出文件 |
|
|
75
|
+
| `revise` | 基于原始素材二次创作(问题/文章/图集/动态),写入输出文件 |
|
|
76
|
+
| `query` | 根据 prompt 生成内容,支持 source/language/output |
|
|
77
|
+
|
|
78
|
+
### Skills(技能)
|
|
79
|
+
|
|
80
|
+
| Skill | 作用 |
|
|
81
|
+
|-------|------|
|
|
82
|
+
| `extract` | 按 format(list/detail/text/navi)从 HTML/文本/JSON 提取内容 |
|
|
83
|
+
| `revise` | 按 format(question/status/gallery/article)二次创作内容 |
|
|
84
|
+
|
|
85
|
+
### Commands(命令)
|
|
86
|
+
|
|
87
|
+
| Command | 作用 |
|
|
88
|
+
|---------|------|
|
|
89
|
+
| `/tl` | 中英互译:中文→英文附关键词解析(Keywords & Phrases),英文→中文 |
|
|
90
|
+
|
|
91
|
+
## 使用方式
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 使用 extract skill:从 HTML 或文本提取列表(通过 general agent 调用)
|
|
95
|
+
opencode run --agent general '请用 skill 工具加载 extract 技能(name=extract),将以下参数传给它执行提取:{"format": "list", "source": "<html/文本或路径>", "output": "/tmp/list.json"}'
|
|
96
|
+
|
|
97
|
+
# 使用 extract skill:提取单条详情
|
|
98
|
+
opencode run --agent general '请用 skill 工具加载 extract 技能(name=extract),将以下参数传给它执行提取:{"format": "detail", "source": "<html或路径>", "output": "/tmp/result.json"}'
|
|
99
|
+
|
|
100
|
+
# 使用 revise skill:基于素材创作文章(通过 general agent 调用)
|
|
101
|
+
opencode run --agent general '请用 skill 工具加载 revise 技能(name=revise),将以下参数传给它执行创作:{"format": "article", "source": "<素材>", "output": "/tmp/article.json"}'
|
|
102
|
+
|
|
103
|
+
# 使用 query skill:直接生成内容(通过 general agent 调用)
|
|
104
|
+
opencode run --agent general '请用 skill 工具加载 query 技能(name=query),将以下参数传给它执行生成:{"prompt": "写一篇关于AI的文章"}'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
未提供 `output` 时,结果直接输出到 stdout。
|
|
108
|
+
|
|
109
|
+
## 使用命令(Commands)
|
|
110
|
+
|
|
111
|
+
命令由 opencode 原生加载(需方式 B:`OPENCODE_CONFIG_DIR` 指向本包),在 TUI 内输入命令名即可调用:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
/tl <要翻译的文本> # 中英互译;中文→英文附关键词解析,英文→中文
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 用本包配置启动 opencode(pnpm 脚本)
|
|
118
|
+
|
|
119
|
+
在包目录 `packages/harness` 下执行 pnpm 脚本 `opencode`,它会先设置 `OPENCODE_CONFIG_DIR` 为本包目录,再启动 opencode(从而加载本包的技能/代理/命令):
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pnpm run opencode # 在当前工作目录启动
|
|
123
|
+
pnpm run opencode -- /path/to/project # 指定 cwd:以该目录为项目目录启动
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- `opencode` 脚本定义:`"opencode": "OPENCODE_CONFIG_DIR=$(pwd) opencode"`;
|
|
127
|
+
- 不带参数时 `opencode` 以当前工作目录启动;带参数时以参数目录为项目目录启动(opencode 位置参数即项目目录);
|
|
128
|
+
- 在 monorepo 根目录可用 `pnpm --filter harness run opencode`,或 `pnpm --dir packages/harness run opencode`。
|