opencode-codeops 1.5.0 → 1.6.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to CodeOps are recorded here.
4
4
 
5
+ ## 1.6.0 — 2026-09-19
6
+
7
+ ### Features
8
+
9
+ - installer: register the plugin automatically on install/update
10
+ - installer: unify install/update into one command
11
+ - installer: add npm-first install, agents installer, and release tooling
12
+
5
13
  ## 1.5.0 — 2026-09-19
6
14
 
7
15
  ### Features
package/README.md CHANGED
@@ -27,29 +27,8 @@ Turn an idea or existing system into ambiguity-free requirements, grounded speci
27
27
 
28
28
  ## Installation
29
29
 
30
- CodeOps has two parts that OpenCode loads differently: the **plugin** (standards and hooks) is
31
- installed by OpenCode from npm, and the **skills** and **subagents** must be copied onto the
32
- filesystem because OpenCode only discovers those from disk.
33
-
34
- ### 1. Add the plugin
35
-
36
- Add to your `opencode.json`:
37
-
38
- ```json
39
- {
40
- "$schema": "https://opencode.ai/config.json",
41
- "plugin": ["opencode-codeops"]
42
- }
43
- ```
44
-
45
- OpenCode installs the plugin automatically via Bun on next startup. A global config
46
- (`~/.config/opencode/opencode.json`) is recommended so CodeOps is active in every project.
47
-
48
- ### 2. Install the skills and subagents
49
-
50
- OpenCode discovers skills and subagents only from the filesystem; it never reads them from a plugin
51
- package. One command installs both. The installer is a thin `npx` wrapper around this package, so
52
- the installed files always match the published version:
30
+ One command installs everything CodeOps owns: the skills, the subagents, and the OpenCode plugin
31
+ entry in your config.
53
32
 
54
33
  ```bash
55
34
  # Global (recommended) — available in every OpenCode project
@@ -66,22 +45,34 @@ npx -y opencode-codeops@latest install
66
45
  npx -y opencode-codeops@latest update # alias of install
67
46
  ```
68
47
 
48
+ `install`/`update` writes the skills and subagents onto the filesystem (OpenCode discovers those
49
+ only from disk), then registers the plugin in the OpenCode config by calling OpenCode's own
50
+ `opencode plugin` command, so standards injection and `CODEOPS_PLUGIN_ROOT` are enabled. Restart
51
+ OpenCode after installing for the plugin to load. Pass `--no-plugin` to manage the config yourself.
52
+
69
53
  The scope is auto-detected: inside a CodeOps project (a git repo with `.opencode/` or
70
- `codeops/.codeops.yml`) it installs into `./.opencode/skills` and `./.opencode/agents`; anywhere
71
- else it installs globally into `~/.config/opencode/`. Pass `--project` or `--global` to force one.
54
+ `codeops/.codeops.yml`) it installs into `./.opencode`, and registers the plugin in the project
55
+ config; anywhere else it installs globally into `~/.config/opencode` and the global config. Pass
56
+ `--project` or `--global` to force one.
72
57
 
73
- Pin a version with `CODEOPS_VERSION` (an npm dist-tag or exact version; defaults to `latest`):
58
+ If you prefer to register the plugin manually instead, add it to your `opencode.json`:
74
59
 
75
- ```bash
76
- CODEOPS_VERSION=1.5.0 curl -fsSL https://cdn.jsdelivr.net/npm/opencode-codeops@latest/install.sh | bash
60
+ ```json
61
+ {
62
+ "$schema": "https://opencode.ai/config.json",
63
+ "plugin": ["opencode-codeops"]
64
+ }
77
65
  ```
78
66
 
79
- Pin the plugin to the same version so the two cannot drift apart:
67
+ Pin a version with `CODEOPS_VERSION` (an npm dist-tag or exact version; defaults to `latest`):
80
68
 
81
- ```json
82
- { "plugin": ["opencode-codeops@1.5.0"] }
69
+ ```bash
70
+ CODEOPS_VERSION=1.6.0 curl -fsSL https://cdn.jsdelivr.net/npm/opencode-codeops@latest/install.sh | bash
83
71
  ```
84
72
 
73
+ `install`/`update` pins the plugin in the OpenCode config to the installer's own version, so the
74
+ plugin and the installed files cannot drift apart; run `update` to move both to a new version.
75
+
85
76
  Re-running the installer upgrades an existing install in place. It replaces only the files this
86
77
  package owns, recorded in `.opencode-codeops.json`. Files you author yourself, or install with
87
78
  another tool, are left untouched.
@@ -93,21 +84,24 @@ npx -y opencode-codeops@latest status
93
84
  npx -y opencode-codeops@latest uninstall
