lakonai 1.0.1 → 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/README.md +1 -1
- package/bin/lakonai.js +7 -1
- package/package.json +1 -1
- package/src/hooks/session-start.js +46 -0
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ lakonai ls -la # → files without noise
|
|
|
99
99
|
|
|
100
100
|
### Layer 2 — Graph read-guard (Claude Code)
|
|
101
101
|
|
|
102
|
-
`lakonai graph build` parses your codebase into an AST knowledge graph —
|
|
102
|
+
`lakonai graph build` parses your codebase into an AST knowledge graph — pure AST, works in under a second for most projects. When Claude Code reads a source file, the read-guard intercepts and returns a compact subgraph (symbols, edges, community) instead of the full text. Semantic search optionally calls an LLM once per file to generate docblocks (cached; see below).
|
|
103
103
|
|
|
104
104
|
```
|
|
105
105
|
102 files → 512 nodes → 573 edges built in <0.1s
|
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 = {
|