lakonai 0.16.0 → 0.16.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 +25 -21
- package/bin/lakonai.js +9 -5
- package/package.json +1 -1
- package/src/mem-llm.js +11 -8
package/README.md
CHANGED
|
@@ -77,43 +77,47 @@ Two extras worth knowing:
|
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
80
|
-
## Output savings:
|
|
80
|
+
## Output savings: the rule trims the model's prose too
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
The input side (filtered shell output, blocked reads, compressed catalogs) is
|
|
83
|
+
deterministic. But the terse rule also makes the **model itself** write less.
|
|
84
|
+
`lakonai gain` measures it by running the same prompts through your local AI CLI
|
|
85
|
+
twice - once rule-free, once with the terse rule as a system prompt - and
|
|
86
|
+
comparing output tokens.
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
| a **raw, verbose** model (Gemini default) | **~70%** | as strong as any terse-prompt tool |
|
|
88
|
-
| **Claude Code** - already concise by design | **~10% more** | the hard case: trimming what's already trimmed |
|
|
88
|
+
On a rule-free Claude baseline, explain / how-do-I / write-a-function prompts run
|
|
89
|
+
**~52% leaner** with the rule (1332 → 634 tokens across 4 prompts).
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
the only variable is how much fat the model started with._
|
|
91
|
+
Read that as a **best case on prose turns**, not your day-to-day average:
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
- it's a small, fixed corpus of chatty prompts - exactly where preamble balloons;
|
|
94
|
+
- model output varies run to run (the figure is a single weekly sample, not an average);
|
|
95
|
+
- agentic turns (code edits, tool calls, diffs) are mostly code, not prose, so the
|
|
96
|
+
rule trims far less there.
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
Your real workload lands somewhere between the deterministic **input** savings
|
|
99
|
+
(~46%) and this prose ceiling, pulled down by however much of your work is
|
|
100
|
+
code and tooling rather than explanation.
|
|
101
|
+
|
|
102
|
+
> `lakonai gain` shows both: the measured, deterministic input number and the
|
|
103
|
+
> estimated output number - labelled as an estimate, never inflated into a headline.
|
|
100
104
|
|
|
101
105
|
---
|
|
102
106
|
|
|
103
107
|
## See your savings
|
|
104
108
|
|
|
105
109
|
```
|
|
106
|
-
lakonai - saved
|
|
110
|
+
lakonai - saved 196.8k tok (46% smaller) across 1910 commands
|
|
107
111
|
|
|
108
|
-
today
|
|
109
|
-
this week
|
|
112
|
+
today 984 tok saved (17%)
|
|
113
|
+
this week 124.5k tok saved (57%)
|
|
110
114
|
|
|
111
|
-
top:
|
|
115
|
+
top: grep 55.3k · tail 55.1k · Read 34.3k · git 23.4k · cat 15.2k
|
|
112
116
|
|
|
113
|
-
output (terse rule): ~
|
|
117
|
+
output (terse rule): ~52% fewer tokens (1332 → 634, 4 prompts) [claude]
|
|
114
118
|
```
|
|
115
119
|
|
|
116
|
-
Input is measured & deterministic; output is
|
|
120
|
+
Input is measured & deterministic; output is estimated by your local AI CLI (no key,
|
|
117
121
|
weekly, at a TTY only). Both sides, one number.
|
|
118
122
|
|
|
119
123
|
---
|
package/bin/lakonai.js
CHANGED
|
@@ -156,20 +156,24 @@ async function maybeRefreshOutputBench() {
|
|
|
156
156
|
process.stderr.write(
|
|
157
157
|
`measuring output savings with ${provider.bin} (one-off, ~a minute, no API key)…\n`
|
|
158
158
|
);
|
|
159
|
-
//
|
|
160
|
-
//
|
|
159
|
+
// Both arms run rule-free (so the CLI's own config doesn't auto-load the
|
|
160
|
+
// installed terse rule and pollute the baseline) from an empty cwd (so no
|
|
161
|
+
// project CLAUDE.md leaks in). The terse arm differs ONLY by the rule appended
|
|
162
|
+
// as a system prompt. Auth stays on the real Keychain credential — see
|
|
163
|
+
// callAgent's ruleFree note for why we don't redirect the config dir.
|
|
161
164
|
const fs = require('fs');
|
|
162
165
|
const os = require('os');
|
|
163
166
|
const path = require('path');
|
|
164
|
-
const
|
|
167
|
+
const emptyCwd = fs.mkdtempSync(path.join(os.tmpdir(), 'lakon-bench-'));
|
|
165
168
|
let res;
|
|
166
169
|
try {
|
|
167
170
|
res = ob.measure({
|
|
168
|
-
call: (p, system) =>
|
|
171
|
+
call: (p, system) =>
|
|
172
|
+
llm.callAgent(p, { provider, systemPrompt: system, ruleFree: true, cwd: emptyCwd }),
|
|
169
173
|
});
|
|
170
174
|
} finally {
|
|
171
175
|
try {
|
|
172
|
-
fs.rmSync(
|
|
176
|
+
fs.rmSync(emptyCwd, { recursive: true, force: true });
|
|
173
177
|
} catch {
|
|
174
178
|
/* temp dir cleanup is best-effort */
|
|
175
179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lakonai",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.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",
|
package/src/mem-llm.js
CHANGED
|
@@ -20,7 +20,7 @@ const { spawnSync } = require('child_process');
|
|
|
20
20
|
// so they cannot drive compression directly — a user on those platforms relies on
|
|
21
21
|
// whichever of the CLIs below they also have installed.
|
|
22
22
|
const PROVIDERS = [
|
|
23
|
-
{ id: 'claude', platform: 'Claude Code', bin: 'claude', stdin: true, args: () => ['--print'], modelFlag: '--model', systemFlag: '--append-system-prompt',
|
|
23
|
+
{ id: 'claude', platform: 'Claude Code', bin: 'claude', stdin: true, args: () => ['--print'], modelFlag: '--model', systemFlag: '--append-system-prompt', ruleFreeArgs: ['--setting-sources', 'project'] },
|
|
24
24
|
{ id: 'gemini', platform: 'Gemini CLI', bin: 'gemini', stdin: false, args: (p) => ['-p', p], modelFlag: '-m' },
|
|
25
25
|
{ id: 'codex', platform: 'Codex', bin: 'codex', stdin: true, args: () => ['exec', '-'], modelFlag: '-m' },
|
|
26
26
|
{ id: 'cursor', platform: 'Cursor', bin: 'cursor-agent', stdin: false, args: (p) => ['-p', p], modelFlag: '--model' },
|
|
@@ -113,7 +113,7 @@ ${compressed}`;
|
|
|
113
113
|
// Run the chosen agent CLI in non-interactive mode. `run` is injectable for tests
|
|
114
114
|
// (production: spawnSync). Throws a clear error when the CLI is missing or returns
|
|
115
115
|
// non-zero so the caller can surface it.
|
|
116
|
-
function callAgent(prompt, { run = spawnSync, provider, model = process.env.LAKONAI_MEM_MODEL, systemPrompt,
|
|
116
|
+
function callAgent(prompt, { run = spawnSync, provider, model = process.env.LAKONAI_MEM_MODEL, systemPrompt, ruleFree, cwd } = {}) {
|
|
117
117
|
const p = provider || pickProvider();
|
|
118
118
|
// Prefer the CLI's real system-prompt flag (stronger behavioral effect); fall
|
|
119
119
|
// back to prepending it to the prompt when the CLI has no such flag.
|
|
@@ -122,13 +122,16 @@ function callAgent(prompt, { run = spawnSync, provider, model = process.env.LAKO
|
|
|
122
122
|
const args = p.args(effective);
|
|
123
123
|
if (model && p.modelFlag) args.push(p.modelFlag, model);
|
|
124
124
|
if (useFlag) args.push(p.systemFlag, systemPrompt);
|
|
125
|
-
// For a clean benchmark baseline:
|
|
126
|
-
//
|
|
127
|
-
// the
|
|
125
|
+
// For a clean benchmark baseline: stop the CLI auto-loading the installed rule
|
|
126
|
+
// (e.g. ~/.claude/CLAUDE.md) so the "no rule" arm is truly rule-free. We do this
|
|
127
|
+
// via the CLI's own flag (claude: --setting-sources project, dropping the `user`
|
|
128
|
+
// source) — NOT by redirecting the config dir, which on macOS switches the CLI to
|
|
129
|
+
// file-based auth and leaves it "Not logged in" (the credential lives in the
|
|
130
|
+
// Keychain, keyed to the default config dir). Pair it with an empty `cwd` so no
|
|
131
|
+
// project CLAUDE.md leaks in either.
|
|
132
|
+
if (ruleFree && p.ruleFreeArgs) args.push(...p.ruleFreeArgs);
|
|
128
133
|
const opts = { input: p.stdin ? effective : undefined, encoding: 'utf8', maxBuffer: 8 * 1024 * 1024 };
|
|
129
|
-
if (
|
|
130
|
-
opts.env = { ...process.env, [p.cleanEnvVar]: cleanConfigDir };
|
|
131
|
-
}
|
|
134
|
+
if (cwd) opts.cwd = cwd;
|
|
132
135
|
const res = run(p.bin, args, opts);
|
|
133
136
|
if (res.error) {
|
|
134
137
|
if (res.error.code === 'ENOENT') {
|