opencode-codeops 1.6.0 → 1.7.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,18 @@
2
2
 
3
3
  All notable changes to CodeOps are recorded here.
4
4
 
5
+ ## 1.7.0 — 2026-09-24
6
+
7
+ ### Fixes
8
+
9
+ - installer: install _shared and references beside the skills
10
+
11
+ ### Features
12
+
13
+ - installer: register the plugin automatically on install/update
14
+ - installer: unify install/update into one command
15
+ - installer: add npm-first install, agents installer, and release tooling
16
+
5
17
  ## 1.6.0 — 2026-09-19
6
18
 
7
19
  ### Features
package/README.md CHANGED
@@ -50,6 +50,11 @@ only from disk), then registers the plugin in the OpenCode config by calling Ope
50
50
  `opencode plugin` command, so standards injection and `CODEOPS_PLUGIN_ROOT` are enabled. Restart
51
51
  OpenCode after installing for the plugin to load. Pass `--no-plugin` to manage the config yourself.
52
52
 
53
+ The installer also places the shared `_shared/` and `references/` documents beside the installed
54
+ `skills/` directory (for example `~/.config/opencode/_shared`), so the skills' relative links to
55
+ them resolve at their installed location. An existing directory with either name is only replaced
56
+ with `--force`.
57
+
53
58
  The scope is auto-detected: inside a CodeOps project (a git repo with `.opencode/` or
54
59
  `codeops/.codeops.yml`) it installs into `./.opencode`, and registers the plugin in the project
55
60
  config; anywhere else it installs globally into `~/.config/opencode` and the global config. Pass
@@ -46,6 +46,18 @@ import {
46
46
  // package root that contains skills/ and package.json.
47
47
  const PACKAGE_ROOT = dirname(dirname(fileURLToPath(import.meta.url)))
48
48
 
49
+ /**
50
+ * Package-root sibling directories that the installed skills reference with
51
+ * `../../<name>/...` links.
52
+ *
53
+ * The skills live in `skills/<skill>/`, so `../../_shared/...` and
54
+ * `../../references/...` only resolve when these directories sit beside the
55
+ * installed `skills` directory. The installer copies them from the parent of
56
+ * the source skills directory into the parent of the install target, and
57
+ * records them in the marker so `uninstall` can remove them.
58
+ */
59
+ export const SHARED_DIRS = ["_shared", "references"]
60
+
49
61
  export { MARKER_FILE, readMarker }
50
62
 
51
63
  /**
@@ -120,14 +132,17 @@ export function listSkills(sourceDir) {
120
132
  * @param details - Marker contents
121
133
  * @param details.version - Installed package version
122
134
  * @param details.skills - Skill directory names the package owns
135
+ * @param details.shared - Shared directory names the package owns, installed
136
+ * beside the skills directory; defaults to an empty list for older callers
123
137
  */
124
- export function writeMarker(targetDir, { version, skills }) {
138
+ export function writeMarker(targetDir, { version, skills, shared = [] }) {
125
139
  writeMarkerFile(targetDir, {
126
140
  schema: 1,
127
141
  source: "opencode-codeops",
128
142
  version,
129
143
  installedAt: new Date().toISOString(),
130
144
  skills,
145
+ shared,
131
146
  })
132
147
  }
133
148
 
@@ -159,12 +174,97 @@ function installOneSkill({ sourceDir, targetDir, name, dryRun, link }) {
159
174
  return atomicReplace({ from, targetDir, name, recursive: true })
160
175
  }
161
176
 
177
+ /**
178
+ * Installs the package-root sibling directories the skills link to.
179
+ *
180
+ * Both the source and the destination are the parents of the skills
181
+ * directories, so `../../_shared/...` and `../../references/...` links resolve
182
+ * from every installed skill. A sibling the marker does not own is left
183
+ * untouched unless `force` is set. A sibling missing from the source is skipped
184
+ * with a warning, which is normal when a custom `--source` points at a bare
185
+ * skills directory.
186
+ *
187
+ * @param details - Shared-directory install inputs
188
+ * @param details.sourceDir - Skills source directory (siblings live beside it)
189
+ * @param details.targetDir - Skills install directory (siblings install beside it)
190
+ * @param details.ownedShared - Shared directory names the marker already owns
191
+ * @param details.force - Replace unowned same-named directories
192
+ * @param details.dryRun - Report only, write nothing
193
+ * @param details.link - Symlink to the source instead of copying
194
+ * @returns The installed shared directory names and the skipped count
195
+ */
196
+ function installSharedDirs({ sourceDir, targetDir, ownedShared, force, dryRun, link }) {
197
+ const sourceRoot = dirname(sourceDir)
198
+ const installRoot = dirname(targetDir)
199
+ const shared = []
200
+ let skipped = 0
201
+
202
+ for (const name of SHARED_DIRS) {
203
+ const from = join(sourceRoot, name)
204
+ const dest = join(installRoot, name)
205
+
206
+ if (!existsSync(from)) {
207
+ // The marker may already own this directory from an earlier install even
208
+ // though the current source no longer ships it. Keep the recorded
209
+ // ownership so `uninstall` can still remove it, and leave the copy alone.
210
+ if (ownedShared.has(name) && entryExists(dest)) {
211
+ console.log(`shared directory not found in source; keeping managed copy: ${dest}`)
212
+ shared.push(name)
213
+ } else {
214
+ console.log(`shared directory not found in source, skipped: ${from}`)
215
+ }
216
+ continue
217
+ }
218
+
219
+ if (entryExists(dest) && !ownedShared.has(name) && !force) {
220
+ console.log(`conflict, skipped (not managed by opencode-codeops; use --force): ${dest}`)
221
+ skipped += 1
222
+ continue
223
+ }
224
+
225
+ const existed = entryExists(dest)
226
+ if (!dryRun) {
227
+ if (link) linkEntry({ from, dest, type: "dir" })
228
+ else atomicReplace({ from, targetDir: installRoot, name, recursive: true })
229
+ }
230
+ shared.push(name)
231
+ console.log(`${dryRun ? "[dry-run] would " : ""}${existed ? "replace" : "install"}: ${dest}`)
232
+ }
233
+
234
+ return { shared, skipped }
235
+ }
236
+
237
+ /**
238
+ * Reports that shared directories are skipped when the target is a symlink.
239
+ *
240
+ * The skills are written through a symlinked target into the real directory,
241
+ * but the shared directories would land beside the link. Their `../../` links
242
+ * then resolve beside the real skills directory, so installing beside the link
243
+ * puts them in the wrong place; copying into the link target could overwrite
244
+ * the package checkout the link often points at. Skipping leaves the escape
245
+ * hatch safe and lets the user place the shared directories beside the real
246
+ * skills directory if the link target does not already contain them.
247
+ *
248
+ * @param targetDir - Symlinked skills install directory
249
+ * @returns Empty install result
250
+ */
251
+ function skipSharedDirs(targetDir) {
252
+ console.log(
253
+ `warning: ${targetDir} is a symlink; skipping shared directories. ` +
254
+ "_shared/ and references/ must exist beside the real skills directory " +
255
+ "for the skills' relative links to resolve."
256
+ )
257
+ return { shared: [], skipped: 0 }
258
+ }
259
+
162
260
  /**
163
261
  * Installs or upgrades every packaged skill into a target directory.
164
262
  *
165
263
  * Skills named by an existing marker, plus every packaged skill on a first run,
166
264
  * are replaced. A same-named directory that the marker does not own is skipped
167
265
  * unless `force` is set, so an unrelated skill is never overwritten by accident.
266
+ * The shared directories the skills link to are installed beside the target
267
+ * through {@link installSharedDirs}.
168
268
  *
169
269
  * @param details - Install inputs
170
270
  * @param details.sourceDir - Skills directory holding the packaged skills
@@ -173,7 +273,7 @@ function installOneSkill({ sourceDir, targetDir, name, dryRun, link }) {
173
273
  * @param details.force - Replace same-named directories the marker does not own
174
274
  * @param details.dryRun - Report only, write nothing
175
275
  * @param details.link - Symlink to the source instead of copying
176
- * @returns Counts plus the skill names recorded in the marker
276
+ * @returns Counts plus the skill and shared names recorded in the marker
177
277
  */
178
278
  export function installSkills({
179
279
  sourceDir,
@@ -186,13 +286,15 @@ export function installSkills({
186
286
  const names = listSkills(sourceDir)
187
287
  const marker = readSkillsMarker(targetDir)
188
288
  const managed = marker ? new Set(marker.skills ?? []) : null
189
- const counts = { skills: names.length, installed: 0, replaced: 0, skipped: 0 }
289
+ const ownedShared = new Set(marker?.shared ?? [])
290
+ const counts = { skills: names.length, installed: 0, replaced: 0, skipped: 0, shared: 0 }
190
291
  const owned = []
191
292
  const prefix = dryRun ? "[dry-run] would " : ""
192
293
 
193
294
  if (!dryRun) {
194
295
  ensureDir(targetDir)
195
296
  cleanStaleArtifacts(targetDir)
297
+ cleanStaleArtifacts(dirname(targetDir))
196
298
  }
197
299
 
198
300
  for (const name of names) {
@@ -211,9 +313,15 @@ export function installSkills({
211
313
  console.log(`${prefix}${existed ? "replace" : "install"}: ${dest}`)
212
314
  }
213
315
 
214
- if (!dryRun) writeMarker(targetDir, { version, skills: owned })
316
+ const installedShared = isSymlink(targetDir)
317
+ ? skipSharedDirs(targetDir)
318
+ : installSharedDirs({ sourceDir, targetDir, ownedShared, force, dryRun, link })
319
+ counts.shared = installedShared.shared.length
320
+ counts.skipped += installedShared.skipped
215
321
 
216
- return { ...counts, owned }
322
+ if (!dryRun) writeMarker(targetDir, { version, skills: owned, shared: installedShared.shared })
323
+
324
+ return { ...counts, owned, shared: installedShared.shared }
217
325
  }
218
326
 
219
327
  /**
@@ -222,16 +330,19 @@ export function installSkills({
222
330
  * The marker is the ownership record, so an unmanaged install is left intact.
223
331
  * Without a marker the function reports an error instead of guessing.
224
332
  *
333
+ * Removes both the owned skills and the shared directories the installer placed
334
+ * beside them, so an uninstall leaves no package-owned files behind.
335
+ *
225
336
  * @param details - Uninstall inputs
226
337
  * @param details.targetDir - Skills directory to clean
227
338
  * @param details.dryRun - Report only, write nothing
228
- * @returns Removed skill names plus the marker outcome, or a reason it refused
339
+ * @returns Removed skill and shared names plus the marker outcome, or a reason it refused
229
340
  */
230
341
  export function uninstallSkills({ targetDir, dryRun = false }) {
231
342
  const marker = readSkillsMarker(targetDir)
232
343
 
233
344
  if (!marker) {
234
- return { removed: [], markerRemoved: false, error: "no opencode-codeops marker found" }
345
+ return { removed: [], shared: [], markerRemoved: false, error: "no opencode-codeops marker found" }
235
346
  }
236
347
 
237
348
  const removed = []
@@ -245,9 +356,21 @@ export function uninstallSkills({ targetDir, dryRun = false }) {
245
356
  console.log(`${dryRun ? "would remove" : "removed"}: ${dest}`)
246
357
  }
247
358
 
359
+ const shared = []
360
+ const installRoot = dirname(targetDir)
361
+
362
+ for (const name of marker.shared ?? []) {
363
+ const dest = join(installRoot, name)
364
+ if (!entryExists(dest)) continue
365
+
366
+ if (!dryRun) rmSync(dest, { recursive: true, force: true })
367
+ shared.push(name)
368
+ console.log(`${dryRun ? "would remove" : "removed"}: ${dest}`)
369
+ }
370
+
248
371
  if (!dryRun) rmSync(join(targetDir, MARKER_FILE), { force: true })
249
372
 
250
- return { removed, markerRemoved: true }
373
+ return { removed, shared, markerRemoved: true }
251
374
  }
252
375
 
253
376
  /** Prints command usage. */
@@ -341,6 +464,11 @@ function printStatus({ targetDir, sourceDir, sourceVersion }) {
341
464
  if (missing.length > 0) {
342
465
  console.log(`warning: missing managed skills: ${missing.join(", ")}`)
343
466
  }
467
+ const installRoot = dirname(targetDir)
468
+ const missingShared = (marker.shared ?? []).filter((name) => !entryExists(join(installRoot, name)))
469
+ if (missingShared.length > 0) {
470
+ console.log(`warning: missing managed shared directories: ${missingShared.join(", ")}`)
471
+ }
344
472
  return
345
473
  }
346
474
 
@@ -415,8 +543,8 @@ export function main(argv, io = {}) {
415
543
  return 0
416
544
  }
417
545
  console.log(
418
- `${options.dryRun ? "would remove" : "removed"} ${result.removed.length} skill(s); ` +
419
- `marker ${options.dryRun ? "would be removed" : "removed"}`
546
+ `${options.dryRun ? "would remove" : "removed"} ${result.removed.length} skill(s) and ` +
547
+ `${result.shared.length} shared dir(s); marker ${options.dryRun ? "would be removed" : "removed"}`
420
548
  )
421
549
  return 0
422
550
  }
@@ -432,7 +560,8 @@ export function main(argv, io = {}) {
432
560
  const mode = options.dryRun ? " (dry-run, nothing written)" : ""
433
561
  console.log(
434
562
  `Done${mode}: ${counts.skills} skills | ` +
435
- `installed ${counts.installed}, replaced ${counts.replaced}, ${counts.skipped} skipped`
563
+ `installed ${counts.installed}, replaced ${counts.replaced}, ${counts.skipped} skipped | ` +
564
+ `shared ${counts.shared}/${SHARED_DIRS.length}`
436
565
  )
437
566
  if (counts.skipped > 0) {
438
567
  console.log("Re-run with --force to replace skipped directories.")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codeops",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Specification-first engineering for complex systems — CodeOps plugin for OpenCode",
5
5
  "type": "module",
6
6
  "engines": {