my-opencode 1.3.4 → 3.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 (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +309 -271
  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 +206 -198
  16. package/bin/moc.js +9 -3
  17. package/opencode.json +240 -170
  18. package/package.json +53 -51
  19. package/plugins/README.md +74 -67
  20. package/plugins/provider-profile.mjs +238 -194
  21. package/scripts/postinstall.js +202 -202
  22. package/scripts/validate-role-flow.mjs +90 -0
  23. package/skills/adr/SKILL.md +91 -91
  24. package/skills/adr/references/templates.md +100 -100
  25. package/skills/adr/scripts/README.md +5 -5
  26. package/skills/design-evidence/SKILL.md +56 -0
  27. package/skills/dev-flow/SKILL.md +126 -188
  28. package/skills/dev-flow/references/code-phase.md +35 -72
  29. package/skills/dev-flow/references/contract-phase.md +66 -81
  30. package/skills/dev-flow/references/verify-phase.md +70 -129
  31. package/skills/dev-flow/scripts/README.md +3 -3
  32. package/skills/docs-gen/SKILL.md +162 -162
  33. package/skills/docs-gen/references/doc-styles.md +216 -216
  34. package/skills/docs-gen/scripts/README.md +5 -5
  35. package/skills/orchestrate/SKILL.md +63 -112
  36. package/skills/orchestrate/references/orchestration-patterns.md +49 -56
  37. package/skills/pr-review/SKILL.md +110 -110
  38. package/skills/pr-review/references/review-dimensions.md +117 -117
  39. package/skills/pr-review/references/security-checklist.md +122 -122
  40. package/skills/pr-review/scripts/README.md +5 -5
  41. package/skills/test-gen/SKILL.md +143 -143
  42. package/skills/test-gen/references/framework-detection.md +105 -105
  43. package/skills/test-gen/references/test-patterns.md +260 -260
  44. package/skills/test-gen/scripts/README.md +5 -5
  45. package/agents/executor.md +0 -30
  46. package/agents/fullstack-dev.md +0 -57
  47. package/agents/spec-writer.md +0 -37
package/bin/moc CHANGED
@@ -1,199 +1,207 @@
1
1
  #!/bin/sh
2
-
3
- profile=
4
- known_profiles="opencode openai google copilot"
5
-
6
- print_help() {
7
- cat <<'EOF'
8
- Usage:
9
- moc [profile] [opencode-args...]
10
- moc --help
11
- moc doctor [profile]
12
- moc print-config [profile]
13
-
14
- Profiles:
15
- opencode | openai | google | copilot
16
-
17
- Examples:
18
- moc
19
- moc google
20
- moc openai --list-agents
21
- moc doctor google
22
- moc print-config google
23
-
24
- Notes:
25
- - `moc` without extra args launches interactive opencode.
26
- - Use `moc doctor` or `moc print-config` for non-interactive debugging.
27
- EOF
28
- }
29
-
30
- print_doctor() {
31
- active_profile=$1
32
- printf 'profile=%s\n' "$active_profile"
33
- printf 'plugin_path=%s\n' "$plugin_path"
34
- printf 'config_path=%s\n' "$config_path"
35
- printf 'cache_content_path=%s\n' "$cache_content_path"
36
- printf 'cache_meta_path=%s\n' "$cache_meta_path"
37
- printf 'plugin_exists=%s\n' "$( [ -f "$plugin_path" ] && printf yes || printf no )"
38
- printf 'config_exists=%s\n' "$( [ -f "$config_path" ] && printf yes || printf no )"
39
- printf 'cache_content_exists=%s\n' "$( [ -f "$cache_content_path" ] && printf yes || printf no )"
40
- printf 'cache_meta_exists=%s\n' "$( [ -f "$cache_meta_path" ] && printf yes || printf no )"
41
- }
42
-
43
- case "${1-}" in
44
- --help|-h|help)
45
- print_help
46
- exit 0
47
- ;;
48
- "")
49
- profile=opencode
50
- ;;
51
- doctor)
52
- profile=${2-opencode}
53
- ;;
54
- print-config)
55
- profile=${2-opencode}
56
- ;;
57
- opencode|openai|google|copilot)
58
- profile=$1
59
- shift
60
- ;;
61
- esac
62
-
63
- if [ -z "$profile" ]; then
64
- exec opencode "$@"
65
- fi
66
-
67
- case "$profile" in
68
- opencode|openai|google|copilot)
69
- ;;
70
- *)
71
- printf '%s\n' "moc: unknown profile '$profile'. Must be one of: $known_profiles" >&2
72
- exit 1
73
- ;;
74
- esac
75
-
76
- exec_opencode_with_profile() {
77
- exec env \
78
- OPENCODE_PROVIDER_PROFILE="$profile" \
79
- OPENCODE_CONFIG_CONTENT="$config_content" \
80
- opencode "$@"
81
- }
82
-
83
- plugin_path=.opencode/plugins/provider-profile.mjs
84
- config_path=.opencode/opencode.json
85
- cache_dir=.opencode/cache/provider-profile
86
- cache_content_path=$cache_dir/$profile.json
87
- cache_meta_path=$cache_dir/$profile.meta
88
-
89
- get_mtime() {
90
- if stat -f %m "$1" >/dev/null 2>&1; then
91
- stat -f %m "$1"
92
- else
93
- stat -c %Y "$1"
94
- fi
95
- }
96
-
97
- read_meta() {
98
- meta_profile=
99
- meta_plugin_mtime=
100
- meta_config_mtime=
101
-
102
- [ -f "$1" ] || return 1
103
-
104
- while IFS='=' read -r key value; do
105
- case "$key" in
106
- profile) meta_profile=$value ;;
107
- plugin_mtime) meta_plugin_mtime=$value ;;
108
- config_mtime) meta_config_mtime=$value ;;
109
- esac
110
- done < "$1"
111
-
112
- [ -n "$meta_profile" ] && [ -n "$meta_plugin_mtime" ] && [ -n "$meta_config_mtime" ]
113
- }
114
-
115
- write_cache() {
116
- tmp_content=$cache_content_path.tmp.$$
117
- tmp_meta=$cache_meta_path.tmp.$$
118
-
119
- if ! mkdir -p "$cache_dir" 2>/dev/null; then
120
- return 1
121
- fi
122
-
123
- if ! printf '%s\n' "$1" > "$tmp_content"; then
124
- rm -f "$tmp_content" "$tmp_meta"
125
- return 1
126
- fi
127
-
128
- if ! {
129
- printf 'profile=%s\n' "$profile"
130
- printf 'plugin_mtime=%s\n' "$plugin_mtime"
131
- printf 'config_mtime=%s\n' "$config_mtime"
132
- } > "$tmp_meta"; then
133
- rm -f "$tmp_content" "$tmp_meta"
134
- return 1
135
- fi
136
-
137
- if ! mv "$tmp_content" "$cache_content_path" || ! mv "$tmp_meta" "$cache_meta_path"; then
138
- rm -f "$tmp_content" "$tmp_meta"
139
- return 1
140
- fi
141
-
142
- return 0
143
- }
144
-
145
- if [ ! -f "$plugin_path" ]; then
146
- printf '%s\n' "moc: plugin not found at $plugin_path; falling back to plain opencode" >&2
147
- exec opencode "$@"
148
- fi
149
-
150
- if [ ! -f "$config_path" ]; then
151
- printf '%s\n' "moc: config not found at $config_path; cannot compute provider profile override" >&2
152
- exit 1
153
- fi
154
-
155
- case "${1-}" in
156
- doctor)
157
- print_doctor "$profile"
158
- exit 0
159
- ;;
160
- esac
161
-
162
- plugin_mtime=$(get_mtime "$plugin_path") || {
163
- printf '%s\n' "moc: failed to read plugin mtime from $plugin_path" >&2
164
- exit 1
165
- }
166
-
167
- config_mtime=$(get_mtime "$config_path") || {
168
- printf '%s\n' "moc: failed to read config mtime from $config_path" >&2
169
- exit 1
170
- }
171
-
172
- config_content=
173
-
174
- if read_meta "$cache_meta_path" && [ -f "$cache_content_path" ]; then
175
- if [ "$meta_profile" = "$profile" ] \
176
- && [ "$meta_plugin_mtime" = "$plugin_mtime" ] \
177
- && [ "$meta_config_mtime" = "$config_mtime" ]; then
178
- config_content=$(tr -d '\n' < "$cache_content_path") || config_content=
179
- fi
180
- fi
181
-
182
- if [ -z "$config_content" ]; then
183
- if ! config_content=$(OPENCODE_PROVIDER_PROFILE=$profile node "$plugin_path"); then
184
- printf '%s\n' "moc: failed to compute OPENCODE_CONFIG_CONTENT from $plugin_path" >&2
185
- exit 1
186
- fi
187
-
188
- write_cache "$config_content" || \
189
- printf '%s\n' "moc: warning: failed to update cache at $cache_dir; continuing with fresh config" >&2
190
- fi
191
-
192
- case "${1-}" in
193
- print-config)
194
- printf '%s\n' "$config_content"
195
- exit 0
196
- ;;
197
- esac
198
-
199
- exec_opencode_with_profile "$@"
2
+
3
+ profile=
4
+ known_profiles="opencode openai copilot anthropic"
5
+
6
+ print_help() {
7
+ cat <<'EOF'
8
+ Usage:
9
+ moc [profile] [opencode-args...]
10
+ moc --help
11
+ moc doctor [profile]
12
+ moc print-config [profile]
13
+
14
+ Profiles:
15
+ opencode | openai | copilot | anthropic
16
+
17
+ Examples:
18
+ moc
19
+ moc openai --list-agents
20
+ moc doctor anthropic
21
+ moc print-config anthropic
22
+
23
+ Notes:
24
+ - `moc` without extra args launches interactive opencode.
25
+ - Use `moc doctor` or `moc print-config` for non-interactive debugging.
26
+ EOF
27
+ }
28
+
29
+ print_doctor() {
30
+ active_profile=$1
31
+ printf 'profile=%s\n' "$active_profile"
32
+ printf 'plugin_path=%s\n' "$plugin_path"
33
+ printf 'config_path=%s\n' "$config_path"
34
+ printf 'cache_content_path=%s\n' "$cache_content_path"
35
+ printf 'cache_meta_path=%s\n' "$cache_meta_path"
36
+ printf 'plugin_exists=%s\n' "$( [ -f "$plugin_path" ] && printf yes || printf no )"
37
+ printf 'config_exists=%s\n' "$( [ -f "$config_path" ] && printf yes || printf no )"
38
+ printf 'cache_content_exists=%s\n' "$( [ -f "$cache_content_path" ] && printf yes || printf no )"
39
+ printf 'cache_meta_exists=%s\n' "$( [ -f "$cache_meta_path" ] && printf yes || printf no )"
40
+ }
41
+
42
+ case "${1-}" in
43
+ --help|-h|help)
44
+ print_help
45
+ exit 0
46
+ ;;
47
+ "")
48
+ profile=opencode
49
+ ;;
50
+ doctor)
51
+ profile=${2-opencode}
52
+ ;;
53
+ print-config)
54
+ profile=${2-opencode}
55
+ ;;
56
+ opencode|openai|copilot|anthropic)
57
+ profile=$1
58
+ shift
59
+ ;;
60
+ esac
61
+
62
+ if [ -z "$profile" ]; then
63
+ exec opencode "$@"
64
+ fi
65
+
66
+ case "$profile" in
67
+ opencode|openai|copilot|anthropic)
68
+ ;;
69
+ *)
70
+ printf '%s\n' "moc: unknown profile '$profile'. Must be one of: $known_profiles" >&2
71
+ exit 1
72
+ ;;
73
+ esac
74
+
75
+ exec_opencode_with_profile() {
76
+ # Profile launches always use a private server (--standalone). A background
77
+ # service started without this profile env would otherwise ignore it.
78
+ standalone_flag=--standalone
79
+ for arg in "$@"; do
80
+ if [ "$arg" = "--standalone" ]; then
81
+ standalone_flag=
82
+ fi
83
+ done
84
+
85
+ exec env \
86
+ OPENCODE_PROVIDER_PROFILE="$profile" \
87
+ OPENCODE_CONFIG_CONTENT="$config_content" \
88
+ opencode ${standalone_flag:+"$standalone_flag"} "$@"
89
+ }
90
+
91
+ plugin_path=.opencode/plugins/provider-profile.mjs
92
+ config_path=.opencode/opencode.json
93
+ cache_dir=.opencode/cache/provider-profile
94
+ cache_content_path=$cache_dir/$profile.json
95
+ cache_meta_path=$cache_dir/$profile.meta
96
+
97
+ get_mtime() {
98
+ if stat -f %m "$1" >/dev/null 2>&1; then
99
+ stat -f %m "$1"
100
+ else
101
+ stat -c %Y "$1"
102
+ fi
103
+ }
104
+
105
+ read_meta() {
106
+ meta_profile=
107
+ meta_plugin_mtime=
108
+ meta_config_mtime=
109
+
110
+ [ -f "$1" ] || return 1
111
+
112
+ while IFS='=' read -r key value; do
113
+ case "$key" in
114
+ profile) meta_profile=$value ;;
115
+ plugin_mtime) meta_plugin_mtime=$value ;;
116
+ config_mtime) meta_config_mtime=$value ;;
117
+ esac
118
+ done < "$1"
119
+
120
+ [ -n "$meta_profile" ] && [ -n "$meta_plugin_mtime" ] && [ -n "$meta_config_mtime" ]
121
+ }
122
+
123
+ write_cache() {
124
+ tmp_content=$cache_content_path.tmp.$$
125
+ tmp_meta=$cache_meta_path.tmp.$$
126
+
127
+ if ! mkdir -p "$cache_dir" 2>/dev/null; then
128
+ return 1
129
+ fi
130
+
131
+ if ! printf '%s\n' "$1" > "$tmp_content"; then
132
+ rm -f "$tmp_content" "$tmp_meta"
133
+ return 1
134
+ fi
135
+
136
+ if ! {
137
+ printf 'profile=%s\n' "$profile"
138
+ printf 'plugin_mtime=%s\n' "$plugin_mtime"
139
+ printf 'config_mtime=%s\n' "$config_mtime"
140
+ } > "$tmp_meta"; then
141
+ rm -f "$tmp_content" "$tmp_meta"
142
+ return 1
143
+ fi
144
+
145
+ if ! mv "$tmp_content" "$cache_content_path" || ! mv "$tmp_meta" "$cache_meta_path"; then
146
+ rm -f "$tmp_content" "$tmp_meta"
147
+ return 1
148
+ fi
149
+
150
+ return 0
151
+ }
152
+
153
+ if [ ! -f "$plugin_path" ]; then
154
+ printf '%s\n' "moc: plugin not found at $plugin_path; falling back to plain opencode" >&2
155
+ exec opencode "$@"
156
+ fi
157
+
158
+ if [ ! -f "$config_path" ]; then
159
+ printf '%s\n' "moc: config not found at $config_path; cannot compute provider profile override" >&2
160
+ exit 1
161
+ fi
162
+
163
+ case "${1-}" in
164
+ doctor)
165
+ print_doctor "$profile"
166
+ exit 0
167
+ ;;
168
+ esac
169
+
170
+ plugin_mtime=$(get_mtime "$plugin_path") || {
171
+ printf '%s\n' "moc: failed to read plugin mtime from $plugin_path" >&2
172
+ exit 1
173
+ }
174
+
175
+ config_mtime=$(get_mtime "$config_path") || {
176
+ printf '%s\n' "moc: failed to read config mtime from $config_path" >&2
177
+ exit 1
178
+ }
179
+
180
+ config_content=
181
+
182
+ if read_meta "$cache_meta_path" && [ -f "$cache_content_path" ]; then
183
+ if [ "$meta_profile" = "$profile" ] \
184
+ && [ "$meta_plugin_mtime" = "$plugin_mtime" ] \
185
+ && [ "$meta_config_mtime" = "$config_mtime" ]; then
186
+ config_content=$(tr -d '\n' < "$cache_content_path") || config_content=
187
+ fi
188
+ fi
189
+
190
+ if [ -z "$config_content" ]; then
191
+ if ! config_content=$(OPENCODE_PROVIDER_PROFILE=$profile node "$plugin_path"); then
192
+ printf '%s\n' "moc: failed to compute OPENCODE_CONFIG_CONTENT from $plugin_path" >&2
193
+ exit 1
194
+ fi
195
+
196
+ write_cache "$config_content" || \
197
+ printf '%s\n' "moc: warning: failed to update cache at $cache_dir; continuing with fresh config" >&2
198
+ fi
199
+
200
+ case "${1-}" in
201
+ print-config)
202
+ printf '%s\n' "$config_content"
203
+ exit 0
204
+ ;;
205
+ esac
206
+
207
+ exec_opencode_with_profile "$@"
package/bin/moc.js CHANGED
@@ -5,8 +5,8 @@ import fs from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import { spawn, spawnSync } from 'node:child_process';
7
7
 
8
- const knownProfiles = new Set(['opencode', 'openai', 'google', 'copilot']);
9
- const knownProfilesText = 'opencode openai google copilot';
8
+ const knownProfiles = new Set(['opencode', 'openai', 'copilot', 'anthropic']);
9
+ const knownProfilesText = 'opencode openai copilot anthropic';
10
10
  const signalExitCodes = {
11
11
  SIGHUP: 1,
12
12
  SIGINT: 2,
@@ -341,7 +341,13 @@ function main() {
341
341
  process.exit(0);
342
342
  }
343
343
 
344
- spawnOpencode(forwardedArgs, {
344
+ // Profile launches always use a private server (--standalone). A background
345
+ // service started without this profile env would otherwise ignore it.
346
+ const launchArgs = forwardedArgs.includes('--standalone')
347
+ ? forwardedArgs
348
+ : ['--standalone', ...forwardedArgs];
349
+
350
+ spawnOpencode(launchArgs, {
345
351
  OPENCODE_PROVIDER_PROFILE: profile,
346
352
  OPENCODE_CONFIG_CONTENT: configContent,
347
353
  });