@wwkit/harness 1.0.8 → 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.
Files changed (110) hide show
  1. package/agents/extract.md +2 -14
  2. package/agents/lint.md +367 -0
  3. package/agents/pyit.md +361 -0
  4. package/agents/pyut.md +347 -0
  5. package/agents/query.md +2 -14
  6. package/agents/revise.md +2 -14
  7. package/agents/work.md +151 -0
  8. package/commands/git-sync.md +218 -0
  9. package/commands/net-port.md +364 -0
  10. package/commands/pyit.md +6 -0
  11. package/commands/pyut.md +6 -0
  12. package/commands/resume.md +104 -0
  13. package/package.json +2 -2
  14. package/skills/better-skill/SKILL.md +124 -0
  15. package/skills/blame-skill/SKILL.md +201 -0
  16. package/skills/lint-ai-fix/SKILL.md +141 -0
  17. package/skills/lint-config-setup/SKILL.md +106 -0
  18. package/skills/lint-config-setup/references/languages/js.md +110 -0
  19. package/skills/lint-config-setup/references/languages/py.md +89 -0
  20. package/skills/lint-env-ensure/SKILL.md +92 -0
  21. package/skills/lint-env-ensure/references/config.md +65 -0
  22. package/skills/lint-language-detect/SKILL.md +79 -0
  23. package/skills/lint-language-detect/references/detect-language.js +65 -0
  24. package/skills/lint-rules-analyze/SKILL.md +129 -0
  25. package/skills/lint-suitability-check/SKILL.md +84 -0
  26. package/skills/lint-tool-fix/SKILL.md +94 -0
  27. package/skills/new-skill/SKILL.md +227 -0
  28. package/skills/new-skill/references/template.md +53 -0
  29. package/skills/new-skill/references/workflow-patterns.md +104 -0
  30. package/skills/pytest-case-create/SKILL.md +327 -0
  31. package/skills/pytest-case-create/references/test-standards.md +244 -0
  32. package/skills/pytest-case-fix/SKILL.md +274 -0
  33. package/skills/pytest-coverage-analyze/SKILL.md +226 -0
  34. package/skills/pytest-coverage-analyze/references/scoring-rules.md +57 -0
  35. package/skills/pytest-env-ensure/SKILL.md +198 -0
  36. package/skills/pytest-env-ensure/references/config.md +145 -0
  37. package/skills/pytest-execute/SKILL.md +155 -0
  38. package/skills/pytest-sample/SKILL.md +164 -0
  39. package/skills/pytest-sample/references/src/pytest-sample/Calculator.py +67 -0
  40. package/skills/pytest-sample/references/src/pytest-sample/ConfigManager.py +68 -0
  41. package/skills/pytest-sample/references/src/pytest-sample/FileProcessor.py +53 -0
  42. package/skills/pytest-sample/references/src/pytest-sample/OrderService.py +82 -0
  43. package/skills/pytest-sample/references/src/pytest-sample/TokenGenerator.py +50 -0
  44. package/skills/pytest-sample/references/src/pytest-sample/UserService.py +45 -0
  45. package/skills/pytest-sample/references/src/pytest-sample/__init__.py +0 -0
  46. package/skills/pytest-suitability-check/SKILL.md +224 -0
  47. package/skills/read-docs/SKILL.md +134 -0
  48. package/skills/read-docs/references/opencode/agents/cases.md +206 -0
  49. package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -0
  50. package/skills/read-docs/references/opencode/agents/detail.md +191 -0
  51. package/skills/read-docs/references/opencode/agents/examples.md +100 -0
  52. package/skills/read-docs/references/opencode/agents/index.md +307 -0
  53. package/skills/read-docs/references/opencode/agents/workflow.md +161 -0
  54. package/skills/read-docs/references/opencode/cli/commands/acp.md +32 -0
  55. package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -0
  56. package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -0
  57. package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -0
  58. package/skills/read-docs/references/opencode/cli/commands/others.md +49 -0
  59. package/skills/read-docs/references/opencode/cli/commands/plugin.md +13 -0
  60. package/skills/read-docs/references/opencode/cli/commands/provider.md +44 -0
  61. package/skills/read-docs/references/opencode/cli/commands/run.md +81 -0
  62. package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -0
  63. package/skills/read-docs/references/opencode/cli/commands/session.md +38 -0
  64. package/skills/read-docs/references/opencode/cli/commands/web.md +15 -0
  65. package/skills/read-docs/references/opencode/cli/env.md +39 -0
  66. package/skills/read-docs/references/opencode/cli/index.md +19 -0
  67. package/skills/read-docs/references/opencode/cli/tui.md +35 -0
  68. package/skills/read-docs/references/opencode/commands/examples.md +42 -0
  69. package/skills/read-docs/references/opencode/commands/index.md +185 -0
  70. package/skills/read-docs/references/opencode/config/provider.md +152 -0
  71. package/skills/read-docs/references/opencode/formatter/index.md +71 -0
  72. package/skills/read-docs/references/opencode/guide/config.md +419 -0
  73. package/skills/read-docs/references/opencode/guide/formatters.md +70 -0
  74. package/skills/read-docs/references/opencode/guide/index.md +37 -0
  75. package/skills/read-docs/references/opencode/guide/providers.md +31 -0
  76. package/skills/read-docs/references/opencode/guide/rules.md +63 -0
  77. package/skills/read-docs/references/opencode/plugins/examples.md +75 -0
  78. package/skills/read-docs/references/opencode/plugins/index.md +188 -0
  79. package/skills/read-docs/references/opencode/reference/index.md +119 -0
  80. package/skills/read-docs/references/opencode/rule/index.md +78 -0
  81. package/skills/read-docs/references/opencode/skills/detail.md +113 -0
  82. package/skills/read-docs/references/opencode/skills/examples.md +141 -0
  83. package/skills/read-docs/references/opencode/skills/index.md +126 -0
  84. package/skills/read-docs/references/opencode/skills/workflow.md +146 -0
  85. package/skills/read-docs/references/opencode/tests/agent.md +10 -0
  86. package/skills/read-docs/references/opencode/tests/config.md +60 -0
  87. package/skills/read-docs/references/opencode/tests/file.md +12 -0
  88. package/skills/read-docs/references/opencode/tests/serve.md +18 -0
  89. package/skills/read-docs/references/opencode/tests/session.md +31 -0
  90. package/skills/read-docs/references/opencode/tests/web.md +17 -0
  91. package/skills/read-docs/references/opencode/tools/arguments.md +305 -0
  92. package/skills/read-docs/references/opencode/tools/context.md +18 -0
  93. package/skills/read-docs/references/opencode/tools/custom.md +111 -0
  94. package/skills/read-docs/references/opencode/tools/detail.md +104 -0
  95. package/skills/read-docs/references/opencode/tools/examples.md +71 -0
  96. package/skills/read-docs/references/opencode/tools/index.md +56 -0
  97. package/skills/read-docs/references/opencode/tools/lsp.md +26 -0
  98. package/skills/read-docs/references/opencode/tools/mcp.md +132 -0
  99. package/skills/read-docs/references/opencode/train/README.md +135 -0
  100. package/skills/read-docs/references/opencode/train/agent-basic.md +772 -0
  101. package/skills/read-docs/references/opencode/train/command-basic.md +668 -0
  102. package/skills/read-docs/references/opencode/train/config-basic.md +509 -0
  103. package/skills/read-docs/references/opencode/train/index.md +164 -0
  104. package/skills/read-docs/references/opencode/train/practice.md +873 -0
  105. package/skills/read-docs/references/opencode/train/skill-basic.md +608 -0
  106. package/skills/read-docs/references/opencode/tui/commands/config.md +32 -0
  107. package/skills/read-docs/references/opencode/tui/commands/editor.md +47 -0
  108. package/skills/read-docs/references/opencode/tui/commands/index.md +125 -0
  109. package/skills/read-docs/references/opencode/tui/commands/init.md +5 -0
  110. package/skills/read-docs/references/opencode/tui/index.md +26 -0
