@parad0x_labs/openclaw-context-capsule 1.6.0 → 1.7.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ## 1.7.0
4
+
5
+ - **Value-atom preservation.** A lone distinctive value — a bare port (`5433`), an
6
+ issue ref (`#4821`), a version (`v2.13.0`), an ISO date, or a hyphenated code
7
+ (`NEEDLE-ZX-7742`) — is now emitted as its own dense atom, so it survives
8
+ compression even when its surrounding sentence loses the budget race. Previously
9
+ such a value only survived when its whole line was selected. New regression:
10
+ `test/value-survival.test.mjs` (wired into `npm test`).
11
+ - **Docs accuracy.** Corrected the documented config defaults (`maxCapsuleTokens`
12
+ `700` → `1400`, `capsuleTokenRatio` `0.08` → `0.14`) to match the shipped values.
13
+ Reframed the fidelity figures to state plainly that they are measured on the
14
+ maintainer's own private sessions via `test/fidelity-bench.mjs` (reproduce on your
15
+ own `~/.openclaw` sessions), not a repo fixture. The supersession clean rate (83%
16
+ floor) and value-survival remain CI-gated by `npm test`.
17
+
18
+ ## 1.6.0
19
+
20
+ - Self-contained compression core bundled in `src/compression.ts` (no external
21
+ runtime dependency; no network / file-system / on-chain calls).
package/README.md CHANGED
@@ -46,8 +46,8 @@ LLM is given the extractive capsule, not opaque compressed bytes.
46
46
  | --- | ---: | --- |
47
47
  | `minMessages` | `20` | Sessions shorter than this pass through unchanged. |
48
48
  | `keepRecentMessages` | `10` | Recent messages kept verbatim after compression. |
49
- | `maxCapsuleTokens` | `700` | Hard cap for the injected extractive capsule. |
50
- | `capsuleTokenRatio` | `0.08` | If OpenClaw provides a model token budget, cap the capsule to this fraction of the budget. |
49
+ | `maxCapsuleTokens` | `1400` | Hard cap for the injected extractive capsule. |
50
+ | `capsuleTokenRatio` | `0.14` | If OpenClaw provides a model token budget, cap the capsule to this fraction of the budget. |
51
51
  | `minCompressTokens` | `900` | Estimated transcript-token floor before compression activates. |
52
52
 
53
53
  ```jsonc
@@ -57,8 +57,8 @@ LLM is given the extractive capsule, not opaque compressed bytes.
57
57
  "context-capsule": {
58
58
  "minMessages": 20,
59
59
  "keepRecentMessages": 10,
60
- "maxCapsuleTokens": 700,
61
- "capsuleTokenRatio": 0.08,
60
+ "maxCapsuleTokens": 1400,
61
+ "capsuleTokenRatio": 0.14,
62
62
  "minCompressTokens": 900
63
63
  }
64
64
  }
package/SKILL.md CHANGED
@@ -1,6 +1,9 @@
1
1
  ---
2
2
  name: context-capsule
3
3
  description: Compresses older OpenClaw agent session history into a bounded, lane-change-aware context capsule — keeps recent messages verbatim, flags abandoned directions, quarantines injected instructions, and redacts secrets. Local, deterministic, any model.
4
+ license: MIT
5
+ metadata:
6
+ author: Parad0x-Labs
4
7
  ---
5
8
 
6
9
  # Context Capsule
@@ -19,11 +22,17 @@ Claude, GPT, Ollama, Mistral, LM Studio.
19
22
  held-out pivot set it cleans 83% of abandoned subjects with **zero** wrongly
20
23
  flagged live choices.
21
24
  - **High fidelity per token.** Distinctive signals — file paths, IDs, ports,
22
- URLs, commands, errors, decisions — are emitted as dense atoms, so the capsule
23
- keeps **79% of key signals at ~5× reduction and 93% at ~3.4×** on real
24
- sessions (measured, see `test/fidelity-bench.mjs`).
25
-
26
- > **Self-contained (v1.6.0):** The compression core is bundled directly in this
25
+ URLs, commands, errors, decisions — are emitted as dense atoms. As of **v1.7.0**,
26
+ a lone value (a bare port `5433`, an issue ref `#4821`, a version `v2.13.0`, an
27
+ ISO date, a hyphenated code like `NEEDLE-ZX-7742`) is emitted as its **own** atom,
28
+ so it survives compression even when its surrounding sentence loses the budget
29
+ race — CI-tested in `test/value-survival.test.mjs`. On the maintainer's own real
30
+ sessions the capsule kept ~79% of key signals at ~5× reduction and ~93% at ~3.4×;
31
+ `test/fidelity-bench.mjs` measures this against **your own** `~/.openclaw` sessions
32
+ (run it on your data to reproduce — the figures are from private sessions, not a
33
+ repo fixture).
34
+
35
+ > **Self-contained (v1.7.0):** The compression core is bundled directly in this
27
36
  > skill (`src/compression.ts`). There is **no external runtime dependency**, and
