🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@archships/dim-plugin-auto-compact

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@archships/dim-plugin-auto-compact - npm Package Compare versions

Comparing version
0.0.11
to
0.0.12
+19
-20
dist/index.js

@@ -14,3 +14,3 @@ //#region src/index.ts

const CONTINUATION_SUMMARY_BLOCK_PATTERN = /<continuation_summary>([\s\S]*?)<\/continuation_summary>/g;
const SUMMARY_PROMPT_VERSION = "continuation-summary-v1";
const SUMMARY_PROMPT_VERSION = "continuation-summary-v2";
const COMPACTION_INJECTION_METADATA_KEY = "_dimCompactionInjection";

@@ -46,6 +46,3 @@ const DEFAULT_SUMMARY_PROMPT = `You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:

Write in a way that enables immediate resumption of the task.
Wrap the final output in:
<continuation_summary>
...
</continuation_summary>`;
Return only the continuation summary body as plain text. Do not add XML tags, wrappers, or surrounding commentary.`;
function createAutoCompactPlugin(options = {}) {

@@ -410,3 +407,3 @@ const normalized = normalizeOptions(options);

let summaryCallCount = 0;
let summaryNormalization = "strict";
let summaryNormalization = "plain_text";
const chunkSummarySections = [];

@@ -465,8 +462,8 @@ for (const [index, chunk] of chunks.entries()) {

}
if (!text.trim()) throw createCodedError("empty_summary", "Auto compact summary model returned empty text");
if (!text.trim()) throw createCodedError("invalid_summary_contract", "Auto compact summary body cannot be empty");
const normalizedSummary = normalizeContinuationSummary(text);
if (normalizedSummary.normalization !== "strict") input.logger.emit({
if (normalizedSummary.normalization !== "plain_text") input.logger.emit({
level: "warn",
source: "auto-compact",
message: "Auto compact summary output did not match the strict continuation wrapper contract; normalized automatically",
message: "Auto compact summary output deviated from the preferred plain-text contract; normalized automatically",
metadata: {

@@ -662,18 +659,18 @@ sessionId: input.sessionId,

const blockMatches = [...trimmed.matchAll(CONTINUATION_SUMMARY_BLOCK_PATTERN)];
if (blockMatches.length > 1) throw createCodedError("invalid_summary_contract", "Auto compact summary must be wrapped in exactly one <continuation_summary>...</continuation_summary> block");
if (blockMatches.length > 1) throw createCodedError("invalid_summary_contract", "Auto compact summary must be plain text or contain exactly one <continuation_summary>...</continuation_summary> block");
if (blockMatches.length === 1) {
if (openCount !== 1 || closeCount !== 1) throw createCodedError("invalid_summary_contract", "Auto compact summary must be wrapped in exactly one <continuation_summary>...</continuation_summary> block");
if (openCount !== 1 || closeCount !== 1) throw createCodedError("invalid_summary_contract", "Auto compact summary must be plain text or contain exactly one <continuation_summary>...</continuation_summary> block");
const [match] = blockMatches;
const body = match?.[1]?.trim();
if (!body) throw createCodedError("invalid_summary_contract", "Auto compact summary wrapper cannot be empty");
if (!body) throw createCodedError("invalid_summary_contract", "Auto compact summary body cannot be empty");
return {
summary: renderCanonicalContinuationSummary(body),
normalization: match.index === 0 && match[0].length === trimmed.length ? "strict" : "extracted_block"
normalization: match.index === 0 && match[0].length === trimmed.length ? "wrapped_block" : "extracted_block"
};
}
if (openCount > 0 || closeCount > 0) throw createCodedError("invalid_summary_contract", "Auto compact summary must be wrapped in exactly one <continuation_summary>...</continuation_summary> block");
if (!trimmed) throw createCodedError("invalid_summary_contract", "Auto compact summary wrapper cannot be empty");
if (openCount > 0 || closeCount > 0) throw createCodedError("invalid_summary_contract", "Auto compact summary must be plain text or contain exactly one <continuation_summary>...</continuation_summary> block");
if (!trimmed) throw createCodedError("invalid_summary_contract", "Auto compact summary body cannot be empty");
return {
summary: renderCanonicalContinuationSummary(trimmed),
normalization: "wrapped_plain_text"
normalization: "plain_text"
};

@@ -686,5 +683,5 @@ }

const rank = {
strict: 0,
extracted_block: 1,
wrapped_plain_text: 2
plain_text: 0,
wrapped_block: 1,
extracted_block: 2
};

@@ -753,3 +750,5 @@ return rank[left] >= rank[right] ? left : right;

function readSummaryNormalizationMode(value) {
return value === "strict" || value === "extracted_block" || value === "wrapped_plain_text" ? value : void 0;
if (value === "plain_text" || value === "wrapped_block" || value === "extracted_block") return value;
if (value === "strict") return "wrapped_block";
if (value === "wrapped_plain_text") return "plain_text";
}

@@ -756,0 +755,0 @@ function readAttemptDiagnostics(value) {

{
"name": "@archships/dim-plugin-auto-compact",
"version": "0.0.11",
"version": "0.0.12",
"description": "Official auto compaction plugin for dim-agent-sdk.",

@@ -27,4 +27,4 @@ "homepage": "https://dimcode.dev/",

"devDependencies": {
"@archships/dim-agent-sdk": "0.0.48",
"@archships/dim-plugin-api": "0.0.17"
"@archships/dim-agent-sdk": "0.0.52",
"@archships/dim-plugin-api": "0.0.19"
},

@@ -31,0 +31,0 @@ "scripts": {

@@ -55,5 +55,5 @@ # @archships/dim-plugin-auto-compact

- summary model calls now opt into the SDK usage ledger with semantic request kinds: threshold-triggered passes record `auto_compaction`, and `session.compact()` summary calls record `manual_compaction`
- the summary prompt still asks the model for exactly one `<continuation_summary>...</continuation_summary>` block, but runtime now tolerates one valid wrapped block surrounded by noise or non-empty plain text with no wrapper and normalizes both back to one canonical block
- multiple wrapper blocks, empty wrappers, or malformed wrapper tags still fail with `invalid_summary_contract`
- `lastAttempt` is updated on every threshold-triggered compaction pass with `planned` / `skipped` / `compacted` / `failed`, budget metadata, estimator-based `estimatedInputTokensAfter` / `estimatedSavedTokens`, reason codes such as `missing_summary_model`, `nothing_to_compact`, `summary_generation_failed`, or `compaction_owner_required`, and optional `summaryNormalization` values (`strict`, `extracted_block`, `wrapped_plain_text`) when the summary output was inspected
- the default summary prompt asks the model for plain-text summary body only; runtime wraps accepted output back into one canonical `<continuation_summary>...</continuation_summary>` block, and it continues to accept a single wrapped block with or without surrounding noise for backward compatibility
- multiple wrapper blocks, empty bodies, or malformed wrapper tags still fail with `invalid_summary_contract`
- `lastAttempt` is updated on every threshold-triggered compaction pass with `planned` / `skipped` / `compacted` / `failed`, budget metadata, estimator-based `estimatedInputTokensAfter` / `estimatedSavedTokens`, reason codes such as `missing_summary_model`, `nothing_to_compact`, `summary_generation_failed`, or `compaction_owner_required`, and optional `summaryNormalization` values (`plain_text`, `wrapped_block`, `extracted_block`) when the summary output was inspected
- persisted plugin state keeps only semantic provenance fields; summary-call counters and per-message id arrays stay out of `pluginState`

@@ -60,0 +60,0 @@ - `context.compacted` notifications now include compacted / retained message counts plus estimator-based before / after / saved token fields when budgeting is enabled

Sorry, the diff of this file is too big to display