@inkeep/open-knowledge 0.5.0-beta.40 → 0.5.0-beta.42

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.
Files changed (30) hide show
  1. package/dist/assets/skills/open-knowledge/SKILL.md +43 -20
  2. package/dist/cli.mjs +45 -43
  3. package/dist/constants-Co5pHcW2.mjs +2 -0
  4. package/dist/{dist-kgy3NArq.mjs → dist-Ck9KORwV.mjs} +1 -1
  5. package/dist/{dist-DjC84IgZ.mjs → dist-DhjzONr6.mjs} +35 -35
  6. package/dist/index.mjs +1 -1
  7. package/dist/{init-BH7ZH8Ug.mjs → init-C83LwZ9L.mjs} +4 -4
  8. package/dist/init-C9m6w7yf.mjs +1 -0
  9. package/dist/loader-BdspI5Vy.mjs +1 -0
  10. package/dist/{loader-C2EgX1O-.mjs → loader-BzMkwP2B.mjs} +2 -2
  11. package/dist/preview-CJUr5n6r.mjs +1 -0
  12. package/dist/{preview-Ctrbhc4r.mjs → preview-DLRNjMAm.mjs} +2 -2
  13. package/dist/public/assets/SettingsDialogBody-ClSRatcR.js +11 -0
  14. package/dist/public/assets/config-validation-events-B6dxLseJ.js +10 -0
  15. package/dist/public/assets/index-BXbMiiLK.js +1918 -0
  16. package/dist/public/index.html +3 -3
  17. package/dist/{repair-launch-json-DKsMVH1M.mjs → repair-launch-json-BEXAmyYj.mjs} +2 -2
  18. package/dist/{repair-mcp-configs-BQ5B5SEm.mjs → repair-mcp-configs-C1P6nujr.mjs} +2 -2
  19. package/dist/{src-p510n6xV.mjs → src-Qw69gDuh.mjs} +2 -2
  20. package/dist/start-D_t9jHk0.mjs +1 -0
  21. package/dist/{start--BCdrceO.mjs → start-DjkaPQd5.mjs} +2 -2
  22. package/package.json +1 -1
  23. package/dist/constants-CQfcgXd1.mjs +0 -2
  24. package/dist/init-CBnvLBjl.mjs +0 -1
  25. package/dist/loader-B87qQn2P.mjs +0 -1
  26. package/dist/preview-CF4spOTa.mjs +0 -1
  27. package/dist/public/assets/SettingsDialogBody-DsD6fHwY.js +0 -11
  28. package/dist/public/assets/config-validation-events-C8srGpAi.js +0 -10
  29. package/dist/public/assets/index-BQdYAvoY.js +0 -1918
  30. package/dist/start-CbVIel-D.mjs +0 -1
@@ -3,7 +3,7 @@ name: open-knowledge
3
3
  description: "MUST invoke when the project contains a .ok/ directory — before any read or edit of .md / .mdx files, any mcp__open-knowledge__ tool call, and any write_document / edit_document. Skip if no .ok/ — not an Open Knowledge project. Carries preview-attach (open preview browser at session start; one-shot on `action: attach-preview-once`; surface to user on `action: start-ui` when no UI is running), STOP rules for native Read/Grep/Edit on in-scope markdown, grounding rules (every factual claim needs a source), standard markdown linking with get_dead_links verification, image sourcing + alt-text + source-citation rules, folder-first organization with opt-in nested .ok/ frontmatter + templates, and the anti-pattern table."
4
4
  compatibility: "Claude Code, Claude Desktop, Claude Cowork, Claude.ai web. Requires Open Knowledge MCP server + code execution."
5
5
  metadata:
6
- version: "0.5.0-beta.40"
6
+ version: "0.5.0-beta.42"
7
7
  author: "Inkeep"
8
8
  repository: "https://github.com/inkeep/open-knowledge"
9
9
  ---
@@ -18,12 +18,27 @@ Open Knowledge (OK) is a markdown-CRDT collaboration platform exposed via MCP. T
18
18
  ## TL;DR — the 90% case
19
19
 
20
20
  1. **Reads:** `exec("cat …")` for a single doc, `exec("ls -A …")` for a directory, `search` for ranked, `grep` for literal. Native `Read` / `Grep` only on source code (`.ts` / `.py` / …), never on in-scope `.md` / `.mdx`.
