lakonai 0.13.0 → 0.14.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/README.md +19 -18
- package/bin/lakonai.js +10 -0
- package/package.json +1 -1
- package/src/shim-guard.js +34 -0
package/README.md
CHANGED
|
@@ -317,28 +317,29 @@ Each profile gets its own independent install. `lakonai uninstall` / `lakonai re
|
|
|
317
317
|
|
|
318
318
|
### What each agent actually gets (honest capability matrix)
|
|
319
319
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
|
330
|
-
|
|
|
331
|
-
|
|
|
332
|
-
|
|
|
333
|
-
|
|
|
334
|
-
|
|
|
320
|
+
Once you run `lakonai shim` (see above), the **shell-mediated** features are
|
|
321
|
+
automatic on every agent — they work at the PATH level, no hook API and no model
|
|
322
|
+
cooperation needed. **Shell filtering** routes every wrapped command through
|
|
323
|
+
lakonai, and the **Read-guard** refuses junk reads done via the shell
|
|
324
|
+
(`cat pnpm-lock.yaml`, `head node_modules/…`). What the shim *can't* see is an
|
|
325
|
+
agent's own non-shell Read tool and its full command stream — guarding that tool
|
|
326
|
+
and auto-learning need a call-rewriting hook, which today only Claude Code
|
|
327
|
+
exposes. Honest matrix:
|
|
328
|
+
|
|
329
|
+
| Agent | Terse rule | Shell filter | Read/Grep guard | Auto-learning |
|
|
330
|
+
| ----------- | :--------: | -------------------- | --------------------- | :-----------: |
|
|
331
|
+
| Claude Code | ✅ | ✅ automatic (hook) | ✅ tool + shell | ✅ |
|
|
332
|
+
| Codex CLI | ✅ | ✅ automatic (shim¹) | ✅ shell reads (shim²) | ❌³ |
|
|
333
|
+
| Cursor | ✅ | ✅ automatic (shim¹) | ✅ shell reads (shim²) | ❌³ |
|
|
334
|
+
| Windsurf | ✅ | ✅ automatic (shim¹) | ✅ shell reads (shim²) | ❌³ |
|
|
335
|
+
| Cline | ✅ | ✅ automatic (shim¹) | ✅ shell reads (shim²) | ❌³ |
|
|
336
|
+
| Gemini CLI | ✅ | ✅ automatic (shim¹) | ✅ shell reads (shim²) | ❌³ |
|
|
335
337
|
|
|
336
338
|
Run `lakonai doctor` to see, per platform, what's actually active on your machine.
|
|
337
339
|
|
|
338
340
|
¹ `lakonai shim` prepends `~/.lakon/shim` to PATH so `ls`/`grep`/`rg`/`ag`/`find`/`cat`/`tree`/`head` filter automatically for any agent that runs them through a shell (opt-in — it edits your shell rc; `git` is excluded for safety). Without it, those commands filter only when the model prefixes `lakonai` itself.
|
|
339
|
-
²
|
|
340
|
-
³
|
|
341
|
-
⁴ Gemini's `BeforeTool` hook *can* rewrite/cap a tool call; a Gemini guard installer is planned but not shipped (needs validation against the real CLI schema).
|
|
341
|
+
² The shim refuses junk reads (lockfiles, `node_modules/…`, build artifacts) done through the shell with `cat`/`head`/`tail`/`less` — same deny rules as the Claude Read hook. An agent's *own* internal Read tool (not via the shell) still needs a hook, so capping/blocking it is automatic only on Claude Code. Codex's hook [can't yet rewrite a tool call](https://github.com/openai/codex/issues/18491); Cursor's can deny but not cap; Gemini's `BeforeTool` could (installer planned, pending schema validation against the real CLI).
|
|
342
|
+
³ Auto-learning needs to observe the agent's full command stream (an end-of-turn hook), so it's Claude-Code-only — and largely moot elsewhere, since the shim already filters the standard heavy commands without needing to learn them.
|
|
342
343
|
|
|
343
344
|
¹ "Claude Code" covers **every** Claude Code frontend — terminal CLI, VS Code extension, JetBrains plugin, desktop app. All read the same `~/.claude/CLAUDE.md` + `~/.claude/settings.json`, so one install lights up all of them.
|
|
344
345
|
|
package/bin/lakonai.js
CHANGED
|
@@ -63,6 +63,16 @@ Update notifications:
|
|
|
63
63
|
`;
|
|
64
64
|
|
|
65
65
|
function runAndFilter(cmd, args) {
|
|
66
|
+
// Universal Read-guard: refuse junk reads (lockfiles/node_modules) done via the
|
|
67
|
+
// shell (`cat pnpm-lock.yaml`) on ANY agent that uses the shim — same deny rules
|
|
68
|
+
// as the Claude Read hook, no platform hook required.
|
|
69
|
+
const denied = require('../src/shim-guard').check(cmd, args);
|
|
70
|
+
if (denied) {
|
|
71
|
+
process.stdout.write(`lakonai: skipped ${denied.path} — ${denied.reason}\n`);
|
|
72
|
+
tracking.record({ cmd, args, rawTokens: 0, filteredTokens: 0 });
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
|
|
66
76
|
const merge = needsStderr(cmd, args);
|
|
67
77
|
const stdio = merge ? ['inherit', 'pipe', 'pipe'] : ['inherit', 'pipe', 'inherit'];
|
|
68
78
|
// Strip the shim dir from PATH so spawning `cmd` resolves the real system
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lakonai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
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",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Universal Read-guard for the shell path. The Read-guard hook only fires on
|
|
4
|
+
// Claude Code's Read tool, but EVERY agent reads files through the shell too
|
|
5
|
+
// (`cat pnpm-lock.yaml`, `head node_modules/...`). Those go through the shim →
|
|
6
|
+
// `lakonai cat ...`, so we can refuse junk reads here and the protection becomes
|
|
7
|
+
// automatic on every agent that uses the shim — no per-platform hook needed.
|
|
8
|
+
//
|
|
9
|
+
// Reuses the exact deny rules from the Claude Read-guard so behaviour matches.
|
|
10
|
+
|
|
11
|
+
const { isDeniedPath } = require('./hooks/read-guard');
|
|
12
|
+
|
|
13
|
+
// Commands whose non-flag arguments are file paths we should guard.
|
|
14
|
+
const READ_CMDS = new Set(['cat', 'head', 'tail', 'less', 'more', 'bat']);
|
|
15
|
+
|
|
16
|
+
// Return { path, reason } for the first denied path argument, or null. Args that
|
|
17
|
+
// start with `-` are flags; `--` ends option parsing.
|
|
18
|
+
function check(cmd, args) {
|
|
19
|
+
if (!READ_CMDS.has(cmd) || !Array.isArray(args)) return null;
|
|
20
|
+
let optsEnded = false;
|
|
21
|
+
for (const a of args) {
|
|
22
|
+
if (typeof a !== 'string') continue;
|
|
23
|
+
if (!optsEnded && a === '--') {
|
|
24
|
+
optsEnded = true;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (!optsEnded && a.startsWith('-')) continue; // flag (e.g. -n, -20)
|
|
28
|
+
const reason = isDeniedPath(a);
|
|
29
|
+
if (reason) return { path: a, reason };
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = { check, READ_CMDS };
|