opencode-workflow-guard 1.7.0 → 1.7.2

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
@@ -31,7 +31,7 @@ For server-only setup, add the package to your project's `opencode.json` or glob
31
31
 
32
32
  *Requires OpenCode >= 1.18.* Restart OpenCode after setup. See [docs/installation.md](docs/installation.md) for full setup options.
33
33
 
34
- For the optional TUI badge, configure `"opencode-workflow-guard/tui"` in `tui.json`. The package root is the server plugin; TUI plugin specs are resolved as written and must use the exported `./tui` entrypoint. Do not place the TUI module under the server `plugins/` directory.
34
+ For the optional TUI badge, configure `"opencode-workflow-guard"` in `tui.json`. OpenCode resolves the package's exported `./tui` entrypoint automatically for TUI plugins. Do not place the TUI module under the server `plugins/` directory.
35
35
 
36
36
  ### 2. Verification
37
37
 
@@ -6,7 +6,8 @@ import { join } from "node:path";
6
6
  import { parse, modify, applyEdits } from "jsonc-parser";
7
7
 
8
8
  const SERVER_SPEC = "opencode-workflow-guard";
9
- const TUI_SPEC = "opencode-workflow-guard/tui";
9
+ const TUI_SPEC = "opencode-workflow-guard";
10
+ const LEGACY_TUI_SPEC = "opencode-workflow-guard/tui";
10
11
 
11
12
  function configHome() {
12
13
  return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
@@ -18,7 +19,7 @@ function existingConfig(base, name) {
18
19
  return existsSync(json) ? json : existsSync(jsonc) ? jsonc : json;
19
20
  }
20
21
 
21
- function preparePluginUpdate(path, schema, spec) {
22
+ function preparePluginUpdate(path, schema, spec, legacySpec) {
22
23
  const source = existsSync(path) ? readFileSync(path, "utf8") : `{
23
24
  "$schema": "${schema}"
24
25
  }\n`;
@@ -31,8 +32,17 @@ function preparePluginUpdate(path, schema, spec) {
31
32
  throw new Error(`Cannot update ${path}: "plugin" must be an array`);
32
33
  }
33
34
  const plugins = config.plugin ?? [];
34
- if (plugins.some((entry) => entry === spec || (Array.isArray(entry) && entry[0] === spec))) return undefined;
35
- return applyEdits(source, modify(source, ["plugin", plugins.length], spec, {
35
+ const matches = (entry, target) => entry === target || (Array.isArray(entry) && entry[0] === target);
36
+ if (!legacySpec) {
37
+ if (plugins.some((entry) => matches(entry, spec))) return undefined;
38
+ return applyEdits(source, modify(source, ["plugin", plugins.length], spec, {
39
+ formattingOptions: { insertSpaces: true, tabSize: 2 },
40
+ }));
41
+ }
42
+ const updatedPlugins = plugins.filter((entry) => !matches(entry, legacySpec));
43
+ if (!updatedPlugins.some((entry) => matches(entry, spec))) updatedPlugins.push(spec);
44
+ if (updatedPlugins.length === plugins.length && updatedPlugins.every((entry, index) => entry === plugins[index])) return undefined;
45
+ return applyEdits(source, modify(source, ["plugin"], updatedPlugins, {
36
46
  formattingOptions: { insertSpaces: true, tabSize: 2 },
37
47
  }));
38
48
  }
@@ -46,7 +56,7 @@ if (process.argv[2] !== "setup" || process.argv.length > 3) {
46
56
  const serverPath = existingConfig(base, "opencode");
47
57
  const tuiPath = existingConfig(base, "tui");
48
58
  const serverUpdate = preparePluginUpdate(serverPath, "https://opencode.ai/config.json", SERVER_SPEC);
49
- const tuiUpdate = preparePluginUpdate(tuiPath, "https://opencode.ai/tui.json", TUI_SPEC);
59
+ const tuiUpdate = preparePluginUpdate(tuiPath, "https://opencode.ai/tui.json", TUI_SPEC, LEGACY_TUI_SPEC);
50
60
  mkdirSync(base, { recursive: true });
51
61
  if (serverUpdate !== undefined) writeFileSync(serverPath, serverUpdate);
52
62
  if (tuiUpdate !== undefined) writeFileSync(tuiPath, tuiUpdate);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-workflow-guard",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "OpenCode plugin enforcing workflow discipline through deterministic tool.execute.before hooks",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -44,13 +44,13 @@
44
44
  "prepublishOnly": "npm run typecheck"
45
45
  },
46
46
  "dependencies": {
47
- "@opencode-ai/plugin": "^1.18.21",
48
- "@opentui/solid": "^0.5.6",
49
- "jsonc-parser": "^3.3.1"
47
+ "@opencode-ai/plugin": "latest",
48
+ "@opentui/solid": "latest",
49
+ "jsonc-parser": "latest"
50
50
  },
51
51
  "devDependencies": {
52
- "@changesets/cli": "^3.0.1",
53
- "@types/node": "^26.2.0",
54
- "typescript": "^7.0.2"
52
+ "@changesets/cli": "latest",
53
+ "@types/node": "latest",
54
+ "typescript": "latest"
55
55
  }
56
56
  }
@@ -29,7 +29,7 @@ function text(props: Record<string, unknown>, children: Child[]) {
29
29
  return element("text", props, children);
30
30
  }
31
31
 
32
- const BADGE_ACTIVE = "[Workflow Guard: Active]";
32
+ const BADGE_ACTIVE = "Workflow Guard 🛡️";
33
33
  let lastBlockedReason: string | undefined;
34
34
  const sessionBlockedReasons = new Map<string, string>();
35
35
  const badgeNodes = new Map<string, unknown>();