opencode-work-context 0.5.0 → 0.5.1

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/README.md CHANGED
@@ -156,8 +156,8 @@ explicit per project, run this in each project that should use work-context:
156
156
  npx opencode-work-context activate
157
157
  ```
158
158
 
159
- `activate` writes `.opencode/opencode.json` with the supported package plugin
160
- entry `opencode-work-context` and installs the `/wc` command contract. OpenCode
159
+ `activate` writes `.opencode/opencode.json` with the supported `plugin` entry
160
+ `opencode-work-context` and installs the `/wc` command contract. OpenCode
161
161
  resolves, caches, and updates configured package plugins through its supported
162
162
  plugin manager; the project does not import an npm-global path, create a local
163
163
  `node_modules`, or create `.work-context` data merely by being activated. The
@@ -185,10 +185,14 @@ For an existing JSONC configuration, add the equivalent entry manually:
185
185
 
186
186
  ```jsonc
187
187
  {
188
- "plugins": ["opencode-work-context"] // or "-work-context" to opt out
188
+ "plugin": ["opencode-work-context"] // or "-work-context" to opt out
189
189
  }
190
190
  ```
191
191
 
192
+ Re-running `activate` also migrates work-context entries previously generated
193
+ under the unsupported legacy `plugins` field. Unrelated legacy entries are
194
+ preserved rather than activated or removed implicitly.
195
+
192
196
  Restart OpenCode after changing plugin configuration. OpenCode checks unpinned
193
197
  configured packages through its managed plugin flow; use the OpenCode plugin
194
198
  management command available in your installed OpenCode version when you need
@@ -116,13 +116,24 @@ function activate(enabled, force) {
116
116
  }
117
117
  try { config = JSON.parse(fs.readFileSync(configFile, "utf8")); }
118
118
  catch { fail(`cannot update invalid JSON: ${configRelative}`); return; }
119
- if (!config || typeof config !== "object" || Array.isArray(config) || (config.plugins !== undefined && !Array.isArray(config.plugins))) {
119
+ if (!config || typeof config !== "object" || Array.isArray(config)
120
+ || (config.plugin !== undefined && !Array.isArray(config.plugin))
121
+ || (config.plugins !== undefined && !Array.isArray(config.plugins))) {
120
122
  fail(`cannot update unsupported configuration: ${configRelative}`);
121
123
  return;
122
124
  }
123
125
  }
124
126
  const entry = enabled ? packageManifest.name : "-work-context";
125
- config.plugins = [...(config.plugins || []).filter((item) => item !== entry), entry];
127
+ const isWorkContextEntry = (item) => typeof item === "string" && (
128
+ item === packageManifest.name
129
+ || item.startsWith(`${packageManifest.name}@`)
130
+ || item === "-work-context"
131
+ );
132
+ config.plugin = [...(config.plugin || []).filter((item) => !isWorkContextEntry(item)), entry];
133
+ if (config.plugins) {
134
+ config.plugins = config.plugins.filter((item) => !isWorkContextEntry(item));
135
+ if (config.plugins.length === 0) delete config.plugins;
136
+ }
126
137
  const files = new Map([
127
138
  [configRelative, JSON.stringify(config, null, 2) + "\n"],
128
139
  [path.join(".opencode", "commands", "wc.md"), command],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.5.1",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {