chapterhouse 0.7.0 → 0.8.1
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/agents/korg.agent.md +65 -0
- package/dist/api/korg.js +34 -0
- package/dist/api/korg.test.js +42 -0
- package/dist/api/server.js +238 -2
- package/dist/api/server.test.js +199 -0
- package/dist/config.js +28 -0
- package/dist/config.test.js +20 -0
- package/dist/copilot/agents.js +3 -4
- package/dist/copilot/agents.test.js +12 -1
- package/dist/copilot/orchestrator.js +12 -1
- package/dist/copilot/orchestrator.test.js +3 -7
- package/dist/copilot/system-message.js +12 -10
- package/dist/copilot/system-message.test.js +6 -1
- package/dist/copilot/tools.js +193 -375
- package/dist/copilot/tools.memory.test.js +32 -0
- package/dist/copilot/tools.wiki.test.js +80 -59
- package/dist/copilot/turn-event-log-env.test.js +11 -15
- package/dist/daemon.js +19 -0
- package/dist/memory/decisions.js +6 -5
- package/dist/memory/entities.js +20 -9
- package/dist/memory/eot.js +30 -8
- package/dist/memory/eot.test.js +220 -6
- package/dist/memory/hooks.js +151 -0
- package/dist/memory/hooks.test.js +325 -0
- package/dist/memory/hot-tier.js +37 -0
- package/dist/memory/hot-tier.test.js +30 -0
- package/dist/memory/housekeeping-scheduler.js +35 -0
- package/dist/memory/housekeeping-scheduler.test.js +50 -0
- package/dist/memory/inbox.js +10 -0
- package/dist/memory/index.js +3 -1
- package/dist/memory/migration.js +244 -0
- package/dist/memory/migration.test.js +108 -0
- package/dist/memory/reflect.js +273 -0
- package/dist/memory/reflect.test.js +254 -0
- package/dist/paths.js +31 -11
- package/dist/store/db.js +187 -4
- package/dist/store/db.test.js +66 -2
- package/dist/test/helpers/reset-singletons.js +8 -0
- package/dist/test/helpers/reset-singletons.test.js +37 -0
- package/dist/test/setup-env.js +9 -1
- package/dist/wiki/consolidation.js +641 -0
- package/dist/wiki/consolidation.test.js +143 -0
- package/dist/wiki/frontmatter.js +48 -0
- package/dist/wiki/frontmatter.test.js +42 -0
- package/dist/wiki/fs.js +22 -13
- package/dist/wiki/index-manager.js +305 -330
- package/dist/wiki/index-manager.test.js +265 -144
- package/dist/wiki/ingest.js +347 -0
- package/dist/wiki/ingest.test.js +111 -0
- package/dist/wiki/links.js +151 -0
- package/dist/wiki/links.test.js +176 -0
- package/dist/wiki/log-manager.js +8 -5
- package/dist/wiki/log-manager.test.js +4 -0
- package/dist/wiki/migrate-topics.test.js +16 -6
- package/dist/wiki/scheduler.js +118 -0
- package/dist/wiki/scheduler.test.js +64 -0
- package/dist/wiki/timeline.js +51 -0
- package/dist/wiki/timeline.test.js +65 -0
- package/dist/wiki/topic-structure.js +1 -1
- package/package.json +1 -1
- package/skills/pkb-ideas/SKILL.md +78 -0
- package/skills/pkb-ideas/_meta.json +4 -0
- package/skills/pkb-org/SKILL.md +82 -0
- package/skills/pkb-org/_meta.json +4 -0
- package/skills/pkb-people/SKILL.md +74 -0
- package/skills/pkb-people/_meta.json +4 -0
- package/skills/pkb-research/SKILL.md +83 -0
- package/skills/pkb-research/_meta.json +4 -0
- package/skills/pkb-source/SKILL.md +38 -0
- package/skills/pkb-source/_meta.json +4 -0
- package/skills/wiki-conventions/SKILL.md +5 -5
- package/web/dist/assets/{index-DuKYxMIR.css → index-5kz9aRU9.css} +1 -1
- package/web/dist/assets/{index-DytB69KC.js → index-BbX9RKf3.js} +91 -89
- package/web/dist/assets/index-BbX9RKf3.js.map +1 -0
- package/web/dist/index.html +2 -2
- package/dist/wiki/context.js +0 -138
- package/dist/wiki/fix.js +0 -335
- package/dist/wiki/fix.test.js +0 -350
- package/dist/wiki/lint.js +0 -451
- package/dist/wiki/lint.test.js +0 -329
- package/web/dist/assets/index-DytB69KC.js.map +0 -1
package/dist/wiki/fix.test.js
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { mkdirSync, rmSync, utimesSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
const repoRoot = process.cwd();
|
|
6
|
-
const sandboxRoot = join(repoRoot, ".test-work", `wiki-fix-${process.pid}`);
|
|
7
|
-
process.env.CHAPTERHOUSE_HOME = sandboxRoot;
|
|
8
|
-
process.env.CHAPTERHOUSE_AGENT_NAME = "wiki-fix-test-agent";
|
|
9
|
-
async function loadModules() {
|
|
10
|
-
const nonce = `${Date.now()}-${Math.random()}`;
|
|
11
|
-
const fix = await import(new URL(`./fix.js?case=${nonce}`, import.meta.url).href);
|
|
12
|
-
const wikiFs = await import(new URL(`./fs.js?case=${nonce}`, import.meta.url).href);
|
|
13
|
-
return { fix, wikiFs };
|
|
14
|
-
}
|
|
15
|
-
function resetSandbox() {
|
|
16
|
-
mkdirSync(join(repoRoot, ".test-work"), { recursive: true });
|
|
17
|
-
rmSync(sandboxRoot, { recursive: true, force: true });
|
|
18
|
-
}
|
|
19
|
-
function wikiPath(relativePath) {
|
|
20
|
-
return join(sandboxRoot, ".chapterhouse", "wiki", ...relativePath.split("/"));
|
|
21
|
-
}
|
|
22
|
-
function setMtime(relativePath, isoDate) {
|
|
23
|
-
const timestamp = new Date(`${isoDate}T12:00:00.000Z`);
|
|
24
|
-
utimesSync(wikiPath(relativePath), timestamp, timestamp);
|
|
25
|
-
}
|
|
26
|
-
test.beforeEach(() => {
|
|
27
|
-
resetSandbox();
|
|
28
|
-
});
|
|
29
|
-
test.after(() => {
|
|
30
|
-
rmSync(sandboxRoot, { recursive: true, force: true });
|
|
31
|
-
});
|
|
32
|
-
test("fixWiki dry-run previews frontmatter backfills, tag normalization, and autostub marking without writing files", async () => {
|
|
33
|
-
const { fix, wikiFs } = await loadModules();
|
|
34
|
-
wikiFs.ensureWikiStructure();
|
|
35
|
-
wikiFs.writePage("pages/projects/alpha/index.md", `# Alpha Project
|
|
36
|
-
|
|
37
|
-
Alpha project **launch** notes for the team.
|
|
38
|
-
|
|
39
|
-
## Details
|
|
40
|
-
|
|
41
|
-
One
|
|
42
|
-
Two
|
|
43
|
-
Three
|
|
44
|
-
Four
|
|
45
|
-
Five
|
|
46
|
-
Six
|
|
47
|
-
Seven
|
|
48
|
-
Eight
|
|
49
|
-
`);
|
|
50
|
-
wikiFs.writePage("pages/projects/empty/index.md", `# Empty Page
|
|
51
|
-
`);
|
|
52
|
-
wikiFs.writePage("pages/projects/bravo/index.md", `---
|
|
53
|
-
title: Bravo
|
|
54
|
-
summary: Bravo deployment notes
|
|
55
|
-
updated: 2026-05-10
|
|
56
|
-
tags: [Run Book, Mystery]
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
# Bravo
|
|
60
|
-
|
|
61
|
-
Deployment notes with enough body to avoid the stub marker.
|
|
62
|
-
|
|
63
|
-
## Steps
|
|
64
|
-
|
|
65
|
-
One
|
|
66
|
-
Two
|
|
67
|
-
Three
|
|
68
|
-
Four
|
|
69
|
-
Five
|
|
70
|
-
Six
|
|
71
|
-
Seven
|
|
72
|
-
Eight
|
|
73
|
-
`);
|
|
74
|
-
wikiFs.writePage("pages/projects/stub/index.md", `---
|
|
75
|
-
title: Stub Page
|
|
76
|
-
summary: Tiny page
|
|
77
|
-
updated: 2026-05-10
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
# Stub Page
|
|
81
|
-
|
|
82
|
-
Tiny.
|
|
83
|
-
`);
|
|
84
|
-
wikiFs.writePage("pages/_meta/taxonomy.md", `## Process
|
|
85
|
-
- runbook
|
|
86
|
-
`);
|
|
87
|
-
setMtime("pages/projects/alpha/index.md", "2026-01-02");
|
|
88
|
-
setMtime("pages/projects/empty/index.md", "2026-01-03");
|
|
89
|
-
const beforeAlpha = wikiFs.readPage("pages/projects/alpha/index.md");
|
|
90
|
-
const beforeEmpty = wikiFs.readPage("pages/projects/empty/index.md");
|
|
91
|
-
const beforeBravo = wikiFs.readPage("pages/projects/bravo/index.md");
|
|
92
|
-
const beforeStub = wikiFs.readPage("pages/projects/stub/index.md");
|
|
93
|
-
const report = fix.fixWiki({ dryRun: true });
|
|
94
|
-
assert.equal(report.dryRun, true);
|
|
95
|
-
assert.equal(report.changedFiles, 4);
|
|
96
|
-
const alpha = report.files.find((entry) => entry.path === "pages/projects/alpha/index.md");
|
|
97
|
-
const empty = report.files.find((entry) => entry.path === "pages/projects/empty/index.md");
|
|
98
|
-
const bravo = report.files.find((entry) => entry.path === "pages/projects/bravo/index.md");
|
|
99
|
-
const stub = report.files.find((entry) => entry.path === "pages/projects/stub/index.md");
|
|
100
|
-
assert.deepEqual(alpha?.changes, [
|
|
101
|
-
{ rule: "frontmatter-backfill", details: ["title", "summary", "updated"] },
|
|
102
|
-
]);
|
|
103
|
-
assert.deepEqual(empty?.changes, [
|
|
104
|
-
{ rule: "frontmatter-backfill", details: ["title", "summary", "updated", "autostub"] },
|
|
105
|
-
]);
|
|
106
|
-
assert.deepEqual(bravo?.changes, [
|
|
107
|
-
{ rule: "tag-normalize", details: ["Run Book -> runbook"] },
|
|
108
|
-
]);
|
|
109
|
-
assert.deepEqual(bravo?.unknownTags, ["Mystery"]);
|
|
110
|
-
assert.deepEqual(stub?.changes, [
|
|
111
|
-
{ rule: "autostub-mark", details: ["autostub"] },
|
|
112
|
-
]);
|
|
113
|
-
assert.match(report.diff, /--- a\/pages\/projects\/alpha\/index\.md/);
|
|
114
|
-
assert.match(report.diff, /title: Alpha Project/);
|
|
115
|
-
assert.match(report.diff, /summary: Alpha project launch notes for the team\./);
|
|
116
|
-
assert.match(report.diff, /updated: 2026-01-02/);
|
|
117
|
-
assert.match(report.diff, /summary: \(no summary yet\)/);
|
|
118
|
-
assert.match(report.diff, /tags: \[runbook, Mystery\]/);
|
|
119
|
-
assert.match(report.diff, /autostub: true/);
|
|
120
|
-
assert.equal(wikiFs.readPage("pages/projects/alpha/index.md"), beforeAlpha);
|
|
121
|
-
assert.equal(wikiFs.readPage("pages/projects/empty/index.md"), beforeEmpty);
|
|
122
|
-
assert.equal(wikiFs.readPage("pages/projects/bravo/index.md"), beforeBravo);
|
|
123
|
-
assert.equal(wikiFs.readPage("pages/projects/stub/index.md"), beforeStub);
|
|
124
|
-
});
|
|
125
|
-
test("fixWiki applies changes, logs each applied rule, and is idempotent on the second run", async () => {
|
|
126
|
-
const { fix, wikiFs } = await loadModules();
|
|
127
|
-
wikiFs.ensureWikiStructure();
|
|
128
|
-
wikiFs.writePage("pages/projects/alpha/index.md", `# Alpha Project
|
|
129
|
-
|
|
130
|
-
Alpha project launch notes for the team.
|
|
131
|
-
|
|
132
|
-
## Details
|
|
133
|
-
|
|
134
|
-
One
|
|
135
|
-
Two
|
|
136
|
-
Three
|
|
137
|
-
Four
|
|
138
|
-
Five
|
|
139
|
-
Six
|
|
140
|
-
Seven
|
|
141
|
-
Eight
|
|
142
|
-
`);
|
|
143
|
-
wikiFs.writePage("pages/projects/bravo/index.md", `---
|
|
144
|
-
title: Bravo
|
|
145
|
-
summary: Bravo deployment notes
|
|
146
|
-
updated: 2026-05-10
|
|
147
|
-
tags: [Run Book]
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
# Bravo
|
|
151
|
-
|
|
152
|
-
Deployment notes with enough body to avoid the stub marker.
|
|
153
|
-
|
|
154
|
-
## Steps
|
|
155
|
-
|
|
156
|
-
One
|
|
157
|
-
Two
|
|
158
|
-
Three
|
|
159
|
-
Four
|
|
160
|
-
Five
|
|
161
|
-
Six
|
|
162
|
-
Seven
|
|
163
|
-
Eight
|
|
164
|
-
`);
|
|
165
|
-
wikiFs.writePage("pages/projects/stub/index.md", `---
|
|
166
|
-
title: Stub Page
|
|
167
|
-
summary: Tiny page
|
|
168
|
-
updated: 2026-05-10
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
# Stub Page
|
|
172
|
-
|
|
173
|
-
Tiny.
|
|
174
|
-
`);
|
|
175
|
-
wikiFs.writePage("pages/_meta/taxonomy.md", `## Process
|
|
176
|
-
- runbook
|
|
177
|
-
`);
|
|
178
|
-
setMtime("pages/projects/alpha/index.md", "2026-01-02");
|
|
179
|
-
const logEntries = [];
|
|
180
|
-
const firstReport = fix.fixWiki({
|
|
181
|
-
dryRun: false,
|
|
182
|
-
logAction: (type, path) => logEntries.push(`${type}:${path}`),
|
|
183
|
-
});
|
|
184
|
-
assert.equal(firstReport.dryRun, false);
|
|
185
|
-
assert.equal(firstReport.changedFiles, 3);
|
|
186
|
-
assert.equal(firstReport.diff, "");
|
|
187
|
-
assert.match(wikiFs.readPage("pages/projects/alpha/index.md") ?? "", /title: Alpha Project/);
|
|
188
|
-
assert.match(wikiFs.readPage("pages/projects/alpha/index.md") ?? "", /updated: 2026-01-02/);
|
|
189
|
-
assert.match(wikiFs.readPage("pages/projects/bravo/index.md") ?? "", /tags: \[runbook\]/);
|
|
190
|
-
assert.match(wikiFs.readPage("pages/projects/stub/index.md") ?? "", /autostub: true/);
|
|
191
|
-
assert.deepEqual(logEntries, [
|
|
192
|
-
"fix-frontmatter:pages/projects/alpha/index.md",
|
|
193
|
-
"fix-tags:pages/projects/bravo/index.md",
|
|
194
|
-
"fix-autostub:pages/projects/stub/index.md",
|
|
195
|
-
]);
|
|
196
|
-
const secondReport = fix.fixWiki({
|
|
197
|
-
dryRun: false,
|
|
198
|
-
logAction: (type, path) => logEntries.push(`${type}:${path}`),
|
|
199
|
-
});
|
|
200
|
-
assert.equal(secondReport.changedFiles, 0);
|
|
201
|
-
assert.equal(secondReport.diff, "");
|
|
202
|
-
assert.deepEqual(logEntries, [
|
|
203
|
-
"fix-frontmatter:pages/projects/alpha/index.md",
|
|
204
|
-
"fix-tags:pages/projects/bravo/index.md",
|
|
205
|
-
"fix-autostub:pages/projects/stub/index.md",
|
|
206
|
-
]);
|
|
207
|
-
});
|
|
208
|
-
test("fixWiki respects fix toggles, path globs, autofix false, and pages/_meta skips", async () => {
|
|
209
|
-
const { fix, wikiFs } = await loadModules();
|
|
210
|
-
wikiFs.ensureWikiStructure();
|
|
211
|
-
wikiFs.writePage("pages/projects/match/index.md", `---
|
|
212
|
-
title: Match
|
|
213
|
-
summary: Match notes
|
|
214
|
-
updated: 2026-05-10
|
|
215
|
-
tags: [Run Book]
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
# Match
|
|
219
|
-
|
|
220
|
-
Long enough body.
|
|
221
|
-
|
|
222
|
-
## Details
|
|
223
|
-
|
|
224
|
-
One
|
|
225
|
-
Two
|
|
226
|
-
Three
|
|
227
|
-
Four
|
|
228
|
-
Five
|
|
229
|
-
Six
|
|
230
|
-
Seven
|
|
231
|
-
Eight
|
|
232
|
-
`);
|
|
233
|
-
wikiFs.writePage("pages/projects/skip/index.md", `---
|
|
234
|
-
title: Skip
|
|
235
|
-
summary: Skip notes
|
|
236
|
-
updated: 2026-05-10
|
|
237
|
-
tags: [Run Book]
|
|
238
|
-
autofix: false
|
|
239
|
-
---
|
|
240
|
-
|
|
241
|
-
# Skip
|
|
242
|
-
|
|
243
|
-
Long enough body.
|
|
244
|
-
|
|
245
|
-
## Details
|
|
246
|
-
|
|
247
|
-
One
|
|
248
|
-
Two
|
|
249
|
-
Three
|
|
250
|
-
Four
|
|
251
|
-
Five
|
|
252
|
-
Six
|
|
253
|
-
Seven
|
|
254
|
-
Eight
|
|
255
|
-
`);
|
|
256
|
-
wikiFs.writePage("pages/people/alice/index.md", `---
|
|
257
|
-
title: Alice
|
|
258
|
-
summary: Alice notes
|
|
259
|
-
updated: 2026-05-10
|
|
260
|
-
tags: [Run Book]
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
# Alice
|
|
264
|
-
|
|
265
|
-
Long enough body.
|
|
266
|
-
|
|
267
|
-
## Details
|
|
268
|
-
|
|
269
|
-
One
|
|
270
|
-
Two
|
|
271
|
-
Three
|
|
272
|
-
Four
|
|
273
|
-
Five
|
|
274
|
-
Six
|
|
275
|
-
Seven
|
|
276
|
-
Eight
|
|
277
|
-
`);
|
|
278
|
-
wikiFs.writePage("pages/_meta/manual.md", `---
|
|
279
|
-
title: Manual
|
|
280
|
-
summary: System page
|
|
281
|
-
updated: 2026-05-10
|
|
282
|
-
tags: [Run Book]
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
# Manual
|
|
286
|
-
`);
|
|
287
|
-
wikiFs.writePage("pages/_meta/taxonomy.md", `## Process
|
|
288
|
-
- runbook
|
|
289
|
-
`);
|
|
290
|
-
const beforeSkip = wikiFs.readPage("pages/projects/skip/index.md");
|
|
291
|
-
const beforePeople = wikiFs.readPage("pages/people/alice/index.md");
|
|
292
|
-
const beforeMeta = wikiFs.readPage("pages/_meta/manual.md");
|
|
293
|
-
const report = fix.fixWiki({
|
|
294
|
-
dryRun: true,
|
|
295
|
-
fixes: ["tag-normalize"],
|
|
296
|
-
pathGlob: "pages/projects/**",
|
|
297
|
-
});
|
|
298
|
-
assert.equal(report.changedFiles, 1);
|
|
299
|
-
assert.deepEqual(report.files.map((entry) => entry.path), ["pages/projects/match/index.md"]);
|
|
300
|
-
assert.deepEqual(report.files[0]?.changes.map((change) => change.rule), ["tag-normalize"]);
|
|
301
|
-
assert.doesNotMatch(report.diff, /pages\/projects\/skip\/index\.md/);
|
|
302
|
-
assert.doesNotMatch(report.diff, /pages\/people\/alice\/index\.md/);
|
|
303
|
-
assert.doesNotMatch(report.diff, /pages\/_meta\/manual\.md/);
|
|
304
|
-
assert.equal(wikiFs.readPage("pages/projects/skip/index.md"), beforeSkip);
|
|
305
|
-
assert.equal(wikiFs.readPage("pages/people/alice/index.md"), beforePeople);
|
|
306
|
-
assert.equal(wikiFs.readPage("pages/_meta/manual.md"), beforeMeta);
|
|
307
|
-
});
|
|
308
|
-
test("fixWiki flags unmatched tags even when there is nothing to rewrite", async () => {
|
|
309
|
-
const { fix, wikiFs } = await loadModules();
|
|
310
|
-
wikiFs.ensureWikiStructure();
|
|
311
|
-
wikiFs.writePage("pages/projects/mystery/index.md", `---
|
|
312
|
-
title: Mystery
|
|
313
|
-
summary: Mystery notes
|
|
314
|
-
updated: 2026-05-10
|
|
315
|
-
tags: [Mystery]
|
|
316
|
-
---
|
|
317
|
-
|
|
318
|
-
# Mystery
|
|
319
|
-
|
|
320
|
-
Long enough body.
|
|
321
|
-
|
|
322
|
-
## Details
|
|
323
|
-
|
|
324
|
-
One
|
|
325
|
-
Two
|
|
326
|
-
Three
|
|
327
|
-
Four
|
|
328
|
-
Five
|
|
329
|
-
Six
|
|
330
|
-
Seven
|
|
331
|
-
Eight
|
|
332
|
-
`);
|
|
333
|
-
wikiFs.writePage("pages/_meta/taxonomy.md", `## Process
|
|
334
|
-
- runbook
|
|
335
|
-
`);
|
|
336
|
-
const report = fix.fixWiki({
|
|
337
|
-
dryRun: true,
|
|
338
|
-
fixes: ["tag-normalize"],
|
|
339
|
-
});
|
|
340
|
-
assert.equal(report.changedFiles, 0);
|
|
341
|
-
assert.equal(report.diff, "");
|
|
342
|
-
assert.deepEqual(report.files, [
|
|
343
|
-
{
|
|
344
|
-
path: "pages/projects/mystery/index.md",
|
|
345
|
-
changes: [],
|
|
346
|
-
unknownTags: ["Mystery"],
|
|
347
|
-
},
|
|
348
|
-
]);
|
|
349
|
-
});
|
|
350
|
-
//# sourceMappingURL=fix.test.js.map
|