21
- 2. **Writes:** `write_document` for new or full-replace, `edit_document` for body-only patches. Frontmatter changes go through `write_document({ position: "replace" })` `edit_document` rejects frontmatter edits with HTTP 400.
22
- 3. **Preview:** open the browser at session start (or when a write response carries `warning: { action: "attach-preview-once" }` or surface to the user when `warning: { action: "start-ui" }` says no UI is running). Don't `preview_screenshot` after every edit.
21
+ 2. **Writes:** `write_document` for new or full-replace, `edit_document` for body-only patches, `frontmatter_patch` for 1-2 frontmatter keys (preferred). Full frontmatter rewrites use `write_document({ position: "replace" })`. `edit_document` rejects frontmatter (HTTP 400).
22
+ 3. **Preview:** every OK tool response carries the preview URL (`ui.baseUrl` on reads, `previewUrl` on writes). Navigate your in-app browser to it from the first response you see; refresh from later responses if Electron/UI restarted. Surface to the user on a `start-ui` warning (no UI running). Don't `preview_screenshot` after every edit.
23
23
  4. **Workflow tools** (`ingest` / `research` / `consolidate` / `discover`) return procedural guides, not data. Use them when the work fits the layer; follow their numbered steps.
24
24
 
25
25
  Everything below is depth. Read on demand.
26
26
 
27
+ ## Tool index — by family
28
+
29
+ The full MCP surface, grouped by intent. Each family has one canonical instruction site later in this doc (linked). Reach for the family before the individual tool.
30
+
31
+ - **Read** — `exec` (primary; shell-style), `read_document` (typed; one doc), `search` (ranked, BM25 + recency), `grep` (literal, frontmatter-enriched), `list_documents` (folder + `frontmatter_defaults` + `templates_available` cascade). See *Reads — examples*.
32
+ - **Write / edit** — `write_document` (new or full-replace, incl. `template:` instantiation), `edit_document` (body-only find/replace), `frontmatter_patch` (JSON Merge Patch for 1-2 keys), `delete_document`. See *Writing* and *Frontmatter conventions*.
33
+ - **Restructure** — `rename_document` (single file; updates referrers), `rename_folder` (folder + descendants; updates referrers). Always prefer these over `delete_document` + re-write — they preserve history and rewrite incoming links.
34
+ - **Versioning** — `save_version` (named snapshot), `get_history` (versions for a doc), `rollback_to_version` (restore a snapshot). Call `save_version` before any 1-way operation (delete, large rewrite, folder rename) you may need to undo.
35
+ - **Link graph** — `get_dead_links` (verify after writes; strict-exact), `get_backlinks` (incoming), `get_forward_links` (outgoing), `get_orphans` (no incoming), `get_hubs` (high-incoming), `suggest_links` (untextualized mentions). See *Linking*.
36
+ - **Components** — `get_components` (fetch param schemas + literal `example` bytes). See *Components — prefer canonicals*.
37
+ - **Folder defaults + templates** — `set_folder_rule` (writes `<folder>/.ok/frontmatter.yml`), `write_template` / `delete_template` (writes `<folder>/.ok/templates/`), `get_config` (read resolved config). See *Folder structure + metadata*.
38
+ - **Workflow tools (return procedural guides, not data)** — `ingest`, `research`, `consolidate`, `discover`. See *Workflow tools — when to invoke them*.
39
+
40
+ Tools NOT in OK MCP (they belong to your agent host): `preview_start`, `preview_screenshot`, `WebFetch`, `WebSearch`, native `Read` / `Grep` / `Glob` / `Edit`. The STOP rule below governs which of those you may use on in-scope markdown.
41
+
27
42
  ## STOP — native tools on in-scope `.md` / `.mdx`
28
43
 
29
44
  When this workspace has Open Knowledge MCP configured, do **not** use your host's native file tools on markdown paths inside the content directory. The ban covers every common rationalization:
@@ -51,32 +66,40 @@ Why: native tools skip frontmatter, backlinks, shadow-repo activity, and project
51
66
 
52
67
  ## Preview — open the browser at session start
53
68
 
