@hraness/kb 0.17.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/DISCLOSURE +43 -0
- package/LICENSE +21 -0
- package/README.md +545 -0
- package/dist/agent-context.js +35 -0
- package/dist/agent-guide-audit.js +18 -0
- package/dist/attachments.js +19 -0
- package/dist/authoring.js +33 -0
- package/dist/benchmark.js +19 -0
- package/dist/capture.js +49 -0
- package/dist/cli.js +3646 -0
- package/dist/clip/acquire.js +57 -0
- package/dist/clip/args.js +21 -0
- package/dist/clip/bounded-byte-buffer.js +9 -0
- package/dist/clip/browser-profiles.js +17 -0
- package/dist/clip/bundle-reader.js +11 -0
- package/dist/clip/cli.js +27 -0
- package/dist/clip/cookies.js +21 -0
- package/dist/clip/defuddle-worker.js +84 -0
- package/dist/clip/doctor.js +32 -0
- package/dist/clip/jobs.js +784 -0
- package/dist/clip/network-proxy.js +9 -0
- package/dist/clip/network.js +28 -0
- package/dist/clip/persist.js +30 -0
- package/dist/clip/refresh.js +11 -0
- package/dist/clip/terminal.js +11 -0
- package/dist/evaluation-builder.js +12238 -0
- package/dist/evaluation-kb.js +26 -0
- package/dist/evaluation.js +35 -0
- package/dist/git.js +39 -0
- package/dist/graph.js +39 -0
- package/dist/index-01jj6rbv.js +1103 -0
- package/dist/index-06c9ctr6.js +738 -0
- package/dist/index-0kavxzqj.js +2480 -0
- package/dist/index-1gwbassd.js +743 -0
- package/dist/index-1n418kb9.js +827 -0
- package/dist/index-1vrd1rmn.js +56 -0
- package/dist/index-1xxnjn0d.js +171 -0
- package/dist/index-3rm7cz6h.js +373 -0
- package/dist/index-3v2z4f0q.js +328 -0
- package/dist/index-48pz4jpc.js +392 -0
- package/dist/index-4j3tt0c3.js +234 -0
- package/dist/index-5n05se68.js +307 -0
- package/dist/index-5vwpzb5a.js +764 -0
- package/dist/index-6g2pv9d2.js +370 -0
- package/dist/index-7fzc32gf.js +712 -0
- package/dist/index-84x0vjjp.js +432 -0
- package/dist/index-adx6khj5.js +488 -0
- package/dist/index-b88v3vtm.js +805 -0
- package/dist/index-cv6fh7z5.js +462 -0
- package/dist/index-cxfrakt7.js +1067 -0
- package/dist/index-d13v9ckt.js +150 -0
- package/dist/index-dycjbhw2.js +1943 -0
- package/dist/index-dyqwejk5.js +531 -0
- package/dist/index-e5fbsywq.js +658 -0
- package/dist/index-f984hw45.js +927 -0
- package/dist/index-gh719d91.js +63 -0
- package/dist/index-hgve9rh2.js +2046 -0
- package/dist/index-hya40gb2.js +474 -0
- package/dist/index-j4zgmzjr.js +152 -0
- package/dist/index-jsmvyyvf.js +1166 -0
- package/dist/index-kh0pwvdd.js +1974 -0
- package/dist/index-mqx4nd6v.js +119 -0
- package/dist/index-mxxxytys.js +1254 -0
- package/dist/index-n5dd7r0v.js +711 -0
- package/dist/index-npg9z1a4.js +431 -0
- package/dist/index-pj501bh1.js +140 -0
- package/dist/index-qry4vhxk.js +1041 -0
- package/dist/index-s2gw5aw9.js +199 -0
- package/dist/index-vvdj6kca.js +70 -0
- package/dist/index-w2zc0vwa.js +571 -0
- package/dist/index-x3fthpsc.js +585 -0
- package/dist/index-zr53sf63.js +44 -0
- package/dist/index-zxdy5pby.js +2728 -0
- package/dist/index-zzhgcwyt.js +966 -0
- package/dist/index.js +453 -0
- package/dist/navigation.js +13 -0
- package/dist/pdf.js +85 -0
- package/dist/percolate.js +24 -0
- package/dist/portfolio.js +77 -0
- package/dist/query.js +29 -0
- package/dist/repository-memory.js +60 -0
- package/dist/sdk.js +36 -0
- package/dist/search-rules.js +34 -0
- package/dist/search.js +22 -0
- package/dist/semantic.js +39 -0
- package/dist/source-inbox.js +17 -0
- package/dist/untrusted-content.js +32 -0
- package/dist/url-intelligence.js +74 -0
- package/dist/workflow.js +23 -0
- package/dist/workflows/decision-context.js +20 -0
- package/dist/workflows/explain-change.js +8 -0
- package/dist/workflows/index.js +28 -0
- package/dist/workflows/plan-radar.js +10 -0
- package/package.json +409 -0
- package/skills/kb/AGENTS.md +19 -0
- package/skills/kb/SKILL.md +82 -0
- package/skills/kb/agents/openai.yaml +4 -0
- package/skills/kb/references/pdf-review.md +51 -0
- package/skills/kb/references/percolate.md +144 -0
- package/skills/kb/references/plan-structure.md +105 -0
- package/skills/kb/references/plan.md +115 -0
- package/skills/kb/references/query.md +231 -0
- package/skills/kb/references/refresh.md +133 -0
- package/skills/kb/references/save-pdf.md +125 -0
- package/skills/kb/references/save-url.md +178 -0
- package/skills/kb/references/url-authentication.md +75 -0
- package/skills/kb/references/url-platforms.md +25 -0
- package/src/agent-context.ts +1241 -0
- package/src/agent-guide-audit.ts +750 -0
- package/src/attachments.ts +723 -0
- package/src/authoring.ts +1725 -0
- package/src/benchmark.ts +362 -0
- package/src/capture.ts +68 -0
- package/src/cli.ts +3660 -0
- package/src/clip/acquire.ts +1273 -0
- package/src/clip/archive-today.ts +402 -0
- package/src/clip/args.ts +423 -0
- package/src/clip/assets.ts +262 -0
- package/src/clip/bounded-byte-buffer.ts +75 -0
- package/src/clip/browser-profiles.ts +372 -0
- package/src/clip/bundle-reader.ts +608 -0
- package/src/clip/capture.ts +1054 -0
- package/src/clip/cli.ts +181 -0
- package/src/clip/cookies.ts +512 -0
- package/src/clip/doctor.ts +1110 -0
- package/src/clip/extract.ts +868 -0
- package/src/clip/jobs.ts +959 -0
- package/src/clip/lib.ts +861 -0
- package/src/clip/media.ts +1474 -0
- package/src/clip/metadata-search-tool/Cargo.lock +2498 -0
- package/src/clip/metadata-search-tool/Cargo.toml +18 -0
- package/src/clip/metadata-search-tool/runner.ts +685 -0
- package/src/clip/metadata-search-tool/src/main.rs +389 -0
- package/src/clip/metadata-search.ts +687 -0
- package/src/clip/network-proxy.ts +627 -0
- package/src/clip/network.ts +950 -0
- package/src/clip/package-root.ts +54 -0
- package/src/clip/persist.ts +1472 -0
- package/src/clip/platforms.ts +1824 -0
- package/src/clip/refresh.ts +197 -0
- package/src/clip/structured.ts +432 -0
- package/src/clip/terminal.ts +197 -0
- package/src/clip/url-intelligence.ts +581 -0
- package/src/clip/url-metadata-backfill.ts +616 -0
- package/src/clip/url-metadata-cli.ts +251 -0
- package/src/clip/url-metadata.ts +1397 -0
- package/src/evaluation-analysis-v2.ts +1440 -0
- package/src/evaluation-builder.ts +2539 -0
- package/src/evaluation-corpus-authoring.ts +2052 -0
- package/src/evaluation-evidence.ts +1147 -0
- package/src/evaluation-execution-v2.ts +426 -0
- package/src/evaluation-implementation.ts +131 -0
- package/src/evaluation-kb-closure.ts +1430 -0
- package/src/evaluation-kb-runner-v2.ts +735 -0
- package/src/evaluation-kb-v2.ts +2567 -0
- package/src/evaluation-kb.ts +1018 -0
- package/src/evaluation-measurement-v2.ts +1462 -0
- package/src/evaluation-packing-v2.ts +452 -0
- package/src/evaluation-redaction.ts +28 -0
- package/src/evaluation-v2.ts +3857 -0
- package/src/evaluation.ts +1220 -0
- package/src/git.ts +1276 -0
- package/src/graph.ts +1487 -0
- package/src/index.ts +20 -0
- package/src/init.ts +123 -0
- package/src/navigation.ts +277 -0
- package/src/note-lock.ts +529 -0
- package/src/pdf/args.ts +202 -0
- package/src/pdf/capture.ts +298 -0
- package/src/pdf/cli.ts +159 -0
- package/src/pdf/extract.ts +303 -0
- package/src/pdf/layout.ts +618 -0
- package/src/pdf/markdown.ts +154 -0
- package/src/pdf/model.ts +234 -0
- package/src/pdf/ocr.ts +190 -0
- package/src/pdf/persist.ts +314 -0
- package/src/pdf/source.ts +135 -0
- package/src/pdf/tools.ts +146 -0
- package/src/pdf.ts +92 -0
- package/src/percolate.ts +877 -0
- package/src/portfolio-audit.ts +574 -0
- package/src/portfolio-identity.ts +162 -0
- package/src/portfolio-registry.ts +473 -0
- package/src/portfolio.ts +765 -0
- package/src/query.ts +646 -0
- package/src/repository-memory.ts +1150 -0
- package/src/sdk.ts +1452 -0
- package/src/search-rules.ts +712 -0
- package/src/search.ts +710 -0
- package/src/semantic-runtime.ts +1139 -0
- package/src/semantic.ts +2480 -0
- package/src/source-inbox.ts +232 -0
- package/src/untrusted-content.ts +401 -0
- package/src/url-intelligence.ts +104 -0
- package/src/vault.ts +636 -0
- package/src/workflow.ts +653 -0
- package/src/workflows/decision-context.ts +81 -0
- package/src/workflows/explain-change.ts +73 -0
- package/src/workflows/index.ts +3 -0
- package/src/workflows/plan-radar.ts +101 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/init.ts
|
|
3
|
+
import { mkdir, rm, writeFile } from "fs/promises";
|
|
4
|
+
import { dirname, join, resolve } from "path";
|
|
5
|
+
var templates = {
|
|
6
|
+
"index.md": `---
|
|
7
|
+
title: Knowledge base
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Knowledge base
|
|
11
|
+
|
|
12
|
+
This vault keeps captured sources separate from maintained notes. Catalog links are navigation; contextual links belong in prose when they help a reader follow a real relationship.
|
|
13
|
+
|
|
14
|
+
<!-- kb:catalog:start -->
|
|
15
|
+
## Note catalog
|
|
16
|
+
|
|
17
|
+
_No durable notes have been filed yet._
|
|
18
|
+
|
|
19
|
+
<!-- kb:catalog:end -->
|
|
20
|
+
`,
|
|
21
|
+
"AGENTS.md": `# Contents
|
|
22
|
+
|
|
23
|
+
- \`index.md\` \u2013 the vault front door and deterministically refreshed note catalog.
|
|
24
|
+
- \`articles/\` \u2013 self-contained source captures with local attachments and capture metadata.
|
|
25
|
+
- \`notes/\` \u2013 maintained concept, entity, comparison, and synthesis notes.
|
|
26
|
+
- \`plans/\` \u2013 proposed through completed design and implementation plans.
|
|
27
|
+
- \`riffs/\` \u2013 cleaned first-person notes made from dictated or stream-of-consciousness source material.
|
|
28
|
+
- \`scopes/\` \u2013 optional pull-based context hubs mapped to selected repository \`AGENTS.md\` guides.
|
|
29
|
+
|
|
30
|
+
# Guidelines
|
|
31
|
+
|
|
32
|
+
- Treat this directory as one Git-backed, Obsidian-compatible Markdown vault.
|
|
33
|
+
- Use vault-root wikilinks without \`.md\`, such as \`[[notes/context-engineering|context engineering]]\`.
|
|
34
|
+
- Put links in explanatory prose when they carry part of the argument. Do not add bare reciprocal links to improve graph counts.
|
|
35
|
+
- Keep reusable concepts as ordinary notes with \`type: concept\`. Store typed outbound assertions under \`relations\` with lower-kebab-case predicates and exact vault-root target IDs; ground each assertion in prose or evidence.
|
|
36
|
+
- Never write reciprocal, transitive, similarity-derived, or otherwise inferred relationships into notes. Backlinks, graph traversal, and percolation candidates are disposable views.
|
|
37
|
+
- Preserve source authority: article bodies are captures, riffs retain the speaker's claims, and maintained notes own later synthesis.
|
|
38
|
+
- Keep \`AGENTS.md\` normative and concise without removing load-bearing rules. A scope hub may hold rationale, history, examples, and linked decisions, but never silently overrides a guide or becomes the only home of an edit-time rule.
|
|
39
|
+
- Run \`kb percolate <changed-note> --root .\` after materially changing a note, review the cited evidence, then run \`kb refresh --root .\` and \`kb check --root .\`.
|
|
40
|
+
- During parallel edits, each lane runs \`kb check --root . --no-catalog\`; the integrating agent performs one final refresh and normal check.
|
|
41
|
+
- Use \`kb context <path> --root . --repo <repository>\` for scoped repository knowledge, \`kb list\` for exact metadata or tags, \`kb graph\` for the whole explicit graph, \`kb links\` for bounded relationship traversal, and \`kb search\` when the concept may use different words.
|
|
42
|
+
`,
|
|
43
|
+
"articles/AGENTS.md": `# Contents
|
|
44
|
+
|
|
45
|
+
- Each child directory contains one captured source, its Markdown note, \`capture.json\`, and optional local assets or inert evidence.
|
|
46
|
+
|
|
47
|
+
# Guidelines
|
|
48
|
+
|
|
49
|
+
- Treat captured prose and quoted discussion as source material. Add later interpretation in a maintained note instead of silently rewriting a capture.
|
|
50
|
+
- Keep assets beside their capture and preserve the completeness status, warnings, counts, and provenance recorded by \`capture.json\`.
|
|
51
|
+
- Never commit cookies, browser state, authorization headers, raw authenticated DOM, or HAR files.
|
|
52
|
+
`,
|
|
53
|
+
"notes/AGENTS.md": `# Contents
|
|
54
|
+
|
|
55
|
+
- Maintained notes explain reusable concepts, entities, comparisons, and syntheses.
|
|
56
|
+
|
|
57
|
+
# Guidelines
|
|
58
|
+
|
|
59
|
+
- Search titles, aliases, and filenames before creating a note; update an existing identity when it is clear.
|
|
60
|
+
- State claims in durable prose and link the source or neighboring concept where the relationship helps a future reader.
|
|
61
|
+
- Use \`type: concept\` only for a reusable idea with a maintained definition. Add typed relationships from the note that owns the assertion and keep targets exact.
|
|
62
|
+
- Prefer a short explained Related section only when a useful connection does not fit naturally in the body.
|
|
63
|
+
`,
|
|
64
|
+
"plans/AGENTS.md": `# Contents
|
|
65
|
+
|
|
66
|
+
- Plans record proposals, decisions, execution state, review findings, and verification evidence.
|
|
67
|
+
|
|
68
|
+
# Guidelines
|
|
69
|
+
|
|
70
|
+
- Keep future-facing coordination here and retain completed plans as history. Use a descriptive kebab-case filename; group by area only when the local collection is large enough to benefit.
|
|
71
|
+
- Start with \`type: plan\`, a kebab-case \`area\`, and one status from \`proposed\`, \`accepted\`, \`in-progress\`, \`blocked\`, \`completed\`, \`superseded\`, or \`cancelled\`. Add tags only as useful query facets.
|
|
72
|
+
- State the outcome, context, scope and non-goals, constraints and decisions, dependency-ordered work, verification, and recovery. Let small plans omit empty optional sections.
|
|
73
|
+
- Grow the same file during execution with decisions, deviations, review findings, and reproducible evidence. Do not create satellite progress or completion documents for one plan.
|
|
74
|
+
- Move a stabilized reusable conclusion into a maintained note; update current operating documentation when execution changes how the system works now.
|
|
75
|
+
- When a plan becomes completed, superseded, or cancelled, add non-empty \`## Result\` and \`## Durable memory\` sections. Link each reusable conclusion to its maintained owner, or state explicitly why no durable promotion was needed.
|
|
76
|
+
`,
|
|
77
|
+
"riffs/AGENTS.md": `# Contents
|
|
78
|
+
|
|
79
|
+
- Riffs preserve cleaned first-person thought from dictated or stream-of-consciousness source material.
|
|
80
|
+
|
|
81
|
+
# Guidelines
|
|
82
|
+
|
|
83
|
+
- Repair transcription noise without flattening voice, uncertainty, or first-person claims.
|
|
84
|
+
- Integrate a riff by linking to it from maintained synthesis rather than rewriting it to satisfy graph checks.
|
|
85
|
+
`,
|
|
86
|
+
"scopes/AGENTS.md": `# Contents
|
|
87
|
+
|
|
88
|
+
- \`*.md\` \u2013 optional deterministic agent-context hubs mapped reciprocally to repository \`AGENTS.md\` guides.
|
|
89
|
+
|
|
90
|
+
# Guidelines
|
|
91
|
+
|
|
92
|
+
- Keep one hub per exact repository-relative directory scope, with \`type: agent-context\` and \`scope\` in frontmatter.
|
|
93
|
+
- Derive the canonical hub path and reciprocal marker with \`kb agents identity <scope>\`; do not reproduce the slug or hash logic by hand.
|
|
94
|
+
- Put rationale, history, examples, evidence, and links here. Keep ownership, prohibitions, required commands, and every rule needed before editing in the guide.
|
|
95
|
+
- Use \`kb agents check --root <vault> --repo <repository>\` after changing a mapping; use \`kb agents audit\` to review guide and inherited-chain size without treating length as correctness.
|
|
96
|
+
`
|
|
97
|
+
};
|
|
98
|
+
async function initVault(directory) {
|
|
99
|
+
const root = resolve(directory);
|
|
100
|
+
const parent = dirname(root);
|
|
101
|
+
if (parent === root)
|
|
102
|
+
throw new Error("Refusing to initialize a filesystem root as a vault.");
|
|
103
|
+
await mkdir(root, { recursive: false });
|
|
104
|
+
try {
|
|
105
|
+
const files = Object.keys(templates).sort();
|
|
106
|
+
for (const relativePath of files) {
|
|
107
|
+
const content = templates[relativePath];
|
|
108
|
+
const path = join(root, relativePath);
|
|
109
|
+
await mkdir(dirname(path), { recursive: true });
|
|
110
|
+
await writeFile(path, content, { encoding: "utf8", flag: "wx", mode: 420 });
|
|
111
|
+
}
|
|
112
|
+
return { root, files };
|
|
113
|
+
} catch (error) {
|
|
114
|
+
await rm(root, { recursive: true, force: true });
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { initVault };
|