@@ -0,0 +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
+ ```
@@ -0,0 +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) — 通知、环境保护、自定义工具等示例
@@ -0,0 +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
119
+ - `hidden` : hide the reference form TUI `@` autocomplete
@@ -0,0 +1,78 @@
1
+ # rules
2
+ You can provide custom instructions to opencode by creating an `AGENTS.md` file.
3
+
4
+ It contains instructions that will be included in the LLM’s context to customize its behavior for your specific project.
5
+
6
+ ## Initialize
7
+ To create a new AGENTS.md file, you can run the `/init` command in opencode.
8
+
9
+ It focuses on the things future agent sessions are most likely to need:
10
+ - build, lint, and test commands
11
+ - command order and focused verification steps when they matter
12
+ - architecture and repo structure that are not obvious from filenames alone
13
+ - project-specific conventions, setup quirks, and operational gotchas
14
+
15
+ ## Manual
16
+ You can also just create this file manually.
17
+ ```md
18
+ # SST v3 Monorepo Project
19
+
20
+ This is an SST v3 monorepo with TypeScript. The project uses bun workspaces for package management.
21
+
22
+ ## Project Structure
23
+
24
+ - `packages/` - Contains all workspace packages (functions, core, web, etc.)
25
+ - `infra/` - Infrastructure definitions split by service (storage.ts, api.ts, web.ts)
26
+ - `sst.config.ts` - Main SST configuration with dynamic imports
27
+
28
+ ## Code Standards
29
+
30
+ - Use TypeScript with strict mode enabled
31
+ - Shared code goes in `packages/core/` with proper exports configuration
32
+ - Functions go in `packages/functions/`
33
+ - Infrastructure should be split into logical files in `infra/`
34
+
35
+ ## Monorepo Conventions
36
+
37
+ - Import shared modules using workspace names: `@my-app/core/example`
38
+ ```
39
+
40
+ ## Location
41
+ #### Project
42
+ Place an AGENTS.md in your project root for project-specific rules.
43
+
44
+ #### Global
45
+ in a `~/.config/opencode/AGENTS.md` file.
46
+
47
+ Since this isn’t committed to Git or shared with your team, we recommend using this to specify any personal rules that the LLM should follow.
48
+
49
+ #### Custom Instructions
50
+ You can specify custom instruction files in your `opencode.json` or the global `~/.config/opencode/opencode.json`.
51
+
52
+ All instruction files are combined with your AGENTS.md files.
53
+
54
+ ```json
55
+ {
56
+ "$schema": "https://opencode.ai/config.json",
57
+ "instructions": [
58
+ "CONTRIBUTING.md", "docs/guidelines.md", ".cursor/rules/*.md",
59
+ // remote URLs with a 5 second timeout
60
+ "https://raw.githubusercontent.com/my-org/shared-rules/main/style.md"
61
+ ]
62
+ }
63
+ ```
64
+
65
+ You can teach opencode to read external files by providing explicit instructions in your AGENTS.md. Here’s a practical example:
66
+ ```md
67
+ # TypeScript Project Rules
68
+
69
+ ## External File Loading
70
+
71
+ CRITICAL: When you encounter a file reference (e.g., @rules/general.md), use your Read tool to load it on a need-to-know basis. They're relevant to the SPECIFIC task at hand.
72
+
73
+ Instructions:
74
+
75
+ - Do NOT preemptively load all references - use lazy loading based on actual need
76
+ - When loaded, treat content as mandatory instructions that override defaults
77
+ - Follow references recursively when needed
78
+ ```
@@ -0,0 +1,113 @@
1
+ # 技能详解
2
+
3
+ ## 渐进式加载(Progressive Disclosure)
4
+
5
+ 技能不是把所有内容塞进上下文,而是分层加载:
6
+
7
+ | 层级 | 内容 | 大小 | 加载时机 |
8
+ |------|------|------|----------|
9
+ | 第一层 | name + description | ~100 词 | 始终可见,判断是否需要加载 |
10
+ | 第二层 | SKILL.md 正文 | 中等 | 任务匹配时加载,包含主要指令 |
11
+ | 第三层 | references/ 目录 | 详细 | 仅在需要具体细节时加载 |
12
+
13
+ ## 目录结构
14
+
15
+ 基本结构:
16
+
17
+ ```
18
+ .opencode/
19
+ └── skill/
20
+ └── code-review/
21
+ └── SKILL.md # 技能定义文件(必须大写)
22
+ ```
23
+
24
+ 完整结构:
25
+
26
+ ```
27
+ .opencode/
28
+ └── skill/
29
+ └── sql-analysis/
30
+ ├── SKILL.md # 主文件:工作流程和关键逻辑
31
+ └── references/ # 详细文档(按需加载)
32
+ ├── finance.md # 财务表结构
33
+ ├── product.md # 产品表结构
34
+ └── examples.md # 查询示例
35
+ ```
36
+
37
+ ## Description 编写
38
+
39
+ Description 是唯一决定技能是否被触发的因素。OpenCode 使用语义理解(不是关键词匹配)来判断任务是否需要某个技能。
40
+
41
+ ### 反面示例
42
+
43
+ ```
44
+ description: 帮助处理文档
45
+ ```
46
+
47
+ ### 正面示例
48
+
49
+ ```md
50
+ description: |
51
+ 从 PDF 中提取表格并转换为 CSV 格式,用于数据分析工作流。
52
+ 适用:填写 PDF 表单、批量处理 PDF 文档、提取 PDF 内嵌数据。
53
+ 不适用:简单 PDF 查看、基本格式转换、PDF 编辑。
54
+ ```
55
+
56
+ ### Description 模板
57
+
58
+ ```
59
+ description: |
60
+ [一句话说明核心能力]
61
+ 提供:[该技能包含的资源,如表结构、公式、模板]
62
+ 适用:[触发场景1]、[触发场景2]、[触发场景3]
63
+ 不适用:[边界场景1]、[边界场景2]
64
+ ```
65
+
66
+ ### Description 要素
67
+
68
+ | 要素 | 说明 | 示例 |
69
+ |------|------|------|
70
+ | 具体能力 | 能做什么 | 提取表格、转换格式 |
71
+ | 提供资源 | 包含什么 | 表结构、公式、模板 |
72
+ | 触发场景 | 什么时候用 | 批量处理、表单填写 |
73
+ | 边界限制 | 什么时候不用 | 简单查看 |
74
+
75
+ ## 创建步骤
76
+
77
+ ### 步骤 1:明确需求
78
+
79
+ 在写任何内容之前,回答这些问题:
80
+
81
+ 1. 这个技能解决什么具体问题?→ 明确价值
82
+ 2. 什么情况下应该触发?→ 设计 description
83
+ 3. 成功的输出是什么样?→ 定义验收标准
84
+ 4. 有哪些边缘情况?→ 避免遗漏
85
+
86
+ ### 步骤 2:写 name
87
+
88
+ 简短清晰,反映核心功能。
89
+
90
+ ### 步骤 3:写 description(最重要)
91
+
92
+ Description 决定触发,是最关键的部分。
93
+
94
+ ### 步骤 4:写主要指令
95
+
96
+ 写作原则:
97
+
98
+ 1. 用 Markdown 结构 — 标题、列表、表格增加可读性
99
+ 2. 提供具体示例 — 代码块展示正确用法
100
+ 3. 说明不能做什么 — 避免误用
101
+ 4. 引用详细文档 — 保持主文件精简
102
+
103
+ ### 步骤 5:测试验证
104
+
105
+ 系统化测试技能,确保在各种场景下都能正常工作。
106
+
107
+ ## 技能 + MCP
108
+
109
+ | MCP 提供 | 技能提供 |
110
+ |----------|----------|
111
+ | 连接到各种服务(Notion、Linear、GitHub...) | 如何使用这些工具的最佳实践 |
112
+ | 实时数据访问 | 多步骤工作流编排 |
113
+ | 工具调用能力 | 领域专业知识 |
@@ -0,0 +1,141 @@
1
+ # 技能示例
2
+
3
+ ## 简单示例:translate
4
+
5
+ ```md
6
+ ---
7
+ name: translate
8
+ description: 专业翻译,保留格式和术语。用于翻译技术文档、API 文档、代码注释。
9
+ ---
10
+ # 翻译技能
11
+ ## 翻译规范
12
+ 1. 保持原文格式和段落结构
13
+ 2. 专有名词保留原文并标注
14
+ 3. 技术术语查阅术语表
15
+ 4. 翻译后进行通读润色
16
+ ## 输出格式
17
+ 翻译结果用代码块包裹;
18
+ 对于不确定的翻译,用括号标注原文。
19
+ ```
20
+
21
+ ## 简单示例:brand-guidelines
22
+
23
+ ```md
24
+ ---
25
+ name: brand-guidelines
26
+ description: 应用公司官方品牌色和排版规范。用于创建需要公司视觉风格的文档、演示文稿、界面设计。
27
+ ---
28
+ # 品牌规范技能
29
+ ## 颜色
30
+ **主色**:
31
+ - 深色:`#141413` - 主要文字和深色背景
32
+ - 浅色:`#faf9f5` - 浅色背景和深色上的文字
33
+ - 中灰:`#b0aea5` - 次要元素
34
+ **强调色**:
35
+ - 橙色:`#d97757` - 主强调色
36
+ - 蓝色:`#6a9bcc` - 次强调色
37
+ - 绿色:`#788c5d` - 第三强调色
38
+ ## 字体
39
+ - **标题**:Poppins(备选 Arial)
40
+ - **正文**:Lora(备选 Georgia)
41
+ ## 应用规则
42
+ - 标题(24pt 及以上)使用 Poppins
43
+ - 正文使用 Lora
44
+ - 根据背景智能选择文字颜色
45
+ ```
46
+
47
+ ## 中级示例:sql-analysis(含 references/)
48
+
49
+ `SKILL.md` 只包含工作流程和关键逻辑,详细的表结构放在 `references/` 目录中。
50
+
51
+ ### SKILL.md
52
+
53
+ ```md
54
+ ---
55
+ name: sql-analysis
56
+ description: |
57
+ 用于分析业务数据:收入趋势、ARR 计算、客户分群、产品使用、销售管道。
58
+ 提供:公司表结构、指标定义公式、标准过滤器、常用查询模板。
59
+ 适用:需要写 SQL 分析业务数据、理解公司指标定义、查询数据仓库。
60
+ 不适用:数据库管理、DDL 操作、性能调优、通用 SQL 教学。
61
+ ---
62
+ # SQL 分析技能
63
+ ## 快速工作流程
64
+ 当用户请求数据分析时:
65
+ 1. **明确需求**
66
+ - 什么时间范围?(默认当年)
67
+ - 哪个客户分群?
68
+ - 这个分析用于什么决策?
69
+ 2. **检查现有看板**
70
+ - 查看 `references/dashboards.md` 是否有现成报表
71
+ - 如果有,优先引导用户使用
72
+ 3. **确定数据源**
73
+ - 优先使用汇总表而非原始事件数据
74
+ - 查询前确认表有必需字段
75
+ 4. **执行分析**
76
+ - 应用必需过滤器(排除测试账户等)
77
+ - 用已知基准验证结果
78
+ ## 标准查询过滤器
79
+ 所有收入查询必须:
80
+ - 排除测试账户:`WHERE account != 'Test'`
81
+ - 只用完整周期:`WHERE month <= DATE_TRUNC(CURRENT_DATE(), MONTH)`
82
+ ## ARR 计算方式
83
+ - 月收入转 ARR:`monthly_revenue * 12`
84
+ - 7 日运行率:`rolling_7d * 52`
85
+ ## 详细文档
86
+ 需要表结构和查询模式时,参考:
87
+ - **收入与财务** → `references/finance.md`
88
+ - **产品使用** → `references/product.md`
89
+ - **销售管道** → `references/sales.md`
90
+ ```
91
+
92
+ ### references/finance.md(第三层)
93
+
94
+ ```md
95
+ # 财务表详细结构
96
+ ## monthly_revenue 表
97
+ | 字段 | 类型 | 说明 |
98
+ |-----|------|------|
99
+ | account_id | STRING | 账户 ID |
100
+ | month | DATE | 月份(每月第一天) |
101
+ | mrr | FLOAT | 月度经常性收入 |
102
+ | arr | FLOAT | 年度经常性收入 |
103
+ | segment | STRING | 客户分群 |
104
+ ## 常用查询
105
+ ### 按分群统计月收入
106
+ ```sql
107
+ SELECT
108
+ segment,
109
+ DATE_TRUNC(month, MONTH) as period,
110
+ SUM(mrr) as total_mrr
111
+ FROM monthly_revenue
112
+ WHERE account_id != 'Test'
113
+ GROUP BY 1, 2
114
+ ORDER BY 2 DESC, 3 DESC
115
+ ```
116
+ ```
117
+
118
+ ## Anthropic 示例:docx
119
+
120
+ ```md
121
+ ---
122
+ name: docx
123
+ description: "文档创建、编辑和分析,支持修订、批注、格式保留和文本提取。当 Claude 需要处理 .docx 文件时使用:(1) 创建新文档 (2) 修改内容 (3) 处理修订 (4) 添加批注"
124
+ license: Proprietary. LICENSE.txt has complete terms
125
+ ---
126
+ # DOCX 创建、编辑和分析
127
+ ## 概述
128
+ 用户可能要求创建、编辑或分析 .docx 文件。.docx 本质上是包含 XML 文件的 ZIP 压缩包。
129
+ ## 工作流程决策树
130
+ ### 读取/分析内容
131
+ 使用下面的"文本提取"或"原始 XML 访问"部分
132
+ ### 创建新文档
133
+ 使用"创建新 Word 文档"工作流程
134
+ ### 编辑现有文档
135
+ - **你自己的文档 + 简单修改**:使用"基础 OOXML 编辑"
136
+ - **别人的文档**:使用**修订工作流程**(推荐默认)
137
+ - **法律、学术、商业、政府文档**:**必须**使用修订工作流程
138
+ ## 文本提取
139
+ 使用 pandoc 转换为 markdown:
140
+ `pandoc --track-changes=all path-to-file.docx -o output.md`
141
+ ```