my-opencode 1.3.1 → 1.3.3
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/README.md +18 -1
- package/bin/cli.js +35 -11
- package/opencode.json +7 -7
- package/package.json +1 -1
- package/plugins/README.md +1 -1
- package/plugins/provider-profile.mjs +3 -3
package/README.md
CHANGED
|
@@ -17,12 +17,29 @@ npx my-opencode init
|
|
|
17
17
|
|
|
18
18
|
# 安裝到指定專案
|
|
19
19
|
npx my-opencode init ./my-project
|
|
20
|
+
|
|
21
|
+
# 覆寫既有檔案(升級用)
|
|
22
|
+
npx my-opencode init --force
|
|
20
23
|
```
|
|
21
24
|
|
|
22
25
|
這會在你的專案下建立 `.opencode/`,包含 `skills/`、`agents/`、`plugins/`、`opencode.json`。
|
|
23
26
|
|
|
24
27
|
opencode 會自動發現 `.opencode/opencode.json`,無需額外設定。
|
|
25
28
|
|
|
29
|
+
### 升級到最新版
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 1. 更新 npm 套件
|
|
33
|
+
npm install my-opencode@latest
|
|
34
|
+
|
|
35
|
+
# 2. 覆寫既有 .opencode/ 檔案(預設會跳過已存在檔案)
|
|
36
|
+
npx my-opencode init --force
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> ⚠️ `init` 預設「已存在就跳過」以保護你客製化的檔案。
|
|
40
|
+
> `--force`(alias `-f` / `--overwrite`)才會覆寫 skills/agents/plugins/opencode.json。
|
|
41
|
+
> 若只想保留自己改過的 `opencode.json`,可先備份再執行 `--force`。
|
|
42
|
+
|
|
26
43
|
---
|
|
27
44
|
|
|
28
45
|
### 本地開發(git clone)
|
|
@@ -67,7 +84,7 @@ npx my-opencode help # 顯示說明
|
|
|
67
84
|
|
|
68
85
|
| Profile | Primary / heavy | Small / verifier |
|
|
69
86
|
|---------|------------------|------------------|
|
|
70
|
-
| `opencode` | `opencode/
|
|
87
|
+
| `opencode` | `opencode-go/deepseek-v4-pro` | `opencode-go/deepseek-v4-flash` |
|
|
71
88
|
| `openai` | `openai/gpt-5.4` | `openai/gpt-5.4-mini` |
|
|
72
89
|
| `google` | `google/gemini-3.1-pro-preview-customtools` | `google/gemini-3.5-flash` |
|
|
73
90
|
| `copilot` | `copilot/gpt-5.4` | `copilot/gpt-5.4-mini` |
|
package/bin/cli.js
CHANGED
|
@@ -118,8 +118,9 @@ function cmdHelp() {
|
|
|
118
118
|
✓ 不寫入 package.json
|
|
119
119
|
|
|
120
120
|
\x1b[1mCOMMANDS\x1b[0m
|
|
121
|
-
init [target-dir] 安裝 skills/agents/plugins 到 .opencode/ 下
|
|
121
|
+
init [target-dir] [--force] 安裝 skills/agents/plugins 到 .opencode/ 下
|
|
122
122
|
(預設: 當前目錄的 .opencode/)
|
|
123
|
+
--force/-f/--overwrite 覆寫既有檔案 (升級用)
|
|
123
124
|
list 列出可用的 skills 與 agents
|
|
124
125
|
help 顯示此說明
|
|
125
126
|
|
|
@@ -133,6 +134,7 @@ function cmdHelp() {
|
|
|
133
134
|
npm install my-opencode # 方法 A (自動)
|
|
134
135
|
npx my-opencode init # 方法 B (手動)
|
|
135
136
|
npx my-opencode init ./my-project # 指定專案目錄
|
|
137
|
+
npx my-opencode init --force # 覆寫既有檔案 (升級)
|
|
136
138
|
npx my-opencode list # 列出內容
|
|
137
139
|
moc openai # 用 openai profile 啟動
|
|
138
140
|
`);
|
|
@@ -169,7 +171,7 @@ function cmdList() {
|
|
|
169
171
|
}
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
function cmdInit(targetDir) {
|
|
174
|
+
function cmdInit(targetDir, force) {
|
|
173
175
|
// If no target specified, default to .opencode/ in CWD
|
|
174
176
|
const target = targetDir
|
|
175
177
|
? path.resolve(targetDir, ".opencode")
|
|
@@ -177,6 +179,10 @@ function cmdInit(targetDir) {
|
|
|
177
179
|
|
|
178
180
|
header(`Installing my-opencode → ${target}`);
|
|
179
181
|
|
|
182
|
+
if (force) {
|
|
183
|
+
info("--force: overwriting existing files");
|
|
184
|
+
}
|
|
185
|
+
|
|
180
186
|
if (!fs.existsSync(target)) {
|
|
181
187
|
fs.mkdirSync(target, { recursive: true });
|
|
182
188
|
success(`Created .opencode/`);
|
|
@@ -192,7 +198,7 @@ function cmdInit(targetDir) {
|
|
|
192
198
|
for (const s of skills) {
|
|
193
199
|
const src = path.join(SKILLS_DIR, s);
|
|
194
200
|
const dst = path.join(targetSkills, s);
|
|
195
|
-
copyDirSync(src, dst);
|
|
201
|
+
copyDirSync(src, dst, force);
|
|
196
202
|
skillCount++;
|
|
197
203
|
}
|
|
198
204
|
success(`Skills: ${skillCount} installed → .opencode/skills/`);
|
|
@@ -207,7 +213,7 @@ function cmdInit(targetDir) {
|
|
|
207
213
|
for (const a of agents) {
|
|
208
214
|
const src = path.join(AGENTS_DIR, a);
|
|
209
215
|
const dst = path.join(targetAgents, a);
|
|
210
|
-
if (!fs.existsSync(dst)) {
|
|
216
|
+
if (force || !fs.existsSync(dst)) {
|
|
211
217
|
fs.copyFileSync(src, dst);
|
|
212
218
|
agentCount++;
|
|
213
219
|
} else {
|
|
@@ -226,7 +232,7 @@ function cmdInit(targetDir) {
|
|
|
226
232
|
for (const plugin of plugins) {
|
|
227
233
|
const src = path.join(PLUGINS_DIR, plugin);
|
|
228
234
|
const dst = path.join(targetPlugins, plugin);
|
|
229
|
-
if (!fs.existsSync(dst)) {
|
|
235
|
+
if (force || !fs.existsSync(dst)) {
|
|
230
236
|
fs.copyFileSync(src, dst);
|
|
231
237
|
pluginCount++;
|
|
232
238
|
} else {
|
|
@@ -237,7 +243,7 @@ function cmdInit(targetDir) {
|
|
|
237
243
|
|
|
238
244
|
// ── Generate opencode.json ──────────────────────────────────────────────
|
|
239
245
|
const targetConfig = path.join(target, "opencode.json");
|
|
240
|
-
if (!fs.existsSync(targetConfig)) {
|
|
246
|
+
if (force || !fs.existsSync(targetConfig)) {
|
|
241
247
|
try {
|
|
242
248
|
const config = JSON.parse(fs.readFileSync(OPENCODE_CONFIG, "utf-8"));
|
|
243
249
|
fs.writeFileSync(targetConfig, JSON.stringify(config, null, 2) + "\n");
|
|
@@ -274,22 +280,37 @@ function cmdInit(targetDir) {
|
|
|
274
280
|
|
|
275
281
|
// ─── File Utilities ─────────────────────────────────────────────────────────
|
|
276
282
|
|
|
277
|
-
function copyDirSync(src, dst) {
|
|
283
|
+
function copyDirSync(src, dst, force) {
|
|
278
284
|
fs.mkdirSync(dst, { recursive: true });
|
|
279
285
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
280
286
|
for (const entry of entries) {
|
|
281
287
|
const srcPath = path.join(src, entry.name);
|
|
282
288
|
const dstPath = path.join(dst, entry.name);
|
|
283
289
|
if (entry.isDirectory()) {
|
|
284
|
-
copyDirSync(srcPath, dstPath);
|
|
290
|
+
copyDirSync(srcPath, dstPath, force);
|
|
285
291
|
} else if (entry.isFile()) {
|
|
286
|
-
if (!fs.existsSync(dstPath)) {
|
|
292
|
+
if (force || !fs.existsSync(dstPath)) {
|
|
287
293
|
fs.copyFileSync(srcPath, dstPath);
|
|
288
294
|
}
|
|
289
295
|
}
|
|
290
296
|
}
|
|
291
297
|
}
|
|
292
298
|
|
|
299
|
+
// ─── Argument parsing ─────────────────────────────────────────────────────────
|
|
300
|
+
|
|
301
|
+
function parseInitArgs(args) {
|
|
302
|
+
let targetDir = null;
|
|
303
|
+
let force = false;
|
|
304
|
+
for (const arg of args) {
|
|
305
|
+
if (arg === "--force" || arg === "-f" || arg === "--overwrite") {
|
|
306
|
+
force = true;
|
|
307
|
+
} else if (!targetDir && !arg.startsWith("-")) {
|
|
308
|
+
targetDir = arg;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return { targetDir, force };
|
|
312
|
+
}
|
|
313
|
+
|
|
293
314
|
// ─── Main ───────────────────────────────────────────────────────────────────
|
|
294
315
|
|
|
295
316
|
function main() {
|
|
@@ -298,9 +319,11 @@ function main() {
|
|
|
298
319
|
|
|
299
320
|
switch (cmd) {
|
|
300
321
|
case "init":
|
|
301
|
-
case "install":
|
|
302
|
-
|
|
322
|
+
case "install": {
|
|
323
|
+
const { targetDir, force } = parseInitArgs(args.slice(1));
|
|
324
|
+
cmdInit(targetDir, force);
|
|
303
325
|
break;
|
|
326
|
+
}
|
|
304
327
|
case "list":
|
|
305
328
|
case "ls":
|
|
306
329
|
cmdList();
|
|
@@ -318,6 +341,7 @@ function main() {
|
|
|
318
341
|
在專案中執行以下指令來安裝到 \x1b[33m.opencode/\x1b[0m:
|
|
319
342
|
|
|
320
343
|
\x1b[36mnpx my-opencode init\x1b[0m
|
|
344
|
+
\x1b[36mnpx my-opencode init --force\x1b[0m (升級時覆寫既有檔案)
|
|
321
345
|
|
|
322
346
|
安裝後,將以下內容加入你的 \x1b[33mopencode.json\x1b[0m:
|
|
323
347
|
|
package/opencode.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://opencode.ai/config.json",
|
|
3
|
-
"model": "opencode/
|
|
4
|
-
"small_model": "opencode/deepseek-v4-flash
|
|
3
|
+
"model": "opencode-go/deepseek-v4-pro",
|
|
4
|
+
"small_model": "opencode-go/deepseek-v4-flash",
|
|
5
5
|
"default_agent": "fullstack-dev",
|
|
6
6
|
"instructions": [
|
|
7
7
|
"skills/adr/SKILL.md",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"spec-writer": {
|
|
33
33
|
"description": "Analyze requirements and produce contract specifications in docs/specs/. Writes persistent contracts for parallel development.",
|
|
34
34
|
"mode": "subagent",
|
|
35
|
-
"model": "opencode/
|
|
35
|
+
"model": "opencode-go/deepseek-v4-pro",
|
|
36
36
|
"prompt": "{file:agents/spec-writer.md}",
|
|
37
37
|
"tools": {
|
|
38
38
|
"read": true,
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"verifier": {
|
|
56
56
|
"description": "Run lint, typecheck, tests, and build to verify code changes. Read-only + bash.",
|
|
57
57
|
"mode": "subagent",
|
|
58
|
-
"model": "opencode/deepseek-v4-flash
|
|
58
|
+
"model": "opencode-go/deepseek-v4-flash",
|
|
59
59
|
"prompt": "{file:agents/verifier.md}",
|
|
60
60
|
"tools": {
|
|
61
61
|
"read": true,
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"code-reviewer": {
|
|
68
68
|
"description": "Systematic code review across correctness, security, quality, testing, and style dimensions.",
|
|
69
69
|
"mode": "subagent",
|
|
70
|
-
"model": "opencode/
|
|
70
|
+
"model": "opencode-go/deepseek-v4-pro",
|
|
71
71
|
"prompt": "{file:agents/code-reviewer.md}",
|
|
72
72
|
"tools": {
|
|
73
73
|
"read": true,
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"team-lead": {
|
|
102
102
|
"description": "Multi-agent orchestrator for complex tasks. Delegates to architect, spec-writer, executor, code-reviewer, test-engineer, verifier.",
|
|
103
103
|
"mode": "subagent",
|
|
104
|
-
"model": "opencode/
|
|
104
|
+
"model": "opencode-go/deepseek-v4-pro",
|
|
105
105
|
"prompt": "{file:agents/team-lead.md}",
|
|
106
106
|
"tools": {
|
|
107
107
|
"read": true,
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"architect": {
|
|
114
114
|
"description": "Capture architecture decisions as ADR documents. Analyzes tradeoffs and records context.",
|
|
115
115
|
"mode": "subagent",
|
|
116
|
-
"model": "opencode/
|
|
116
|
+
"model": "opencode-go/deepseek-v4-pro",
|
|
117
117
|
"prompt": "{file:agents/architect.md}",
|
|
118
118
|
"tools": {
|
|
119
119
|
"read": true,
|
package/package.json
CHANGED
package/plugins/README.md
CHANGED
|
@@ -15,7 +15,7 @@ opencode plugin 是透過 `opencode.json` 的 `plugin` 區塊註冊的 npm 或
|
|
|
15
15
|
|
|
16
16
|
| Profile | Primary / heavy | Small / verifier |
|
|
17
17
|
|---------|------------------|------------------|
|
|
18
|
-
| `opencode` | `opencode/
|
|
18
|
+
| `opencode` | `opencode-go/deepseek-v4-pro` | `opencode-go/deepseek-v4-flash` |
|
|
19
19
|
| `openai` | `openai/gpt-5.4` | `openai/gpt-5.4-mini` |
|
|
20
20
|
| `google` | `google/gemini-3.1-pro-preview-customtools` | `google/gemini-3.5-flash` |
|
|
21
21
|
| `copilot` | `copilot/gpt-5.4` | `copilot/gpt-5.4-mini` |
|
|
@@ -8,9 +8,9 @@ const CONFIG_PATH = path.resolve(__dirname, "..", "opencode.json");
|
|
|
8
8
|
|
|
9
9
|
const PROFILE_MAP = Object.freeze({
|
|
10
10
|
opencode: Object.freeze({
|
|
11
|
-
model: "opencode/
|
|
12
|
-
small_model: "opencode/deepseek-v4-flash
|
|
13
|
-
heavy_model: "opencode/
|
|
11
|
+
model: "opencode-go/deepseek-v4-pro",
|
|
12
|
+
small_model: "opencode-go/deepseek-v4-flash",
|
|
13
|
+
heavy_model: "opencode-go/deepseek-v4-pro",
|
|
14
14
|
}),
|
|
15
15
|
openai: Object.freeze({
|
|
16
16
|
model: "openai/gpt-5.4",
|