knolo-core 0.1.0 → 0.1.2
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 +28 -19
- package/bin/knolo.mjs +60 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
2
3
|
# 🧠 KnoLo Core
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/knolo-core)
|
|
6
|
+
[](https://www.npmjs.com/package/knolo-core)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
|
|
9
|
+
**KnoLo Core** is a **local-first knowledge base system** for small language models (LLMs).
|
|
5
10
|
It lets you package your own documents into a compact `.knolo` file and query them deterministically — **no embeddings, no vector DBs, no cloud**. Perfect for **on-device LLMs**.
|
|
6
11
|
|
|
7
12
|
---
|
|
8
13
|
|
|
9
14
|
## ✨ Features
|
|
10
15
|
|
|
11
|
-
* 📦 **Single-file packs** (`.knolo`) you can ship or load offline
|
|
12
|
-
* 🔎 **Deterministic lexical retrieval** (BM25L + phrase + heading boosts)
|
|
13
|
-
* ⚡ **Tiny & fast** — runs in Node, browsers, and Expo
|
|
14
|
-
* 📑 **Context Patches**: structured snippets for
|
|
15
|
-
* 🔒 **Privacy-first**: all data stays local
|
|
16
|
+
* 📦 **Single-file packs** (`.knolo`) you can ship or load offline
|
|
17
|
+
* 🔎 **Deterministic lexical retrieval** (BM25L + phrase + heading boosts)
|
|
18
|
+
* ⚡ **Tiny & fast** — runs in Node, browsers, and Expo
|
|
19
|
+
* 📑 **Context Patches**: structured snippets optimized for LLM prompts
|
|
20
|
+
* 🔒 **Privacy-first**: all data stays local
|
|
16
21
|
|
|
17
22
|
---
|
|
18
23
|
|
|
19
24
|
## 📦 Install
|
|
20
25
|
|
|
21
26
|
```bash
|
|
22
|
-
|
|
27
|
+
npm install knolo-core
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For local development (building from source):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/yourname/knolo-core.git
|
|
34
|
+
cd knolo-core
|
|
23
35
|
npm install
|
|
24
36
|
npm run build
|
|
25
|
-
|
|
26
|
-
# or if published later
|
|
27
|
-
npm install @knolo/core
|
|
28
37
|
```
|
|
29
38
|
|
|
30
39
|
---
|
|
@@ -34,7 +43,7 @@ npm install @knolo/core
|
|
|
34
43
|
### 1. Node.js (in-memory build + query)
|
|
35
44
|
|
|
36
45
|
```js
|
|
37
|
-
import { buildPack, mountPack, query, makeContextPatch } from "
|
|
46
|
+
import { buildPack, mountPack, query, makeContextPatch } from "knolo-core";
|
|
38
47
|
|
|
39
48
|
const docs = [
|
|
40
49
|
{ heading: "React Native Bridge", text: "The bridge sends messages between JS and native. You can throttle events to reduce jank." },
|
|
@@ -74,13 +83,13 @@ console.log("Context Patch:", patch);
|
|
|
74
83
|
|
|
75
84
|
```bash
|
|
76
85
|
# writes mypack.knolo
|
|
77
|
-
|
|
86
|
+
npx knolo docs.json mypack.knolo
|
|
78
87
|
```
|
|
79
88
|
|
|
80
89
|
**Query it in a script:**
|
|
81
90
|
|
|
82
91
|
```js
|
|
83
|
-
import { mountPack, query } from "
|
|
92
|
+
import { mountPack, query } from "knolo-core";
|
|
84
93
|
|
|
85
94
|
const kb = await mountPack({ src: "./mypack.knolo" });
|
|
86
95
|
const hits = query(kb, "throttle events", { topK: 3 });
|
|
@@ -94,7 +103,7 @@ console.log(hits);
|
|
|
94
103
|
```ts
|
|
95
104
|
import { Asset } from "expo-asset";
|
|
96
105
|
import * as FileSystem from "expo-file-system";
|
|
97
|
-
import { mountPack, query, makeContextPatch } from "
|
|
106
|
+
import { mountPack, query, makeContextPatch } from "knolo-core";
|
|
98
107
|
|
|
99
108
|
async function loadKnowledge() {
|
|
100
109
|
const asset = Asset.fromModule(require("./assets/mypack.knolo"));
|
|
@@ -124,18 +133,18 @@ mountPack({ src: string | Uint8Array | ArrayBuffer }) -> Promise<Pack>
|
|
|
124
133
|
query(pack, "your query", { topK?: number, requirePhrases?: string[] }) -> Hit[]
|
|
125
134
|
|
|
126
135
|
// Create LLM-friendly patch
|
|
127
|
-
makeContextPatch(hits, { budget?: "mini"|"small"|"full" }) -> ContextPatch
|
|
136
|
+
makeContextPatch(hits, { budget?: "mini" | "small" | "full" }) -> ContextPatch
|
|
128
137
|
```
|
|
129
138
|
|
|
130
139
|
---
|
|
131
140
|
|
|
132
141
|
## 🔮 Roadmap
|
|
133
142
|
|
|
134
|
-
* Multi-resolution packs (summaries + facts)
|
|
135
|
-
* Overlay store for user notes
|
|
136
|
-
* WASM core for very large packs
|
|
143
|
+
* Multi-resolution packs (summaries + facts)
|
|
144
|
+
* Overlay store for user notes
|
|
145
|
+
* WASM core for very large packs
|
|
137
146
|
|
|
138
147
|
---
|
|
139
148
|
|
|
140
|
-
👉 With KnoLo
|
|
149
|
+
👉 With **KnoLo**, you can **carry knowledge with your model** — no servers, no dependencies, just a tiny portable pack.
|
|
141
150
|
|
package/bin/knolo.mjs
CHANGED
|
@@ -1,30 +1,69 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// Robust CLI that works with ESM or CJS builds and odd resolution cases.
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
10
11
|
|
|
11
|
-
async function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
async function tryImport(filePath) {
|
|
13
|
+
// 1) ESM via file URL
|
|
14
|
+
try {
|
|
15
|
+
const url = pathToFileURL(filePath).href;
|
|
16
|
+
return await import(url);
|
|
17
|
+
} catch (_) {}
|
|
18
|
+
// 2) CJS via require
|
|
19
|
+
try {
|
|
20
|
+
return require(filePath);
|
|
21
|
+
} catch (_) {}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getBuildPack(mod) {
|
|
26
|
+
if (!mod) return undefined;
|
|
27
|
+
// Named export (ESM)
|
|
28
|
+
if (typeof mod.buildPack === "function") return mod.buildPack;
|
|
29
|
+
// CJS default export object: { buildPack } or function
|
|
30
|
+
if (mod.default) {
|
|
31
|
+
if (typeof mod.default === "function") return mod.default;
|
|
32
|
+
if (typeof mod.default.buildPack === "function") return mod.default.buildPack;
|
|
16
33
|
}
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
// Some CJS setups export { buildPack } directly
|
|
35
|
+
if (typeof mod === "function") return mod;
|
|
36
|
+
if (typeof mod.buildPack === "function") return mod.buildPack;
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function loadBuildPack() {
|
|
41
|
+
const candidates = [
|
|
42
|
+
path.resolve(__dirname, "../dist/index.js"),
|
|
43
|
+
path.resolve(__dirname, "../dist/builder.js"),
|
|
44
|
+
// Also try .cjs just in case someone built CJS
|
|
45
|
+
path.resolve(__dirname, "../dist/index.cjs"),
|
|
46
|
+
path.resolve(__dirname, "../dist/builder.cjs"),
|
|
47
|
+
];
|
|
48
|
+
for (const p of candidates) {
|
|
49
|
+
const mod = await tryImport(p);
|
|
50
|
+
const buildPack = getBuildPack(mod);
|
|
51
|
+
if (buildPack) return buildPack;
|
|
21
52
|
}
|
|
22
|
-
|
|
23
|
-
writeFileSync(outputFile, Buffer.from(bytes));
|
|
24
|
-
console.log(`wrote ${outputFile}`);
|
|
53
|
+
throw new Error("Could not locate a buildPack function in dist/");
|
|
25
54
|
}
|
|
26
55
|
|
|
27
|
-
|
|
28
|
-
|
|
56
|
+
const buildPack = await loadBuildPack();
|
|
57
|
+
|
|
58
|
+
const inFile = process.argv[2];
|
|
59
|
+
const outFile = process.argv[3] || "knowledge.knolo";
|
|
60
|
+
|
|
61
|
+
if (!inFile) {
|
|
62
|
+
console.log("Usage: knolo <input.json> [output.knolo]");
|
|
29
63
|
process.exit(1);
|
|
30
|
-
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const docs = JSON.parse(readFileSync(inFile, "utf8"));
|
|
67
|
+
const bytes = await buildPack(docs);
|
|
68
|
+
writeFileSync(outFile, Buffer.from(bytes));
|
|
69
|
+
console.log(`wrote ${outFile}`);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knolo-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Local-first knowledge packs for small LLMs.",
|
|
5
5
|
"keywords": ["llm", "knowledge-base", "rag", "local", "expo"],
|
|
6
|
-
"author": "
|
|
6
|
+
"author": "Sam Paniagua",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|