@bd7pil/opencode-deep-memory 0.5.1 → 0.5.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 CHANGED
@@ -15236,8 +15236,8 @@ function createCompactingHandler(args) {
15236
15236
  var FALLBACK_MAX_CONTEXT = 128e3;
15237
15237
  var OPENCODE_COMPACTION_RATIO = 0.75;
15238
15238
  var THRESHOLDS = {
15239
- medium: 0.3,
15240
- high: 0.5
15239
+ medium: 0.2,
15240
+ high: 0.4
15241
15241
  };
15242
15242
  var calibratedMaxContext = 0;
15243
15243
  function calibrateFromCompaction(lastInputTokens) {
@@ -15318,7 +15318,7 @@ function detectPressure(messages, modelContextWindow) {
15318
15318
  }
15319
15319
 
15320
15320
  // src/compress/nudge.ts
15321
- var NUDGE_COOLDOWN = 5;
15321
+ var NUDGE_COOLDOWN = 3;
15322
15322
  function shouldInjectNudge(level, messagesSinceLastNudge) {
15323
15323
  if (level !== "high") return false;
15324
15324
  if (messagesSinceLastNudge < NUDGE_COOLDOWN) return false;
@@ -15411,7 +15411,7 @@ var DEFAULT_HEAD_LINES = 50;
15411
15411
  var DEFAULT_TAIL_LINES = 20;
15412
15412
  var MAX_LINE_LENGTH = 500;
15413
15413
  function compressToolOutput(toolName, output) {
15414
- if (!output || output.length < 500) return output;
15414
+ if (!output || output.length < 200) return output;
15415
15415
  const strategy = TOOL_COMPRESS_STRATEGIES[toolName];
15416
15416
  if (strategy) return strategy(output);
15417
15417
  return compressGeneric(output);
@@ -15575,7 +15575,7 @@ var PROTECTED_TOOLS = /* @__PURE__ */ new Set([
15575
15575
  ]);
15576
15576
  var NEVER_DEDUP = /* @__PURE__ */ new Set(["read", "bash", "grep", "glob", "find", "search"]);
15577
15577
  var ERROR_PURGE_TURN_THRESHOLD = 4;
15578
- var PROTECTED_HEAD = 2;
15578
+ var PROTECTED_HEAD_SINGLE = 2;
15579
15579
  function simpleHash(s) {
15580
15580
  const len = s.length;
15581
15581
  const sampleSize = 500;
@@ -15598,9 +15598,9 @@ function singlePassCompress(messages, state, protectedTail) {
15598
15598
  ccrStored: 0
15599
15599
  };
15600
15600
  const totalMessages = messages.length;
15601
- if (totalMessages <= PROTECTED_HEAD) return stats;
15601
+ if (totalMessages <= PROTECTED_HEAD_SINGLE) return stats;
15602
15602
  const seen = /* @__PURE__ */ new Map();
15603
- for (let i = PROTECTED_HEAD; i < totalMessages; i++) {
15603
+ for (let i = PROTECTED_HEAD_SINGLE; i < totalMessages; i++) {
15604
15604
  const msg = messages[i];
15605
15605
  if (!msg?.parts?.length) continue;
15606
15606
  if (msg.info.role === "user") continue;
@@ -15656,18 +15656,18 @@ function singlePassCompress(messages, state, protectedTail) {
15656
15656
  seen.set(signature, { msgIdx: i, outputHash });
15657
15657
  }
15658
15658
  }
15659
- if (output.length >= 500) {
15659
+ if (output.length >= 200) {
15660
15660
  const result = compressToolOutput(toolName, output);
15661
- if (result.length < output.length * 0.7) {
15661
+ if (result.length < output.length * 0.85) {
15662
15662
  const hash2 = ccrStore(state, output, result, toolName, callID);
15663
15663
  toolState["output"] = ccrInjectMarker(result, hash2);
15664
15664
  stats.toolOutputCompressed++;
15665
15665
  continue;
15666
15666
  }
15667
15667
  }
15668
- if (output.length >= 500 && detectContentType(output) === "json") {
15668
+ if (output.length >= 200 && detectContentType(output) === "json") {
15669
15669
  const crushed = crushJsonArray(output);
15670
- if (crushed.length < output.length * 0.7) {
15670
+ if (crushed.length < output.length * 0.85) {
15671
15671
  const hash2 = ccrStore(state, output, crushed, toolName, callID);
15672
15672
  toolState["output"] = ccrInjectMarker(crushed, hash2);
15673
15673
  stats.jsonCrushed++;
@@ -15760,7 +15760,7 @@ function injectIntoLastAssistant(messages, text) {
15760
15760
 
15761
15761
  // src/hooks/messages-transform.ts
15762
15762
  var KEEP_RECENT = 8;
15763
- var PROTECTED_HEAD2 = 3;
15763
+ var PROTECTED_HEAD = 3;
15764
15764
  var SYSTEM_INJECTION_PATTERNS = [
15765
15765
  /^$/,
15766
15766
  /^<!-- OMO_INTERNAL_INITIATOR -->$/,
@@ -15847,7 +15847,7 @@ function createMessagesTransformHandler(state, logger) {
15847
15847
  return async (input, output) => {
15848
15848
  const messages = output.messages;
15849
15849
  if (messages.length <= KEEP_RECENT) return;
15850
- if (messages.length <= KEEP_RECENT + PROTECTED_HEAD2) return;
15850
+ if (messages.length <= KEEP_RECENT + PROTECTED_HEAD) return;
15851
15851
  const protectedTailStart = messages.length - KEEP_RECENT;
15852
15852
  const stats = {
15853
15853
  reasoning_cleared: 0,
@@ -15857,7 +15857,7 @@ function createMessagesTransformHandler(state, logger) {
15857
15857
  thinking_stripped: 0
15858
15858
  };
15859
15859
  const toRemove = [];
15860
- for (let i = PROTECTED_HEAD2; i < protectedTailStart; i++) {
15860
+ for (let i = PROTECTED_HEAD; i < protectedTailStart; i++) {
15861
15861
  const msg = messages[i];
15862
15862
  if (!msg?.parts?.length) continue;
15863
15863
  if (msg.info.role === "user") continue;
@@ -15931,14 +15931,14 @@ function createMessagesTransformHandler(state, logger) {
15931
15931
  compression: stats,
15932
15932
  deepCompression: ds,
15933
15933
  messageCount: messages.length,
15934
- protectedHead: PROTECTED_HEAD2,
15934
+ protectedHead: PROTECTED_HEAD,
15935
15935
  protectedTail: KEEP_RECENT
15936
15936
  });
15937
15937
  } else if (Object.values(stats).some((v) => v > 0)) {
15938
15938
  state.mergeNotify({
15939
15939
  compression: stats,
15940
15940
  messageCount: messages.length,
15941
- protectedHead: PROTECTED_HEAD2,
15941
+ protectedHead: PROTECTED_HEAD,
15942
15942
  protectedTail: KEEP_RECENT
15943
15943
  });
15944
15944
  }