@lexwdex-org/opencode-dcp 3.3.2 → 3.3.4
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 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/compress/search.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2001,15 +2001,31 @@ function resolveBoundaryIds(context, state, startId, endId) {
|
|
|
2001
2001
|
}
|
|
2002
2002
|
const startReference = lookup.get(parsedStartId.ref);
|
|
2003
2003
|
const endReference = lookup.get(parsedEndId.ref);
|
|
2004
|
-
if (!startReference) {
|
|
2005
|
-
|
|
2006
|
-
|
|
2004
|
+
if (!startReference || !endReference) {
|
|
2005
|
+
const allKeys = Array.from(lookup.keys());
|
|
2006
|
+
const availableBlockRefs = allKeys.filter((key) => key.startsWith("b")).sort(
|
|
2007
|
+
(a, b) => Number.parseInt(a.slice(1), 10) - Number.parseInt(b.slice(1), 10)
|
|
2007
2008
|
);
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
issues.push(
|
|
2011
|
-
`endId ${parsedEndId.ref} is not available in the current conversation context. Choose an injected ID visible in context.`
|
|
2009
|
+
const availableMsgRefs = allKeys.filter((key) => key.startsWith("m")).sort(
|
|
2010
|
+
(a, b) => Number.parseInt(a.slice(1), 10) - Number.parseInt(b.slice(1), 10)
|
|
2012
2011
|
);
|
|
2012
|
+
const blockHint = availableBlockRefs.length ? ` Available block IDs: ${availableBlockRefs.join(", ")}.` : " No block IDs available.";
|
|
2013
|
+
const msgHint = availableMsgRefs.length === 0 ? " No message IDs available." : availableMsgRefs.length <= 10 ? ` Available message IDs: ${availableMsgRefs.join(", ")}.` : ` Available message IDs: ${availableMsgRefs[0]} to ${availableMsgRefs[availableMsgRefs.length - 1]} (${availableMsgRefs.length} total).`;
|
|
2014
|
+
const hint = `${msgHint}${blockHint}`;
|
|
2015
|
+
if (!startReference) {
|
|
2016
|
+
const wasKnown = state.messageIds.byRef.has(parsedStartId.ref);
|
|
2017
|
+
const reason = wasKnown ? " (message was likely compacted out of the conversation)" : " (invalid ID)";
|
|
2018
|
+
issues.push(
|
|
2019
|
+
`startId ${parsedStartId.ref} is not available${reason}. Choose an injected ID visible in context.${hint}`
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
if (!endReference) {
|
|
2023
|
+
const wasKnown = state.messageIds.byRef.has(parsedEndId.ref);
|
|
2024
|
+
const reason = wasKnown ? " (message was likely compacted out of the conversation)" : " (invalid ID)";
|
|
2025
|
+
issues.push(
|
|
2026
|
+
`endId ${parsedEndId.ref} is not available${reason}. Choose an injected ID visible in context.${hint}`
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2013
2029
|
}
|
|
2014
2030
|
if (issues.length > 0) {
|
|
2015
2031
|
throw new Error(
|
|
@@ -2158,6 +2174,32 @@ function buildBoundaryLookup(context, state) {
|
|
|
2158
2174
|
});
|
|
2159
2175
|
}
|
|
2160
2176
|
}
|
|
2177
|
+
for (const [blockId, block] of state.prune.messages.blocksById) {
|
|
2178
|
+
if (block.active) {
|
|
2179
|
+
continue;
|
|
2180
|
+
}
|
|
2181
|
+
const blockRef = formatBlockRef(blockId);
|
|
2182
|
+
if (lookup.has(blockRef)) {
|
|
2183
|
+
continue;
|
|
2184
|
+
}
|
|
2185
|
+
const anchorMessage = context.rawMessagesById.get(block.anchorMessageId);
|
|
2186
|
+
if (!anchorMessage) {
|
|
2187
|
+
continue;
|
|
2188
|
+
}
|
|
2189
|
+
if (isIgnoredUserMessage(anchorMessage)) {
|
|
2190
|
+
continue;
|
|
2191
|
+
}
|
|
2192
|
+
const rawIndex = context.rawIndexById.get(block.anchorMessageId);
|
|
2193
|
+
if (rawIndex === void 0) {
|
|
2194
|
+
continue;
|
|
2195
|
+
}
|
|
2196
|
+
lookup.set(blockRef, {
|
|
2197
|
+
kind: "compressed-block",
|
|
2198
|
+
rawIndex,
|
|
2199
|
+
blockId: block.blockId,
|
|
2200
|
+
anchorMessageId: block.anchorMessageId
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2161
2203
|
return lookup;
|
|
2162
2204
|
}
|
|
2163
2205
|
|
|
@@ -5693,15 +5735,15 @@ var syncCompressionBlocks = (state, logger, messages) => {
|
|
|
5693
5735
|
messagesState.activeBlockIds.clear();
|
|
5694
5736
|
messagesState.activeByAnchorMessageId.clear();
|
|
5695
5737
|
const now = Date.now();
|
|
5696
|
-
const
|
|
5738
|
+
const missingAnchorBlockIds = [];
|
|
5697
5739
|
const orderedBlocks = Array.from(messagesState.blocksById.values()).sort(sortBlocksByCreation);
|
|
5698
5740
|
for (const block of orderedBlocks) {
|
|
5699
|
-
const
|
|
5700
|
-
if (!
|
|
5741
|
+
const hasAnchorMessage = typeof block.anchorMessageId === "string" && block.anchorMessageId.length > 0 && messageIds.has(block.anchorMessageId);
|
|
5742
|
+
if (!hasAnchorMessage) {
|
|
5701
5743
|
block.active = false;
|
|
5702
5744
|
block.deactivatedAt = now;
|
|
5703
5745
|
block.deactivatedByBlockId = void 0;
|
|
5704
|
-
|
|
5746
|
+
missingAnchorBlockIds.push(block.blockId);
|
|
5705
5747
|
continue;
|
|
5706
5748
|
}
|
|
5707
5749
|
if (block.deactivatedByUser) {
|
|
@@ -5756,9 +5798,9 @@ var syncCompressionBlocks = (state, logger, messages) => {
|
|
|
5756
5798
|
reactivatedCount++;
|
|
5757
5799
|
}
|
|
5758
5800
|
}
|
|
5759
|
-
if (
|
|
5801
|
+
if (missingAnchorBlockIds.length > 0 || deactivatedCount > 0 || reactivatedCount > 0) {
|
|
5760
5802
|
logger.info("Synced compress block state", {
|
|
5761
|
-
|
|
5803
|
+
missingAnchorCount: missingAnchorBlockIds.length,
|
|
5762
5804
|
deactivatedCount,
|
|
5763
5805
|
reactivatedCount
|
|
5764
5806
|
});
|
|
@@ -6621,7 +6663,7 @@ function getActiveCompressionTargets(messagesState) {
|
|
|
6621
6663
|
}
|
|
6622
6664
|
function getRecompressibleCompressionTargets(messagesState, availableMessageIds) {
|
|
6623
6665
|
const allBlocks = Array.from(messagesState.blocksById.values()).filter((block) => {
|
|
6624
|
-
return availableMessageIds.has(block.
|
|
6666
|
+
return availableMessageIds.has(block.anchorMessageId);
|
|
6625
6667
|
});
|
|
6626
6668
|
const messageGroups = /* @__PURE__ */ new Map();
|
|
6627
6669
|
const singleTargets = [];
|
|
@@ -7088,7 +7130,7 @@ async function handleRecompressCommand(ctx) {
|
|
|
7088
7130
|
);
|
|
7089
7131
|
return;
|
|
7090
7132
|
}
|
|
7091
|
-
if (target.blocks.some((block) => !availableMessageIds.has(block.
|
|
7133
|
+
if (target.blocks.some((block) => !availableMessageIds.has(block.anchorMessageId))) {
|
|
7092
7134
|
await sendIgnoredMessage(
|
|
7093
7135
|
client,
|
|
7094
7136
|
sessionId,
|