compressed-context 0.2.0 → 0.2.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/package.json +1 -1
- package/src/compression/summarize.ts +30 -18
package/package.json
CHANGED
|
@@ -32,12 +32,11 @@ function promptRules(options: SummaryPromptOptions | undefined): string[] {
|
|
|
32
32
|
const lines =
|
|
33
33
|
options?.format === "babel"
|
|
34
34
|
? [
|
|
35
|
-
"-
|
|
36
|
-
"- Only `T=<short title>|G=<one-line goal>`
|
|
37
|
-
"-
|
|
38
|
-
"-
|
|
39
|
-
"-
|
|
40
|
-
"- Target 400-800 tokens for T1; drop explanations before exact facts.",
|
|
35
|
+
"- Audience=peer LLM. Notation only, not content: drop grammar/connectives, mix languages/emoji/math(forall、exists、in、=>).",
|
|
36
|
+
"- Only `T=<short title>|G=<one-line goal>` fixed; invent anchors and reuse them; no headings/paragraphs/sentences/JSON/fences.",
|
|
37
|
+
"- Anchors: `S[module]` `D[decision]:why` `F[path:line]` `C[step>step]` `Config[target]:k=v` `?cond=>action` `!edge:detail` `Eval[A/B]:result`; flatten parallel items `[A,B,C]`.",
|
|
38
|
+
"- Files `F:[...]` complete, never \"various files\"; commands `C:[...]` verbatim, never paraphrase.",
|
|
39
|
+
"- Lossless: entity graph, exact numbers (no rounding), versions, config keys, thresholds, formulas, conditions, causality, exceptions, comparisons, placeholders, paths, signatures, error text; unknown=?/NULL, never invent.",
|
|
41
40
|
`- Keep this summary under ${maxChars.toString()} characters.`,
|
|
42
41
|
]
|
|
43
42
|
: options?.format === "markdown"
|
|
@@ -101,11 +100,25 @@ export function sessionGenerator(session: SessionGenerateLike, sessionID: string
|
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
const BABEL_T1_RULES = `Guidance:
|
|
104
|
-
- This checkpoint replaces the messages above;
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
-
|
|
103
|
+
- This checkpoint replaces the messages above; the next reader sees it instead of them, so it must stand on its own. Describe what already happened as history, not as instructions to act now.
|
|
104
|
+
- Keep the objective and hard constraints, decisions with their reasons, outcomes, open items, work the user still expects, and failure lessons.
|
|
105
|
+
- Copy exact identifiers instead of describing them: full paths with line numbers, the line of code that carries the logic, signatures, error text, versions, config keys, thresholds, measured values.
|
|
106
|
+
- Omit build/test logs, repeated reads, exploration that produced nothing, abandoned attempts (one line on why they failed), repeated status checks, and settled discussion.
|
|
107
|
+
- If space is tight, keep in this order: objective and constraints; decisions and reasons; exact technical facts; conclusions; lessons from failures.`
|
|
108
|
+
|
|
109
|
+
const BABEL_T2_RULES = `Guidance for merging existing checkpoints:
|
|
110
|
+
- The sources are already compressed; merge them into one checkpoint covering all of them, without re-telling the process.
|
|
111
|
+
- Keep the latest objective and hard constraints, decisions with their reasons, final outcomes, open items, blocked work, and the user's still-open expectations.
|
|
112
|
+
- Merge duplicate facts and keep the latest status; mark superseded content with one short marker and drop its details.
|
|
113
|
+
- Drop process, logs, full diffs, code listings, and non-load-bearing line numbers. A failed attempt may stay as one line on why it failed.
|
|
114
|
+
- Target roughly 50-150 tokens per source block.`
|
|
115
|
+
|
|
116
|
+
const BABEL_T3_RULES = `Guidance for ultra-condensing existing checkpoints:
|
|
117
|
+
- Reduce the sources to a lookup index: one to three single-line facts per source block, subject plus outcome.
|
|
118
|
+
- Keep only shipped outcomes, open work, architectural decisions, and critical constraints.
|
|
119
|
+
- Drop explanations, rationale details, process, logs, and anything already obsolete or superseded.
|
|
120
|
+
- Open user-requested objectives survive until a later source marks them completed or superseded.
|
|
121
|
+
- Target roughly 30-60 tokens per source block.`
|
|
109
122
|
|
|
110
123
|
const TIER1_RULES = `Guidance:
|
|
111
124
|
- This checkpoint replaces the messages above; the next reader sees it instead of them, so it must stand on its own.
|
|
@@ -133,7 +146,7 @@ const TIER3_RULES = `Guidance for ultra-condensing existing checkpoints:
|
|
|
133
146
|
- Target roughly 30-60 tokens per source block.`
|
|
134
147
|
|
|
135
148
|
function rulesFor(tier: Tier, format?: SummaryFormat): string {
|
|
136
|
-
if (format === "babel") return tier === 1 ? BABEL_T1_RULES : tier === 2 ?
|
|
149
|
+
if (format === "babel") return tier === 1 ? BABEL_T1_RULES : tier === 2 ? BABEL_T2_RULES : BABEL_T3_RULES
|
|
137
150
|
if (tier === 2) return TIER2_RULES
|
|
138
151
|
if (tier === 3) return TIER3_RULES
|
|
139
152
|
return TIER1_RULES
|
|
@@ -230,13 +243,12 @@ const MARKDOWN_CHOICE_RULES = `Guidance for choosing and merging:
|
|
|
230
243
|
|
|
231
244
|
const BABEL_CHOICE_RULES = `Guidance for choosing and merging:
|
|
232
245
|
- Exactly one adjacent pair may be merged. Pick one candidate from the list below and merge ONLY that pair; every other block is context for the decision, not part of the merge.
|
|
233
|
-
- First line must be \`c=N\`, where N is the chosen candidate number.
|
|
234
|
-
-
|
|
235
|
-
-
|
|
236
|
-
- Target 150-300 tokens for T2 and 60-120 tokens for T3; drop explanations before exact facts.
|
|
237
|
-
- Keep the latest objective and hard constraints, decisions with reasons, final outcomes, open items, blocked work, and exact facts that still matter.
|
|
246
|
+
- First line must be \`c=N\`, where N is the chosen candidate number. Second line must be \`T=<short title>|G=<one-line goal>\`; after that write adaptive Babel with anchors you invent and reuse.
|
|
247
|
+
- Babel changes only notation, not content: same policy as a normal merge checkpoint. No Markdown headings, no JSON, no prose/sentences, no code fences.
|
|
248
|
+
- Keep the latest objective and hard constraints, decisions with their reasons, final outcomes, open items, blocked work, and exact facts that still matter.
|
|
238
249
|
- Merge duplicate facts across the chosen pair, keep the latest status, and drop process, logs, repeated reads, full diffs, and non-load-bearing line numbers.
|
|
239
|
-
-
|
|
250
|
+
- If the chosen candidate's output tier is 2, target roughly 50-150 tokens per source block. If it is tier 3, be ultra-condensed: one to three single-line facts per source block.
|
|
251
|
+
- Do not invent facts.`
|
|
240
252
|
|
|
241
253
|
function buildChoicePrompt(
|
|
242
254
|
context: string,
|