54
- **Open the preview browser as your first OK action of the session, if it is not already open.** The user watches edits land live in that pane; if it isn't open, your work is invisible and the whole CRDT pipeline is wasted. Treat this as step zero before your first read, before your first write.
69
+ **The invariant.** If OK Electron is open for this project OR `ok ui` is running for it, every OK tool response carries the preview URL plain HTTP, no custom URL schemes, works in any browser including agent in-app browsers (Claude Desktop, Cursor, Codex, Cowork). Read tools (`exec`, `grep`, `search`, `list_documents`, `read_document`) carry it in `ui.baseUrl` (top-level) and per-doc `previewUrl` fields; write tools carry it in `previewUrl` + the optional `warning` shape. Never construct this URL; always read it from the latest tool response.
70
+
71
+ **The default agent move.** Make your first OK tool call (any read works — `list_documents`, `exec("ls -A")`, or `read_document` is enough). The response carries the preview URL. Navigate to it immediately, then proceed with your real work. The user watches edits land live; you can re-navigate later to verify a CRDT edit landed when a response looks ambiguous. Per host:
72
+
73
+ - **In-app browser hosts** (Claude Desktop, Cursor, Codex, Cowork): navigate the in-app browser to the `previewUrl`. Default.
74
+ - **Claude Code Desktop**: call `preview_start("open-knowledge-ui")` (host tool, not OK MCP).
75
+ - **Stdio-only hosts**: surface the URL in chat; `open <url>` (macOS) if the host can shell out.
76
+
77
+ **Four signals to check if it's already open** (you usually can't pre-check, so read these from each write response):
78
+
79
+ 1. You opened/navigated earlier this session → don't reopen.
80
+ 2. Write response has `previewUrl` (non-null) and NO `warning` → a browser is attached somewhere; do nothing.
81
+ 3. `warning: { action: "attach-preview-once", previewUrl, message }` → UI reachable, no browser attached; navigate one-shot.
82
+ 4. `warning: { action: "start-ui", previewUrl: null, message }` → no UI running anywhere. Surface the message verbatim — recovery options are in the in-band copy. Don't loop on retries.
55
83
 
56
- - Claude Code Desktop: `preview_start("open-knowledge-ui")`.
57
- - Cursor: use the host's open-URL tool with a `previewUrl` from any write response.
58
- - Other hosts: use whatever command opens a URL (macOS: `open <url>`). On hosts with no preview tool (Codex, generic stdio), surface the URL in chat for the user to click.
84
+ Warnings fire at most once per session in the fresh-start case.
59
85
 
60
- **How to know if it's already open.** You usually can't pre-check from the agent side rely on these signals:
86
+ **`previewUrl: null` only means "no UI reachable" on the three attach-warning tools: `write_document` / `edit_document` / `frontmatter_patch`.** Workflow tools return prose and don't carry `previewUrl`. `delete_document` / `rename_document` / `rename_folder` emit `previousPreviewUrl` (different field, for closing stale tabs) and don't fire attach warnings.
61
87
 
62
- 1. You already opened it earlier in this session don't reopen.
63
- 2. A `write_document` / `edit_document` response returns `previewUrl` but NO `warning` → a browser is attached somewhere; do nothing.
64
- 3. A response DOES include `warning: { action: "attach-preview-once", previewUrl, message }` → a UI server is reachable but no browser is attached; open the URL immediately, one-shot.
65
- 4. A response includes `warning: { action: "start-ui", previewUrl: null, message }` → no UI is running anywhere for this project. Surface the message to the user (the in-band copy names the recovery options: `open-knowledge ui` in a terminal, `preview_start("open-knowledge-ui")` in Claude Code Desktop, or opening the project in OK Electron). Don't loop on retries — the user has to act.
88
+ **Always read `previewUrl` from the latest write response.** Don't cache the session-start value Electron quit/reopen (or `ok ui` restart) can change the port; the resolver picks up the new port automatically.
66
89
 
67
- Both warning shapes fire only when needed (server tracks `__system__` subscribers) and at most once per session in the normal fresh-start case.
90
+ If you see `"Hocuspocus server is not running"`, run `ok start` and retry. NEVER construct preview URLs by hand.
68
91
 
69
- If the server isn't running, you'll see a `"Hocuspocus server is not running"` error. If `previewUrl` is `null` in a tool response, no UI is reachable for this project neither a CLI `open-knowledge ui` process nor an OK Electron window. Start one (`open-knowledge ui` from a terminal, `preview_start("open-knowledge-ui")` in Claude Code, or just open the project in OK Electron), then retry. NEVER construct preview URLs by hand — always use the `previewUrl` returned in tool responses.
92
+ OK Electron and `ok ui` cannot serve the same project at oncethey share `ui.lock`. A UI-lock collision means the other is running for that project (use that one, or quit it first).
70
93
 
