@jwitmann/vcc-brain-opencode-v2 2.7.2 → 2.8.0
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 +136 -6
- package/dist/index.js.map +8 -7
- package/dist/server.js +136 -6
- package/dist/server.js.map +8 -7
- package/dist/tui.js +2 -2
- package/dist/tui.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7406,7 +7406,7 @@ import { Plugin } from "@opencode/plugin";
|
|
|
7406
7406
|
// package.json
|
|
7407
7407
|
var package_default = {
|
|
7408
7408
|
name: "@jwitmann/vcc-brain-opencode-v2",
|
|
7409
|
-
version: "2.
|
|
7409
|
+
version: "2.8.0",
|
|
7410
7410
|
description: "VCC Brain adapter for OpenCode V2.",
|
|
7411
7411
|
license: "BSD-3-Clause",
|
|
7412
7412
|
author: "jwitmann",
|
|
@@ -218537,10 +218537,24 @@ function toCompilerNode(message, seq) {
|
|
|
218537
218537
|
if (block !== null)
|
|
218538
218538
|
blocks.push(block);
|
|
218539
218539
|
}
|
|
218540
|
+
if (isTaggedCheckpointBlocks(blocks)) {
|
|
218541
|
+
return {
|
|
218542
|
+
seq,
|
|
218543
|
+
message: { role: "user", content: blocks, source: { kind: "compact-checkpoint" } }
|
|
218544
|
+
};
|
|
218545
|
+
}
|
|
218540
218546
|
return { seq, message: { role: "user", content: blocks } };
|
|
218541
218547
|
}
|
|
218542
218548
|
return null;
|
|
218543
218549
|
}
|
|
218550
|
+
function isTaggedCheckpointBlocks(blocks) {
|
|
218551
|
+
let text = "";
|
|
218552
|
+
for (const block of blocks) {
|
|
218553
|
+
if (block?.type === "text" && typeof block.text === "string")
|
|
218554
|
+
text += block.text;
|
|
218555
|
+
}
|
|
218556
|
+
return text.includes(CHECKPOINT_OPEN_TAG) && text.includes(CHECKPOINT_CLOSE_TAG);
|
|
218557
|
+
}
|
|
218544
218558
|
function pickKeepID(messages, keepMessages) {
|
|
218545
218559
|
const list = Array.isArray(messages) ? messages : [];
|
|
218546
218560
|
const keep = Number.isFinite(keepMessages) && keepMessages > 0 ? Math.max(1, Math.floor(keepMessages)) : DEFAULT_VCC_KEEP_MESSAGES;
|
|
@@ -219327,6 +219341,30 @@ function formatSearchReply(pattern, found) {
|
|
|
219327
219341
|
|
|
219328
219342
|
${found.text}`;
|
|
219329
219343
|
}
|
|
219344
|
+
var FOREIGN_COMPACTION_HEADER_PATTERN = /\[([^\][\n]*-compaction\s+\S[^\][\n]*:[^\][\n]*)\]/;
|
|
219345
|
+
var OWN_COMPACTION_HEADER_PREFIX = "[vcc-compaction ";
|
|
219346
|
+
function findForeignCheckpointHeader(messages) {
|
|
219347
|
+
const list = Array.isArray(messages) ? messages : [];
|
|
219348
|
+
for (const message of list) {
|
|
219349
|
+
const content = message?.content;
|
|
219350
|
+
if (!Array.isArray(content))
|
|
219351
|
+
continue;
|
|
219352
|
+
for (const part of content) {
|
|
219353
|
+
if (part === null || part === undefined || part.type !== "text")
|
|
219354
|
+
continue;
|
|
219355
|
+
const text = part.text;
|
|
219356
|
+
if (typeof text !== "string")
|
|
219357
|
+
continue;
|
|
219358
|
+
const match = FOREIGN_COMPACTION_HEADER_PATTERN.exec(text);
|
|
219359
|
+
if (match === null)
|
|
219360
|
+
continue;
|
|
219361
|
+
const header = `[${match[1] ?? ""}]`;
|
|
219362
|
+
if (!header.startsWith(OWN_COMPACTION_HEADER_PREFIX))
|
|
219363
|
+
return header;
|
|
219364
|
+
}
|
|
219365
|
+
}
|
|
219366
|
+
return null;
|
|
219367
|
+
}
|
|
219330
219368
|
function classifySnapshotStore(read) {
|
|
219331
219369
|
if (!read.ok)
|
|
219332
219370
|
return { status: "failed" };
|
|
@@ -220948,6 +220986,42 @@ function readProjectBlock(input, key) {
|
|
|
220948
220986
|
return success2(section);
|
|
220949
220987
|
}
|
|
220950
220988
|
|
|
220989
|
+
// src/provider-detect.ts
|
|
220990
|
+
var EXTERNAL_RECALL_TOOL_NAMES = new Set(["vcc-recall", "vcc-search"]);
|
|
220991
|
+
var EXTERNAL_ENGINE_SEGMENT = "opencode-vcc-port";
|
|
220992
|
+
function detectExternalCompactionProvider(plugins, tools) {
|
|
220993
|
+
const toolList = Array.isArray(tools) ? tools : [];
|
|
220994
|
+
for (const tool of toolList) {
|
|
220995
|
+
if (isRecord(tool) && typeof tool.name === "string" && EXTERNAL_RECALL_TOOL_NAMES.has(tool.name)) {
|
|
220996
|
+
return { kind: "tool", detail: `external compaction tool "${tool.name}" is registered` };
|
|
220997
|
+
}
|
|
220998
|
+
}
|
|
220999
|
+
const pluginList = Array.isArray(plugins) ? plugins : [];
|
|
221000
|
+
for (const plugin of pluginList) {
|
|
221001
|
+
if (!isRecord(plugin))
|
|
221002
|
+
continue;
|
|
221003
|
+
if (typeof plugin.id === "string" && plugin.id === EXTERNAL_ENGINE_SEGMENT) {
|
|
221004
|
+
return { kind: "plugin", detail: `external compaction plugin "${plugin.id}" is active` };
|
|
221005
|
+
}
|
|
221006
|
+
const source = plugin.source;
|
|
221007
|
+
if (isRecord(source) && source.type === "local" && typeof source.path === "string" && source.path.split("/").includes(EXTERNAL_ENGINE_SEGMENT)) {
|
|
221008
|
+
return { kind: "plugin", detail: `external compaction plugin at "${source.path}" is active` };
|
|
221009
|
+
}
|
|
221010
|
+
}
|
|
221011
|
+
return null;
|
|
221012
|
+
}
|
|
221013
|
+
async function findExternalCompactionProvider(context) {
|
|
221014
|
+
try {
|
|
221015
|
+
const pluginList = typeof context.plugin?.list === "function" ? await context.plugin.list() : null;
|
|
221016
|
+
const toolList = typeof context.tool?.list === "function" ? await context.tool.list() : null;
|
|
221017
|
+
const plugins = isRecord(pluginList) && Array.isArray(pluginList.data) ? pluginList.data : [];
|
|
221018
|
+
const tools = Array.isArray(toolList) ? toolList : [];
|
|
221019
|
+
return detectExternalCompactionProvider(plugins, tools);
|
|
221020
|
+
} catch {
|
|
221021
|
+
return null;
|
|
221022
|
+
}
|
|
221023
|
+
}
|
|
221024
|
+
|
|
220951
221025
|
// src/refresh.ts
|
|
220952
221026
|
import { join as join12 } from "node:path";
|
|
220953
221027
|
async function maybeRefreshPreamble(deps, runtime, sessionID, projectDirectory, homeDirectory, cache, messages) {
|
|
@@ -221012,6 +221086,12 @@ async function refreshPreambleContent(deps, runtime, sessionID, projectDirectory
|
|
|
221012
221086
|
import { execFile } from "node:child_process";
|
|
221013
221087
|
import { join as join13 } from "node:path";
|
|
221014
221088
|
var OMISSION_ID_PATTERN = /^omitted-\d+$/;
|
|
221089
|
+
var CONTEXT_MANAGEMENT_TOOL_NAMES = [
|
|
221090
|
+
"vcc-brain-read_omitted",
|
|
221091
|
+
"vcc-brain-prune",
|
|
221092
|
+
"vcc-brain-recall",
|
|
221093
|
+
"vcc-brain-search"
|
|
221094
|
+
];
|
|
221015
221095
|
function isOmissionID(contentID) {
|
|
221016
221096
|
return OMISSION_ID_PATTERN.test(contentID);
|
|
221017
221097
|
}
|
|
@@ -221149,6 +221229,14 @@ async function registerRecallTool(context, deps) {
|
|
|
221149
221229
|
}
|
|
221150
221230
|
const resolved = resolveRecallSelections(classified.messages, input.type, input.id);
|
|
221151
221231
|
if (resolved.errors.length > 0 || resolved.selections.length === 0) {
|
|
221232
|
+
if (input.type === "checkpoint") {
|
|
221233
|
+
const foreign = findForeignCheckpointHeader(classified.messages);
|
|
221234
|
+
if (foreign !== null) {
|
|
221235
|
+
return {
|
|
221236
|
+
content: `This session's checkpoint was compiled by an external compaction engine (${foreign}), ` + "not by VCC Brain instant-compaction, so vcc-brain-recall has no checkpoint ordinals for it. " + "Restore it with the owning engine's recall tool (for the opencode-vcc-port engine: vcc-recall)."
|
|
221237
|
+
};
|
|
221238
|
+
}
|
|
221239
|
+
}
|
|
221152
221240
|
return {
|
|
221153
221241
|
content: resolved.errors.length > 0 ? resolved.errors.join("; ") : "Nothing to recall."
|
|
221154
221242
|
};
|
|
@@ -221394,10 +221482,52 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221394
221482
|
const effectiveRefreshConfig = projectOverride.config.preambleRefresh;
|
|
221395
221483
|
const effectiveBrainUpdatesConfig = projectOverride.config.brainUpdates;
|
|
221396
221484
|
const effectiveContextManagement = projectOverride.config.contextManagement;
|
|
221397
|
-
|
|
221485
|
+
let contextManagementEnabled = parsed.ok && effectiveContextManagement.enabled;
|
|
221486
|
+
if (contextManagementEnabled) {
|
|
221487
|
+
const external = await findExternalCompactionProvider(context);
|
|
221488
|
+
if (external !== null) {
|
|
221489
|
+
contextManagementEnabled = false;
|
|
221490
|
+
await showToast({
|
|
221491
|
+
title: "VCC Brain",
|
|
221492
|
+
message: `External compaction engine detected (${external.detail}); VCC Brain context management is off — ` + "one compaction/recall provider per session. Preamble, refresh, and brain updates stay on.",
|
|
221493
|
+
variant: "warning"
|
|
221494
|
+
}).catch(() => {
|
|
221495
|
+
return;
|
|
221496
|
+
});
|
|
221497
|
+
}
|
|
221498
|
+
}
|
|
221499
|
+
const standDown = { stoodDown: false };
|
|
221500
|
+
const isActive = () => isCurrent() && !standDown.stoodDown;
|
|
221501
|
+
let providerRecheckDone = false;
|
|
221502
|
+
const maybeStandDownForExternalProvider = async () => {
|
|
221503
|
+
if (!contextManagementEnabled || providerRecheckDone || !isCurrent())
|
|
221504
|
+
return;
|
|
221505
|
+
providerRecheckDone = true;
|
|
221506
|
+
const hit = await findExternalCompactionProvider(context);
|
|
221507
|
+
if (hit === null || !isCurrent())
|
|
221508
|
+
return;
|
|
221509
|
+
standDown.stoodDown = true;
|
|
221510
|
+
try {
|
|
221511
|
+
await context.tool.transform((editor) => {
|
|
221512
|
+
for (const name of CONTEXT_MANAGEMENT_TOOL_NAMES)
|
|
221513
|
+
editor.remove(name);
|
|
221514
|
+
});
|
|
221515
|
+
} catch {}
|
|
221516
|
+
await showToast({
|
|
221517
|
+
title: "VCC Brain",
|
|
221518
|
+
message: `External compaction engine detected (${hit.detail}); VCC Brain context management stood down — ` + "use the owning engine's recall/search tools.",
|
|
221519
|
+
variant: "warning"
|
|
221520
|
+
}).catch(() => {
|
|
221521
|
+
return;
|
|
221522
|
+
});
|
|
221523
|
+
};
|
|
221398
221524
|
await registerCommands(context);
|
|
221399
221525
|
const brainAvailable = new Map;
|
|
221400
221526
|
await context.session.hook("context", async (event) => {
|
|
221527
|
+
if (!isCurrent()) {
|
|
221528
|
+
return;
|
|
221529
|
+
}
|
|
221530
|
+
await maybeStandDownForExternalProvider();
|
|
221401
221531
|
if (!isCurrent()) {
|
|
221402
221532
|
return;
|
|
221403
221533
|
}
|
|
@@ -221480,7 +221610,7 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221480
221610
|
const controller = new AbortController;
|
|
221481
221611
|
if (contextManagementEnabled) {
|
|
221482
221612
|
const requestCompaction = (sessionID, cause) => {
|
|
221483
|
-
if (!
|
|
221613
|
+
if (!isActive()) {
|
|
221484
221614
|
return;
|
|
221485
221615
|
}
|
|
221486
221616
|
requestSessionCompaction(context, runtime, sessionID, cause);
|
|
@@ -221491,7 +221621,7 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221491
221621
|
requestCompaction,
|
|
221492
221622
|
isBrainAvailable,
|
|
221493
221623
|
reportReceiptFailure,
|
|
221494
|
-
isCurrent
|
|
221624
|
+
isCurrent: isActive
|
|
221495
221625
|
};
|
|
221496
221626
|
registerContextHook(context, deps, runtime);
|
|
221497
221627
|
registerCompactionHook(context, {
|
|
@@ -221501,7 +221631,7 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221501
221631
|
isBrainAvailable,
|
|
221502
221632
|
reportReceiptFailure,
|
|
221503
221633
|
refreshEnabled: refreshConfig.enabled,
|
|
221504
|
-
isCurrent
|
|
221634
|
+
isCurrent: isActive
|
|
221505
221635
|
}, runtime);
|
|
221506
221636
|
registerCompletionTrigger(context, deps, runtime, { signal: controller.signal });
|
|
221507
221637
|
await registerReadOmittedTool(context, { stateDirectory });
|
|
@@ -221549,4 +221679,4 @@ export {
|
|
|
221549
221679
|
src_default as default
|
|
221550
221680
|
};
|
|
221551
221681
|
|
|
221552
|
-
//# debugId=
|
|
221682
|
+
//# debugId=B5252D4F94863C7064756E2164756E21
|