acp-kernel 0.0.99 → 0.0.100-pr.497.358
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/boundaries.d.ts.map +1 -1
- package/dist/ccr.d.ts.map +1 -1
- package/dist/{chunk-HNWTM2K4.js → chunk-Q3P5Z2PV.js} +20 -2
- package/dist/chunk-Q3P5Z2PV.js.map +1 -0
- package/dist/compress.d.ts.map +1 -1
- package/dist/compression-rules.d.ts +7 -0
- package/dist/compression-rules.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -11
- package/dist/index.js.map +1 -1
- package/dist/packs.d.ts +6 -0
- package/dist/packs.d.ts.map +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/prompts.d.ts +6 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/protected.d.ts +5 -0
- package/dist/protected.d.ts.map +1 -1
- package/dist/refs.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-HNWTM2K4.js.map +0 -1
package/dist/boundaries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAKD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAehE;AAED;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,wBAAwB;IACrC,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,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;6EAG6E;AAC7E,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,sBAAsB,GAC5B,uBAAuB,CAuFzB;AAED,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;gEAEgE;AAChE,eAAO,MAAM,YAAY,EAAE,YA8B1B,CAAC;AAEF;;;4EAG4E;AAC5E,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACrC,YAAY,GAAE,MAAwC,GACrD,mBAAmB,CA8CrB;AAED;sEACsE;AACtE,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAQvE"}
|
|
@@ -37,6 +37,7 @@ function createBpeTokenizer() {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// src/compression-rules.ts
|
|
40
|
+
var LANGUAGE_PRESERVATION_RULE = "Preserve the source conversation's primary language. Do not translate a monolingual conversation without a user request. For mixed-language source, preserve each segment's language. Keep code, commands, identifiers, and quoted text verbatim when the tier's fidelity rules retain them.";
|
|
40
41
|
var COMPRESS_PHILOSOPHY = `Compression Philosophy:
|
|
41
42
|
- All compression serves the primary task, but be frugal.
|
|
42
43
|
- Context capacity is precious. Save context by compressing consumed outputs, not by avoiding tools.
|
|
@@ -168,7 +169,23 @@ function resolvePrompts(overrides, options = {}) {
|
|
|
168
169
|
`resolvePrompts: overriding compression rules requires { acknowledgeRisk: true }. Overridden keys: ${keys.join(", ")}. These rules are quality-critical (tuned over months of production use); changing them can degrade summary quality and break retrieval (summaries may lose paths, signatures, decisions).`
|
|
169
170
|
);
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
+
const merged = { ...defaultPrompts, ...clean };
|
|
173
|
+
if (options.languagePreservation) {
|
|
174
|
+
return {
|
|
175
|
+
compressPhilosophy: `${merged.compressPhilosophy}
|
|
176
|
+
- ${LANGUAGE_PRESERVATION_RULE}`,
|
|
177
|
+
howToCompressRules: `${merged.howToCompressRules}
|
|
178
|
+
|
|
179
|
+
${LANGUAGE_PRESERVATION_RULE}`,
|
|
180
|
+
tier2DistillRules: `${merged.tier2DistillRules}
|
|
181
|
+
|
|
182
|
+
${LANGUAGE_PRESERVATION_RULE}`,
|
|
183
|
+
tier3CondenseRules: `${merged.tier3CondenseRules}
|
|
184
|
+
|
|
185
|
+
${LANGUAGE_PRESERVATION_RULE}`
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return merged;
|
|
172
189
|
}
|
|
173
190
|
|
|
174
191
|
// src/nudge-text.ts
|
|
@@ -428,6 +445,7 @@ export {
|
|
|
428
445
|
countMessageTokens,
|
|
429
446
|
estimateTokensFast,
|
|
430
447
|
createBpeTokenizer,
|
|
448
|
+
LANGUAGE_PRESERVATION_RULE,
|
|
431
449
|
COMPRESS_PHILOSOPHY,
|
|
432
450
|
HOW_TO_COMPRESS_RULES,
|
|
433
451
|
TIER2_DISTILL_RULES,
|
|
@@ -441,4 +459,4 @@ export {
|
|
|
441
459
|
VIABLE_RANGE_MIN_TOKENS,
|
|
442
460
|
viableRanges
|
|
443
461
|
};
|
|
444
|
-
//# sourceMappingURL=chunk-
|
|
462
|
+
//# sourceMappingURL=chunk-Q3P5Z2PV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tokenize.ts","../src/compression-rules.ts","../src/prompts.ts","../src/nudge-text.ts","../src/viable.ts","../src/truncate.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\n\nexport function defaultCountTokens(text: string): number {\n if (!text) return 0;\n // CJK chars tokenize ~1:1 (chars/4 badly underestimates them). Count them\n // directly, then estimate the non-CJK remainder with chars/4 so digits,\n // punctuation, and symbols in code/JSON are not dropped to zero.\n const cjk = text.match(/[\\u4e00-\\u9fff\\u3040-\\u30ff\\uac00-\\ud7af]/g);\n const cjkCount = cjk?.length ?? 0;\n return cjkCount + Math.ceil((text.length - cjkCount) / 4);\n}\n\nexport function estimateMessageTokens(text: string | undefined): number {\n return defaultCountTokens(text ?? \"\");\n}\n\n/** Guarded contribution of a host-projected thinking payload to the metered\n * message size. Non-finite or non-positive values are treated as absent (0),\n * so a bad host value can never poison the accounting. */\nexport function thinkingTokenValue(thinking: number | undefined): number {\n return typeof thinking === \"number\" &&\n Number.isFinite(thinking) &&\n thinking > 0\n ? thinking\n : 0;\n}\n\n/** Total metered size of a core message: visible text plus any host-projected\n * thinking payload (CoreMessage.thinkingTokens). Every per-message counting\n * site (range recommendations, block compressedTokens, status reports, context\n * breakdown) goes through this so all surfaces share one caliber. */\nexport function countMessageTokens(\n message: { text?: string; thinkingTokens?: number },\n countTokens: TokenCountFn = defaultCountTokens,\n): number {\n return (\n countTokens(message.text ?? \"\") + thinkingTokenValue(message.thinkingTokens)\n );\n}\n\nexport function estimateTokensFast(text: string): number {\n if (!text) return 0;\n return Math.ceil(text.length / 4);\n}\n\nexport type TokenCountFn = (text: string) => number;\n\nconst BPE_SIZE_GUARD = 100_000;\n\nexport function createBpeTokenizer(): TokenCountFn {\n try {\n const mod = require(\"@anthropic-ai/tokenizer\");\n const bpeCount = mod.countTokens ?? mod.default?.countTokens;\n if (typeof bpeCount !== \"function\") return defaultCountTokens;\n return (text: string) => {\n if (text.length > BPE_SIZE_GUARD) return defaultCountTokens(text);\n try {\n return bpeCount(text);\n } catch {\n return defaultCountTokens(text);\n }\n };\n } catch {\n return defaultCountTokens;\n }\n}\n","/**\n * Compression rule texts — VERBATIM copy from context-compress-algorithms (MIT, ours).\n * These were tuned over months of production use.\n *\n * 2026-09-06 amendment (owner-approved; billion-context-pi#309 incident): write-side\n * quote-fidelity rules merged INTO the tuned text. Verbatim user quotes now require\n * a message ref; recorded task state is labeled as history; unicode written directly.\n * Motivation: session 01a071dc blocks b60/b61 stored a fabricated\n * `user verbatim '合并了 下一个'` as a live \"CURRENT TASK\", causing loop relapses.\n *\n * 2026-09-26 amendment (#442 / billion-context#1398 sidecar readout): open-objectives\n * carry-forward rule added at every tier; \"never current directives\" clauses softened.\n * Sidecar showed a multi-block merge (b22 ⊇ b13) dropping a still-open user pivot that\n * b13 had recorded, and the trust-guardrail wording deprioritized objectives living only\n * in summaries. Quotes stay historical; open-objective STATUS is current.\n */\n\n/** Opt-in language-preservation rule (#493): summaries must be written in the\n * source conversation's primary language. NOT part of the canonical constants —\n * hosts opt in via `resolvePrompts(…, { languagePreservation: true })` so the\n * default prompt surface stays byte-identical (zero token cost, no prefix-cache\n * shift on kernel bumps). Single source of truth for every delivery point\n * (philosophy/T1/T2/T3 via resolvePrompts; lean pack via leanHowToCompress). */\nexport const LANGUAGE_PRESERVATION_RULE =\n \"Preserve the source conversation's primary language. Do not translate a monolingual conversation without a user request. For mixed-language source, preserve each segment's language. Keep code, commands, identifiers, and quoted text verbatim when the tier's fidelity rules retain them.\";\n\nexport const COMPRESS_PHILOSOPHY = `Compression Philosophy:\n- All compression serves the primary task, but be frugal.\n- Context capacity is precious. Save context by compressing consumed outputs, not by avoiding tools.\n- Compress by need, not by percentage.\n- Work from summaries, not raw tool outputs. All listed ranges (user prompts, tool outputs, code, logs, exploration, intermediate steps) should be compressed to summary format — the ONLY exceptions are protected content, content the current step is actively using, or critical content you cannot reconstruct.`;\n\nexport const HOW_TO_COMPRESS_RULES = `HOW TO COMPRESS\n\nWhen you call \\`compress\\`, the summary you write becomes the only record of the replaced conversation. Make it self-contained and complete: every user request, experiment purpose, and work task in the range must be accurately captured. A later reader (or you, after decompressing) should be able to continue the task WITHOUT needing the original. The summary records the PAST as of this block's creation: label recorded task state as history (\"TASK AS OF THIS BLOCK: ...\") — never as a live instruction, so a later reader treats it as settled context, not something to re-execute. Write plain text with real unicode characters; never copy \\\\uXXXX escape sequences or JSON-escaped fragments out of tool output.\n\nKEEP VERBATIM — never paraphrase or abbreviate these:\n- Full file paths with line numbers, directory prefix on every mention (\\`lib/hooks.ts:347\\`, \\`src/index.ts:12-18\\`, \\`gatenet_v3/model.py:45\\`). Never abbreviate to a bare filename (\\`hooks.ts\\`, \\`model.py\\`) — they are ambiguous and cannot be grepped or decompressed-to later.\n- Function, class, and type signatures (exact names, params, return types) AND critical code lines that encode logic — the line that IS the finding, not just the function name (e.g. \\`kv_keys += define_gate * a_key[i](emb)\\` is more useful than \"see model_kvnet.py\").\n- Error messages and stack traces (exact text — you need the literal string to grep for it later).\n- Key details from reports and analyses — not just the conclusion. Keep the comparison numbers and the mechanism, not \"X is worse\" alone (write \"1.76× PPL gap because KV store is static\", not \"KVNet underperforms\").\n- Decisions and their rationale (\"chose X over Y because Z\" — the \"because\" is load-bearing; without it the decision looks arbitrary).\n- Constraints discovered (\"must support Node 22\", \"no new dependencies\", \"AGENTS.md forbids \\`as any\\`\").\n- Exact values: versions, config keys, thresholds, magic numbers.\n- User intent — quote short user messages verbatim ONLY WITH their message ref, e.g. \\`User said (m00132): \"ship it tonight\"\\`. Without a verifiable ref, paraphrase (\\`user previously asked (paraphrased): ...\\`) — this is the one exception to the verbatim rule above; never present a reconstructed or half-remembered phrase as a verbatim quote. When the message is too long to quote, preserve intent with extra care: do not change scope, constraints, priorities, acceptance criteria, or requested outcomes. Quotes are historical records, not live instructions — but open-objective STATUS is current (still-open vs completed/superseded) and must be tracked. Losing these changes the task itself.\n- Open objectives carry-forward — if the range (or, when distilling, any source block's summary) contains a user-requested objective that is neither completed nor superseded by the end of the range, the summary MUST keep a one-line \\`Open objectives:\\` entry naming each still-open objective with its message ref (\\`Open objectives: refactor runner into eight arms (m00746)\\`). Distillation re-carries open objectives verbatim from source blocks — they are the last thing to drop and the first thing to restore, at every tier.\n- The user's overall goal and any changes to it — the big-picture objective plus how it evolved during the compressed range. Each summary must reflect the goal as it stood at the end of the range, including pivots (e.g., \"initially: fix bug X → pivoted to: refactor module Y after discovering root cause\"). Losing the goal or its evolution makes all subsequent work appear unmotivated.\n- Purpose behind each significant action — preserve not just what was done but why: the hypothesis behind each experiment, the question behind each exploration, the task goal behind each work action. Without purpose, the summary reads as disconnected technical steps with no through-line.\n- Open questions and unresolved TODOs — losing these changes what work appears to remain.\n- Message refs of key anchors (\\`m00420\\`, \\`m00510–m00520\\`) — they let you or a later reader jump back via decompress to the exact original.\n\nDROP — extract the signal, discard the vessel:\n- Verbose logs (build/test/\\`npm\\` output) once you have captured the error line or the result.\n- Duplicate file reads once the needed content is recorded.\n- Consumed exploration — search hits, agent return values, successful tool outputs — once you have extracted the facts you need (same rule as dead-ends, but nothing went wrong; the content is simply spent).\n- Dead-end exploration — but PRESERVE the lesson in one line: \"tried X, failed because Y\".\n- Back-and-forth discussion and self-corrections once the final position is captured (keep the outcome, drop the journey to it).\n- Repeated status checks (\\`git status\\`, \\`ls\\`) once state is known.\n\nFor each significant item you DROP (scripts, reports, large analyses, long tool outputs), add a one-line CONTENT description of what it covers — not where it lives. Bad: \"probe script at /path/probe_kvnet.py\". Good: \"probe_kvnet.py: tests n-gram baseline, generation quality, long-range dependency, position sensitivity, op pipeline, QUERY attention.\" This lets a later decompress target the right block by relevance, not by guessing locations.\n\nPRIORITY — when the summary must be compact, preserve in this order:\n1. User's overall goal, goal evolution, intent, and hard constraints (losing these changes the task).\n2. Decisions and rationale.\n3. Exact technical artifacts: paths, signatures, errors, values.\n4. Conclusions and key findings.\n5. Lessons learned: what failed and why.\n\nWrite dense, scannable bullets — not narrative prose. If the range spans distinct concerns (request → findings → decision), group bullets under short thematic headers so a reader can scan to the part they need. Every line must earn its place. Do not mimic the style of existing summaries in context; follow these rules.`;\n\nexport const TIER2_DISTILL_RULES = `TIER 2 COMPRESSION — DISTILLATION\n\nYou are compressing historical summaries (not raw conversation). These summaries have already captured the details. Your job is to DISTILL them: extract only what matters for future work, discard the process.\n\nKEEP — these are the only things that survive distillation:\n- Decisions and their rationale (\"chose X over Y because Z\" — the \"because\" is load-bearing).\n- Final outcomes: version numbers shipped, PR numbers merged/closed, bugs fixed or deferred.\n- Key lessons: what failed and why (\"tried X, failed because Y\"). These prevent repeating mistakes.\n- Critical constraints discovered (\"must support Node 22\", \"AGENTS.md forbids as any\").\n- Design decisions with architectural impact (\"chose compress-as-anchor over synthetic messages because prefix cache\").\n- User quotes and task state only as attributed history: keep the source ref with any user quote; never carry an UNVERIFIED tier-1 \"CURRENT TASK\" claim forward as a live directive — relabel it \"TASK AS OF THIS BLOCK\". A ref-backed objective that no later source marks completed or superseded is not unverified: it carries in the \\`Open objectives:\\` entry (next bullet), not as a directive.\n- Open objectives — if ANY source block's summary names a user-requested objective that no later source block marks completed or superseded, the distilled summary MUST keep a one-line \\`Open objectives:\\` entry re-carrying each still-open objective verbatim with its original ref. They are the last thing to drop and the first thing to restore.\n- Whether content is OBSOLETE or SUPERSEDED — mark with one line: \"[SUPERSEDED by PR #NNN]\" or \"[OBSOLETE: deleted in vX.Y.Z]\". Do NOT keep the obsolete content's details — just the marker and reason.\n- Function/class/type names and module paths that are the SUBJECT of the work — e.g., \"fixed filterCompressedRanges in prune.ts\", \"added SessionStateRegistry in state.ts\". Not exact line numbers or full signatures — just enough to LOCATE the code without searching.\n- Exploration findings: if a block was exploratory with no decision, keep the CONCLUSION in one line (\"explored X, not viable because Y\"). Do not keep the exploration process.\n\nDROP — these were useful during the work but are no longer needed:\n- Exact line numbers, diffs, verbose function signatures, full code listings.\n- Build/deploy process details, test execution steps.\n- Review process details (who reviewed, what rounds, test counts).\n- Verbose logs, command output, intermediate debugging steps.\n\nFORMAT:\n- Start each distilled block with a source header line:\n \\`Source: bN+bM+... (XK→YK tok, Zx). [original topic]\\`\n Example: \\`Source: b5+b7 (56K+44K→268 tok, 375x). [Tool-result recap + publish]\\`\n- 3-5 bullet points per source block, each a self-contained fact.\n- Dense, scannable — no narrative prose.\n- Start with the outcome, not the process: \"v1.13.0 shipped (7 PRs bundled)\" not \"implemented 7 PRs then reviewed then merged\".\n- Cross-block synthesis: if multiple source blocks cover the same topic (same PR, same feature, same bug), MERGE them into a single group of bullets. Do not repeat the same fact from different blocks — keep it once under the most relevant source header.\n\nSIZE TARGET: 50-150 tokens per source block (excluding the header). If you can't fit it in 150 tokens, you're keeping too much process. If a block has nothing worth keeping (pure noise), output just the header followed by \"[no actionable content].\"`;\n\nexport const TIER3_CONDENSE_RULES = `TIER 3 COMPRESSION — ULTRA-CONDENSATION\n\nYou are compressing distilled summaries (Tier 2) into ultra-condensed facts (Tier 3). The distilled summaries already contain only decisions and outcomes. Your job is to reduce them to bare factual references.\n\nPRIORITY — when a source block has more facts than the size target allows, keep in this order:\n1. Shipped outcomes (versions released, PRs merged) — these are permanent record.\n2. Open work — PRs/issues still pending AND still-open user-requested objectives (re-carry any source block's \\`Open objectives:\\` entries verbatim); these may need follow-up.\n3. Key decisions with architectural impact (\"chose X over Y because Z\").\n4. Critical constraints (\"must support Node 22\").\nDrop everything else. Tier 3 is a lookup index, not a knowledge base.\n\nFORMAT:\n- Start with a source header line:\n \\`Source: bN+bM+... (XK→YK tok, Zx). [original topic]\\`\n- Output 1-3 facts per source block. Each fact is a single line: subject + outcome.\n- No explanations, no rationale, no process — just the fact.\n- Format: \"[PR/Issue/Version] — [outcome in ≤8 words]\"\n- Merge related facts from different source blocks if they concern the same topic.\n\nEXAMPLES:\n- \"v1.13.0 shipped — quality gate + GC fix (7 PRs)\"\n- \"PR #196 merged — preserve-first-user (supersedes #169)\"\n- \"Bug 1214 fixed — compress consumed all user messages\"\n- \"Objective (m00746) — eight-arm runner refactor, still open\"\n- \"Chose compress-as-anchor — prefix cache benefit over synthetic injection\"\n- \"Constraint: AGENTS.md forbids as any — never suppress types\"\n\nDROP:\n- Multi-sentence context. If a fact needs >1 sentence, it's too detailed for Tier 3.\n- Lessons learned (\"tried X, failed because Y\") — drop UNLESS the failure is likely to recur and the block is <30 days old.\n- Design rationale details — keep the decision, drop the \"because\" unless it's a critical constraint.\n- Anything marked [OBSOLETE] or [SUPERSEDED] — drop entirely, note \"[N blocks obsolete]\" in the summary.\n\nSIZE TARGET: 30-60 tokens per source block (including header). For a batch of N source blocks, total output ≈ N × 40 tokens. If a source block has only one trivial fact, output just the header + one line.`;\n","import {\n COMPRESS_PHILOSOPHY,\n HOW_TO_COMPRESS_RULES,\n LANGUAGE_PRESERVATION_RULE,\n TIER2_DISTILL_RULES,\n TIER3_CONDENSE_RULES,\n} from \"./compression-rules.js\";\n\n/**\n * Overridable prompt text consumed by the kernel's nudge renderer and, via the\n * adapter, the system prompt. Every field here is LOAD-BEARING: these rules\n * were tuned over months of production use and are quality-critical. Overriding\n * them can degrade summary quality (loss of paths / signatures / decisions →\n * broken retrieval), so {@link resolvePrompts} requires `{ acknowledgeRisk: true }`.\n *\n * Surface-level text (summary section headers, status-report chrome, tool\n * descriptions) is intentionally NOT part of this interface — it is owned by\n * the adapter or a later \"prompt-set format\" layer and is safe to customize\n * freely. See DESIGN.md for the load-bearing vs surface classification.\n */\nexport interface Prompts {\n /** Core compression philosophy. Embedded in the system prompt + every nudge. */\n compressPhilosophy: string;\n /** Rules the model follows when writing a tier-1 summary. */\n howToCompressRules: string;\n /** Rules for tier-2 distillation of existing summaries. */\n tier2DistillRules: string;\n /** Rules for tier-3 ultra-condensation of distilled summaries. */\n tier3CondenseRules: string;\n}\n\n/**\n * The kernel's canonical prompt values (verbatim from compression-rules.ts).\n * Frozen so a buggy caller cannot mutate the shared singleton and corrupt\n * every other consumer of {@link defaultPrompts}.\n */\nexport const defaultPrompts: Prompts = Object.freeze({\n compressPhilosophy: COMPRESS_PHILOSOPHY,\n howToCompressRules: HOW_TO_COMPRESS_RULES,\n tier2DistillRules: TIER2_DISTILL_RULES,\n tier3CondenseRules: TIER3_CONDENSE_RULES,\n}) as Prompts;\n\nexport interface ResolvePromptsOptions {\n /**\n * Must be `true` to override any prompt field. Every {@link Prompts} field is\n * load-bearing; overriding without acknowledging the quality risk is a\n * programming error and throws.\n */\n acknowledgeRisk?: boolean;\n /** Opt in to the language-preservation rule (#493): appends\n * {@link LANGUAGE_PRESERVATION_RULE} to all four canonical rule texts.\n * Additive only — it cannot remove or replace load-bearing wording, so it\n * does NOT require `acknowledgeRisk`. Default off: the resolved prompts are\n * byte-identical to {@link defaultPrompts}. */\n languagePreservation?: boolean;\n}\n\n/**\n * Merge prompt overrides onto the kernel defaults. All fields are load-bearing,\n * so ANY override requires `{ acknowledgeRisk: true }`.\n *\n * Only `string`-valued overrides take effect: an explicit `undefined`/`null` or\n * a wrong type is silently dropped (never clobbers a good default), so a\n * malformed partial never degrades the canonical rules. Resolve once at host\n * startup, then pass the resulting {@link Prompts} to {@link renderNudgeText}\n * and to the adapter's system-prompt composition so both layers stay consistent.\n */\nexport function resolvePrompts(\n overrides?: Partial<Prompts>,\n options: ResolvePromptsOptions = {},\n): Prompts {\n const clean: Partial<Prompts> = {};\n if (overrides) {\n for (const [key, value] of Object.entries(overrides)) {\n if (typeof value === \"string\") {\n (clean as Record<string, unknown>)[key] = value;\n }\n }\n }\n const keys = Object.keys(clean) as (keyof Prompts)[];\n if (keys.length > 0 && !options.acknowledgeRisk) {\n throw new Error(\n `resolvePrompts: overriding compression rules requires { acknowledgeRisk: true }. ` +\n `Overridden keys: ${keys.join(\", \")}. These rules are quality-critical (tuned over months of production use); ` +\n `changing them can degrade summary quality and break retrieval (summaries may lose paths, signatures, decisions).`,\n );\n }\n const merged: Prompts = { ...defaultPrompts, ...clean };\n if (options.languagePreservation) {\n return {\n compressPhilosophy: `${merged.compressPhilosophy}\\n- ${LANGUAGE_PRESERVATION_RULE}`,\n howToCompressRules: `${merged.howToCompressRules}\\n\\n${LANGUAGE_PRESERVATION_RULE}`,\n tier2DistillRules: `${merged.tier2DistillRules}\\n\\n${LANGUAGE_PRESERVATION_RULE}`,\n tier3CondenseRules: `${merged.tier3CondenseRules}\\n\\n${LANGUAGE_PRESERVATION_RULE}`,\n };\n }\n return merged;\n}\n","import type {\n NudgeDecision,\n CompressibleRange,\n ProtectedRange,\n ContextBreakdown,\n CompressionBlock,\n BlockSpan,\n} from \"./types.js\";\nimport { defaultPrompts } from \"./prompts.js\";\nimport type { Prompts } from \"./prompts.js\";\n\nexport type NudgeVoice = \"gentle\" | \"emergency\";\n\nexport interface NudgePromptSections {\n efficiencyNote?: string | null;\n emergencyHeader?: string | null;\n t2Guidance?: string | null;\n t3Guidance?: string | null;\n}\n\nexport interface RenderedNudge {\n voice: NudgeVoice;\n text: string;\n}\n\nfunction efficiencyNote(\n prompts: Prompts,\n sections: NudgePromptSections,\n): string | null {\n if (sections.efficiencyNote !== undefined) return sections.efficiencyNote;\n return `This is an efficiency nudge to compress early and keep context lean — not an overflow warning. A separate, stronger alert will appear if the context is actually full.\\n\\n${prompts.compressPhilosophy}`;\n}\n\nfunction emergencyHeader(\n prompts: Prompts,\n sections: NudgePromptSections,\n): string | null {\n if (sections.emergencyHeader !== undefined) return sections.emergencyHeader;\n return `⚠️ Context limit reached — compress now. Prioritize consumed tool outputs.\\n\\n${prompts.compressPhilosophy}`;\n}\n\nfunction formatK(n: number): string {\n if (n >= 1000) return `${(n / 1000).toFixed(1)}K`;\n return `${n}`;\n}\n\nfunction formatBreakdown(bd?: ContextBreakdown): string {\n if (!bd) return \"\";\n const parts: string[] = [];\n if (bd.system > 0) parts.push(`${formatK(bd.system)} system`);\n if (bd.tool > 0) parts.push(`${formatK(bd.tool)} tool`);\n if (bd.summaries > 0) parts.push(`${formatK(bd.summaries)} summaries`);\n if (bd.code > 0) parts.push(`${formatK(bd.code)} code`);\n if (bd.text > 0) parts.push(`${formatK(bd.text)} text`);\n const growth =\n bd.growth > 0 ? `\\n+${formatK(bd.growth)} since last nudge` : \"\";\n return `Context breakdown: ${parts.join(\" | \")}${growth}`;\n}\n\nfunction formatTierTargetBlocks(blocks: CompressionBlock[]): string {\n if (blocks.length === 0) {\n return \"Target blocks: (none — no tier blocks found)\";\n }\n const lines = blocks.map((b) => {\n const summaryTokens = Math.ceil((b.summary ?? \"\").length / 4);\n const topic = b.topic ? ` \"${b.topic}\"` : \"\";\n return ` ${b.blockId} ${b.effectiveMessageIds.length} msgs ${formatK(b.compressedTokens)}→${formatK(summaryTokens)}${topic}`;\n });\n return `Target ${blocks[0]!.tier === 1 ? \"tier-1\" : \"tier-2\"} blocks to distill (${blocks.length}):\\n${lines.join(\"\\n\")}`;\n}\n\nconst BLOCK_MAP_MAX_SHOWN = 8;\n\nfunction formatBlockMap(spans: BlockSpan[]): string {\n if (spans.length === 0) return \"\";\n const hidden = Math.max(0, spans.length - BLOCK_MAP_MAX_SHOWN);\n const shown = hidden > 0 ? spans.slice(-BLOCK_MAP_MAX_SHOWN) : spans;\n const items = shown.map(\n (s) =>\n `${s.blockId}=${s.startRef}–${s.endRef}${s.tier > 1 ? ` t${s.tier}` : \"\"}`,\n );\n const prefix = hidden > 0 ? `…+${hidden} older · ` : \"\";\n return `Active blocks (${spans.length}): ${prefix}${items.join(\" · \")}`;\n}\n\nexport function formatRanges(\n compressible: CompressibleRange[],\n protectedRanges: ProtectedRange[],\n): string {\n if (compressible.length === 0 && protectedRanges.length === 0) {\n return \"[No specific ranges detected — compress any consumed content.]\";\n }\n\n // Merge compressible + protected into a single oldest-first list, mirroring\n // opencode-acp's formatCompressibleRanges. Splitting them into two sections\n // lost the time order and hid overlaps; a range can be partly compressible\n // and partly protected, which only the merged view shows correctly.\n interface Merged {\n startRef: string;\n endRef: string;\n startNum: number;\n endNum: number;\n startPos: number;\n endPos: number;\n count: number;\n tokens: number;\n userMsgs: number;\n compressibleTokens: number;\n compressibleCount: number;\n protectedTokens: number;\n protectedCount: number;\n protectedTools: string[];\n toolPct: number;\n textPct: number;\n dangerous: boolean;\n }\n const refNum = (ref: string): number => {\n const m = ref.match(/\\d+/);\n return m ? parseInt(m[0], 10) : 0;\n };\n const entries: Merged[] = [];\n for (const r of compressible) {\n entries.push({\n startRef: r.startRef,\n endRef: r.endRef,\n startNum: refNum(r.startRef),\n endNum: refNum(r.endRef),\n startPos: r.startIndex ?? refNum(r.startRef),\n endPos: r.endIndex ?? refNum(r.endRef),\n count: r.count,\n tokens: r.tokens,\n userMsgs: r.userMsgs ?? 0,\n toolPct: r.toolPct,\n textPct: r.textPct,\n compressibleTokens: r.tokens,\n compressibleCount: r.count,\n protectedTokens: 0,\n protectedCount: 0,\n protectedTools: [],\n dangerous: r.dangerous ?? false,\n });\n }\n for (const r of protectedRanges) {\n entries.push({\n startRef: r.startRef,\n endRef: r.endRef,\n startNum: refNum(r.startRef),\n endNum: refNum(r.endRef),\n startPos: r.startIndex ?? refNum(r.startRef),\n endPos: r.endIndex ?? refNum(r.endRef),\n count: r.count,\n tokens: r.tokens,\n userMsgs: 0,\n toolPct: 0,\n textPct: 0,\n compressibleTokens: 0,\n compressibleCount: 0,\n protectedTokens: r.tokens,\n protectedCount: r.count,\n protectedTools: [...r.tools],\n dangerous: false,\n });\n }\n // Order/merge by POSITION, never ref number: refs can be non-monotonic vs array\n // order (subagent interleaving / mid-array summary nodes), and ref-number merging\n // then yields endpoints resolveBoundaries collapses to a tiny slice (#887).\n entries.sort((a, b) => a.startPos - b.startPos || a.startNum - b.startNum);\n // Merge positionally adjacent/overlapping ranges (gap ≤ 1 slot).\n const merged: Merged[] = [];\n for (const e of entries) {\n const last = merged[merged.length - 1];\n if (last && e.startPos <= last.endPos + 1) {\n last.endRef = e.endRef;\n last.endNum = Math.max(last.endNum, e.endNum);\n last.endPos = Math.max(last.endPos, e.endPos);\n last.count += e.count;\n last.tokens += e.tokens;\n last.userMsgs += e.userMsgs;\n last.compressibleTokens += e.compressibleTokens;\n last.compressibleCount += e.compressibleCount;\n last.protectedTokens += e.protectedTokens;\n last.protectedCount += e.protectedCount;\n if (e.dangerous) last.dangerous = true;\n for (const t of e.protectedTools) {\n if (!last.protectedTools.includes(t)) last.protectedTools.push(t);\n }\n } else {\n merged.push({ ...e });\n }\n }\n const userNote = (n: number): string =>\n n > 0 ? ` · ${n} user msg${n > 1 ? \"s\" : \"\"}` : \"\";\n const lines = merged.map((e) => {\n const suffix =\n e.dangerous && e.compressibleTokens > 0\n ? \" ⚠️ NOT recommended unless you are certain.\"\n : \"\";\n if (e.protectedTokens > 0 && e.compressibleTokens === 0) {\n return ` ${e.startRef}–${e.endRef} ${e.count} msgs ${formatK(e.tokens)} [PROTECTED: ${e.protectedTools.join(\", \")} — not compressible]${suffix}`;\n }\n if (e.protectedTokens > 0 && e.compressibleTokens > 0) {\n return ` ${e.startRef}–${e.endRef} ${e.count} msgs ${formatK(e.tokens)} [${formatK(e.compressibleTokens)} compressible | ${formatK(e.protectedTokens)} protected: ${e.protectedTools.join(\", \")}]${userNote(e.userMsgs)}${suffix}`;\n }\n return ` ${e.startRef}–${e.endRef} ${e.count} msgs ${formatK(e.tokens)} [tool ${e.toolPct}% | text ${e.textPct}%]${userNote(e.userMsgs)}${suffix}`;\n });\n return `Compressible ranges (${merged.length}, oldest first):\\n${lines.join(\"\\n\")}`;\n}\n\nconst DEFAULT_T2_GUIDANCE = `Your tier-1 compression summaries have accumulated. Distill them into a single denser tier-2 summary. Use block IDs as boundaries (startId and endId as bN). Any raw (uncompressed) messages sitting between the boundary blocks are absorbed into the tier-2 block as well — apply HOW TO COMPRESS to those raw messages and the TIER 2 distillation rules to the existing summaries, so the whole span is covered and nothing is lost.`;\n\nconst DEFAULT_T3_GUIDANCE = `Your tier-2 compression summaries have accumulated. Condense them further into a tier-3 ultra-condensed summary. Use block IDs as boundaries (startId and endId as bN). Any raw (uncompressed) messages sitting between the boundary blocks are absorbed into the tier-3 block as well — apply HOW TO COMPRESS to those raw messages and the TIER 3 condensation rules to the existing summaries, so the whole span is covered and nothing is lost.`;\n\nfunction tierGuidance(\n tier: 2 | 3,\n sections: NudgePromptSections,\n): string | null {\n const value = tier === 2 ? sections.t2Guidance : sections.t3Guidance;\n if (value !== undefined) return value;\n return tier === 2 ? DEFAULT_T2_GUIDANCE : DEFAULT_T3_GUIDANCE;\n}\n\nfunction compact(parts: string[]): string[] {\n while (parts.length > 0 && parts[0] === \"\") parts.shift();\n return parts;\n}\n\nexport function renderNudgeText(\n decision: NudgeDecision,\n prompts: Prompts = defaultPrompts,\n sections: NudgePromptSections = {},\n): RenderedNudge {\n const breakdownStr = formatBreakdown(decision.contextBreakdown);\n const rangesStr = formatRanges(\n decision.compressibleRanges,\n decision.protectedRanges ?? [],\n );\n const blockMapStr = formatBlockMap(decision.activeBlockSpans ?? []);\n const isEmergency =\n !!decision.breakdown?.emergencyOverride || !!decision.breakdown?.overLimit;\n\n if (decision.tier !== null && decision.tier >= 2) {\n const isT2 = decision.tier === 2;\n const targets = decision.tierTargetBlocks ?? [];\n const blockList = formatTierTargetBlocks(targets);\n const startId = targets[0]?.blockId ?? \"b1\";\n const endId = targets[targets.length - 1]?.blockId ?? \"b5\";\n const voice: NudgeVoice = isEmergency ? \"emergency\" : \"gentle\";\n const triggerLine = isEmergency\n ? `[EMERGENCY — TIER ${decision.tier} ${isT2 ? \"DISTILLATION\" : \"CONDENSATION\"}] Context limit reached — distill NOW into a denser summary to reclaim tokens.`\n : `[TIER ${decision.tier} ${isT2 ? \"DISTILLATION\" : \"CONDENSATION\"} TRIGGER]`;\n const guidance = tierGuidance(isT2 ? 2 : 3, sections);\n const head = efficiencyNote(prompts, sections);\n return {\n voice,\n text: compact([\n ...(head === null ? [] : [head]),\n \"\",\n breakdownStr,\n \"\",\n triggerLine,\n ...(guidance === null ? [] : [guidance]),\n blockList,\n `Example: compress({ content: [{ startId: \"${startId}\", endId: \"${endId}\", summary: \"...\" }] })`,\n \"\",\n prompts.howToCompressRules,\n \"\",\n isT2 ? prompts.tier2DistillRules : prompts.tier3CondenseRules,\n ]).join(\"\\n\"),\n };\n }\n\n if (isEmergency) {\n const head = emergencyHeader(prompts, sections);\n return {\n voice: \"emergency\",\n text: compact([\n ...(head === null ? [] : [head]),\n \"\",\n breakdownStr,\n \"\",\n prompts.howToCompressRules,\n \"\",\n `{ \"topic\": \"...\", \"content\": [{ \"startId\": \"<ID>\", \"endId\": \"<ID>\", \"summary\": \"...\" }] }`,\n \"Only use IDs from visible messages above. Compress older work first.\",\n \"\",\n rangesStr,\n ...(blockMapStr ? [\"\", blockMapStr] : []),\n ]).join(\"\\n\"),\n };\n }\n\n const gentleHead = efficiencyNote(prompts, sections);\n return {\n voice: \"gentle\",\n text: compact([\n ...(gentleHead === null ? [] : [gentleHead]),\n \"\",\n breakdownStr,\n \"\",\n prompts.howToCompressRules,\n \"\",\n rangesStr,\n ...(blockMapStr ? [\"\", blockMapStr] : []),\n \"\",\n `💡 If you compress, fold the ranges you keep in ONE call — pass multiple content entries (\\`content: [{...}, {...}]\\`) or ONE plain string holding every range, each block starting with its 'mNNNNN–mNNNNN topic' header line (most robust through lossy gateways). Ranges the task still needs can wait — they reappear in later nudges.`,\n ]).join(\"\\n\"),\n };\n}\n","/** Minimum size for a compressible range to be worth recommending. Ranges\n * below this are fragmented leftovers (a 16-token ack, a one-line tool\n * result): the model cannot write a meaningful >=50-char summary for them,\n * and a batched compress call that includes one gets atomically rejected\n * (the kernel validates the whole batch). Observed in the wild: a 14-range\n * recommendation list containing a 16-token range → every batch attempt\n * failed with \"Summary too short\". Apply on every surface that recommends\n * ranges: the injected nudge, acp_status, and the /acp panel. */\nexport const VIABLE_RANGE_MIN_TOKENS = 200;\n\nexport function viableRanges<T extends { tokens: number }>(ranges: T[]): T[] {\n return ranges.filter((r) => r.tokens >= VIABLE_RANGE_MIN_TOKENS);\n}\n","// UTF-16-safe truncation. A plain slice can land between the two code units\n// of an astral character (emoji, CJK ext-B+), stranding a lone surrogate:\n// JSON.stringify escapes it (\\ud83e), and gateways that re-encode request\n// bodies to strict UTF-8 then throw UnicodeEncodeError on every retry\n// (ranxianglei/billion-context#816) — a deterministic poison that never heals.\n\nfunction isHighSurrogate(c: number): boolean {\n return c >= 0xd800 && c <= 0xdbff;\n}\n\nfunction isLowSurrogate(c: number): boolean {\n return c >= 0xdc00 && c <= 0xdfff;\n}\n\n/** At most maxUnits code units; never ends on a stranded high surrogate. */\nexport function clampPrefix(text: string, maxUnits: number): string {\n const cut = Math.min(maxUnits, text.length);\n if (cut > 0 && isHighSurrogate(text.charCodeAt(cut - 1)))\n return text.slice(0, cut - 1);\n return text.slice(0, cut);\n}\n\n/** A [start, end) window with both edges snapped off surrogate pairs. */\nexport function clampWindow(text: string, start: number, end: number): string {\n let s = Math.max(0, Math.min(start, text.length));\n let e = Math.min(text.length, Math.max(s, end));\n if (s > 0 && isLowSurrogate(text.charCodeAt(s))) s += 1;\n if (e > s && isHighSurrogate(text.charCodeAt(e - 1))) e -= 1;\n return text.slice(s, Math.max(s, e));\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAE9B,IAAMA,WAAU,cAAc,YAAY,GAAG;AAEtC,SAAS,mBAAmB,MAAsB;AACvD,MAAI,CAAC,KAAM,QAAO;AAIlB,QAAM,MAAM,KAAK,MAAM,4CAA4C;AACnE,QAAM,WAAW,KAAK,UAAU;AAChC,SAAO,WAAW,KAAK,MAAM,KAAK,SAAS,YAAY,CAAC;AAC1D;AASO,SAAS,mBAAmB,UAAsC;AACvE,SAAO,OAAO,aAAa,YACzB,OAAO,SAAS,QAAQ,KACxB,WAAW,IACT,WACA;AACN;AAMO,SAAS,mBACd,SACA,cAA4B,oBACpB;AACR,SACE,YAAY,QAAQ,QAAQ,EAAE,IAAI,mBAAmB,QAAQ,cAAc;AAE/E;AAEO,SAAS,mBAAmB,MAAsB;AACvD,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,KAAK,KAAK,KAAK,SAAS,CAAC;AAClC;AAIA,IAAM,iBAAiB;AAEhB,SAAS,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AAC;AAC9B,SAAO,KAAK,MAAM,GAAG,GAAG;AAC1B;AAGO,SAAS,YAAY,MAAc,OAAe,KAAqB;AAC5E,MAAI,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,KAAK,MAAM,CAAC;AAChD,MAAI,IAAI,KAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,GAAG,CAAC;AAC9C,MAAI,IAAI,KAAK,eAAe,KAAK,WAAW,CAAC,CAAC,EAAG,MAAK;AACtD,MAAI,IAAI,KAAK,gBAAgB,KAAK,WAAW,IAAI,CAAC,CAAC,EAAG,MAAK;AAC3D,SAAO,KAAK,MAAM,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AACrC;","names":["require","require"]}
|
package/dist/compress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAgBhF,OAAO,KAAK,EAAE,mBAAmB,EAAa,MAAM,UAAU,CAAC;AAE/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgBvD,OAAO,EAGL,KAAK,YAAY,EAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAEhB,MAAM,EAEN,WAAW,EAGX,iBAAiB,EAEjB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACxD;mEAC+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,mBAA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xB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;8DAC0D;IAC1D,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AAqND,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CAme7D;AAyrCD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* b13 had recorded, and the trust-guardrail wording deprioritized objectives living only
|
|
15
15
|
* in summaries. Quotes stay historical; open-objective STATUS is current.
|
|
16
16
|
*/
|
|
17
|
+
/** Opt-in language-preservation rule (#493): summaries must be written in the
|
|
18
|
+
* source conversation's primary language. NOT part of the canonical constants —
|
|
19
|
+
* hosts opt in via `resolvePrompts(…, { languagePreservation: true })` so the
|
|
20
|
+
* default prompt surface stays byte-identical (zero token cost, no prefix-cache
|
|
21
|
+
* shift on kernel bumps). Single source of truth for every delivery point
|
|
22
|
+
* (philosophy/T1/T2/T3 via resolvePrompts; lean pack via leanHowToCompress). */
|
|
23
|
+
export declare const LANGUAGE_PRESERVATION_RULE = "Preserve the source conversation's primary language. Do not translate a monolingual conversation without a user request. For mixed-language source, preserve each segment's language. Keep code, commands, identifiers, and quoted text verbatim when the tier's fidelity rules retain them.";
|
|
17
24
|
export declare const COMPRESS_PHILOSOPHY = "Compression Philosophy:\n- All compression serves the primary task, but be frugal.\n- Context capacity is precious. Save context by compressing consumed outputs, not by avoiding tools.\n- Compress by need, not by percentage.\n- Work from summaries, not raw tool outputs. All listed ranges (user prompts, tool outputs, code, logs, exploration, intermediate steps) should be compressed to summary format \u2014 the ONLY exceptions are protected content, content the current step is actively using, or critical content you cannot reconstruct.";
|
|
18
25
|
export declare const HOW_TO_COMPRESS_RULES = "HOW TO COMPRESS\n\nWhen you call `compress`, the summary you write becomes the only record of the replaced conversation. Make it self-contained and complete: every user request, experiment purpose, and work task in the range must be accurately captured. A later reader (or you, after decompressing) should be able to continue the task WITHOUT needing the original. The summary records the PAST as of this block's creation: label recorded task state as history (\"TASK AS OF THIS BLOCK: ...\") \u2014 never as a live instruction, so a later reader treats it as settled context, not something to re-execute. Write plain text with real unicode characters; never copy \\uXXXX escape sequences or JSON-escaped fragments out of tool output.\n\nKEEP VERBATIM \u2014 never paraphrase or abbreviate these:\n- Full file paths with line numbers, directory prefix on every mention (`lib/hooks.ts:347`, `src/index.ts:12-18`, `gatenet_v3/model.py:45`). Never abbreviate to a bare filename (`hooks.ts`, `model.py`) \u2014 they are ambiguous and cannot be grepped or decompressed-to later.\n- Function, class, and type signatures (exact names, params, return types) AND critical code lines that encode logic \u2014 the line that IS the finding, not just the function name (e.g. `kv_keys += define_gate * a_key[i](emb)` is more useful than \"see model_kvnet.py\").\n- Error messages and stack traces (exact text \u2014 you need the literal string to grep for it later).\n- Key details from reports and analyses \u2014 not just the conclusion. Keep the comparison numbers and the mechanism, not \"X is worse\" alone (write \"1.76\u00D7 PPL gap because KV store is static\", not \"KVNet underperforms\").\n- Decisions and their rationale (\"chose X over Y because Z\" \u2014 the \"because\" is load-bearing; without it the decision looks arbitrary).\n- Constraints discovered (\"must support Node 22\", \"no new dependencies\", \"AGENTS.md forbids `as any`\").\n- Exact values: versions, config keys, thresholds, magic numbers.\n- User intent \u2014 quote short user messages verbatim ONLY WITH their message ref, e.g. `User said (m00132): \"ship it tonight\"`. Without a verifiable ref, paraphrase (`user previously asked (paraphrased): ...`) \u2014 this is the one exception to the verbatim rule above; never present a reconstructed or half-remembered phrase as a verbatim quote. When the message is too long to quote, preserve intent with extra care: do not change scope, constraints, priorities, acceptance criteria, or requested outcomes. Quotes are historical records, not live instructions \u2014 but open-objective STATUS is current (still-open vs completed/superseded) and must be tracked. Losing these changes the task itself.\n- Open objectives carry-forward \u2014 if the range (or, when distilling, any source block's summary) contains a user-requested objective that is neither completed nor superseded by the end of the range, the summary MUST keep a one-line `Open objectives:` entry naming each still-open objective with its message ref (`Open objectives: refactor runner into eight arms (m00746)`). Distillation re-carries open objectives verbatim from source blocks \u2014 they are the last thing to drop and the first thing to restore, at every tier.\n- The user's overall goal and any changes to it \u2014 the big-picture objective plus how it evolved during the compressed range. Each summary must reflect the goal as it stood at the end of the range, including pivots (e.g., \"initially: fix bug X \u2192 pivoted to: refactor module Y after discovering root cause\"). Losing the goal or its evolution makes all subsequent work appear unmotivated.\n- Purpose behind each significant action \u2014 preserve not just what was done but why: the hypothesis behind each experiment, the question behind each exploration, the task goal behind each work action. Without purpose, the summary reads as disconnected technical steps with no through-line.\n- Open questions and unresolved TODOs \u2014 losing these changes what work appears to remain.\n- Message refs of key anchors (`m00420`, `m00510\u2013m00520`) \u2014 they let you or a later reader jump back via decompress to the exact original.\n\nDROP \u2014 extract the signal, discard the vessel:\n- Verbose logs (build/test/`npm` output) once you have captured the error line or the result.\n- Duplicate file reads once the needed content is recorded.\n- Consumed exploration \u2014 search hits, agent return values, successful tool outputs \u2014 once you have extracted the facts you need (same rule as dead-ends, but nothing went wrong; the content is simply spent).\n- Dead-end exploration \u2014 but PRESERVE the lesson in one line: \"tried X, failed because Y\".\n- Back-and-forth discussion and self-corrections once the final position is captured (keep the outcome, drop the journey to it).\n- Repeated status checks (`git status`, `ls`) once state is known.\n\nFor each significant item you DROP (scripts, reports, large analyses, long tool outputs), add a one-line CONTENT description of what it covers \u2014 not where it lives. Bad: \"probe script at /path/probe_kvnet.py\". Good: \"probe_kvnet.py: tests n-gram baseline, generation quality, long-range dependency, position sensitivity, op pipeline, QUERY attention.\" This lets a later decompress target the right block by relevance, not by guessing locations.\n\nPRIORITY \u2014 when the summary must be compact, preserve in this order:\n1. User's overall goal, goal evolution, intent, and hard constraints (losing these changes the task).\n2. Decisions and rationale.\n3. Exact technical artifacts: paths, signatures, errors, values.\n4. Conclusions and key findings.\n5. Lessons learned: what failed and why.\n\nWrite dense, scannable bullets \u2014 not narrative prose. If the range spans distinct concerns (request \u2192 findings \u2192 decision), group bullets under short thematic headers so a reader can scan to the part they need. Every line must earn its place. Do not mimic the style of existing summaries in context; follow these rules.";
|
|
19
26
|
export declare const TIER2_DISTILL_RULES = "TIER 2 COMPRESSION \u2014 DISTILLATION\n\nYou are compressing historical summaries (not raw conversation). These summaries have already captured the details. Your job is to DISTILL them: extract only what matters for future work, discard the process.\n\nKEEP \u2014 these are the only things that survive distillation:\n- Decisions and their rationale (\"chose X over Y because Z\" \u2014 the \"because\" is load-bearing).\n- Final outcomes: version numbers shipped, PR numbers merged/closed, bugs fixed or deferred.\n- Key lessons: what failed and why (\"tried X, failed because Y\"). These prevent repeating mistakes.\n- Critical constraints discovered (\"must support Node 22\", \"AGENTS.md forbids as any\").\n- Design decisions with architectural impact (\"chose compress-as-anchor over synthetic messages because prefix cache\").\n- User quotes and task state only as attributed history: keep the source ref with any user quote; never carry an UNVERIFIED tier-1 \"CURRENT TASK\" claim forward as a live directive \u2014 relabel it \"TASK AS OF THIS BLOCK\". A ref-backed objective that no later source marks completed or superseded is not unverified: it carries in the `Open objectives:` entry (next bullet), not as a directive.\n- Open objectives \u2014 if ANY source block's summary names a user-requested objective that no later source block marks completed or superseded, the distilled summary MUST keep a one-line `Open objectives:` entry re-carrying each still-open objective verbatim with its original ref. They are the last thing to drop and the first thing to restore.\n- Whether content is OBSOLETE or SUPERSEDED \u2014 mark with one line: \"[SUPERSEDED by PR #NNN]\" or \"[OBSOLETE: deleted in vX.Y.Z]\". Do NOT keep the obsolete content's details \u2014 just the marker and reason.\n- Function/class/type names and module paths that are the SUBJECT of the work \u2014 e.g., \"fixed filterCompressedRanges in prune.ts\", \"added SessionStateRegistry in state.ts\". Not exact line numbers or full signatures \u2014 just enough to LOCATE the code without searching.\n- Exploration findings: if a block was exploratory with no decision, keep the CONCLUSION in one line (\"explored X, not viable because Y\"). Do not keep the exploration process.\n\nDROP \u2014 these were useful during the work but are no longer needed:\n- Exact line numbers, diffs, verbose function signatures, full code listings.\n- Build/deploy process details, test execution steps.\n- Review process details (who reviewed, what rounds, test counts).\n- Verbose logs, command output, intermediate debugging steps.\n\nFORMAT:\n- Start each distilled block with a source header line:\n `Source: bN+bM+... (XK\u2192YK tok, Zx). [original topic]`\n Example: `Source: b5+b7 (56K+44K\u2192268 tok, 375x). [Tool-result recap + publish]`\n- 3-5 bullet points per source block, each a self-contained fact.\n- Dense, scannable \u2014 no narrative prose.\n- Start with the outcome, not the process: \"v1.13.0 shipped (7 PRs bundled)\" not \"implemented 7 PRs then reviewed then merged\".\n- Cross-block synthesis: if multiple source blocks cover the same topic (same PR, same feature, same bug), MERGE them into a single group of bullets. Do not repeat the same fact from different blocks \u2014 keep it once under the most relevant source header.\n\nSIZE TARGET: 50-150 tokens per source block (excluding the header). If you can't fit it in 150 tokens, you're keeping too much process. If a block has nothing worth keeping (pure noise), output just the header followed by \"[no actionable content].\"";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compression-rules.d.ts","sourceRoot":"","sources":["../src/compression-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,mBAAmB,giBAIqR,CAAC;AAEtT,eAAO,MAAM,qBAAqB,o7LAoC8R,CAAC;AAEjU,eAAO,MAAM,mBAAmB,+/GA+ByN,CAAC;AAE1P,eAAO,MAAM,oBAAoB,2yEAiC4K,CAAC"}
|
|
1
|
+
{"version":3,"file":"compression-rules.d.ts","sourceRoot":"","sources":["../src/compression-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;gFAKgF;AAChF,eAAO,MAAM,0BAA0B,iSACyP,CAAC;AAEjS,eAAO,MAAM,mBAAmB,giBAIqR,CAAC;AAEtT,eAAO,MAAM,qBAAqB,o7LAoC8R,CAAC;AAEjU,eAAO,MAAM,mBAAmB,+/GA+ByN,CAAC;AAE1P,eAAO,MAAM,oBAAoB,2yEAiC4K,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,12 +13,12 @@ export type { TokenCountFn } from "./tokenize.js";
|
|
|
13
13
|
export { renderNudgeText, formatRanges } from "./nudge-text.js";
|
|
14
14
|
export type { NudgeVoice, RenderedNudge, NudgePromptSections, } from "./nudge-text.js";
|
|
15
15
|
export { resolveBlockSpan, activeBlockSpans, formatCreatedBlocks, } from "./block-map.js";
|
|
16
|
-
export { COMPRESS_PHILOSOPHY, HOW_TO_COMPRESS_RULES, TIER2_DISTILL_RULES, TIER3_CONDENSE_RULES, } from "./compression-rules.js";
|
|
16
|
+
export { COMPRESS_PHILOSOPHY, HOW_TO_COMPRESS_RULES, LANGUAGE_PRESERVATION_RULE, TIER2_DISTILL_RULES, TIER3_CONDENSE_RULES, } from "./compression-rules.js";
|
|
17
17
|
export { defaultPrompts, resolvePrompts } from "./prompts.js";
|
|
18
18
|
export type { Prompts, ResolvePromptsOptions } from "./prompts.js";
|
|
19
19
|
export { applySectionOverrides, cloneWithDescriptions, applyAcpToolOverrides, } from "./surface-config.js";
|
|
20
20
|
export type { SectionOverride, CompressPromptSections, ToolPromptOverrides, ToolPrompts, AcpToolLike, } from "./surface-config.js";
|
|
21
|
-
export { isValidPackName, sanitizePackSurface, defaultPack, leanPack, LEAN_HOW_TO_COMPRESS, builtinSource, createDirPackSource, createPackResolver, defaultPackSources, } from "./packs.js";
|
|
21
|
+
export { isValidPackName, sanitizePackSurface, defaultPack, leanPack, LEAN_HOW_TO_COMPRESS, leanHowToCompress, builtinSource, createDirPackSource, createPackResolver, defaultPackSources, } from "./packs.js";
|
|
22
22
|
export type { PromptPackFile, PackSurface, Pack, PackSource, PackResolver, } from "./packs.js";
|
|
23
23
|
export { truncateLargeToolOutputs } from "./truncate-tools.js";
|
|
24
24
|
export type { TruncateOptions, TruncateResult } from "./truncate-tools.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAk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B,SAAS,EACT,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,8BAA8B,EAC9B,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,GACZ,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EA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AO,EACL,sBAAsB,EACtB,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,8BAA8B,EAC9B,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,GACZ,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
COMPRESS_PHILOSOPHY,
|
|
3
3
|
HOW_TO_COMPRESS_RULES,
|
|
4
|
+
LANGUAGE_PRESERVATION_RULE,
|
|
4
5
|
TIER2_DISTILL_RULES,
|
|
5
6
|
TIER3_CONDENSE_RULES,
|
|
6
7
|
VIABLE_RANGE_MIN_TOKENS,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
resolvePrompts,
|
|
17
18
|
thinkingTokenValue,
|
|
18
19
|
viableRanges
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Q3P5Z2PV.js";
|
|
20
21
|
import {
|
|
21
22
|
activeBlocks,
|
|
22
23
|
advanceSurvival,
|
|
@@ -31,8 +32,8 @@ import {
|
|
|
31
32
|
// src/refs.ts
|
|
32
33
|
var REF_WIDTH = 5;
|
|
33
34
|
var MIN_INDEX = 1;
|
|
34
|
-
var MAX_INDEX =
|
|
35
|
-
var REF_PATTERN = /^m0*(\d{1,
|
|
35
|
+
var MAX_INDEX = 9999999;
|
|
36
|
+
var REF_PATTERN = /^m0*(\d{1,7})$/;
|
|
36
37
|
var BLOCKED_REF = "BLOCKED";
|
|
37
38
|
function emptyRefMap() {
|
|
38
39
|
return { byRaw: {}, byRef: {} };
|
|
@@ -1272,10 +1273,12 @@ function isNeverPreserveRecent(msg, patterns, preservePatterns) {
|
|
|
1272
1273
|
return false;
|
|
1273
1274
|
}
|
|
1274
1275
|
function matchToolPattern(toolName, pattern) {
|
|
1275
|
-
|
|
1276
|
-
|
|
1276
|
+
const name = toolName.toLowerCase();
|
|
1277
|
+
const pat = pattern.toLowerCase();
|
|
1278
|
+
if (pat.endsWith("*")) {
|
|
1279
|
+
return name.startsWith(pat.slice(0, -1));
|
|
1277
1280
|
}
|
|
1278
|
-
return
|
|
1281
|
+
return name === pat;
|
|
1279
1282
|
}
|
|
1280
1283
|
function isMessageProtected(msg, config) {
|
|
1281
1284
|
if (msg.contentType !== "tool-call" && msg.contentType !== "tool-result" || !msg.toolName) {
|
|
@@ -1486,10 +1489,13 @@ var LEADING_TAG_RE = new RegExp("^\\x3cacp [^>]*>[^\\x3c]*\\x3c\\/acp>\\n?");
|
|
|
1486
1489
|
function stripLeadingTag(text) {
|
|
1487
1490
|
return text.replace(LEADING_TAG_RE, "");
|
|
1488
1491
|
}
|
|
1492
|
+
var CANONICAL_REF = "m(?:\\d{5}|[1-9]\\d{5,6})";
|
|
1489
1493
|
var PLACEHOLDER_LINE1_RE = new RegExp(
|
|
1490
|
-
"^\u{1F4E6} \\[acp-stored #(
|
|
1494
|
+
"^\u{1F4E6} \\[acp-stored #(" + CANONICAL_REF + ") \xB7 (.+?) \xB7 (0|[1-9]\\d{0,2}(?:,\\d{3})*) tok\\](?: `(.+)`)?$"
|
|
1495
|
+
);
|
|
1496
|
+
var PLACEHOLDER_LINE2_RE = new RegExp(
|
|
1497
|
+
'^ \u2192 (.+?)\\("(' + CANONICAL_REF + ')"\\) returns the full text$'
|
|
1491
1498
|
);
|
|
1492
|
-
var PLACEHOLDER_LINE2_RE = /^ → (.+?)\("(m\d{5})"\) returns the full text$/;
|
|
1493
1499
|
function parseStoredPlaceholder(text) {
|
|
1494
1500
|
const body = stripLeadingTag(text);
|
|
1495
1501
|
const trimmed = body.endsWith("\n") ? body.slice(0, -1) : body;
|
|
@@ -1747,14 +1753,14 @@ function noteRetrieval(state) {
|
|
|
1747
1753
|
}
|
|
1748
1754
|
|
|
1749
1755
|
// src/boundaries.ts
|
|
1750
|
-
var MESSAGE_REF_PATTERN = /^m0*(\d{1,
|
|
1756
|
+
var MESSAGE_REF_PATTERN = /^m0*(\d{1,7})$/;
|
|
1751
1757
|
var BLOCK_REF_PATTERN = /^b(\d{1,9})$/;
|
|
1752
1758
|
function parseBoundary(ref) {
|
|
1753
1759
|
const normalized = ref.trim().toLowerCase();
|
|
1754
1760
|
const messageMatch = MESSAGE_REF_PATTERN.exec(normalized);
|
|
1755
1761
|
if (messageMatch) {
|
|
1756
1762
|
const numericId = Number(messageMatch[1]);
|
|
1757
|
-
if (numericId >= 1 && numericId <=
|
|
1763
|
+
if (numericId >= 1 && numericId <= 9999999) {
|
|
1758
1764
|
return { kind: "message", numericId, raw: normalized };
|
|
1759
1765
|
}
|
|
1760
1766
|
}
|
|
@@ -5293,12 +5299,13 @@ var nudgeNode = {
|
|
|
5293
5299
|
countTokens: ctx.countTokens
|
|
5294
5300
|
});
|
|
5295
5301
|
const baseline = io.state.nudge.lastPerMessageNudgeTokens;
|
|
5302
|
+
const shownAtDecision = io.state.nudge.lastNudgeShownTokens;
|
|
5296
5303
|
const nudgeGrowthTokens = resolveAdaptiveGrowth(
|
|
5297
5304
|
ctx.config.modelContextLimit,
|
|
5298
5305
|
ctx.config.nudge
|
|
5299
5306
|
);
|
|
5300
5307
|
let stamped = { ...io.state.nudge };
|
|
5301
|
-
if (baseline > 0 && ctx.tokenCount < baseline - nudgeGrowthTokens) {
|
|
5308
|
+
if (baseline > 0 && ctx.tokenCount < baseline - nudgeGrowthTokens || shownAtDecision > 0 && ctx.tokenCount < shownAtDecision - nudgeGrowthTokens) {
|
|
5302
5309
|
stamped.lastPerMessageNudgeTokens = ctx.tokenCount;
|
|
5303
5310
|
stamped.lastNudgeShownTokens = 0;
|
|
5304
5311
|
stamped.lastShownByTier = {};
|
|
@@ -6059,6 +6066,11 @@ DROP \u2014 keep the signal, discard the vessel: verbose logs once the error/res
|
|
|
6059
6066
|
PRIORITY when compacting: 1. user goal/evolution/intent/hard constraints \xB7 2. decisions + rationale \xB7 3. exact artifacts (paths, signatures, errors, values) \xB7 4. conclusions \xB7 5. lessons learned (what failed and why).
|
|
6060
6067
|
|
|
6061
6068
|
Format: dense scannable bullets under short thematic headers, not narrative prose; every line earns its place. Do not mimic the style of existing summaries in context; follow these rules.`;
|
|
6069
|
+
function leanHowToCompress(languagePreservation = false) {
|
|
6070
|
+
return languagePreservation ? `${LEAN_HOW_TO_COMPRESS}
|
|
6071
|
+
|
|
6072
|
+
${LANGUAGE_PRESERVATION_RULE}` : LEAN_HOW_TO_COMPRESS;
|
|
6073
|
+
}
|
|
6062
6074
|
var leanPack = {
|
|
6063
6075
|
name: "lean",
|
|
6064
6076
|
version: "1.0.0",
|
|
@@ -8638,6 +8650,7 @@ export {
|
|
|
8638
8650
|
IMAGE_FULL_TOOL_NAME,
|
|
8639
8651
|
IMAGE_FULL_TOOL_OPENAI,
|
|
8640
8652
|
IMAGE_FULL_TOOL_RESPONSES,
|
|
8653
|
+
LANGUAGE_PRESERVATION_RULE,
|
|
8641
8654
|
LEAN_HOW_TO_COMPRESS,
|
|
8642
8655
|
MAX_VERBOSITY_LEVEL,
|
|
8643
8656
|
MIN_VERBOSITY_LEVEL,
|
|
@@ -8769,6 +8782,7 @@ export {
|
|
|
8769
8782
|
isToolMessage,
|
|
8770
8783
|
isValidPackName,
|
|
8771
8784
|
jsonFoldPlugin,
|
|
8785
|
+
leanHowToCompress,
|
|
8772
8786
|
leanPack,
|
|
8773
8787
|
listCrushPlugins,
|
|
8774
8788
|
listMessageFilters,
|