@wrenautomation/knowledge 0.0.0-stage → 0.59.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/LICENSE.md +61 -0
- package/README.md +94 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +234 -0
- package/dist/cli.js.map +1 -0
- package/dist/git.d.ts +20 -0
- package/dist/git.js +83 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +13 -0
- package/dist/lint.js +56 -0
- package/dist/lint.js.map +1 -0
- package/dist/push.d.ts +15 -0
- package/dist/push.js +52 -0
- package/dist/push.js.map +1 -0
- package/dist/record-index.d.ts +458 -0
- package/dist/record-index.js +247 -0
- package/dist/record-index.js.map +1 -0
- package/dist/records.d.ts +263 -0
- package/dist/records.js +162 -0
- package/dist/records.js.map +1 -0
- package/dist/render.d.ts +6 -0
- package/dist/render.js +37 -0
- package/dist/render.js.map +1 -0
- package/dist/repo.d.ts +30 -0
- package/dist/repo.js +75 -0
- package/dist/repo.js.map +1 -0
- package/dist/write.d.ts +51 -0
- package/dist/write.js +175 -0
- package/dist/write.js.map +1 -0
- package/package.json +46 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# PolyForm Strict License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/strict/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
|
|
12
|
+
|
|
13
|
+
## Patent License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
16
|
+
|
|
17
|
+
## Noncommercial Purposes
|
|
18
|
+
|
|
19
|
+
Any noncommercial purpose is a permitted purpose.
|
|
20
|
+
|
|
21
|
+
## Personal Uses
|
|
22
|
+
|
|
23
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
24
|
+
|
|
25
|
+
## Noncommercial Organizations
|
|
26
|
+
|
|
27
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
28
|
+
|
|
29
|
+
## Fair Use
|
|
30
|
+
|
|
31
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
32
|
+
|
|
33
|
+
## No Other Rights
|
|
34
|
+
|
|
35
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
36
|
+
|
|
37
|
+
## Patent Defense
|
|
38
|
+
|
|
39
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
40
|
+
|
|
41
|
+
## Violations
|
|
42
|
+
|
|
43
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
44
|
+
|
|
45
|
+
## No Liability
|
|
46
|
+
|
|
47
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
48
|
+
|
|
49
|
+
## Definitions
|
|
50
|
+
|
|
51
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
52
|
+
|
|
53
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
54
|
+
|
|
55
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
56
|
+
|
|
57
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
58
|
+
|
|
59
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
60
|
+
|
|
61
|
+
Required Notice: Copyright 2026 William Jin (https://wrenautomation.com)
|
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# knowledge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
What you know, as files. Sources, findings, verdicts and rules are markdown records in a git repo, each
|
|
4
|
+
linked to the evidence behind it. People edit them by hand; agents write them through a CLI. A
|
|
5
|
+
Postgres (or PGlite) index built from the commits answers queries, backlinks and stale marks.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i -g @wrenautomation/knowledge
|
|
9
|
+
cd my-notes && git init && knowledge init --owner ana
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Records
|
|
13
|
+
|
|
14
|
+
One file each. The folder says the type: `sources/`, `findings/`, `verdicts/`, `rules/<topic>/`, `guides/`.
|
|
15
|
+
|
|
16
|
+
```md
|
|
17
|
+
---
|
|
18
|
+
id: open-with-their-name-qx492r
|
|
19
|
+
type: rule
|
|
20
|
+
title: Open with their name
|
|
21
|
+
status: live
|
|
22
|
+
version: 1
|
|
23
|
+
by: agent-7
|
|
24
|
+
why: three replies of five named the opener
|
|
25
|
+
cites:
|
|
26
|
+
- youtube-uSTGNHGFOAo
|
|
27
|
+
topic: outbound-copy
|
|
28
|
+
created: '2026-11-09T15:37:26.923Z'
|
|
29
|
+
updated: '2026-11-09T15:37:26.923Z'
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
Put the name in line one.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| Type | Fields of its own |
|
|
36
|
+
|---|---|
|
|
37
|
+
| source | `kind` (site, page, video, reel, post, person, tool, doc, paper, feed, repo, list, other), `url`, `handle`, `priority` 1-9, `media` {sha256, type} |
|
|
38
|
+
| finding | `source` (a source's id), `quote` (the source's words; none for a paraphrase), `page`, `at` (0:16, p. 4), `run` |
|
|
39
|
+
| verdict | `from` (vireo, orrery, owner, other), `ref` (hero:3), `score` |
|
|
40
|
+
| rule | `topic`, `order` |
|
|
41
|
+
| guide | `topic`, `description`. A procedure (an SOP) as one doc; its body cites `[2]` or `[2 0:16]`, the 2nd id in `cites` |
|
|
42
|
+
|
|
43
|
+
Every record: `id`, `title`, `status` (live, retired), `version`, `by`, `why`, `cites`, `tags`, `created`,
|
|
44
|
+
`updated`. Other keys are kept. A file whose name starts with `_` is not a record (a site's folder page).
|
|
45
|
+
|
|
46
|
+
## Writes
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
echo '[{"type":"source","id":"youtube-abc","title":"A talk","kind":"video"},
|
|
50
|
+
{"type":"rule","title":"Hook first","topic":"linkedin","cites":["youtube-abc"]}]' \
|
|
51
|
+
| knowledge add --by agent-7 --why "from the talk"
|
|
52
|
+
echo '{"body":"New text.","topic":"x"}' | knowledge edit hook-first-k2m9qa --by agent-7 --why "…"
|
|
53
|
+
knowledge retire youtube-abc --by ana --why "the talk is out of date"
|
|
54
|
+
knowledge apply --by agent-7 --why "…" < changes.json # [{"op":"add|edit|retire", …}]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- One command = one commit. The whole tree is linted first; a fault in a record it touches refuses the
|
|
58
|
+
change and writes nothing. A failed commit puts every file back.
|
|
59
|
+
- The lint: unique ids, a file at the path its type and id call for, every cite in the repo, a finding's
|
|
60
|
+
source is a source, a guide's `[n]` is in its cites, a rule cites its evidence (only the owner in `knowledge.json` may write one with
|
|
61
|
+
none). A live record that cites a retired one is a warning.
|
|
62
|
+
- `--push`, or `"push": true` in `knowledge.json`, pushes after the commit. A rejected push fetches, merges,
|
|
63
|
+
lints the merge (two clean branches can still break a cite) and tries again; a bad merge is undone.
|
|
64
|
+
|
|
65
|
+
## Reads
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
knowledge show hook-first-k2m9qa # fields, body, what it cites, what cites it
|
|
69
|
+
knowledge find hook --type rule # every word in the id, title or body
|
|
70
|
+
knowledge stale # live records whose evidence is missing, retired or newer
|
|
71
|
+
knowledge render outbound-copy # markdown, not JSON: the body, then its cites as a numbered Sources list
|
|
72
|
+
knowledge lint # the working tree; --rev <commit> for a commit
|
|
73
|
+
knowledge sync [--full]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Reads sync the index first. The index holds what the last commit holds, never uncommitted edits.
|
|
77
|
+
PGlite in `<repo>/.index/` (git ignores it), or Postgres with `--db` or `KNOWLEDGE_DATABASE_URL`. Rows carry
|
|
78
|
+
the repo's name, so one Postgres can index many repos (`find --all-repos`).
|
|
79
|
+
|
|
80
|
+
## On a git server
|
|
81
|
+
|
|
82
|
+
A pre-receive hook refuses a push that adds a fault:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
while read old new ref; do knowledge lint --rev "$new" --base "$old" >/dev/null || exit 1; done
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Guarantees
|
|
89
|
+
|
|
90
|
+
- One commit is one transaction. A lock serializes writers in one checkout; a push is a compare-and-swap
|
|
91
|
+
on the branch.
|
|
92
|
+
- The index applies the diff from its last commit to HEAD, and the new head, in one transaction. A
|
|
93
|
+
replay is safe, a crash keeps the old state, and `sync --full` rebuilds it from the files.
|
|
94
|
+
|
|
95
|
+
License: PolyForm Strict 1.0.0.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `knowledge`: agents write records with --by and --why, every command answers JSON. Writes take JSON
|
|
4
|
+
* on stdin (one object or an array: one commit), sync the index after the commit (read your writes),
|
|
5
|
+
* and push when knowledge.json says so or --push is given.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { basename, join } from "node:path";
|
|
9
|
+
import { Command, Option } from "commander";
|
|
10
|
+
import { head } from "./git.js";
|
|
11
|
+
import { lint } from "./lint.js";
|
|
12
|
+
import { newFaults, push } from "./push.js";
|
|
13
|
+
import { openIndex } from "./record-index.js";
|
|
14
|
+
import { TYPES } from "./records.js";
|
|
15
|
+
import { render } from "./render.js";
|
|
16
|
+
import { CONFIG, findRoot, loadAt, loadConfig, loadWorking } from "./repo.js";
|
|
17
|
+
import { LintError, withLock, write } from "./write.js";
|
|
18
|
+
const out = (v) => process.stdout.write(`${JSON.stringify(v, null, 2)}\n`);
|
|
19
|
+
const fail = (msg, extra = {}) => {
|
|
20
|
+
process.stdout.write(`${JSON.stringify({ error: msg, ...extra }, null, 2)}\n`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
};
|
|
23
|
+
const program = new Command("knowledge")
|
|
24
|
+
.description("Sources, findings, verdicts and rules as markdown records in a git repo, with an index.")
|
|
25
|
+
.option("--repo <dir>", "the repo root (default: KNOWLEDGE_DIR, else the nearest knowledge.json up)")
|
|
26
|
+
.option("--db <url>", "a Postgres index (default: KNOWLEDGE_DATABASE_URL, else PGlite in <repo>/.index)")
|
|
27
|
+
.option("--name <name>", "this repo's name in the index (default: knowledge.json name, else the folder)");
|
|
28
|
+
function ctx() {
|
|
29
|
+
const o = program.opts();
|
|
30
|
+
const root = findRoot(o.repo ?? process.env.KNOWLEDGE_DIR);
|
|
31
|
+
const cfg = loadConfig(root);
|
|
32
|
+
return { root, name: o.name ?? cfg.name ?? basename(root) };
|
|
33
|
+
}
|
|
34
|
+
/** Index work; a PGlite folder takes one process at a time, so it runs under the checkout's lock. */
|
|
35
|
+
async function withIndex(c, fn, locked = false) {
|
|
36
|
+
const url = program.opts().db ?? process.env.KNOWLEDGE_DATABASE_URL;
|
|
37
|
+
const run = async () => {
|
|
38
|
+
const ix = await openIndex(url ? { url } : { dir: join(c.root, ".index") });
|
|
39
|
+
try {
|
|
40
|
+
return await fn(ix);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
await ix.close();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return url || locked ? run() : withLock(c.root, run);
|
|
47
|
+
}
|
|
48
|
+
function stdinJson() {
|
|
49
|
+
const text = readFileSync(0, "utf8").trim();
|
|
50
|
+
if (!text)
|
|
51
|
+
fail("expected JSON on stdin");
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(text);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
return fail(`stdin is not JSON: ${e.message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const who = (o) => {
|
|
60
|
+
if (!o.by || !o.why)
|
|
61
|
+
fail("--by and --why are required");
|
|
62
|
+
return { by: o.by, why: o.why };
|
|
63
|
+
};
|
|
64
|
+
async function commit(changes, o) {
|
|
65
|
+
const c = ctx();
|
|
66
|
+
try {
|
|
67
|
+
const w = await write(c.root, changes, who(o));
|
|
68
|
+
const synced = await withIndex(c, (ix) => ix.sync(c.root, c.name));
|
|
69
|
+
const pushed = o.push || loadConfig(c.root).push ? push(c.root) : undefined;
|
|
70
|
+
out({
|
|
71
|
+
...w,
|
|
72
|
+
index: { head: synced.head, mode: synced.mode },
|
|
73
|
+
...(pushed ? { push: pushed } : {}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
if (e instanceof LintError)
|
|
78
|
+
fail("the change fails the lint; nothing was written", { problems: e.problems });
|
|
79
|
+
fail(e.message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const writeOpts = (cmd) => cmd
|
|
83
|
+
.requiredOption("--by <who>", "the agent's id, or the person")
|
|
84
|
+
.requiredOption("--why <text>", "why this change: lands in the record and the commit")
|
|
85
|
+
.option("--push", "push after the commit");
|
|
86
|
+
writeOpts(program
|
|
87
|
+
.command("add")
|
|
88
|
+
.description(`Add records from stdin: {"type": "${TYPES.join("|")}", "title", "body", "cites": [ids], …type fields}, or an array (one commit). An item may carry its own "why".`)).action(async (o) => {
|
|
89
|
+
const v = stdinJson();
|
|
90
|
+
const items = (Array.isArray(v) ? v : [v]);
|
|
91
|
+
await commit(items.map((i) => ({ ...i, op: "add" })), o);
|
|
92
|
+
});
|
|
93
|
+
writeOpts(program
|
|
94
|
+
.command("edit <id>")
|
|
95
|
+
.description('Change a record from a stdin patch: {"title", "body", "cites", …fields}; null drops a field.')).action(async (id, o) => {
|
|
96
|
+
const patch = stdinJson();
|
|
97
|
+
await commit([{ ...patch, op: "edit", id }], o);
|
|
98
|
+
});
|
|
99
|
+
writeOpts(program
|
|
100
|
+
.command("retire <ids...>")
|
|
101
|
+
.description("Retire records: kept in the repo, marked retired.")).action(async (ids, o) => {
|
|
102
|
+
await commit(ids.map((id) => ({ op: "retire", id })), o);
|
|
103
|
+
});
|
|
104
|
+
writeOpts(program
|
|
105
|
+
.command("apply")
|
|
106
|
+
.description('Mixed changes in one commit, from stdin: [{"op": "add|edit|retire", …}].')).action(async (o) => {
|
|
107
|
+
const v = stdinJson();
|
|
108
|
+
if (!Array.isArray(v))
|
|
109
|
+
fail("apply takes an array of changes");
|
|
110
|
+
await commit(v, o);
|
|
111
|
+
});
|
|
112
|
+
program
|
|
113
|
+
.command("show <id>")
|
|
114
|
+
.description("A record from the index: fields, body, what it cites, what cites it.")
|
|
115
|
+
.action(async (id) => {
|
|
116
|
+
const c = ctx();
|
|
117
|
+
const r = await withIndex(c, async (ix) => {
|
|
118
|
+
await ix.sync(c.root, c.name);
|
|
119
|
+
return ix.get(c.name, id);
|
|
120
|
+
});
|
|
121
|
+
if (!r)
|
|
122
|
+
fail(`no record ${id}`);
|
|
123
|
+
out(r);
|
|
124
|
+
});
|
|
125
|
+
program
|
|
126
|
+
.command("render <id>")
|
|
127
|
+
.description("A record as markdown (not JSON): its body, then its cites as a numbered Sources list. A skill or a reader takes this.")
|
|
128
|
+
.action((id) => {
|
|
129
|
+
const root = findRoot(program.opts().repo ?? process.env.KNOWLEDGE_DIR);
|
|
130
|
+
try {
|
|
131
|
+
process.stdout.write(render(root, id));
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
fail(e.message);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
program
|
|
138
|
+
.command("find [words...]")
|
|
139
|
+
.description("Records whose id, title or body hold every word; newest first.")
|
|
140
|
+
.addOption(new Option("--type <type>").choices([...TYPES]))
|
|
141
|
+
.option("--topic <topic>")
|
|
142
|
+
.option("--status <status>", "live | retired")
|
|
143
|
+
.option("--all-repos", "every repo in the index")
|
|
144
|
+
.option("-n <n>", "how many", "50")
|
|
145
|
+
.action(async (words, o) => {
|
|
146
|
+
const c = ctx();
|
|
147
|
+
const rows = await withIndex(c, async (ix) => {
|
|
148
|
+
await ix.sync(c.root, c.name);
|
|
149
|
+
return ix.find(o.allRepos ? null : c.name, {
|
|
150
|
+
q: words.join(" "),
|
|
151
|
+
type: o.type,
|
|
152
|
+
topic: o.topic,
|
|
153
|
+
status: o.status,
|
|
154
|
+
limit: Number(o.n),
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
out(rows.map((r) => ({
|
|
158
|
+
repo: r.repo,
|
|
159
|
+
id: r.id,
|
|
160
|
+
type: r.type,
|
|
161
|
+
title: r.title,
|
|
162
|
+
status: r.status,
|
|
163
|
+
path: r.path,
|
|
164
|
+
updated: r.updated,
|
|
165
|
+
})));
|
|
166
|
+
});
|
|
167
|
+
program
|
|
168
|
+
.command("stale")
|
|
169
|
+
.description("Live records whose evidence is missing, retired or changed after them.")
|
|
170
|
+
.action(async () => {
|
|
171
|
+
const c = ctx();
|
|
172
|
+
out(await withIndex(c, async (ix) => {
|
|
173
|
+
await ix.sync(c.root, c.name);
|
|
174
|
+
return ix.stale(c.name);
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
program
|
|
178
|
+
.command("lint")
|
|
179
|
+
.description("Check the tree: the working tree, or a commit (--rev). With --base, only faults the commit made.")
|
|
180
|
+
.option("--rev <rev>", "lint a commit instead of the working tree")
|
|
181
|
+
.option("--base <revs...>", "with --rev: report only errors none of these had (a pre-receive hook)")
|
|
182
|
+
.action((o) => {
|
|
183
|
+
const root = findRoot(program.opts().repo ?? process.env.KNOWLEDGE_DIR);
|
|
184
|
+
const owner = loadConfig(root).owner;
|
|
185
|
+
const problems = o.rev
|
|
186
|
+
? o.base
|
|
187
|
+
? newFaults(root, owner, o.base, o.rev)
|
|
188
|
+
: lint(loadAt(root, o.rev), owner)
|
|
189
|
+
: lint(loadWorking(root), owner);
|
|
190
|
+
const errs = problems.filter((p) => p.level === "error").length;
|
|
191
|
+
out({ errors: errs, warnings: problems.length - errs, problems });
|
|
192
|
+
if (errs)
|
|
193
|
+
process.exit(1);
|
|
194
|
+
});
|
|
195
|
+
program
|
|
196
|
+
.command("sync")
|
|
197
|
+
.description("Bring the index up to HEAD.")
|
|
198
|
+
.option("--full", "rebuild this repo's rows from the files")
|
|
199
|
+
.action(async (o) => {
|
|
200
|
+
const c = ctx();
|
|
201
|
+
out(await withIndex(c, (ix) => ix.sync(c.root, c.name, { full: !!o.full })));
|
|
202
|
+
});
|
|
203
|
+
program
|
|
204
|
+
.command("push")
|
|
205
|
+
.description("Push; when the remote moved, merge, lint the merge, try again.")
|
|
206
|
+
.action(async () => {
|
|
207
|
+
const c = ctx();
|
|
208
|
+
const p = push(c.root);
|
|
209
|
+
if (p.pushed)
|
|
210
|
+
await withIndex(c, (ix) => ix.sync(c.root, c.name));
|
|
211
|
+
out(p);
|
|
212
|
+
if (!p.pushed)
|
|
213
|
+
process.exit(1);
|
|
214
|
+
});
|
|
215
|
+
program
|
|
216
|
+
.command("init")
|
|
217
|
+
.description("Make this folder (a git repo) a knowledge repo: knowledge.json, .index/ ignored.")
|
|
218
|
+
.option("--owner <name>", "who may write a rule with no cites", "owner")
|
|
219
|
+
.option("--name <name>", "this repo's name in the index")
|
|
220
|
+
.action((o) => {
|
|
221
|
+
const root = program.opts().repo ?? process.cwd();
|
|
222
|
+
if (!head(root) && !existsSync(join(root, ".git")))
|
|
223
|
+
fail("not a git repo: git init first");
|
|
224
|
+
const cfgPath = join(root, CONFIG);
|
|
225
|
+
if (!existsSync(cfgPath))
|
|
226
|
+
writeFileSync(cfgPath, `${JSON.stringify({ ...(o.name ? { name: o.name } : {}), owner: o.owner, push: false }, null, 2)}\n`);
|
|
227
|
+
const gi = join(root, ".gitignore");
|
|
228
|
+
const cur = existsSync(gi) ? readFileSync(gi, "utf8") : "";
|
|
229
|
+
if (!/^\.index\/?$/m.test(cur))
|
|
230
|
+
writeFileSync(gi, `${cur}${cur && !cur.endsWith("\n") ? "\n" : ""}.index/\n`);
|
|
231
|
+
out({ root, config: loadConfig(root) });
|
|
232
|
+
});
|
|
233
|
+
program.parseAsync().catch((e) => fail(e.message));
|
|
234
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAoB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,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QACtB,aAAa,CACX,OAAO,EACP,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CACrG,CAAC;IACJ,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5B,aAAa,CAAC,EAAE,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAChF,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class GitError extends Error {
|
|
2
|
+
name: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function git(cwd: string, args: string[], input?: string | Buffer): string;
|
|
5
|
+
export declare function gitBuf(cwd: string, args: string[], input?: string | Buffer): Buffer;
|
|
6
|
+
export declare function tryGit(cwd: string, args: string[]): {
|
|
7
|
+
ok: boolean;
|
|
8
|
+
out: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const head: (cwd: string) => string | null;
|
|
11
|
+
export declare const isAncestor: (cwd: string, a: string, b: string) => boolean;
|
|
12
|
+
/** Every path under `dirs` at a commit. */
|
|
13
|
+
export declare function lsTree(cwd: string, rev: string, dirs: readonly string[]): string[];
|
|
14
|
+
/** Paths changed between two commits under `dirs`: added or modified, and deleted. No renames (a delete plus an add). */
|
|
15
|
+
export declare function diff(cwd: string, from: string, to: string, dirs: readonly string[]): {
|
|
16
|
+
changed: string[];
|
|
17
|
+
deleted: string[];
|
|
18
|
+
};
|
|
19
|
+
/** File texts at a commit, in one `cat-file --batch`. A missing path is left out. */
|
|
20
|
+
export declare function readAt(cwd: string, rev: string, paths: readonly string[]): Map<string, string>;
|
package/dist/git.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** The git calls the store needs. The git CLI, so a bare repo (a server's hook) works the same. */
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
const MAX = 512 * 1024 * 1024;
|
|
4
|
+
export class GitError extends Error {
|
|
5
|
+
name = "GitError";
|
|
6
|
+
}
|
|
7
|
+
export function git(cwd, args, input) {
|
|
8
|
+
return gitBuf(cwd, args, input).toString("utf8").trimEnd();
|
|
9
|
+
}
|
|
10
|
+
export function gitBuf(cwd, args, input) {
|
|
11
|
+
try {
|
|
12
|
+
return execFileSync("git", args, {
|
|
13
|
+
cwd,
|
|
14
|
+
maxBuffer: MAX,
|
|
15
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
16
|
+
...(input !== undefined ? { input } : {}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
const err = e;
|
|
21
|
+
throw new GitError(`git ${args[0]}: ${err.stderr?.toString().trim() || err.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function tryGit(cwd, args) {
|
|
25
|
+
try {
|
|
26
|
+
return { ok: true, out: git(cwd, args) };
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
return { ok: false, out: e.message };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const head = (cwd) => {
|
|
33
|
+
const r = tryGit(cwd, ["rev-parse", "--verify", "-q", "HEAD"]);
|
|
34
|
+
return r.ok && r.out ? r.out : null;
|
|
35
|
+
};
|
|
36
|
+
export const isAncestor = (cwd, a, b) => tryGit(cwd, ["merge-base", "--is-ancestor", a, b]).ok;
|
|
37
|
+
/** Every path under `dirs` at a commit. */
|
|
38
|
+
export function lsTree(cwd, rev, dirs) {
|
|
39
|
+
const out = gitBuf(cwd, ["ls-tree", "-r", "-z", "--name-only", rev, "--", ...dirs]).toString("utf8");
|
|
40
|
+
return out.split("\0").filter(Boolean);
|
|
41
|
+
}
|
|
42
|
+
/** Paths changed between two commits under `dirs`: added or modified, and deleted. No renames (a delete plus an add). */
|
|
43
|
+
export function diff(cwd, from, to, dirs) {
|
|
44
|
+
const out = gitBuf(cwd, [
|
|
45
|
+
"diff",
|
|
46
|
+
"--no-renames",
|
|
47
|
+
"--name-status",
|
|
48
|
+
"-z",
|
|
49
|
+
from,
|
|
50
|
+
to,
|
|
51
|
+
"--",
|
|
52
|
+
...dirs,
|
|
53
|
+
]).toString("utf8");
|
|
54
|
+
const parts = out.split("\0").filter(Boolean);
|
|
55
|
+
const changed = [];
|
|
56
|
+
const deleted = [];
|
|
57
|
+
for (let i = 0; i + 1 < parts.length; i += 2) {
|
|
58
|
+
const status = parts[i];
|
|
59
|
+
const path = parts[i + 1];
|
|
60
|
+
(status.startsWith("D") ? deleted : changed).push(path);
|
|
61
|
+
}
|
|
62
|
+
return { changed, deleted };
|
|
63
|
+
}
|
|
64
|
+
/** File texts at a commit, in one `cat-file --batch`. A missing path is left out. */
|
|
65
|
+
export function readAt(cwd, rev, paths) {
|
|
66
|
+
const files = new Map();
|
|
67
|
+
if (!paths.length)
|
|
68
|
+
return files;
|
|
69
|
+
const buf = gitBuf(cwd, ["cat-file", "--batch"], paths.map((p) => `${rev}:${p}\n`).join(""));
|
|
70
|
+
let at = 0;
|
|
71
|
+
for (const p of paths) {
|
|
72
|
+
const nl = buf.indexOf(10, at);
|
|
73
|
+
const line = buf.subarray(at, nl).toString("utf8");
|
|
74
|
+
at = nl + 1;
|
|
75
|
+
if (line.endsWith(" missing"))
|
|
76
|
+
continue;
|
|
77
|
+
const size = Number(line.split(" ")[2]);
|
|
78
|
+
files.set(p, buf.subarray(at, at + size).toString("utf8"));
|
|
79
|
+
at += size + 1;
|
|
80
|
+
}
|
|
81
|
+
return files;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9B,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,GAAG,UAAU,CAAC;CAC5B;AAED,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,KAAuB;IACtE,OAAO,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,IAAc,EAAE,KAAuB;IACzE,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;YAC/B,GAAG;YACH,SAAS,EAAE,GAAG;YACd,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,GAAG,CAAC,KAAK,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"./push.js";
|
|
4
|
+
export * from "./record-index.js";
|
|
5
|
+
export * from "./records.js";
|
|
6
|
+
export * from "./render.js";
|
|
7
|
+
export * from "./repo.js";
|
|
8
|
+
export * from "./write.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
package/dist/lint.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules a tree must hold before a commit lands (a write) or a head moves (push, server hook).
|
|
3
|
+
* Errors refuse the change; warnings report stale links.
|
|
4
|
+
*/
|
|
5
|
+
import type { Tree } from "./repo.js";
|
|
6
|
+
export interface Problem {
|
|
7
|
+
level: "error" | "warn";
|
|
8
|
+
path: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
msg: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function lint(tree: Tree, owner: string): Problem[];
|
|
13
|
+
export declare const errors: (ps: Problem[]) => Problem[];
|
package/dist/lint.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules a tree must hold before a commit lands (a write) or a head moves (push, server hook).
|
|
3
|
+
* Errors refuse the change; warnings report stale links.
|
|
4
|
+
*/
|
|
5
|
+
import { CITE_NUMBER, edgesOf, pathOf } from "./records.js";
|
|
6
|
+
export function lint(tree, owner) {
|
|
7
|
+
const out = tree.broken.map((b) => ({
|
|
8
|
+
level: "error",
|
|
9
|
+
path: b.path,
|
|
10
|
+
msg: b.error,
|
|
11
|
+
}));
|
|
12
|
+
const byId = new Map();
|
|
13
|
+
for (const l of tree.docs) {
|
|
14
|
+
const { fm } = l.doc;
|
|
15
|
+
const e = (msg) => out.push({ level: "error", path: l.path, id: fm.id, msg });
|
|
16
|
+
const prev = byId.get(fm.id);
|
|
17
|
+
if (prev)
|
|
18
|
+
e(`id ${fm.id} is also at ${prev.path}`);
|
|
19
|
+
else
|
|
20
|
+
byId.set(fm.id, l);
|
|
21
|
+
const want = pathOf(fm);
|
|
22
|
+
if (l.path !== want)
|
|
23
|
+
e(`a ${fm.type} with this id belongs at ${want}`);
|
|
24
|
+
}
|
|
25
|
+
for (const l of tree.docs) {
|
|
26
|
+
const { fm } = l.doc;
|
|
27
|
+
const e = (level, msg) => out.push({ level, path: l.path, id: fm.id, msg });
|
|
28
|
+
for (const to of edgesOf(fm)) {
|
|
29
|
+
const t = byId.get(to)?.doc.fm;
|
|
30
|
+
if (to === fm.id)
|
|
31
|
+
e("error", "cites itself");
|
|
32
|
+
else if (!t)
|
|
33
|
+
e("error", `cites ${to}, which is not in the repo`);
|
|
34
|
+
else if (fm.status === "live" && t.status === "retired")
|
|
35
|
+
e("warn", `cites ${to}, which is retired`);
|
|
36
|
+
}
|
|
37
|
+
if (fm.type === "finding") {
|
|
38
|
+
const s = byId.get(fm.source)?.doc.fm;
|
|
39
|
+
if (s && s.type !== "source")
|
|
40
|
+
e("error", `source ${fm.source} is a ${s.type}, not a source`);
|
|
41
|
+
}
|
|
42
|
+
if (fm.type === "guide")
|
|
43
|
+
for (const m of l.doc.body.matchAll(CITE_NUMBER)) {
|
|
44
|
+
const n = Number(m[1]);
|
|
45
|
+
if (n < 1 || n > fm.cites.length) {
|
|
46
|
+
e("error", `[${n}] has no cite: the guide cites ${fm.cites.length}`);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (fm.type === "rule" && fm.status === "live" && fm.cites.length === 0 && fm.by !== owner)
|
|
51
|
+
e("error", `a rule cites its evidence; only ${owner} may write one with none`);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
export const errors = (ps) => ps.filter((p) => p.level === "error");
|
|
56
|
+
//# sourceMappingURL=lint.js.map
|
package/dist/lint.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAU5D,MAAM,UAAU,IAAI,CAAC,IAAU,EAAE,KAAa;IAC5C,MAAM,GAAG,GAAc,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7C,KAAK,EAAE,OAAgB;QACvB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,GAAG,EAAE,CAAC,CAAC,KAAK;KACb,CAAC,CAAC,CAAC;IACJ,MAAM,IAAI,GAAG,IAAI,GAAG,EAAsC,CAAC;IAC3D,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1B,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC;QACrB,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACtF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,IAAI;YAAE,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,eAAe,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;;YAC9C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACxB,MAAM,IAAI,GAA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,EAAE,CAAC,MAAM,SAAS,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC;QAC/F,CAAC;QACD,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO;YACrB,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACjD,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;oBACjC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,kCAAkC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;oBACrE,MAAM;gBACR,CAAC;YACH,CAAC;QACH,IAAI,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,EAAE,CAAC,MAAM,KAAK,MAAM,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,KAAK;YACxF,CAAC,CAAC,OAAO,EAAE,mCAAmC,KAAK,0BAA0B,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAa,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC"}
|
package/dist/push.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Problem } from "./lint.js";
|
|
2
|
+
export interface Pushed {
|
|
3
|
+
pushed: boolean;
|
|
4
|
+
head: string | null;
|
|
5
|
+
merged: boolean;
|
|
6
|
+
tries: number;
|
|
7
|
+
problems?: Problem[];
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function push(root: string, tries?: number): Pushed;
|
|
11
|
+
/**
|
|
12
|
+
* The lint errors at `rev` that no base had: what a change made. A push, and a server's pre-receive
|
|
13
|
+
* hook (`knowledge lint --rev <new> --base <old>`), refuse on these only.
|
|
14
|
+
*/
|
|
15
|
+
export declare function newFaults(root: string, owner: string, bases: string[], rev: string): Problem[];
|