my-opencode 1.2.1 → 1.3.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 -21
- package/README.md +259 -180
- package/agents/architect.md +30 -30
- package/agents/code-reviewer.md +29 -29
- package/agents/executor.md +30 -30
- package/agents/fullstack-dev.md +57 -57
- package/agents/spec-writer.md +37 -37
- package/agents/team-lead.md +60 -60
- package/agents/tech-writer.md +30 -30
- package/agents/test-engineer.md +30 -30
- package/agents/verifier.md +33 -33
- package/bin/cli.js +341 -311
- package/bin/moc +199 -0
- package/opencode.json +170 -167
- package/package.json +50 -48
- package/plugins/README.md +64 -0
- package/plugins/provider-profile.mjs +139 -0
- package/scripts/postinstall.js +202 -182
- package/skills/adr/SKILL.md +91 -91
- package/skills/adr/references/templates.md +100 -100
- package/skills/adr/scripts/README.md +5 -5
- package/skills/dev-flow/SKILL.md +188 -188
- package/skills/dev-flow/references/code-phase.md +72 -72
- package/skills/dev-flow/references/contract-phase.md +81 -81
- package/skills/dev-flow/references/verify-phase.md +129 -129
- package/skills/dev-flow/scripts/README.md +3 -3
- package/skills/docs-gen/SKILL.md +162 -162
- package/skills/docs-gen/references/doc-styles.md +216 -216
- package/skills/docs-gen/scripts/README.md +5 -5
- package/skills/orchestrate/SKILL.md +112 -112
- package/skills/orchestrate/references/orchestration-patterns.md +56 -56
- package/skills/pr-review/SKILL.md +110 -110
- package/skills/pr-review/references/review-dimensions.md +117 -117
- package/skills/pr-review/references/security-checklist.md +122 -122
- package/skills/pr-review/scripts/README.md +5 -5
- package/skills/test-gen/SKILL.md +143 -143
- package/skills/test-gen/references/framework-detection.md +105 -105
- package/skills/test-gen/references/test-patterns.md +260 -260
- package/skills/test-gen/scripts/README.md +5 -5
package/bin/cli.js
CHANGED
|
@@ -1,311 +1,341 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* my-opencode CLI
|
|
5
|
-
*
|
|
6
|
-
* Two install methods:
|
|
7
|
-
*
|
|
8
|
-
* 1. npm install my-opencode
|
|
9
|
-
* → Files in node_modules/ (gitignored) + postinstall copies to .opencode/
|
|
10
|
-
*
|
|
11
|
-
* 2. npx my-opencode init
|
|
12
|
-
* → Files copied directly to .opencode/, no dependency in package.json
|
|
13
|
-
*
|
|
14
|
-
* Commands:
|
|
15
|
-
* init [target-dir] Install skills/agents into .opencode/
|
|
16
|
-
* list List available skills and agents
|
|
17
|
-
* help Show this help
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { fileURLToPath } from "node:url";
|
|
21
|
-
import path from "node:path";
|
|
22
|
-
import fs from "node:fs";
|
|
23
|
-
|
|
24
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
25
|
-
const PKG_ROOT = path.resolve(path.dirname(__filename), "..");
|
|
26
|
-
|
|
27
|
-
const SKILLS_DIR = path.join(PKG_ROOT, "skills");
|
|
28
|
-
const AGENTS_DIR = path.join(PKG_ROOT, "agents");
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.
|
|
74
|
-
.
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
✓
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
✓
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
"
|
|
301
|
-
"
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
break;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* my-opencode CLI
|
|
5
|
+
*
|
|
6
|
+
* Two install methods:
|
|
7
|
+
*
|
|
8
|
+
* 1. npm install my-opencode
|
|
9
|
+
* → Files in node_modules/ (gitignored) + postinstall copies to .opencode/
|
|
10
|
+
*
|
|
11
|
+
* 2. npx my-opencode init
|
|
12
|
+
* → Files copied directly to .opencode/, no dependency in package.json
|
|
13
|
+
*
|
|
14
|
+
* Commands:
|
|
15
|
+
* init [target-dir] Install skills/agents/plugins into .opencode/
|
|
16
|
+
* list List available skills and agents
|
|
17
|
+
* help Show this help
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import path from "node:path";
|
|
22
|
+
import fs from "node:fs";
|
|
23
|
+
|
|
24
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
25
|
+
const PKG_ROOT = path.resolve(path.dirname(__filename), "..");
|
|
26
|
+
|
|
27
|
+
const SKILLS_DIR = path.join(PKG_ROOT, "skills");
|
|
28
|
+
const AGENTS_DIR = path.join(PKG_ROOT, "agents");
|
|
29
|
+
const PLUGINS_DIR = path.join(PKG_ROOT, "plugins");
|
|
30
|
+
const OPENCODE_CONFIG = path.join(PKG_ROOT, "opencode.json");
|
|
31
|
+
|
|
32
|
+
const INDENT = " ";
|
|
33
|
+
|
|
34
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
function header(text) {
|
|
37
|
+
console.log(`\n\x1b[36m━━━ ${text} ━━━\x1b[0m\n`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function success(text) {
|
|
41
|
+
console.log(`\x1b[32m✓\x1b[0m ${text}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function warn(text) {
|
|
45
|
+
console.log(`\x1b[33m⚠\x1b[0m ${text}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function info(text) {
|
|
49
|
+
console.log(`\x1b[34mℹ\x1b[0m ${text}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getDirectories(dirPath) {
|
|
53
|
+
try {
|
|
54
|
+
return fs.readdirSync(dirPath, { withFileTypes: true })
|
|
55
|
+
.filter(d => d.isDirectory())
|
|
56
|
+
.map(d => d.name);
|
|
57
|
+
} catch {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function extractFrontmatterDescription(filePath) {
|
|
63
|
+
try {
|
|
64
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
65
|
+
const match = content.match(/^---\n([\s\S]+?)\n---/);
|
|
66
|
+
if (!match) return "";
|
|
67
|
+
const frontmatter = match[1];
|
|
68
|
+
|
|
69
|
+
// Try multi-line YAML (description: | ...)
|
|
70
|
+
const multiLine = frontmatter.match(/^description:\s*\|\s*\n((?:\s{2}.*\n?)*)/m);
|
|
71
|
+
if (multiLine) {
|
|
72
|
+
return multiLine[1]
|
|
73
|
+
.split("\n")
|
|
74
|
+
.map(l => l.replace(/^\s{2}/, "").trim())
|
|
75
|
+
.filter(l => l)
|
|
76
|
+
.join(" ");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Try single-line: description: text
|
|
80
|
+
const singleLine = frontmatter.match(/^description:\s*(.+)$/m);
|
|
81
|
+
if (singleLine) {
|
|
82
|
+
const val = singleLine[1].trim();
|
|
83
|
+
if (val && val !== "|") return val;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return "";
|
|
87
|
+
} catch {
|
|
88
|
+
return "";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function getFiles(dirPath) {
|
|
93
|
+
try {
|
|
94
|
+
return fs.readdirSync(dirPath, { withFileTypes: true })
|
|
95
|
+
.filter(d => d.isFile())
|
|
96
|
+
.map(d => d.name);
|
|
97
|
+
} catch {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ─── Commands ───────────────────────────────────────────────────────────────
|
|
103
|
+
|
|
104
|
+
function cmdHelp() {
|
|
105
|
+
console.log(`
|
|
106
|
+
\x1b[1mmy-opencode\x1b[0m — 高品質 opencode 開發流程 skill 與 agents 集合
|
|
107
|
+
|
|
108
|
+
\x1b[1m安裝方式 (擇一)\x1b[0m
|
|
109
|
+
|
|
110
|
+
\x1b[36m方法 A: npm install\x1b[0m (自動複製到 .opencode/)
|
|
111
|
+
npm install my-opencode
|
|
112
|
+
✓ postinstall 自動將 agents/ skills/ plugins/ 複製到 .opencode/
|
|
113
|
+
✓ 原始檔案留在 node_modules/ (已 gitignore)
|
|
114
|
+
|
|
115
|
+
\x1b[36m方法 B: npx\x1b[0m (不留 package.json dependency)
|
|
116
|
+
npx my-opencode init
|
|
117
|
+
✓ 直接安裝到 .opencode/
|
|
118
|
+
✓ 不寫入 package.json
|
|
119
|
+
|
|
120
|
+
\x1b[1mCOMMANDS\x1b[0m
|
|
121
|
+
init [target-dir] 安裝 skills/agents/plugins 到 .opencode/ 下
|
|
122
|
+
(預設: 當前目錄的 .opencode/)
|
|
123
|
+
list 列出可用的 skills 與 agents
|
|
124
|
+
help 顯示此說明
|
|
125
|
+
|
|
126
|
+
\x1b[1mLAUNCHER\x1b[0m
|
|
127
|
+
moc 預設使用 opencode profile 啟動 opencode
|
|
128
|
+
moc openai 使用 openai profile 啟動 opencode
|
|
129
|
+
moc google 使用 google profile 啟動 opencode
|
|
130
|
+
moc --help 透明轉發到 opencode --help
|
|
131
|
+
|
|
132
|
+
\x1b[1mEXAMPLES\x1b[0m
|
|
133
|
+
npm install my-opencode # 方法 A (自動)
|
|
134
|
+
npx my-opencode init # 方法 B (手動)
|
|
135
|
+
npx my-opencode init ./my-project # 指定專案目錄
|
|
136
|
+
npx my-opencode list # 列出內容
|
|
137
|
+
moc openai # 用 openai profile 啟動
|
|
138
|
+
`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function cmdList() {
|
|
142
|
+
header("Available Skills");
|
|
143
|
+
const skills = getDirectories(SKILLS_DIR);
|
|
144
|
+
if (skills.length === 0) {
|
|
145
|
+
warn("No skills found.");
|
|
146
|
+
} else {
|
|
147
|
+
for (const s of skills) {
|
|
148
|
+
const skillPath = path.join(SKILLS_DIR, s, "SKILL.md");
|
|
149
|
+
const desc = extractFrontmatterDescription(skillPath);
|
|
150
|
+
console.log(`${INDENT}\x1b[33m${s}\x1b[0m`);
|
|
151
|
+
if (desc) console.log(`${INDENT} ${desc}`);
|
|
152
|
+
console.log();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
header("Available Agents");
|
|
157
|
+
const agents = getFiles(AGENTS_DIR);
|
|
158
|
+
if (agents.length === 0) {
|
|
159
|
+
warn("No agents found.");
|
|
160
|
+
} else {
|
|
161
|
+
for (const a of agents) {
|
|
162
|
+
const agentPath = path.join(AGENTS_DIR, a);
|
|
163
|
+
const desc = extractFrontmatterDescription(agentPath);
|
|
164
|
+
const name = a.replace(/\.md$/, "");
|
|
165
|
+
console.log(`${INDENT}\x1b[33m${name}\x1b[0m`);
|
|
166
|
+
if (desc) console.log(`${INDENT} ${desc}`);
|
|
167
|
+
console.log();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function cmdInit(targetDir) {
|
|
173
|
+
// If no target specified, default to .opencode/ in CWD
|
|
174
|
+
const target = targetDir
|
|
175
|
+
? path.resolve(targetDir, ".opencode")
|
|
176
|
+
: path.resolve(process.cwd(), ".opencode");
|
|
177
|
+
|
|
178
|
+
header(`Installing my-opencode → ${target}`);
|
|
179
|
+
|
|
180
|
+
if (!fs.existsSync(target)) {
|
|
181
|
+
fs.mkdirSync(target, { recursive: true });
|
|
182
|
+
success(`Created .opencode/`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ── Copy skills ───────────────────────────────────────────────────────────
|
|
186
|
+
const targetSkills = path.join(target, "skills");
|
|
187
|
+
if (!fs.existsSync(targetSkills)) {
|
|
188
|
+
fs.mkdirSync(targetSkills, { recursive: true });
|
|
189
|
+
}
|
|
190
|
+
const skills = getDirectories(SKILLS_DIR);
|
|
191
|
+
let skillCount = 0;
|
|
192
|
+
for (const s of skills) {
|
|
193
|
+
const src = path.join(SKILLS_DIR, s);
|
|
194
|
+
const dst = path.join(targetSkills, s);
|
|
195
|
+
copyDirSync(src, dst);
|
|
196
|
+
skillCount++;
|
|
197
|
+
}
|
|
198
|
+
success(`Skills: ${skillCount} installed → .opencode/skills/`);
|
|
199
|
+
|
|
200
|
+
// ── Copy agents ──────────────────────────────────────────────────────────
|
|
201
|
+
const targetAgents = path.join(target, "agents");
|
|
202
|
+
if (!fs.existsSync(targetAgents)) {
|
|
203
|
+
fs.mkdirSync(targetAgents, { recursive: true });
|
|
204
|
+
}
|
|
205
|
+
const agents = getFiles(AGENTS_DIR);
|
|
206
|
+
let agentCount = 0;
|
|
207
|
+
for (const a of agents) {
|
|
208
|
+
const src = path.join(AGENTS_DIR, a);
|
|
209
|
+
const dst = path.join(targetAgents, a);
|
|
210
|
+
if (!fs.existsSync(dst)) {
|
|
211
|
+
fs.copyFileSync(src, dst);
|
|
212
|
+
agentCount++;
|
|
213
|
+
} else {
|
|
214
|
+
warn(`Skipped (already exists): agents/${a}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
success(`Agents: ${agentCount} installed → .opencode/agents/`);
|
|
218
|
+
|
|
219
|
+
// ── Copy plugins ─────────────────────────────────────────────────────────
|
|
220
|
+
const targetPlugins = path.join(target, "plugins");
|
|
221
|
+
if (!fs.existsSync(targetPlugins)) {
|
|
222
|
+
fs.mkdirSync(targetPlugins, { recursive: true });
|
|
223
|
+
}
|
|
224
|
+
const plugins = getFiles(PLUGINS_DIR).filter((name) => name.endsWith(".mjs"));
|
|
225
|
+
let pluginCount = 0;
|
|
226
|
+
for (const plugin of plugins) {
|
|
227
|
+
const src = path.join(PLUGINS_DIR, plugin);
|
|
228
|
+
const dst = path.join(targetPlugins, plugin);
|
|
229
|
+
if (!fs.existsSync(dst)) {
|
|
230
|
+
fs.copyFileSync(src, dst);
|
|
231
|
+
pluginCount++;
|
|
232
|
+
} else {
|
|
233
|
+
warn(`Skipped (already exists): plugins/${plugin}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
success(`Plugins: ${pluginCount} installed → .opencode/plugins/`);
|
|
237
|
+
|
|
238
|
+
// ── Generate opencode.json ──────────────────────────────────────────────
|
|
239
|
+
const targetConfig = path.join(target, "opencode.json");
|
|
240
|
+
if (!fs.existsSync(targetConfig)) {
|
|
241
|
+
try {
|
|
242
|
+
const config = JSON.parse(fs.readFileSync(OPENCODE_CONFIG, "utf-8"));
|
|
243
|
+
fs.writeFileSync(targetConfig, JSON.stringify(config, null, 2) + "\n");
|
|
244
|
+
success("Generated .opencode/opencode.json — ready to use");
|
|
245
|
+
} catch {
|
|
246
|
+
warn("Could not generate opencode.json (source config missing or invalid)");
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
warn("Skipped (already exists): .opencode/opencode.json");
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ── Summary ──────────────────────────────────────────────────────────────
|
|
253
|
+
console.log();
|
|
254
|
+
header("Installation Complete");
|
|
255
|
+
info("my-opencode is ready at .opencode/");
|
|
256
|
+
info('Use "moc" as the primary launcher once the bin is on your PATH');
|
|
257
|
+
console.log();
|
|
258
|
+
console.log(`${INDENT}Your project's opencode.json should reference:`);
|
|
259
|
+
console.log(`${INDENT} "instructions": [`);
|
|
260
|
+
console.log(`${INDENT} ".opencode/skills/adr/SKILL.md",`);
|
|
261
|
+
console.log(`${INDENT} ".opencode/skills/dev-flow/SKILL.md",`);
|
|
262
|
+
console.log(`${INDENT} ".opencode/skills/pr-review/SKILL.md",`);
|
|
263
|
+
console.log(`${INDENT} ".opencode/skills/test-gen/SKILL.md",`);
|
|
264
|
+
console.log(`${INDENT} ".opencode/skills/docs-gen/SKILL.md",`);
|
|
265
|
+
console.log(`${INDENT} ".opencode/skills/orchestrate/SKILL.md"`);
|
|
266
|
+
console.log(`${INDENT} ]`);
|
|
267
|
+
console.log();
|
|
268
|
+
console.log(`${INDENT}Agents, commands, and plugins from .opencode/opencode.json`);
|
|
269
|
+
console.log(`${INDENT}are auto-discovered by opencode.`);
|
|
270
|
+
console.log();
|
|
271
|
+
info("Documentation: https://github.com/jjyung/my-opencode");
|
|
272
|
+
console.log();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ─── File Utilities ─────────────────────────────────────────────────────────
|
|
276
|
+
|
|
277
|
+
function copyDirSync(src, dst) {
|
|
278
|
+
fs.mkdirSync(dst, { recursive: true });
|
|
279
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
280
|
+
for (const entry of entries) {
|
|
281
|
+
const srcPath = path.join(src, entry.name);
|
|
282
|
+
const dstPath = path.join(dst, entry.name);
|
|
283
|
+
if (entry.isDirectory()) {
|
|
284
|
+
copyDirSync(srcPath, dstPath);
|
|
285
|
+
} else if (entry.isFile()) {
|
|
286
|
+
if (!fs.existsSync(dstPath)) {
|
|
287
|
+
fs.copyFileSync(srcPath, dstPath);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// ─── Main ───────────────────────────────────────────────────────────────────
|
|
294
|
+
|
|
295
|
+
function main() {
|
|
296
|
+
const args = process.argv.slice(2);
|
|
297
|
+
const cmd = args[0] || "";
|
|
298
|
+
|
|
299
|
+
switch (cmd) {
|
|
300
|
+
case "init":
|
|
301
|
+
case "install":
|
|
302
|
+
cmdInit(args[1]);
|
|
303
|
+
break;
|
|
304
|
+
case "list":
|
|
305
|
+
case "ls":
|
|
306
|
+
cmdList();
|
|
307
|
+
break;
|
|
308
|
+
case "help":
|
|
309
|
+
case "--help":
|
|
310
|
+
case "-h":
|
|
311
|
+
cmdHelp();
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
// No args — show a friendly welcome and prompt to init
|
|
315
|
+
console.log(`
|
|
316
|
+
\x1b[1mmy-opencode\x1b[0m — 高品質 opencode 開發流程 skill 與 agents 集合
|
|
317
|
+
|
|
318
|
+
在專案中執行以下指令來安裝到 \x1b[33m.opencode/\x1b[0m:
|
|
319
|
+
|
|
320
|
+
\x1b[36mnpx my-opencode init\x1b[0m
|
|
321
|
+
|
|
322
|
+
安裝後,將以下內容加入你的 \x1b[33mopencode.json\x1b[0m:
|
|
323
|
+
|
|
324
|
+
\x1b[2m"instructions": [
|
|
325
|
+
".opencode/skills/adr/SKILL.md",
|
|
326
|
+
".opencode/skills/dev-flow/SKILL.md",
|
|
327
|
+
".opencode/skills/pr-review/SKILL.md",
|
|
328
|
+
".opencode/skills/test-gen/SKILL.md",
|
|
329
|
+
".opencode/skills/docs-gen/SKILL.md",
|
|
330
|
+
".opencode/skills/orchestrate/SKILL.md"
|
|
331
|
+
]\x1b[0m
|
|
332
|
+
|
|
333
|
+
更多資訊請執行:\x1b[36mnpx my-opencode help\x1b[0m
|
|
334
|
+
|
|
335
|
+
若已透過 npm install 安裝,也可直接使用:\x1b[36mmoc\x1b[0m / \x1b[36mmoc openai\x1b[0m
|
|
336
|
+
`);
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
main();
|