@a13xu/lucid 1.0.0 → 1.4.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/LICENSE +21 -21
- package/README.md +117 -99
- package/build/database.d.ts +19 -0
- package/build/database.js +91 -62
- package/build/guardian/checklist.d.ts +1 -0
- package/build/guardian/checklist.js +67 -0
- package/build/guardian/validator.d.ts +21 -0
- package/build/guardian/validator.js +332 -0
- package/build/index.js +142 -32
- package/build/indexer/file.d.ts +15 -0
- package/build/indexer/file.js +100 -0
- package/build/indexer/project.d.ts +8 -0
- package/build/indexer/project.js +312 -0
- package/build/store/content.d.ts +3 -0
- package/build/store/content.js +11 -0
- package/build/tools/grep.d.ts +17 -0
- package/build/tools/grep.js +65 -0
- package/build/tools/guardian.d.ts +21 -0
- package/build/tools/guardian.js +58 -0
- package/build/tools/init.d.ts +11 -0
- package/build/tools/init.js +110 -0
- package/build/tools/sync.d.ts +18 -0
- package/build/tools/sync.js +61 -0
- package/package.json +48 -48
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { resolve, extname } from "path";
|
|
3
|
+
import { existsSync, readFileSync } from "fs";
|
|
4
|
+
import { indexFile, upsertFileIndex } from "../indexer/file.js";
|
|
5
|
+
import { indexProject } from "../indexer/project.js";
|
|
6
|
+
const SUPPORTED_EXTS = new Set([".ts", ".tsx", ".js", ".jsx", ".py", ".go", ".rs"]);
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// sync_file
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
export const SyncFileSchema = z.object({
|
|
11
|
+
path: z.string().min(1),
|
|
12
|
+
});
|
|
13
|
+
export function handleSyncFile(stmts, args) {
|
|
14
|
+
const filepath = resolve(args.path);
|
|
15
|
+
if (!existsSync(filepath))
|
|
16
|
+
return `File not found: ${filepath}`;
|
|
17
|
+
if (!SUPPORTED_EXTS.has(extname(filepath).toLowerCase())) {
|
|
18
|
+
return `Unsupported file type: ${extname(filepath)}. Supported: ${[...SUPPORTED_EXTS].join(", ")}`;
|
|
19
|
+
}
|
|
20
|
+
const index = indexFile(filepath);
|
|
21
|
+
if (!index)
|
|
22
|
+
return `Could not read file: ${filepath}`;
|
|
23
|
+
const source = readFileSync(filepath, "utf-8");
|
|
24
|
+
const result = upsertFileIndex(index, source, stmts);
|
|
25
|
+
if (!result.stored) {
|
|
26
|
+
return `⏭️ Unchanged: ${filepath} (hash match — skipped)`;
|
|
27
|
+
}
|
|
28
|
+
const ratio = Math.round((1 - (result.savedBytes + Buffer.byteLength(source, "utf-8") - result.savedBytes) / Buffer.byteLength(source, "utf-8")) * 100);
|
|
29
|
+
const saved = Math.round(result.savedBytes / 1024 * 10) / 10;
|
|
30
|
+
const lines = [
|
|
31
|
+
`✅ Synced: ${filepath}`,
|
|
32
|
+
` exports: ${index.exports.join(", ") || "none"}`,
|
|
33
|
+
` compressed: saved ${saved}KB`,
|
|
34
|
+
];
|
|
35
|
+
if (index.description)
|
|
36
|
+
lines.push(` description: ${index.description}`);
|
|
37
|
+
if (index.todos.length > 0)
|
|
38
|
+
lines.push(` TODOs: ${index.todos.length} open`);
|
|
39
|
+
return lines.join("\n");
|
|
40
|
+
}
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// sync_project
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
export const SyncProjectSchema = z.object({
|
|
45
|
+
directory: z.string().optional(),
|
|
46
|
+
});
|
|
47
|
+
export function handleSyncProject(stmts, args) {
|
|
48
|
+
const dir = resolve(args.directory ?? process.cwd());
|
|
49
|
+
const results = indexProject(dir, stmts);
|
|
50
|
+
if (results.length === 0)
|
|
51
|
+
return `No changes indexed in: ${dir}`;
|
|
52
|
+
const stats = stmts.fileStorageStats.get();
|
|
53
|
+
const ratio = stats.total_original > 0
|
|
54
|
+
? Math.round((1 - stats.total_compressed / stats.total_original) * 100)
|
|
55
|
+
: 0;
|
|
56
|
+
return [
|
|
57
|
+
`✅ Project re-synced: ${dir}`,
|
|
58
|
+
` ${results.length} source(s) updated`,
|
|
59
|
+
` Storage: ${Math.round(stats.total_compressed / 1024)}KB compressed / ${Math.round(stats.total_original / 1024)}KB original (${ratio}% saved)`,
|
|
60
|
+
].join("\n");
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@a13xu/lucid",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Persistent memory for Claude Code agents — SQLite + FTS5 knowledge graph via MCP",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"lucid": "./build/index.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"build/**/*.js",
|
|
11
|
-
"build/**/*.d.ts",
|
|
12
|
-
"README.md"
|
|
13
|
-
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"prepublishOnly": "npm run build"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"mcp",
|
|
20
|
-
"claude",
|
|
21
|
-
"claude-code",
|
|
22
|
-
"memory",
|
|
23
|
-
"sqlite",
|
|
24
|
-
"knowledge-graph",
|
|
25
|
-
"ai",
|
|
26
|
-
"anthropic"
|
|
27
|
-
],
|
|
28
|
-
"author": "a13xu",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "https://github.com/a13xu/lucid.git"
|
|
33
|
-
},
|
|
34
|
-
"homepage": "https://github.com/a13xu/lucid#readme",
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=18"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
40
|
-
"better-sqlite3": "^11.0.0",
|
|
41
|
-
"zod": "^3.23.8"
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@types/better-sqlite3": "^7.6.11",
|
|
45
|
-
"@types/node": "^20.0.0",
|
|
46
|
-
"typescript": "^5.4.0"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@a13xu/lucid",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Persistent memory for Claude Code agents — SQLite + FTS5 knowledge graph via MCP",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"lucid": "./build/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"build/**/*.js",
|
|
11
|
+
"build/**/*.d.ts",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"mcp",
|
|
20
|
+
"claude",
|
|
21
|
+
"claude-code",
|
|
22
|
+
"memory",
|
|
23
|
+
"sqlite",
|
|
24
|
+
"knowledge-graph",
|
|
25
|
+
"ai",
|
|
26
|
+
"anthropic"
|
|
27
|
+
],
|
|
28
|
+
"author": "a13xu",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/a13xu/lucid.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/a13xu/lucid#readme",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
40
|
+
"better-sqlite3": "^11.0.0",
|
|
41
|
+
"zod": "^3.23.8"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
45
|
+
"@types/node": "^20.0.0",
|
|
46
|
+
"typescript": "^5.4.0"
|
|
47
|
+
}
|
|
48
|
+
}
|