lakonai 0.16.0 → 0.16.1
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/bin/lakonai.js +9 -5
- package/package.json +1 -1
- package/src/mem-llm.js +11 -8
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.1",
|
|
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') {
|