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