@unson/brainbase-mcp 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Unson LLC
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 ADDED
@@ -0,0 +1,493 @@
1
+ # Brainbase Personal Onboarding Kit
2
+
3
+ Brainbase is a local-first MCP server for handing your personal source of truth to AI coding tools.
4
+
5
+ The v1 value is narrow by design: create a canonical local SSOT for yourself, your work, relationships, and decisions, then expose it through MCP tools that Codex, Claude, and CodeCode can call.
6
+
7
+ Ontology 1.0.0 adds a portable semantic contract on top of those local files. It defines types, relation vocabulary, validation constraints, deterministic decision inference, and version-evolution guidance without requiring a hosted Brainbase service.
8
+
9
+ This repository does not include the internal Brainbase UI, session runtime, xterm transport, workflow mission control, social operations, hosted backend, Infisical setup, or Unson internal data. Those belong in the internal `brainbase-unson` system.
10
+
11
+ ## Manual
12
+
13
+ Read the public onboarding manual at [brainbase.pages.dev](https://brainbase.pages.dev/). It guides users through five phases: choose one real use case, register approved work context, prove the first value, add only necessary sources, and operationalize Skills, routines, and MCP.
14
+
15
+ The manual is the best starting point for first-time users. It explains Brainbase concepts, the first onboarding flow, MCP registration, project context setup, source onboarding, daily routines, and CLI reference.
16
+
17
+ ## Agent-assisted Onboarding
18
+
19
+ Brainbase is designed to be adopted from Codex, Claude Code, or CodeCode. The first onboarding goal is a useful answer from your own context, not connector setup.
20
+
21
+ ```bash
22
+ npm install
23
+ npm run build
24
+ npm run onboard:start -- --target codex
25
+ ```
26
+
27
+ `onboard:start` is the Japanese first-run entrypoint for agent-assisted onboarding. It creates the minimum Personal OS directory, but it does not save self, project, relationship, decision, mail, calendar, drive, or task facts until the user approves them. It asks Codex or Claude Code what context you do not want to explain repeatedly, then shows the first prompt to try, the expected value, the minimum seed command, `onboard:demo`, project registration, optional source diagnosis, candidate review, MCP install, and `doctor`. The demo command appears before source diagnosis.
28
+
29
+ If the user says "I want to onboard Brainbase", the agent should run this flow instead of returning a checklist. The expected sequence is: build if needed, run `onboard:start`, ask for the smallest context the user wants Brainbase to remember, seed only approved facts, then run `onboard:demo` with a real request. The agent must show the prompt, sample result, what the user no longer had to explain, and the still-unfinished operationalization work. `ready: true`, `first_value_demo_ready`, generated skills, generated routines, and `onboard:install --dry-run` are not completion signals by themselves.
30
+
31
+ For a Google Workspace / Google Drive / local-notes setup, pass the known answers and let the command surface what still needs approval:
32
+
33
+ ```bash
34
+ node dist/cli.js onboard:start \
35
+ --target codex \
36
+ --name "Your Name" \
37
+ --project "Current project" \
38
+ --goal "What this project should achieve" \
39
+ --status "Current state" \
40
+ --role "Your role" \
41
+ --email gmail \
42
+ --calendar google-calendar \
43
+ --drive google-drive \
44
+ --drive-folder "<allowed-google-drive-folder-id>" \
45
+ --tasks scattered-calendar-notes
46
+ ```
47
+
48
+ The output is intentionally command-ready for Codex and Claude Code. It keeps OAuth tokens out of chat, starts with metadata-first collection, requires Drive/local folder allowlists, and keeps `sources/` plus `candidates/` as secondary material until the user approves canonical writes.
49
+
50
+ If you only want the raw interview protocol, use:
51
+
52
+ ```bash
53
+ node dist/cli.js onboard:agent
54
+ ```
55
+
56
+ Paste the generated protocol into Codex or Claude Code. The agent should first ask what you do not want to explain repeatedly:
57
+
58
+ - a work premise
59
+ - a key relationship
60
+ - a decision principle
61
+ - an active project
62
+
63
+ Then approve the smallest facts that should become canonical local SSOT and seed them explicitly:
64
+
65
+ ```bash
66
+ brainbase onboard:init
67
+ brainbase onboard:seed \
68
+ --name "Your Name" \
69
+ --value "What should not be re-explained" \
70
+ --project "Current project" \
71
+ --relationship "Key Partner|collaborator|Context you want AI tools to remember"
72
+ ```
73
+
74
+ Run the first value demo with a real request. This is the onboarding completion signal:
75
+
76
+ ```bash
77
+ brainbase onboard:demo --scenario "Draft the first note I should send to Key Partner about Current project"
78
+ ```
79
+
80
+ `onboard:demo` reads only locally saved, approved facts. It does not call an LLM, hosted backend, or raw source collector. If it returns `ready: true`, the agent still needs to show the try-this prompt, sample result, and plain-language value: the user did not have to explain the saved work premise or person context again.
81
+
82
+ After the demo, keep onboarding open until the operationalization checklist is either completed or explicitly deferred:
83
+
84
+ ```bash
85
+ brainbase onboard:skills --target codex
86
+ brainbase onboard:routines --target codex --cwd /path/to/brainbase
87
+ brainbase onboard:install --target codex --dry-run
88
+ brainbase doctor
89
+ ```
90
+
91
+ The recommended order is public skills, `ohayo` / `oyasumi` / `retro` routines registered paused or confirmation-gated, real MCP config merge after approving the dry-run snippet, source allowlist / import / candidate review decisions, then `doctor` plus MCP `get_context` / `search` verification from a fresh agent session.
92
+
93
+ The commands above are still safe by default. `onboard:skills` and `onboard:routines` generate output unless you provide an explicit `--out`, and `onboard:install --dry-run` is only a preview. Do not treat those generated artifacts as installed until the user approves file writes, scheduler registration, and live config changes.
94
+
95
+ Preview the MCP config before merging it into the real agent config:
96
+
97
+ ```bash
98
+ brainbase onboard:install --target codex --dry-run
99
+ brainbase doctor
100
+ ```
101
+
102
+ Source setup is optional follow-up work. After the demo, ask Brainbase to diagnose the local source setup only when the demo shows that more context is needed or when you want to import existing tools:
103
+
104
+ ```bash
105
+ brainbase onboard:diagnose-sources \
106
+ --email gmail \
107
+ --calendar google-calendar \
108
+ --drive google-drive \
109
+ --drive-folder "<allowed-google-drive-folder-id>" \
110
+ --tasks notion
111
+ ```
112
+
113
+ Gmail, Google Calendar, and Google Drive diagnosis uses local GoG-style collection when available. The first pass should be metadata-first. Drive collection requires explicit folder allowlists. If GoG is missing, diagnosis reports `needs_setup` instead of pretending import is ready.
114
+
115
+ For a Google Workspace local-first adopter with an always-on SSH-accessible Mac mini, Workspace mail/calendar/drive, a secondary Gmail account, local files, and tasks scattered across Calendar and notes, generate the setup plan first:
116
+
117
+ ```bash
118
+ brainbase onboard:plan \
119
+ --profile google-workspace-local \
120
+ --host mac-mini \
121
+ --email google-workspace \
122
+ --secondary-email gmail \
123
+ --calendar google-calendar \
124
+ --drive google-drive \
125
+ --drive-folder "<allowed-google-drive-folder-id>" \
126
+ --local-folder "<allowed-local-notes-folder>" \
127
+ --tasks scattered-calendar-notes \
128
+ --inactive-task-tool notion
129
+ ```
130
+
131
+ This plan treats the Mac mini as the user's local MCP runtime host, not as a hosted Brainbase backend or server-operations handoff. Google Workspace and Gmail are staged through read-only metadata-first GoG steps. Google Drive and local files are allowlist-first; do not scan the whole Drive or home directory. If Notion was tried and abandoned, keep it as inactive context and extract task candidates from Google Calendar and approved local notes instead.
132
+
133
+ Candidate files are also optional post-demo review material. They do not count as canonical memory:
134
+
135
+ ```bash
136
+ brainbase onboard:candidates --write \
137
+ --name "Your Name" \
138
+ --value "What should not be re-explained" \
139
+ --project "Current project" \
140
+ --relationship "Key Partner|collaborator|Context you want AI tools to remember"
141
+ ```
142
+
143
+ Review candidates with the user, then promote only approved facts through `brainbase onboard:seed` or an equivalent explicit promotion flow.
144
+
145
+ ### Register active projects
146
+
147
+ Brainbase can register active projects from the onboarding interview before any external source is connected. Codex or Claude Code should ask the user about the project goal, current status, their role, key stakeholders, allowed source areas, task sources, and project-specific decision principles. Source references are metadata-only allowlists; this command does not read mail, calendar, drive, task, or local-note content.
148
+
149
+ ```bash
150
+ # Dry-run first: show the project registration plan without canonical writes
151
+ brainbase onboard:projects \
152
+ --name "Current project" \
153
+ --goal "What this project should achieve" \
154
+ --status "Current state" \
155
+ --role "Your role" \
156
+ --stakeholder "Key Partner|collaborator|Why this person matters" \
157
+ --source "drive|Proposal folder|gdrive-folder-id" \
158
+ --task-source "Calendar follow-ups" \
159
+ --decision-principle "How AI should make tradeoffs in this project"
160
+
161
+ # After user approval, promote it into canonical SSOT
162
+ brainbase onboard:projects --name "Current project" --goal "Approved goal" --write
163
+ ```
164
+
165
+ After `--write`, project context is stored in canonical local SSOT and becomes visible through Brainbase MCP `get_context`, `list_entities`, and `search`.
166
+
167
+ ### Import collected sources and extract candidates
168
+
169
+ Once the diagnosed GoG collectors have produced metadata JSON, complete the value loop locally. Brainbase still never authenticates to a provider; it only normalizes already-collected JSON, derives candidates, and promotes the ones you select.
170
+
171
+ ```bash
172
+ # 1. Import collected provider JSON (metadata-first; bodies and file contents are dropped)
173
+ gog gmail search "newer_than:90d" --json > /tmp/gmail.json
174
+ brainbase onboard:import --source gmail --from /tmp/gmail.json
175
+ brainbase onboard:import --source calendar --from /tmp/calendar.json
176
+ brainbase onboard:import --source drive --from /tmp/drive.json
177
+ brainbase onboard:import --source local --from /tmp/local-notes.json
178
+
179
+ # 2. Extract reviewable candidates from sources/ (deterministic; exclude your own address)
180
+ brainbase onboard:extract --self-email you@example.com --write
181
+
182
+ # 3. Review the extracted candidate file, then promote only selected ids (dry-run by default)
183
+ brainbase onboard:apply --from <candidate-file> --select <id> --write
184
+ brainbase doctor
185
+ ```
186
+
187
+ `onboard:import` and `onboard:extract` never write canonical SSOT. Only `onboard:apply --write` promotes selected candidates into `graph.json`, `personal-kg.jsonl`, `relationships.json`, and `decisions.jsonl`.
188
+
189
+ ### Register the daily operating routines
190
+
191
+ Loading context once is not enough; the operating loop runs every day. Generate personal-scoped morning (`ohayo`), end-of-day (`oyasumi`), and weekly retrospective (`retro`) routines for whichever coding agent you run. Brainbase prints the definition; your agent registers it with its own scheduler. The routines are scoped to your own connected sources and local Brainbase MCP context — they are not the internal Unson operations.
192
+
193
+ ```bash
194
+ # Codex host (emits per-file automation.toml documents)
195
+ brainbase onboard:routines --target codex --cwd /path/to/brainbase \
196
+ --ohayo-hour 7 --oyasumi-hour 22 --retro-dow FRI --retro-hour 17
197
+
198
+ # Claude Code host (emits scheduled-task definitions with cron + prompt)
199
+ brainbase onboard:routines --target claude --cwd /path/to/brainbase
200
+
201
+ # Only some routines, written to a file
202
+ brainbase onboard:routines --target codex --routines ohayo,retro --out ./routines.toml
203
+ ```
204
+
205
+ `onboard:routines` is generation-only and dry-run by default: it prints definitions, writes a file only with `--out`, never registers a live scheduler, and never writes canonical SSOT.
206
+
207
+ ### Public onboarding skillsを生成する
208
+
209
+ Brainbaseには、コーディングエージェント向けの公開safeな最小skillsも入っています。これは内部Brainbase運用skillsではなく、個人オンボーディング、ソース取り込み、候補レビュー、日次ルーティンのための日本語instructionsです。
210
+
211
+ ```bash
212
+ # Codex-compatible skill paths に合わせて表示
213
+ brainbase onboard:skills --target codex
214
+
215
+ # Claude Code project skill paths に合わせて表示
216
+ brainbase onboard:skills --target claude
217
+
218
+ # portableなSKILL.mdをreview用ディレクトリへ書き出す
219
+ brainbase onboard:skills --target portable --out ./brainbase-skills
220
+
221
+ # 一部のskillsだけ生成する
222
+ brainbase onboard:skills --target codex --skills brainbase-source-import,brainbase-candidate-review
223
+ ```
224
+
225
+ 標準のpublic skill ids:
226
+
227
+ - `brainbase-personal-onboarding`
228
+ - `brainbase-source-import`
229
+ - `brainbase-candidate-review`
230
+ - `brainbase-daily-routines`
231
+
232
+ `onboard:skills` はgeneration-onlyで、defaultはdry-runです。`--out` のときだけファイルを書き、既存の `SKILL.md` はoverwriteしません。live Codex / Claude Code configurationもcanonical SSOTも変更しません。
233
+
234
+ `onboard:recommend` remains available when you only want connector guidance:
235
+
236
+ ```bash
237
+ brainbase onboard:recommend \
238
+ --email gmail \
239
+ --calendar google-calendar \
240
+ --drive google-drive \
241
+ --tasks notion
242
+ ```
243
+
244
+ External sources are staged as secondary material:
245
+
246
+ ```text
247
+ ~/.brainbase/personal-os/
248
+ sources/
249
+ gmail/
250
+ calendar/
251
+ drive/
252
+ tasks/
253
+ candidates/
254
+ ```
255
+
256
+ Do not paste OAuth tokens, passwords, API keys, or refresh tokens into chat. Imported mail, calendar, drive, and task material stays under `sources/` until reviewed. Only approved candidates should be promoted into `graph.json`, `relationships.json`, `personal-kg.jsonl`, or `decisions.jsonl`.
257
+
258
+ ## 30 Minute Setup
259
+
260
+ ```bash
261
+ npm install
262
+ npm run build
263
+ npm run onboard:init
264
+ npm run onboard:seed -- --name "Your Name" --value "What matters in your work" --project "Current project" --relationship "Key Partner|collaborator|Context you want AI tools to remember"
265
+ node dist/cli.js onboard:demo --scenario "Draft the first note I should send to Key Partner about Current project"
266
+ npm run doctor
267
+ npm run onboard:install -- --target codex --dry-run
268
+ ```
269
+
270
+ The default data directory is:
271
+
272
+ ```text
273
+ ~/.brainbase/personal-os/
274
+ ```
275
+
276
+ It contains the canonical local SSOT:
277
+
278
+ - `graph.json`: people, organizations, projects, and relationship entities.
279
+ - `personal-kg.jsonl`: values, judgment criteria, experiences, and personal context.
280
+ - `relationships.json`: relationship context that should survive across tools.
281
+ - `decisions.jsonl`: decision records and principles.
282
+ - `sources/`: optional raw notes, logs, mail, calendar, drive, and task exports. MCP tools prefer canonical files over these raw materials.
283
+
284
+ Brainbase CLI and MCP readers coordinate canonical updates with a local process lock and recover interrupted multi-file writes before reading. Code that opens the four canonical files directly does not participate in that lock, so concurrent raw filesystem reads are outside the atomic consistency guarantee. Use the Brainbase CLI or MCP tools when another Brainbase process may be writing.
285
+ - `candidates/`: staging area for extracted facts before user approval.
286
+ - `schemas/`: generated schema references for the local files.
287
+
288
+ For a local checkout, launch the built MCP server with:
289
+
290
+ ```bash
291
+ BRAINBASE_PERSONAL_OS_DIR=/path/to/personal-os npm start
292
+ ```
293
+
294
+ The generated MCP client config uses the same idea explicitly: your current Node executable plus this checkout's built `dist/index.js`.
295
+
296
+ When installed as a package, you can launch it with:
297
+
298
+ ```bash
299
+ BRAINBASE_PERSONAL_OS_DIR=/path/to/personal-os brainbase-mcp
300
+ ```
301
+
302
+ ## MCP Tools
303
+
304
+ - `get_context`: returns initial AI context from the local Graph and Personal KG.
305
+ - `list_entities`: lists `person`, `org`, `project`, `relationship`, and `decision` entities.
306
+ - `search`: searches canonical Graph and Personal KG data.
307
+ - `search_personal_kg`: searches owner-local Personal KG only.
308
+ - `onboarding_status`: reports seeded areas, first value demo readiness, missing setup, and local connection status.
309
+ - `get_ontology`: returns the immutable bundled Ontology 1.0.0 release without reading Personal OS files.
310
+ - `audit_ontology`: audits canonical local files and distinguishes verified violations from unavailable input.
311
+ - `infer_decisions`: derives active, superseded, and conflicting decisions from explicit rules.
312
+ - `ontology_impact`: explains compatibility, migration, and rollback from an earlier ontology version.
313
+
314
+ ## Portable Ontology 1.0.0
315
+
316
+ Inspect the semantic contract and audit your local canonical files:
317
+
318
+ ```bash
319
+ brainbase ontology:show
320
+ brainbase ontology:audit
321
+ brainbase ontology:audit --ontology-version 0.0.0
322
+ ```
323
+
324
+ `ontology:audit` exits non-zero when an error-level violation exists or when a canonical file cannot be verified. It never reports an unavailable or malformed source as zero violations. Warnings, such as a relationship whose person is not yet present in the Graph, remain visible but do not block approved writes.
325
+ Use `--ontology-version 0.0.0` to interpret a pre-kernel snapshot without retroactively applying the 1.0.0 `effectiveAt`, supersession, conflict, or validation rules. The selected version is included in audit and inference results; unsupported versions fail explicitly.
326
+
327
+ Decision evolution is opt-in, read-compatible, and write-gated. Existing decision rows remain readable. New rows may add `topic`, `supersedes`, and `effectiveAt`; only an explicit `supersedes` reference makes an older decision inactive. Multiple active decisions with the same explicit `topic` are reported as a conflict instead of being silently resolved.
328
+
329
+ Before enabling 1.0.0 writes, back up the Personal OS directory, capture the current MCP client configuration and launch command, and run the read-only `brainbase ontology:audit --ontology-version 1.0.0`. Existing rows remain readable, but error-level semantic violations must be reviewed before `onboard:seed`, `onboard:projects --write`, or `onboard:apply --write` can change canonical files. For the first npm release, rollback means running `npm uninstall -g @unson/brainbase-mcp`, restoring the captured MCP client configuration and launch command, and restarting the client. For later upgrades, reinstall the last known working package version instead. Restore the pre-upgrade Personal OS backup only if reviewed repairs changed canonical files.
330
+
331
+ ## CLI
332
+
333
+ When installed as a package, Brainbase exposes two binaries:
334
+
335
+ ```bash
336
+ brainbase-mcp
337
+ brainbase
338
+ ```
339
+
340
+ For local checkout onboarding, run commands through `npm run ...` until the package is installed or linked. `onboard:install` writes a config that launches the built MCP entrypoint with your current Node executable, so the generated config works without guessing whether `brainbase-mcp` is on `PATH`.
341
+
342
+ Installed package commands:
343
+
344
+ ```bash
345
+ brainbase onboard:init
346
+ brainbase onboard:seed
347
+ brainbase onboard:demo
348
+ brainbase onboard:install --target codex --dry-run
349
+ brainbase onboard:import --source gmail --from /tmp/gmail.json
350
+ brainbase onboard:extract --self-email you@example.com --write
351
+ brainbase onboard:apply --from <candidate-file> --select <id> --write
352
+ brainbase onboard:projects --name "Current project" --goal "What this project should achieve"
353
+ brainbase onboard:routines --target codex --cwd /path/to/brainbase
354
+ brainbase onboard:skills --target codex
355
+ brainbase ontology:show
356
+ brainbase ontology:audit
357
+ brainbase doctor
358
+ ```
359
+
360
+ Local checkout equivalents:
361
+
362
+ ```bash
363
+ npm run build
364
+ node dist/cli.js onboard:agent
365
+ node dist/cli.js onboard:demo --scenario "Draft the first note I should send to Key Partner about Current project"
366
+ node dist/cli.js onboard:plan --profile google-workspace-local --host mac-mini --email google-workspace --secondary-email gmail --calendar google-calendar --drive google-drive --drive-folder "<folder-id>" --local-folder "<notes-folder>" --tasks scattered-calendar-notes --inactive-task-tool notion
367
+ node dist/cli.js onboard:diagnose-sources --email gmail --calendar google-calendar --drive google-drive --drive-folder "<folder-id>" --tasks notion
368
+ node dist/cli.js onboard:candidates --write --name "Your Name" --project "Current project"
369
+ node dist/cli.js onboard:projects --name "Current project" --goal "What this project should achieve"
370
+ node dist/cli.js onboard:import --source gmail --from /tmp/gmail.json
371
+ node dist/cli.js onboard:extract --self-email you@example.com --write
372
+ node dist/cli.js onboard:apply --from <candidate-file> --select <id> --write
373
+ node dist/cli.js onboard:routines --target codex --cwd "$(pwd)"
374
+ node dist/cli.js onboard:skills --target codex
375
+ node dist/cli.js onboard:recommend --email gmail --calendar google-calendar --drive google-drive --tasks notion
376
+ npm run onboard:init
377
+ npm run onboard:seed -- --name "Your Name"
378
+ npm run onboard:install -- --target codex --dry-run
379
+ npm run doctor
380
+ ```
381
+
382
+ Non-interactive seed example:
383
+
384
+ ```bash
385
+ brainbase onboard:seed \
386
+ --name "Your Name" \
387
+ --value "Clear ownership and durable decisions" \
388
+ --decision-principle "Prefer canonical facts over chat memory" \
389
+ --project "Personal AI operating system" \
390
+ --relationship "Key Partner|collaborator|Works with me on AI adoption"
391
+ ```
392
+
393
+ ## Install MCP Config
394
+
395
+ Dry-run output:
396
+
397
+ ```bash
398
+ npm run onboard:install -- --target codex --dry-run
399
+ npm run onboard:install -- --target claude --dry-run
400
+ npm run onboard:install -- --target codecode --dry-run
401
+ ```
402
+
403
+ The command prints a valid MCP server config snippet. Use `--output /path/to/new-snippet-file` when you want Brainbase to write the generated snippet.
404
+
405
+ `--output` intentionally creates a new snippet file and refuses to overwrite an existing file. It does not merge into existing Codex, Claude, or CodeCode config files. Review the snippet, then paste or merge it into the target client config yourself so existing MCP servers and client settings are preserved.
406
+
407
+ Codex output is TOML for `~/.codex/config.toml` style configuration:
408
+
409
+ ```toml
410
+ [mcp_servers.brainbase]
411
+ command = "/path/to/node"
412
+ args = ["/path/to/brainbase/dist/index.js"]
413
+
414
+ [mcp_servers.brainbase.env]
415
+ BRAINBASE_PERSONAL_OS_DIR = "/path/to/personal-os"
416
+ ```
417
+
418
+ Claude and CodeCode output use the standard MCP `mcpServers` JSON shape:
419
+
420
+ ```json
421
+ {
422
+ "mcpServers": {
423
+ "brainbase": {
424
+ "command": "/path/to/node",
425
+ "args": ["/path/to/brainbase/dist/index.js"],
426
+ "env": {
427
+ "BRAINBASE_PERSONAL_OS_DIR": "/path/to/personal-os"
428
+ }
429
+ }
430
+ }
431
+ }
432
+ ```
433
+
434
+ Choose a temporary snippet path when using `--output`; do not point it at a live client config unless you have already moved the old file aside.
435
+
436
+ ## Migration From Prior Brainbase Repos
437
+
438
+ This repository is intentionally replaced as the external Personal Onboarding Kit. It is not a compatible continuation of the previous internal Brainbase UI/runtime package.
439
+
440
+ Use this repo when you want:
441
+
442
+ - Local personal SSOT under `~/.brainbase/personal-os/`.
443
+ - MCP access from Codex, Claude, or CodeCode.
444
+ - No hosted backend, no Infisical requirement, and no Unson internal data.
445
+
446
+ Keep or pin the internal `brainbase-unson` system when you need:
447
+
448
+ - Brainbase UI, session runtime, terminal/xterm transport, workflow mission control, or social operations.
449
+ - bb.unson.jp, Lightsail, Graph API, JWT/API-token flows, or hosted sync.
450
+ - Legacy Graph API MCP tools such as `get_entity`.
451
+ - VibePro runtime or internal 31013 operation surfaces.
452
+
453
+ The v1 MCP surface contains the five original context/onboarding tools plus the additive Ontology 1.0.0 tools: `get_ontology`, `audit_ontology`, `infer_decisions`, and `ontology_impact`.
454
+
455
+ ## Hosted Backends
456
+
457
+ v1 does not support hosted Brainbase backends, Unson APIs, Infisical-managed secrets, bb.unson.jp sync, or Lightsail sync.
458
+
459
+ Future hosted behavior should be separated behind an explicit option such as:
460
+
461
+ ```bash
462
+ BRAINBASE_BACKEND=hosted
463
+ ```
464
+
465
+ Local MCP mode requires no secrets.
466
+
467
+ ## Development
468
+
469
+ ```bash
470
+ npm install
471
+ npm run build
472
+ npm test
473
+ npm pack --dry-run
474
+ ```
475
+
476
+ ### Maintainer release operation
477
+
478
+ Scoped package publication is configured as public. Configure the repository Actions secret `NPM_TOKEN`, then normally publish a version-bumped merge from the reviewed `develop` history. The merge trigger plans the version delta automatically. For the first `0.1.0` publication or recovery, dispatch the same package-wide serialized workflow from the GitHub CLI. `NPM_TOKEN` must be authorized to publish `@unson/brainbase-mcp`.
479
+
480
+ ```bash
481
+ RELEASE_REF="${RELEASE_REF:-develop}"
482
+ gh workflow run npm-publish.yml --repo Unson-LLC/brainbase --ref develop -f release_ref="$RELEASE_REF"
483
+ ```
484
+
485
+ Dispatch the reviewed ref once and retain the Actions run URL as release evidence. Do not rerun a failed first-publication attempt until its failure phase is known: if it stopped before registry mutation, revert or correct the reviewed release change before a new dispatch; if npm already contains the version, treat that version as immutable and use the verification or version-bump recovery path below.
486
+
487
+ Direct local `release:publish` is rejected because it would bypass the package-wide Actions concurrency queue. The CLI requires a runner-issued GitHub OIDC attestation for the exact upstream workflow on `refs/heads/develop` and the current run, so caller-set Actions environment variables or the same workflow path on another ref are not sufficient. Local `release:plan`, `release:validate`, and `release:verify` remain available for credential-free diagnosis; all registry mutation goes through the workflow above.
488
+
489
+ The validation CLI rejects dirty checkouts and commits outside the trusted ref, then runs build, test, production dependency audit, creates the real tarball without an npm credential, and stamps its manifest with the exact reviewed `gitHead` before hashing it. Publication requires the matching proof, rechecks both SHA-256 and npm-compatible SHA-512 integrity, publishes that same tarball with lifecycle scripts disabled, and compares registry `dist.integrity` with the validated artifact. It is idempotent: it publishes an absent version, or verifies that an existing immutable version has the same Git commit and bytes. It also reconciles the appropriate npm dist-tag. The workflow runs validation in a read-only job with no OIDC or npm credential, then transfers the immutable artifact to a separately permissioned publication job with npm provenance. The publish CLI requires the upstream GitHub Actions context and the workflow serialization marker, so supported mutation paths share one package queue. Its manual `release_ref` input is restricted to commits reachable from `develop` and is used for the first publication or recovery. `release:verify` is read-only and fails if metadata or dist-tags do not match.
490
+
491
+ Publication is complete only after the Actions `validate` and `publish` jobs pass, the npm registry reports the expected version, `gitHead`, `dist.integrity`, and dist-tag, and the matching GitHub Release targets the reviewed release commit. Retain those registry values, the GitHub Release URL, and the Actions run URL together; a green workflow or GitHub Release alone is insufficient. If `NPM_TOKEN` is absent or the workflow is disabled, read-only local CLI operations still work, but the npm release remains incomplete.
492
+
493
+ npm versions are immutable. Before publication, fix the cause and rerun the same reviewed ref. After a faulty publication, deprecate that version, keep users on the last known-good pinned version, and release a reviewed version bump; never overwrite the published bytes. Any manual dist-tag rollback requires a separate registry metadata and support review.
package/SECURITY.md ADDED
@@ -0,0 +1,62 @@
1
+ # Security Policy
2
+
3
+ ## Scope
4
+
5
+ Brainbase MCP v1 is a local-first package. It does not require hosted backends, Infisical, bb.unson.jp, Lightsail, API keys, OAuth tokens, or Unson internal data.
6
+
7
+ The default runtime reads canonical local files under `~/.brainbase/personal-os/` or the path supplied through `BRAINBASE_PERSONAL_OS_DIR`.
8
+
9
+ ## Supported Checks
10
+
11
+ Before release or contribution, run:
12
+
13
+ ```bash
14
+ npm run build
15
+ npm test
16
+ npm audit
17
+ npm pack --dry-run --json
18
+ ```
19
+
20
+ For public package publication, use:
21
+
22
+ ```bash
23
+ npm publish --access public
24
+ ```
25
+
26
+ `package.json` includes `publishConfig.access=public` so scoped package publication does not accidentally default to private package semantics.
27
+
28
+ `npm pack --dry-run --json` should include only the package runtime and public docs:
29
+
30
+ - `dist/`
31
+ - `README.md`
32
+ - `LICENSE`
33
+ - `SECURITY.md`
34
+ - `package.json`
35
+
36
+ It must not include personal SSOT files, raw sources, UI artifacts, internal operation scripts, VibePro workbench files, or secrets.
37
+
38
+ ## Local Data
39
+
40
+ Do not commit files from:
41
+
42
+ - `~/.brainbase/personal-os/`
43
+ - Any directory used as `BRAINBASE_PERSONAL_OS_DIR`
44
+ - `sources/` directories that contain raw personal notes, logs, or meeting transcripts
45
+
46
+ The repository templates and tests must use synthetic fixture data only.
47
+
48
+ ## Reporting Security Issues
49
+
50
+ Report security issues through GitHub:
51
+
52
+ https://github.com/Unson-LLC/brainbase/issues
53
+
54
+ Do not include credentials, personal SSOT content, private meeting notes, or raw logs in public issues.
55
+
56
+ ## Best Practices
57
+
58
+ - Keep local MCP mode secret-free.
59
+ - Use placeholders in documentation and fixtures.
60
+ - Prefer canonical local SSOT files over raw source material.
61
+ - Treat hosted backends and remote sync as future optional integrations, not v1 behavior.
62
+ - Keep `.vibepro/`, `node_modules/`, `dist/`, coverage output, and local test scratch directories out of git.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ interface CliIo {
3
+ stdout?: {
4
+ write(chunk: string): unknown;
5
+ };
6
+ stderr?: {
7
+ write(chunk: string): unknown;
8
+ };
9
+ }
10
+ export declare function runCli(argv?: string[], io?: CliIo): Promise<number>;
11
+ export {};