@williamthorsen/kb 0.6.0 → 0.6.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 +1 -9
- package/dist/esm/filesystem/write-atomic.d.ts +1 -0
- package/dist/esm/filesystem/write-atomic.js +17 -0
- package/dist/esm/note-io/write-note.js +2 -16
- package/dist/esm/taxonomy/write-taxonomy.js +2 -17
- package/package.json +7 -4
- package/dist/esm/lints/index.d.ts +0 -3
- package/dist/esm/lints/index.js +0 -3
package/README.md
CHANGED
|
@@ -4,15 +4,7 @@ Foundation library for knowledge-base tooling.
|
|
|
4
4
|
Provides knowledge-base discovery, registry loading, frontmatter parsing and writing, tag canonicalization, and type-blind vault-integrity checks.
|
|
5
5
|
It underpins the knowledge-base skills — among them `kb-retrieve` (assertion recall) and `kb-retrieve-events` (event recall), `kb-add`, `kb-curate`, `capture-event`, and `kb-update-events` — and the planned `@williamthorsen/kb-mcp` server.
|
|
6
6
|
|
|
7
|
-
<!-- section:release-notes -->
|
|
8
|
-
## Release notes — v0.6.0 (2026-08-13)
|
|
9
|
-
|
|
10
|
-
### 🎉 Features
|
|
11
|
-
|
|
12
|
-
- Attach causes to kb's loader errors and retire its lint deferral (#1272)
|
|
13
|
-
|
|
14
|
-
Errors `kb` raises on malformed input now carry the underlying parse error as their cause. Callers constructing one of these errors themselves can attach a cause. When `kb` reports a thrown error that carries no message, the diagnostic now names the error's class instead of trailing off empty.
|
|
15
|
-
<!-- /section:release-notes -->
|
|
7
|
+
<!-- section:release-notes --><!-- /section:release-notes -->
|
|
16
8
|
|
|
17
9
|
## Exports
|
|
18
10
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeAtomic(path: string, content: string): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { rename, unlink, writeFile } from 'node:fs/promises';
|
|
3
|
+
export async function writeAtomic(path, content) {
|
|
4
|
+
const tempPath = `${path}.${randomBytes(8).toString('hex')}.tmp`;
|
|
5
|
+
try {
|
|
6
|
+
await writeFile(tempPath, content, 'utf8');
|
|
7
|
+
await rename(tempPath, path);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
try {
|
|
11
|
+
await unlink(tempPath);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
}
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { rename, unlink, writeFile } from 'node:fs/promises';
|
|
1
|
+
import { writeAtomic } from "../filesystem/write-atomic.js";
|
|
3
2
|
import { renderFrontmatterFields } from "./yaml-fields.js";
|
|
4
3
|
const FENCE = '---';
|
|
5
4
|
export function renderNote(fields, body) {
|
|
@@ -8,18 +7,5 @@ export function renderNote(fields, body) {
|
|
|
8
7
|
return `${FENCE}\n${frontmatter}\n${FENCE}\n\n${normalizedBody}`;
|
|
9
8
|
}
|
|
10
9
|
export async function writeNote(path, fields, body) {
|
|
11
|
-
|
|
12
|
-
const tempPath = `${path}.${randomBytes(8).toString('hex')}.tmp`;
|
|
13
|
-
await writeFile(tempPath, content, 'utf8');
|
|
14
|
-
try {
|
|
15
|
-
await rename(tempPath, path);
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
try {
|
|
19
|
-
await unlink(tempPath);
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
}
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
10
|
+
await writeAtomic(path, renderNote(fields, body));
|
|
25
11
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readFile, rename, unlink, writeFile } from 'node:fs/promises';
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
3
2
|
import { join } from 'node:path';
|
|
4
3
|
import { describeError } from '@williamthorsen/toolbelt.errors';
|
|
5
4
|
import { isMap, isPair, isScalar, parseDocument } from 'yaml';
|
|
6
5
|
import { KbLoaderError } from "../config/kb-loader-error.js";
|
|
6
|
+
import { writeAtomic } from "../filesystem/write-atomic.js";
|
|
7
7
|
import { TAXONOMY_FILE } from "../layout/index.js";
|
|
8
8
|
import { isEnoent, isRecord } from "../type-guards.js";
|
|
9
9
|
import { describeKeyDefect } from "./taxonomy-schema.js";
|
|
@@ -130,18 +130,3 @@ function sortByPath(declarations) {
|
|
|
130
130
|
return a.path < b.path ? -1 : 1;
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
async function writeAtomic(path, content) {
|
|
134
|
-
const tempPath = `${path}.${randomBytes(8).toString('hex')}.tmp`;
|
|
135
|
-
await writeFile(tempPath, content, 'utf8');
|
|
136
|
-
try {
|
|
137
|
-
await rename(tempPath, path);
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
try {
|
|
141
|
-
await unlink(tempPath);
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
}
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@williamthorsen/kb",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Knowledge-base foundation: discovery, config, frontmatter parsing, records, tags, and vault-integrity checks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"frontmatter",
|
|
@@ -97,13 +97,16 @@
|
|
|
97
97
|
"dist"
|
|
98
98
|
],
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@williamthorsen/toolbelt.errors": "0.3
|
|
101
|
-
"picomatch": "4.0.
|
|
100
|
+
"@williamthorsen/toolbelt.errors": "0.6.3",
|
|
101
|
+
"picomatch": "4.0.7",
|
|
102
102
|
"yaml": "2.9.0",
|
|
103
103
|
"zod": "4.4.3"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@types/
|
|
106
|
+
"@types/node": "24.13.3",
|
|
107
|
+
"@types/picomatch": "4.0.3",
|
|
108
|
+
"eslint": "10.9.1",
|
|
109
|
+
"vitest": "4.1.11"
|
|
107
110
|
},
|
|
108
111
|
"engines": {
|
|
109
112
|
"node": ">=24"
|
package/dist/esm/lints/index.js
DELETED