71
- OK Electron and the CLI's `ok ui` cannot serve the same project at the same time they both hold the same `ui.lock`. If `ok ui` errors with a UI-lock collision, an OK Electron window is open for that project (use that window, or quit it and re-run `ok ui`). The reverse holds for the user-facing case: opening a project in OK Electron while a standalone `ok ui` is running for the same project will fail the lock acquire.
94
+ **The preview is read-only for the agent.** Navigate to verify edits landed; you cannot click or type to drive edits the CRDT flow is one-way (agent MCP CRDT preview).
72
95
 
73
- **No screenshots after edits.** Do NOT take `preview_screenshot` after every `edit_document` / `write_document`. Trust the CRDT tool response as confirmation the edit landed. Only screenshot when debugging a visual issue or when explicitly asked.
96
+ **No screenshots after every edit.** Do NOT take `preview_screenshot` (host tool, not OK MCP) after every write. Trust the response. Screenshot only when (a) debugging a visual issue, (b) a response looks ambiguous, or (c) the user asks.
74
97
 
75
98
  ## Writing
76
99
 
77
100
  Call `write_document` / `edit_document` as soon as you have content. Native `Edit` / `sed` / direct `Write` on in-scope markdown is forbidden — it bypasses the CRDT and loses agent attribution in the shadow repo.
78
101
 
79
- To delete a doc, call `delete_document` — never `rm` / `unlink` / native `Bash` removal on in-scope markdown. The MCP path closes open agent sessions and unloads the doc from Hocuspocus before unlinking; native `rm` desynchronizes those. Deletion is irreversible from this tool — call `save_version` first if you may need to roll back, and `get_backlinks` first if you want to fix the referrers that will become redlinks.
102
+ To delete a doc, call `delete_document` — never `rm` / `unlink` / native `Bash` removal on in-scope markdown. The MCP path closes open agent sessions and unloads the doc from Hocuspocus before unlinking; native `rm` desynchronizes those. Deletion is irreversible from this tool — call `save_version` first if you may need to roll back (restore via `rollback_to_version`; list snapshots via `get_history`), and `get_backlinks` first if you want to fix the referrers that will become redlinks. To move or rename a doc instead of delete + rewrite, use `rename_document` (single file) or `rename_folder` (folder + descendants) — both rewrite incoming references atomically.
80
103
 
81
104
  **If `edit_document` returns "Text not found" on text you can verify exists on disk** (via `exec("cat …")`), the MCP session is likely stale (e.g., after a folder rename or server restart). Treat this as the escape-hatch trigger from the STOP block: prefix your next user-visible sentence with `Open Knowledge MCP unavailable:` and report the inconsistency. Don't loop on retries — the symptom is structural, not transient.
82
105
 
@@ -133,7 +156,7 @@ Knowledge-base docs are factual artifacts — whether the project is a wiki, an
133
156
  - **Internal cross-refs between OK docs** → `[text](./other-doc.md)` — link liberally to aid navigation.
134
157
  - **Never wrap a link in backticks.** `` `[text](./foo.md)` `` is a bug — the backticks make it render as literal code rather than a link.
135
158
  - **Never use HTML anchors** (`<a href="...">`). Markdown link syntax only.
136
- - **Verify before walking away.** After writing a doc, call `get_dead_links({ sourceDocNames: ['your/doc'] })` to find broken references. Fix each redlink or explicitly accept it.
159
+ - **Verify before walking away.** After writing a doc, call `get_dead_links({ sourceDocNames: ['your/doc'] })` to find broken references. Fix each redlink or explicitly accept it. Companion link-graph reads (same family): `get_backlinks` (incoming), `get_forward_links` (outgoing), `get_orphans` (no incoming), `get_hubs` (high-incoming), `suggest_links` (untextualized mentions worth linking).
137
160
  - **The editor's red-underline visual lies.** Its dead-link detection tolerates slug-fallback (e.g., `foo` may appear resolved because `foo.md` exists at root). `get_dead_links` is strict-exact — trust the tool, not the visual.
138
161
 
139
162
  **Note on wiki-link syntax (`[[Page]]`):** the parser still handles it for legacy content, but it's NO LONGER the recommended default. Write new content with standard markdown links per above. Seed-pack templates (`ok seed --pack <name>`) may still emit `[[Page]]` placeholders inside template body text — those are legacy. When you instantiate a seed-pack template, replace the legacy placeholders with standard markdown links during the `{shape}`-fill pass.
