diff --git a/.gitignore b/.gitignore index a7e6b4d..965648d 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,9 @@ __pycache__/ .vscode/ *.swp +# demo +demo/bundle.js + # indexing / analysis artifacts .ckb/ *.scip diff --git a/demo/build.mjs b/demo/build.mjs new file mode 100644 index 0000000..536cb5e --- /dev/null +++ b/demo/build.mjs @@ -0,0 +1,13 @@ +import { build } from 'esbuild'; + +await build({ + entryPoints: ['src/index.ts'], + bundle: true, + format: 'iife', + globalName: 'CCE', + outfile: 'demo/bundle.js', + target: 'es2020', + platform: 'browser', +}); + +console.log('Built demo/bundle.js'); diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 0000000..27c0171 --- /dev/null +++ b/demo/index.html @@ -0,0 +1,1616 @@ + + + + + + Context Compression Engine — Demo + + + + + + +
+
+ +
+ deterministic + github ↗ +
+
+ +
+
+ + + 4 +
+ +
+ + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+ + +
+ + +
+ +
+
+
Compression
+ +
+
recency
+
+ Number of most recent messages to keep untouched. Only older messages are candidates + for compression. recencyWindow +
+
+
+
budget
+
+ Target token count. When enabled, binary-searches the recency window to fit the output + within this limit. tokenBudget +
+
+
+
preserve
+
+ Roles that are never compressed, comma-separated. Typically system. These + messages pass through verbatim regardless of position. +
+
+
+
converge
+
+ Hard-truncate non-recent messages when the binary search bottoms out and the budget is + still exceeded. Last resort. forceConverge +
+
+ +
Deduplication
+ +
+
dedup
+
+ Replace exact duplicate messages with a compact reference to the first occurrence. + Compares full content via hash + equality check. +
+
+
+
fuzzy
+
+ Detect near-duplicate messages using line-level Jaccard similarity. Catches messages + that are mostly the same but not identical. fuzzyDedup +
+
+
+
threshold
+
+ Similarity cutoff for fuzzy dedup, 0–1. Higher = stricter matching. Default + 0.85 means 85% of lines must overlap to count as a near-duplicate. +
+
+ +
Output
+ +
+
preserved
+
+ Message was kept verbatim — either in the recency window, a preserved role, or + classified as code/structured data (T0). +
+
+
+
compressed
+
+ Prose was summarized by the deterministic scorer. + Red strikethrough = removed text, + green = replacement summary. +
+
+
+
removed
+
+ Message was dropped entirely, typically by dedup replacing a duplicate with a + back-reference. +
+
+
+
+ +
+
+
+ Input + + + role: message — blank lines separate + +
+ +
+ +
+
+ Output + +
+
+
+
+
+
+ Write a conversation on the left,
then hit Compress +
+
+
+
+
+
+
+
+ + + + + diff --git a/eslint.config.js b/eslint.config.js index 73365b2..bd80311 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -5,7 +5,7 @@ export default tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, { - ignores: ['dist/', 'coverage/', 'node_modules/'], + ignores: ['dist/', 'coverage/', 'node_modules/', 'demo/'], }, { rules: { diff --git a/package-lock.json b/package-lock.json index 5f5581f..9500d01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@arethetypeswrong/cli": "^0.18.2", "@eslint/js": "^10.0.1", "@vitest/coverage-v8": "^4.0.18", + "esbuild": "^0.27.3", "eslint": "^10.0.2", "openai": "^6.25.0", "prettier": "^3.8.1", diff --git a/package.json b/package.json index 9b33f2f..08ef87a 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "test:e2e:smoke": "cd e2e && npm install ../context-compression-engine-*.tgz && npm test", "test:e2e:cleanup": "rm -f context-compression-engine-*.tgz && rm -rf e2e/node_modules && rm -f e2e/package-lock.json", "test:e2e:published": "cd e2e && npm install context-compression-engine && npm test", - "prepublishOnly": "npm test && tsc" + "prepublishOnly": "npm test && tsc", + "demo:build": "node demo/build.mjs", + "demo": "npm run demo:build && npx serve demo" }, "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -61,6 +63,7 @@ "@arethetypeswrong/cli": "^0.18.2", "@eslint/js": "^10.0.1", "@vitest/coverage-v8": "^4.0.18", + "esbuild": "^0.27.3", "eslint": "^10.0.2", "openai": "^6.25.0", "prettier": "^3.8.1",