codiedev 0.9.42 → 0.9.44
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/dist/codie.js +86 -15
- package/package.json +1 -1
package/dist/codie.js
CHANGED
|
@@ -169,6 +169,87 @@ function installBrandWordmarkUnsafe(runtime) {
|
|
|
169
169
|
(0, child_process_1.spawnSync)("codesign", ["--force", "--sign", "-", runtime], { stdio: "ignore" });
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
async function runNonInteractive(runtime, runtimeArgs, env) {
|
|
173
|
+
const child = (0, child_process_1.spawn)(runtime, runtimeArgs, {
|
|
174
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
175
|
+
env,
|
|
176
|
+
});
|
|
177
|
+
return await new Promise((resolve, reject) => {
|
|
178
|
+
let blockReason;
|
|
179
|
+
let stdoutTail = Buffer.alloc(0);
|
|
180
|
+
let possibleOpenCodeError;
|
|
181
|
+
const errorPrefixes = [Buffer.from("\x1b[91m\x1b[1mError:"), Buffer.from("Error: {")];
|
|
182
|
+
const retainedPrefixBytes = Math.max(...errorPrefixes.map((prefix) => prefix.length)) - 1;
|
|
183
|
+
// OpenCode reports a plugin rejection through two different pipes: the
|
|
184
|
+
// adapter's private reason on stderr, then its generic UnknownError on
|
|
185
|
+
// stdout. Pipe ordering is nondeterministic, so retain only a possible
|
|
186
|
+
// terminal error block until the marker arrives. Ordinary run output keeps
|
|
187
|
+
// streaming immediately (apart from the few bytes needed to match a prefix).
|
|
188
|
+
const writeStdout = (chunk) => {
|
|
189
|
+
if (blockReason) {
|
|
190
|
+
if (possibleOpenCodeError)
|
|
191
|
+
possibleOpenCodeError.push(Buffer.from(chunk));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (possibleOpenCodeError) {
|
|
195
|
+
possibleOpenCodeError.push(Buffer.from(chunk));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const combined = Buffer.concat([stdoutTail, chunk]);
|
|
199
|
+
let errorStart = -1;
|
|
200
|
+
for (const prefix of errorPrefixes) {
|
|
201
|
+
const index = combined.indexOf(prefix);
|
|
202
|
+
if (index >= 0 && (errorStart < 0 || index < errorStart))
|
|
203
|
+
errorStart = index;
|
|
204
|
+
}
|
|
205
|
+
if (errorStart >= 0) {
|
|
206
|
+
if (errorStart > 0)
|
|
207
|
+
process.stdout.write(combined.subarray(0, errorStart));
|
|
208
|
+
possibleOpenCodeError = [combined.subarray(errorStart)];
|
|
209
|
+
stdoutTail = Buffer.alloc(0);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const flushBytes = Math.max(0, combined.length - retainedPrefixBytes);
|
|
213
|
+
if (flushBytes > 0)
|
|
214
|
+
process.stdout.write(combined.subarray(0, flushBytes));
|
|
215
|
+
stdoutTail = combined.subarray(flushBytes);
|
|
216
|
+
};
|
|
217
|
+
child.stdout?.on("data", (chunk) => {
|
|
218
|
+
writeStdout(Buffer.from(chunk));
|
|
219
|
+
});
|
|
220
|
+
child.stderr?.on("data", (chunk) => {
|
|
221
|
+
const text = chunk.toString();
|
|
222
|
+
const reason = (0, codieLauncher_1.extractCodieSecurityBlock)(text);
|
|
223
|
+
if (reason) {
|
|
224
|
+
blockReason = reason;
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (!blockReason)
|
|
228
|
+
process.stderr.write(chunk);
|
|
229
|
+
});
|
|
230
|
+
child.once("error", reject);
|
|
231
|
+
child.once("close", (status) => {
|
|
232
|
+
if (blockReason) {
|
|
233
|
+
if (stdoutTail.length > 0)
|
|
234
|
+
process.stdout.write(stdoutTail);
|
|
235
|
+
const heldError = possibleOpenCodeError
|
|
236
|
+
? Buffer.concat(possibleOpenCodeError).toString()
|
|
237
|
+
: "";
|
|
238
|
+
if (heldError && !(heldError.includes("UnknownError") && heldError.includes("Unexpected server error"))) {
|
|
239
|
+
process.stdout.write(heldError);
|
|
240
|
+
}
|
|
241
|
+
console.error(`Codie Security blocked this action:\n${blockReason}`);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
if (stdoutTail.length > 0)
|
|
245
|
+
process.stdout.write(stdoutTail);
|
|
246
|
+
if (possibleOpenCodeError)
|
|
247
|
+
process.stdout.write(Buffer.concat(possibleOpenCodeError));
|
|
248
|
+
}
|
|
249
|
+
resolve(status);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
}
|
|
172
253
|
async function main() {
|
|
173
254
|
(0, codieRuntime_1.assertCodieNodeVersion)(process.versions.node);
|
|
174
255
|
const connected = connectedCodiedevConfig();
|
|
@@ -235,23 +316,13 @@ async function main() {
|
|
|
235
316
|
const nonInteractiveRun = runtimeArgs[0] === "run";
|
|
236
317
|
if (nonInteractiveRun)
|
|
237
318
|
env.CODIEDEV_SECURITY_BLOCK_OUTPUT = "marker";
|
|
238
|
-
const result = (0, child_process_1.spawnSync)(runtime, runtimeArgs, {
|
|
239
|
-
stdio: nonInteractiveRun ? ["inherit", "inherit", "pipe"] : "inherit",
|
|
240
|
-
encoding: nonInteractiveRun ? "utf8" : undefined,
|
|
241
|
-
env,
|
|
242
|
-
});
|
|
243
|
-
if (result.error)
|
|
244
|
-
throw result.error;
|
|
245
319
|
if (nonInteractiveRun) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (blockReason) {
|
|
249
|
-
console.error(`Codie Security blocked this action:\n${blockReason}`);
|
|
250
|
-
}
|
|
251
|
-
else if (stderr) {
|
|
252
|
-
process.stderr.write(stderr);
|
|
253
|
-
}
|
|
320
|
+
process.exitCode = (await runNonInteractive(runtime, runtimeArgs, env)) ?? 1;
|
|
321
|
+
return;
|
|
254
322
|
}
|
|
323
|
+
const result = (0, child_process_1.spawnSync)(runtime, runtimeArgs, { stdio: "inherit", env });
|
|
324
|
+
if (result.error)
|
|
325
|
+
throw result.error;
|
|
255
326
|
process.exitCode = result.status === null ? 1 : result.status;
|
|
256
327
|
}
|
|
257
328
|
main().catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codiedev",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.44",
|
|
4
4
|
"description": "Connect Claude Code, Codex, Cursor, OpenCode, or VS Code Copilot to Codiedev for team session capture and artifact collaboration — and run the governed Codie harness",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codiedev": "dist/cli.js",
|