lakonai 1.2.0 → 1.2.2

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/README.md CHANGED
@@ -7,18 +7,26 @@
7
7
  <h3 align="center">Speak less. Ship more.</h3>
8
8
 
9
9
  <p align="center">
10
- <strong>Cut LLM tokens by up to 94% — without losing a single identifier.</strong>
10
+ <strong>Cut LLM tokens by up to 99.8% — without losing a single identifier.</strong><br/>
11
+ <sub>A 182k-line <code>git diff</code> went <strong>1,513,910 → 2,331 tokens</strong>. Measured, not rounded.</sub>
11
12
  </p>
12
13
 
13
14
  <p align="center"><em>Spartan replies for AI agents.</em></p>
14
15
 
15
16
  <p align="center">
16
17
  <a href="https://www.npmjs.com/package/lakonai"><img src="https://img.shields.io/npm/v/lakonai?color=0F0F0F&label=npm" alt="npm" /></a>
18
+ <a href="https://github.com/bargadev/lakonai"><img src="https://img.shields.io/badge/GitHub-bargadev%2Flakonai-0F0F0F?logo=github" alt="GitHub repo" /></a>
17
19
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-0F0F0F" alt="MIT" /></a>
18
20
  <img src="https://img.shields.io/badge/node-%E2%89%A518-0F0F0F" alt="node ≥18" />
19
21
  <img src="https://img.shields.io/badge/deps-0-0F0F0F" alt="zero dependencies" />
20
22
  <img src="https://img.shields.io/badge/agents-6-0F0F0F" alt="6 AI agents" />
21
- <img src="https://img.shields.io/badge/tests-725-0F0F0F" alt="725 tests" />
23
+ <img src="https://img.shields.io/badge/tests-751-0F0F0F" alt="751 tests" />
24
+ </p>
25
+
26
+ <p align="center">
27
+ <a href="https://github.com/bargadev/lakonai">
28
+ <img src="./docs/assets/before-after.svg" width="820" alt="lakonai: a 182k-line git diff main…HEAD went 1,513,910 → 2,331 tokens (−99.8%), structure and identifiers intact" />
29
+ </a>
22
30
  </p>
23
31
 
24
32
  <p align="center">
@@ -286,14 +294,14 @@ Input is measured and deterministic. Output is estimated by your local AI CLI (n
286
294
 
287
295
  ## Test suite
288
296
 
289
- 725 tests across 47 suites — all passing, no mocks on I/O boundaries.
297
+ 751 tests across 48 suites — all passing, no mocks on I/O boundaries.
290
298
 
291
299
  | Type | Suites | Tests |
292
300
  |------|--------|-------|
293
- | Unit | 13 | 183 |
294
- | Integration (module + real FS) | 31 | 489 |
295
- | E2E / CLI (spawn + real process) | 3 | 53 |
296
- | **Total** | **47** | **725** |
301
+ | Unit | 13 | 170 |
302
+ | Integration (module + real FS) | 33 | 530 |
303
+ | E2E / CLI (spawn + real process) | 2 | 51 |
304
+ | **Total** | **48** | **751** |
297
305
 
298
306
  Coverage: **95% statements · 89% branches · 97% functions**
299
307
 
@@ -311,12 +319,17 @@ Your AI agent isn't laconic. It opens with _"Sure! I'd be happy to help…"_, re
311
319
 
312
320
  ## Credits
313
321
 
314
- Built on ideas from three projects:
322
+ lakonai is an original, zero-dependency tool written from scratch. Several of its
323
+ layers were **inspired by** prior art — none of it is vendored or forked, and the
324
+ compression engine, auto-learning, read-guard, overflow sandbox, and BM25 graph
325
+ query are lakonai's own:
315
326
 
316
- - [**caveman**](https://github.com/juliusbrussee/caveman) (MIT) — terse rule, auto-clarity, proxy compression, pixel mode
317
- - [**graphify**](https://github.com/Bklieger/graphify) — AST knowledge graph, Leiden community detection, force-directed viz, NL query (reimplemented in Node.js; BM25 replaces LLM query)
318
- - [**rtk**](https://github.com/rtk-ai/rtk) — CLI output filtering approach, extended with auto-learning and 30+ built-in filters
327
+ - [**caveman**](https://github.com/juliusbrussee/caveman) (MIT) — inspired the terse-response rule, auto-clarity, and pixel skill mode
328
+ - [**graphify**](https://github.com/Bklieger/graphify) — inspired the AST knowledge graph and community detection; lakonai reimplements it in Node.js and drops the LLM at query time for zero-cost BM25
329
+ - [**rtk**](https://github.com/rtk-ai/rtk) — inspired the CLI-filtering approach; lakonai goes further with auto-learning and 30+ built-in filters
319
330
 
320
- Condensed into one zero-dependency npm package with automatic install, savings tracking, and four layers of compression.
331
+ Where an idea carries a license (caveman is MIT), credit stays. Everything else —
332
+ the declarative filter engine, the hook dispatch, savings tracking, and the four
333
+ layers of compression — is built here.
321
334
 
322
335
  MIT — see [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lakonai",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "lakonai — save AI context tokens. Filters & compresses CLI output (git, ls, grep, find, test runners, lint/build, docker/kubectl/aws) before it reaches Claude Code, Codex, Cursor, Windsurf, Cline or Gemini — and learns to filter new commands automatically the more you use it.",
5
5
  "keywords": [
6
6
  "claude",
@@ -83,6 +83,19 @@ function entryHasHook(entry, basename) {
83
83
  return entry.hooks.some((h) => h && typeof h.command === 'string' && h.command.includes(basename));
84
84
  }
85
85
 
86
+ // Build the hook command string for settings.json.
87
+ // On Windows, Claude Code executes "command" hooks through bash (Git Bash),
88
+ // which strips backslashes ("C:\Users\...\x.js" -> "C:Users...x.js" -> command
89
+ // not found) and cannot exec a .js by path. Use `node` with a forward-slash
90
+ // path, which works in bash and node accepts on Windows. On POSIX the executable
91
+ // hook file (shebang + chmod 0755) runs directly.
92
+ function hookCommand(dest) {
93
+ if (process.platform === 'win32') {
94
+ return `node "${dest.split(path.sep).join('/')}"`;
95
+ }
96
+ return dest;
97
+ }
98
+
86
99
  function mergeHook(data, hookDef, dest) {
87
100
  /* istanbul ignore next */
88
101
  const eventKey = hookDef.event || 'PreToolUse';
@@ -95,12 +108,12 @@ function mergeHook(data, hookDef, dest) {
95
108
  if (!entryHasHook(existing, hookDef.basename)) {
96
109
  /* istanbul ignore next */
97
110
  existing.hooks = existing.hooks || [];
98
- existing.hooks.push({ type: 'command', command: dest });
111
+ existing.hooks.push({ type: 'command', command: hookCommand(dest) });
99
112
  }
100
113
  } else {
101
114
  data.hooks[eventKey].push({
102
115
  matcher: hookDef.matcher,
103
- hooks: [{ type: 'command', command: dest }],
116
+ hooks: [{ type: 'command', command: hookCommand(dest) }],
104
117
  });
105
118
  }
106
119
  } else {
@@ -109,7 +122,7 @@ function mergeHook(data, hookDef, dest) {
109
122
  );
110
123
  if (!existing) {
111
124
  data.hooks[eventKey].push({
112
- hooks: [{ type: 'command', command: dest }],
125
+ hooks: [{ type: 'command', command: hookCommand(dest) }],
113
126
  });
114
127
  }
115
128
  }