claude-second-brain 0.4.1 → 0.5.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/README.md +4 -4
- package/bin/create.js +9 -3
- package/package.json +16 -3
- package/template/.claude/skills/brain-ingest/SKILL.md +4 -4
- package/template/.claude/skills/brain-rebuild/SKILL.md +13 -13
- package/template/.claude/skills/brain-refresh/SKILL.md +6 -6
- package/template/.claude/skills/brain-search/SKILL.md +1 -1
- package/template/.claude/skills/qmd-cli/SKILL.md +34 -34
- package/template/.claude/skills/setup/SKILL.md +8 -8
- package/template/CLAUDE.md +11 -11
- package/template/README.md +9 -6
- package/template/mise.toml +2 -1
- package/template/package.json +33 -0
- package/template/scripts/qmd/reindex.ts +2 -2
- package/template/scripts/qmd/setup.ts +8 -7
- package/template/scripts/qmd/tsconfig.json +3 -13
- package/template/scripts/qmd/package.json +0 -14
- /package/template/{sources → raw-sources}/README.md +0 -0
- /package/template/{sources → raw-sources}/articles/.gitkeep +0 -0
- /package/template/{sources → raw-sources}/pdfs/.gitkeep +0 -0
- /package/template/{sources → raw-sources}/personal/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ The CLI will ask:
|
|
|
63
63
|
- **qmd index path** — where to store the local search index (default: `~/.cache/qmd/index.sqlite`)
|
|
64
64
|
- **GitHub repo** — optionally create a private repo and push automatically (requires `gh` CLI)
|
|
65
65
|
|
|
66
|
-
Then scaffolds the vault, installs `mise` + `
|
|
66
|
+
Then scaffolds the vault, installs `mise` + `node` + `pnpm`, runs `pnpm install`, and `git init`.
|
|
67
67
|
|
|
68
68
|
**Step 2 — Initialize inside Claude Code**
|
|
69
69
|
|
|
@@ -100,7 +100,7 @@ The wiki ships with a set of slash commands that cover the full workflow. No man
|
|
|
100
100
|
|
|
101
101
|
### Daily workflow
|
|
102
102
|
|
|
103
|
-
**`/brain-ingest`** — Drop a file into `sources/articles/`, `sources/pdfs/`, or `sources/personal/`. Run `/brain-ingest`. Claude summarizes the source, asks what matters most to you, creates a `wiki/sources/` page, updates or creates related topic pages, flags any contradictions with existing knowledge, and logs everything.
|
|
103
|
+
**`/brain-ingest`** — Drop a file into `raw-sources/articles/`, `raw-sources/pdfs/`, or `raw-sources/personal/`. Run `/brain-ingest`. Claude summarizes the source, asks what matters most to you, creates a `wiki/sources/` page, updates or creates related topic pages, flags any contradictions with existing knowledge, and logs everything.
|
|
104
104
|
|
|
105
105
|
**`/brain-search`** — Ask anything about what you know. Claude runs hybrid semantic search across the wiki, reads the most relevant pages, and writes an answer with inline `[[wiki/page]]` citations. If the answer synthesizes multiple pages in a novel way, it offers to file it as a permanent `wiki/qa/` entry.
|
|
106
106
|
|
|
@@ -137,7 +137,7 @@ Sources flow in on the left, Claude synthesizes them into the wiki, qmd indexes
|
|
|
137
137
|
|
|
138
138
|
```mermaid
|
|
139
139
|
flowchart TB
|
|
140
|
-
subgraph Sources["sources/ — raw, immutable"]
|
|
140
|
+
subgraph Sources["raw-sources/ — raw, immutable"]
|
|
141
141
|
direction LR
|
|
142
142
|
S1[articles/]
|
|
143
143
|
S2[pdfs/]
|
|
@@ -226,7 +226,7 @@ All pages cross-link with Obsidian `[[wikilinks]]`. Contradictions are flagged w
|
|
|
226
226
|
```
|
|
227
227
|
my-brain/
|
|
228
228
|
├── CLAUDE.md ← The schema. Claude reads this every session.
|
|
229
|
-
├── sources/
|
|
229
|
+
├── raw-sources/ ← Your raw inputs. Claude never modifies these.
|
|
230
230
|
│ ├── articles/
|
|
231
231
|
│ ├── pdfs/
|
|
232
232
|
│ └── personal/
|
package/bin/create.js
CHANGED
|
@@ -173,13 +173,19 @@ async function main() {
|
|
|
173
173
|
else spin.stop("Failed to install mise — run: npm install -g @jdxcode/mise", 1)
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
// Run mise install inside the new vault to install
|
|
177
|
-
spin.start("Installing
|
|
176
|
+
// Run mise install inside the new vault to install node + pnpm
|
|
177
|
+
spin.start("Installing node + pnpm via mise")
|
|
178
178
|
run(["mise", "trust"], targetDir)
|
|
179
179
|
const miseOk = run(["mise", "install"], targetDir)
|
|
180
|
-
if (miseOk) spin.stop("
|
|
180
|
+
if (miseOk) spin.stop("node + pnpm installed")
|
|
181
181
|
else spin.stop("mise install failed — run it manually inside your vault", 1)
|
|
182
182
|
|
|
183
|
+
// Install vault dependencies via pnpm
|
|
184
|
+
spin.start("Installing vault dependencies")
|
|
185
|
+
const pnpmOk = run(["mise", "exec", "--", "pnpm", "install"], targetDir)
|
|
186
|
+
if (pnpmOk) spin.stop("dependencies installed")
|
|
187
|
+
else spin.stop("pnpm install failed — run it manually inside your vault", 1)
|
|
188
|
+
|
|
183
189
|
// Git init
|
|
184
190
|
spin.start("Initializing git repo")
|
|
185
191
|
const gitOk = run(["git", "init"], targetDir)
|
package/package.json
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-second-brain",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "The fastest way to start your personal knowledge base powered by Obsidian, Claude Code, qmd, and GitHub.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"claude-second-brain": "./bin/create.js"
|
|
8
8
|
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"docs:dev": "vocs dev",
|
|
11
|
+
"docs:build": "vocs build",
|
|
12
|
+
"docs:preview": "vocs preview"
|
|
13
|
+
},
|
|
9
14
|
"files": [
|
|
10
15
|
"bin/",
|
|
11
16
|
"template/",
|
|
12
17
|
"image.png"
|
|
13
18
|
],
|
|
14
19
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
20
|
+
"node": ">=22.0.0"
|
|
16
21
|
},
|
|
22
|
+
"packageManager": "pnpm@10.8.0",
|
|
17
23
|
"dependencies": {
|
|
18
24
|
"@clack/prompts": "^1.2.0",
|
|
19
25
|
"picocolors": "^1.1.1"
|
|
@@ -22,5 +28,12 @@
|
|
|
22
28
|
"repository": {
|
|
23
29
|
"type": "git",
|
|
24
30
|
"url": "https://github.com/jessepinkman9900/claude-second-brain"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "^19.2.14",
|
|
34
|
+
"react": "^19.2.5",
|
|
35
|
+
"react-dom": "^19.2.5",
|
|
36
|
+
"typescript": "^6.0.2",
|
|
37
|
+
"vocs": "1.4.1"
|
|
25
38
|
}
|
|
26
39
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: brain-ingest
|
|
3
3
|
description: "Ingest a new source into the wiki. Reads the source, summarizes it, creates a wiki/sources/ page, updates affected topic and entity pages, flags contradictions, and logs the activity. Trigger phrases: /brain-ingest, ingest [file or URL], add this source, read and file this, process this article/paper/note."
|
|
4
|
-
argument-hint: "File path (e.g. sources/articles/my-article.md), URL, or leave blank if source is pasted in chat"
|
|
4
|
+
argument-hint: "File path (e.g. raw-sources/articles/my-article.md), URL, or leave blank if source is pasted in chat"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Brain Ingest
|
|
@@ -10,7 +10,7 @@ Runs the full 9-step ingest workflow defined in CLAUDE.md. Do not skip steps.
|
|
|
10
10
|
|
|
11
11
|
## Inputs
|
|
12
12
|
|
|
13
|
-
- **File path** — a file in `sources/articles/`, `sources/pdfs/`, or `sources/personal/`
|
|
13
|
+
- **File path** — a file in `raw-sources/articles/`, `raw-sources/pdfs/`, or `raw-sources/personal/`
|
|
14
14
|
- **URL** — fetch and read the full content directly
|
|
15
15
|
- **Pasted text** — treat whatever the user has shared as the source
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ Runs the full 9-step ingest workflow defined in CLAUDE.md. Do not skip steps.
|
|
|
35
35
|
- Add the new source to the Sources Ingested section: one-line description + `[[wiki/sources/slug]]` link
|
|
36
36
|
|
|
37
37
|
**Step 5 — Identify affected wiki pages**
|
|
38
|
-
- Run: `INDEX_PATH=__QMD_PATH__
|
|
38
|
+
- Run: `INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "<source topic and key claims>"`
|
|
39
39
|
- Also Glob `wiki/*.md` and `wiki/sources/*.md` to catch anything qmd missed
|
|
40
40
|
- List all pages to create or update before proceeding
|
|
41
41
|
|
|
@@ -63,6 +63,6 @@ Runs the full 9-step ingest workflow defined in CLAUDE.md. Do not skip steps.
|
|
|
63
63
|
|
|
64
64
|
## Hard Rules
|
|
65
65
|
|
|
66
|
-
- Never modify anything in `sources/` — immutable raw inputs
|
|
66
|
+
- Never modify anything in `raw-sources/` — immutable raw inputs
|
|
67
67
|
- Every wiki page must have frontmatter with at least `type` and `updated`
|
|
68
68
|
- One source summary page per source — never merge two sources into one
|
|
@@ -12,7 +12,7 @@ Redesigns the qmd schema based on what the wiki actually contains today, then re
|
|
|
12
12
|
|
|
13
13
|
- The wiki has grown and the current single `wiki` collection no longer matches how the user searches
|
|
14
14
|
- The user wants finer-grained contexts (e.g. distinct context descriptions per sub-folder)
|
|
15
|
-
- After significant reorganization of `wiki/` or `sources/` folder structure
|
|
15
|
+
- After significant reorganization of `wiki/` or `raw-sources/` folder structure
|
|
16
16
|
- Never as a routine refresh — for that, use `/brain-refresh`
|
|
17
17
|
|
|
18
18
|
## Procedure
|
|
@@ -25,14 +25,14 @@ All commands run from the vault root.
|
|
|
25
25
|
- Read `CLAUDE.md` to understand the documented schema and any references to collection names
|
|
26
26
|
- List current state from qmd:
|
|
27
27
|
```bash
|
|
28
|
-
INDEX_PATH=__QMD_PATH__
|
|
29
|
-
INDEX_PATH=__QMD_PATH__
|
|
30
|
-
INDEX_PATH=__QMD_PATH__
|
|
28
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection list
|
|
29
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd context list
|
|
30
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd status
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Step 2 — Analyze the wiki
|
|
34
34
|
|
|
35
|
-
- Glob `wiki/**/*.md` and `sources/**/*.md`
|
|
35
|
+
- Glob `wiki/**/*.md` and `raw-sources/**/*.md`
|
|
36
36
|
- Read enough pages (especially `wiki/index.md` and `wiki/overview.md`) to understand actual topic clusters, page-type distribution, and folder structure
|
|
37
37
|
- Identify natural groupings: by domain (e.g. ml, distributed-systems, finance), by page type (topics vs entities vs qa), by source provenance, etc.
|
|
38
38
|
|
|
@@ -74,20 +74,20 @@ If collection names changed:
|
|
|
74
74
|
For each existing collection that no longer fits the new schema:
|
|
75
75
|
|
|
76
76
|
```bash
|
|
77
|
-
INDEX_PATH=__QMD_PATH__
|
|
77
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection remove <old-name>
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
For each obsolete context:
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
|
-
INDEX_PATH=__QMD_PATH__
|
|
83
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd context rm <path>
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
### Step 8 — Register the new schema
|
|
87
87
|
|
|
88
88
|
Run:
|
|
89
89
|
```bash
|
|
90
|
-
|
|
90
|
+
pnpm qmd:setup
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
This is idempotent — collections that already exist (e.g. ones you kept) are skipped; new ones are added; contexts are upserted.
|
|
@@ -96,7 +96,7 @@ This is idempotent — collections that already exist (e.g. ones you kept) are s
|
|
|
96
96
|
|
|
97
97
|
Run:
|
|
98
98
|
```bash
|
|
99
|
-
|
|
99
|
+
pnpm qmd:reindex
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
This indexes all files under the new collections and generates fresh embeddings.
|
|
@@ -104,9 +104,9 @@ This indexes all files under the new collections and generates fresh embeddings.
|
|
|
104
104
|
### Step 10 — Verify and report
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
INDEX_PATH=__QMD_PATH__
|
|
108
|
-
INDEX_PATH=__QMD_PATH__
|
|
109
|
-
INDEX_PATH=__QMD_PATH__
|
|
107
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection list
|
|
108
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd context list
|
|
109
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd status
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
Confirm the new collections appear, contexts match the plan, and document/embedding counts are non-zero. Report a summary of what changed (collections added/removed/renamed, contexts updated, files re-indexed, references updated in CLAUDE.md and skills).
|
|
@@ -116,4 +116,4 @@ Confirm the new collections appear, contexts match the plan, and document/embedd
|
|
|
116
116
|
- Never apply schema changes without explicit user approval at Step 4
|
|
117
117
|
- Never delete a collection without first showing the user what will be dropped
|
|
118
118
|
- Always update `CLAUDE.md` and skill files in lockstep with collection renames — stale `-c <name>` references will silently break `/brain-search`
|
|
119
|
-
- Do not touch `wiki/`, `sources/`, or any user content — this skill changes the index schema, not the data
|
|
119
|
+
- Do not touch `wiki/`, `raw-sources/`, or any user content — this skill changes the index schema, not the data
|
|
@@ -6,12 +6,12 @@ argument-hint: "Optional: 'force' to force re-embedding of every chunk (slow, us
|
|
|
6
6
|
|
|
7
7
|
# Brain Refresh
|
|
8
8
|
|
|
9
|
-
Refreshes the qmd index so search reflects the current state of the vault. Wraps `
|
|
9
|
+
Refreshes the qmd index so search reflects the current state of the vault. Wraps `pnpm qmd:reindex` (incremental) and the qmd CLI's force-embed flag.
|
|
10
10
|
|
|
11
11
|
## When to Use
|
|
12
12
|
|
|
13
13
|
- After a `/brain-ingest` session (or several) — batch the refresh, don't run after every file edit
|
|
14
|
-
- After manual edits to `wiki/` or `sources/` files
|
|
14
|
+
- After manual edits to `wiki/` or `raw-sources/` files
|
|
15
15
|
- When `/brain-search` results feel stale or miss recently added content
|
|
16
16
|
- After upgrading `@tobilu/qmd` or changing the embedding model — use `force` mode
|
|
17
17
|
|
|
@@ -23,7 +23,7 @@ All commands run from the vault root.
|
|
|
23
23
|
|
|
24
24
|
Run:
|
|
25
25
|
```bash
|
|
26
|
-
|
|
26
|
+
pnpm qmd:reindex
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
This script does two things:
|
|
@@ -38,10 +38,10 @@ When the user passes `force`, re-embed **every** chunk — not just the changed
|
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
# Step 1 — update the file index first
|
|
41
|
-
|
|
41
|
+
pnpm qmd:reindex
|
|
42
42
|
|
|
43
43
|
# Step 2 — force re-embed everything
|
|
44
|
-
INDEX_PATH=__QMD_PATH__
|
|
44
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd embed -f
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Force mode is slow — confirm with the user before proceeding if the wiki is large.
|
|
@@ -51,7 +51,7 @@ Force mode is slow — confirm with the user before proceeding if the wiki is la
|
|
|
51
51
|
After refresh, confirm with:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
INDEX_PATH=__QMD_PATH__
|
|
54
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd status
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
Document and embedding counts should be non-zero and reflect recent activity. If embeddings show as `0` or far below document count, re-run the refresh.
|
|
@@ -11,7 +11,7 @@ Runs the 4-step query workflow defined in CLAUDE.md. Answers come with inline `[
|
|
|
11
11
|
## Workflow
|
|
12
12
|
|
|
13
13
|
**Step 1 — Search the wiki**
|
|
14
|
-
- Run hybrid search: `INDEX_PATH=__QMD_PATH__
|
|
14
|
+
- Run hybrid search: `INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "<question>"`
|
|
15
15
|
- Read `wiki/index.md` to confirm coverage and catch any pages qmd didn't surface
|
|
16
16
|
- Read the 2–5 most relevant pages in full before synthesizing
|
|
17
17
|
|
|
@@ -13,10 +13,10 @@ Local semantic document index with hybrid search (BM25 + vector), collection man
|
|
|
13
13
|
This vault keeps its index at `__QMD_PATH__`. All CLI commands **must** prefix with `INDEX_PATH=__QMD_PATH__`:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
INDEX_PATH=__QMD_PATH__
|
|
16
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "..."
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
The scripts `
|
|
19
|
+
The scripts `pnpm qmd:setup` and `pnpm qmd:reindex` write to this same file. The CLI must match.
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
@@ -24,40 +24,40 @@ The scripts `bun scripts/qmd/setup.ts` and `bun scripts/qmd/reindex.ts` write to
|
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
# Create/index a collection
|
|
27
|
-
INDEX_PATH=__QMD_PATH__
|
|
27
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection add <path> --name <name> --mask <glob-pattern>
|
|
28
28
|
# e.g.:
|
|
29
|
-
INDEX_PATH=__QMD_PATH__
|
|
29
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection add wiki --name wiki --mask "**/*.md"
|
|
30
30
|
|
|
31
31
|
# List all collections with details
|
|
32
|
-
INDEX_PATH=__QMD_PATH__
|
|
32
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection list
|
|
33
33
|
|
|
34
34
|
# Remove a collection
|
|
35
|
-
INDEX_PATH=__QMD_PATH__
|
|
35
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection remove <name>
|
|
36
36
|
|
|
37
37
|
# Rename a collection
|
|
38
|
-
INDEX_PATH=__QMD_PATH__
|
|
38
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection rename <old-name> <new-name>
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## Listing Files
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
INDEX_PATH=__QMD_PATH__
|
|
45
|
-
INDEX_PATH=__QMD_PATH__
|
|
44
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd ls
|
|
45
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd ls [collection[/path]]
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
## Context
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
INDEX_PATH=__QMD_PATH__
|
|
52
|
-
INDEX_PATH=__QMD_PATH__
|
|
53
|
-
INDEX_PATH=__QMD_PATH__
|
|
51
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd context add [path] "description text"
|
|
52
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd context list
|
|
53
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd context rm <path>
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
## Retrieving Documents
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
INDEX_PATH=__QMD_PATH__
|
|
60
|
-
INDEX_PATH=__QMD_PATH__
|
|
59
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd get <file>[:line] [-l N] [--from N]
|
|
60
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd multi-get <pattern> [-l N] [--max-bytes N]
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
**Multi-get format flags:** `--json`, `--csv`, `--md`, `--xml`, `--files`
|
|
@@ -66,16 +66,16 @@ INDEX_PATH=__QMD_PATH__ bunx @tobilu/qmd multi-get <pattern> [-l N] [--max-bytes
|
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
68
|
# Show index status and collections
|
|
69
|
-
INDEX_PATH=__QMD_PATH__
|
|
69
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd status
|
|
70
70
|
|
|
71
71
|
# Re-index all collections
|
|
72
|
-
INDEX_PATH=__QMD_PATH__
|
|
72
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd update [--pull]
|
|
73
73
|
|
|
74
74
|
# Create vector embeddings (900 tokens/chunk, 15% overlap)
|
|
75
|
-
INDEX_PATH=__QMD_PATH__
|
|
75
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd embed [-f]
|
|
76
76
|
|
|
77
77
|
# Remove cache and orphaned data, vacuum DB
|
|
78
|
-
INDEX_PATH=__QMD_PATH__
|
|
78
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd cleanup
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
> After bulk ingest sessions, run `update` then `embed` to keep the index fresh.
|
|
@@ -108,28 +108,28 @@ INDEX_PATH=__QMD_PATH__ bunx @tobilu/qmd cleanup
|
|
|
108
108
|
|
|
109
109
|
```bash
|
|
110
110
|
# Hybrid search across all collections
|
|
111
|
-
INDEX_PATH=__QMD_PATH__
|
|
111
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query "distributed systems consensus"
|
|
112
112
|
|
|
113
113
|
# Search only the wiki collection, JSON output
|
|
114
|
-
INDEX_PATH=__QMD_PATH__
|
|
114
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "transformer architecture" --json
|
|
115
115
|
|
|
116
116
|
# Keyword-only search, top 10, markdown output
|
|
117
|
-
INDEX_PATH=__QMD_PATH__
|
|
117
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd search -c wiki "kafka" -n 10 --md
|
|
118
118
|
|
|
119
119
|
# Vector search with full documents
|
|
120
|
-
INDEX_PATH=__QMD_PATH__
|
|
120
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd vsearch "attention mechanism" --full
|
|
121
121
|
|
|
122
122
|
# Filter by score threshold
|
|
123
|
-
INDEX_PATH=__QMD_PATH__
|
|
123
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query "machine learning" --all --min-score 0.7
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
## MCP Server
|
|
127
127
|
|
|
128
128
|
```bash
|
|
129
|
-
INDEX_PATH=__QMD_PATH__
|
|
130
|
-
INDEX_PATH=__QMD_PATH__
|
|
131
|
-
INDEX_PATH=__QMD_PATH__
|
|
132
|
-
INDEX_PATH=__QMD_PATH__
|
|
129
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd mcp
|
|
130
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd mcp --http [--port N]
|
|
131
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd mcp --http --daemon
|
|
132
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd mcp stop
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
## Global Options
|
|
@@ -145,24 +145,24 @@ Note: use `INDEX_PATH` env var rather than `--index` — `INDEX_PATH` accepts a
|
|
|
145
145
|
### First-time setup for this vault
|
|
146
146
|
```bash
|
|
147
147
|
# Handled by the /setup skill:
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
pnpm qmd:setup
|
|
149
|
+
pnpm qmd:reindex
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
### After a bulk ingest session
|
|
153
153
|
```bash
|
|
154
|
-
INDEX_PATH=__QMD_PATH__
|
|
155
|
-
INDEX_PATH=__QMD_PATH__
|
|
154
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd update
|
|
155
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd embed
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
### Research workflow
|
|
159
159
|
```bash
|
|
160
160
|
# Discover relevant pages
|
|
161
|
-
INDEX_PATH=__QMD_PATH__
|
|
161
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "<topic>"
|
|
162
162
|
|
|
163
163
|
# Get a specific file
|
|
164
|
-
INDEX_PATH=__QMD_PATH__
|
|
164
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd get wiki/distributed-systems.md
|
|
165
165
|
|
|
166
166
|
# Get multiple related files
|
|
167
|
-
INDEX_PATH=__QMD_PATH__
|
|
167
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd multi-get "wiki/kafka.md,wiki/distributed-systems.md" --md
|
|
168
168
|
```
|
|
@@ -21,7 +21,7 @@ All commands run from the vault root.
|
|
|
21
21
|
|
|
22
22
|
Run:
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
pnpm qmd:setup
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Registers the two core qmd collections (`wiki`, `raw-sources`) and their path-level context descriptions. Idempotent — safe to re-run.
|
|
@@ -30,7 +30,7 @@ Registers the two core qmd collections (`wiki`, `raw-sources`) and their path-le
|
|
|
30
30
|
|
|
31
31
|
Run:
|
|
32
32
|
```bash
|
|
33
|
-
|
|
33
|
+
pnpm qmd:reindex
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Scans all collections for new/changed files and generates vector embeddings. The first run downloads ~2GB of local GGUF models — this will take a while.
|
|
@@ -39,7 +39,7 @@ Scans all collections for new/changed files and generates vector embeddings. The
|
|
|
39
39
|
|
|
40
40
|
Skip step 1 and run only:
|
|
41
41
|
```bash
|
|
42
|
-
|
|
42
|
+
pnpm qmd:reindex
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Do **not** re-run after every single file edit — batch it after a session.
|
|
@@ -50,17 +50,17 @@ Run these three commands to confirm everything is working:
|
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
# List registered collections (expect: wiki, raw-sources)
|
|
53
|
-
INDEX_PATH=__QMD_PATH__
|
|
53
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd collection list
|
|
54
54
|
|
|
55
55
|
# List registered contexts
|
|
56
|
-
INDEX_PATH=__QMD_PATH__
|
|
56
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd context list
|
|
57
57
|
|
|
58
58
|
# Show index status and embedding counts
|
|
59
|
-
INDEX_PATH=__QMD_PATH__
|
|
59
|
+
INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd status
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Both collections should appear in `collection list`. `status` should show non-zero document and embedding counts — if embeddings are 0, re-run step 2.
|
|
63
63
|
|
|
64
64
|
## Notes
|
|
65
|
-
- `
|
|
66
|
-
- If `
|
|
65
|
+
- `node` and `pnpm` are managed via `mise` — ensure `mise install` and `pnpm install` have been run before setup
|
|
66
|
+
- If `pnpm dlx @tobilu/qmd` commands fail after setup, re-run step 1 then step 2
|
package/template/CLAUDE.md
CHANGED
|
@@ -18,7 +18,7 @@ Claude is responsible for: summarizing, cross-referencing, filing, and maintaini
|
|
|
18
18
|
```
|
|
19
19
|
claude-second-brain/
|
|
20
20
|
├── CLAUDE.md ← This file. The schema.
|
|
21
|
-
├── sources/
|
|
21
|
+
├── raw-sources/ ← Raw source material. IMMUTABLE — Claude never modifies these.
|
|
22
22
|
│ ├── articles/ ← Web articles saved as markdown
|
|
23
23
|
│ ├── pdfs/ ← PDF files or extracted text
|
|
24
24
|
│ └── personal/ ← Personal notes flagged for ingestion
|
|
@@ -95,7 +95,7 @@ Run this workflow whenever the user adds a new source. Do not skip steps.
|
|
|
95
95
|
|
|
96
96
|
**Step 1 — Read the source**
|
|
97
97
|
- If URL: fetch and read the full content.
|
|
98
|
-
- If file in `sources/`: read it with the Read tool.
|
|
98
|
+
- If file in `raw-sources/`: read it with the Read tool.
|
|
99
99
|
- If pasted text: treat as the source.
|
|
100
100
|
|
|
101
101
|
**Step 2 — Discuss with the user**
|
|
@@ -111,7 +111,7 @@ Run this workflow whenever the user adds a new source. Do not skip steps.
|
|
|
111
111
|
- Add the new source to the Sources section with a one-line description and link.
|
|
112
112
|
|
|
113
113
|
**Step 5 — Identify affected wiki pages**
|
|
114
|
-
- Run `INDEX_PATH=__QMD_PATH__
|
|
114
|
+
- Run `INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "<source topic and key claims>"` to surface related existing wiki pages.
|
|
115
115
|
- Also Glob `wiki/*.md` and `wiki/sources/*.md` to ensure completeness.
|
|
116
116
|
- List all pages to create or update.
|
|
117
117
|
|
|
@@ -142,7 +142,7 @@ Run this workflow whenever the user adds a new source. Do not skip steps.
|
|
|
142
142
|
Run this workflow when the user asks a question against the wiki.
|
|
143
143
|
|
|
144
144
|
**Step 1 — Search the wiki**
|
|
145
|
-
- Run `INDEX_PATH=__QMD_PATH__
|
|
145
|
+
- Run `INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "<question>"` to surface semantically relevant pages.
|
|
146
146
|
- Read `wiki/index.md` to confirm coverage and catch any pages qmd didn't surface.
|
|
147
147
|
- Read the 2-5 most relevant pages fully.
|
|
148
148
|
|
|
@@ -199,7 +199,7 @@ N issues found, N fixed. [Brief summary of notable findings.]
|
|
|
199
199
|
|
|
200
200
|
## Hard Rules
|
|
201
201
|
|
|
202
|
-
1. **Never modify anything in `sources/`**. These are immutable raw inputs.
|
|
202
|
+
1. **Never modify anything in `raw-sources/`**. These are immutable raw inputs.
|
|
203
203
|
2. **Never touch existing vault files** (daily-notes, misc, ideas, root-level .md files, .obsidian/). The wiki lives only in `wiki/`.
|
|
204
204
|
3. **Always append to `wiki/log.md`** — never overwrite it.
|
|
205
205
|
4. **One source summary per ingested source** in `wiki/sources/`. Never merge two sources into one summary page.
|
|
@@ -211,21 +211,21 @@ N issues found, N fixed. [Brief summary of notable findings.]
|
|
|
211
211
|
|
|
212
212
|
## Search Tool
|
|
213
213
|
|
|
214
|
-
This vault uses **qmd** (`
|
|
215
|
-
Collections and contexts are registered via `
|
|
214
|
+
This vault uses **qmd** (`pnpm dlx @tobilu/qmd`) for local semantic and full-text search.
|
|
215
|
+
Collections and contexts are registered via `pnpm qmd:setup` and stored at `__QMD_PATH__` (gitignored).
|
|
216
216
|
|
|
217
217
|
Key commands:
|
|
218
218
|
|
|
219
219
|
| Command | Use |
|
|
220
220
|
|---------|-----|
|
|
221
|
-
| `INDEX_PATH=__QMD_PATH__
|
|
222
|
-
| `INDEX_PATH=__QMD_PATH__
|
|
223
|
-
| `INDEX_PATH=__QMD_PATH__
|
|
221
|
+
| `INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd query -c wiki "<question>"` | Hybrid search — best for topic discovery |
|
|
222
|
+
| `INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd search -c wiki "<terms>"` | Fast keyword search (BM25, no LLM) |
|
|
223
|
+
| `INDEX_PATH=__QMD_PATH__ pnpm dlx @tobilu/qmd vsearch -c wiki "<question>"` | Pure vector/semantic search |
|
|
224
224
|
|
|
225
225
|
Add `--json` for structured output. Omit `-c wiki` to search all collections (wiki, raw-sources, human, daily-notes).
|
|
226
226
|
|
|
227
227
|
**Re-indexing:** After a bulk ingest session run:
|
|
228
228
|
```bash
|
|
229
|
-
|
|
229
|
+
pnpm qmd:reindex
|
|
230
230
|
```
|
|
231
231
|
Do NOT re-index after every single file edit.
|
package/template/README.md
CHANGED
|
@@ -13,10 +13,13 @@ Inspired by [Andrej Karpathy's approach to LLM-powered knowledge management](htt
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
# 1. Install tools
|
|
16
|
+
# 1. Install tools (node + pnpm via mise)
|
|
17
17
|
mise install
|
|
18
18
|
|
|
19
|
-
# 2.
|
|
19
|
+
# 2. Install dependencies
|
|
20
|
+
pnpm install
|
|
21
|
+
|
|
22
|
+
# 3. Open Claude Code
|
|
20
23
|
claude
|
|
21
24
|
```
|
|
22
25
|
|
|
@@ -36,7 +39,7 @@ Registers the qmd collections and generates local vector embeddings. First run d
|
|
|
36
39
|
|
|
37
40
|
### Daily workflow
|
|
38
41
|
|
|
39
|
-
**`/brain-ingest`** — Add a file to `sources/articles/`, `sources/pdfs/`, or `sources/personal/`, then run `/brain-ingest`. Claude summarizes the source, asks what aspects matter most, updates related wiki pages, flags contradictions, and logs everything.
|
|
42
|
+
**`/brain-ingest`** — Add a file to `raw-sources/articles/`, `raw-sources/pdfs/`, or `raw-sources/personal/`, then run `/brain-ingest`. Claude summarizes the source, asks what aspects matter most, updates related wiki pages, flags contradictions, and logs everything.
|
|
40
43
|
|
|
41
44
|
**`/brain-search`** — Ask anything: `what do I know about [topic]?` Claude searches the wiki semantically and returns a cited answer. If it synthesizes multiple pages in a useful way, it offers to file it as a permanent `wiki/qa/` entry.
|
|
42
45
|
|
|
@@ -60,7 +63,7 @@ Sources flow in on the left, Claude synthesizes them into the wiki, qmd indexes
|
|
|
60
63
|
|
|
61
64
|
```mermaid
|
|
62
65
|
flowchart TB
|
|
63
|
-
subgraph Sources["sources/ — raw, immutable"]
|
|
66
|
+
subgraph Sources["raw-sources/ — raw, immutable"]
|
|
64
67
|
direction LR
|
|
65
68
|
S1[articles/]
|
|
66
69
|
S2[pdfs/]
|
|
@@ -138,7 +141,7 @@ All pages cross-link with Obsidian `[[wikilinks]]`. Contradictions are flagged w
|
|
|
138
141
|
```
|
|
139
142
|
claude-second-brain/
|
|
140
143
|
├── CLAUDE.md ← The schema. Claude reads this every session.
|
|
141
|
-
├── sources/
|
|
144
|
+
├── raw-sources/ ← Your raw inputs. Claude never modifies these.
|
|
142
145
|
│ ├── articles/ ← Web articles saved as markdown
|
|
143
146
|
│ ├── pdfs/ ← PDFs or extracted text
|
|
144
147
|
│ └── personal/ ← Brain dumps, rough notes
|
|
@@ -185,7 +188,7 @@ After a bulk ingest session, re-index to keep search current:
|
|
|
185
188
|
/brain-refresh
|
|
186
189
|
```
|
|
187
190
|
|
|
188
|
-
This wraps `
|
|
191
|
+
This wraps `pnpm qmd:reindex` — you can also run that command directly if you're not inside Claude Code. Pass `force` to `/brain-refresh` to re-embed every chunk (e.g. after changing the embedding model).
|
|
189
192
|
|
|
190
193
|
---
|
|
191
194
|
|
package/template/mise.toml
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-second-brain-vault",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"qmd:setup": "tsx scripts/qmd/setup.ts",
|
|
7
|
+
"qmd:reindex": "tsx scripts/qmd/reindex.ts"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@tobilu/qmd": "^2.1.0"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@types/node": "^22.10.2",
|
|
14
|
+
"tsx": "^4.19.2",
|
|
15
|
+
"typescript": "^5.7.2"
|
|
16
|
+
},
|
|
17
|
+
"packageManager": "pnpm@10.8.0",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.0.0"
|
|
20
|
+
},
|
|
21
|
+
"pnpm": {
|
|
22
|
+
"onlyBuiltDependencies": [
|
|
23
|
+
"better-sqlite3",
|
|
24
|
+
"esbuild",
|
|
25
|
+
"node-llama-cpp",
|
|
26
|
+
"tree-sitter-go",
|
|
27
|
+
"tree-sitter-javascript",
|
|
28
|
+
"tree-sitter-python",
|
|
29
|
+
"tree-sitter-rust",
|
|
30
|
+
"tree-sitter-typescript"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* First run downloads ~2GB of GGUF models — expected, one-time.
|
|
5
5
|
*
|
|
6
6
|
* Run from vault root:
|
|
7
|
-
*
|
|
7
|
+
* pnpm qmd:reindex
|
|
8
8
|
*
|
|
9
9
|
* Suitable as a cronjob:
|
|
10
|
-
* 0 * * * * cd /home/user/my-brain &&
|
|
10
|
+
* 0 * * * * cd /home/user/my-brain && pnpm qmd:reindex
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { createStore } from "@tobilu/qmd"
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
* Safe to re-run: skips collections that already exist, upserts contexts.
|
|
4
4
|
*
|
|
5
5
|
* Run once from vault root:
|
|
6
|
-
*
|
|
6
|
+
* pnpm qmd:setup
|
|
7
7
|
*
|
|
8
8
|
* After setup, index the vault:
|
|
9
|
-
*
|
|
9
|
+
* pnpm qmd:reindex
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { createStore } from "@tobilu/qmd"
|
|
13
|
-
import { join } from "path"
|
|
13
|
+
import { dirname, join } from "node:path"
|
|
14
|
+
import { fileURLToPath } from "node:url"
|
|
14
15
|
|
|
15
|
-
const VAULT = join(import.meta.
|
|
16
|
+
const VAULT = join(dirname(fileURLToPath(import.meta.url)), "../..")
|
|
16
17
|
const DB = "__QMD_PATH__"
|
|
17
18
|
|
|
18
19
|
const store = await createStore({ dbPath: DB })
|
|
@@ -32,7 +33,7 @@ async function ensureCollection(name: string, relPath: string, pattern: string)
|
|
|
32
33
|
|
|
33
34
|
console.log("Collections:")
|
|
34
35
|
await ensureCollection("wiki", "wiki", "**/*.md")
|
|
35
|
-
await ensureCollection("raw-sources", "sources",
|
|
36
|
+
await ensureCollection("raw-sources", "raw-sources", "**/*.md")
|
|
36
37
|
|
|
37
38
|
// --- Global context ---
|
|
38
39
|
console.log("\nContexts:")
|
|
@@ -47,10 +48,10 @@ await store.addContext("wiki", "", "LLM-maintained synthesized knowledge
|
|
|
47
48
|
await store.addContext("wiki", "/sources", "Source summaries — one page per ingested source, with abstract, key claims, and synthesis notes")
|
|
48
49
|
await store.addContext("wiki", "/qa", "Filed Q&A answers that synthesize multiple wiki pages around a notable question")
|
|
49
50
|
|
|
50
|
-
// sources/
|
|
51
|
+
// raw-sources/
|
|
51
52
|
await store.addContext("raw-sources", "", "Raw source material — immutable originals, never modified after ingestion")
|
|
52
53
|
await store.addContext("raw-sources", "/articles", "Web articles saved as markdown")
|
|
53
54
|
await store.addContext("raw-sources", "/pdfs", "PDF files or their extracted text")
|
|
54
55
|
await store.addContext("raw-sources", "/personal", "Personal notes flagged for wiki ingestion")
|
|
55
56
|
|
|
56
|
-
console.log("\nSetup complete. Run:
|
|
57
|
+
console.log("\nSetup complete. Run: pnpm qmd:reindex")
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
// Environment setup & latest features
|
|
4
3
|
"lib": ["ESNext"],
|
|
5
4
|
"target": "ESNext",
|
|
6
|
-
"module": "
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
7
|
"moduleDetection": "force",
|
|
8
|
-
"jsx": "react-jsx",
|
|
9
8
|
"allowJs": true,
|
|
10
9
|
|
|
11
|
-
// Bundler mode
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
10
|
"verbatimModuleSyntax": true,
|
|
15
11
|
"noEmit": true,
|
|
16
12
|
|
|
17
|
-
// Best practices
|
|
18
13
|
"strict": true,
|
|
19
14
|
"skipLibCheck": true,
|
|
20
15
|
"noFallthroughCasesInSwitch": true,
|
|
21
16
|
"noUncheckedIndexedAccess": true,
|
|
22
|
-
"noImplicitOverride": true
|
|
23
|
-
|
|
24
|
-
// Some stricter flags (disabled by default)
|
|
25
|
-
"noUnusedLocals": false,
|
|
26
|
-
"noUnusedParameters": false,
|
|
27
|
-
"noPropertyAccessFromIndexSignature": false
|
|
17
|
+
"noImplicitOverride": true
|
|
28
18
|
}
|
|
29
19
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|