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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compressed-context",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "OpenCode 上下文管理插件:按需压缩、自包含摘要",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,12 +32,11 @@ function promptRules(options: SummaryPromptOptions | undefined): string[] {
32
32
  const lines =
33
33
  options?.format === "babel"
34
34
  ? [
35
- "- Receiver is another equally capable language model, not a human. Drop human readability and grammar; freely mix languages, emoji, math/logic symbols; replace connectives, modifiers, and long clauses with symbols.",
36
- "- Only `T=<short title>|G=<one-line goal>` is fixed. Do not use a fixed key schema or long labels (`Meta:`, `Entity:`, `Decisions:`, `Progress:`). Invent the shortest one-character anchors or delimiters that fit this source and use them consistently.",
37
- "- Body is a compact latent index, not prose: no headings, no paragraphs, no sentences, no JSON, no code fences.",
38
- "- Preserve exactly in latent space: entity/relation graph; exact numbers, versions, config keys, thresholds, formulas; conditions, causality, exceptions; comparisons; original placeholders, paths, commands, signatures, error text. Never invent or round.",
39
- "- Keep the latest objective, constraints, decisions with reasons, outcomes, open items, and work the user still expects. Drop narrative, process, logs, repeated reads, and duplicates.",
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; write a compact latent index, not a story.
105
- - Only T/G is fixed. Dynamically invent the shortest anchors/delimiters for this source; do not reuse a fixed field schema or long labels.
106
- - Keep only what future work needs: latest objective, hard constraints, decisions with one-line reasons, outcomes, open items, and exact technical facts.
107
- - Preserve exact paths, line numbers, signatures, commands, error text, versions, config keys, thresholds, and measured values.
108
- - Drop process, logs, repeated reads, full diffs, abandoned details, and explanation prose. If space is tight, keep exact facts before narrative.`
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 ? TIER2_RULES : TIER3_RULES
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
- - Second line must be \`T=<short title>|G=<one-line goal>\`. After that, write adaptive Babel: only T/G is fixed; dynamically invent the shortest anchors/delimiters and use them consistently. Do not use a fixed field schema or long labels.
235
- - Mix languages, emoji, and logic symbols freely for density; no Markdown headings, no JSON, no prose/sentences, no code fences.
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
- - Copy identifiers, paths, commands, errors, versions, and numbers verbatim. Do not invent facts.`
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,