@wwkit/harness 1.0.9 → 1.0.11

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 (125) hide show
  1. package/agents/extract.md +2 -14
  2. package/agents/lint.md +368 -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 +631 -0
  8. package/commands/fix.md +77 -0
  9. package/commands/git-sync.md +218 -0
  10. package/commands/net-port.md +364 -0
  11. package/commands/pyit.md +6 -0
  12. package/commands/pyut.md +6 -0
  13. package/commands/resume.md +104 -0
  14. package/package.json +4 -2
  15. package/plugins/work-bootstrap.js +77 -0
  16. package/scripts/work-review-package +50 -0
  17. package/scripts/work-task-brief +27 -0
  18. package/scripts/work-workspace +31 -0
  19. package/skills/better-skill/SKILL.md +124 -0
  20. package/skills/blame-skill/SKILL.md +201 -0
  21. package/skills/lint-ai-fix/SKILL.md +141 -0
  22. package/skills/lint-config-setup/SKILL.md +106 -0
  23. package/skills/lint-config-setup/references/languages/js.md +110 -0
  24. package/skills/lint-config-setup/references/languages/py.md +89 -0
  25. package/skills/lint-env-ensure/SKILL.md +92 -0
  26. package/skills/lint-env-ensure/references/config.md +65 -0
  27. package/skills/lint-language-detect/SKILL.md +79 -0
  28. package/skills/lint-language-detect/references/detect-language.js +65 -0
  29. package/skills/lint-rules-analyze/SKILL.md +129 -0
  30. package/skills/lint-suitability-check/SKILL.md +84 -0
  31. package/skills/lint-tool-fix/SKILL.md +94 -0
  32. package/skills/new-skill/SKILL.md +227 -0
  33. package/skills/new-skill/references/template.md +53 -0
  34. package/skills/new-skill/references/workflow-patterns.md +104 -0
  35. package/skills/pytest-case-create/SKILL.md +327 -0
  36. package/skills/pytest-case-create/references/test-standards.md +244 -0
  37. package/skills/pytest-case-fix/SKILL.md +274 -0
  38. package/skills/pytest-coverage-analyze/SKILL.md +226 -0
  39. package/skills/pytest-coverage-analyze/references/scoring-rules.md +57 -0
  40. package/skills/pytest-env-ensure/SKILL.md +198 -0
  41. package/skills/pytest-env-ensure/references/config.md +145 -0
  42. package/skills/pytest-execute/SKILL.md +155 -0
  43. package/skills/pytest-sample/SKILL.md +164 -0
  44. package/skills/pytest-sample/references/src/pytest-sample/Calculator.py +67 -0
  45. package/skills/pytest-sample/references/src/pytest-sample/ConfigManager.py +68 -0
  46. package/skills/pytest-sample/references/src/pytest-sample/FileProcessor.py +53 -0
  47. package/skills/pytest-sample/references/src/pytest-sample/OrderService.py +82 -0
  48. package/skills/pytest-sample/references/src/pytest-sample/TokenGenerator.py +50 -0
  49. package/skills/pytest-sample/references/src/pytest-sample/UserService.py +45 -0
  50. package/skills/pytest-sample/references/src/pytest-sample/__init__.py +0 -0
  51. package/skills/pytest-suitability-check/SKILL.md +224 -0
  52. package/skills/read-docs/SKILL.md +134 -0
  53. package/skills/read-docs/references/opencode/agents/cases.md +206 -0
  54. package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -0
  55. package/skills/read-docs/references/opencode/agents/detail.md +191 -0
  56. package/skills/read-docs/references/opencode/agents/examples.md +100 -0
  57. package/skills/read-docs/references/opencode/agents/index.md +309 -0
  58. package/skills/read-docs/references/opencode/agents/parallel-dispatch.md +149 -0
  59. package/skills/read-docs/references/opencode/agents/subagent-internals.md +217 -0
  60. package/skills/read-docs/references/opencode/agents/workflow.md +161 -0
  61. package/skills/read-docs/references/opencode/cli/commands/acp.md +32 -0
  62. package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -0
  63. package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -0
  64. package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -0
  65. package/skills/read-docs/references/opencode/cli/commands/others.md +49 -0
  66. package/skills/read-docs/references/opencode/cli/commands/plugin.md +13 -0
  67. package/skills/read-docs/references/opencode/cli/commands/provider.md +44 -0
  68. package/skills/read-docs/references/opencode/cli/commands/run.md +81 -0
  69. package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -0
  70. package/skills/read-docs/references/opencode/cli/commands/session.md +38 -0
  71. package/skills/read-docs/references/opencode/cli/commands/web.md +15 -0
  72. package/skills/read-docs/references/opencode/cli/env.md +39 -0
  73. package/skills/read-docs/references/opencode/cli/index.md +19 -0
  74. package/skills/read-docs/references/opencode/cli/tui.md +35 -0
  75. package/skills/read-docs/references/opencode/commands/examples.md +42 -0
  76. package/skills/read-docs/references/opencode/commands/index.md +185 -0
  77. package/skills/read-docs/references/opencode/config/provider.md +152 -0
  78. package/skills/read-docs/references/opencode/formatter/index.md +71 -0
  79. package/skills/read-docs/references/opencode/guide/config.md +419 -0
  80. package/skills/read-docs/references/opencode/guide/formatters.md +70 -0
  81. package/skills/read-docs/references/opencode/guide/index.md +37 -0
  82. package/skills/read-docs/references/opencode/guide/providers.md +31 -0
  83. package/skills/read-docs/references/opencode/guide/rules.md +63 -0
  84. package/skills/read-docs/references/opencode/plugins/examples.md +75 -0
  85. package/skills/read-docs/references/opencode/plugins/index.md +188 -0
  86. package/skills/read-docs/references/opencode/reference/index.md +119 -0
  87. package/skills/read-docs/references/opencode/rule/index.md +78 -0
  88. package/skills/read-docs/references/opencode/skills/detail.md +113 -0
  89. package/skills/read-docs/references/opencode/skills/examples.md +141 -0
  90. package/skills/read-docs/references/opencode/skills/index.md +126 -0
  91. package/skills/read-docs/references/opencode/skills/workflow.md +146 -0
  92. package/skills/read-docs/references/opencode/tests/agent.md +10 -0
  93. package/skills/read-docs/references/opencode/tests/config.md +60 -0
  94. package/skills/read-docs/references/opencode/tests/file.md +12 -0
  95. package/skills/read-docs/references/opencode/tests/serve.md +18 -0
  96. package/skills/read-docs/references/opencode/tests/session.md +31 -0
  97. package/skills/read-docs/references/opencode/tests/web.md +17 -0
  98. package/skills/read-docs/references/opencode/tools/arguments.md +305 -0
  99. package/skills/read-docs/references/opencode/tools/context.md +18 -0
  100. package/skills/read-docs/references/opencode/tools/custom.md +111 -0
  101. package/skills/read-docs/references/opencode/tools/detail.md +104 -0
  102. package/skills/read-docs/references/opencode/tools/examples.md +71 -0
  103. package/skills/read-docs/references/opencode/tools/index.md +56 -0
  104. package/skills/read-docs/references/opencode/tools/lsp.md +26 -0
  105. package/skills/read-docs/references/opencode/tools/mcp.md +132 -0
  106. package/skills/read-docs/references/opencode/train/README.md +135 -0
  107. package/skills/read-docs/references/opencode/train/agent-basic.md +772 -0
  108. package/skills/read-docs/references/opencode/train/command-basic.md +668 -0
  109. package/skills/read-docs/references/opencode/train/config-basic.md +509 -0
  110. package/skills/read-docs/references/opencode/train/index.md +164 -0
  111. package/skills/read-docs/references/opencode/train/practice.md +873 -0
  112. package/skills/read-docs/references/opencode/train/skill-basic.md +608 -0
  113. package/skills/read-docs/references/opencode/tui/commands/config.md +32 -0
  114. package/skills/read-docs/references/opencode/tui/commands/editor.md +47 -0
  115. package/skills/read-docs/references/opencode/tui/commands/index.md +125 -0
  116. package/skills/read-docs/references/opencode/tui/commands/init.md +5 -0
  117. package/skills/read-docs/references/opencode/tui/index.md +26 -0
  118. package/skills/read-docs/references/superpowers/bootstrap.md +107 -0
  119. package/skills/read-docs/references/superpowers/comparison.md +77 -0
  120. package/skills/read-docs/references/superpowers/context.md +71 -0
  121. package/skills/read-docs/references/superpowers/index.md +58 -0
  122. package/skills/read-docs/references/superpowers/parallel.md +49 -0
  123. package/skills/read-docs/references/superpowers/sdd.md +183 -0
  124. package/skills/read-docs/references/superpowers/skills.md +68 -0
  125. package/skills/read-docs/references/superpowers/workflow.md +83 -0
