open-plan-annotator 0.2.15 → 0.2.16

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.
@@ -12,7 +12,7 @@
12
12
  "name": "open-plan-annotator",
13
13
  "source": "./",
14
14
  "description": "Interactive plan annotation UI: review, strikethrough, and comment on Claude's plans before approving. Fully local, no external services.",
15
- "version": "0.2.15",
15
+ "version": "0.2.16",
16
16
  "author": {
17
17
  "name": "ndom91"
18
18
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "open-plan-annotator",
3
3
  "description": "Interactive plan annotation UI: review, strikethrough, and comment on Claude's plans before approving. Fully local, no external services.",
4
- "version": "0.2.15",
4
+ "version": "0.2.16",
5
5
  "author": {
6
6
  "name": "ndom91"
7
7
  },
@@ -5,9 +5,12 @@ import { dirname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
7
  const PKG_ROOT = fileURLToPath(new URL("..", import.meta.url));
8
- const BINARY_PATH = join(PKG_ROOT, "bin", "open-plan-annotator-binary");
8
+ const LOCAL_BINARY_PATH = join(PKG_ROOT, "bin", "open-plan-annotator-binary");
9
9
  const INSTALL_SCRIPT = join(PKG_ROOT, "install.cjs");
10
10
 
11
+ /** Resolved path to the binary (may differ from LOCAL_BINARY_PATH if found on PATH). */
12
+ let BINARY_PATH = LOCAL_BINARY_PATH;
13
+
11
14
  /**
12
15
  * @typedef {{
13
16
  * hookSpecificOutput: {
@@ -99,9 +102,33 @@ function validateHookOutput(value) {
99
102
  throw new Error("unsupported decision payload");
100
103
  }
101
104
 
105
+ /**
106
+ * Check if `open-plan-annotator` is available on PATH.
107
+ * The CLI wrapper handles binary discovery/download and stdin/stdout
108
+ * forwarding, so we can spawn it directly as a fallback when the local
109
+ * binary isn't available (e.g. OpenCode loads the plugin from its own
110
+ * node_modules but the binary only exists in a global pnpm install).
111
+ * @returns {string | undefined}
112
+ */
113
+ function findWrapperOnPath() {
114
+ const cmd = process.platform === "win32" ? "where" : "which";
115
+ try {
116
+ const result = execFileSync(cmd, ["open-plan-annotator"], {
117
+ encoding: "utf-8",
118
+ stdio: ["ignore", "pipe", "ignore"],
119
+ }).trim().split("\n")[0];
120
+ return result || undefined;
121
+ } catch {
122
+ return undefined;
123
+ }
124
+ }
125
+
102
126
  /** Ensure the compiled binary exists, downloading if necessary. */
103
127
  function ensureBinary() {
104
- if (existsSync(BINARY_PATH)) return;
128
+ if (existsSync(LOCAL_BINARY_PATH)) {
129
+ BINARY_PATH = LOCAL_BINARY_PATH;
130
+ return;
131
+ }
105
132
 
106
133
  // Try to find node on PATH for running the install script
107
134
  try {
@@ -121,12 +148,23 @@ function ensureBinary() {
121
148
  }
122
149
  }
123
150
 
124
- if (!existsSync(BINARY_PATH)) {
125
- throw new Error(
126
- `open-plan-annotator: binary not found at ${BINARY_PATH}. ` +
127
- `Try running: node ${INSTALL_SCRIPT}`,
128
- );
151
+ if (existsSync(LOCAL_BINARY_PATH)) {
152
+ BINARY_PATH = LOCAL_BINARY_PATH;
153
+ return;
129
154
  }
155
+
156
+ // Fallback: use the CLI wrapper from PATH (e.g. global pnpm install).
157
+ // The wrapper handles binary discovery/download and stdio forwarding.
158
+ const wrapperPath = findWrapperOnPath();
159
+ if (wrapperPath) {
160
+ BINARY_PATH = wrapperPath;
161
+ return;
162
+ }
163
+
164
+ throw new Error(
165
+ `open-plan-annotator: binary not found at ${LOCAL_BINARY_PATH}. ` +
166
+ `Try running: node ${INSTALL_SCRIPT}`,
167
+ );
130
168
  }
131
169
 
132
170
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-plan-annotator",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "type": "module",
5
5
  "description": "Fully local plugin for interactive plan annotation from your Agentic assistants",
6
6
  "author": "ndom91",