claude-second-brain 1.2.2 → 1.3.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/README.md CHANGED
@@ -1,345 +1,69 @@
1
-
2
1
  # :classical_building: claude-second-brain
3
2
 
4
3
  **Your notes don't compound. This wiki does.**
5
4
 
6
5
  [![npm](https://img.shields.io/npm/v/claude-second-brain)](https://www.npmjs.com/package/claude-second-brain) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [![Ask DeepWiki](https://img.shields.io/badge/Ask-DeepWiki-blue)](https://deepwiki.com/jessepinkman9900/claude-second-brain)
7
6
 
7
+ [Getting started](https://jessepinkman9900.github.io/claude-second-brain/getting-started) · [Skills](https://jessepinkman9900.github.io/claude-second-brain/skills) · [CLI](https://jessepinkman9900.github.io/claude-second-brain/cli) · [How it works](https://jessepinkman9900.github.io/claude-second-brain/concepts/how-it-works)
8
8
 
9
- The fastest way to start your personal knowledge base powered by [Obsidian](https://obsidian.md), your AI coding agent ([Claude Code](https://claude.ai/code), Codex, Cursor, GitHub Copilot, Gemini CLI, and more), [qmd](https://github.com/tobi/qmd), and git.
9
+ Drop in an article, PDF or note. Your AI agent reads it, files it into a cross-linked wiki, and answers questions about it months later with citations.
10
10
 
11
+ > **Inspired by [Andrej Karpathy's approach to LLM-powered knowledge management](https://x.com/karpathy/status/2040470801506541998?s=20)**: give an LLM agent an "idea file" and let it build and maintain your knowledge base.
11
12
 
12
- ```
13
+ ```bash
13
14
  npx claude-second-brain
14
15
  ```
15
16
 
16
- One command gives you a fully wired knowledge system:
17
- - Your AI agent ([Claude Code](https://claude.ai/code), Codex, Cursor, …) ingests your sources and maintains a cross-linked wiki
18
- - [qmd](https://github.com/tobi/qmd) powers local semantic search
19
- - The scaffolded folder **is your Obsidian vault** — open it directly in [Obsidian](https://obsidian.md), with [obsidian-git](https://github.com/Vinzent03/obsidian-git) pre-configured for seamless sync
20
- - A git ([GitHub](https://github.com), [Cloudflare Artifacts](https://developers.cloudflare.com/artifacts/), or any remote) is the source of truth — version history, anywhere access, and a backup you control
21
-
22
- You've been reading papers, articles, and books for years. Drop a source in, run `/brain-ingest`, and your agent reads it — extracts what matters, cross-links it to everything you already know, and files it. Ask a question six months later and get cited answers, not a list of files to re-read.
23
-
24
- > **Inspired by [Andrej Karpathy's approach to LLM-powered knowledge management](https://x.com/karpathy/status/2040470801506541998?s=20)** — share an "idea file" with an LLM agent and let it build and maintain your knowledge base.
17
+ Needs Node 22+ and an agent that supports [Agent Skills](https://agentskills.io). [Obsidian](https://obsidian.md) is optional.
25
18
 
26
19
  ![Obsidian graph view of a running wiki](image.png)
27
20
 
28
- ---
29
-
30
-
31
- ## How this is different
21
+ ## What you get
32
22
 
33
- This is not a RAG system. It's not a chatbot over your notes. It's an actively maintained, cross-linked wiki — five structured page types, YAML frontmatter, and a set of agent skills that run the whole thing — in Claude Code, Codex, Cursor, Copilot, or any agent that supports [Agent Skills](https://agentskills.io).
23
+ - **A wiki your agent maintains.** Summaries, topic pages, cross-links and contradiction flags, written for you.
24
+ - **Local search** across everything, powered by [qmd](https://github.com/tobi/qmd).
25
+ - **An [Obsidian](https://jessepinkman9900.github.io/claude-second-brain/integrations/obsidian) vault** with graph view, backlinks and [git sync](https://jessepinkman9900.github.io/claude-second-brain/integrations/obsidian-git) already set up. Read it on your phone through [iCloud](https://jessepinkman9900.github.io/claude-second-brain/integrations/icloud).
26
+ - **Plain git** as the source of truth: GitHub, Cloudflare Artifacts, or any remote.
34
27
 
28
+ ## Quickstart
35
29
 
36
- The schema (`CLAUDE.md`) is that idea file. Your agent reads it every session (other agents reach it through `AGENTS.md`).
30
+ 1. **Create a brain.** Run `npx claude-second-brain` and answer four prompts.
31
+ 2. **Build the search index.** Run `pnpm qmd:reindex` in the new brain folder. The first run downloads about 2GB of models, once per machine.
32
+ 3. **Add a source.** Save an article to `raw-sources/articles/` and run `/brain-ingest` in your agent.
33
+ 4. **Ask.** Run `/brain-search` with a question and get an answer that cites your wiki pages.
37
34
 
38
- ---
35
+ The [setup guide](https://jessepinkman9900.github.io/claude-second-brain/getting-started) covers each prompt, git remotes and Obsidian.
39
36
 
40
- ## The stack
37
+ ## Skills
41
38
 
42
- | Tool | Role |
39
+ | Skill | What it does |
43
40
  |---|---|
44
- | **Your agent** (Claude Code, Codex, Cursor, Copilot, …) | Reads sources, writes wiki pages, cross-links, flags contradictions |
45
- | **qmd** | Local hybrid search (vector + BM25) across your entire wiki |
46
- | **Obsidian** | Graph view, backlinks, mobile reading — offline, no extra sync |
47
- | **Git** (GitHub, Cloudflare Artifacts, …) | Source of truth — version history, your agent anywhere, Obsidian sync |
48
-
49
- Everything is pre-configured. You bring the sources.
50
-
51
- ---
52
-
53
- ## Get started in 3 steps
54
-
55
- **Step 1 — Scaffold**
56
-
57
- ```bash
58
- npx claude-second-brain
59
- ```
60
-
61
- Or install globally — `csb` is a shorter alias:
62
-
63
- ```bash
64
- npm i -g claude-second-brain
65
- csb
66
- ```
67
-
68
- The CLI will ask:
69
- - **Brain name** — what to call this brain (default: `my-brain`)
70
- - **Git remote** — GitHub (private repo via `gh`), Cloudflare Artifacts (via wrangler), or skip
71
- - **Register qmd collections after install?**
72
- - **Install skills for which agents?** — Claude Code plus any detected agent is preselected
73
-
74
- Creates the brain at `~/.claude-second-brain/my-brain/`, registers it in `~/.claude-second-brain/config.toml`, runs `pnpm install` (using your system pnpm 10+, or mise to fetch node + pnpm if it's missing), registers the qmd collections, installs the skills for the agents you picked, and runs `git init`.
75
-
76
- **Step 2 — Generate vector embeddings**
77
-
78
- ```bash
79
- cd ~/.claude-second-brain/my-brain
80
- pnpm qmd:reindex
81
- ```
82
-
83
- First run downloads ~2GB of GGUF models — once per machine. qmd collections are already registered by the CLI during scaffolding.
84
-
85
- **Step 3 — Open in Obsidian (and push to GitHub if not done)**
86
-
87
- **If you created a GitHub repo during setup**, it's already pushed — skip straight to opening in Obsidian.
88
-
89
- **If you skipped GitHub during setup**, connect it now:
90
-
91
- ```bash
92
- git remote add origin https://github.com/you/my-brain.git
93
- git push -u origin main
94
- ```
95
-
96
- Open `~/.claude-second-brain/my-brain/` as a vault in Obsidian — the folder is already a valid Obsidian vault. The Git plugin is pre-configured — enable it and sync is automatic.
97
-
98
- ---
99
-
100
- ## Agent skills included
101
-
102
- The wiki ships with a set of slash commands that cover the full workflow. No manual prompting, no copy-pasting.
103
-
104
- ### Daily workflow
105
-
106
- **`/brain-ingest`** — Drop a file into `raw-sources/articles/`, `raw-sources/pdfs/`, or `raw-sources/personal/`. Run `/brain-ingest`. Your agent 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.
107
-
108
- **`/brain-search`** — Ask anything about what you know. Your agent 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.
109
-
110
- **`/lint`** — Health-check the wiki. Surfaces orphan pages, broken links, unresolved contradictions, and data gaps. Reports findings and applies fixes where possible.
111
-
112
- ### Maintenance
113
-
114
- **`/brain-refresh`** — Re-scan the vault for new or changed files and regenerate vector embeddings. Run after a bulk ingest session or manual edits. Pass `force` to re-embed every chunk (e.g. after changing the embedding model).
115
-
116
- **`/brain-rebuild`** — **Destructive.** Redesigns the qmd schema: analyzes the wiki, proposes new collections and contexts, waits for your approval, then patches `scripts/qmd/setup.ts`, drops the old index, and rebuilds embeddings from scratch. Use only when the current structure no longer fits how you search.
117
-
118
- ---
119
-
120
- ## Works with any agent
121
-
122
- The wiki skills follow the open [Agent Skills](https://agentskills.io/specification) format, so the same `/brain-ingest`, `/brain-search`, `/brain-refresh`, `/brain-rebuild` and `/lint` work in every agent that supports skills. The CLI installs them for the agents you pick:
123
-
124
- | Agent | Global skills dir | Vault skills dir |
125
- |---|---|---|
126
- | Claude Code | `~/.claude/skills` (symlink) | `.claude/skills` |
127
- | Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Amp, Cline | `~/.agents/skills` | `.agents/skills` |
128
- | Windsurf | `~/.codeium/windsurf/skills` (symlink) | `.windsurf/skills` |
129
- | Goose | `~/.config/goose/skills` (symlink) | `.goose/skills` |
130
- | Kiro CLI, Roo Code, Continue, Junie, Augment | `~/.<agent>/skills` (symlink) | `.<agent>/skills` |
131
-
132
- The vault's operating instructions live in `CLAUDE.md`, with an `AGENTS.md` that points agents which read that file (Codex, Cursor, Copilot, …) to it. Using an agent that isn't listed? Copy the skill folders from `~/.agents/skills` into its skills directory.
133
-
134
- ---
135
-
136
- ## Access from anywhere
137
-
138
- **Edit anywhere — your agent on desktop, web or mobile**
139
- The vault is a plain git repo, so any agent that can clone it can work on it: run it locally, or use a cloud agent with GitHub access (Claude Code on the web and mobile, Codex cloud, Copilot coding agent, Cursor background agents, …) to ingest a source, run a query, or update a page from your phone.
140
-
141
- **Read anywhere — Obsidian desktop and mobile**
142
- Open the repo as an Obsidian vault. The bundled `.obsidian` folder pre-configures the [obsidian-git](https://github.com/Vinzent03/obsidian-git) community plugin — no setup required, just enable it. Your wiki syncs automatically on every commit. For iOS: put the repo folder inside iCloud Drive — Obsidian Mobile picks it up natively with no extra setup. Graph view, backlinks, offline reading — all working.
143
-
144
- **Browse anywhere — your git host**
145
- It's a plain git repo. On GitHub (or any host with a web UI), view and edit files directly in the browser at any time.
41
+ | [`/brain-ingest`](https://jessepinkman9900.github.io/claude-second-brain/skills/brain-ingest) | Read a source and fold it into the wiki |
42
+ | [`/brain-search`](https://jessepinkman9900.github.io/claude-second-brain/skills/brain-search) | Answer a question with citations |
43
+ | [`/lint`](https://jessepinkman9900.github.io/claude-second-brain/skills/lint) | Find broken links, orphans and contradictions |
44
+ | [`/brain-refresh`](https://jessepinkman9900.github.io/claude-second-brain/skills/brain-refresh) | Re-index after edits |
45
+ | [`/brain-rebuild`](https://jessepinkman9900.github.io/claude-second-brain/skills/brain-rebuild) | Redesign the search index (destructive) |
146
46
 
147
- ---
47
+ Works with Claude Code, Codex, Cursor, GitHub Copilot and [11 more agents](https://jessepinkman9900.github.io/claude-second-brain/skills).
148
48
 
149
49
  ## How it works
150
50
 
151
- Sources flow in on the left, your agent synthesizes them into the wiki, qmd indexes every page into a local hybrid search index, and git makes the whole vault editable from Obsidian and your agent on any device.
51
+ Your sources go in on the left. Your brain in the middle is a wiki your agent writes and cross-links, with qmd indexing it for search. Any agent on the right can read and grow it, and because the vault is a git repo, Obsidian and every device see the same files.
152
52
 
153
- ```mermaid
154
- flowchart TB
155
- subgraph Sources["raw-sources/ — raw, immutable"]
156
- direction LR
157
- S1[articles/]
158
- S2[pdfs/]
159
- S3[personal/]
160
- end
53
+ ![Articles, PDFs, notes, Obsidian and Git feed your brain (wiki + qmd), which Claude Code, Codex, Cursor, Copilot and Gemini all work with](.github/assets/how-it-works.png)
161
54
 
162
- subgraph Skills["Agent skills"]
163
- direction LR
164
- I["/brain-ingest"]
165
- Q["/brain-search"]
166
- R["/brain-refresh"]
167
- end
55
+ More in [How it works](https://jessepinkman9900.github.io/claude-second-brain/concepts/how-it-works) and the [wiki schema](https://jessepinkman9900.github.io/claude-second-brain/concepts/schema).
168
56
 
169
- subgraph Wiki["wiki/ — cross-linked synthesis"]
170
- direction LR
171
- W1[overview.md]
172
- W2[topic / entity pages]
173
- W3[sources/]
174
- W4[qa/]
175
- end
176
-
177
- QMD[("qmd.sqlite<br/>vector + BM25<br/>hybrid index")]
178
-
179
- subgraph Remote["Git remote — source of truth"]
180
- GH[private repo]
181
- end
182
-
183
- subgraph Read["Read / edit anywhere"]
184
- direction LR
185
- OB["Obsidian<br/>graph · backlinks · mobile"]
186
- CC["Your agent<br/>desktop, web + mobile"]
187
- end
188
-
189
- User((you))
190
-
191
- Sources -->|read| I
192
- I -->|write pages, cross-link,<br/>flag contradictions| Wiki
193
- R -.->|chunk + embed<br/>changed files| QMD
194
- Wiki -.->|indexed by| QMD
195
- User -->|ask a question| Q
196
- Q -->|hybrid search| QMD
197
- QMD -->|top-k pages| Q
198
- Q -->|cited answer| User
199
- Wiki <-->|"obsidian-git<br/>auto commit / pull"| GH
200
- GH --> OB
201
- GH --> CC
202
- ```
203
-
204
- ### The ingest loop, zoomed in
205
-
206
- ```
207
- ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
208
- │ Drop in a source │ │ /brain-ingest │ │ Wiki grows │
209
- │ │ │ Code │ │ │
210
- │ · article │──────▶ │ │──────▶ │ · cross-linked │
211
- │ · PDF │ │ reads + extracts │ │ pages │
212
- │ · personal note │ │ key knowledge │ │ · contradictions │
213
- │ │ │ │ │ flagged │
214
- └─────────────────────┘ └─────────────────────┘ │ · syntheses │
215
- │ written │
216
- └─────────────────────┘
217
- ```
218
-
219
- Query it anytime with `/brain-search`. Get answers with inline `[[wiki/page]]` citations, not a list of files.
220
-
221
- ---
222
-
223
- ## Wiki structure
224
-
225
- Five page types, all with YAML frontmatter:
226
-
227
- | Type | File | Purpose |
228
- |---|---|---|
229
- | `overview` | `wiki/overview.md` | Evolving high-level synthesis |
230
- | `topic` | `wiki/[concept].md` | A concept, domain, or idea |
231
- | `entity` | `wiki/[name].md` | A person, tool, company, or project |
232
- | `source-summary` | `wiki/sources/[slug].md` | One page per ingested source |
233
- | `qa` | `wiki/qa/[slug].md` | Filed answers to notable queries |
234
-
235
- All pages cross-link with Obsidian `[[wikilinks]]`. Contradictions are flagged with `[!WARNING]` callouts. Full schema in [CLAUDE.md](./CLAUDE.md).
236
-
237
- ---
238
-
239
- ## Directory layout
240
-
241
- All brains live under `~/.claude-second-brain/`. A central `config.toml` tracks them.
242
-
243
- ```
244
- ~/.claude-second-brain/
245
- ├── config.toml ← Brain registry (default brain, paths, git remotes)
246
- └── my-brain/
247
- ├── CLAUDE.md ← The schema. Your agent reads this every session.
248
- ├── raw-sources/ ← Your raw inputs. The agent never modifies these.
249
- │ ├── articles/
250
- │ ├── pdfs/
251
- │ └── personal/
252
- ├── wiki/ ← The agent owns this entirely.
253
- │ ├── index.md
254
- │ ├── log.md
255
- │ ├── overview.md
256
- │ ├── sources/
257
- │ └── qa/
258
- ├── scripts/qmd/ ← Semantic search setup and re-indexing
259
- └── .qmd/ ← qmd index (gitignored)
260
- ```
261
-
262
- ## Multiple brains
263
-
264
- Run `npx claude-second-brain` again to create additional brains. Each gets its own folder, its own qmd index, and its own git remote — fully isolated. The global skills (`/brain-ingest`, `/brain-search`, `/brain-refresh`) always operate on the **default brain** declared in `config.toml`. The first brain you create is set as the default automatically.
265
-
266
- Manage brains from the CLI (`csb` is the short alias — swap for `npx claude-second-brain` if not installed globally):
267
-
268
- ```bash
269
- csb ls # list all brains (default marked with *)
270
- csb use <name> # switch the default brain
271
- csb rm <name> # remove a brain (deletes its folder + config entry)
272
- csb path # print the default brain's directory
273
- csb path qmd # print the default brain's qmd index path
274
- csb path config # print ~/.claude-second-brain/config.toml
275
- csb qmd query -c wiki "<terms>" # run qmd against the default brain
276
- csb exec -- pnpm qmd:reindex # run any command inside the default brain
277
- csb skills --agent codex,cursor # install/update skills for more agents
278
- csb git-token # renew a Cloudflare Artifacts git token (90 days)
279
- csb doctor # verify tools, config, skills, and each brain
280
- ```
281
-
282
- Every subcommand accepts `--help` for details (`csb rm --help`, `csb path --help`, …).
283
-
284
- ---
285
-
286
- ## Installing and updating skills
287
-
288
- The skills follow the [Agent Skills](https://agentskills.io/specification) format, so they work in Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf, Goose and more. `/brain-ingest`, `/brain-search`, and `/brain-refresh` install globally during setup; `/brain-rebuild` and `/lint` live inside the vault.
289
-
290
- Setup asks which agents to install for (Claude Code plus any agent it detects is preselected). It uses the same layout as [`npx skills`](https://github.com/vercel-labs/skills):
291
-
292
- - Global skills are written once to `~/.agents/skills/<name>`. Codex, Cursor, Copilot, Gemini CLI, OpenCode, Amp and Cline read that folder directly.
293
- - Agents with their own folder get a symlink to it, e.g. `~/.claude/skills/brain-search → ~/.agents/skills/brain-search` (or `~/.codeium/windsurf/skills`, `~/.config/goose/skills`, …). If symlinks aren't available, or you pass `--copy`, the skill is copied instead.
294
- - In the vault, `/brain-rebuild` and `/lint` live in `.claude/skills/` and are copied into each other selected agent's project folder (`.agents/skills/`, `.windsurf/skills/`, …).
295
-
296
- ```bash
297
- # Pick agents up front (comma-separated, or `all`); CSB_AGENTS works too
298
- npx claude-second-brain my-brain --agent claude-code,codex,github-copilot
299
-
300
- # Add agents later, or update skills after upgrading
301
- npx claude-second-brain skills --agent cursor,windsurf
302
- npx claude-second-brain skills --list # supported agents and their skills dirs
303
- ```
304
-
305
- ### Update the built-in wiki skills
306
-
307
- The wiki's own skills are scaffolded at creation time. To pull in improvements, use `npx skills` pointing to the template skills directory in this repo:
308
-
309
- ```bash
310
- # Install or update all 5 wiki skills from the latest template
311
- npx skills add https://github.com/jessepinkman9900/claude-second-brain/tree/main/template/.claude/skills -a claude-code -y
312
-
313
- # Same, for other agents (npx skills asks which agents if you omit -a)
314
- npx skills add https://github.com/jessepinkman9900/claude-second-brain/tree/main/template/.claude/skills -a codex -a cursor -y
315
-
316
- # Or update a specific skill
317
- npx skills add https://github.com/jessepinkman9900/claude-second-brain/tree/main/template/.claude/skills --skill brain-ingest -a claude-code -y
318
- ```
319
-
320
- Once installed via `npx skills`, future updates are a single command:
57
+ ## CLI
321
58
 
322
59
  ```bash
323
- npx skills update -a claude-code
60
+ csb ls # list your brains
61
+ csb use <name> # switch the default brain
62
+ csb skills --agent codex,cursor # install skills for more agents
63
+ csb doctor # check tools, config and skills
324
64
  ```
325
65
 
326
- ---
327
-
328
- ## Roadmap
329
-
330
- - [ ] GitHub Actions to invoke `/brain-refresh` on a schedule
331
- - [ ] GitHub agentic workflows — auto-ingest on push, scheduled lint, auto-summary on new sources
332
- - [ ] More wiki skills (source discovery, topic clustering)
333
-
334
- ---
335
-
336
- ## Requirements
337
-
338
- - [pnpm](https://pnpm.io) 10+ on Node 22+, or [mise](https://mise.jdx.dev/) — if pnpm isn't installed, the CLI installs mise and uses it to fetch node + pnpm
339
- - An AI coding agent that supports [Agent Skills](https://agentskills.io) — [Claude Code](https://claude.ai/code), Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf, Goose, …
340
- - [Obsidian](https://obsidian.md/) — optional but recommended
341
-
342
- ---
66
+ `csb` comes with `npm i -g claude-second-brain`. Every command is in the [CLI reference](https://jessepinkman9900.github.io/claude-second-brain/cli).
343
67
 
344
68
  ## License
345
69
 
package/bin/create.js CHANGED
@@ -748,7 +748,7 @@ async function cmdGitToken(args) {
748
748
  let printOnly = false
749
749
  for (let i = 0; i < args.length; i++) {
750
750
  const a = args[i]
751
- if (a === "--brain") brainName = args[++i]
751
+ if (a === "--brain") { brainName = brainFlagValue(args, i); i++ }
752
752
  else if (a === "--ttl") ttl = parseTtl(args[++i])
753
753
  else if (a.startsWith("--ttl=")) ttl = parseTtl(a.slice(6))
754
754
  else if (a === "--read") scope = "read"
@@ -806,7 +806,7 @@ async function cmdSkills(args) {
806
806
 
807
807
  let brainName = null
808
808
  for (let i = 0; i < rest.length; i++) {
809
- if (rest[i] === "--brain") brainName = rest[++i]
809
+ if (rest[i] === "--brain") { brainName = brainFlagValue(rest, i); i++ }
810
810
  }
811
811
 
812
812
  const isInteractive = Boolean(process.stdin.isTTY)
@@ -861,8 +861,10 @@ function parseConfig(content) {
861
861
  return { defaultBrain: defaultMatch ? defaultMatch[1] : null, brains, header }
862
862
  }
863
863
 
864
- function hasHelpFlag(args) {
865
- return args.some(a => a === "--help" || a === "-h")
864
+ function hasHelpFlag(args, forwardAfterSeparator = false) {
865
+ const separator = forwardAfterSeparator ? args.indexOf("--") : -1
866
+ const ownArgs = separator === -1 ? args : args.slice(0, separator)
867
+ return ownArgs.some(a => a === "--help" || a === "-h")
866
868
  }
867
869
 
868
870
  async function readConfigStatus() {
@@ -1108,6 +1110,14 @@ async function cmdUse(args) {
1108
1110
  }
1109
1111
  }
1110
1112
 
1113
+ function brainFlagValue(args, index) {
1114
+ const value = args[index + 1]
1115
+ if (!value || value.startsWith("-")) {
1116
+ throw new Error("--brain requires a brain name.")
1117
+ }
1118
+ return value
1119
+ }
1120
+
1111
1121
  async function cmdPath(args) {
1112
1122
  // Canonical: csb path [qmd|config|root] [--brain <name>]
1113
1123
  // Deprecated: csb path --qmd | --config | --root
@@ -1116,7 +1126,7 @@ async function cmdPath(args) {
1116
1126
  let sawLegacyFlag = false
1117
1127
  for (let i = 0; i < args.length; i++) {
1118
1128
  const a = args[i]
1119
- if (a === "--brain") { name = args[++i]; continue }
1129
+ if (a === "--brain") { name = brainFlagValue(args, i); i++; continue }
1120
1130
  if (a === "--root") { mode = "root"; sawLegacyFlag = true; continue }
1121
1131
  if (a === "--qmd") { mode = "qmd"; sawLegacyFlag = true; continue }
1122
1132
  if (a === "--config") { mode = "config"; sawLegacyFlag = true; continue }
@@ -1143,7 +1153,7 @@ function parseBrainAndRest(args) {
1143
1153
  const rest = []
1144
1154
  for (let i = 0; i < args.length; i++) {
1145
1155
  const a = args[i]
1146
- if (a === "--brain") { name = args[++i]; continue }
1156
+ if (a === "--brain") { name = brainFlagValue(args, i); i++; continue }
1147
1157
  if (a === "--") { rest.push(...args.slice(i + 1)); break }
1148
1158
  rest.push(a)
1149
1159
  }
@@ -1541,6 +1551,12 @@ async function createBrain(initialName, { agents: explicitAgents = null, copy =
1541
1551
  p.log.step(`Name of the brain?\n${pc.dim(targetName)}`)
1542
1552
  }
1543
1553
 
1554
+ // The name is both a directory component and a TOML string. Reject path
1555
+ // separators, traversal components and characters that corrupt the config.
1556
+ if (!targetName.trim() || targetName === "." || targetName === ".." || /[/\\"\x00-\x1f\x7f]/.test(targetName)) {
1557
+ throw new Error("Brain name must be a single directory name without quotes or control characters.")
1558
+ }
1559
+
1544
1560
  const toDisplayPath = p => p.startsWith(homedir()) ? "~" + p.slice(homedir().length) : p
1545
1561
  const qmdPath = join(CSB_ROOT, targetName, ".qmd", "index.sqlite")
1546
1562
 
@@ -1833,7 +1849,7 @@ async function main() {
1833
1849
  }
1834
1850
 
1835
1851
  // Per-subcommand --help / -h — intercept before any prompts run.
1836
- if (SUBCOMMANDS.has(cmd) && hasHelpFlag(rest)) {
1852
+ if (SUBCOMMANDS.has(cmd) && hasHelpFlag(rest, cmd === "exec" || cmd === "qmd")) {
1837
1853
  const topicMap = { list: "ls", remove: "rm", default: "use", switch: "use" }
1838
1854
  await printHelp(topicMap[cmd] || cmd)
1839
1855
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-second-brain",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "The fastest way to start your personal knowledge base powered by Obsidian, any AI coding agent (Claude Code, Codex, Cursor, Copilot, …), qmd, and git.",
5
5
  "keywords": [
6
6
  "ai",
@@ -25,8 +25,10 @@
25
25
  },
26
26
  "scripts": {
27
27
  "docs:dev": "vocs dev",
28
- "docs:build": "vocs build",
29
- "docs:preview": "vocs preview"
28
+ "docs:build": "vocs build && node scripts/docs/postbuild.js",
29
+ "docs:preview": "vocs preview",
30
+ "test": "node --test tests/*.test.js",
31
+ "docs:verify": "node scripts/docs/verify.js"
30
32
  },
31
33
  "files": [
32
34
  "bin/",
@@ -52,10 +54,13 @@
52
54
  },
53
55
  "devDependencies": {
54
56
  "@types/react": "^19.3.3",
57
+ "mermaid": "^11",
55
58
  "react": "^19.3.1",
56
59
  "react-dom": "^19.3.1",
57
60
  "typescript": "^6.0.3",
58
- "vocs": "1.4.1"
61
+ "vite": "^8",
62
+ "vocs": "2.12.0",
63
+ "waku": "1.0.0-rc.5"
59
64
  },
60
65
  "pnpm": {
61
66
  "overrides": {
@@ -1,6 +1,11 @@
1
- # qmd local index (repo-scoped, machine-local)
1
+ # qmd local index (machine-local, rebuilt by `pnpm qmd:setup` / `pnpm qmd:reindex`)
2
+ .qmd/
2
3
  qmd.sqlite*
3
4
 
5
+ # Obsidian per-device UI state (open tabs, panes); differs on every device
6
+ .obsidian/workspace.json
7
+ .obsidian/workspace-mobile.json
8
+
4
9
  # Finder (MacOS) folder config
5
10
  .DS_Store
6
11