my-opencode 1.3.3 → 2.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 -21
- package/README.md +299 -267
- package/agents/architect.md +30 -30
- package/agents/backend-dev.md +29 -0
- package/agents/business-analyst.md +30 -0
- package/agents/code-reviewer.md +29 -29
- package/agents/design-evidence.md +29 -0
- package/agents/frontend-dev.md +29 -0
- package/agents/system-designer.md +30 -0
- package/agents/team-lead.md +65 -60
- package/agents/tech-writer.md +30 -30
- package/agents/test-engineer.md +30 -30
- package/agents/verifier.md +38 -33
- package/bin/cli.js +366 -364
- package/bin/moc +198 -198
- package/opencode.json +218 -170
- package/package.json +53 -50
- package/plugins/README.md +67 -64
- package/plugins/provider-profile.mjs +203 -139
- package/scripts/postinstall.js +202 -202
- package/scripts/validate-role-flow.mjs +90 -0
- 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/design-evidence/SKILL.md +56 -0
- package/skills/dev-flow/SKILL.md +126 -188
- package/skills/dev-flow/references/code-phase.md +35 -72
- package/skills/dev-flow/references/contract-phase.md +66 -81
- package/skills/dev-flow/references/verify-phase.md +70 -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 +63 -112
- package/skills/orchestrate/references/orchestration-patterns.md +49 -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/agents/executor.md +0 -30
- package/agents/fullstack-dev.md +0 -57
- package/agents/spec-writer.md +0 -37
package/scripts/postinstall.js
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* postinstall.js — npm postinstall hook
|
|
5
|
-
*
|
|
6
|
-
* After `npm install my-opencode` in another project, this script
|
|
7
|
-
* automatically copies agents/, skills/, plugins/, and opencode.json to the
|
|
8
|
-
* target project's .opencode/ directory.
|
|
9
|
-
*
|
|
10
|
-
* The package stays in node_modules/ (gitignored, no residue).
|
|
11
|
-
* The .opencode/ files are what opencode reads.
|
|
12
|
-
*
|
|
13
|
-
* To skip: npm install my-opencode --ignore-scripts
|
|
14
|
-
* To run manually: npx my-opencode init
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { fileURLToPath } from "node:url";
|
|
18
|
-
import path from "node:path";
|
|
19
|
-
import fs from "node:fs";
|
|
20
|
-
|
|
21
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
22
|
-
const __dirname = path.dirname(__filename);
|
|
23
|
-
|
|
24
|
-
const PKG_DIR = path.resolve(__dirname, "..");
|
|
25
|
-
const SKILLS_SRC = path.join(PKG_DIR, "skills");
|
|
26
|
-
const AGENTS_SRC = path.join(PKG_DIR, "agents");
|
|
27
|
-
const PLUGINS_SRC = path.join(PKG_DIR, "plugins");
|
|
28
|
-
const CONFIG_SRC = path.join(PKG_DIR, "opencode.json");
|
|
29
|
-
|
|
30
|
-
// ─── Detect project root ────────────────────────────────────────────────
|
|
31
|
-
//
|
|
32
|
-
// During npm postinstall, `process.cwd()` is typically the package root
|
|
33
|
-
// (node_modules/my-opencode/), but behavior varies by npm version.
|
|
34
|
-
// We try multiple strategies to find the parent project root.
|
|
35
|
-
|
|
36
|
-
function hasPackageJson(dir) {
|
|
37
|
-
try {
|
|
38
|
-
const pkgPath = path.join(dir, "package.json");
|
|
39
|
-
if (!fs.existsSync(pkgPath)) return false;
|
|
40
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
41
|
-
return pkg.name !== "my-opencode";
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function findProjectRoot() {
|
|
48
|
-
// Strategy 1: process.cwd() is the project root (npm v6 behavior)
|
|
49
|
-
let candidate = path.resolve(process.cwd());
|
|
50
|
-
if (hasPackageJson(candidate)) return candidate;
|
|
51
|
-
|
|
52
|
-
// Strategy 2: process.cwd() is node_modules/my-opencode/ (npm v7+)
|
|
53
|
-
candidate = path.resolve(process.cwd(), "..", "..");
|
|
54
|
-
if (hasPackageJson(candidate)) return candidate;
|
|
55
|
-
|
|
56
|
-
// Strategy 3: __dirname is scripts/, go up 3 levels
|
|
57
|
-
candidate = path.resolve(__dirname, "..", "..", "..");
|
|
58
|
-
if (hasPackageJson(candidate)) return candidate;
|
|
59
|
-
|
|
60
|
-
// Strategy 4: Walk up from __dirname until we find a project's package.json
|
|
61
|
-
candidate = path.resolve(__dirname);
|
|
62
|
-
while (candidate !== path.parse(candidate).root) {
|
|
63
|
-
const parent = path.resolve(candidate, "..");
|
|
64
|
-
if (hasPackageJson(parent)) return parent;
|
|
65
|
-
candidate = parent;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ─── File utilities ─────────────────────────────────────────────────────
|
|
72
|
-
|
|
73
|
-
function copyDirSync(src, dst) {
|
|
74
|
-
let count = 0;
|
|
75
|
-
fs.mkdirSync(dst, { recursive: true });
|
|
76
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
77
|
-
for (const entry of entries) {
|
|
78
|
-
const srcPath = path.join(src, entry.name);
|
|
79
|
-
const dstPath = path.join(dst, entry.name);
|
|
80
|
-
if (entry.isDirectory()) {
|
|
81
|
-
count += copyDirSync(srcPath, dstPath);
|
|
82
|
-
} else if (entry.isFile()) {
|
|
83
|
-
if (!fs.existsSync(dstPath)) {
|
|
84
|
-
fs.copyFileSync(srcPath, dstPath);
|
|
85
|
-
count++;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return count;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function copyFileIfNotExists(src, dst) {
|
|
93
|
-
if (!fs.existsSync(dst)) {
|
|
94
|
-
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
95
|
-
fs.copyFileSync(src, dst);
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// ─── Main ───────────────────────────────────────────────────────────────
|
|
102
|
-
|
|
103
|
-
function main() {
|
|
104
|
-
const INDENT = " ";
|
|
105
|
-
const CYAN = "\x1b[36m";
|
|
106
|
-
const GREEN = "\x1b[32m";
|
|
107
|
-
const YELLOW = "\x1b[33m";
|
|
108
|
-
const RESET = "\x1b[0m";
|
|
109
|
-
|
|
110
|
-
function header(text) {
|
|
111
|
-
console.log(`\n${CYAN}━━━ ${text} ━━━${RESET}\n`);
|
|
112
|
-
}
|
|
113
|
-
function success(text) {
|
|
114
|
-
console.log(`${GREEN}✓${RESET} ${text}`);
|
|
115
|
-
}
|
|
116
|
-
function warn(text) {
|
|
117
|
-
console.log(`${YELLOW}⚠${RESET} ${text}`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const projectRoot = findProjectRoot();
|
|
121
|
-
if (!projectRoot) {
|
|
122
|
-
warn(
|
|
123
|
-
"Could not detect project root for my-opencode postinstall.\n" +
|
|
124
|
-
`${INDENT}Run "npx my-opencode init" to set up manually.`,
|
|
125
|
-
);
|
|
126
|
-
process.exit(0);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const targetDir = path.join(projectRoot, ".opencode");
|
|
130
|
-
const targetSkills = path.join(targetDir, "skills");
|
|
131
|
-
const targetAgents = path.join(targetDir, "agents");
|
|
132
|
-
const targetPlugins = path.join(targetDir, "plugins");
|
|
133
|
-
const targetConfig = path.join(targetDir, "opencode.json");
|
|
134
|
-
|
|
135
|
-
// ── Create .opencode/ ──────────────────────────────────────────────────
|
|
136
|
-
if (!fs.existsSync(targetDir)) {
|
|
137
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ── Copy skills ────────────────────────────────────────────────────────
|
|
141
|
-
let skillCount = 0;
|
|
142
|
-
if (fs.existsSync(SKILLS_SRC)) {
|
|
143
|
-
const skills = fs
|
|
144
|
-
.readdirSync(SKILLS_SRC, { withFileTypes: true })
|
|
145
|
-
.filter((d) => d.isDirectory())
|
|
146
|
-
.map((d) => d.name);
|
|
147
|
-
|
|
148
|
-
for (const s of skills) {
|
|
149
|
-
const dst = path.join(targetSkills, s);
|
|
150
|
-
if (!fs.existsSync(dst)) {
|
|
151
|
-
copyDirSync(path.join(SKILLS_SRC, s), dst);
|
|
152
|
-
skillCount++;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// ── Copy agents ────────────────────────────────────────────────────────
|
|
158
|
-
let agentCount = 0;
|
|
159
|
-
if (fs.existsSync(AGENTS_SRC)) {
|
|
160
|
-
const agents = fs
|
|
161
|
-
.readdirSync(AGENTS_SRC, { withFileTypes: true })
|
|
162
|
-
.filter((d) => d.isFile() && d.name.endsWith(".md"))
|
|
163
|
-
.map((d) => d.name);
|
|
164
|
-
|
|
165
|
-
for (const a of agents) {
|
|
166
|
-
const dst = path.join(targetAgents, a);
|
|
167
|
-
if (copyFileIfNotExists(path.join(AGENTS_SRC, a), dst)) {
|
|
168
|
-
agentCount++;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// ── Copy plugins ───────────────────────────────────────────────────────
|
|
174
|
-
let pluginCount = 0;
|
|
175
|
-
if (fs.existsSync(PLUGINS_SRC)) {
|
|
176
|
-
fs.mkdirSync(targetPlugins, { recursive: true });
|
|
177
|
-
const plugins = fs
|
|
178
|
-
.readdirSync(PLUGINS_SRC, { withFileTypes: true })
|
|
179
|
-
.filter((d) => d.isFile() && d.name.endsWith(".mjs"))
|
|
180
|
-
.map((d) => d.name);
|
|
181
|
-
|
|
182
|
-
for (const plugin of plugins) {
|
|
183
|
-
const dst = path.join(targetPlugins, plugin);
|
|
184
|
-
if (copyFileIfNotExists(path.join(PLUGINS_SRC, plugin), dst)) {
|
|
185
|
-
pluginCount++;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// ── Copy opencode.json ────────────────────────────────────────────────
|
|
191
|
-
copyFileIfNotExists(CONFIG_SRC, targetConfig);
|
|
192
|
-
|
|
193
|
-
// Suppress output if nothing changed (quiet idempotency)
|
|
194
|
-
if (skillCount === 0 && agentCount === 0 && pluginCount === 0) return;
|
|
195
|
-
|
|
196
|
-
header("my-opencode: installed to .opencode/");
|
|
197
|
-
if (skillCount > 0) success(`Skills: ${skillCount}`);
|
|
198
|
-
if (agentCount > 0) success(`Agents: ${agentCount}`);
|
|
199
|
-
if (pluginCount > 0) success(`Plugins: ${pluginCount}`);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
main();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* postinstall.js — npm postinstall hook
|
|
5
|
+
*
|
|
6
|
+
* After `npm install my-opencode` in another project, this script
|
|
7
|
+
* automatically copies agents/, skills/, plugins/, and opencode.json to the
|
|
8
|
+
* target project's .opencode/ directory.
|
|
9
|
+
*
|
|
10
|
+
* The package stays in node_modules/ (gitignored, no residue).
|
|
11
|
+
* The .opencode/ files are what opencode reads.
|
|
12
|
+
*
|
|
13
|
+
* To skip: npm install my-opencode --ignore-scripts
|
|
14
|
+
* To run manually: npx my-opencode init
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import fs from "node:fs";
|
|
20
|
+
|
|
21
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
22
|
+
const __dirname = path.dirname(__filename);
|
|
23
|
+
|
|
24
|
+
const PKG_DIR = path.resolve(__dirname, "..");
|
|
25
|
+
const SKILLS_SRC = path.join(PKG_DIR, "skills");
|
|
26
|
+
const AGENTS_SRC = path.join(PKG_DIR, "agents");
|
|
27
|
+
const PLUGINS_SRC = path.join(PKG_DIR, "plugins");
|
|
28
|
+
const CONFIG_SRC = path.join(PKG_DIR, "opencode.json");
|
|
29
|
+
|
|
30
|
+
// ─── Detect project root ────────────────────────────────────────────────
|
|
31
|
+
//
|
|
32
|
+
// During npm postinstall, `process.cwd()` is typically the package root
|
|
33
|
+
// (node_modules/my-opencode/), but behavior varies by npm version.
|
|
34
|
+
// We try multiple strategies to find the parent project root.
|
|
35
|
+
|
|
36
|
+
function hasPackageJson(dir) {
|
|
37
|
+
try {
|
|
38
|
+
const pkgPath = path.join(dir, "package.json");
|
|
39
|
+
if (!fs.existsSync(pkgPath)) return false;
|
|
40
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
41
|
+
return pkg.name !== "my-opencode";
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function findProjectRoot() {
|
|
48
|
+
// Strategy 1: process.cwd() is the project root (npm v6 behavior)
|
|
49
|
+
let candidate = path.resolve(process.cwd());
|
|
50
|
+
if (hasPackageJson(candidate)) return candidate;
|
|
51
|
+
|
|
52
|
+
// Strategy 2: process.cwd() is node_modules/my-opencode/ (npm v7+)
|
|
53
|
+
candidate = path.resolve(process.cwd(), "..", "..");
|
|
54
|
+
if (hasPackageJson(candidate)) return candidate;
|
|
55
|
+
|
|
56
|
+
// Strategy 3: __dirname is scripts/, go up 3 levels
|
|
57
|
+
candidate = path.resolve(__dirname, "..", "..", "..");
|
|
58
|
+
if (hasPackageJson(candidate)) return candidate;
|
|
59
|
+
|
|
60
|
+
// Strategy 4: Walk up from __dirname until we find a project's package.json
|
|
61
|
+
candidate = path.resolve(__dirname);
|
|
62
|
+
while (candidate !== path.parse(candidate).root) {
|
|
63
|
+
const parent = path.resolve(candidate, "..");
|
|
64
|
+
if (hasPackageJson(parent)) return parent;
|
|
65
|
+
candidate = parent;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ─── File utilities ─────────────────────────────────────────────────────
|
|
72
|
+
|
|
73
|
+
function copyDirSync(src, dst) {
|
|
74
|
+
let count = 0;
|
|
75
|
+
fs.mkdirSync(dst, { recursive: true });
|
|
76
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
77
|
+
for (const entry of entries) {
|
|
78
|
+
const srcPath = path.join(src, entry.name);
|
|
79
|
+
const dstPath = path.join(dst, entry.name);
|
|
80
|
+
if (entry.isDirectory()) {
|
|
81
|
+
count += copyDirSync(srcPath, dstPath);
|
|
82
|
+
} else if (entry.isFile()) {
|
|
83
|
+
if (!fs.existsSync(dstPath)) {
|
|
84
|
+
fs.copyFileSync(srcPath, dstPath);
|
|
85
|
+
count++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return count;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function copyFileIfNotExists(src, dst) {
|
|
93
|
+
if (!fs.existsSync(dst)) {
|
|
94
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
95
|
+
fs.copyFileSync(src, dst);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ─── Main ───────────────────────────────────────────────────────────────
|
|
102
|
+
|
|
103
|
+
function main() {
|
|
104
|
+
const INDENT = " ";
|
|
105
|
+
const CYAN = "\x1b[36m";
|
|
106
|
+
const GREEN = "\x1b[32m";
|
|
107
|
+
const YELLOW = "\x1b[33m";
|
|
108
|
+
const RESET = "\x1b[0m";
|
|
109
|
+
|
|
110
|
+
function header(text) {
|
|
111
|
+
console.log(`\n${CYAN}━━━ ${text} ━━━${RESET}\n`);
|
|
112
|
+
}
|
|
113
|
+
function success(text) {
|
|
114
|
+
console.log(`${GREEN}✓${RESET} ${text}`);
|
|
115
|
+
}
|
|
116
|
+
function warn(text) {
|
|
117
|
+
console.log(`${YELLOW}⚠${RESET} ${text}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const projectRoot = findProjectRoot();
|
|
121
|
+
if (!projectRoot) {
|
|
122
|
+
warn(
|
|
123
|
+
"Could not detect project root for my-opencode postinstall.\n" +
|
|
124
|
+
`${INDENT}Run "npx my-opencode init" to set up manually.`,
|
|
125
|
+
);
|
|
126
|
+
process.exit(0);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const targetDir = path.join(projectRoot, ".opencode");
|
|
130
|
+
const targetSkills = path.join(targetDir, "skills");
|
|
131
|
+
const targetAgents = path.join(targetDir, "agents");
|
|
132
|
+
const targetPlugins = path.join(targetDir, "plugins");
|
|
133
|
+
const targetConfig = path.join(targetDir, "opencode.json");
|
|
134
|
+
|
|
135
|
+
// ── Create .opencode/ ──────────────────────────────────────────────────
|
|
136
|
+
if (!fs.existsSync(targetDir)) {
|
|
137
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ── Copy skills ────────────────────────────────────────────────────────
|
|
141
|
+
let skillCount = 0;
|
|
142
|
+
if (fs.existsSync(SKILLS_SRC)) {
|
|
143
|
+
const skills = fs
|
|
144
|
+
.readdirSync(SKILLS_SRC, { withFileTypes: true })
|
|
145
|
+
.filter((d) => d.isDirectory())
|
|
146
|
+
.map((d) => d.name);
|
|
147
|
+
|
|
148
|
+
for (const s of skills) {
|
|
149
|
+
const dst = path.join(targetSkills, s);
|
|
150
|
+
if (!fs.existsSync(dst)) {
|
|
151
|
+
copyDirSync(path.join(SKILLS_SRC, s), dst);
|
|
152
|
+
skillCount++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ── Copy agents ────────────────────────────────────────────────────────
|
|
158
|
+
let agentCount = 0;
|
|
159
|
+
if (fs.existsSync(AGENTS_SRC)) {
|
|
160
|
+
const agents = fs
|
|
161
|
+
.readdirSync(AGENTS_SRC, { withFileTypes: true })
|
|
162
|
+
.filter((d) => d.isFile() && d.name.endsWith(".md"))
|
|
163
|
+
.map((d) => d.name);
|
|
164
|
+
|
|
165
|
+
for (const a of agents) {
|
|
166
|
+
const dst = path.join(targetAgents, a);
|
|
167
|
+
if (copyFileIfNotExists(path.join(AGENTS_SRC, a), dst)) {
|
|
168
|
+
agentCount++;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ── Copy plugins ───────────────────────────────────────────────────────
|
|
174
|
+
let pluginCount = 0;
|
|
175
|
+
if (fs.existsSync(PLUGINS_SRC)) {
|
|
176
|
+
fs.mkdirSync(targetPlugins, { recursive: true });
|
|
177
|
+
const plugins = fs
|
|
178
|
+
.readdirSync(PLUGINS_SRC, { withFileTypes: true })
|
|
179
|
+
.filter((d) => d.isFile() && d.name.endsWith(".mjs"))
|
|
180
|
+
.map((d) => d.name);
|
|
181
|
+
|
|
182
|
+
for (const plugin of plugins) {
|
|
183
|
+
const dst = path.join(targetPlugins, plugin);
|
|
184
|
+
if (copyFileIfNotExists(path.join(PLUGINS_SRC, plugin), dst)) {
|
|
185
|
+
pluginCount++;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ── Copy opencode.json ────────────────────────────────────────────────
|
|
191
|
+
copyFileIfNotExists(CONFIG_SRC, targetConfig);
|
|
192
|
+
|
|
193
|
+
// Suppress output if nothing changed (quiet idempotency)
|
|
194
|
+
if (skillCount === 0 && agentCount === 0 && pluginCount === 0) return;
|
|
195
|
+
|
|
196
|
+
header("my-opencode: installed to .opencode/");
|
|
197
|
+
if (skillCount > 0) success(`Skills: ${skillCount}`);
|
|
198
|
+
if (agentCount > 0) success(`Agents: ${agentCount}`);
|
|
199
|
+
if (pluginCount > 0) success(`Plugins: ${pluginCount}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
main();
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const read = (relativePath) => fs.readFileSync(path.join(root, relativePath), "utf8");
|
|
8
|
+
const fail = (message) => {
|
|
9
|
+
console.error(`FAIL: ${message}`);
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
};
|
|
12
|
+
const expect = (condition, message) => {
|
|
13
|
+
if (!condition) fail(message);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const config = JSON.parse(read("opencode.json"));
|
|
17
|
+
const expectedAgents = [
|
|
18
|
+
"team-lead",
|
|
19
|
+
"design-evidence",
|
|
20
|
+
"business-analyst",
|
|
21
|
+
"system-designer",
|
|
22
|
+
"frontend-dev",
|
|
23
|
+
"backend-dev",
|
|
24
|
+
"verifier",
|
|
25
|
+
"code-reviewer",
|
|
26
|
+
"test-engineer",
|
|
27
|
+
"tech-writer",
|
|
28
|
+
"architect",
|
|
29
|
+
];
|
|
30
|
+
const removedAgents = ["fullstack-dev", "spec-writer", "executor"];
|
|
31
|
+
const expectedCommands = [
|
|
32
|
+
"evidence",
|
|
33
|
+
"business-spec",
|
|
34
|
+
"technical-design",
|
|
35
|
+
"frontend",
|
|
36
|
+
"backend",
|
|
37
|
+
"review",
|
|
38
|
+
"test",
|
|
39
|
+
"docs",
|
|
40
|
+
"orchestrate",
|
|
41
|
+
"adr",
|
|
42
|
+
"verify",
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
expect(config.default_agent === "team-lead", "default_agent must be team-lead");
|
|
46
|
+
for (const agent of expectedAgents) {
|
|
47
|
+
expect(config.agent?.[agent], `missing agent: ${agent}`);
|
|
48
|
+
const prompt = config.agent?.[agent]?.prompt;
|
|
49
|
+
if (prompt?.startsWith("{file:") && prompt.endsWith("}")) {
|
|
50
|
+
expect(fs.existsSync(path.join(root, prompt.slice(6, -1))), `missing prompt for ${agent}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
for (const agent of removedAgents) {
|
|
54
|
+
expect(!config.agent?.[agent], `removed agent remains registered: ${agent}`);
|
|
55
|
+
expect(!fs.existsSync(path.join(root, "agents", `${agent}.md`)), `removed agent file remains: ${agent}`);
|
|
56
|
+
}
|
|
57
|
+
for (const command of expectedCommands) {
|
|
58
|
+
expect(config.command?.[command], `missing command: ${command}`);
|
|
59
|
+
expect(config.agent?.[config.command?.[command]?.agent], `command points to unknown agent: ${command}`);
|
|
60
|
+
}
|
|
61
|
+
expect(!config.command?.spec, "removed command remains registered: spec");
|
|
62
|
+
for (const instruction of config.instructions ?? []) {
|
|
63
|
+
expect(fs.existsSync(path.join(root, instruction)), `missing instruction: ${instruction}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const evidenceSkill = read("skills/design-evidence/SKILL.md");
|
|
67
|
+
for (const term of ["observed", "inferred", "unknown", "confidence", "prototype", "EVID-"]) {
|
|
68
|
+
expect(evidenceSkill.includes(term), `design-evidence skill missing term: ${term}`);
|
|
69
|
+
}
|
|
70
|
+
const devFlow = read("skills/dev-flow/SKILL.md");
|
|
71
|
+
for (const term of ["Business Requirements", "Technical Design", "frontend-contract.md", "backend-contract.md", "traceability.md", "VER-"]) {
|
|
72
|
+
expect(devFlow.includes(term), `dev-flow skill missing term: ${term}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const plugin = spawnSync(process.execPath, [path.join(root, "plugins/provider-profile.mjs")], {
|
|
76
|
+
cwd: root,
|
|
77
|
+
env: { ...process.env, OPENCODE_PROVIDER_PROFILE: "google" },
|
|
78
|
+
encoding: "utf8",
|
|
79
|
+
});
|
|
80
|
+
expect(plugin.status === 0, "provider profile plugin failed to execute");
|
|
81
|
+
if (plugin.status === 0) {
|
|
82
|
+
const output = JSON.parse(plugin.stdout);
|
|
83
|
+
for (const agent of ["design-evidence", "business-analyst", "system-designer", "code-reviewer", "team-lead", "architect"]) {
|
|
84
|
+
expect(output.agent?.[agent]?.model === "google/gemini-3.1-pro-preview-customtools", `google heavy model missing for ${agent}`);
|
|
85
|
+
}
|
|
86
|
+
expect(output.agent?.verifier?.model === "google/gemini-3.5-flash", "google verifier model mismatch");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (process.exitCode) process.exit(process.exitCode);
|
|
90
|
+
console.log("Role-flow structure validation passed.");
|