28
37
  > the plugin makes **no network, file-system, or on-chain calls**. Everything
29
38
  > runs locally using only Node's built-in `zlib` and `crypto`, and is fully
@@ -906,6 +906,12 @@ const ATOM_URL_RE = /https?:\/\/[^\s)\]}>"']+/giu;
906
906
  const ATOM_PATH_RE = /(?:[.~]?\/)?[\w.-]+\/[\w./@+-]*\.[A-Za-z0-9]{1,8}/giu;
907
907
  const ATOM_CMD_RE = /\b(?:pnpm|npm|bun|node|git|gh|openclaw|launchctl|lsof|tail|cat|rg|jq|curl|ssh|docker|kubectl)\s+[\w./@:=-][^\n,;]*/giu;
908
908
  const ATOM_HASH_RE = /\b[A-Za-z0-9]{20,}\b/gu;
909
+ // Bare distinctive VALUES the URL/path/command/hash passes miss: a standalone port or
910
+ // code (3+ digits), an issue ref (#42), a version (v2.13), an ISO date, an sk- key, or a
911
+ // hyphenated code carrying digits (NEEDLE-ZX-7742). These are the answer of a fact and are
912
+ // short, so the length gate below would drop them — harvest them separately so a lone
913
+ // `5433` / `#42` / `2026-07-15` survives as its own atom, not only when its line is picked.
914
+ const ATOM_VALUE_RE = /\bsk-[A-Za-z0-9_-]{6,}\b|\b\d{4}-\d{2}-\d{2}\b|#\d{2,}\b|\bv\d+\.\d+(?:\.\d+)?\b|\b\w*-\w*\d{2,}[\w-]*\b|\b\d{3,}\b/giu;
909
915
  function extractAtoms(content) {
910
916
  const atoms = new Set();
911
917
  const harvest = (re) => {
@@ -925,6 +931,14 @@ function extractAtoms(content) {
925
931
  if (![...atoms].some((a) => a.includes(m)))
926
932
  atoms.add(m.slice(0, 60));
927
933
  }
934
+ // Bare values last, min length 2 (so `#42` survives), skipping any already contained in a
935
+ // URL/path/hash atom (a port inside a URL is not double-emitted).
936
+ ATOM_VALUE_RE.lastIndex = 0;
937
+ for (const m of content.match(ATOM_VALUE_RE) ?? []) {
938
+ const v = m.trim();
939
+ if (v.length >= 2 && ![...atoms].some((a) => a.includes(v)))
940
+ atoms.add(v.slice(0, 60));
941
+ }
928
942
  return [...atoms];
929
943
  }
930
944
  function extractFacts(messages, maxFacts) {
package/dist/index.js CHANGED
@@ -190,7 +190,7 @@ class ContextCapsuleEngine {
190
190
  info = {
191
191
  id: "context-capsule",
192
192
  name: "Context Capsule",
193
- version: "1.6.0",
193
+ version: "1.7.0",
194
194
  ownsCompaction: false,
195
195
  turnMaintenanceMode: "background",
196
196
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parad0x_labs/openclaw-context-capsule",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Self-contained OpenClaw context engine that compresses older agent session history into a bounded extractive capsule, preserving decisions, tasks, errors, files, links, and durable facts while keeping recent messages verbatim.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,7 +8,8 @@
8
8
  "dist/",
9
9
  "openclaw.plugin.json",
10
10
  "README.md",
11
- "SKILL.md"
11
+ "SKILL.md",
12
+ "CHANGELOG.md"
12
13
  ],
13
14
  "keywords": [
14
15
  "openclaw",
@@ -38,7 +39,7 @@
38
39
  "typecheck": "tsc --noEmit -p tsconfig.json",
39
40
  "prepack": "npm run build",
40
41
  "prepublishOnly": "npm run build && npm test",
41
- "test": "npm run build && node test/compression-smoke.mjs && node test/quality.test.mjs && node test/supersession-bench.mjs && node test/hardening-bench.mjs && node test/secret-bench.mjs && node test/platform-parity.test.mjs"
42
+ "test": "npm run build && node test/compression-smoke.mjs && node test/quality.test.mjs && node test/value-survival.test.mjs && node test/supersession-bench.mjs && node test/hardening-bench.mjs && node test/secret-bench.mjs && node test/platform-parity.test.mjs"
42
43
  },
43
44
  "engines": {
44
45
  "node": ">=22"