@aperdomoll90/ledger-ai 1.0.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/README.md +120 -0
- package/dist/cli.js +153 -0
- package/dist/commands/backup.js +89 -0
- package/dist/commands/check.js +79 -0
- package/dist/commands/config.js +115 -0
- package/dist/commands/export.js +21 -0
- package/dist/commands/ingest.js +221 -0
- package/dist/commands/init.js +142 -0
- package/dist/commands/onboard.js +190 -0
- package/dist/commands/pull.js +75 -0
- package/dist/commands/push.js +21 -0
- package/dist/commands/restore.js +72 -0
- package/dist/commands/setup.js +159 -0
- package/dist/commands/show.js +34 -0
- package/dist/hooks/block-env.sh +54 -0
- package/dist/hooks/hooks/block-env.sh +54 -0
- package/dist/hooks/hooks/post-write-ledger.sh +40 -0
- package/dist/hooks/hooks/session-end-check.sh +23 -0
- package/dist/hooks/post-write-ledger.sh +40 -0
- package/dist/hooks/session-end-check.sh +23 -0
- package/dist/lib/config.js +63 -0
- package/dist/lib/errors.js +23 -0
- package/dist/lib/generators.js +115 -0
- package/dist/lib/hash.js +4 -0
- package/dist/lib/migrate.js +23 -0
- package/dist/lib/notes.js +105 -0
- package/dist/lib/prompt.js +65 -0
- package/dist/mcp-server.js +348 -0
- package/dist/migrations/000-tracking.sql +4 -0
- package/dist/migrations/001-schema.sql +27 -0
- package/dist/migrations/002-functions.sql +14 -0
- package/dist/migrations/003-rls.sql +5 -0
- package/dist/migrations/migrations/000-tracking.sql +4 -0
- package/dist/migrations/migrations/001-schema.sql +27 -0
- package/dist/migrations/migrations/002-functions.sql +14 -0
- package/dist/migrations/migrations/003-rls.sql +5 -0
- package/package.json +60 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA extensions;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS notes (
|
|
4
|
+
id bigserial PRIMARY KEY,
|
|
5
|
+
content text NOT NULL,
|
|
6
|
+
metadata jsonb DEFAULT '{}',
|
|
7
|
+
embedding vector(1536),
|
|
8
|
+
created_at timestamptz DEFAULT now(),
|
|
9
|
+
updated_at timestamptz DEFAULT now()
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE OR REPLACE FUNCTION update_updated_at()
|
|
13
|
+
RETURNS TRIGGER AS $$
|
|
14
|
+
BEGIN
|
|
15
|
+
NEW.updated_at = now();
|
|
16
|
+
RETURN NEW;
|
|
17
|
+
END;
|
|
18
|
+
$$ LANGUAGE plpgsql;
|
|
19
|
+
|
|
20
|
+
DROP TRIGGER IF EXISTS notes_updated_at ON notes;
|
|
21
|
+
CREATE TRIGGER notes_updated_at
|
|
22
|
+
BEFORE UPDATE ON notes
|
|
23
|
+
FOR EACH ROW
|
|
24
|
+
EXECUTE FUNCTION update_updated_at();
|
|
25
|
+
|
|
26
|
+
CREATE INDEX IF NOT EXISTS notes_embedding_idx
|
|
27
|
+
ON notes USING hnsw (embedding vector_cosine_ops);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CREATE OR REPLACE FUNCTION match_notes(
|
|
2
|
+
q_emb text,
|
|
3
|
+
threshold double precision DEFAULT 0.5,
|
|
4
|
+
max_results integer DEFAULT 10
|
|
5
|
+
)
|
|
6
|
+
RETURNS TABLE(id bigint, content text, metadata jsonb, similarity double precision)
|
|
7
|
+
LANGUAGE sql STABLE AS $$
|
|
8
|
+
SELECT notes.id, notes.content, notes.metadata,
|
|
9
|
+
1 - (notes.embedding <=> q_emb::vector) AS similarity
|
|
10
|
+
FROM notes
|
|
11
|
+
WHERE 1 - (notes.embedding <=> q_emb::vector) > threshold
|
|
12
|
+
ORDER BY notes.embedding <=> q_emb::vector
|
|
13
|
+
LIMIT least(max_results, 200)
|
|
14
|
+
$$;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE notes ENABLE ROW LEVEL SECURITY;
|
|
2
|
+
DROP POLICY IF EXISTS "service_role_all" ON notes;
|
|
3
|
+
DROP POLICY IF EXISTS "anon_read_only" ON notes;
|
|
4
|
+
-- Service role bypasses RLS (Supabase built-in). No policies needed.
|
|
5
|
+
-- Anon key is locked out: RLS enabled + no matching policy = deny all.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA extensions;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS notes (
|
|
4
|
+
id bigserial PRIMARY KEY,
|
|
5
|
+
content text NOT NULL,
|
|
6
|
+
metadata jsonb DEFAULT '{}',
|
|
7
|
+
embedding vector(1536),
|
|
8
|
+
created_at timestamptz DEFAULT now(),
|
|
9
|
+
updated_at timestamptz DEFAULT now()
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE OR REPLACE FUNCTION update_updated_at()
|
|
13
|
+
RETURNS TRIGGER AS $$
|
|
14
|
+
BEGIN
|
|
15
|
+
NEW.updated_at = now();
|
|
16
|
+
RETURN NEW;
|
|
17
|
+
END;
|
|
18
|
+
$$ LANGUAGE plpgsql;
|
|
19
|
+
|
|
20
|
+
DROP TRIGGER IF EXISTS notes_updated_at ON notes;
|
|
21
|
+
CREATE TRIGGER notes_updated_at
|
|
22
|
+
BEFORE UPDATE ON notes
|
|
23
|
+
FOR EACH ROW
|
|
24
|
+
EXECUTE FUNCTION update_updated_at();
|
|
25
|
+
|
|
26
|
+
CREATE INDEX IF NOT EXISTS notes_embedding_idx
|
|
27
|
+
ON notes USING hnsw (embedding vector_cosine_ops);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CREATE OR REPLACE FUNCTION match_notes(
|
|
2
|
+
q_emb text,
|
|
3
|
+
threshold double precision DEFAULT 0.5,
|
|
4
|
+
max_results integer DEFAULT 10
|
|
5
|
+
)
|
|
6
|
+
RETURNS TABLE(id bigint, content text, metadata jsonb, similarity double precision)
|
|
7
|
+
LANGUAGE sql STABLE AS $$
|
|
8
|
+
SELECT notes.id, notes.content, notes.metadata,
|
|
9
|
+
1 - (notes.embedding <=> q_emb::vector) AS similarity
|
|
10
|
+
FROM notes
|
|
11
|
+
WHERE 1 - (notes.embedding <=> q_emb::vector) > threshold
|
|
12
|
+
ORDER BY notes.embedding <=> q_emb::vector
|
|
13
|
+
LIMIT least(max_results, 200)
|
|
14
|
+
$$;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE notes ENABLE ROW LEVEL SECURITY;
|
|
2
|
+
DROP POLICY IF EXISTS "service_role_all" ON notes;
|
|
3
|
+
DROP POLICY IF EXISTS "anon_read_only" ON notes;
|
|
4
|
+
-- Service role bypasses RLS (Supabase built-in). No policies needed.
|
|
5
|
+
-- Anon key is locked out: RLS enabled + no matching policy = deny all.
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aperdomoll90/ledger-ai",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI identity and memory system — portable persona, knowledge sync, semantic search across agents and devices",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ledger": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**/*.js",
|
|
11
|
+
"dist/**/*.d.ts",
|
|
12
|
+
"dist/migrations/**/*.sql",
|
|
13
|
+
"dist/hooks/**/*.sh"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"start": "tsx src/mcp-server.ts",
|
|
17
|
+
"build": "tsc && cp -r src/migrations dist/migrations && cp -r src/hooks dist/hooks && chmod +x dist/cli.js dist/hooks/*.sh",
|
|
18
|
+
"prepublishOnly": "npm run build && npm test",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ai",
|
|
25
|
+
"memory",
|
|
26
|
+
"knowledge-base",
|
|
27
|
+
"rag",
|
|
28
|
+
"semantic-search",
|
|
29
|
+
"mcp",
|
|
30
|
+
"supabase",
|
|
31
|
+
"pgvector",
|
|
32
|
+
"claude",
|
|
33
|
+
"agent",
|
|
34
|
+
"persona",
|
|
35
|
+
"sync"
|
|
36
|
+
],
|
|
37
|
+
"author": "Adrian Perdomo",
|
|
38
|
+
"license": "ISC",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/aperdomoll90/ledger"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
48
|
+
"@supabase/supabase-js": "^2.99.1",
|
|
49
|
+
"commander": "^14.0.3",
|
|
50
|
+
"dotenv": "^17.3.1",
|
|
51
|
+
"openai": "^6.29.0",
|
|
52
|
+
"zod": "^4.3.6"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^25.5.0",
|
|
56
|
+
"tsx": "^4.21.0",
|
|
57
|
+
"typescript": "^5.9.3",
|
|
58
|
+
"vitest": "^4.1.0"
|
|
59
|
+
}
|
|
60
|
+
}
|