@jwitmann/vcc-brain-opencode-v2 2.8.0 → 2.8.1
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 +57 -22
- package/dist/index.js.map +7 -7
- package/dist/server.js +57 -22
- package/dist/server.js.map +7 -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.8.
|
|
7409
|
+
version: "2.8.1",
|
|
7410
7410
|
description: "VCC Brain adapter for OpenCode V2.",
|
|
7411
7411
|
license: "BSD-3-Clause",
|
|
7412
7412
|
author: "jwitmann",
|
|
@@ -217460,6 +217460,16 @@ function readOptionNumber(path, block, key, defaultValue) {
|
|
|
217460
217460
|
}
|
|
217461
217461
|
return success2(value);
|
|
217462
217462
|
}
|
|
217463
|
+
function readOptionString(path, block, key, defaultValue) {
|
|
217464
|
+
const value = block[key];
|
|
217465
|
+
if (value === undefined) {
|
|
217466
|
+
return success2(defaultValue);
|
|
217467
|
+
}
|
|
217468
|
+
if (typeof value !== "string") {
|
|
217469
|
+
return failure2({ message: `The "${path}.${key}" option must be a string.` });
|
|
217470
|
+
}
|
|
217471
|
+
return success2(value);
|
|
217472
|
+
}
|
|
217463
217473
|
function readOptionBoolean(path, block, key, defaultValue) {
|
|
217464
217474
|
const value = block[key];
|
|
217465
217475
|
if (value === undefined) {
|
|
@@ -219776,8 +219786,12 @@ function countWords(text, maxWords) {
|
|
|
219776
219786
|
import { join as join11 } from "node:path";
|
|
219777
219787
|
|
|
219778
219788
|
// src/context-config.ts
|
|
219789
|
+
function isFullContextMode(config) {
|
|
219790
|
+
return config.mode === "full";
|
|
219791
|
+
}
|
|
219779
219792
|
var DEFAULT_CONTEXT_MANAGEMENT_CONFIG = {
|
|
219780
219793
|
enabled: false,
|
|
219794
|
+
mode: "full",
|
|
219781
219795
|
ratio: 0.8,
|
|
219782
219796
|
hardCapTokens: 250000,
|
|
219783
219797
|
keepRecentTurns: 3,
|
|
@@ -219805,6 +219819,7 @@ function parseContextManagementBlock(block, base = DEFAULT_CONTEXT_MANAGEMENT_CO
|
|
|
219805
219819
|
}
|
|
219806
219820
|
const path = "vcc-brain.contextManagement";
|
|
219807
219821
|
const enabled = readOptionBoolean(path, block, "enabled", base.enabled);
|
|
219822
|
+
const mode = readOptionString(path, block, "mode", base.mode);
|
|
219808
219823
|
const ratio = readOptionNumber(path, block, "ratio", base.ratio);
|
|
219809
219824
|
const hardCapTokens = readOptionNumber(path, block, "hardCapTokens", base.hardCapTokens);
|
|
219810
219825
|
const keepRecentTurns = readOptionNumber(path, block, "keepRecentTurns", base.keepRecentTurns);
|
|
@@ -219812,6 +219827,13 @@ function parseContextManagementBlock(block, base = DEFAULT_CONTEXT_MANAGEMENT_CO
|
|
|
219812
219827
|
const compactFloorTokens = readOptionNumber(path, block, "compactFloorTokens", base.compactFloorTokens);
|
|
219813
219828
|
if (!enabled.ok)
|
|
219814
219829
|
return enabled;
|
|
219830
|
+
if (!mode.ok)
|
|
219831
|
+
return mode;
|
|
219832
|
+
if (mode.value !== "full" && mode.value !== "vcc") {
|
|
219833
|
+
return failure2({
|
|
219834
|
+
message: `The "${path}.mode" option must be "full" or "vcc".`
|
|
219835
|
+
});
|
|
219836
|
+
}
|
|
219815
219837
|
if (!ratio.ok)
|
|
219816
219838
|
return ratio;
|
|
219817
219839
|
if (!hardCapTokens.ok)
|
|
@@ -219824,6 +219846,7 @@ function parseContextManagementBlock(block, base = DEFAULT_CONTEXT_MANAGEMENT_CO
|
|
|
219824
219846
|
return compactFloorTokens;
|
|
219825
219847
|
return success2({
|
|
219826
219848
|
enabled: enabled.value,
|
|
219849
|
+
mode: mode.value,
|
|
219827
219850
|
ratio: ratio.value,
|
|
219828
219851
|
hardCapTokens: hardCapTokens.value,
|
|
219829
219852
|
keepRecentTurns: keepRecentTurns.value,
|
|
@@ -219840,20 +219863,23 @@ function registerContextHook(context, deps, runtime) {
|
|
|
219840
219863
|
}
|
|
219841
219864
|
const sessionID = event.sessionID;
|
|
219842
219865
|
const config = deps.config;
|
|
219866
|
+
const fullMode = isFullContextMode(config);
|
|
219843
219867
|
await ensureSessionHydrated(deps.stateDirectory, runtime, sessionID);
|
|
219844
219868
|
if (!deps.isBrainAvailable(sessionID)) {
|
|
219845
219869
|
await ensureRefusalReceipt(deps.stateDirectory, runtime, sessionID, deps);
|
|
219846
219870
|
return;
|
|
219847
219871
|
}
|
|
219848
219872
|
const session = sessionRuntime(runtime, sessionID);
|
|
219849
|
-
if (
|
|
219850
|
-
|
|
219851
|
-
|
|
219852
|
-
|
|
219853
|
-
|
|
219854
|
-
|
|
219873
|
+
if (fullMode) {
|
|
219874
|
+
if (isContextStale(deps)) {
|
|
219875
|
+
return;
|
|
219876
|
+
}
|
|
219877
|
+
const remembered = await rememberSnapshot(join11(deps.stateDirectory, "context-snapshot"), sessionID, event.messages, new Date().toISOString(), session.snapshotSeen);
|
|
219878
|
+
if (isContextStale(deps)) {
|
|
219879
|
+
return;
|
|
219880
|
+
}
|
|
219881
|
+
session.snapshotSeen = remembered.seen;
|
|
219855
219882
|
}
|
|
219856
|
-
session.snapshotSeen = remembered.seen;
|
|
219857
219883
|
const estimatedTokens = estimateContextTokens(session.estimator, event.messages);
|
|
219858
219884
|
const windowTokens = await resolveWindowTokens(context, session, event.model);
|
|
219859
219885
|
session.lastEstimate = estimatedTokens;
|
|
@@ -219893,6 +219919,9 @@ function registerContextHook(context, deps, runtime) {
|
|
|
219893
219919
|
if (!exceedsThresholds(estimateAfterTrim, windowTokens ?? 0, config)) {
|
|
219894
219920
|
return;
|
|
219895
219921
|
}
|
|
219922
|
+
if (!fullMode) {
|
|
219923
|
+
return;
|
|
219924
|
+
}
|
|
219896
219925
|
if (shouldSuppressCompactionRequest(session, estimatedTokens, windowTokens ?? 0, Date.now())) {
|
|
219897
219926
|
return;
|
|
219898
219927
|
}
|
|
@@ -221483,7 +221512,7 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221483
221512
|
const effectiveBrainUpdatesConfig = projectOverride.config.brainUpdates;
|
|
221484
221513
|
const effectiveContextManagement = projectOverride.config.contextManagement;
|
|
221485
221514
|
let contextManagementEnabled = parsed.ok && effectiveContextManagement.enabled;
|
|
221486
|
-
if (contextManagementEnabled) {
|
|
221515
|
+
if (contextManagementEnabled && isFullContextMode(effectiveContextManagement)) {
|
|
221487
221516
|
const external = await findExternalCompactionProvider(context);
|
|
221488
221517
|
if (external !== null) {
|
|
221489
221518
|
contextManagementEnabled = false;
|
|
@@ -221500,8 +221529,9 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221500
221529
|
const isActive = () => isCurrent() && !standDown.stoodDown;
|
|
221501
221530
|
let providerRecheckDone = false;
|
|
221502
221531
|
const maybeStandDownForExternalProvider = async () => {
|
|
221503
|
-
if (!contextManagementEnabled || providerRecheckDone || !isCurrent())
|
|
221532
|
+
if (!contextManagementEnabled || !isFullContextMode(effectiveContextManagement) || providerRecheckDone || !isCurrent()) {
|
|
221504
221533
|
return;
|
|
221534
|
+
}
|
|
221505
221535
|
providerRecheckDone = true;
|
|
221506
221536
|
const hit = await findExternalCompactionProvider(context);
|
|
221507
221537
|
if (hit === null || !isCurrent())
|
|
@@ -221609,6 +221639,7 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221609
221639
|
};
|
|
221610
221640
|
const controller = new AbortController;
|
|
221611
221641
|
if (contextManagementEnabled) {
|
|
221642
|
+
const fullMode = isFullContextMode(config);
|
|
221612
221643
|
const requestCompaction = (sessionID, cause) => {
|
|
221613
221644
|
if (!isActive()) {
|
|
221614
221645
|
return;
|
|
@@ -221624,20 +221655,24 @@ var VccBrainPlugin = Plugin.define({
|
|
|
221624
221655
|
isCurrent: isActive
|
|
221625
221656
|
};
|
|
221626
221657
|
registerContextHook(context, deps, runtime);
|
|
221627
|
-
|
|
221628
|
-
|
|
221629
|
-
|
|
221630
|
-
|
|
221631
|
-
|
|
221632
|
-
|
|
221633
|
-
|
|
221634
|
-
|
|
221635
|
-
|
|
221658
|
+
if (fullMode) {
|
|
221659
|
+
registerCompactionHook(context, {
|
|
221660
|
+
config,
|
|
221661
|
+
stateDirectory,
|
|
221662
|
+
brainPaths: DEFAULT_BRAIN_PATHS,
|
|
221663
|
+
isBrainAvailable,
|
|
221664
|
+
reportReceiptFailure,
|
|
221665
|
+
refreshEnabled: refreshConfig.enabled,
|
|
221666
|
+
isCurrent: isActive
|
|
221667
|
+
}, runtime);
|
|
221668
|
+
}
|
|
221636
221669
|
registerCompletionTrigger(context, deps, runtime, { signal: controller.signal });
|
|
221637
221670
|
await registerReadOmittedTool(context, { stateDirectory });
|
|
221638
221671
|
await registerPruneTool(context, { stateDirectory });
|
|
221639
|
-
|
|
221640
|
-
|
|
221672
|
+
if (fullMode) {
|
|
221673
|
+
await registerRecallTool(context, { stateDirectory });
|
|
221674
|
+
await registerSearchTool(context, { stateDirectory });
|
|
221675
|
+
}
|
|
221641
221676
|
await registerSearchSessionsTool(context, {
|
|
221642
221677
|
projectDirectory: context.location.directory
|
|
221643
221678
|
});
|
|
@@ -221679,4 +221714,4 @@ export {
|
|
|
221679
221714
|
src_default as default
|
|
221680
221715
|
};
|
|
221681
221716
|
|
|
221682
|
-
//# debugId=
|
|
221717
|
+
//# debugId=ED9B918913E4F56E64756E2164756E21
|