open-plan-annotator 0.2.10 → 0.2.12
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
|
+
"version": "0.2.12",
|
|
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.
|
|
4
|
+
"version": "0.2.12",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "ndom91"
|
|
7
7
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { execFileSync } = require("child_process");
|
|
3
|
+
const { execFileSync, spawn } = require("child_process");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
|
|
@@ -39,11 +39,54 @@ if (!fs.existsSync(binaryPath)) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
// Spawn the binary with detached so it can outlive this wrapper.
|
|
43
|
+
// We pipe stdout to detect the JSON hook output, then forward it and exit
|
|
44
|
+
// immediately — the binary keeps its server alive in the background.
|
|
45
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
46
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
47
|
+
detached: true,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
child.stdin.write(stdinBuffer);
|
|
51
|
+
child.stdin.end();
|
|
52
|
+
|
|
53
|
+
let stdout = "";
|
|
54
|
+
let forwarded = false;
|
|
55
|
+
|
|
56
|
+
child.stdout.on("data", (chunk) => {
|
|
57
|
+
stdout += chunk;
|
|
58
|
+
|
|
59
|
+
if (forwarded) return;
|
|
60
|
+
|
|
61
|
+
// Look for a complete JSON line (the hook output)
|
|
62
|
+
const lines = stdout.split("\n");
|
|
63
|
+
for (const line of lines) {
|
|
64
|
+
const trimmed = line.trim();
|
|
65
|
+
if (!trimmed) continue;
|
|
66
|
+
try {
|
|
67
|
+
JSON.parse(trimmed);
|
|
68
|
+
// Valid JSON — forward it and exit, letting the binary run in the background
|
|
69
|
+
forwarded = true;
|
|
70
|
+
process.stdout.write(trimmed + "\n", () => {
|
|
71
|
+
child.unref();
|
|
72
|
+
process.exit(0);
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
} catch {
|
|
76
|
+
// Not JSON yet, keep buffering
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
child.on("close", (code) => {
|
|
82
|
+
if (!forwarded) {
|
|
83
|
+
// Binary exited without producing valid JSON — forward whatever we have
|
|
84
|
+
if (stdout.trim()) process.stdout.write(stdout);
|
|
85
|
+
process.exit(code || 1);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
child.on("error", (err) => {
|
|
90
|
+
console.error("open-plan-annotator: failed to spawn binary:", err.message);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
package/opencode/bridge.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { existsSync, statSync } from "node:fs";
|
|
4
|
+
import { dirname } from "node:path";
|
|
3
5
|
import { fileURLToPath } from "node:url";
|
|
4
6
|
|
|
5
7
|
const WRAPPER_PATH = fileURLToPath(new URL("../bin/open-plan-annotator.cjs", import.meta.url));
|
|
@@ -102,7 +104,18 @@ export async function runPlanReview(options) {
|
|
|
102
104
|
const payload = buildHookPayload(options);
|
|
103
105
|
|
|
104
106
|
const result = await new Promise((resolve, reject) => {
|
|
105
|
-
|
|
107
|
+
let cwd = options.cwd ?? process.cwd();
|
|
108
|
+
|
|
109
|
+
// Guard: ensure cwd is a directory, not a file
|
|
110
|
+
try {
|
|
111
|
+
if (existsSync(cwd) && !statSync(cwd).isDirectory()) {
|
|
112
|
+
cwd = dirname(cwd);
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
// Fall back to wrapper's directory if all else fails
|
|
116
|
+
cwd = dirname(WRAPPER_PATH);
|
|
117
|
+
}
|
|
118
|
+
|
|
106
119
|
const child = spawn(process.execPath, [WRAPPER_PATH], {
|
|
107
120
|
cwd,
|
|
108
121
|
stdio: ["pipe", "pipe", "pipe"],
|