@jwitmann/vcc-brain-opencode-v2 2.9.1 → 2.9.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/dist/index.js +92 -59
- package/dist/index.js.map +9 -8
- package/dist/server.js +92 -59
- package/dist/server.js.map +9 -8
- package/dist/tui.js +2 -2
- package/dist/tui.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -7409,7 +7409,7 @@ import { Plugin } from "@opencode/plugin";
|
|
|
7409
7409
|
// package.json
|
|
7410
7410
|
var package_default = {
|
|
7411
7411
|
name: "@jwitmann/vcc-brain-opencode-v2",
|
|
7412
|
-
version: "2.9.
|
|
7412
|
+
version: "2.9.2",
|
|
7413
7413
|
description: "VCC Brain adapter for OpenCode V2.",
|
|
7414
7414
|
license: "BSD-3-Clause",
|
|
7415
7415
|
author: "jwitmann",
|
|
@@ -216793,6 +216793,14 @@ function evaluateBrainUpdateActivity(state, fingerprint, completedCalls, thresho
|
|
|
216793
216793
|
};
|
|
216794
216794
|
return { state: next, completedSinceBaseline: sinceBaseline, crossed };
|
|
216795
216795
|
}
|
|
216796
|
+
function brainUpdateReminderText(toolCallThreshold) {
|
|
216797
|
+
return `<vcc-brain-brain-update-reminder>
|
|
216798
|
+
You have completed ${toolCallThreshold} tool calls without a Brain change.
|
|
216799
|
+
Before continuing, record any durable decisions, contracts, or lessons in the
|
|
216800
|
+
appropriate Brain partition. Do not write transient task progress or restate
|
|
216801
|
+
implementation. If nothing durable has emerged, make no Brain edits.
|
|
216802
|
+
</vcc-brain-brain-update-reminder>`;
|
|
216803
|
+
}
|
|
216796
216804
|
function isHelperTool(part) {
|
|
216797
216805
|
return part.namespace === "vcc-brain" || part.namespace === "operator";
|
|
216798
216806
|
}
|
|
@@ -217496,15 +217504,7 @@ async function maybeAppendBrainUpdateReminder(deps, runtime, sessionID, messages
|
|
|
217496
217504
|
await appendReceipt(join9(deps.stateDirectory, "context-log"), sessionID, receipt);
|
|
217497
217505
|
return `${content}
|
|
217498
217506
|
|
|
217499
|
-
${
|
|
217500
|
-
}
|
|
217501
|
-
function brainUpdateReminder(toolCallThreshold) {
|
|
217502
|
-
return `<vcc-brain-brain-update-reminder>
|
|
217503
|
-
You have completed ${toolCallThreshold} tool calls without a Brain change.
|
|
217504
|
-
Before continuing, record any durable decisions, contracts, or lessons in the
|
|
217505
|
-
appropriate Brain partition. Do not write transient task progress or restate
|
|
217506
|
-
implementation. If nothing durable has emerged, make no Brain edits.
|
|
217507
|
-
</vcc-brain-brain-update-reminder>`;
|
|
217507
|
+
${brainUpdateReminderText(deps.config.toolCallThreshold)}`;
|
|
217508
217508
|
}
|
|
217509
217509
|
|
|
217510
217510
|
// src/utils.ts
|
|
@@ -219099,6 +219099,23 @@ ${JSON.stringify(event.data ?? null)}`;
|
|
|
219099
219099
|
text
|
|
219100
219100
|
};
|
|
219101
219101
|
}
|
|
219102
|
+
function dropPhantomSeqZeroHits(out) {
|
|
219103
|
+
const hits = out.hits.filter((hit) => hit.seq !== 0);
|
|
219104
|
+
const dropped = out.hits.length - hits.length;
|
|
219105
|
+
const totalMatches = out.totalMatches - dropped;
|
|
219106
|
+
const omitted = Math.max(0, totalMatches - hits.length);
|
|
219107
|
+
const lines = [
|
|
219108
|
+
`[search "${out.pattern}": ${totalMatches} matching event(s)]`,
|
|
219109
|
+
...hits.map((hit) => hit.text),
|
|
219110
|
+
...omitted > 0 ? [`[${omitted} more matching event(s) omitted — narrow the pattern or use recall]`] : [],
|
|
219111
|
+
...out.truncated ? ["[search budget exhausted; some hits were cut]"] : []
|
|
219112
|
+
];
|
|
219113
|
+
if (hits.length > 0)
|
|
219114
|
+
lines.push("[use recall with a (seq N) pointer to restore any hit's full original content]");
|
|
219115
|
+
return { ...out, totalMatches, hits, omitted, text: lines.join(`
|
|
219116
|
+
|
|
219117
|
+
`) };
|
|
219118
|
+
}
|
|
219102
219119
|
|
|
219103
219120
|
// src/compaction-snapshot.ts
|
|
219104
219121
|
var SNAPSHOT_VERSION = 1;
|
|
@@ -219413,27 +219430,7 @@ function searchSnapshot(messages, patternSource, config = {}) {
|
|
|
219413
219430
|
}
|
|
219414
219431
|
};
|
|
219415
219432
|
const out = searchSession(paddedSession, patternSource, { maxSearchHits, maxRecallTokens });
|
|
219416
|
-
|
|
219417
|
-
const dropped = out.hits.length - hits.length;
|
|
219418
|
-
const totalMatches = out.totalMatches - dropped;
|
|
219419
|
-
const omitted = Math.max(0, totalMatches - hits.length);
|
|
219420
|
-
const lines = [
|
|
219421
|
-
`[search "${out.pattern}": ${totalMatches} matching event(s)]`,
|
|
219422
|
-
...hits.map((hit) => hit.text),
|
|
219423
|
-
...omitted > 0 ? [`[${omitted} more matching event(s) omitted — narrow the pattern or use recall]`] : [],
|
|
219424
|
-
...out.truncated ? ["[search budget exhausted; some hits were cut]"] : []
|
|
219425
|
-
];
|
|
219426
|
-
if (hits.length > 0)
|
|
219427
|
-
lines.push("[use recall with a (seq N) pointer to restore any hit's full original content]");
|
|
219428
|
-
return {
|
|
219429
|
-
...out,
|
|
219430
|
-
totalMatches,
|
|
219431
|
-
hits,
|
|
219432
|
-
omitted,
|
|
219433
|
-
text: lines.join(`
|
|
219434
|
-
|
|
219435
|
-
`)
|
|
219436
|
-
};
|
|
219433
|
+
return dropPhantomSeqZeroHits(out);
|
|
219437
219434
|
}
|
|
219438
219435
|
function formatRecallReply(type, id, recalled) {
|
|
219439
219436
|
const label = `**vcc-brain-recall ${type} ${id}** (${recalled.seqs.length} event(s), ${recalled.tokens} tokens` + `${recalled.missing > 0 ? `, ${recalled.missing} missing` : ""}` + `${recalled.truncated ? ", budget-truncated" : ""})`;
|
|
@@ -221272,8 +221269,62 @@ async function refreshPreambleContent(deps, runtime, sessionID, projectDirectory
|
|
|
221272
221269
|
}
|
|
221273
221270
|
|
|
221274
221271
|
// src/tool.ts
|
|
221275
|
-
import { execFile } from "node:child_process";
|
|
221276
221272
|
import { join as join14 } from "node:path";
|
|
221273
|
+
|
|
221274
|
+
// ../core/src/helper-binary.ts
|
|
221275
|
+
import { execFile } from "node:child_process";
|
|
221276
|
+
var HELPER_BIN = "vcc-brain-helper";
|
|
221277
|
+
var HELPER_TIMEOUT_MS = 60000;
|
|
221278
|
+
var HELPER_MAX_BUFFER_BYTES = 4 * 1024 * 1024;
|
|
221279
|
+
function asAbortSignal(value) {
|
|
221280
|
+
if (typeof value !== "object" || value === null) {
|
|
221281
|
+
return;
|
|
221282
|
+
}
|
|
221283
|
+
const candidate = value;
|
|
221284
|
+
return typeof candidate.aborted === "boolean" && typeof candidate.addEventListener === "function" ? value : undefined;
|
|
221285
|
+
}
|
|
221286
|
+
function isBufferOverflow(error) {
|
|
221287
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
221288
|
+
return false;
|
|
221289
|
+
}
|
|
221290
|
+
const code = error.code;
|
|
221291
|
+
return code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER" || code === "ENOBUFS";
|
|
221292
|
+
}
|
|
221293
|
+
function runHelperBinary(argument_, options) {
|
|
221294
|
+
const bin = process.env.VCC_BRAIN_HELPER_BIN ?? HELPER_BIN;
|
|
221295
|
+
const signal = asAbortSignal(options?.signal);
|
|
221296
|
+
if (signal?.aborted === true) {
|
|
221297
|
+
return Promise.resolve({ exitCode: -1, output: "Helper call cancelled.", cancelled: true });
|
|
221298
|
+
}
|
|
221299
|
+
return new Promise((resolve) => {
|
|
221300
|
+
execFile(bin, [...argument_], { timeout: HELPER_TIMEOUT_MS, maxBuffer: HELPER_MAX_BUFFER_BYTES, signal }, (error, stdout, stderr) => {
|
|
221301
|
+
if (error !== null && (signal?.aborted === true || error.name === "AbortError")) {
|
|
221302
|
+
resolve({ exitCode: -1, output: "Helper call cancelled.", cancelled: true });
|
|
221303
|
+
return;
|
|
221304
|
+
}
|
|
221305
|
+
if (error === null) {
|
|
221306
|
+
resolve({ exitCode: 0, output: stdout, cancelled: false });
|
|
221307
|
+
return;
|
|
221308
|
+
}
|
|
221309
|
+
if (isBufferOverflow(error)) {
|
|
221310
|
+
resolve({
|
|
221311
|
+
exitCode: typeof error.code === "number" ? error.code : 2,
|
|
221312
|
+
output: `Helper output exceeded ${HELPER_MAX_BUFFER_BYTES} bytes and was discarded. ` + "Narrow the request (query keywords, recall --seq/--from-seq) and retry.",
|
|
221313
|
+
cancelled: false
|
|
221314
|
+
});
|
|
221315
|
+
return;
|
|
221316
|
+
}
|
|
221317
|
+
const exitCode = typeof error.code === "number" ? error.code : 2;
|
|
221318
|
+
if (exitCode !== 0 && stderr !== "") {
|
|
221319
|
+
resolve({ exitCode, output: stderr, cancelled: false });
|
|
221320
|
+
return;
|
|
221321
|
+
}
|
|
221322
|
+
resolve({ exitCode, output: stdout !== "" ? stdout : error.message, cancelled: false });
|
|
221323
|
+
});
|
|
221324
|
+
});
|
|
221325
|
+
}
|
|
221326
|
+
|
|
221327
|
+
// src/tool.ts
|
|
221277
221328
|
var OMISSION_ID_PATTERN = /^omitted-\d+$/;
|
|
221278
221329
|
var CONTEXT_MANAGEMENT_TOOL_NAMES = [
|
|
221279
221330
|
"vcc-brain-read_omitted",
|
|
@@ -221480,30 +221531,12 @@ async function registerSearchTool(context, deps) {
|
|
|
221480
221531
|
});
|
|
221481
221532
|
});
|
|
221482
221533
|
}
|
|
221483
|
-
var HELPER_BIN = "vcc-brain-helper";
|
|
221484
|
-
var HELPER_TIMEOUT_MS = 60000;
|
|
221485
|
-
function runHelperBinary(argument_) {
|
|
221486
|
-
return new Promise((resolve) => {
|
|
221487
|
-
execFile(HELPER_BIN, [...argument_], { timeout: HELPER_TIMEOUT_MS }, (error, stdout, stderr) => {
|
|
221488
|
-
if (error === null) {
|
|
221489
|
-
resolve({ exitCode: 0, output: stdout });
|
|
221490
|
-
return;
|
|
221491
|
-
}
|
|
221492
|
-
const exitCode = typeof error.code === "number" ? error.code : 2;
|
|
221493
|
-
if (exitCode !== 0 && stderr !== "") {
|
|
221494
|
-
resolve({ exitCode, output: stderr });
|
|
221495
|
-
return;
|
|
221496
|
-
}
|
|
221497
|
-
resolve({ exitCode, output: stdout !== "" ? stdout : error.message });
|
|
221498
|
-
});
|
|
221499
|
-
});
|
|
221500
|
-
}
|
|
221501
221534
|
async function registerSearchSessionsTool(context, deps) {
|
|
221502
221535
|
await context.tool.transform((editor) => {
|
|
221503
221536
|
editor.add({
|
|
221504
221537
|
name: "vcc-brain-search-sessions",
|
|
221505
221538
|
options: { codemode: false },
|
|
221506
|
-
description: "Search OTHER sessions (cross-session recall) for keywords, scoped to this project plus mutual peers. " + "Returns matching turns with stored session ids (like opencode:ses_
|
|
221539
|
+
description: "Search OTHER sessions (cross-session recall) for keywords, scoped to this project plus mutual peers. " + "Returns matching turns with stored session ids (like opencode:ses_..., dsh:<uuid>, or pi:<id>); " + "call vcc-brain-recall-session to restore a session's full turns. " + "Use vcc-brain-search (not this tool) for the current conversation. " + "OpenCode results require one `vcc-brain-helper recall-cross index` run on this machine first.",
|
|
221507
221540
|
input: {
|
|
221508
221541
|
type: "object",
|
|
221509
221542
|
properties: {
|
|
@@ -221514,7 +221547,7 @@ async function registerSearchSessionsTool(context, deps) {
|
|
|
221514
221547
|
harness: {
|
|
221515
221548
|
type: "string",
|
|
221516
221549
|
description: "Limit results to one harness.",
|
|
221517
|
-
enum: ["dsh", "opencode", "all"]
|
|
221550
|
+
enum: ["dsh", "opencode", "pi", "all"]
|
|
221518
221551
|
}
|
|
221519
221552
|
},
|
|
221520
221553
|
required: ["keywords"]
|
|
@@ -221536,14 +221569,14 @@ async function registerSearchSessionsTool(context, deps) {
|
|
|
221536
221569
|
deps.projectDirectory
|
|
221537
221570
|
];
|
|
221538
221571
|
if (input.harness !== undefined && input.harness !== "") {
|
|
221539
|
-
if (input.harness !== "dsh" && input.harness !== "opencode" && input.harness !== "all") {
|
|
221540
|
-
return { content: "Invalid input: harness must be one of dsh, opencode, all." };
|
|
221572
|
+
if (input.harness !== "dsh" && input.harness !== "opencode" && input.harness !== "pi" && input.harness !== "all") {
|
|
221573
|
+
return { content: "Invalid input: harness must be one of dsh, opencode, pi, all." };
|
|
221541
221574
|
}
|
|
221542
221575
|
invocation.push("--harness", input.harness);
|
|
221543
221576
|
}
|
|
221544
221577
|
invocation.push(...words);
|
|
221545
221578
|
try {
|
|
221546
|
-
const result = await runHelperBinary(invocation);
|
|
221579
|
+
const result = await runHelperBinary(invocation, null);
|
|
221547
221580
|
return { content: result.output };
|
|
221548
221581
|
} catch {
|
|
221549
221582
|
return { content: "Could not run the recall index. Is vcc-brain-helper installed?" };
|
|
@@ -221557,13 +221590,13 @@ async function registerRecallSessionTool(context) {
|
|
|
221557
221590
|
editor.add({
|
|
221558
221591
|
name: "vcc-brain-recall-session",
|
|
221559
221592
|
options: { codemode: false },
|
|
221560
|
-
description: "Restore the full turns of one indexed past session by its stored session id " + "(like opencode:ses_
|
|
221593
|
+
description: "Restore the full turns of one indexed past session by its stored session id " + "(like opencode:ses_..., dsh:<uuid>, or pi:<id>), optionally a single turn by sequence number. " + "Use vcc-brain-recall (not this tool) for the current conversation.",
|
|
221561
221594
|
input: {
|
|
221562
221595
|
type: "object",
|
|
221563
221596
|
properties: {
|
|
221564
221597
|
sessionId: {
|
|
221565
221598
|
type: "string",
|
|
221566
|
-
description: "Stored session id, like opencode:ses_
|
|
221599
|
+
description: "Stored session id, like opencode:ses_..., dsh:<uuid>, or pi:<id>."
|
|
221567
221600
|
},
|
|
221568
221601
|
seq: {
|
|
221569
221602
|
type: "string",
|
|
@@ -221591,7 +221624,7 @@ async function registerRecallSessionTool(context) {
|
|
|
221591
221624
|
invocation.push("--seq", sequence);
|
|
221592
221625
|
}
|
|
221593
221626
|
try {
|
|
221594
|
-
const result = await runHelperBinary(invocation);
|
|
221627
|
+
const result = await runHelperBinary(invocation, null);
|
|
221595
221628
|
return { content: result.output };
|
|
221596
221629
|
} catch {
|
|
221597
221630
|
return { content: "Could not run the recall index. Is vcc-brain-helper installed?" };
|
|
@@ -221979,4 +222012,4 @@ export {
|
|
|
221979
222012
|
src_default as default
|
|
221980
222013
|
};
|
|
221981
222014
|
|
|
221982
|
-
//# debugId=
|
|
222015
|
+
//# debugId=5275C9ACEF08608064756E2164756E21
|