kb-hub 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +180 -2
- package/dist/cli.js +952 -0
- package/dist/cli.js.map +1 -0
- package/package.json +53 -4
- package/templates/vault/AGENTS.md +65 -0
- package/templates/vault/CLAUDE.md +1 -0
- package/templates/vault/index.md +11 -0
- package/templates/vault/log.md +3 -0
- package/templates/vault/outputs/.gitkeep +0 -0
- package/templates/vault/projects/.gitkeep +0 -0
- package/templates/vault/raw/inbox/.gitkeep +0 -0
- package/templates/vault/wiki/.gitkeep +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nacho Mautone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,181 @@
|
|
|
1
|
-
#
|
|
1
|
+
# kb-hub
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Works on macOS and Windows (Linux too).
|
|
4
|
+
>
|
|
5
|
+
> Your notes, bug history and private specs, available to your coding agent in any repo, with a record of where each note came from.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**Status: v0.1 is feature-complete and not on npm yet.** It was built spec-first with [OpenSpec](https://github.com/Fission-AI/OpenSpec): the behavior contract is in [`openspec/specs/`](openspec/specs/) and the history of each change in [`openspec/changes/archive/`](openspec/changes/archive/).
|
|
10
|
+
|
|
11
|
+
## Why
|
|
12
|
+
|
|
13
|
+
Coding agents can't see what you know: notes, bug context, decisions, and specs that can't go into a big shared repo. So every session starts with you searching and pasting context by hand, and what you learn during the session is lost when it ends.
|
|
14
|
+
|
|
15
|
+
kb-hub keeps that knowledge in a plain markdown vault (the LLM Wiki pattern described by Andrej Karpathy) and serves it to any agent through MCP. The agent does the synthesis; kb-hub keeps the books.
|
|
16
|
+
|
|
17
|
+
## What v0.1 does
|
|
18
|
+
|
|
19
|
+
| Tool | What it does |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `ping` | Confirms the agent is connected and shows which vault it sees |
|
|
22
|
+
| `search` | Full-text search over the vault, wiki pages ranked above raw captures |
|
|
23
|
+
| `read` | Reads a page with its frontmatter, never outside the vault |
|
|
24
|
+
| `capture` | Saves a note to `raw/inbox/` stamped with repo, branch, commit and work item ID |
|
|
25
|
+
| `status` | Captures not yet compiled into the wiki, broken `[[wikilinks]]`, latest log entries |
|
|
26
|
+
|
|
27
|
+
Example, against the [example vault](examples/demo-vault):
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
search { "query": "coupon", "limit": 2 }
|
|
31
|
+
|
|
32
|
+
1. Incident 2026-10: coupon applied twice (wiki/incident-2026-10-coupon-applied-twice.md, wiki)
|
|
33
|
+
Incident 2026-10: coupon applied twice What happened. On 21 October, customers who retried a failed payment got their coupon discount applied a second time…
|
|
34
|
+
2. Coupon applied twice on retry (raw/inbox/2026-10-21-coupon-applied-twice-on-retry.md, raw)
|
|
35
|
+
Customers who retry a failed payment get the coupon discount twice…
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The compiled wiki page comes first; the raw capture it was built from comes second. `read { "path": "wiki/incident-2026-10-coupon-applied-twice.md" }` then returns the page's frontmatter and body.
|
|
39
|
+
|
|
40
|
+
From a repo on branch `feature/4821-checkout`, the agent saves what it learned:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
capture { "title": "Checkout fails with expired coupon", "text": "The cart checks coupon expiry, checkout does not. Validate again on POST /checkout." }
|
|
44
|
+
|
|
45
|
+
Captured raw/inbox/2026-11-10-checkout-fails-with-expired-coupon.md ("Checkout fails with expired coupon"). Provenance: repo mate-and-co/storefront, branch feature/4821-checkout, commit 5d8bcb0, work item 4821.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The note lands in the inbox with its provenance in the frontmatter, and `log.md` gets a `capture` entry:
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
---
|
|
52
|
+
title: Checkout fails with expired coupon
|
|
53
|
+
tags: []
|
|
54
|
+
captured_at: "2026-11-10T09:14:02-03:00"
|
|
55
|
+
provenance:
|
|
56
|
+
repo: mate-and-co/storefront
|
|
57
|
+
branch: feature/4821-checkout
|
|
58
|
+
commit: "5d8bcb0"
|
|
59
|
+
work_item: "4821"
|
|
60
|
+
---
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`status` then shows what still needs work, computed without a model:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
**Vault:** 3 wiki pages, 1 project page, 4 raw notes.
|
|
67
|
+
|
|
68
|
+
**Pending captures (2):** not yet compiled into a wiki or project page.
|
|
69
|
+
- 2026-11-08 · Shipping cost rounding differs between cart and checkout · `raw/inbox/2026-11-08-shipping-cost-rounding.md`
|
|
70
|
+
- 2026-11-10 · Checkout fails with expired coupon · `raw/inbox/2026-11-10-checkout-fails-with-expired-coupon.md`
|
|
71
|
+
|
|
72
|
+
To compile them, follow "Compiling" in the vault's AGENTS.md.
|
|
73
|
+
|
|
74
|
+
**Broken links (1):**
|
|
75
|
+
- `[[refund-policy]]` in `wiki/checkout-flow.md`
|
|
76
|
+
|
|
77
|
+
**Recent log:**
|
|
78
|
+
- [2026-11-10] capture | Checkout fails with expired coupon
|
|
79
|
+
- [2026-11-08] capture | Shipping cost rounding differs between cart and checkout
|
|
80
|
+
- [2026-11-04] compile | wiki/checkout-flow.md
|
|
81
|
+
- [2026-11-03] capture | Checkout timeout in the payment sandbox
|
|
82
|
+
- [2026-10-22] compile | wiki/incident-2026-10-coupon-applied-twice.md
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
A capture counts as compiled once a page in `wiki/` or `projects/` lists it in its `sources` frontmatter. Compiling is the agent's job, in a session opened at the vault, following the vault's `AGENTS.md`.
|
|
86
|
+
|
|
87
|
+
Plus `npx kb-hub init <dir>` to create a vault with an `AGENTS.md` that tells the agent how to use it.
|
|
88
|
+
|
|
89
|
+
## Quickstart
|
|
90
|
+
|
|
91
|
+
Not on npm yet. Until the v0.1.0 release, run it from source:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git clone https://github.com/jMautone/kb-hub && cd kb-hub && npm ci && npm run build
|
|
95
|
+
node dist/cli.js init ~/my-vault
|
|
96
|
+
claude mcp add kb --scope user -- node "$PWD/dist/cli.js" mcp --vault ~/my-vault
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
On Windows (PowerShell), use `$env:USERPROFILE\my-vault` instead of `~/my-vault`. `--scope user` makes the server available in every project, not only the folder you ran the command in.
|
|
100
|
+
|
|
101
|
+
Once published, it will be:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx kb-hub init ~/my-vault
|
|
105
|
+
claude mcp add kb --scope user -- npx -y kb-hub mcp --vault ~/my-vault
|
|
106
|
+
# Windows: claude mcp add kb --scope user -- cmd /c npx -y kb-hub mcp --vault %USERPROFILE%\my-vault
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Then ask the agent, in any repo, to `ping` kb-hub to confirm it sees your vault. To try it without your own notes, point `--vault` at [`examples/demo-vault`](examples/demo-vault), a made-up knowledge base for a fictional online store.
|
|
110
|
+
|
|
111
|
+
### Make the agent use it
|
|
112
|
+
|
|
113
|
+
The vault's own `AGENTS.md` tells an agent how to search, capture and compile, but only when the session is opened in the vault. For every other repo, add this to your user-level `~/.claude/CLAUDE.md` (on Windows, `%USERPROFILE%\.claude\CLAUDE.md`):
|
|
114
|
+
|
|
115
|
+
```markdown
|
|
116
|
+
## Knowledge base (kb-hub)
|
|
117
|
+
|
|
118
|
+
I keep my notes, bug history and decisions in a vault served by the `kb` MCP server.
|
|
119
|
+
|
|
120
|
+
- Before asking me for context about a bug, feature, work item, business term or past decision, search the vault with `kb` `search` and `read` the most relevant pages. Cite the pages you used.
|
|
121
|
+
- When we learn something worth keeping beyond this session (a root cause, a decision and its reason, a command that worked, context I explained), save it with `kb` `capture`: one topic, a short specific title, written so it makes sense without this conversation.
|
|
122
|
+
- Never capture secrets, credentials or personal data.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Provenance
|
|
126
|
+
|
|
127
|
+
Every capture records where it came from, read from git in the folder the agent is working in:
|
|
128
|
+
|
|
129
|
+
| Field | Source |
|
|
130
|
+
| --- | --- |
|
|
131
|
+
| `repo` | `owner/name` from the `origin` remote (`org/project/repo` for Azure DevOps), or the repo folder's name when there is no `origin`. Credentials in the URL are never stored. |
|
|
132
|
+
| `branch` | The current branch, or `null` in detached HEAD |
|
|
133
|
+
| `commit` | The short hash of `HEAD`, or `null` before the first commit |
|
|
134
|
+
| `work_item` | The first number of two or more digits at the start of the branch name or after a `/` (`feature/4821-checkout` → `4821`, `bugfix/77-null-cart` → `77`) |
|
|
135
|
+
|
|
136
|
+
Outside a git repo, or when git is not installed, the note is still saved and every field is `null`. On Windows this needs [Git for Windows](https://git-scm.com/download/win) on `PATH`.
|
|
137
|
+
|
|
138
|
+
**Other work item formats.** Set `KB_WORKITEM_PATTERN` to a regular expression; its first capture group becomes the work item. For example, for Jira-style branches like `PROJ-123-checkout`:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
claude mcp add kb --scope user -e KB_WORKITEM_PATTERN='([A-Z]+-\d+)' -- npx -y kb-hub mcp --vault ~/my-vault
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Which repo?** kb-hub reads git in its own working directory. Claude Code starts MCP servers in the folder where you run `claude`, so captures get that repo's provenance with no extra setup. This was checked with Claude Code 2.1 and a test repo on `feature/4821-checkout` with an Azure DevOps remote: the capture came out with `contoso/Shop/storefront`, the branch, the commit and work item `4821`, without passing `cwd`. If your client starts servers somewhere else, the capture result says that no repository was found, and the agent can pass the repo path as `cwd`. To check your setup, ask the agent to `ping` kb-hub and then make a test capture.
|
|
145
|
+
|
|
146
|
+
## How it works
|
|
147
|
+
|
|
148
|
+
```mermaid
|
|
149
|
+
flowchart LR
|
|
150
|
+
A[Coding agent<br/>in any repo] -- MCP stdio --> S[kb-hub server]
|
|
151
|
+
S --> C[core: index, provenance, status]
|
|
152
|
+
C -- read / write --> V[(markdown vault)]
|
|
153
|
+
C -- git rev-parse --> R[current repo]
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Alternatives
|
|
157
|
+
|
|
158
|
+
| Tool | Use it instead when |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| [llm-wiki-mcp](https://github.com/flsteven87/llm-wiki-mcp) | You want the LLM Wiki pattern in Python with write-page and inventory tools, and don't need provenance or link checks |
|
|
161
|
+
| Basic Memory, qmd | You want semantic search over notes and don't need the LLM Wiki structure |
|
|
162
|
+
|
|
163
|
+
## Development
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm ci
|
|
167
|
+
npm run check # lint, build and tests: the gate before every PR
|
|
168
|
+
npm run dev -- mcp --vault examples/demo-vault
|
|
169
|
+
vhs demo/demo.tape # re-records demo/demo.gif; needs VHS, node, git and jq
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
See [`AGENTS.md`](AGENTS.md) for how changes are made, and [`docs/decisions/`](docs/decisions/) for the decisions behind the design.
|
|
173
|
+
|
|
174
|
+
## Roadmap
|
|
175
|
+
|
|
176
|
+
- **v0.2:** serve specs that can't live in a shared repo from the vault (`kb link`), plus skills to ingest, query and review.
|
|
177
|
+
- **v0.3:** terminal CLI (`kb add`, `kb push`), stale-page and drift checks, export to Azure DevOps Wiki.
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
[MIT](LICENSE)
|