oh-my-opencode-cohub 1.0.0
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 -0
- package/README.md +154 -0
- package/dist/cli/config-io.d.ts +21 -0
- package/dist/cli/config-io.d.ts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +211 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +745 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions/chinese.d.ts +2 -0
- package/dist/instructions/chinese.d.ts.map +1 -0
- package/dist/instructions/chinese.js +9 -0
- package/dist/instructions/chinese.js.map +1 -0
- package/dist/prompts/council.d.ts +2 -0
- package/dist/prompts/council.d.ts.map +1 -0
- package/dist/prompts/council.js +63 -0
- package/dist/prompts/council.js.map +1 -0
- package/dist/prompts/designer.d.ts +2 -0
- package/dist/prompts/designer.d.ts.map +1 -0
- package/dist/prompts/designer.js +66 -0
- package/dist/prompts/designer.js.map +1 -0
- package/dist/prompts/explorer.d.ts +2 -0
- package/dist/prompts/explorer.d.ts.map +1 -0
- package/dist/prompts/explorer.js +37 -0
- package/dist/prompts/explorer.js.map +1 -0
- package/dist/prompts/fixer.d.ts +2 -0
- package/dist/prompts/fixer.d.ts.map +1 -0
- package/dist/prompts/fixer.js +52 -0
- package/dist/prompts/fixer.js.map +1 -0
- package/dist/prompts/librarian.d.ts +2 -0
- package/dist/prompts/librarian.d.ts.map +1 -0
- package/dist/prompts/librarian.js +29 -0
- package/dist/prompts/librarian.js.map +1 -0
- package/dist/prompts/observer.d.ts +2 -0
- package/dist/prompts/observer.d.ts.map +1 -0
- package/dist/prompts/observer.js +26 -0
- package/dist/prompts/observer.js.map +1 -0
- package/dist/prompts/oracle.d.ts +2 -0
- package/dist/prompts/oracle.d.ts.map +1 -0
- package/dist/prompts/oracle.js +31 -0
- package/dist/prompts/oracle.js.map +1 -0
- package/dist/prompts/orchestrator.d.ts +2 -0
- package/dist/prompts/orchestrator.d.ts.map +1 -0
- package/dist/prompts/orchestrator.js +239 -0
- package/dist/prompts/orchestrator.js.map +1 -0
- package/dist/prompts/planner.d.ts +2 -0
- package/dist/prompts/planner.d.ts.map +1 -0
- package/dist/prompts/planner.js +12 -0
- package/dist/prompts/planner.js.map +1 -0
- package/dist/prompts/rule-app.d.ts +2 -0
- package/dist/prompts/rule-app.d.ts.map +1 -0
- package/dist/prompts/rule-app.js +6 -0
- package/dist/prompts/rule-app.js.map +1 -0
- package/dist/prompts/rule-project.d.ts +2 -0
- package/dist/prompts/rule-project.d.ts.map +1 -0
- package/dist/prompts/rule-project.js +6 -0
- package/dist/prompts/rule-project.js.map +1 -0
- package/dist/prompts/rule-user.d.ts +2 -0
- package/dist/prompts/rule-user.d.ts.map +1 -0
- package/dist/prompts/rule-user.js +6 -0
- package/dist/prompts/rule-user.js.map +1 -0
- package/dist/task-manager/tracker.d.ts +36 -0
- package/dist/task-manager/tracker.d.ts.map +1 -0
- package/dist/task-manager/tracker.js +117 -0
- package/dist/task-manager/tracker.js.map +1 -0
- package/dist/task-manager/types.d.ts +18 -0
- package/dist/task-manager/types.d.ts.map +1 -0
- package/dist/task-manager/types.js +2 -0
- package/dist/task-manager/types.js.map +1 -0
- package/dist/tui.d.ts +4 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +127 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# oh-my-opencode-cohub
|
|
2
|
+
|
|
3
|
+
OpenCode 中文智能体编排插件 CoHub——纯调度模式、全中文提示词、规范分析代理、方案制定代理。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🚀 **独立运行**:纯 OpenCode Plugin,依赖 `@opencode-ai/plugin` SDK,零外部插件依赖
|
|
8
|
+
- 🤖 **12 个内置代理**:8 个通用代理(orchestrator/oracle/librarian/explorer/designer/fixer/observer/council)+ 4 个规范/方案代理(rule-user/rule-project/rule-app/planner)
|
|
9
|
+
- 🪝 **自动注入**:通过 `system.transform` 钩子在每次 LLM 调用时注入中文语言要求
|
|
10
|
+
- 🧠 **纯调度 Orchestrator**:不碰任何文件工具,只负责规划、委派、验证
|
|
11
|
+
- 🇨🇳 **全中文提示词**:8 个内置代理 + 4 个插件代理全中文
|
|
12
|
+
- 📋 **规范分析代理**:rule-user(用户AGENTS.md)、rule-project(项目AGENTS.md)、rule-app(.opencode/rules/)
|
|
13
|
+
- 🎯 **方案制定代理**:planner 综合所有输入输出结构化任务分解
|
|
14
|
+
- 🔗 **OpenSpec + Superpowers 死板路由**:收到需求即触发,不判断"大小"
|
|
15
|
+
- ⚡ **六步工作流**:理解→收集→规范分析→制定方案→调度→验证
|
|
16
|
+
- 📜 **AGENTS.md 全覆盖**:项目级和用户级 AGENTS.md 对**本插件所有代理**(内置 8 个 + 插件 4 个)均生效,无需额外配置
|
|
17
|
+
|
|
18
|
+
## 快速开始
|
|
19
|
+
|
|
20
|
+
### 安装
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install oh-my-opencode-cohub
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 配置 opencode.json
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"plugin": ["oh-my-opencode-cohub"]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
重启 OpenCode 即可。12 个代理自动注册,中文语言要求自动注入。
|
|
35
|
+
|
|
36
|
+
### 使用方式
|
|
37
|
+
|
|
38
|
+
安装后,OpenCode 会自动:
|
|
39
|
+
- 加载中文代理提示词
|
|
40
|
+
- 注册 4 个插件代理:@rule-user、@rule-project、@rule-app、@planner
|
|
41
|
+
- 注入中文语言要求
|
|
42
|
+
- 所有代理(包括 @rule-user、@rule-project、@rule-app、@planner)自动继承项目级和用户级 AGENTS.md 规则
|
|
43
|
+
|
|
44
|
+
## 代理一览
|
|
45
|
+
|
|
46
|
+
### 代理(12 个,全中文提示词)
|
|
47
|
+
|
|
48
|
+
| 代理 | 模型 | 职责 | 读取源 |
|
|
49
|
+
|------|------|------|--------|
|
|
50
|
+
| orchestrator | 见默认配置 | 纯调度:规划→委派→验证 | — |
|
|
51
|
+
| oracle | 见默认配置 | 架构审查/代码审查(含 Superpowers skills) | — |
|
|
52
|
+
| librarian | 见默认配置 | 外部文档/API 研究 | — |
|
|
53
|
+
| explorer | 见默认配置 | 代码库搜索定位 | — |
|
|
54
|
+
| designer | 见默认配置 | UI/UX 设计与实现 | — |
|
|
55
|
+
| fixer | 见默认配置 | 代码修改执行(含 TDD skill) | — |
|
|
56
|
+
| observer | 见默认配置 | 图片/PDF 分析 | — |
|
|
57
|
+
| council | 见默认配置 | 多模型共识 | — |
|
|
58
|
+
| rule-user | 见默认配置 | 用户级规范分析 | `~/.config/opencode/AGENTS.md` |
|
|
59
|
+
| rule-project | 见默认配置 | 项目级规范分析 | 项目 `AGENTS.md` |
|
|
60
|
+
| rule-app | 见默认配置 | 应用规则分析 | `.opencode/rules/*.md` |
|
|
61
|
+
| planner | 见默认配置 | 方案制定 | 综合需求+信息+规则 |
|
|
62
|
+
|
|
63
|
+
> 模型通过 `DEFAULT_MODELS` 常量配置,默认使用 DeepSeek,可通过 plugin config 覆盖任意代理模型。
|
|
64
|
+
|
|
65
|
+
## 工作流
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
1. 理解需求
|
|
69
|
+
2. 信息收集(@explorer / @librarian / @observer)
|
|
70
|
+
3. 规范分析(并行 @rule-user / @rule-project / @rule-app)
|
|
71
|
+
4. 制定方案 → @planner
|
|
72
|
+
5. 调度执行(@fixer / @designer 等)
|
|
73
|
+
6. 验证(@oracle / @designer)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 依赖
|
|
77
|
+
|
|
78
|
+
- OpenCode
|
|
79
|
+
- `@opencode-ai/plugin`(TypeScript 编译依赖)
|
|
80
|
+
- 无其他外部插件依赖
|
|
81
|
+
|
|
82
|
+
## 自定义模型
|
|
83
|
+
|
|
84
|
+
通过 `opencode.json` 的 plugin config 覆盖默认模型:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"plugin": [
|
|
89
|
+
{
|
|
90
|
+
"name": "oh-my-opencode-cohub",
|
|
91
|
+
"config": {
|
|
92
|
+
"models": {
|
|
93
|
+
"orchestrator": "openai/gpt-5.5",
|
|
94
|
+
"fixer": "openai/gpt-5.4-mini"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 自定义提示词
|
|
103
|
+
|
|
104
|
+
### 方式一:通过 plugin config 覆盖(推荐)
|
|
105
|
+
|
|
106
|
+
在 `opencode.json` 的 plugin config 中传入自定义 prompt:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"plugin": [
|
|
111
|
+
{
|
|
112
|
+
"name": "oh-my-opencode-cohub",
|
|
113
|
+
"config": {
|
|
114
|
+
"overrides": {
|
|
115
|
+
"oracle": "你是我的自定义 Oracle 代理——负责代码审查和安全审计……",
|
|
116
|
+
"fixer": "你是我的自定义 Fixer 代理——只做 Python 代码修改……"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
支持覆盖的代理名称:`orchestrator`、`oracle`、`librarian`、`explorer`、`designer`、`fixer`、`observer`、`council`、`rule-user`、`rule-project`、`rule-app`、`planner`
|
|
125
|
+
|
|
126
|
+
### 方式二:文件覆盖(类 oh-my-opencode-slim 机制)
|
|
127
|
+
|
|
128
|
+
在项目 `.opencode/oh-my-opencode-cohub/` 或 `~/.config/opencode/oh-my-opencode-cohub/` 目录下创建 `{agent}.md` 文件:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
oh-my-opencode-cohub/
|
|
132
|
+
├── oracle.md ← 完全替换 oracle 提示词
|
|
133
|
+
├── fixer_append.md ← 追加到 fixer 提示词末尾
|
|
134
|
+
└── planner.md ← 完全替换 planner 提示词
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
文件名规则:
|
|
138
|
+
- `{agent}.md` —— 完全替换该代理的内置提示词
|
|
139
|
+
- `{agent}_append.md` —— 追加内容到内置提示词末尾
|
|
140
|
+
|
|
141
|
+
查找优先级:项目 `.opencode/` > `~/.config/opencode/`
|
|
142
|
+
|
|
143
|
+
### 方式三:Fork 并修改源码
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# 修改 src/prompts/oracle.ts 并重新编译
|
|
147
|
+
npm run build
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
适合深度定制,但需维护自己的分支。
|
|
151
|
+
|
|
152
|
+
## 许可证
|
|
153
|
+
|
|
154
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** 添加 CoHub 到 opencode.json 的 plugin 数组 */
|
|
2
|
+
export declare function addPluginToOpenCodeConfig(): {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
/** 添加 CoHub 到 tui.json 的 plugin 数组 */
|
|
7
|
+
export declare function addPluginToTuiConfig(): {
|
|
8
|
+
success: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
/** 将 co-orchestrator 注册到 opencode.json 的 agent 字段(TAB 切换必需——插件系统无法设 primary) */
|
|
12
|
+
export declare function registerCoOrchestratorToAgent(): {
|
|
13
|
+
success: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
/** 卸载 CoHub——精确清理,不碰其他插件数据 */
|
|
17
|
+
export declare function uninstallCoHub(): {
|
|
18
|
+
success: boolean;
|
|
19
|
+
messages: string[];
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=config-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-io.d.ts","sourceRoot":"","sources":["../../src/cli/config-io.ts"],"names":[],"mappings":"AA4BA,2CAA2C;AAC3C,wBAAgB,yBAAyB,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAajF;AAED,sCAAsC;AACtC,wBAAgB,oBAAoB,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAa5E;AAOD,gFAAgF;AAChF,wBAAgB,6BAA6B,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAuBrF;AAED,8BAA8B;AAC9B,wBAAgB,cAAc,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAuGzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/config-io.ts
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import * as os from "node:os";
|
|
7
|
+
var PACKAGE_NAME = "oh-my-opencode-cohub";
|
|
8
|
+
function getOpencodeConfigPath() {
|
|
9
|
+
return path.join(os.homedir(), ".config", "opencode", "opencode.json");
|
|
10
|
+
}
|
|
11
|
+
function getTuiConfigPath() {
|
|
12
|
+
return path.join(os.homedir(), ".config", "opencode", "tui.json");
|
|
13
|
+
}
|
|
14
|
+
function readJSON(filePath) {
|
|
15
|
+
try {
|
|
16
|
+
if (!fs.existsSync(filePath))
|
|
17
|
+
return null;
|
|
18
|
+
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function writeJSON(filePath, data) {
|
|
24
|
+
const dir = path.dirname(filePath);
|
|
25
|
+
if (!fs.existsSync(dir))
|
|
26
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
27
|
+
const content = JSON.stringify(data, null, 2) + `
|
|
28
|
+
`;
|
|
29
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
30
|
+
}
|
|
31
|
+
function addPluginToOpenCodeConfig() {
|
|
32
|
+
const configPath = getOpencodeConfigPath();
|
|
33
|
+
let config = readJSON(configPath) ?? {};
|
|
34
|
+
const plugins = Array.isArray(config.plugin) ? [...config.plugin] : [];
|
|
35
|
+
if (plugins.some((p) => p.includes(PACKAGE_NAME))) {
|
|
36
|
+
return { success: true, message: "CoHub 已在 opencode.json 的 plugin 数组中,跳过" };
|
|
37
|
+
}
|
|
38
|
+
plugins.unshift(PACKAGE_NAME);
|
|
39
|
+
config.plugin = plugins;
|
|
40
|
+
writeJSON(configPath, config);
|
|
41
|
+
return { success: true, message: `✓ 已添加 "${PACKAGE_NAME}" 到 opencode.json 的 plugin 数组` };
|
|
42
|
+
}
|
|
43
|
+
function addPluginToTuiConfig() {
|
|
44
|
+
const configPath = getTuiConfigPath();
|
|
45
|
+
let config = readJSON(configPath) ?? {};
|
|
46
|
+
const plugins = Array.isArray(config.plugin) ? [...config.plugin] : [];
|
|
47
|
+
if (plugins.some((p) => p.includes(PACKAGE_NAME))) {
|
|
48
|
+
return { success: true, message: "CoHub 已在 tui.json 的 plugin 数组中,跳过" };
|
|
49
|
+
}
|
|
50
|
+
plugins.unshift(PACKAGE_NAME);
|
|
51
|
+
config.plugin = plugins;
|
|
52
|
+
writeJSON(configPath, config);
|
|
53
|
+
return { success: true, message: `✓ 已添加 "${PACKAGE_NAME}" 到 tui.json 的 plugin 数组` };
|
|
54
|
+
}
|
|
55
|
+
function getOhMyConfigPath() {
|
|
56
|
+
return path.join(os.homedir(), ".config", "opencode", "oh-my-opencode-slim.json");
|
|
57
|
+
}
|
|
58
|
+
function registerCoOrchestratorToAgent() {
|
|
59
|
+
const configPath = getOpencodeConfigPath();
|
|
60
|
+
let config = readJSON(configPath);
|
|
61
|
+
if (!config) {
|
|
62
|
+
config = {};
|
|
63
|
+
}
|
|
64
|
+
config.agent = config.agent ?? {};
|
|
65
|
+
const agents = config.agent;
|
|
66
|
+
if (agents["co-orchestrator"]) {
|
|
67
|
+
return { success: true, message: "co-orchestrator 已存在于 opencode.json 的 agent 字段,跳过" };
|
|
68
|
+
}
|
|
69
|
+
agents["co-orchestrator"] = {
|
|
70
|
+
description: "纯调度者——理解需求→委派→方案→执行→验证",
|
|
71
|
+
mode: "primary",
|
|
72
|
+
prompt: "你是 CoHub 纯调度者(Orchestrator)。唯一职责:理解需求 → 委派信息收集 → 制定方案 → 调度子代理执行 → 委派验证。用中文思考和回复。",
|
|
73
|
+
model: "deepseek/deepseek-v4-pro"
|
|
74
|
+
};
|
|
75
|
+
writeJSON(configPath, config);
|
|
76
|
+
return { success: true, message: "✓ 已将 co-orchestrator (primary) 注册到 opencode.json 的 agent 字段" };
|
|
77
|
+
}
|
|
78
|
+
function uninstallCoHub() {
|
|
79
|
+
const messages = [];
|
|
80
|
+
const configPath = getOpencodeConfigPath();
|
|
81
|
+
let config = readJSON(configPath);
|
|
82
|
+
if (config) {
|
|
83
|
+
const plugins = Array.isArray(config.plugin) ? [...config.plugin] : [];
|
|
84
|
+
const before = plugins.length;
|
|
85
|
+
const filtered = plugins.filter((p) => {
|
|
86
|
+
if (typeof p === "string") {
|
|
87
|
+
return !p.includes("oh-my-opencode-cohub") && !p.includes("Desktop.*cohub");
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
});
|
|
91
|
+
if (filtered.length < before) {
|
|
92
|
+
config.plugin = filtered;
|
|
93
|
+
messages.push("✓ 已从 opencode.json 的 plugin 数组移除 CoHub");
|
|
94
|
+
}
|
|
95
|
+
if (config.agent && typeof config.agent === "object") {
|
|
96
|
+
const agents = config.agent;
|
|
97
|
+
if (agents["co-orchestrator"]) {
|
|
98
|
+
delete agents["co-orchestrator"];
|
|
99
|
+
messages.push("✓ 已从 opencode.json 的 agent 字段移除 co-orchestrator");
|
|
100
|
+
}
|
|
101
|
+
if (Object.keys(agents).length === 0) {
|
|
102
|
+
delete config.agent;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
writeJSON(configPath, config);
|
|
106
|
+
} else {
|
|
107
|
+
messages.push("⚠ opencode.json 不存在,跳过");
|
|
108
|
+
}
|
|
109
|
+
const tuiPath = getTuiConfigPath();
|
|
110
|
+
if (fs.existsSync(tuiPath)) {
|
|
111
|
+
const tuiConfig = readJSON(tuiPath);
|
|
112
|
+
if (tuiConfig) {
|
|
113
|
+
const tuiPlugins = Array.isArray(tuiConfig.plugin) ? [...tuiConfig.plugin] : [];
|
|
114
|
+
const before = tuiPlugins.length;
|
|
115
|
+
const filtered = tuiPlugins.filter((p) => {
|
|
116
|
+
if (typeof p === "string") {
|
|
117
|
+
return !p.includes("oh-my-opencode-cohub") && !p.includes("Desktop.*cohub");
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
});
|
|
121
|
+
if (filtered.length < before) {
|
|
122
|
+
tuiConfig.plugin = filtered;
|
|
123
|
+
writeJSON(tuiPath, tuiConfig);
|
|
124
|
+
messages.push("✓ 已从 tui.json 的 plugin 数组移除 CoHub");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const tuiStatePath = path.join(os.homedir(), ".local", "share", "opencode", "storage", "oh-my-opencode-slim", "tui-state.json");
|
|
129
|
+
if (fs.existsSync(tuiStatePath)) {
|
|
130
|
+
let tuiState = readJSON(tuiStatePath);
|
|
131
|
+
if (tuiState) {
|
|
132
|
+
let cleaned = false;
|
|
133
|
+
if (tuiState.agentModels && typeof tuiState.agentModels === "object") {
|
|
134
|
+
const models = tuiState.agentModels;
|
|
135
|
+
for (const key of Object.keys(models)) {
|
|
136
|
+
if (key.startsWith("co-")) {
|
|
137
|
+
delete models[key];
|
|
138
|
+
cleaned = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (tuiState.agentVariants && typeof tuiState.agentVariants === "object") {
|
|
143
|
+
const variants = tuiState.agentVariants;
|
|
144
|
+
for (const key of Object.keys(variants)) {
|
|
145
|
+
if (key.startsWith("co-")) {
|
|
146
|
+
delete variants[key];
|
|
147
|
+
cleaned = true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (cleaned) {
|
|
152
|
+
writeJSON(tuiStatePath, tuiState);
|
|
153
|
+
messages.push("✓ 已清理 tui-state.json 中的 co-* 残留(未影响其他插件数据)");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const ohMyPath = getOhMyConfigPath();
|
|
158
|
+
if (fs.existsSync(ohMyPath)) {
|
|
159
|
+
let ohMyConfig = readJSON(ohMyPath);
|
|
160
|
+
if (ohMyConfig && ohMyConfig.agents && typeof ohMyConfig.agents === "object") {
|
|
161
|
+
let cleanedOhMy = false;
|
|
162
|
+
const agents = ohMyConfig.agents;
|
|
163
|
+
for (const key of Object.keys(agents)) {
|
|
164
|
+
if (key.startsWith("co-")) {
|
|
165
|
+
delete agents[key];
|
|
166
|
+
cleanedOhMy = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (cleanedOhMy) {
|
|
170
|
+
writeJSON(ohMyPath, ohMyConfig);
|
|
171
|
+
messages.push("✓ 已清理 oh-my-opencode-slim.json agents 字段中的 co-* 代理");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
messages.push("✅ CoHub 卸载完成。完全关闭 OpenCode 后重新打开即可。");
|
|
176
|
+
return { success: true, messages };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/cli/index.ts
|
|
180
|
+
async function main() {
|
|
181
|
+
const args = process.argv.slice(2);
|
|
182
|
+
const command = args[0];
|
|
183
|
+
if (command === "install") {
|
|
184
|
+
console.log(`\uD83D\uDE80 CoHub v1.0 安装中...
|
|
185
|
+
`);
|
|
186
|
+
const r1 = addPluginToOpenCodeConfig();
|
|
187
|
+
console.log(r1.message);
|
|
188
|
+
const r2 = addPluginToTuiConfig();
|
|
189
|
+
console.log(r2.message);
|
|
190
|
+
const r3 = registerCoOrchestratorToAgent();
|
|
191
|
+
console.log(r3.message);
|
|
192
|
+
console.log(`
|
|
193
|
+
✅ CoHub 安装完成!`);
|
|
194
|
+
console.log(' 重启 OpenCode 后,TAB 选择 "co-orchestrator" 开始纯调度模式。');
|
|
195
|
+
console.log(" 右侧面板可查看 12 个代理的运行状态。");
|
|
196
|
+
} else if (command === "uninstall") {
|
|
197
|
+
console.log(`\uD83E\uDDF9 CoHub 卸载中...
|
|
198
|
+
`);
|
|
199
|
+
const result = uninstallCoHub();
|
|
200
|
+
for (const msg of result.messages) {
|
|
201
|
+
console.log(msg);
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
console.log("CoHub - OpenCode 中文智能体编排插件");
|
|
205
|
+
console.log("");
|
|
206
|
+
console.log("用法:");
|
|
207
|
+
console.log(" bunx oh-my-opencode-cohub install 安装 CoHub");
|
|
208
|
+
console.log(" bunx oh-my-opencode-cohub uninstall 卸载 CoHub");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
main().catch(console.error);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Plugin } from '@opencode-ai/plugin';
|
|
2
|
+
/** 中文提示词映射表 —— 供外部使用 */
|
|
3
|
+
export declare const CHINESE_PROMPTS: Record<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* 中文语言指令 —— 可注入到 AGENTS.md 或 instructions
|
|
6
|
+
*/
|
|
7
|
+
export declare const CHINESE_INSTRUCTION = "# \u4E2D\u6587\u8BED\u8A00\u8981\u6C42\n\n\u4F60\u5FC5\u987B\u59CB\u7EC8\u4F7F\u7528\u4E2D\u6587\u8FDB\u884C\u601D\u8003\u3001\u63A8\u7406\u548C\u56DE\u590D\u3002\n\n- \u6240\u6709\u81EA\u7136\u8BED\u8A00\u90E8\u5206\uFF08\u5206\u6790\u3001\u89C4\u5212\u3001\u89E3\u91CA\u3001\u8BA8\u8BBA\uFF09\u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\n- \u4EE3\u7801\u3001\u6280\u672F\u672F\u8BED\u3001\u6587\u4EF6\u540D\u3001\u547D\u4EE4\u53EF\u4EE5\u4FDD\u7559\u539F\u6837\n- \u6B64\u89C4\u5219\u5BF9\u6240\u6709\u4EE3\u7406\uFF08Orchestrator \u548C\u6240\u6709\u5B50\u4EE3\u7406\uFF09\u751F\u6548\n- \u8DE8\u6240\u6709\u9879\u76EE\u751F\u6548\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E\u9879\u76EE\u7EA7\u89C4\u5219";
|
|
8
|
+
declare const CoHubPlugin: Plugin;
|
|
9
|
+
export default CoHubPlugin;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAoClD,wBAAwB;AACxB,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAalD,CAAC;AAwEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,wrBAA+B,CAAC;AAEhE,QAAA,MAAM,WAAW,EAAE,MAkKlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|