lakonai 1.0.2 → 1.1.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 +7 -1
- package/package.json +1 -1
- package/src/hooks/session-start.js +46 -0
package/bin/lakonai.js
CHANGED
|
@@ -140,8 +140,14 @@ function runAndFilter(cmd, args) {
|
|
|
140
140
|
// binary, not the lakonai shim that may have invoked us (prevents recursion).
|
|
141
141
|
const { pathWithoutShim } = require('../src/install/shim');
|
|
142
142
|
const env = { ...process.env, PATH: pathWithoutShim(process.env) };
|
|
143
|
-
const child = spawnSync(cmd, args, { encoding: 'utf8', stdio, env });
|
|
143
|
+
const child = spawnSync(cmd, args, { encoding: 'utf8', stdio, env, maxBuffer: 200 * 1024 * 1024 });
|
|
144
144
|
if (child.error) {
|
|
145
|
+
/* istanbul ignore next -- requires >200 MB output to trigger; not unit-testable */
|
|
146
|
+
if (child.error.code === 'ENOBUFS') {
|
|
147
|
+
// Output exceeded maxBuffer — pass through raw so nothing is lost.
|
|
148
|
+
const fallback = spawnSync(cmd, args, { stdio: 'inherit', env });
|
|
149
|
+
process.exit(fallback.status ?? 0);
|
|
150
|
+
}
|
|
145
151
|
process.stderr.write(`lakonai: ${child.error.message}\n`);
|
|
146
152
|
process.exit(127);
|
|
147
153
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lakonai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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",
|
|
@@ -2,8 +2,40 @@
|
|
|
2
2
|
/* istanbul ignore file -- thin SessionStart I/O shell: stdin + version check */
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { execFileSync, spawn } = require('child_process');
|
|
5
8
|
const { checkForUpdate, formatNotice } = require('./version-check');
|
|
6
9
|
|
|
10
|
+
// Walk up from cwd to find the git root. Returns null if not in a git repo.
|
|
11
|
+
function findGitRoot(dir) {
|
|
12
|
+
let cur = dir;
|
|
13
|
+
while (true) {
|
|
14
|
+
if (fs.existsSync(path.join(cur, '.git'))) return cur;
|
|
15
|
+
const parent = path.dirname(cur);
|
|
16
|
+
if (parent === cur) return null;
|
|
17
|
+
cur = parent;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Trigger a background graph build and return a notice string.
|
|
22
|
+
// Fire-and-forget — never blocks the session start.
|
|
23
|
+
function triggerGraphBuild(gitRoot) {
|
|
24
|
+
try {
|
|
25
|
+
const lakonai = process.execPath === process.argv[0]
|
|
26
|
+
? 'lakonai'
|
|
27
|
+
: process.execPath;
|
|
28
|
+
spawn('lakonai', ['graph', 'build', gitRoot], {
|
|
29
|
+
detached: true,
|
|
30
|
+
stdio: 'ignore',
|
|
31
|
+
env: { ...process.env },
|
|
32
|
+
}).unref();
|
|
33
|
+
return `lakonai graph: new project detected — building graph for ${gitRoot} in background.\nRun \`lakonai graph query\` once done.`;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
7
39
|
/* istanbul ignore next */
|
|
8
40
|
async function readStdin() {
|
|
9
41
|
let raw = '';
|
|
@@ -28,6 +60,20 @@ async function main() {
|
|
|
28
60
|
if (summary) parts.push(`lakonai learn: ${summary}`);
|
|
29
61
|
} catch { /* best-effort */ }
|
|
30
62
|
|
|
63
|
+
// Auto-build graph for new git projects that don't have one yet.
|
|
64
|
+
if (!process.env.LAKON_NO_AUTO_GRAPH) {
|
|
65
|
+
try {
|
|
66
|
+
const gitRoot = findGitRoot(process.cwd());
|
|
67
|
+
if (gitRoot) {
|
|
68
|
+
const graphJson = path.join(gitRoot, 'lakonai-graph', 'graph.json');
|
|
69
|
+
if (!fs.existsSync(graphJson)) {
|
|
70
|
+
const notice = triggerGraphBuild(gitRoot);
|
|
71
|
+
if (notice) parts.push(notice);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch { /* best-effort */ }
|
|
75
|
+
}
|
|
76
|
+
|
|
31
77
|
if (!parts.length) process.exit(0);
|
|
32
78
|
|
|
33
79
|
const response = {
|