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.
Files changed (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +299 -267
  3. package/agents/architect.md +30 -30
  4. package/agents/backend-dev.md +29 -0
  5. package/agents/business-analyst.md +30 -0
  6. package/agents/code-reviewer.md +29 -29
  7. package/agents/design-evidence.md +29 -0
  8. package/agents/frontend-dev.md +29 -0
  9. package/agents/system-designer.md +30 -0
  10. package/agents/team-lead.md +65 -60
  11. package/agents/tech-writer.md +30 -30
  12. package/agents/test-engineer.md +30 -30
  13. package/agents/verifier.md +38 -33
  14. package/bin/cli.js +366 -364
  15. package/bin/moc +198 -198
  16. package/opencode.json +218 -170
  17. package/package.json +53 -50
  18. package/plugins/README.md +67 -64
  19. package/plugins/provider-profile.mjs +203 -139
  20. package/scripts/postinstall.js +202 -202
  21. package/scripts/validate-role-flow.mjs +90 -0
  22. package/skills/adr/SKILL.md +91 -91
  23. package/skills/adr/references/templates.md +100 -100
  24. package/skills/adr/scripts/README.md +5 -5
  25. package/skills/design-evidence/SKILL.md +56 -0
  26. package/skills/dev-flow/SKILL.md +126 -188
  27. package/skills/dev-flow/references/code-phase.md +35 -72
  28. package/skills/dev-flow/references/contract-phase.md +66 -81
  29. package/skills/dev-flow/references/verify-phase.md +70 -129
  30. package/skills/dev-flow/scripts/README.md +3 -3
  31. package/skills/docs-gen/SKILL.md +162 -162
  32. package/skills/docs-gen/references/doc-styles.md +216 -216
  33. package/skills/docs-gen/scripts/README.md +5 -5
  34. package/skills/orchestrate/SKILL.md +63 -112
  35. package/skills/orchestrate/references/orchestration-patterns.md +49 -56
  36. package/skills/pr-review/SKILL.md +110 -110
  37. package/skills/pr-review/references/review-dimensions.md +117 -117
  38. package/skills/pr-review/references/security-checklist.md +122 -122
  39. package/skills/pr-review/scripts/README.md +5 -5
  40. package/skills/test-gen/SKILL.md +143 -143
  41. package/skills/test-gen/references/framework-detection.md +105 -105
  42. package/skills/test-gen/references/test-patterns.md +260 -260
  43. package/skills/test-gen/scripts/README.md +5 -5
  44. package/agents/executor.md +0 -30
  45. package/agents/fullstack-dev.md +0 -57
  46. package/agents/spec-writer.md +0 -37
@@ -1,139 +1,203 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
- const CONFIG_PATH = path.resolve(__dirname, "..", "opencode.json");
8
-
9
- const PROFILE_MAP = Object.freeze({
10
- opencode: Object.freeze({
11
- model: "opencode-go/deepseek-v4-pro",
12
- small_model: "opencode-go/deepseek-v4-flash",
13
- heavy_model: "opencode-go/deepseek-v4-pro",
14
- }),
15
- openai: Object.freeze({
16
- model: "openai/gpt-5.4",
17
- small_model: "openai/gpt-5.4-mini",
18
- heavy_model: "openai/gpt-5.4",
19
- }),
20
- google: Object.freeze({
21
- model: "google/gemini-3.1-pro-preview-customtools",
22
- small_model: "google/gemini-3.5-flash",
23
- heavy_model: "google/gemini-3.1-pro-preview-customtools",
24
- }),
25
- copilot: Object.freeze({
26
- model: "copilot/gpt-5.4",
27
- small_model: "copilot/gpt-5.4-mini",
28
- heavy_model: "copilot/gpt-5.4",
29
- }),
30
- });
31
-
32
- const SUPPORTED_PROFILES = Object.keys(PROFILE_MAP);
33
- const HEAVY_AGENTS = ["spec-writer", "code-reviewer", "team-lead", "architect"];
34
- const ALL_OVERRIDDEN_AGENTS = [...HEAVY_AGENTS, "verifier"];
35
-
36
- function normalizeProfileValue(value) {
37
- return typeof value === "string" ? value.trim() : "";
38
- }
39
-
40
- function assertKnownProfile(value) {
41
- if (!SUPPORTED_PROFILES.includes(value)) {
42
- throw new Error(
43
- `Unknown provider profile "${value}". Must be one of: ${SUPPORTED_PROFILES.join(", ")}`,
44
- );
45
- }
46
- }
47
-
48
- function pickProfile(options = {}) {
49
- const optionProfile = normalizeProfileValue(options.profile);
50
- const envProfile = normalizeProfileValue(process.env.OPENCODE_PROVIDER_PROFILE);
51
- const activeProfile = optionProfile || envProfile || "opencode";
52
-
53
- assertKnownProfile(activeProfile);
54
-
55
- return activeProfile;
56
- }
57
-
58
- export default function resolveProfile(options = {}) {
59
- const activeProfile = pickProfile(options);
60
- const profile = PROFILE_MAP[activeProfile];
61
-
62
- return {
63
- model: profile.model,
64
- small_model: profile.small_model,
65
- agent_overrides: {
66
- "spec-writer": profile.heavy_model,
67
- verifier: profile.small_model,
68
- "code-reviewer": profile.heavy_model,
69
- "team-lead": profile.heavy_model,
70
- architect: profile.heavy_model,
71
- },
72
- };
73
- }
74
-
75
- export function buildProfileConfig(options = {}) {
76
- const resolved = resolveProfile(options);
77
-
78
- return {
79
- model: resolved.model,
80
- small_model: resolved.small_model,
81
- agent: Object.fromEntries(
82
- ALL_OVERRIDDEN_AGENTS.map((name) => [name, { model: resolved.agent_overrides[name] }]),
83
- ),
84
- };
85
- }
86
-
87
- function isProviderProfilePlugin(entry) {
88
- return typeof entry === "string" && entry.replaceAll("\\", "/").endsWith("provider-profile.mjs");
89
- }
90
-
91
- export function readPluginOptions(configPath = CONFIG_PATH) {
92
- try {
93
- const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
94
- const plugins = Array.isArray(config.plugin) ? config.plugin : [];
95
-
96
- for (const plugin of plugins) {
97
- if (Array.isArray(plugin) && plugin.length === 2 && isProviderProfilePlugin(plugin[0])) {
98
- return plugin[1] && typeof plugin[1] === "object" ? plugin[1] : {};
99
- }
100
- }
101
- } catch {
102
- return {};
103
- }
104
-
105
- return {};
106
- }
107
-
108
- /**
109
- * ProviderProfilePlugin — runtime hook placeholder (no-op).
110
- *
111
- * This is a no-op runtime hook for opencode's plugin system.
112
- * The actual model-profile switching happens outside the runtime hook:
113
- *
114
- * 1) `bin/moc` (the shell launcher) or direct invocation sets
115
- * `OPENCODE_CONFIG_CONTENT` by running this module directly:
116
- * `node plugins/provider-profile.mjs`
117
- *
118
- * 2) The direct-execution path at the bottom of this file generates
119
- * the JSON config override fragment that opencode merges at startup.
120
- *
121
- * This function exists so the module is loadable as an opencode plugin,
122
- * but no runtime transformation is needed because the config override is
123
- * already applied via `OPENCODE_CONFIG_CONTENT` at process launch.
124
- *
125
- * @returns {object} Empty object — no runtime hook behavior.
126
- */
127
- export function ProviderProfilePlugin() {
128
- return {};
129
- }
130
-
131
- function isDirectExecution() {
132
- const scriptPath = process.argv[1];
133
- return scriptPath ? path.resolve(scriptPath) === __filename : false;
134
- }
135
-
136
- if (isDirectExecution()) {
137
- const options = readPluginOptions();
138
- process.stdout.write(`${JSON.stringify(buildProfileConfig(options))}\n`);
139
- }
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ const CONFIG_PATH = path.resolve(__dirname, "..", "opencode.json");
8
+
9
+ const PROFILE_MAP = Object.freeze({
10
+ opencode: Object.freeze({
11
+ model: "opencode-go/deepseek-v4-pro",
12
+ small_model: "opencode-go/deepseek-v4-flash",
13
+ heavy_model: "opencode-go/deepseek-v4-pro",
14
+ }),
15
+ openai: Object.freeze({
16
+ model: "openai/gpt-5.6",
17
+ small_model: "openai/gpt-5.6-luna",
18
+ heavy_model: "openai/gpt-5.6",
19
+ reasoning: Object.freeze({
20
+ "openai/gpt-5.6-luna": Object.freeze({
21
+ default_effort: "low",
22
+ efforts: ["high", "medium", "low"],
23
+ }),
24
+ }),
25
+ }),
26
+ google: Object.freeze({
27
+ model: "google/gemini-3.1-pro-preview-customtools",
28
+ small_model: "google/gemini-3.5-flash",
29
+ heavy_model: "google/gemini-3.1-pro-preview-customtools",
30
+ }),
31
+ copilot: Object.freeze({
32
+ model: "github-copilot/gpt-5.6-sol",
33
+ small_model: "github-copilot/gpt-5.6-luna",
34
+ heavy_model: "github-copilot/gpt-5.6-sol",
35
+ reasoning: Object.freeze({
36
+ "github-copilot/gpt-5.6-luna": Object.freeze({
37
+ default_effort: "low",
38
+ efforts: ["high", "medium", "low"],
39
+ }),
40
+ }),
41
+ }),
42
+ });
43
+
44
+ const SUPPORTED_PROFILES = Object.keys(PROFILE_MAP);
45
+ const HEAVY_AGENTS = [
46
+ "design-evidence",
47
+ "business-analyst",
48
+ "system-designer",
49
+ "code-reviewer",
50
+ "team-lead",
51
+ "architect",
52
+ ];
53
+ const ALL_OVERRIDDEN_AGENTS = [...HEAVY_AGENTS, "verifier"];
54
+
55
+ function normalizeProfileValue(value) {
56
+ return typeof value === "string" ? value.trim() : "";
57
+ }
58
+
59
+ function assertKnownProfile(value) {
60
+ if (!SUPPORTED_PROFILES.includes(value)) {
61
+ throw new Error(
62
+ `Unknown provider profile "${value}". Must be one of: ${SUPPORTED_PROFILES.join(", ")}`,
63
+ );
64
+ }
65
+ }
66
+
67
+ function pickProfile(options = {}) {
68
+ const optionProfile = normalizeProfileValue(options.profile);
69
+ const envProfile = normalizeProfileValue(process.env.OPENCODE_PROVIDER_PROFILE);
70
+ const activeProfile = optionProfile || envProfile || "opencode";
71
+
72
+ assertKnownProfile(activeProfile);
73
+
74
+ return activeProfile;
75
+ }
76
+
77
+ export default function resolveProfile(options = {}) {
78
+ const activeProfile = pickProfile(options);
79
+ const profile = PROFILE_MAP[activeProfile];
80
+
81
+ return {
82
+ model: profile.model,
83
+ small_model: profile.small_model,
84
+ agent_overrides: {
85
+ "design-evidence": profile.heavy_model,
86
+ "business-analyst": profile.heavy_model,
87
+ "system-designer": profile.heavy_model,
88
+ verifier: profile.small_model,
89
+ "code-reviewer": profile.heavy_model,
90
+ "team-lead": profile.heavy_model,
91
+ architect: profile.heavy_model,
92
+ },
93
+ };
94
+ }
95
+
96
+ export function buildProfileConfig(options = {}) {
97
+ const activeProfile = pickProfile(options);
98
+ const profile = PROFILE_MAP[activeProfile];
99
+ const resolved = resolveProfile(options);
100
+ const provider = buildProviderOverrides(profile);
101
+
102
+ return {
103
+ model: resolved.model,
104
+ small_model: resolved.small_model,
105
+ ...(Object.keys(provider).length > 0 ? { provider } : {}),
106
+ agent: Object.fromEntries(
107
+ ALL_OVERRIDDEN_AGENTS.map((name) => [name, { model: resolved.agent_overrides[name] }]),
108
+ ),
109
+ };
110
+ }
111
+
112
+ /**
113
+ * Build the `provider` config fragment for models that need reasoning-effort
114
+ * variants (e.g. gpt-5.6-luna with high/medium/low effort switching).
115
+ *
116
+ * Output shape (merged into opencode config via OPENCODE_CONFIG_CONTENT):
117
+ * provider.openai.models["gpt-5.6-luna"] = {
118
+ * options: { reasoningEffort: <default_effort> },
119
+ * variants: { high: { reasoningEffort: "high" }, ... },
120
+ * }
121
+ */
122
+ function buildProviderOverrides(profile) {
123
+ if (!profile.reasoning) return {};
124
+
125
+ const provider = {};
126
+ for (const [modelRef, cfg] of Object.entries(profile.reasoning)) {
127
+ const [providerId, ...rest] = modelRef.split("/");
128
+ const modelId = rest.join("/");
129
+ if (!providerId || !modelId) continue;
130
+
131
+ const variants = {};
132
+ for (const effort of cfg.efforts) {
133
+ variants[effort] = { reasoningEffort: effort };
134
+ }
135
+
136
+ const modelConfig = { variants };
137
+ if (cfg.default_effort) {
138
+ modelConfig.options = { reasoningEffort: cfg.default_effort };
139
+ }
140
+
141
+ provider[providerId] = {
142
+ models: {
143
+ [modelId]: modelConfig,
144
+ },
145
+ };
146
+ }
147
+
148
+ return provider;
149
+ }
150
+
151
+ function isProviderProfilePlugin(entry) {
152
+ return typeof entry === "string" && entry.replaceAll("\\", "/").endsWith("provider-profile.mjs");
153
+ }
154
+
155
+ export function readPluginOptions(configPath = CONFIG_PATH) {
156
+ try {
157
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
158
+ const plugins = Array.isArray(config.plugin) ? config.plugin : [];
159
+
160
+ for (const plugin of plugins) {
161
+ if (Array.isArray(plugin) && plugin.length === 2 && isProviderProfilePlugin(plugin[0])) {
162
+ return plugin[1] && typeof plugin[1] === "object" ? plugin[1] : {};
163
+ }
164
+ }
165
+ } catch {
166
+ return {};
167
+ }
168
+
169
+ return {};
170
+ }
171
+
172
+ /**
173
+ * ProviderProfilePlugin — runtime hook placeholder (no-op).
174
+ *
175
+ * This is a no-op runtime hook for opencode's plugin system.
176
+ * The actual model-profile switching happens outside the runtime hook:
177
+ *
178
+ * 1) `bin/moc` (the shell launcher) or direct invocation sets
179
+ * `OPENCODE_CONFIG_CONTENT` by running this module directly:
180
+ * `node plugins/provider-profile.mjs`
181
+ *
182
+ * 2) The direct-execution path at the bottom of this file generates
183
+ * the JSON config override fragment that opencode merges at startup.
184
+ *
185
+ * This function exists so the module is loadable as an opencode plugin,
186
+ * but no runtime transformation is needed because the config override is
187
+ * already applied via `OPENCODE_CONFIG_CONTENT` at process launch.
188
+ *
189
+ * @returns {object} Empty object — no runtime hook behavior.
190
+ */
191
+ export function ProviderProfilePlugin() {
192
+ return {};
193
+ }
194
+
195
+ function isDirectExecution() {
196
+ const scriptPath = process.argv[1];
197
+ return scriptPath ? path.resolve(scriptPath) === __filename : false;
198
+ }
199
+
200
+ if (isDirectExecution()) {
201
+ const options = readPluginOptions();
202
+ process.stdout.write(`${JSON.stringify(buildProfileConfig(options))}\n`);
203
+ }