@@ -0,0 +1,161 @@
1
+ # Agent 工作流
2
+
3
+ ## 模式 1:Prompt Chaining(提示链)
4
+
5
+ 将任务分解为顺序执行的步骤,每一步的输出是下一步的输入。
6
+
7
+ **适用场景**:任务可清晰分解为固定子任务,需要用延迟换取准确性。
8
+
9
+ ```md
10
+ ---
11
+ description: 多步骤翻译处理
12
+ mode: subagent
13
+ steps: 10
14
+ ---
15
+ # 任务流程
16
+ 按以下步骤执行,每步完成后再进行下一步:
17
+ ## 步骤 1:直译
18
+ 将原文逐句翻译成中文,保持原意。
19
+ ## 步骤 2:意译润色
20
+ 在直译基础上,调整为通顺的中文表达。
21
+ ## 步骤 3:专业术语检查
22
+ 检查专业术语是否准确,必要时保留英文。
23
+ ## 步骤 4:格式化
24
+ 按照目标格式(Markdown)整理输出。
25
+ # 输出要求
26
+ 每个步骤都输出中间结果,最后给出最终版本。
27
+ ```
28
+
29
+ ## 模式 2:Routing(路由)
30
+
31
+ 根据输入特征,将任务导向不同的专门处理流程。
32
+
33
+ **适用场景**:不同类别需要不同处理方式,分类可以准确完成。
34
+
35
+ ```md
36
+ ---
37
+ description: 代码问题分类路由器
38
+ mode: subagent
39
+ ---
40
+ # 角色
41
+ 你是代码问题分类专家,负责将问题路由到正确的处理流程。
42
+ # 分类规则
43
+ 分析用户的代码问题,判断属于以下哪一类:
44
+ 1. **Bug 修复** → 调用 @bug-fixer
45
+ 2. **性能优化** → 调用 @performance-optimizer
46
+ 3. **安全审计** → 调用 @security-auditor
47
+ 4. **代码重构** → 调用 @refactor-expert
48
+ 5. **新功能开发** → 不路由,直接处理
49
+ # 输出格式
50
+ 先说明分类理由,然后调用相应的 subagent。
51
+ ```
52
+
53
+ ## 模式 3:Parallelization(并行化)
54
+
55
+ 多个任务同时执行,最后汇总结果。
56
+
57
+ **两种变体**:
58
+ - **Sectioning(分片)**:独立子任务并行
59
+ - **Voting(投票)**:同一任务多视角验证
60
+
61
+ **适用场景**:子任务相互独立,需要多视角提高准确性,时间敏感需要加速。
62
+
63
+ ```md
64
+ ---
65
+ description: 代码质量并行检查器
66
+ mode: subagent
67
+ ---
68
+ # 任务
69
+ 对给定代码同时进行多维度检查。
70
+ # 并行任务
71
+ **同时**调用以下 subagent(使用多个 Task tool 调用):
72
+ 1. @security-auditor - 安全漏洞检查
73
+ 2. @performance-reviewer - 性能分析
74
+ 3. @style-checker - 代码风格检查
75
+ 4. @test-coverage-analyzer - 测试覆盖分析
76
+ # 汇总规则
77
+ 收集所有结果后,生成综合报告:
78
+ ## 综合评分
79
+ - 安全性:X/10
80
+ - 性能:X/10
81
+ - 代码风格:X/10
82
+ - 测试覆盖:X/10
83
+ - **总分**:X/40
84
+ ## 问题汇总
85
+ 按严重程度排序所有发现的问题。
86
+ ## 优先修复建议
87
+ 给出最应该优先处理的 3 个问题。
88
+ ```
89
+
90
+ ## 模式 4:Orchestrator-Workers(编排-工人)
91
+
92
+ 中央 LLM(编排器)动态分析任务,将其分解并分配给专门的 Worker Agent。
93
+
94
+ **适用场景**:无法预测需要哪些子任务,任务复杂度不确定,需要灵活应对。
95
+
96
+ ```md
97
+ ---
98
+ description: 项目分析编排器,动态分配分析任务
99
+ mode: primary
100
+ ---
101
+ # 角色
102
+ 你是项目分析编排器,负责理解用户需求并协调专家团队。
103
+ # 可用专家
104
+ - @architecture-analyst - 架构分析
105
+ - @dependency-auditor - 依赖审计
106
+ - @security-auditor - 安全审计
107
+ - @performance-profiler - 性能分析
108
+ - @docs-reviewer - 文档评审
109
+ - @test-analyzer - 测试分析
110
+ # 工作流程
111
+ 1. **理解需求**:分析用户想知道什么
112
+ 2. **制定计划**:决定需要调用哪些专家
113
+ 3. **执行分析**:调用选定的专家
114
+ 4. **整合结果**:汇总所有专家的发现
115
+ 5. **给出建议**:基于整体分析给出行动建议
116
+ # 原则
117
+ - 不要过度分析,根据用户需求选择必要的专家
118
+ - 如果用户问题简单,可能不需要任何专家
119
+ ```
120
+
121
+ ## 模式 5:Evaluator-Optimizer(评估-优化)
122
+
123
+ 一个 Agent 生成内容,另一个 Agent 评估,循环直到满足标准。
124
+
125
+ **适用场景**:有明确的评估标准,迭代改进有价值,类似人类的"写作-修改"过程。
126
+
127
+ ```md
128
+ ---
129
+ description: 迭代代码优化器
130
+ mode: subagent
131
+ steps: 15
132
+ ---
133
+ # 角色
134
+ 你是代码优化专家,通过迭代改进代码质量。
135
+ # 优化循环
136
+ ## 1. 分析阶段
137
+ - 阅读当前代码
138
+ - 识别可优化点
139
+ - 评估当前质量分数
140
+ ## 2. 优化阶段
141
+ - 选择影响最大的优化点
142
+ - 实施优化
143
+ - 确保不破坏功能
144
+ ## 3. 验证阶段
145
+ - 运行测试确保功能正常
146
+ - 重新评估质量分数
147
+ ## 4. 决策阶段
148
+ - 如果质量分数 >= 8,停止优化
149
+ - 如果质量分数提升 < 0.5,停止
150
+ - 否则,继续下一轮
151
+ # 质量评分标准
152
+ | 分数 | 可读性 | 性能 | 安全性 | 测试覆盖 |
153
+ |------|--------|------|--------|---------|
154
+ | 9-10 | 命名清晰、注释完整 | O(n)或更优 | 无漏洞 | >90% |
155
+ | 7-8 | 命名合理、关键注释 | O(n log n) | 低风险 | 70-90% |
156
+ | 5-6 | 基本可读 | O(n²) | 中风险 | 50-70% |
157
+ | <5 | 难以理解 | O(n³)+ | 高风险 | <50% |
158
+ # 失败处理
159
+ - 测试失败:立即回滚本轮修改,尝试其他方向
160
+ - 步数耗尽:输出当前最佳版本和剩余优化建议
161
+ ```
@@ -0,0 +1,32 @@
1
+ # acp
2
+ Start an ACP (Agent Client Protocol) server that communicates via stdin/stdout using nd-JSON.
3
+ ```
4
+ opencode acp
5
+
6
+ # 指定工作目录
7
+ opencode acp --cwd D:\jsapp\wego_oc
8
+
9
+ # 用 HTTP 方式
10
+ opencode acp --port 8080 --hostname 0.0.0.0
11
+ ```
12
+
13
+ ## Flags
14
+ - `--cwd` : working directory
15
+ - `--port` : Port to listen on
16
+ - `--hostname` : Hostname to listen on
17
+ - `--mdns`
18
+ - `--mdns-domain`
19
+ - `--cors`
20
+
21
+ ## ACP vs MCP
22
+ - mcp : 让Agent调用外部工具
23
+ - acp : 让外部程序调用Agent,适用场景:IDE 插件、CI/CD 流水线、自定义客户端等需要程序化调用 OpenCode Agent 能力的场景。
24
+
25
+ ## apis vs acp
26
+ - apis: OpenAPI3.1 http协议,http rest通信,适合web应用、脚本、通用集成
27
+ - acp: acp协议,stdin/stdout通信,适合IDE插件、Agent编排、流水线
28
+
29
+ ## serve and client
30
+ - `opencode` : 自动启动server,客户端为TUI
31
+ - `opencode serve` : 单独启动server,无客户端,提供 HTTP Rest API
32
+ - `opencode acp` : 单独启动server,无客户端,提供acp
@@ -0,0 +1,16 @@
1
+ ## agent
2
+ Manage agents for OpenCode (`create` or `list`).
3
+ ```
4
+ opencode agent [command]
5
+ ```
6
+
7
+ Create a new agent with custom configuration.
8
+ ```
9
+ opencode agent create
10
+ ```
11
+
12
+ List all available agents.
13
+ ```
14
+ opencode agent list
15
+ ```
16
+
@@ -0,0 +1,20 @@
1
+ # attach
2
+ Attach a terminal to an already running OpenCode backend server started via serve or web commands.
3
+
4
+ ```
5
+ opencode attach [url]
6
+
7
+ // start the backend server for web access
8
+ opencode web --port 4096 --hostname 0.0.0.0
9
+
10
+ // in another terminal, attach the TUI to the running backend
11
+ opencode attach http://10.20.30.40:4096
12
+ ```
13
+
14
+ Flags
15
+ - `--dir` Working directory to start TUI in
16
+ - `-c` Continue the last session
17
+ - `-s` Session ID to continue
18
+ - `--fork` Fork the session when continuing (use with --continue or --session)
19
+ - `-p` Basic auth password (defaults to OPENCODE_SERVER_PASSWORD)
20
+ - `-u` Basic auth username (defaults to OPENCODE_SERVER_USERNAME or opencode)
@@ -0,0 +1,37 @@
1
+ # mcp
2
+ Manage Model Context Protocol servers.
3
+ ```
4
+ opencode mcp [command]
5
+ ```
6
+
7
+ ## add
8
+ Add an MCP server to your configuration.
9
+ ```
10
+ opencode mcp add
11
+ ```
12
+
13
+ ## list
14
+ List all configured MCP servers and their connection status.
15
+ ```
16
+ opencode mcp list
17
+ ```
18
+
19
+ ## auth
20
+ Authenticate with an OAuth-enabled MCP server.
21
+ ```
22
+ opencode mcp auth [name]
23
+
24
+ opencode mcp auth list
25
+ ```
26
+
27
+ ## logout
28
+ Remove OAuth credentials for an MCP server.
29
+ ```
30
+ opencode mcp logout [name]
31
+ ```
32
+
33
+ ## debug
34
+ Debug OAuth connection issues for an MCP server.
35
+ ```
36
+ opencode mcp debug <name>
37
+ ```
@@ -0,0 +1,49 @@
1
+ # stats
2
+ Show token usage and cost statistics for your sessions.
3
+ ```
4
+ opencode stats
5
+ ```
6
+
7
+ ## Flags:
8
+ - `--days` : last N days
9
+ - `--tools` : Number of tools to show
10
+ - `--models` : Show model usage breakdown
11
+ - `--project` : Filter by project
12
+
13
+ # db
14
+ Dtabase tools
15
+ ```
16
+ opencode db [query]
17
+ ```
18
+ ## Flags
19
+ - `--format` : Output format, json or tsv
20
+
21
+ # debug
22
+ Debugging and troubleshooting tools
23
+ ```
24
+ opencode debug [command]
25
+ ```
26
+
27
+ # uninstall
28
+ Uninstall OpenCode and remove all related files.
29
+ ```
30
+ opencode uninstall
31
+ ```
32
+
33
+ ## Flags
34
+ - `--keep-config` `-c` : Keep config files
35
+ - `--keep-data` `-d` : Keep session data and snapshots
36
+ - `--dry-run` : Show what would be removed without removing
37
+ - `--force` `-f` : Skip confirmation prompts
38
+
39
+ # upgrade
40
+ Updates opencode to the latest version or a specific version
41
+ ```
42
+ // latest
43
+ opencode upgrade
44
+
45
+ // specific
46
+ opencode upgrade v0.1.48
47
+ ```
48
+ ## Flags
49
+ - `--method` `-m` : The installation method, curl/npm/pnmp/bun/brew
@@ -0,0 +1,13 @@
1
+ # plugin
2
+ Install a plugin and update your config.
3
+
4
+ ```
5
+ opencode plugin <module>
6
+
7
+ // alias
8
+ opencode plug <module>
9
+ ```
10
+
11
+ ## Flags
12
+ - `--global` `-g` : Install in global config
13
+ - `--force` `-f` : Replace existing plugin version
@@ -0,0 +1,44 @@
1
+ # auth
2
+ Command to manage credentials and login for providers.
3
+ ```
4
+ opencode auth [command]
5
+ ```
6
+
7
+ ## login
8
+
9
+ OpenCode is powered by the provider list at Models.dev, so you can use opencode auth login to configure API keys for any provider you’d like to use. This is stored in ~/.local/share/opencode/auth.json.
10
+
11
+ ```
12
+ opencode auth login
13
+ ```
14
+
15
+ When OpenCode starts up it loads the providers from the credentials file. And if there are any keys defined in your environments or a .env file in your project.
16
+
17
+ Flags
18
+ - `--provider` `-p` : Provider ID or name to log in to
19
+ - `--method` `-m` : Login method label to use, skipping method selection
20
+
21
+ ## list
22
+ Lists all the authenticated providers as stored in the credentials file.
23
+ ```
24
+ opencode auth list
25
+ opencode auth ls
26
+ ```
27
+
28
+ ## logout
29
+ Logs you out of a provider by clearing it from the credentials file.
30
+ ```
31
+ opencode auth logout
32
+ ```
33
+
34
+ # models
35
+ List all available models from configured providers in the format provider/model.
36
+ ```
37
+ opencode models [provider]
38
+
39
+ opencode models anthropic
40
+ ```
41
+
42
+ ## Flags
43
+ - `--refresh` : Refresh the models cache form models.dev
44
+ - `--verbose` : Use more verbose model output (includes metadata like costs)
@@ -0,0 +1,81 @@
1
+ # run
2
+ Run opencode in `non-interactive` mode by passing a prompt directly.
3
+ ```
4
+ opencode run [message..]
5
+ ```
6
+
7
+ ## run --attach
8
+ You can also attach to a running `opencode serve` instance to avoid MCP server cold boot times on every run:
9
+ ```
10
+ opencode serve --port 4096
11
+ opencode run --attach http://localhost:4096 "Explain async/await in JavaScript"
12
+ ```
13
+
14
+ 冷启动与attach:
15
+ - `opencode run`每次执行都要:启动进程 → 加载 MCP Server → 初始化模型 → 执行 → 退出。MCP Server 启动可能需要数秒,频繁执行时浪费时间。
16
+
17
+ 解决方案:
18
+ - 终端1:启动常驻服务器(一次性冷启动)
19
+ ```
20
+ opencode serve --port 4096
21
+ ```
22
+ - 终端n:多任务复用同一个服务器(跳过冷启动)
23
+ ```
24
+ opencode run --attach http://localhost:4096 "Explain async/await"
25
+ opencode run --attach http://localhost:4096 "Fix the bug in main.ts"
26
+ ```
27
+
28
+ ## Flags
29
+ ### Model and Perm
30
+ - `--model` `-m` : Model to use in the form of `provider/model`
31
+ - `--auto` : Auto-approve permissions that are not explicitly denied
32
+
33
+ ### Invoke
34
+ - `--command` : The command to run, use message for args
35
+ - `--agent` : Agent to use
36
+
37
+ ### Attach
38
+ - `--attach` : Attach to a running opencode server (e.g., `http://localhost:4096`)
39
+ - `--port` : Port for the local server (defaults to random port)
40
+ - `--password` `-p` : Basic auth password (defaults to `OPENCODE_SERVER_PASSWORD`)
41
+ - `--username` `-u` : Basic auth username (defaults to `OPENCODE_SERVER_USERNAME` or `opencode`)
42
+
43
+ ### IO
44
+ - `--dir` : Directory to run in, or path on the remote server when attaching
45
+ - `--file` `-f` : File(s) to attach to message
46
+ - `--format` : Format: default (formatted) or json (raw JSON events)
47
+
48
+ ### Session
49
+ - `--continue` `-c` : Continue the last session
50
+ - `--session` `-s` : Session ID to continue
51
+ - `--fork` : Fork the session when continuing (use with --continue or --session)
52
+ - `--share` : Share the session
53
+ - `--title` : Title for the session (uses truncated prompt if no value provided)
54
+
55
+ ### Thinking
56
+ - `--variant` : Model variant (provider-specific reasoning effort)
57
+ - `--thinking` : Show thinking blocks
58
+
59
+ ## Fork
60
+ - 原会话不变
61
+ - sessions列表新增一个会话
62
+ - 复制快照后独立发展
63
+
64
+ ## File
65
+ 文件内容会作为用户消息的一部分发送给模型。适合指令较长或需要复用的场景。
66
+ ```
67
+ // 不需要额外 message
68
+ opencode run -f instructions.md
69
+
70
+ // 或文件内容 + 简短补充
71
+ opencode run -f instructions.md -- "注意优先处理错误处理部分"
72
+
73
+ // multi files
74
+ opencode run -f instructions.md instructions.md -- "注意优先处理错误处理部分"
75
+ ```
76
+
77
+ ## Variant
78
+ 控制模型推理努力程度,类似OpenAI的reasoning effort参数
79
+ - `low` : 低推理,快速响应
80
+ - `medium` : 中等推理(默认)
81
+ - `high` : 高推理(深度思考,适合复杂任务)
@@ -0,0 +1,84 @@
1
+ # serve
2
+ Start a headless OpenCode server for API access without the TUI interface.
3
+ ```
4
+ opencode serve [--port <number>] [--hostname <string>] [--cors <origin>]
5
+
6
+ opencode serve --cors http://localhost:5173 --cors https://app.example.com
7
+ ```
8
+
9
+ ## Flags
10
+ - `--port` : Port to listen on, default `4096`
11
+ - `--hostname` : Hostname to listen on, default `127.0.0.1`
12
+ - `--mdns` : Enable mDNS discovery, default `false`
13
+ - `--mdns-domain` : Custom mDNS domain name, default `opencode.local`
14
+ - `--cors` : Additional browser origin to allow CORS, defualt `[]`
15
+ - can be passed multiple time
16
+
17
+ ## Authentication
18
+ Set `OPENCODE_SERVER_PASSWORD` to protect the server with HTTP basic auth.
19
+ - The username defaults to `opencode`, or set `OPENCODE_SERVER_USERNAME` to override it.
20
+ - This applies to both `opencode serve` and `opencode web`.
21
+
22
+ ```
23
+ OPENCODE_SERVER_PASSWORD=your-password opencode serve
24
+ ```
25
+
26
+ ## How it works
27
+ When you run opencode it starts a TUI and a server. You can run opencode serve to start a standalone server.
28
+
29
+ #### Connect to an existing server
30
+ When you start the TUI it randomly assigns a port and hostname. You can instead pass in the `--hostname` and `--port` flags. Then use this to connect to its server.
31
+
32
+ ## Spec
33
+ The server publishes an OpenAPI 3.1 spec that can be viewed at:
34
+ ```
35
+ http://<hostname>:<port>/doc
36
+ ```
37
+
38
+ For example, http://localhost:4096/doc. Use the spec to generate clients or inspect request and response types. Or view it in a Swagger explorer.
39
+
40
+ ## APIs
41
+ The opencode server exposes the following APIs.
42
+
43
+ ### Global
44
+ - `/global/health` : Get server health and version, `{healthy:true,version:string}`
45
+ - `/global/event` : Get global events (SSE stream)
46
+
47
+ ### Project
48
+ - `/project` : list all projects, `Project[]`
49
+ - `/project/current` : Get the current project, `Project`
50
+
51
+ ### Path & VCS
52
+ - `/path` : Get the current path, `Path`
53
+ - `/vcs` : Get VCS info for the current project, `VcsInfo`
54
+
55
+ ### Instance
56
+ - `/instance/dispose` : Dispose the current instance, `boolean`
57
+
58
+ ## Config
59
+
60
+ ## Provider
61
+
62
+ ## Sessions
63
+
64
+ ## Messages
65
+
66
+ ## Commands
67
+
68
+ ## Files
69
+
70
+ ## Tools
71
+
72
+ ## LSP
73
+
74
+ ## Agents
75
+
76
+ ## Logging
77
+
78
+ ## TUI
79
+
80
+ ## Auth
81
+
82
+ ## Evetns
83
+
84
+ ## Docs
@@ -0,0 +1,38 @@
1
+ # session
2
+ Manage sessions
3
+ ```
4
+ // list all sessions
5
+ opencode session list
6
+
7
+ // delete an session
8
+ opencode session delete <sessionID>
9
+ ```
10
+
11
+ ## Flags:
12
+ - `--max-count` `-n` : limit to N most recent sessions
13
+ - `--format` : Output format : table or json
14
+
15
+ # export
16
+ Export session data as JSON
17
+ ```
18
+ opencode export [sessionID]
19
+
20
+ # write to a file
21
+ opencode export ses_0cadb81d5ffernOJ0n2SD1FZ6S > ses_0cadb81d5ffernOJ0n2SD1FZ6S.json
22
+ ```
23
+ If you don’t provide a session ID, you’ll be prompted to select from available sessions.
24
+
25
+ ## Flags
26
+ - `--sanitize` : Redact sensitive transcript/file data
27
+
28
+ # import
29
+ Import session data from a JSON file or share URL.
30
+ ```
31
+ opencode import <file>
32
+
33
+ // local file
34
+ opencode import session.json
35
+
36
+ // share url
37
+ opencode import https://opncd.ai/s/abc123
38
+ ```
@@ -0,0 +1,15 @@
1
+ # web
2
+ Start a headless OpenCode server with a web interface.
3
+ ```
4
+ opencode web
5
+ ```
6
+ This starts an HTTP server and opens a web browser to access OpenCode through a web interface.
7
+
8
+ Set `OPENCODE_SERVER_PASSWORD` to enable HTTP basic auth (username defaults to `opencode`).
9
+
10
+ ## Flags
11
+ - `--port` : Port to listen on
12
+ - `--hostname` : Hostname to listen on
13
+ - `--mdns`
14
+ - `--mdns-domain`
15
+ - `--cors`
@@ -0,0 +1,39 @@
1
+ # Environment variables
2
+ OpenCode can be configured using environment variables.
3
+
4
+ ## path
5
+ - `OPENCODE_GIT_BASH_PATH` : `string` Path to git bash executable on Windows
6
+ - `OPENCODE_TUI_CONFIG` : `string` Path to TUI config file
7
+ - `OPENCODE_CONFIG` : `string` Path to config file
8
+ - `OPENCODE_CONFIG_DIR` : `string` Path to config directory
9
+ - `OPENCODE_MODELS_URL` : `string` Custom URL for fetching models configuration
10
+
11
+ 设置`OPENCODE_CONFIG`的会与全局`~/.config/opencode`合并。
12
+
13
+ ## config
14
+ - `OPENCODE_CONFIG_CONTENT` : `string` Inline json config content
15
+ - `OPENCODE_PERMISSION` : `string` Inline json permission config
16
+
17
+ ## session
18
+ - `OPENCODE_AUTO_SHARE` : `boolean` Automatically share sessions
19
+
20
+ ## server
21
+ - `OPENCODE_SERVER_PASSWORD` : `string` Enable basic auth for serve/web
22
+ - `OPENCODE_SERVER_USERNAME` : `string` Override basic auth username (default opencode)
23
+
24
+ ## enable
25
+ - `OPENCODE_ENABLE_EXPERIMENTAL_MODELS` : `boolean` Enable experimental models
26
+ - `OPENCODE_ENABLE_EXA` : `boolean` Enable Exa web search tools
27
+
28
+ ## disable
29
+ - `OPENCODE_DISABLE_AUTOUPDATE` : `boolean` Disable automatic udpate checks
30
+ - `OPENCODE_DISABLE_PRUNE` : `boolean` Disable pruning of old data
31
+ - `OPENCODE_DISABLE_TERMINAL_TITLE` : `boolean` Disable automatic terminal title updates
32
+ - `OPENCODE_DISABLE_DEFAULT_PLUGINS` : `boolean` Disable default plugins
33
+ - `OPENCODE_DISABLE_LSP_DOWNLOAD` : `boolean` Disable automatic LSP server downloads
34
+ - `OPENCODE_DISABLE_AUTOCOMPACT` : `boolean` Disable automatic context compaction
35
+ - `OPENCODE_DISABLE_CLAUDE_CODE` : `boolean` Disable reading from `.claude` (prompt + skills)
36
+ - `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` : `boolean` Disable reading `~/.claude/CLAUDE.md`
37
+ - `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` : `boolean` Disable loading `.claude/skills`
38
+ - `OPENCODE_DISABLE_MODELS_FETCH` : `boolean` Disable fetching models from remote sources
39
+ - `OPENCODE_DISABLE_MOUSE` : `boolean` Disable mouse capture in the TUI
@@ -0,0 +1,19 @@
1
+ # CLI
2
+ OpenCode CLI options and commands.
3
+
4
+ The OpenCode CLI by default starts the TUI when run without any arguments.
5
+ ```
6
+ opencode
7
+ ```
8
+
9
+ But it also accepts commands as documented on this page. This allows you to interact with OpenCode programmatically.
10
+ ```
11
+ opencode run "Explain how closures work in JavaScript"
12
+ ```
13
+
14
+ ## Global Flags
15
+ - `--help` `-h` : Display help
16
+ - `--version` `-v` : Print version number
17
+ - `--print-logs` : Print logs to stderr
18
+ - `--log-level` : Log Level, DEBUG,INFO,WARN,ERROR
19
+ - `--pure` : Run without external plugins
@@ -0,0 +1,35 @@
1
+ # TUI
2
+ The OpenCode CLI by default starts the TUI when run without any arguments.
3
+ ```
4
+ opencode
5
+ ```
6
+
7
+ ## Flags
8
+ - `--continue` `-c` : Continue the last session
9
+ - `--session` `-s` : Session ID to continue
10
+ - `--model` `-m` : Model to use in the form of `provider/model`
11
+ - `--agent` : Agent to use
12
+ - `--auto` : Auto-approve permissions that are not explicitly denied
13
+
14
+ ### --auto
15
+ 结合 opencode.json 中的 permission 配置理解:
16
+ ```json
17
+ {
18
+ "permission": {
19
+ "skill": { "*": "allow" }, // 技能调用:全部允许
20
+ "agent": { "*": "allow" }, // Agent 调用:全部允许
21
+ "command": { "*": "deny" } // 命令执行:拒绝
22
+ }
23
+ }
24
+ ```
25
+ - permission 中设为 "allow" 的 → 始终自动批准
26
+ - permission 中设为 "deny" 的 → 始终拒绝
27
+ - 未在 permission 中配置的 → 默认需手动确认,但 --auto 会将其自动批准
28
+ 简单说:--auto = 免确认模式,适合自动化流水线或信任当前操作环境的场景。
29
+
30
+ ### web服务配置
31
+ - `--hostname 0.0.0.0` : Hostname to listen on,默认`localhost`仅本机可访问
32
+ - `--port 8081` : Port to listen on, 默认`3000`
33
+ - `--mdns` : 启动 mDNS 局域网,默认关闭
34
+ - `--mdns-domain opencode.local` : 自定义mDNS域名
35
+ - `--cors http://myapp.com` : 允许跨域浏览器来源,,默认仅本机