@rlabs-inc/fsdb 1.0.1 → 1.2.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 +13 -37
- package/dist/core/database.d.ts.map +1 -1
- package/dist/index.js +134 -22
- package/dist/index.mjs +134 -22
- package/dist/persistence/markdown.d.ts +3 -3
- package/dist/persistence/markdown.d.ts.map +1 -1
- package/dist/persistence/watcher.d.ts.map +1 -1
- package/dist/vector/search.d.ts +1 -1
- package/dist/vector/search.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
|
|
1
2
|
# fsDB - Fractal State Database
|
|
2
3
|
|
|
3
|
-
A reactive database with parallel arrays and fine-grained reactivity.
|
|
4
|
+
A reactive database built with parallel arrays and fine-grained reactivity.
|
|
4
5
|
|
|
5
|
-
**F**
|
|
6
|
+
**F**ractal **S**tate **DB**
|
|
6
7
|
|
|
7
8
|
## Features
|
|
8
9
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
10
|
+
- **Fine-grained reactivity** at field level
|
|
11
|
+
- **Markdown Persistence** - YAML frontmatter + body, human-readable
|
|
12
|
+
- **O(1) array access** vs object property lookup
|
|
13
|
+
- **Zero Global State** - Each database instance is isolated
|
|
11
14
|
- **Reactive Queries** - Queries auto-update when data changes
|
|
12
15
|
- **Vector Search** - Cosine similarity with stale detection
|
|
13
|
-
- **Markdown Persistence** - YAML frontmatter + body, human-readable
|
|
14
16
|
- **File Watching** - External changes sync automatically
|
|
15
|
-
- **
|
|
17
|
+
- **CPU cache locality**
|
|
18
|
+
- **Minimal garbage collection**
|
|
16
19
|
|
|
17
20
|
## Installation
|
|
18
21
|
|
|
@@ -61,33 +64,6 @@ effect(() => {
|
|
|
61
64
|
users.update(id, { active: false })
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
## The Father State Pattern
|
|
65
|
-
|
|
66
|
-
Instead of storing records as objects (slow):
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
// Traditional - array of objects
|
|
70
|
-
const records = [
|
|
71
|
-
{ id: '1', name: 'Alice', age: 30 },
|
|
72
|
-
{ id: '2', name: 'Bob', age: 25 },
|
|
73
|
-
]
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
We use parallel arrays indexed by a central registry (fast):
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
// Father State Pattern - parallel arrays
|
|
80
|
-
registry = { idToIndex: { '1': 0, '2': 1 } }
|
|
81
|
-
names = ['Alice', 'Bob']
|
|
82
|
-
ages = [30, 25]
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Benefits:**
|
|
86
|
-
- O(1) array access vs object property lookup
|
|
87
|
-
- Better CPU cache locality
|
|
88
|
-
- Fine-grained reactivity at field level
|
|
89
|
-
- Minimal garbage collection
|
|
90
|
-
|
|
91
67
|
## API Reference
|
|
92
68
|
|
|
93
69
|
### Database
|
|
@@ -217,7 +193,7 @@ const activeCount = queryCount(users, r => r.active)
|
|
|
217
193
|
// First match
|
|
218
194
|
const admin = queryFirst(users, r => r.role === 'admin')
|
|
219
195
|
|
|
220
|
-
// Use in effects
|
|
196
|
+
// Use in effects
|
|
221
197
|
effect(() => {
|
|
222
198
|
console.log('Active users:', activeUsers.value.count)
|
|
223
199
|
})
|
|
@@ -290,7 +266,7 @@ age: 30
|
|
|
290
266
|
embedding: [0.1, 0.2, 0.3, ...]
|
|
291
267
|
---
|
|
292
268
|
|
|
293
|
-
This is the bio content (contentColumn)
|
|
269
|
+
This is the bio content in markdown format (contentColumn)
|
|
294
270
|
```
|
|
295
271
|
|
|
296
272
|
### Stale Detection
|
|
@@ -332,9 +308,9 @@ On Apple Silicon (M1/M2/M3):
|
|
|
332
308
|
## Architecture
|
|
333
309
|
|
|
334
310
|
```
|
|
335
|
-
Database (
|
|
311
|
+
Database (ECS Arrays)
|
|
336
312
|
└── Collections (ReactiveMap)
|
|
337
|
-
└── Collection (
|
|
313
|
+
└── Collection (ECS Arrays)
|
|
338
314
|
├── Registry (index management)
|
|
339
315
|
└── Columns (parallel arrays)
|
|
340
316
|
├── names: ['Alice', 'Bob', ...]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/core/database.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAA;AAUpH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAMtE,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IACrF,iCAAiC;IACjC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAEvB,+BAA+B;IAC/B,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAEvB,0BAA0B;IAC1B,aAAa,IAAI,IAAI,CAAA;IAErB,yBAAyB;IACzB,YAAY,IAAI,IAAI,CAAA;IAEpB,4BAA4B;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAE5B,yCAAyC;IACzC,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,CAAA;IAEvF,0DAA0D;IAC1D,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,GAAG,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAE1G,+BAA+B;IAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,Y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,CAAC,CAAC,CAgRzB;AAMD,MAAM,WAAW,QAAQ;IACvB,oBAAoB;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,gCAAgC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB,iCAAiC;IACjC,UAAU,CAAC,CAAC,SAAS,gBAAgB,EACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAC1C,oBAAoB,CAAC,CAAC,CAAC,CAAA;IAE1B,iCAAiC;IACjC,aAAa,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;IAE5F,gCAAgC;IAChC,eAAe,IAAI,MAAM,EAAE,CAAA;IAE3B,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,QAAQ,CA2DtE;AAGD,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1720,11 +1720,62 @@ function createCollection(name, options) {
|
|
|
1720
1720
|
}
|
|
1721
1721
|
|
|
1722
1722
|
// src/persistence/markdown.ts
|
|
1723
|
+
var isBun = typeof Bun !== "undefined";
|
|
1724
|
+
async function readFileText(filepath) {
|
|
1725
|
+
if (isBun) {
|
|
1726
|
+
const file = Bun.file(filepath);
|
|
1727
|
+
if (!await file.exists())
|
|
1728
|
+
return null;
|
|
1729
|
+
return await file.text();
|
|
1730
|
+
} else {
|
|
1731
|
+
const fs = await import("fs/promises");
|
|
1732
|
+
try {
|
|
1733
|
+
return await fs.readFile(filepath, "utf-8");
|
|
1734
|
+
} catch {
|
|
1735
|
+
return null;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
async function writeFile(filepath, content) {
|
|
1740
|
+
if (isBun) {
|
|
1741
|
+
await Bun.write(filepath, content);
|
|
1742
|
+
return true;
|
|
1743
|
+
} else {
|
|
1744
|
+
const fs = await import("fs/promises");
|
|
1745
|
+
await fs.writeFile(filepath, content, "utf-8");
|
|
1746
|
+
return true;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
function listMarkdownFiles(dirpath) {
|
|
1750
|
+
if (isBun) {
|
|
1751
|
+
const glob = new Bun.Glob("*.md");
|
|
1752
|
+
return Array.from(glob.scanSync({ cwd: dirpath }));
|
|
1753
|
+
} else {
|
|
1754
|
+
const fs = require("fs");
|
|
1755
|
+
try {
|
|
1756
|
+
const files = fs.readdirSync(dirpath);
|
|
1757
|
+
return files.filter((f) => f.endsWith(".md"));
|
|
1758
|
+
} catch {
|
|
1759
|
+
return [];
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1723
1763
|
function idToFilename(id) {
|
|
1724
|
-
|
|
1764
|
+
const encoded = id.replace(/[^a-zA-Z0-9\-_.]/g, (char) => {
|
|
1765
|
+
const code = char.charCodeAt(0);
|
|
1766
|
+
if (code > 255) {
|
|
1767
|
+
return `%u${code.toString(16).padStart(4, "0")}`;
|
|
1768
|
+
}
|
|
1769
|
+
return `%${code.toString(16).padStart(2, "0")}`;
|
|
1770
|
+
});
|
|
1771
|
+
const safe = encoded.startsWith(".") ? `%2e${encoded.slice(1)}` : encoded;
|
|
1772
|
+
return safe + ".md";
|
|
1725
1773
|
}
|
|
1726
1774
|
function filenameToId(filename) {
|
|
1727
|
-
|
|
1775
|
+
const withoutExt = filename.replace(/\.md$/, "");
|
|
1776
|
+
return withoutExt.replace(/%u([0-9a-fA-F]{4})|%([0-9a-fA-F]{2})/g, (_, quad, pair) => {
|
|
1777
|
+
return String.fromCharCode(parseInt(quad || pair, 16));
|
|
1778
|
+
});
|
|
1728
1779
|
}
|
|
1729
1780
|
function parseMarkdown(text) {
|
|
1730
1781
|
const frontmatter = {};
|
|
@@ -1762,6 +1813,14 @@ function parseYamlValue(value) {
|
|
|
1762
1813
|
return true;
|
|
1763
1814
|
if (value === "false")
|
|
1764
1815
|
return false;
|
|
1816
|
+
if (value === ".nan" || value === "NaN")
|
|
1817
|
+
return NaN;
|
|
1818
|
+
if (value === ".inf" || value === "Infinity")
|
|
1819
|
+
return Infinity;
|
|
1820
|
+
if (value === "-.inf" || value === "-Infinity")
|
|
1821
|
+
return -Infinity;
|
|
1822
|
+
if (value === "-0.0" || value === "-0")
|
|
1823
|
+
return -0;
|
|
1765
1824
|
if (/^-?\d+$/.test(value)) {
|
|
1766
1825
|
return parseInt(value, 10);
|
|
1767
1826
|
}
|
|
@@ -1775,7 +1834,14 @@ function parseYamlValue(value) {
|
|
|
1775
1834
|
return value;
|
|
1776
1835
|
}
|
|
1777
1836
|
}
|
|
1778
|
-
if (value.startsWith('"') && value.endsWith('"')
|
|
1837
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
1838
|
+
try {
|
|
1839
|
+
return JSON.parse(value);
|
|
1840
|
+
} catch {
|
|
1841
|
+
return value.slice(1, -1);
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
if (value.startsWith("'") && value.endsWith("'")) {
|
|
1779
1845
|
return value.slice(1, -1);
|
|
1780
1846
|
}
|
|
1781
1847
|
return value;
|
|
@@ -1788,6 +1854,14 @@ function toYamlValue(value) {
|
|
|
1788
1854
|
return value ? "true" : "false";
|
|
1789
1855
|
}
|
|
1790
1856
|
if (typeof value === "number") {
|
|
1857
|
+
if (Number.isNaN(value))
|
|
1858
|
+
return ".nan";
|
|
1859
|
+
if (value === Infinity)
|
|
1860
|
+
return ".inf";
|
|
1861
|
+
if (value === -Infinity)
|
|
1862
|
+
return "-.inf";
|
|
1863
|
+
if (Object.is(value, -0))
|
|
1864
|
+
return "-0.0";
|
|
1791
1865
|
return String(value);
|
|
1792
1866
|
}
|
|
1793
1867
|
if (Array.isArray(value)) {
|
|
@@ -1797,11 +1871,7 @@ function toYamlValue(value) {
|
|
|
1797
1871
|
return JSON.stringify(Array.from(value));
|
|
1798
1872
|
}
|
|
1799
1873
|
if (typeof value === "string") {
|
|
1800
|
-
|
|
1801
|
-
`) || value.startsWith('"') || value.startsWith("'") || value === "true" || value === "false" || value === "null") {
|
|
1802
|
-
return JSON.stringify(value);
|
|
1803
|
-
}
|
|
1804
|
-
return value;
|
|
1874
|
+
return JSON.stringify(value);
|
|
1805
1875
|
}
|
|
1806
1876
|
return JSON.stringify(value);
|
|
1807
1877
|
}
|
|
@@ -1829,11 +1899,10 @@ function generateMarkdown(record, schema, contentColumn) {
|
|
|
1829
1899
|
}
|
|
1830
1900
|
async function loadFromMarkdown(filepath, schema, contentColumn) {
|
|
1831
1901
|
try {
|
|
1832
|
-
const
|
|
1833
|
-
if (
|
|
1902
|
+
const text = await readFileText(filepath);
|
|
1903
|
+
if (text === null) {
|
|
1834
1904
|
return null;
|
|
1835
1905
|
}
|
|
1836
|
-
const text = await file.text();
|
|
1837
1906
|
const { frontmatter, content } = parseMarkdown(text);
|
|
1838
1907
|
const id = frontmatter.id;
|
|
1839
1908
|
if (!id) {
|
|
@@ -1854,6 +1923,12 @@ async function loadFromMarkdown(filepath, schema, contentColumn) {
|
|
|
1854
1923
|
const parsed = parseColumnType(schema[key]);
|
|
1855
1924
|
if (parsed.baseType === "vector" && Array.isArray(value)) {
|
|
1856
1925
|
value = new Float32Array(value);
|
|
1926
|
+
} else if (parsed.baseType === "string" && typeof value !== "string") {
|
|
1927
|
+
value = value === null ? "" : String(value);
|
|
1928
|
+
} else if (parsed.baseType === "number" && typeof value !== "number") {
|
|
1929
|
+
value = Number(value) || 0;
|
|
1930
|
+
} else if (parsed.baseType === "boolean" && typeof value !== "boolean") {
|
|
1931
|
+
value = value === "true" || value === true;
|
|
1857
1932
|
}
|
|
1858
1933
|
record[key] = value;
|
|
1859
1934
|
}
|
|
@@ -1866,8 +1941,7 @@ async function loadFromMarkdown(filepath, schema, contentColumn) {
|
|
|
1866
1941
|
async function saveToMarkdown(filepath, record, schema, contentColumn) {
|
|
1867
1942
|
try {
|
|
1868
1943
|
const markdown = generateMarkdown(record, schema, contentColumn);
|
|
1869
|
-
await
|
|
1870
|
-
return true;
|
|
1944
|
+
return await writeFile(filepath, markdown);
|
|
1871
1945
|
} catch {
|
|
1872
1946
|
return false;
|
|
1873
1947
|
}
|
|
@@ -1875,8 +1949,7 @@ async function saveToMarkdown(filepath, record, schema, contentColumn) {
|
|
|
1875
1949
|
async function loadFromDirectory(dirpath, schema, contentColumn) {
|
|
1876
1950
|
const results = [];
|
|
1877
1951
|
try {
|
|
1878
|
-
const
|
|
1879
|
-
const files = glob.scanSync({ cwd: dirpath });
|
|
1952
|
+
const files = listMarkdownFiles(dirpath);
|
|
1880
1953
|
for (const filename of files) {
|
|
1881
1954
|
const filepath = `${dirpath}/${filename}`;
|
|
1882
1955
|
const result = await loadFromMarkdown(filepath, schema, contentColumn);
|
|
@@ -1903,6 +1976,34 @@ async function ensureDirectory(dirpath) {
|
|
|
1903
1976
|
|
|
1904
1977
|
// src/persistence/watcher.ts
|
|
1905
1978
|
var import_fs = require("fs");
|
|
1979
|
+
var isBun2 = typeof Bun !== "undefined";
|
|
1980
|
+
async function fileExists(filepath) {
|
|
1981
|
+
if (isBun2) {
|
|
1982
|
+
return await Bun.file(filepath).exists();
|
|
1983
|
+
} else {
|
|
1984
|
+
const fs = await import("fs/promises");
|
|
1985
|
+
try {
|
|
1986
|
+
await fs.access(filepath);
|
|
1987
|
+
return true;
|
|
1988
|
+
} catch {
|
|
1989
|
+
return false;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function listMarkdownFilesSync(dirpath) {
|
|
1994
|
+
if (isBun2) {
|
|
1995
|
+
const glob = new Bun.Glob("*.md");
|
|
1996
|
+
return Array.from(glob.scanSync({ cwd: dirpath }));
|
|
1997
|
+
} else {
|
|
1998
|
+
const fs = require("fs");
|
|
1999
|
+
try {
|
|
2000
|
+
const files = fs.readdirSync(dirpath);
|
|
2001
|
+
return files.filter((f) => f.endsWith(".md"));
|
|
2002
|
+
} catch {
|
|
2003
|
+
return [];
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
1906
2007
|
function createFileWatcher(options) {
|
|
1907
2008
|
const {
|
|
1908
2009
|
dirpath,
|
|
@@ -1924,8 +2025,7 @@ function createFileWatcher(options) {
|
|
|
1924
2025
|
if (_savingIds.has(id)) {
|
|
1925
2026
|
return;
|
|
1926
2027
|
}
|
|
1927
|
-
const
|
|
1928
|
-
const exists = await file.exists();
|
|
2028
|
+
const exists = await fileExists(filepath);
|
|
1929
2029
|
let event;
|
|
1930
2030
|
if (!exists) {
|
|
1931
2031
|
if (!_knownFiles.has(filename))
|
|
@@ -1984,8 +2084,7 @@ function createFileWatcher(options) {
|
|
|
1984
2084
|
if (_isWatching.value)
|
|
1985
2085
|
return;
|
|
1986
2086
|
try {
|
|
1987
|
-
const
|
|
1988
|
-
for (const filename of glob.scanSync({ cwd: dirpath })) {
|
|
2087
|
+
for (const filename of listMarkdownFilesSync(dirpath)) {
|
|
1989
2088
|
_knownFiles.add(filename);
|
|
1990
2089
|
}
|
|
1991
2090
|
_watcher = import_fs.watch(dirpath, { recursive: false }, (eventType, filename) => {
|
|
@@ -2031,6 +2130,18 @@ function createFileWatcher(options) {
|
|
|
2031
2130
|
}
|
|
2032
2131
|
|
|
2033
2132
|
// src/vector/search.ts
|
|
2133
|
+
var isBun3 = typeof Bun !== "undefined";
|
|
2134
|
+
function hashContent(content) {
|
|
2135
|
+
if (isBun3) {
|
|
2136
|
+
return BigInt(Bun.hash(content));
|
|
2137
|
+
} else {
|
|
2138
|
+
let hash = 5381n;
|
|
2139
|
+
for (let i = 0;i < content.length; i++) {
|
|
2140
|
+
hash = (hash << 5n) + hash + BigInt(content.charCodeAt(i));
|
|
2141
|
+
}
|
|
2142
|
+
return hash;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2034
2145
|
function toFloat32Array(arr) {
|
|
2035
2146
|
if (arr instanceof Float32Array)
|
|
2036
2147
|
return arr;
|
|
@@ -2100,7 +2211,7 @@ function createEmbeddingManager() {
|
|
|
2100
2211
|
const hashes = new ReactiveMap;
|
|
2101
2212
|
return {
|
|
2102
2213
|
setEmbedding(id, column, content) {
|
|
2103
|
-
const hash =
|
|
2214
|
+
const hash = hashContent(content);
|
|
2104
2215
|
let columnHashes = hashes.get(id);
|
|
2105
2216
|
if (!columnHashes) {
|
|
2106
2217
|
columnHashes = new Map;
|
|
@@ -2115,7 +2226,7 @@ function createEmbeddingManager() {
|
|
|
2115
2226
|
const storedHash = columnHashes.get(column);
|
|
2116
2227
|
if (storedHash === undefined)
|
|
2117
2228
|
return false;
|
|
2118
|
-
const currentHash =
|
|
2229
|
+
const currentHash = hashContent(currentContent);
|
|
2119
2230
|
return storedHash !== currentHash;
|
|
2120
2231
|
},
|
|
2121
2232
|
getHash(id, column) {
|
|
@@ -2385,7 +2496,8 @@ function createDatabase(options = {}) {
|
|
|
2385
2496
|
} else if (options.local) {
|
|
2386
2497
|
basePath = `${process.cwd()}/.fsdb/${name}`;
|
|
2387
2498
|
} else {
|
|
2388
|
-
|
|
2499
|
+
const home = typeof Bun !== "undefined" ? Bun.env.HOME : process.env.HOME;
|
|
2500
|
+
basePath = `${home}/.fsdb/${name}`;
|
|
2389
2501
|
}
|
|
2390
2502
|
const collections = new ReactiveMap;
|
|
2391
2503
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -1629,11 +1629,62 @@ function createCollection(name, options) {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
|
|
1631
1631
|
// src/persistence/markdown.ts
|
|
1632
|
+
var isBun = typeof Bun !== "undefined";
|
|
1633
|
+
async function readFileText(filepath) {
|
|
1634
|
+
if (isBun) {
|
|
1635
|
+
const file = Bun.file(filepath);
|
|
1636
|
+
if (!await file.exists())
|
|
1637
|
+
return null;
|
|
1638
|
+
return await file.text();
|
|
1639
|
+
} else {
|
|
1640
|
+
const fs = await import("fs/promises");
|
|
1641
|
+
try {
|
|
1642
|
+
return await fs.readFile(filepath, "utf-8");
|
|
1643
|
+
} catch {
|
|
1644
|
+
return null;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
async function writeFile(filepath, content) {
|
|
1649
|
+
if (isBun) {
|
|
1650
|
+
await Bun.write(filepath, content);
|
|
1651
|
+
return true;
|
|
1652
|
+
} else {
|
|
1653
|
+
const fs = await import("fs/promises");
|
|
1654
|
+
await fs.writeFile(filepath, content, "utf-8");
|
|
1655
|
+
return true;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function listMarkdownFiles(dirpath) {
|
|
1659
|
+
if (isBun) {
|
|
1660
|
+
const glob = new Bun.Glob("*.md");
|
|
1661
|
+
return Array.from(glob.scanSync({ cwd: dirpath }));
|
|
1662
|
+
} else {
|
|
1663
|
+
const fs = __require("fs");
|
|
1664
|
+
try {
|
|
1665
|
+
const files = fs.readdirSync(dirpath);
|
|
1666
|
+
return files.filter((f) => f.endsWith(".md"));
|
|
1667
|
+
} catch {
|
|
1668
|
+
return [];
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1632
1672
|
function idToFilename(id) {
|
|
1633
|
-
|
|
1673
|
+
const encoded = id.replace(/[^a-zA-Z0-9\-_.]/g, (char) => {
|
|
1674
|
+
const code = char.charCodeAt(0);
|
|
1675
|
+
if (code > 255) {
|
|
1676
|
+
return `%u${code.toString(16).padStart(4, "0")}`;
|
|
1677
|
+
}
|
|
1678
|
+
return `%${code.toString(16).padStart(2, "0")}`;
|
|
1679
|
+
});
|
|
1680
|
+
const safe = encoded.startsWith(".") ? `%2e${encoded.slice(1)}` : encoded;
|
|
1681
|
+
return safe + ".md";
|
|
1634
1682
|
}
|
|
1635
1683
|
function filenameToId(filename) {
|
|
1636
|
-
|
|
1684
|
+
const withoutExt = filename.replace(/\.md$/, "");
|
|
1685
|
+
return withoutExt.replace(/%u([0-9a-fA-F]{4})|%([0-9a-fA-F]{2})/g, (_, quad, pair) => {
|
|
1686
|
+
return String.fromCharCode(parseInt(quad || pair, 16));
|
|
1687
|
+
});
|
|
1637
1688
|
}
|
|
1638
1689
|
function parseMarkdown(text) {
|
|
1639
1690
|
const frontmatter = {};
|
|
@@ -1671,6 +1722,14 @@ function parseYamlValue(value) {
|
|
|
1671
1722
|
return true;
|
|
1672
1723
|
if (value === "false")
|
|
1673
1724
|
return false;
|
|
1725
|
+
if (value === ".nan" || value === "NaN")
|
|
1726
|
+
return NaN;
|
|
1727
|
+
if (value === ".inf" || value === "Infinity")
|
|
1728
|
+
return Infinity;
|
|
1729
|
+
if (value === "-.inf" || value === "-Infinity")
|
|
1730
|
+
return -Infinity;
|
|
1731
|
+
if (value === "-0.0" || value === "-0")
|
|
1732
|
+
return -0;
|
|
1674
1733
|
if (/^-?\d+$/.test(value)) {
|
|
1675
1734
|
return parseInt(value, 10);
|
|
1676
1735
|
}
|
|
@@ -1684,7 +1743,14 @@ function parseYamlValue(value) {
|
|
|
1684
1743
|
return value;
|
|
1685
1744
|
}
|
|
1686
1745
|
}
|
|
1687
|
-
if (value.startsWith('"') && value.endsWith('"')
|
|
1746
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
1747
|
+
try {
|
|
1748
|
+
return JSON.parse(value);
|
|
1749
|
+
} catch {
|
|
1750
|
+
return value.slice(1, -1);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
if (value.startsWith("'") && value.endsWith("'")) {
|
|
1688
1754
|
return value.slice(1, -1);
|
|
1689
1755
|
}
|
|
1690
1756
|
return value;
|
|
@@ -1697,6 +1763,14 @@ function toYamlValue(value) {
|
|
|
1697
1763
|
return value ? "true" : "false";
|
|
1698
1764
|
}
|
|
1699
1765
|
if (typeof value === "number") {
|
|
1766
|
+
if (Number.isNaN(value))
|
|
1767
|
+
return ".nan";
|
|
1768
|
+
if (value === Infinity)
|
|
1769
|
+
return ".inf";
|
|
1770
|
+
if (value === -Infinity)
|
|
1771
|
+
return "-.inf";
|
|
1772
|
+
if (Object.is(value, -0))
|
|
1773
|
+
return "-0.0";
|
|
1700
1774
|
return String(value);
|
|
1701
1775
|
}
|
|
1702
1776
|
if (Array.isArray(value)) {
|
|
@@ -1706,11 +1780,7 @@ function toYamlValue(value) {
|
|
|
1706
1780
|
return JSON.stringify(Array.from(value));
|
|
1707
1781
|
}
|
|
1708
1782
|
if (typeof value === "string") {
|
|
1709
|
-
|
|
1710
|
-
`) || value.startsWith('"') || value.startsWith("'") || value === "true" || value === "false" || value === "null") {
|
|
1711
|
-
return JSON.stringify(value);
|
|
1712
|
-
}
|
|
1713
|
-
return value;
|
|
1783
|
+
return JSON.stringify(value);
|
|
1714
1784
|
}
|
|
1715
1785
|
return JSON.stringify(value);
|
|
1716
1786
|
}
|
|
@@ -1738,11 +1808,10 @@ function generateMarkdown(record, schema, contentColumn) {
|
|
|
1738
1808
|
}
|
|
1739
1809
|
async function loadFromMarkdown(filepath, schema, contentColumn) {
|
|
1740
1810
|
try {
|
|
1741
|
-
const
|
|
1742
|
-
if (
|
|
1811
|
+
const text = await readFileText(filepath);
|
|
1812
|
+
if (text === null) {
|
|
1743
1813
|
return null;
|
|
1744
1814
|
}
|
|
1745
|
-
const text = await file.text();
|
|
1746
1815
|
const { frontmatter, content } = parseMarkdown(text);
|
|
1747
1816
|
const id = frontmatter.id;
|
|
1748
1817
|
if (!id) {
|
|
@@ -1763,6 +1832,12 @@ async function loadFromMarkdown(filepath, schema, contentColumn) {
|
|
|
1763
1832
|
const parsed = parseColumnType(schema[key]);
|
|
1764
1833
|
if (parsed.baseType === "vector" && Array.isArray(value)) {
|
|
1765
1834
|
value = new Float32Array(value);
|
|
1835
|
+
} else if (parsed.baseType === "string" && typeof value !== "string") {
|
|
1836
|
+
value = value === null ? "" : String(value);
|
|
1837
|
+
} else if (parsed.baseType === "number" && typeof value !== "number") {
|
|
1838
|
+
value = Number(value) || 0;
|
|
1839
|
+
} else if (parsed.baseType === "boolean" && typeof value !== "boolean") {
|
|
1840
|
+
value = value === "true" || value === true;
|
|
1766
1841
|
}
|
|
1767
1842
|
record[key] = value;
|
|
1768
1843
|
}
|
|
@@ -1775,8 +1850,7 @@ async function loadFromMarkdown(filepath, schema, contentColumn) {
|
|
|
1775
1850
|
async function saveToMarkdown(filepath, record, schema, contentColumn) {
|
|
1776
1851
|
try {
|
|
1777
1852
|
const markdown = generateMarkdown(record, schema, contentColumn);
|
|
1778
|
-
await
|
|
1779
|
-
return true;
|
|
1853
|
+
return await writeFile(filepath, markdown);
|
|
1780
1854
|
} catch {
|
|
1781
1855
|
return false;
|
|
1782
1856
|
}
|
|
@@ -1784,8 +1858,7 @@ async function saveToMarkdown(filepath, record, schema, contentColumn) {
|
|
|
1784
1858
|
async function loadFromDirectory(dirpath, schema, contentColumn) {
|
|
1785
1859
|
const results = [];
|
|
1786
1860
|
try {
|
|
1787
|
-
const
|
|
1788
|
-
const files = glob.scanSync({ cwd: dirpath });
|
|
1861
|
+
const files = listMarkdownFiles(dirpath);
|
|
1789
1862
|
for (const filename of files) {
|
|
1790
1863
|
const filepath = `${dirpath}/${filename}`;
|
|
1791
1864
|
const result = await loadFromMarkdown(filepath, schema, contentColumn);
|
|
@@ -1812,6 +1885,34 @@ async function ensureDirectory(dirpath) {
|
|
|
1812
1885
|
|
|
1813
1886
|
// src/persistence/watcher.ts
|
|
1814
1887
|
import { watch } from "fs";
|
|
1888
|
+
var isBun2 = typeof Bun !== "undefined";
|
|
1889
|
+
async function fileExists(filepath) {
|
|
1890
|
+
if (isBun2) {
|
|
1891
|
+
return await Bun.file(filepath).exists();
|
|
1892
|
+
} else {
|
|
1893
|
+
const fs = await import("fs/promises");
|
|
1894
|
+
try {
|
|
1895
|
+
await fs.access(filepath);
|
|
1896
|
+
return true;
|
|
1897
|
+
} catch {
|
|
1898
|
+
return false;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
function listMarkdownFilesSync(dirpath) {
|
|
1903
|
+
if (isBun2) {
|
|
1904
|
+
const glob = new Bun.Glob("*.md");
|
|
1905
|
+
return Array.from(glob.scanSync({ cwd: dirpath }));
|
|
1906
|
+
} else {
|
|
1907
|
+
const fs = __require("fs");
|
|
1908
|
+
try {
|
|
1909
|
+
const files = fs.readdirSync(dirpath);
|
|
1910
|
+
return files.filter((f) => f.endsWith(".md"));
|
|
1911
|
+
} catch {
|
|
1912
|
+
return [];
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1815
1916
|
function createFileWatcher(options) {
|
|
1816
1917
|
const {
|
|
1817
1918
|
dirpath,
|
|
@@ -1833,8 +1934,7 @@ function createFileWatcher(options) {
|
|
|
1833
1934
|
if (_savingIds.has(id)) {
|
|
1834
1935
|
return;
|
|
1835
1936
|
}
|
|
1836
|
-
const
|
|
1837
|
-
const exists = await file.exists();
|
|
1937
|
+
const exists = await fileExists(filepath);
|
|
1838
1938
|
let event;
|
|
1839
1939
|
if (!exists) {
|
|
1840
1940
|
if (!_knownFiles.has(filename))
|
|
@@ -1893,8 +1993,7 @@ function createFileWatcher(options) {
|
|
|
1893
1993
|
if (_isWatching.value)
|
|
1894
1994
|
return;
|
|
1895
1995
|
try {
|
|
1896
|
-
const
|
|
1897
|
-
for (const filename of glob.scanSync({ cwd: dirpath })) {
|
|
1996
|
+
for (const filename of listMarkdownFilesSync(dirpath)) {
|
|
1898
1997
|
_knownFiles.add(filename);
|
|
1899
1998
|
}
|
|
1900
1999
|
_watcher = watch(dirpath, { recursive: false }, (eventType, filename) => {
|
|
@@ -1940,6 +2039,18 @@ function createFileWatcher(options) {
|
|
|
1940
2039
|
}
|
|
1941
2040
|
|
|
1942
2041
|
// src/vector/search.ts
|
|
2042
|
+
var isBun3 = typeof Bun !== "undefined";
|
|
2043
|
+
function hashContent(content) {
|
|
2044
|
+
if (isBun3) {
|
|
2045
|
+
return BigInt(Bun.hash(content));
|
|
2046
|
+
} else {
|
|
2047
|
+
let hash = 5381n;
|
|
2048
|
+
for (let i = 0;i < content.length; i++) {
|
|
2049
|
+
hash = (hash << 5n) + hash + BigInt(content.charCodeAt(i));
|
|
2050
|
+
}
|
|
2051
|
+
return hash;
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
1943
2054
|
function toFloat32Array(arr) {
|
|
1944
2055
|
if (arr instanceof Float32Array)
|
|
1945
2056
|
return arr;
|
|
@@ -2009,7 +2120,7 @@ function createEmbeddingManager() {
|
|
|
2009
2120
|
const hashes = new ReactiveMap;
|
|
2010
2121
|
return {
|
|
2011
2122
|
setEmbedding(id, column, content) {
|
|
2012
|
-
const hash =
|
|
2123
|
+
const hash = hashContent(content);
|
|
2013
2124
|
let columnHashes = hashes.get(id);
|
|
2014
2125
|
if (!columnHashes) {
|
|
2015
2126
|
columnHashes = new Map;
|
|
@@ -2024,7 +2135,7 @@ function createEmbeddingManager() {
|
|
|
2024
2135
|
const storedHash = columnHashes.get(column);
|
|
2025
2136
|
if (storedHash === undefined)
|
|
2026
2137
|
return false;
|
|
2027
|
-
const currentHash =
|
|
2138
|
+
const currentHash = hashContent(currentContent);
|
|
2028
2139
|
return storedHash !== currentHash;
|
|
2029
2140
|
},
|
|
2030
2141
|
getHash(id, column) {
|
|
@@ -2294,7 +2405,8 @@ function createDatabase(options = {}) {
|
|
|
2294
2405
|
} else if (options.local) {
|
|
2295
2406
|
basePath = `${process.cwd()}/.fsdb/${name}`;
|
|
2296
2407
|
} else {
|
|
2297
|
-
|
|
2408
|
+
const home = typeof Bun !== "undefined" ? Bun.env.HOME : process.env.HOME;
|
|
2409
|
+
basePath = `${home}/.fsdb/${name}`;
|
|
2298
2410
|
}
|
|
2299
2411
|
const collections = new ReactiveMap;
|
|
2300
2412
|
return {
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Markdown Persistence
|
|
3
3
|
*
|
|
4
4
|
* Parse and generate markdown files with YAML frontmatter.
|
|
5
|
-
* Uses Bun file APIs
|
|
5
|
+
* Uses Bun file APIs when available, falls back to Node.js fs/promises.
|
|
6
6
|
*/
|
|
7
7
|
import type { SchemaDefinition, RecordWithMeta } from '../core/types';
|
|
8
|
-
/** Convert an ID to a safe filename */
|
|
8
|
+
/** Convert an ID to a safe filename (reversible via percent-encoding) */
|
|
9
9
|
export declare function idToFilename(id: string): string;
|
|
10
|
-
/** Extract ID from a filename */
|
|
10
|
+
/** Extract ID from a filename (decodes percent-encoding) */
|
|
11
11
|
export declare function filenameToId(filename: string): string;
|
|
12
12
|
interface ParsedMarkdown {
|
|
13
13
|
frontmatter: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/persistence/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAkB,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/persistence/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAkB,cAAc,EAAE,MAAM,eAAe,CAAA;AA2DrF,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAe/C;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMrD;AAMD,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAqC1D;AAqGD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,EACzD,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,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
CHANGED
|
@@ -44,7 +44,7 @@ export interface EmbeddingManager {
|
|
|
44
44
|
/**
|
|
45
45
|
* Create an embedding manager for stale detection
|
|
46
46
|
*
|
|
47
|
-
* Uses Bun.hash
|
|
47
|
+
* Uses fast content hashing for fingerprinting (Bun.hash when available)
|
|
48
48
|
*/
|
|
49
49
|
export declare function createEmbeddingManager(): EmbeddingManager;
|
|
50
50
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/vector/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/vector/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,eAAe,CAAA;AA0BtB;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,YAAY,GAAG,YAAY,CAGzE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAY/D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,EAC1B,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,GACzB,MAAM,CAsBR;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,YAAY,EAAE,EACvB,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,CAmCzC;AAMD,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAE/D,uDAAuD;IACvD,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAA;IAEpE,2CAA2C;IAC3C,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAEvD,8BAA8B;IAC9B,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3C,uBAAuB;IACvB,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CA4CzD;AAMD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,gBAAgB,EACrD,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,YAAY,EAAE,MAAM,CAAC,EACrB,WAAW,EAAE,YAAY,GAAG,MAAM,EAAE,EACpC,OAAO,GAAE,mBAAmB,CAAC,CAAC,CAAM,GACnC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CA4CzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rlabs-inc/fsdb",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Fractal State Database - A reactive in memory database with markdown files persistence made with parallel arrays and fine-grained reactivity.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|