opencode-work-context 0.6.0 → 0.6.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
@@ -153,22 +153,20 @@ For one managed package installation shared by OpenCode while keeping activation
153
153
  explicit per project, run this in each project that should use work-context:
154
154
 
155
155
  ```sh
156
- npx opencode-work-context activate
156
+ npx --yes opencode-work-context@latest activate
157
157
  ```
158
158
 
159
- `activate` writes `.opencode/opencode.json` with the supported `plugin` entry
160
- `opencode-work-context` and installs the `/wc` command contract. OpenCode
161
- resolves, caches, and updates configured package plugins through its supported
162
- plugin manager; the project does not import an npm-global path, create a local
163
- `node_modules`, or create `.work-context` data merely by being activated. The
164
- package's server and optional TUI parts are loaded together by OpenCode, so this
165
- also works on server-only hosts.
159
+ `activate` writes the exact current package spec, such as
160
+ `opencode-work-context@0.6.1`, to the supported `plugin` arrays in
161
+ `.opencode/opencode.json` and `.opencode/tui.json`, and installs the `/wc`
162
+ command contract. OpenCode stores that package once in its shared managed cache;
163
+ the project does not import an npm-global path, create a local `node_modules`, or
164
+ create `.work-context` data merely by being activated.
166
165
 
167
166
  Managed activation has two scopes: it enables the plugin only in the current
168
167
  project, while OpenCode keeps the package in its shared managed cache for every
169
168
  activated project. It does not require `npm install -g` or a project-local npm
170
- dependency. Restart OpenCode after publishing a new unpinned package version so
171
- the managed plugin flow can refresh the shared copy.
169
+ dependency. The exact spec avoids stale unversioned cache entries.
172
170
 
173
171
  Activation is opt-in. Projects without this entry stay inactive. If a machine
174
172
  administrator or user has configured the package globally, a project can add
@@ -185,7 +183,7 @@ For an existing JSONC configuration, add the equivalent entry manually:
185
183
 
186
184
  ```jsonc
187
185
  {
188
- "plugin": ["opencode-work-context"] // or "-work-context" to opt out
186
+ "plugin": ["opencode-work-context@<version>"] // or "-work-context" to opt out
189
187
  }
190
188
  ```
191
189
 
@@ -193,11 +191,16 @@ Re-running `activate` also migrates work-context entries previously generated
193
191
  under the unsupported legacy `plugins` field. Unrelated legacy entries are
194
192
  preserved rather than activated or removed implicitly.
195
193
 
196
- Restart OpenCode after changing plugin configuration. OpenCode checks unpinned
197
- configured packages through its managed plugin flow; use the OpenCode plugin
198
- management command available in your installed OpenCode version when you need
199
- to refresh it immediately. Pinned plugin entries are intentionally not updated
200
- automatically.
194
+ Update managed activation from one activated project with an exact version:
195
+
196
+ ```sh
197
+ opencode plugin opencode-work-context@<version> --force
198
+ ```
199
+
200
+ This updates both project config targets and populates the versioned shared cache
201
+ entry. Re-run `npx --yes opencode-work-context@<version> activate --force` in
202
+ other activated projects when their pinned config must also change. Restart
203
+ OpenCode after changing plugin configuration.
201
204
 
202
205
  Do not activate the managed package in a project already configured through
203
206
  the local installer below. The command refuses that combination so server tools
@@ -103,6 +103,8 @@ function activate(enabled, force) {
103
103
  }
104
104
  const configRelative = path.join(".opencode", "opencode.json");
105
105
  const configFile = path.join(projectRoot, configRelative);
106
+ const managedTuiConfigRelative = path.join(".opencode", "tui.json");
107
+ const managedTuiConfigFile = path.join(projectRoot, managedTuiConfigRelative);
106
108
  const jsoncFile = path.join(projectRoot, ".opencode", "opencode.jsonc");
107
109
  if (exists(jsoncFile)) {
108
110
  fail("cannot update .opencode/opencode.jsonc; add the plugin entry manually or use .opencode/opencode.json");
@@ -123,7 +125,21 @@ function activate(enabled, force) {
123
125
  return;
124
126
  }
125
127
  }
126
- const entry = enabled ? packageManifest.name : "-work-context";
128
+ let managedTuiConfig = { $schema: "https://opencode.ai/tui.json" };
129
+ if (exists(managedTuiConfigFile)) {
130
+ if (hasSymlinkParent(managedTuiConfigFile) || !fs.lstatSync(managedTuiConfigFile).isFile() || fs.lstatSync(managedTuiConfigFile).isSymbolicLink()) {
131
+ fail(`refusing to overwrite non-regular file: ${managedTuiConfigRelative}`);
132
+ return;
133
+ }
134
+ try { managedTuiConfig = JSON.parse(fs.readFileSync(managedTuiConfigFile, "utf8")); }
135
+ catch { fail(`cannot update invalid JSON: ${managedTuiConfigRelative}`); return; }
136
+ if (!managedTuiConfig || typeof managedTuiConfig !== "object" || Array.isArray(managedTuiConfig)
137
+ || (managedTuiConfig.plugin !== undefined && !Array.isArray(managedTuiConfig.plugin))) {
138
+ fail(`cannot update unsupported configuration: ${managedTuiConfigRelative}`);
139
+ return;
140
+ }
141
+ }
142
+ const entry = enabled ? `${packageManifest.name}@${packageManifest.version}` : "-work-context";
127
143
  const isWorkContextEntry = (item) => typeof item === "string" && (
128
144
  item === packageManifest.name
129
145
  || item.startsWith(`${packageManifest.name}@`)
@@ -134,14 +150,16 @@ function activate(enabled, force) {
134
150
  config.plugins = config.plugins.filter((item) => !isWorkContextEntry(item));
135
151
  if (config.plugins.length === 0) delete config.plugins;
136
152
  }
153
+ managedTuiConfig.plugin = [...(managedTuiConfig.plugin || []).filter((item) => !isWorkContextEntry(item)), entry];
137
154
  const files = new Map([
138
155
  [configRelative, JSON.stringify(config, null, 2) + "\n"],
156
+ [managedTuiConfigRelative, JSON.stringify(managedTuiConfig, null, 2) + "\n"],
139
157
  [path.join(".opencode", "commands", "wc.md"), command],
140
158
  ]);
141
159
  const conflicts = [...files].flatMap(([relative, content]) => {
142
160
  const file = path.join(projectRoot, relative);
143
161
  if (hasSymlinkParent(file) || (exists(file) && (!fs.lstatSync(file).isFile() || fs.lstatSync(file).isSymbolicLink()))) return [relative];
144
- return relative !== configRelative && !force && exists(file) && fs.readFileSync(file, "utf8") !== content ? [relative] : [];
162
+ return ![configRelative, managedTuiConfigRelative].includes(relative) && !force && exists(file) && fs.readFileSync(file, "utf8") !== content ? [relative] : [];
145
163
  });
146
164
  if (conflicts.length) {
147
165
  fail(`refusing to overwrite existing files: ${conflicts.join(", ")}; rerun with --force`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {