@hraness/wordcell 0.20.0-bootstrap.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/LICENSE +21 -0
- package/README.md +749 -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 +57 -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 +41 -0
- package/dist/index-054mb7d3.js +1974 -0
- package/dist/index-06c9ctr6.js +738 -0
- package/dist/index-180zbkkt.js +2480 -0
- package/dist/index-1gwbassd.js +743 -0
- package/dist/index-1xxnjn0d.js +171 -0
- package/dist/index-23z4zxgg.js +119 -0
- package/dist/index-2gv8y733.js +432 -0
- package/dist/index-3ehtt59c.js +199 -0
- package/dist/index-3rm7cz6h.js +373 -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-6jcz0m1c.js +712 -0
- package/dist/index-6sw24nvv.js +1189 -0
- package/dist/index-8a08v6x8.js +56 -0
- package/dist/index-adx6khj5.js +488 -0
- package/dist/index-b88v3vtm.js +805 -0
- package/dist/index-bcknqxrq.js +1943 -0
- package/dist/index-bs0yf4pp.js +711 -0
- package/dist/index-by0pbant.js +827 -0
- package/dist/index-d13v9ckt.js +150 -0
- package/dist/index-dfag79p7.js +370 -0
- package/dist/index-e4fagfjz.js +44 -0
- package/dist/index-e5fbsywq.js +658 -0
- package/dist/index-ekpwvbra.js +1070 -0
- package/dist/index-f984hw45.js +927 -0
- package/dist/index-gh719d91.js +63 -0
- package/dist/index-h170byqw.js +371 -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-m7et4rz4.js +966 -0
- package/dist/index-mxxxytys.js +1254 -0
- package/dist/index-n05s3wsb.js +2728 -0
- package/dist/index-nd6nynv2.js +1162 -0
- package/dist/index-npg9z1a4.js +431 -0
- package/dist/index-pj501bh1.js +140 -0
- package/dist/index-rdd5f7jj.js +70 -0
- package/dist/index-sy0zety7.js +3630 -0
- package/dist/index-tkpxp48t.js +1166 -0
- package/dist/index-w2zc0vwa.js +571 -0
- package/dist/index-why54q5p.js +462 -0
- package/dist/index-x3fthpsc.js +585 -0
- package/dist/index-x6m57nfc.js +1041 -0
- package/dist/index.js +784 -0
- package/dist/kb-alias.js +55 -0
- package/dist/navigation.js +13 -0
- package/dist/pdf.js +85 -0
- package/dist/percolate.js +44 -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 +421 -0
- package/skills/wordcell/AGENTS.md +22 -0
- package/skills/wordcell/SKILL.md +91 -0
- package/skills/wordcell/agents/openai.yaml +4 -0
- package/skills/wordcell/references/companion-skills.md +96 -0
- package/skills/wordcell/references/customize.md +123 -0
- package/skills/wordcell/references/pdf-review.md +51 -0
- package/skills/wordcell/references/percolate.md +176 -0
- package/skills/wordcell/references/plan-structure.md +105 -0
- package/skills/wordcell/references/plan.md +115 -0
- package/skills/wordcell/references/query.md +252 -0
- package/skills/wordcell/references/refresh.md +133 -0
- package/skills/wordcell/references/save-pdf.md +125 -0
- package/skills/wordcell/references/save-url.md +178 -0
- package/skills/wordcell/references/url-authentication.md +75 -0
- package/skills/wordcell/references/url-platforms.md +25 -0
- package/skills/wordcell/templates/companion-skill.template.md +57 -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-model.ts +798 -0
- package/src/authoring-platform.ts +549 -0
- package/src/authoring-program.ts +278 -0
- package/src/authoring-runtime.ts +54 -0
- package/src/authoring.ts +75 -0
- package/src/benchmark.ts +362 -0
- package/src/capture.ts +68 -0
- package/src/cli-program.ts +3662 -0
- package/src/cli.ts +6 -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 +1494 -0
- package/src/index.ts +21 -0
- package/src/init.ts +123 -0
- package/src/kb-alias.ts +14 -0
- package/src/navigation.ts +277 -0
- package/src/note-lock.ts +529 -0
- package/src/oh-adoption.ts +444 -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 +1948 -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-model.ts +444 -0
- package/src/workflow-platform.ts +74 -0
- package/src/workflow-program.ts +183 -0
- package/src/workflow-runtime.ts +51 -0
- package/src/workflow.ts +23 -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,252 @@
|
|
|
1
|
+
# Query the knowledge base
|
|
2
|
+
|
|
3
|
+
Use the cheapest precise view first, then broaden. Markdown files remain the
|
|
4
|
+
authority; search scores, metadata rows, and graph results are derived views.
|
|
5
|
+
|
|
6
|
+
## Locate the vault
|
|
7
|
+
|
|
8
|
+
- Resolve `<vault>` to the directory containing its managed or authored `index.md`, then
|
|
9
|
+
set the shell-local `KB_ROOT` to that path (`KB_ROOT=kb` from a typical
|
|
10
|
+
repository root, or `KB_ROOT=.` from inside the vault).
|
|
11
|
+
- Resolve `<repository>` to the repository root when the question concerns a
|
|
12
|
+
repository path (`KB_REPO=.` from that root).
|
|
13
|
+
- Read the vault's applicable agent instructions and note conventions.
|
|
14
|
+
- Pass the resolved path to every `--root`; do not scan a repository root merely
|
|
15
|
+
because that is where the agent session started.
|
|
16
|
+
|
|
17
|
+
## Recover a stopped session
|
|
18
|
+
|
|
19
|
+
When the user asks to resume earlier work, begin with the path being changed.
|
|
20
|
+
Keep each retrieval signal separate so the agent can inspect why a record was
|
|
21
|
+
returned:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
wordcell context packages/parser/src/index.ts --root "$KB_ROOT" --repo "$KB_REPO"
|
|
25
|
+
wordcell search "why parser retries stop" --root "$KB_ROOT" --mode exact \
|
|
26
|
+
--history --repo "$KB_REPO" --json
|
|
27
|
+
wordcell backlinks notes/parser-contract --root "$KB_ROOT" --json
|
|
28
|
+
wordcell history notes/parser-contract --root "$KB_ROOT" \
|
|
29
|
+
--repo "$KB_REPO" --json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Replace the example path, query, and note ID with values from the current task.
|
|
33
|
+
Read the inherited guides and authoritative Markdown returned by these views.
|
|
34
|
+
Use the backlink to inspect related plans and use Git history as provenance,
|
|
35
|
+
not as proof that the note remains correct. This workflow recovers only context
|
|
36
|
+
that was persisted in files or Git; it does not reconstruct private chat.
|
|
37
|
+
|
|
38
|
+
## Choose the retrieval lane
|
|
39
|
+
|
|
40
|
+
- Repository file or directory: run `wordcell context` first. Read its inherited
|
|
41
|
+
guides root to nearest, then inspect its maintained knowledge, active plans,
|
|
42
|
+
dated research, reports, and separate historical-plan group. Open only useful
|
|
43
|
+
context hubs or records.
|
|
44
|
+
- Known frontmatter field or tag such as type, status, or area: use `wordcell list`.
|
|
45
|
+
- Known note title, path, or alias: use `wordcell links` or `wordcell backlinks`, which
|
|
46
|
+
resolve note identities before returning authored relationships.
|
|
47
|
+
- A whole-vault structural question or relationship audit: use `wordcell graph --json`,
|
|
48
|
+
then inspect the smallest relevant portion of its canonical output.
|
|
49
|
+
- A phrase, identity, or concept expressed with different vocabulary: use `wordcell search`, whose default hybrid result preserves exact and QMD evidence separately.
|
|
50
|
+
- Direct provenance for one note or repository path: use `wordcell history` or
|
|
51
|
+
`wordcell history search` without changing authored metadata or links.
|
|
52
|
+
- Recent captures awaiting maintained disposition: use the advisory `wordcell inbox` view.
|
|
53
|
+
- Broad orientation: read `index.md`, then follow the smallest useful link trail. Use `wordcell catalog` when an exhaustive disposable inventory is actually needed.
|
|
54
|
+
- A question spanning registered vaults: use `wordcell portfolio search` with a reviewed registry and explicit authorization. Use `wordcell portfolio audit` to assess IDs, duplicate authority, links, attachments, and provenance without repairing content.
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
wordcell context src/parser.ts --root "$KB_ROOT" --repo "$KB_REPO"
|
|
58
|
+
wordcell list --root "$KB_ROOT" --scope src/parser --where type=plan --json
|
|
59
|
+
wordcell list --root "$KB_ROOT" --where type=plan --where status=in-progress --sort area --json
|
|
60
|
+
wordcell list --root "$KB_ROOT" --tag retrieval --sort title --json
|
|
61
|
+
wordcell backlinks "Plan title or path" --root "$KB_ROOT" --json
|
|
62
|
+
wordcell links "Plan title or path" --root "$KB_ROOT" --direction both --depth 1 --limit 25 --json
|
|
63
|
+
wordcell relation list "Plan title or path" --root "$KB_ROOT" --json
|
|
64
|
+
wordcell graph --root "$KB_ROOT" --json
|
|
65
|
+
wordcell search "why browser capture uses the current tab" --root "$KB_ROOT" --json
|
|
66
|
+
wordcell search "accepted ingestion plans" --root "$KB_ROOT" --where type=plan --where status=accepted --tag ingestion --json
|
|
67
|
+
wordcell search "notes/write-path" --root "$KB_ROOT" --mode exact --no-history --json
|
|
68
|
+
wordcell history "notes/write-path" --root "$KB_ROOT" --repo "$KB_REPO" --json
|
|
69
|
+
wordcell history search src/parser.ts --root "$KB_ROOT" --repo "$KB_REPO" --json
|
|
70
|
+
wordcell inbox --root "$KB_ROOT" --limit 25 --json
|
|
71
|
+
wordcell portfolio search "durable memory" --registry ./kb-portfolio.json --workspace .. --shared --json
|
|
72
|
+
wordcell portfolio audit --registry ./kb-portfolio.json --workspace .. --vault hraness/wordcell --vault 0thernet/jungle --strict --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Portfolio selection is an access decision. Prefer repeated `--vault owner/id`
|
|
76
|
+
for deliberate private or personal scope. `--shared` selects only public and
|
|
77
|
+
organization entries; `--all` exists only for audit. One operation is bounded
|
|
78
|
+
to 32 vaults and never silently truncates a larger registry-derived selection.
|
|
79
|
+
Open returned notes before concluding. Cross-vault scores are not compared;
|
|
80
|
+
federation uses deterministic reciprocal local rank and stable logical IDs.
|
|
81
|
+
|
|
82
|
+
When a reviewed consumer policy needs repeatable query shorthand, pass a strict
|
|
83
|
+
v1 rules file. An alias is recognized only as the first token and can add a
|
|
84
|
+
query, mode, metadata filters, tags, or repository scopes without discarding
|
|
85
|
+
caller constraints. Priority ordering is a separate opt-in:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
wordcell search "@active-plans parser" --root "$KB_ROOT" \
|
|
89
|
+
--rules ./search-rules.json --priority --json
|
|
90
|
+
wordcell portfolio search "@active-plans parser" \
|
|
91
|
+
--registry ./kb-portfolio.json --workspace .. --shared \
|
|
92
|
+
--rules ./search-rules.json --priority --json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`--rules` alone enables aliases but retains relevance order. `--priority`
|
|
96
|
+
requires a rules file and requests `priority-then-relevance`; exact identities
|
|
97
|
+
still come first, and matching selected hits carry a rule trace. Keep this
|
|
98
|
+
policy beside the registry or repository that owns it. Rules do not grant
|
|
99
|
+
access, choose authority, author links, or mutate Markdown.
|
|
100
|
+
|
|
101
|
+
`wordcell context` prints hub and record summaries, not their bodies. Each record
|
|
102
|
+
states the exact `repository_scopes` declaration that matched, the match depth,
|
|
103
|
+
and whether that declaration currently names a file, directory, or absent
|
|
104
|
+
future or retired path. Current memory and terminal plans stay in separate
|
|
105
|
+
groups. Guides remain
|
|
106
|
+
the normative, always-loaded home for ownership, required commands,
|
|
107
|
+
prohibitions, invariants, and edit gates. Scope hubs are optional pull-based
|
|
108
|
+
rationale, history, examples, evidence, and links; they cannot override a guide
|
|
109
|
+
or become the only home of a load-bearing rule. Use `--kind file` or
|
|
110
|
+
`--kind directory` when `auto` cannot classify a missing target reliably.
|
|
111
|
+
|
|
112
|
+
Repeated filters use AND semantics. Metadata paths may be dotted. String and
|
|
113
|
+
tag comparisons are case-insensitive; array metadata matches by membership.
|
|
114
|
+
Missing sort values come last, with path as the deterministic tie-breaker.
|
|
115
|
+
`--where` addresses authored frontmatter only; it does not filter derived H1
|
|
116
|
+
titles or file paths. Unquoted `true`, `false`, `null`, and numeric filter
|
|
117
|
+
values are typed. Keep quotes inside the argument to match a string with the
|
|
118
|
+
same spelling, for example `--where 'external_id="9007199254740993"'`.
|
|
119
|
+
`--scope` is an exact, case-sensitive repository-scope filter rather than a
|
|
120
|
+
substring or area match. Use it when the desired authored path declaration is
|
|
121
|
+
known.
|
|
122
|
+
|
|
123
|
+
## Use hybrid search as discovery
|
|
124
|
+
|
|
125
|
+
`wordcell search` first scans current Markdown for identity, phrase, metadata, tag,
|
|
126
|
+
and prose matches. By default it runs that exact lane alongside QMD's local
|
|
127
|
+
full-text and vector rankings, then combines the ranked lists while retaining
|
|
128
|
+
each lane's evidence. Exact title and alias identities stay ahead of broader
|
|
129
|
+
matches. The QMD path avoids query expansion and reranking models by default.
|
|
130
|
+
|
|
131
|
+
The first hybrid or semantic query downloads QMD's compact local embedding
|
|
132
|
+
model; later queries reuse the local cache. Prewarm explicitly when useful:
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
wordcell index --root "$KB_ROOT"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Use `--mode exact` for live model-free search, `--mode keyword` for QMD
|
|
139
|
+
full-text retrieval, or `--mode semantic` for its vector lane. Repeated
|
|
140
|
+
`--where`, `--has`, and `--tag` constraints are checked against the live
|
|
141
|
+
Markdown snapshot. QMD has no path-allowlist search in the pinned release, so a
|
|
142
|
+
selective semantic query over-fetches a bounded global window and reports a
|
|
143
|
+
degraded partial lane when that window cannot prove completeness. Treat every
|
|
144
|
+
retrieval rank as a lead, not a fact. Open the returned Markdown, read enough
|
|
145
|
+
surrounding context, and confirm claims against linked sources or capture
|
|
146
|
+
manifests.
|
|
147
|
+
|
|
148
|
+
Default search also returns bounded explicit graph context around the strongest
|
|
149
|
+
results. Supply `--related <note>` to seed a known neighborhood or `--no-graph`
|
|
150
|
+
when structure does not help. Search does no Git work unless provenance is
|
|
151
|
+
requested. Use `--history --repo <repository>` for optional recent per-note
|
|
152
|
+
provenance or `--require-history --repo <repository>` when the task cannot
|
|
153
|
+
proceed with a partial Git lane. `--no-history` remains an explicit compatibility
|
|
154
|
+
form. Graph neighbors and Git history remain separate from primary
|
|
155
|
+
text rank. They explain and expand candidates without becoming authored facts,
|
|
156
|
+
links, or recency boosts.
|
|
157
|
+
|
|
158
|
+
`wordcell history <note>` returns the bounded commit history already associated with
|
|
159
|
+
one resolved note. `wordcell history search <query-or-path>` searches the bounded Git
|
|
160
|
+
projection directly and retains hashes, subjects, matched paths, co-change
|
|
161
|
+
paths, and incomplete-detail diagnostics. Git co-change is historical evidence,
|
|
162
|
+
not permission to write a scope or relationship.
|
|
163
|
+
|
|
164
|
+
## Reuse one snapshot in code mode
|
|
165
|
+
|
|
166
|
+
For several related queries, prefer one SDK session to repeated CLI process
|
|
167
|
+
startup:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import { openKnowledgeBase, packUntrustedSearchContext } from "@hraness/wordcell/sdk";
|
|
171
|
+
|
|
172
|
+
const kb = await openKnowledgeBase({ root: "kb", repository: "." });
|
|
173
|
+
try {
|
|
174
|
+
const result = await kb.search({
|
|
175
|
+
query: "why browser capture uses the current tab",
|
|
176
|
+
graph: { depth: 1 },
|
|
177
|
+
history: "auto",
|
|
178
|
+
});
|
|
179
|
+
console.log(packUntrustedSearchContext(result).content);
|
|
180
|
+
} finally {
|
|
181
|
+
await kb.close();
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`grep`, `list`, `read`, `links`, `backlinks`, `search`, `history`, and
|
|
186
|
+
`searchHistory` share one confined read-only scan. QMD and Git initialize
|
|
187
|
+
lazily. The session does not watch Markdown or repository changes. Close it
|
|
188
|
+
before a write and open a new session after the final refresh and check.
|
|
189
|
+
|
|
190
|
+
Pass only ordinary plain objects and arrays from Wordcell or parsed JSON into
|
|
191
|
+
`packUntrustedSearchContext`. A same-realm JavaScript `Proxy` is executable
|
|
192
|
+
code, not inert data; isolate or serialize it before projection.
|
|
193
|
+
|
|
194
|
+
When independent queries can run concurrently, compose them with
|
|
195
|
+
`defineWorkflow` and `runWorkflow` or import a packaged workflow. The runner
|
|
196
|
+
validates a finite acyclic graph, caps global concurrency, serializes QMD nodes,
|
|
197
|
+
and keeps Git concurrency bounded. Do not bypass those resource groups with
|
|
198
|
+
unbounded `Promise.all` calls. Custom workflows use the staged
|
|
199
|
+
`defineWorkflow<Input>("id").node(...).output(...)` builder so dependency
|
|
200
|
+
results and the final output remain typed.
|
|
201
|
+
|
|
202
|
+
## Use focused structural views
|
|
203
|
+
|
|
204
|
+
`wordcell graph --json` returns the current resolved wikilinks, typed relationships,
|
|
205
|
+
diagnostics, and note-level connection counts without creating a second graph
|
|
206
|
+
store. Use it when a question spans the vault. Prefer `wordcell relation list`,
|
|
207
|
+
`wordcell backlinks`, or `wordcell links` when a known note gives you a narrower starting
|
|
208
|
+
point.
|
|
209
|
+
|
|
210
|
+
`wordcell links` is cycle-safe and requires an explicit traversal depth and result
|
|
211
|
+
limit. `wordcell relation list` separates authored outbound assertions from derived
|
|
212
|
+
inbound relationships while retaining canonical note IDs and source
|
|
213
|
+
provenance. Open the returned Markdown before treating an edge as correct: a
|
|
214
|
+
typed relationship records an authored assertion, not proof.
|
|
215
|
+
|
|
216
|
+
If a structural question is not covered by a named command, inspect the
|
|
217
|
+
bounded JSON graph in the agent or a short task-local script. Do not create or
|
|
218
|
+
commit a parallel graph database merely to answer one query. A recurring query
|
|
219
|
+
is evidence for a focused, tested command with an explicit output contract.
|
|
220
|
+
|
|
221
|
+
## Combine meaning with structure
|
|
222
|
+
|
|
223
|
+
1. For a repository-path question, use `wordcell context` before broader retrieval.
|
|
224
|
+
2. Use default hybrid search to discover candidate identities when exact
|
|
225
|
+
structure does not answer the question. Read its lane evidence and partial
|
|
226
|
+
diagnostics before relying on the order.
|
|
227
|
+
3. Use `wordcell list` to narrow by authored metadata such as `type`, `status`,
|
|
228
|
+
`area`, or `tags`.
|
|
229
|
+
4. Use `wordcell links` at depth 1 to inspect immediate explicit relationships and
|
|
230
|
+
`wordcell backlinks` for a focused inbound view. Increase depth only when the
|
|
231
|
+
first neighborhood is insufficient. Traversal defaults to 50 notes and
|
|
232
|
+
reports truncation; lower `--limit` for tighter agent context or raise it
|
|
233
|
+
deliberately when a high-degree hub is genuinely relevant.
|
|
234
|
+
5. Use `wordcell graph --json` only when the question genuinely spans multiple
|
|
235
|
+
neighborhoods; keep one-off processing task-local.
|
|
236
|
+
6. Read the authoritative notes and cited captures before synthesizing.
|
|
237
|
+
|
|
238
|
+
A title match may identify a prerequisite, prior version, or supporting note
|
|
239
|
+
rather than the artifact that owns the current outcome. Confirm status and
|
|
240
|
+
ownership in the candidate Markdown before answering or editing it.
|
|
241
|
+
|
|
242
|
+
Do not infer an edge from semantic similarity, or a conclusion from a tag. Do
|
|
243
|
+
not write generated backlink sections into notes. If the query exposes stale
|
|
244
|
+
metadata or a broken link, repair the authored Markdown and finish with
|
|
245
|
+
`wordcell refresh --root "$KB_ROOT"` and `wordcell check --root "$KB_ROOT"`.
|
|
246
|
+
Close any open SDK session before that repair and reopen it after validation.
|
|
247
|
+
|
|
248
|
+
An authored `index.md` may declare `kb_catalog: authored`; refresh and check
|
|
249
|
+
then leave it untouched. `wordcell catalog --root "$KB_ROOT"` renders the exhaustive
|
|
250
|
+
inventory on demand. A managed vault keeps the original generated-catalog
|
|
251
|
+
behavior. Neither mode changes scanning, graph analysis, semantic indexing, or
|
|
252
|
+
attachment validation.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Refresh a knowledge base
|
|
2
|
+
|
|
3
|
+
Use a refresh-review-check loop. Keep authored prose under deliberate editorial control. A managed vault gives the marked catalog region to the tool; an authored vault leaves its complete front door untouched.
|
|
4
|
+
|
|
5
|
+
## 1. Locate the vault
|
|
6
|
+
|
|
7
|
+
- Resolve `<vault>` to the directory containing its managed or authored `index.md`, then
|
|
8
|
+
set the shell-local `KB_ROOT` to that path (`KB_ROOT=kb` from a typical
|
|
9
|
+
repository root, or `KB_ROOT=.` from inside the vault).
|
|
10
|
+
- When the change concerns `scopes/` or an `kb:context` marker, resolve the
|
|
11
|
+
repository root and set `KB_REPO` to that path (`KB_REPO=.` from the
|
|
12
|
+
repository root).
|
|
13
|
+
- Read the vault's applicable agent instructions and note conventions before editing.
|
|
14
|
+
- Preserve note voice, frontmatter, filenames, and link intent unless a reported finding justifies a specific change.
|
|
15
|
+
|
|
16
|
+
## 2. Refresh derived state
|
|
17
|
+
|
|
18
|
+
When several agents are still editing a managed vault, do not refresh its
|
|
19
|
+
shared catalog in each lane. Validate the lane's Markdown and graph facts with:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
wordcell check --root "$KB_ROOT" --no-catalog
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The integrating agent performs the managed refresh once after the lanes join.
|
|
26
|
+
An authored vault declares `kb_catalog: authored` in `index.md`; its refresh has
|
|
27
|
+
no catalog write and is safe from that shared generated-file hotspot.
|
|
28
|
+
|
|
29
|
+
Run:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
wordcell refresh --root "$KB_ROOT"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
In managed mode this command atomically updates only the marked catalog region
|
|
36
|
+
in `index.md`. In authored mode it reports the index as authored and leaves the
|
|
37
|
+
file unchanged. Use `wordcell catalog --root "$KB_ROOT"` for a disposable exhaustive
|
|
38
|
+
inventory in either mode. Catalog links are navigation, so they do not count as
|
|
39
|
+
contextual graph edges.
|
|
40
|
+
|
|
41
|
+
## 3. Review the advisories
|
|
42
|
+
|
|
43
|
+
Open every reported source line and the relevant target notes before deciding whether to edit.
|
|
44
|
+
|
|
45
|
+
- Repair a broken wikilink only when its intended target is clear. Otherwise, report the uncertainty.
|
|
46
|
+
- Repair a broken or ambiguous typed relationship only after confirming its exact canonical target and predicate from the source note.
|
|
47
|
+
- Disambiguate a wikilink with a vault-root path only after confirming the author's intent.
|
|
48
|
+
- Treat a contextual orphan as a prompt to inspect the note, not as a demand to add a link.
|
|
49
|
+
- Treat an unlinked title or alias mention as a candidate, not proof that the sentence should link.
|
|
50
|
+
- Add a contextual wikilink only when it improves the meaning or navigation of the sentence.
|
|
51
|
+
- Repair a missing, escaping, ambiguous, case-mismatched, symlinked, or hard-linked local image, PDF, or tldraw target. External URLs remain outside this attachment gate.
|
|
52
|
+
- When a repository-owned wrapper adds lifecycle findings, treat them as
|
|
53
|
+
migration advisories: active plans should have descriptions and exact
|
|
54
|
+
`repository_scopes`, in-progress plans should retain execution evidence,
|
|
55
|
+
terminal plans should record a result and durable-memory disposition, and
|
|
56
|
+
maintained notes should declare `type: note` or `type: concept`.
|
|
57
|
+
- When a repository-owned scope audit reports an absent active or maintained
|
|
58
|
+
scope, inspect it as possible stale routing. Future paths may intentionally
|
|
59
|
+
be absent; terminal records may intentionally retain retired paths. The
|
|
60
|
+
portable `wordcell refresh` and `wordcell check` commands do not impose this lifecycle
|
|
61
|
+
policy by themselves.
|
|
62
|
+
|
|
63
|
+
Backlinks are derived from explicit contextual wikilinks and typed
|
|
64
|
+
relationships. Mention and percolation candidates are derived analysis. Never
|
|
65
|
+
inject reciprocal, transitive, or similarity-derived relationships or generated
|
|
66
|
+
backlink sections to improve graph counts. Never mutate authored prose
|
|
67
|
+
automatically or apply suggestions mechanically in bulk.
|
|
68
|
+
|
|
69
|
+
Run a bounded percolation review for each materially changed note:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
wordcell percolate "<changed-note-id>" --root "$KB_ROOT" --limit 25 --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Open the cited notes before deciding whether to create a reusable
|
|
76
|
+
`type: concept` note or a source-owned typed relationship.
|
|
77
|
+
|
|
78
|
+
Intentional orphans and unlinked mentions may remain. Record the reason instead of manufacturing a connection.
|
|
79
|
+
|
|
80
|
+
Review recent captures without maintained disposition when useful:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
wordcell inbox --root "$KB_ROOT" --limit 25 --json
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The inbox ignores source-to-source and catalog links. It is advisory; an
|
|
87
|
+
intentional leaf capture needs no manufactured backlink.
|
|
88
|
+
|
|
89
|
+
## 4. Validate changed repository-context mappings
|
|
90
|
+
|
|
91
|
+
If the change adds, removes, renames, or moves a scope hub, changes its
|
|
92
|
+
`type` or `scope`, or edits an `kb:context` marker, run:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
wordcell agents identity "<repository-scope>" --json
|
|
96
|
+
wordcell agents check --root "$KB_ROOT" --repo "$KB_REPO"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Use the non-mutating identity command to derive the hub path and exact marker
|
|
100
|
+
when creating or moving a mapping. The check command verifies canonical IDs,
|
|
101
|
+
exact repository-relative
|
|
102
|
+
directory scopes, collisions, repository confinement, real scope directories
|
|
103
|
+
and guide files, guide shape, and reciprocal markers. A moved scope has a new
|
|
104
|
+
identity, so update the hub filename and guide marker together. An unmapped
|
|
105
|
+
`AGENTS.md` is valid.
|
|
106
|
+
|
|
107
|
+
Use the audit when the change affects guide structure, inheritance, or repeated
|
|
108
|
+
rules:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
wordcell agents audit --root "$KB_ROOT" --repo "$KB_REPO"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The audit runs the correctness checks and adds deterministic per-guide,
|
|
115
|
+
per-section, inherited-chain, long-bullet, and exact-duplicate advisories.
|
|
116
|
+
Review each advisory in context. Length is not correctness: do not move a
|
|
117
|
+
load-bearing ownership rule, prohibition, command, invariant, or gate out of
|
|
118
|
+
`AGENTS.md` merely to satisfy a suggested budget. Guide discovery skips common
|
|
119
|
+
generated and vendor directories and never follows symbolic-link directories.
|
|
120
|
+
|
|
121
|
+
## 5. Re-refresh and check
|
|
122
|
+
|
|
123
|
+
After any note or link edit, run the refresh command again so derived state and advisories reflect the final content. Then run the read-only gate:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
wordcell check --root "$KB_ROOT"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Finish only when the graph check and any required agent-context check succeed,
|
|
130
|
+
the configured catalog mode is satisfied, and broken or ambiguous links,
|
|
131
|
+
relationships, and local attachments are resolved. Summarize deliberate
|
|
132
|
+
concept, relationship, link, scope, and mapping edits plus advisories
|
|
133
|
+
intentionally left in place.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Save a PDF to the knowledge base
|
|
2
|
+
|
|
3
|
+
Use the installed `wordcell` CLI. Resolve `<vault>` to the directory containing its
|
|
4
|
+
authored or managed `index.md` front door, then set the shell-local `KB_ROOT`
|
|
5
|
+
to that path (`KB_ROOT=kb` from a typical repository root).
|
|
6
|
+
|
|
7
|
+
Check the local conversion routes, then capture the PDF:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
wordcell doctor
|
|
11
|
+
wordcell pdf "/absolute/path/to/document.pdf" --output "$KB_ROOT/articles"
|
|
12
|
+
wordcell pdf "https://example.com/document.pdf" --output "$KB_ROOT/articles"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Pass a stable slug or replace a prior tool-owned bundle only when needed:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
wordcell pdf "/absolute/path/to/document.pdf" --slug ben-leaves-zo --output "$KB_ROOT/articles"
|
|
19
|
+
wordcell pdf "/absolute/path/to/document.pdf" --output "$KB_ROOT/articles" --force
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The command installs one atomic bundle:
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
<slug>/
|
|
26
|
+
<slug>.md
|
|
27
|
+
capture.json
|
|
28
|
+
source.pdf
|
|
29
|
+
annotations.json # present after a reviewed annotation pass
|
|
30
|
+
assets/
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`source.pdf` is the byte-identical input. The manifest records its original
|
|
34
|
+
name, hash, byte count, page count, bounded document metadata, processed-page
|
|
35
|
+
and block counts, image geometry, OCR status, and warnings without retaining
|
|
36
|
+
the original absolute path. A reviewed second pass also retains the exact
|
|
37
|
+
normalized annotation array as `annotations.json`; the manifest records its
|
|
38
|
+
path, count, byte count, and SHA-256 so the image interpretation remains
|
|
39
|
+
reproducible.
|
|
40
|
+
|
|
41
|
+
## Preserve text and visual evidence
|
|
42
|
+
|
|
43
|
+
Treat native PDF text and image text as two independent extraction surfaces.
|
|
44
|
+
Native text supplies layout, heading, link, and reading-order evidence. Local
|
|
45
|
+
OCR supplies candidate text for scans and screenshots. Keep every extracted
|
|
46
|
+
image as an asset even when its text is converted to Markdown.
|
|
47
|
+
|
|
48
|
+
For recognizable conversations, review the source image and turn OCR into
|
|
49
|
+
readable message blocks with available platform, author, channel, and timestamp
|
|
50
|
+
metadata. Preserve uncertain words explicitly instead of silently repairing
|
|
51
|
+
them. Read [the image-derived text review guide](pdf-review.md) before refining
|
|
52
|
+
screenshot-heavy or mixed-media PDFs.
|
|
53
|
+
|
|
54
|
+
The first capture supplies stable image IDs and hashes in `capture.json`.
|
|
55
|
+
For screenshot-heavy documents, write reviewed interpretations to a JSON array
|
|
56
|
+
and rerun the capture:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
[
|
|
60
|
+
{
|
|
61
|
+
"id": "page-5-image-1-0123456789ab",
|
|
62
|
+
"sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
|
63
|
+
"kind": "mixed",
|
|
64
|
+
"method": "agent",
|
|
65
|
+
"markdown": "> bg @ Oct 15, 2024 at 4:26 PM\n> Message text",
|
|
66
|
+
"metadata": {
|
|
67
|
+
"platform": "Slack",
|
|
68
|
+
"contentType": "message screenshot",
|
|
69
|
+
"author": "bg",
|
|
70
|
+
"timestamp": "Oct 15, 2024 at 4:26 PM",
|
|
71
|
+
"participants": ["bg"]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
wordcell pdf "/absolute/path/to/document.pdf" \
|
|
79
|
+
--output "$KB_ROOT/articles" \
|
|
80
|
+
--annotations /tmp/pdf-image-annotations.json \
|
|
81
|
+
--force
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Use only IDs and SHA-256 values from the first manifest. The command rejects a
|
|
85
|
+
stale interpretation if the extracted image changed. Omit metadata fields that
|
|
86
|
+
are not visible, and use `kind: "visual"` with an optional `alt` instead of
|
|
87
|
+
inventing a transcription for a non-text image. Put only the transcribed body
|
|
88
|
+
in `markdown`; the renderer owns the image embed, “Text visible in…” heading,
|
|
89
|
+
and visible metadata line.
|
|
90
|
+
|
|
91
|
+
Embed primarily visual images in the Markdown. For text-bearing or mixed
|
|
92
|
+
images, keep the source image embedded beside the transcription so diagrams,
|
|
93
|
+
photos, UI state, and spatial meaning remain inspectable. The embed is the
|
|
94
|
+
source-image reference; do not duplicate it inside an annotation.
|
|
95
|
+
|
|
96
|
+
Heading inference follows native font, emphasis, spacing, and page geometry.
|
|
97
|
+
Review semantic hierarchy separately: typography can identify a heading without
|
|
98
|
+
proving whether it is a peer or a child of the preceding section. Report an
|
|
99
|
+
ambiguous or incorrect level instead of silently treating the inference as
|
|
100
|
+
source truth.
|
|
101
|
+
|
|
102
|
+
## Report completeness literally
|
|
103
|
+
|
|
104
|
+
Use `complete` only when every page was processed and every extracted image was
|
|
105
|
+
classified. Preserve `partial` when a tool, page, image, byte, time, or OCR
|
|
106
|
+
boundary was reached. A usable native-text extraction does not make
|
|
107
|
+
unprocessed screenshot pages complete.
|
|
108
|
+
|
|
109
|
+
Review:
|
|
110
|
+
|
|
111
|
+
1. Compare the manifest page count with the PDF.
|
|
112
|
+
2. Review inferred headings and report ambiguous or incorrect hierarchy.
|
|
113
|
+
3. Sample native-text, screenshot, scanned, and visual-only pages.
|
|
114
|
+
4. Confirm every retained asset resolves from the Markdown or manifest.
|
|
115
|
+
5. Check that source-image links accompany OCR-derived text.
|
|
116
|
+
6. Report the output path, status, page and image counts, OCR coverage, and
|
|
117
|
+
unresolved warnings.
|
|
118
|
+
|
|
119
|
+
After adding or linking the capture, run the vault's normal refresh and check:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
wordcell percolate "<maintained-note-id>" --root "$KB_ROOT" --limit 25 --json
|
|
123
|
+
wordcell refresh --root "$KB_ROOT"
|
|
124
|
+
wordcell check --root "$KB_ROOT"
|
|
125
|
+
```
|