94
85
  ```
95
86
 
96
- `status` reports the installed version next to the current package version, so a plugin/files
87
+ `status` reports the installed skills and agents versions and the configured plugin entry, so a
97
88
  mismatch is visible. Use `--dry-run` to preview an install; a same-named file the package does not
98
- own is skipped with a warning, and `--force` replaces it.
89
+ own is skipped with a warning, and `--force` replaces it. `uninstall` removes the skills and
90
+ subagents but leaves the plugin entry in your config; remove `opencode-codeops` from the `plugin`
91
+ array by hand to fully disable it.
99
92
 
100
93
  ### Local development
101
94
 
102
95
  Symlink the plugin into your OpenCode plugin directory and link the installed files to a checkout,
103
- so edits are picked up without reinstalling:
96
+ so edits are picked up without reinstalling. Pass `--no-plugin` so the checkout is not overwritten
97
+ by a registered npm plugin:
104
98
 
105
99
  ```bash
106
100
  # Plugin (project or global plugin directory)
107
101
  ln -s /path/to/opencode-codeops/plugin/index.ts ~/.config/opencode/plugins/codeops.ts
108
102
 
109
103
  # Skills and agents — link instead of copy
110
- node /path/to/opencode-codeops/bin/index.mjs install --link --global
104
+ node /path/to/opencode-codeops/bin/index.mjs install --link --global --no-plugin
111
105
  ```
112
106
 
113
107
  ## Setup
package/bin/index.mjs CHANGED
@@ -27,6 +27,8 @@ import { existsSync, realpathSync } from "node:fs"
27
27
  import { join } from "node:path"
28
28
  import { fileURLToPath } from "node:url"
29
29
 
30
+ import { PLUGIN_NAME, readConfiguredPlugin, registerPlugin } from "./lib/opencode-plugin.mjs"
31
+
30
32
  /** Commands this CLI understands. */
31
33
  const COMMANDS = new Set(["install", "update", "status", "uninstall", "help"])
32
34
 
@@ -47,10 +49,15 @@ Options:
47
49
  --dry-run Show what would happen without writing files
48
50
  --force Replace same-named files this package does not own
49
51
  --link Symlink to the source instead of copying (development)
52
+ --no-plugin Do not register the plugin in the OpenCode config
50
53
  -h, --help Show this help
51
54
 
52
55
  Scope is auto-detected: inside a CodeOps project (a git repo with .opencode/ or
53
- codeops/.codeops.yml) the files go to .opencode/; otherwise to ~/.config/opencode/.`)
56
+ codeops/.codeops.yml) the files go to .opencode/; otherwise to ~/.config/opencode/.
57
+
58
+ install/update also register the CodeOps plugin in the OpenCode config (unless
59
+ --no-plugin), so standards injection and CODEOPS_PLUGIN_ROOT are enabled. Restart
60
+ OpenCode after installing for the plugin to load.`)
54
61
  }
55
62
 
56
63
  /**
@@ -108,16 +115,46 @@ async function runCombined(command, rest, io) {
108
115
  const agents = await import("./install-agents.mjs")
109
116
 
110
117
  const cwd = io.cwd ?? process.cwd()
118
+ const noPlugin = rest.includes("--no-plugin")
119
+ const dryRun = rest.includes("--dry-run")
111
120
  const scope = resolveScope(
112
121
  { project: rest.includes("--project"), global: rest.includes("--global") },
113
122
  cwd
114
123
  )
115
- const passed = rest.filter((arg) => arg !== "--project" && arg !== "--global")
124
+ const passed = rest.filter(
125
+ (arg) => arg !== "--project" && arg !== "--global" && arg !== "--no-plugin"
126
+ )
116
127
  const scoped = [scope === "project" ? "--project" : "--global", ...passed]
117
128
 
118
129
  const skillsCode = skills.main([command, ...scoped], io)
119
130
  const agentsCode = agents.main([command, ...scoped], io)
120
- return skillsCode || agentsCode
131
+ const code = skillsCode || agentsCode
132
+
133
+ if (command === "install" && code === 0 && !noPlugin && !dryRun) {
134
+ const version = io.version ?? skills.readPackageVersion()
135
+ const result = registerPlugin({ scope, version, cwd, run: io.run })
136
+ if (result.ok) {
137
+ console.log(`Plugin: registered ${result.spec} in the ${scope} OpenCode config.`)
138
+ console.log("Restart OpenCode to load the plugin.")
139
+ } else {
140
+ console.log(
141
+ `Plugin: not registered (${result.reason}). ` +
142
+ `Add "${PLUGIN_NAME}" to the "plugin" array in your opencode.json.`
143
+ )
144
+ }
145
+ }
146
+
147
+ if (command === "status") {
148
+ const plugins = readConfiguredPlugin({ cwd, run: io.run })
149
+ if (plugins === undefined) {
150
+ console.log("plugin: opencode CLI unavailable; cannot read the config")
151
+ } else {
152
+ const entry = plugins.find((item) => String(item).startsWith(PLUGIN_NAME))
153
+ console.log(entry ? `plugin: configured (${entry})` : "plugin: not configured")
154
+ }
155
+ }
156
+
157
+ return code
121
158
  }
122
159
 
123
160
  /**
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Registers (or inspects) the CodeOps plugin in OpenCode's own config.
4
+ *
5
+ * OpenCode ships a command that installs a plugin and updates the config
6
+ * safely, including JSON/JSONC formatting and version replacement:
7
+ *
8
+ * opencode plugin <module> [--global] [--force]
9
+ *
10
+ * The installer delegates to that command instead of editing `opencode.json`
11
+ * itself, so it never has to parse JSONC or risk clobbering a user's config.
12
+ * All calls are best-effort: if the `opencode` executable is missing or the
13
+ * command fails, the caller still completes the file install and tells the user
14
+ * how to register the plugin manually.
15
+ *
16
+ * @module lib/opencode-plugin
17
+ */
18
+
19
+ import { spawnSync } from "node:child_process"
20
+
21
+ /** The npm package name of the plugin. */
22
+ export const PLUGIN_NAME = "opencode-codeops"
23
+
24
+ /**
25
+ * Runs a command and normalizes the result.
26
+ *
27
+ * @param command - Executable to run
28
+ * @param args - Argument list
29
+ * @param options - Spawn options (for example `cwd`)
30
+ * @returns The exit status, stdout, stderr, and any spawn error
31
+ */
32
+ export function defaultRun(command, args, options = {}) {
33
+ const result = spawnSync(command, args, { encoding: "utf-8", ...options })
34
+ return {
35
+ status: result.status ?? 1,
36
+ stdout: result.stdout ?? "",
37
+ stderr: result.stderr ?? "",
38
+ error: result.error,
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Builds the arguments for `opencode plugin`.
44
+ *
45
+ * @param details - Plugin registration inputs
46
+ * @param details.scope - `"global"` adds `--global`; `"project"` omits it
47
+ * @param details.version - Exact version to pin, or `undefined` for the bare name
48
+ * @returns Arguments after the `opencode` executable
49
+ * @example
50
+ * buildPluginArgs({ scope: "global", version: "1.0.0" })
51
+ * // ["plugin", "opencode-codeops@1.0.0", "--global", "--force"]
52
+ */
53
+ export function buildPluginArgs({ scope, version }) {
54
+ const module = version ? `${PLUGIN_NAME}@${version}` : PLUGIN_NAME
55
+ const args = ["plugin", module]
56
+ if (scope === "global") args.push("--global")
57
+ args.push("--force")
58
+ return args
59
+ }
60
+
61
+ /**
62
+ * Registers the plugin in the OpenCode config.
63
+ *
64
+ * Tries the exact version first so plugin and files stay in sync; if the CLI
65
+ * rejects the versioned spec, falls back to the bare package name. Never throws.
66
+ *
67
+ * @param details - Registration inputs
68
+ * @param details.scope - `"global"` or `"project"`
69
+ * @param details.version - Version to pin
70
+ * @param details.cwd - Working directory (used for project scope)
71
+ * @param details.run - Command runner, injectable for tests
72
+ * @returns Whether registration succeeded, the spec used, and a reason on failure
73
+ */
74
+ export function registerPlugin({ scope, version, cwd, run = defaultRun }) {
75
+ try {
76
+ const probe = run("opencode", ["--version"], { cwd })
77
+ if (probe.error || probe.status !== 0) {
78
+ return { ok: false, spec: null, reason: "opencode CLI not found on PATH" }
79
+ }
80
+
81
+ const pinned = run("opencode", buildPluginArgs({ scope, version }), { cwd })
82
+ if (!pinned.error && pinned.status === 0) {
83
+ return { ok: true, spec: `${PLUGIN_NAME}@${version}` }
84
+ }
85
+
86
+ const bare = run("opencode", buildPluginArgs({ scope, version: null }), { cwd })
87
+ if (!bare.error && bare.status === 0) {
88
+ return { ok: true, spec: PLUGIN_NAME }
89
+ }
90
+
91
+ const message = (bare.stderr || bare.stdout || pinned.stderr || pinned.stdout || "").trim()
92
+ return { ok: false, spec: null, reason: message.split("\n").pop() || "opencode plugin failed" }
93
+ } catch (caught) {
94
+ return { ok: false, spec: null, reason: caught.message }
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Reads the resolved `plugin` list from OpenCode's effective config.
100
+ *
101
+ * @param details - Inspection inputs
102
+ * @param details.cwd - Working directory
103
+ * @param details.run - Command runner, injectable for tests
104
+ * @returns The plugin entries, or `undefined` when the config cannot be read
105
+ */
106
+ export function readConfiguredPlugin({ cwd, run = defaultRun } = {}) {
107
+ try {
108
+ const result = run("opencode", ["debug", "config"], { cwd })
109
+ if (result.error || result.status !== 0) return undefined
110
+
111
+ const config = JSON.parse(result.stdout)
112
+ return Array.isArray(config.plugin) ? config.plugin : []
113
+ } catch {
114
+ return undefined
115
+ }
116
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codeops",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Specification-first engineering for complex systems — CodeOps plugin for OpenCode",
5
5
  "type": "module",
6
6
  "engines": {