@@ -365,7 +388,7 @@ The skill carries the trigger ("KB content changed this turn — go look"). The
365
388
  | Write a doc in an unfamiliar folder | go straight to `write_document` with hand-authored markdown | `list_documents(<folder>)` first — read `frontmatter_defaults` + `templates_available` before writing |
366
389
  | Land in an existing repo without orienting | go straight to `write_document` or run the per-folder pre-write checklist ad-hoc when no folder frontmatter / templates exist | invoke `discover` once for the project — it extracts conventions from siblings, sets folder frontmatter, writes templates, and activates the link graph |
367
390
  | Author a doc when a matching template exists | `write_document({ markdown: "..." })` from scratch | `write_document({ template, position: "replace" })` — templates carry the folder's frontmatter + body discipline |
368
- | Change a doc's title / tags | `edit_document` to swap the YAML (rejected — HTTP 400 frontmatter-intersect) | `write_document({ position: "replace", markdown })` with the new frontmatter block at the top of `markdown` |
391
+ | Change a doc's title / tags | `edit_document` to swap the YAML (rejected — HTTP 400 frontmatter-intersect) | `frontmatter_patch({ docName, patch })` for 1-2 keys; `write_document({ position: "replace", markdown })` for full rewrites |
369
392
  | Repeat the same frontmatter on sibling docs | hand-set identical `tags` / `title` prefix on every new file | `set_folder_rule(...)` once — the cascade carries it to every child |
370
393
  | Re-derive the same body skeleton repeatedly | copy-paste the structure from a sibling each time | `write_template(...)` once, then pick from `templates_available` thereafter |
371
394
  | Scaffold a new folder for a doc category | `set_folder_rule` for frontmatter and stop there | pair `set_folder_rule` with `write_template` in the same turn — discipline + body shape |
@@ -384,7 +407,7 @@ Three correspond to [Karpathy's three-layer knowledge-base pattern](https://gist
384
407
  | `ingest` | Raw sources (immutable) | User shares a URL/PDF/file to preserve verbatim, **OR you fetched a URL** (`WebFetch` / `WebSearch` / equivalent) to ground a claim that's about to land in the knowledge base. The KB is closed-loop — agent-initiated fetches are not exempt. No analysis in the file itself — takeaways go back to the user in chat. |
385
408
  | `research` | KB, provisional | User asks you to investigate, compare alternatives, or synthesize multiple sources. Produces a `status: provisional` article with a `sources:` list. Follows scan-first routing, a STOP scoping gate, 3P-external framing, and a validate checklist — the tool body enforces each step. |
386
409
  | `consolidate` | KB, canonical | Team has actually decided after research and wants the outcome committed as source-of-truth. Starts with a STOP gate confirming the decision exists; writes a `status: canonical` article with a `supersedes:` chain. |
387
- | `discover` | Project metadata | First arrival at a repo with existing content AND no folder frontmatter / templates set. Extracts conventions from siblings; activates the link graph (orphans, hubs, untextualized mentions); proposes folder frontmatter + templates + `.okignore`; per-phase user confirmation. Requires `open-knowledge start` running (Phase 1 step 0 gates). Skip on empty repos (use `ok seed`). One-shot; idempotent on re-run. |
410
+ | `discover` | Project metadata | First arrival at a repo with existing content AND no folder frontmatter / templates set. Extracts conventions from siblings; activates the link graph (orphans, hubs, untextualized mentions); proposes folder frontmatter + templates + `.okignore`; per-phase user confirmation. Requires `ok start` running (Phase 1 step 0 gates). Skip on empty repos (use `ok seed`). One-shot; idempotent on re-run. |
388
411
 
389
412
  **These tools are your default move, not `write_document`.** When the work fits one of the three layers — preserving an external source, investigating/synthesizing, committing a decided outcome — invoke the corresponding tool instead of going straight to `write_document` / `edit_document`. The tool bodies enforce framing (sources, status, supersedes chains) that hand-written articles routinely miss. `write_document` is correct for everything that does **not** fit the three layers (specs, runbooks, scratch notes, project pages); for the three that do, lead with the tool. This is doubly true in projects that ran `ok seed` — a doc landing in `external-sources/` / `research/` / `articles/` should have come out of `ingest` / `research` / `consolidate`.
390
413