neurain 0.1.0-alpha.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +57 -0
  3. package/README.md +205 -0
  4. package/SECURITY.md +22 -0
  5. package/bin/neurain.mjs +7 -0
  6. package/docs/comparison-mem0.en.md +22 -0
  7. package/docs/connect-claude.en.md +48 -0
  8. package/docs/connect-claude.kr.md +51 -0
  9. package/docs/connect-codex.en.md +38 -0
  10. package/docs/connect-codex.kr.md +40 -0
  11. package/docs/connect-gemini.en.md +71 -0
  12. package/docs/connect-gemini.kr.md +71 -0
  13. package/docs/connect-runtime.en.md +61 -0
  14. package/docs/connect-runtime.kr.md +61 -0
  15. package/docs/development-status.en.md +157 -0
  16. package/docs/development-status.kr.md +157 -0
  17. package/docs/knowledge-os.en.md +105 -0
  18. package/docs/knowledge-os.kr.md +106 -0
  19. package/docs/pricing.en.md +14 -0
  20. package/docs/privacy-and-data-flow.en.md +25 -0
  21. package/docs/public-saas-readiness.en.md +39 -0
  22. package/docs/quickstart.en.md +64 -0
  23. package/docs/quickstart.kr.md +64 -0
  24. package/docs/release-checklist.en.md +38 -0
  25. package/docs/safety.en.md +36 -0
  26. package/docs/self-improvement-90-roadmap.en.md +429 -0
  27. package/docs/self-improvement-90-roadmap.kr.md +429 -0
  28. package/docs/self-improving-workflows.en.md +163 -0
  29. package/docs/self-improving-workflows.kr.md +163 -0
  30. package/docs/support.en.md +17 -0
  31. package/docs/troubleshooting.en.md +35 -0
  32. package/package.json +36 -0
  33. package/src/cli.mjs +261 -0
  34. package/src/core/adopt.mjs +304 -0
  35. package/src/core/answer_eval.mjs +450 -0
  36. package/src/core/capabilities.mjs +217 -0
  37. package/src/core/capture_durable.mjs +181 -0
  38. package/src/core/classify.mjs +237 -0
  39. package/src/core/compile_desk.mjs +324 -0
  40. package/src/core/complete.mjs +108 -0
  41. package/src/core/config.mjs +142 -0
  42. package/src/core/connect.mjs +355 -0
  43. package/src/core/curator.mjs +351 -0
  44. package/src/core/daemon.mjs +536 -0
  45. package/src/core/digest.mjs +155 -0
  46. package/src/core/doctor.mjs +115 -0
  47. package/src/core/durable.mjs +96 -0
  48. package/src/core/envelope.mjs +97 -0
  49. package/src/core/flush.mjs +190 -0
  50. package/src/core/fs.mjs +121 -0
  51. package/src/core/init.mjs +194 -0
  52. package/src/core/journal.mjs +269 -0
  53. package/src/core/labels.mjs +117 -0
  54. package/src/core/lessons.mjs +793 -0
  55. package/src/core/lifecycle.mjs +1138 -0
  56. package/src/core/link_check.mjs +180 -0
  57. package/src/core/live_cases.mjs +221 -0
  58. package/src/core/onboard.mjs +175 -0
  59. package/src/core/plan_receipt.mjs +177 -0
  60. package/src/core/plan_writeback.mjs +176 -0
  61. package/src/core/queue.mjs +62 -0
  62. package/src/core/queue_archive.mjs +87 -0
  63. package/src/core/queue_model.mjs +161 -0
  64. package/src/core/queue_write.mjs +28 -0
  65. package/src/core/recall.mjs +1802 -0
  66. package/src/core/recall_bench.mjs +275 -0
  67. package/src/core/recall_corpus.mjs +152 -0
  68. package/src/core/recall_facts.mjs +233 -0
  69. package/src/core/recall_intel.mjs +233 -0
  70. package/src/core/recall_lexical.mjs +269 -0
  71. package/src/core/recap.mjs +78 -0
  72. package/src/core/review_queue.mjs +131 -0
  73. package/src/core/review_worker.mjs +284 -0
  74. package/src/core/route.mjs +73 -0
  75. package/src/core/safety.mjs +57 -0
  76. package/src/core/scheduler.mjs +697 -0
  77. package/src/core/search.mjs +54 -0
  78. package/src/core/secret_scan.mjs +143 -0
  79. package/src/core/semantic.mjs +187 -0
  80. package/src/core/source_digest.mjs +56 -0
  81. package/src/core/source_digest_gen.mjs +311 -0
  82. package/src/core/stage.mjs +105 -0
  83. package/src/core/status.mjs +175 -0
  84. package/src/core/vault_state.mjs +115 -0
  85. package/src/core/watch.mjs +282 -0
  86. package/src/core/wiki_log.mjs +29 -0
  87. package/src/core/wrap.mjs +62 -0
  88. package/src/mcp/server.mjs +865 -0
  89. package/templates/starter-vault/README.md +9 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - Expanded the recall markdown corpus to the general area knowledge class (`10_areas/<area>/**`, hubs, area registry), with config-extensible include/exclude (`recall.include`/`recall.exclude`).
6
+ - Added label-based privacy gating (`labels.mjs`): per-file frontmatter `sensitivity`, area baseline from `_area.md`, and boundary-aware path markers exclude private content at index time. Fixes a substring marker that could exclude a whole legitimate folder.
7
+ - Added a routed lexical recall branch (`recall_lexical.mjs`): BM25 + structural/layer/entity/domain/fact-ledger boosts, unioned ahead of exact-token and semantic in hybrid search. Auto-enabled when a search index registry has areas or `--area` is set; off by default on a bare vault.
8
+ - Added `--area <name>` scoping to `recall search`, `semantic-search`, and `hybrid-search`.
9
+ - Added `recall bench` and `recall scorecard` to score external benchmark suites (strict/loose matchers, gate verdict, `--case --explain` traces, Hit@K/R@K/MRR/latency).
10
+ - Added read-only view commands `status`, `digest`, `queue`, and `review-queue`, with matching MCP tools (`neurain_session_status`, `neurain_digest_preview`, `neurain_queue_view`, `neurain_review_queue`). They read vault state formats (session-state, wrap-journal, writeback queue + per-area registry, source-digest manifest) and degrade gracefully when absent. `status` is read-only (no digest ack, no maintenance); `digest` never acks; `review-queue` redacts private item paths; `digest` redacts cross-area references and stays within the session's area.
11
+
12
+ ## 0.1.0-alpha.0
13
+
14
+ - Added installable `neurain` CLI package.
15
+ - Added `init`, `adopt`, `doctor`, `search`, `connect`, and `mcp` alpha commands.
16
+ - Added Codex and Claude Code MCP connection dry-runs.
17
+ - Added stdio MCP server with status, search, capture, and adopt scan tools.
18
+ - Added adoption receipts and rollback.
19
+ - Added public alpha docs for quickstart, safety, privacy, and troubleshooting.
package/LICENSE ADDED
@@ -0,0 +1,57 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" or "Your" shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on or derived from the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
26
+
27
+ 2. Grant of Copyright License.
28
+
29
+ Subject to the terms and conditions of this License, each Contributor grants You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License.
32
+
33
+ Subject to the terms and conditions of this License, each Contributor grants You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
34
+
35
+ 4. Redistribution.
36
+
37
+ You may reproduce and distribute copies of the Work or Derivative Works in any medium, with or without modifications, provided that You meet the conditions of this License, including giving recipients a copy of this License and retaining required notices.
38
+
39
+ 5. Submission of Contributions.
40
+
41
+ Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License.
42
+
43
+ 6. Trademarks.
44
+
45
+ This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work.
46
+
47
+ 7. Disclaimer of Warranty.
48
+
49
+ Unless required by applicable law or agreed to in writing, Licensor provides the Work on an "AS IS" basis, without warranties or conditions of any kind, either express or implied.
50
+
51
+ 8. Limitation of Liability.
52
+
53
+ In no event and under no legal theory shall any Contributor be liable to You for damages arising as a result of this License or out of the use or inability to use the Work.
54
+
55
+ 9. Accepting Warranty or Additional Liability.
56
+
57
+ While redistributing the Work or Derivative Works, You may choose to offer support, warranty, indemnity, or other liability obligations, but only on Your own behalf and on Your sole responsibility.
package/README.md ADDED
@@ -0,0 +1,205 @@
1
+ # Neurain Knowledge OS
2
+
3
+ Neurain Knowledge OS is a local-first knowledge operating layer for AI agents. It helps Codex, Claude Code, Gemini CLI, Agent Runtime, or another AI host work with a user-owned folder without turning that folder into a hidden cloud memory database.
4
+
5
+ Neurain is not an LLM and does not compete with Claude, GPT, Gemini, or local models. It sits underneath agent runtimes as a source-grounded, portable memory and wiki layer.
6
+
7
+ Layer model:
8
+
9
+ - Model layer: Claude, GPT, Gemini, DeepSeek, local models.
10
+ - Agent runtime layer: Codex, Claude Code, Gemini CLI, Agent Runtime, OpenClaw.
11
+ - Knowledge OS layer: Neurain Knowledge OS.
12
+
13
+ Alpha promise:
14
+
15
+ - Bring a folder.
16
+ - Initialize a clean Neurain vault.
17
+ - Scan an existing work folder before any write.
18
+ - Connect Codex, Claude Code, Gemini CLI, or Agent Runtime through MCP.
19
+ - Connect Gemini CLI through MCP with a bounded read-first tool allowlist.
20
+ - Keep source material local and review risky writes.
21
+ - Let sessions improve over time through reviewed lesson candidates.
22
+ - Surface local watch reports for recent files, events, review triggers, and unsafe signal handling.
23
+ - Turn local signals into read-only review worker proposals before any durable improvement is promoted.
24
+ - Run one-shot scheduler ticks that decide whether review should run without starting daemons or writing.
25
+ - Run bounded foreground scheduler monitors that repeat read-only ticks only while the user keeps the command running.
26
+ - Keep a user-started foreground daemon running so review checks repeat while the user works, with only operational state written.
27
+ - Measure background review trigger precision, recall, no-recursion, and private-boundary handling before claiming automation quality.
28
+ - Record host lifecycle boundary events and report session lineage without pretending Neurain owns the host model loop.
29
+ - Evaluate Claude Code, Codex, Runtime, and generic host lifecycle hook payloads for safe event mapping, ignored handling of malformed, unsupported, and missing-session payloads, and non-persistence of prompt bodies, transcript paths, tool output, secrets, and private payloads, without writing to the target root.
30
+ - Manage lesson lifecycle with curator dry-runs, snapshots, rollback, pinned protection, and no deletion.
31
+ - Build an optional local SQLite FTS5 recall cache for faster cross-session search while keeping markdown as canonical truth.
32
+ - Find paraphrased queries with a local lexical-semantic recall layer (stemming, synonyms, fuzzy) that is deterministic, makes no model call, and keeps the embedding provider swappable without LLM lock-in.
33
+ - Use hybrid recall (exact-token union semantic) as the robust default that is never worse than exact-token and adds paraphrase catches on top. For hybrid search, `--top` is the candidate depth for each branch, so the returned union can be longer than `top` when semantic-only catches exist.
34
+ - Measure recall coverage on a real folder's own content with read-only, metrics-only live-eval (no stored content, safe on a private vault) as a first step toward live user evidence.
35
+ - Prepare reviewed live case packs with a redacted E23 scaffold that stores hash-only source refs, no raw source text, and no absolute local paths.
36
+ - Measure cross-session recall with synthetic fixtures and reviewed case files without touching the target root.
37
+ - Measure lesson candidate detection with a read-only precision, recall, false-positive, and unsafe-blocking eval.
38
+ - Keep your knowledge portable across AI hosts instead of locked inside one chat product.
39
+
40
+ ## Quickstart
41
+
42
+ ```bash
43
+ npx neurain onboard ~/NeurainDemo --lang en
44
+ npx neurain init ~/NeurainDemo --lang en
45
+ npx neurain doctor ~/NeurainDemo
46
+ npx neurain connect codex ~/NeurainDemo --dry-run
47
+ npx neurain connect claude ~/NeurainDemo --dry-run
48
+ npx neurain connect gemini ~/NeurainDemo --dry-run
49
+ npx neurain connect runtime ~/NeurainDemo --dry-run
50
+ npx neurain connect codex ~/NeurainDemo --lifecycle-hooks --dry-run
51
+ npx neurain connect claude ~/NeurainDemo --lifecycle-hooks --dry-run
52
+ npx neurain connect runtime ~/NeurainDemo --lifecycle-hooks --dry-run
53
+ ```
54
+
55
+ `onboard` is the non-developer first screen. It is read-only and tells a new user whether to initialize, scan, connect, or preview wrap next.
56
+
57
+ When the Codex, Claude, or Gemini dry-run command looks right, run the same command without `--dry-run`. Gemini uses a bounded MCP tool allowlist. Runtime connector alpha prints a bounded MCP config snippet for an agent host that supports MCP instead of editing host config directly.
58
+
59
+ Lifecycle hook previews are connector-specific. Claude Code prints a `.claude/settings.local.json` style snippet for SessionStart, UserPromptSubmit, Stop, and SessionEnd. Codex prints a `.codex/hooks.json` style snippet for SessionStart plus review_due after Edit or Write PostToolUse. Runtime prints a host-proxy contract for agent loops that can forward direct lifecycle boundary events. All adapters map host payloads into Neurain lifecycle receipts without storing prompt bodies, transcript paths, tool stdout, or tool stderr in model context.
60
+
61
+ ## Self-Improving Workflow
62
+
63
+ Neurain can preview what the next session should learn from recent work. This is the first alpha step toward a host-agnostic self-improving workflow, adapted for a local-first Knowledge OS rather than a single owned agent loop:
64
+
65
+ ```bash
66
+ npx neurain wrap ~/NeurainDemo --dry-run
67
+ npx neurain watch ~/NeurainDemo --poll-once
68
+ npx neurain review ~/NeurainDemo --json
69
+ npx neurain scheduler tick ~/NeurainDemo --json
70
+ npx neurain scheduler monitor ~/NeurainDemo --interval-seconds 60 --max-ticks 3 --json
71
+ npx neurain scheduler eval ~/NeurainDemo --fixture-size 100 --json
72
+ npx neurain scheduler eval ~/NeurainDemo --case-file scheduler-cases.json --min-cases 5 --json
73
+ npx neurain daemon run ~/NeurainDemo --interval-seconds 300 --max-ticks 2 --json
74
+ npx neurain daemon status ~/NeurainDemo --json
75
+ npx neurain lifecycle report ~/NeurainDemo --json
76
+ npx neurain lifecycle eval ~/NeurainDemo --fixture-size 100 --json
77
+ npx neurain lifecycle eval ~/NeurainDemo --case-file lifecycle-cases.json --min-cases 6 --json
78
+ npx neurain connect codex ~/NeurainDemo --lifecycle-hooks --dry-run --json
79
+ npx neurain connect claude ~/NeurainDemo --lifecycle-hooks --dry-run --json
80
+ npx neurain connect gemini ~/NeurainDemo --lifecycle-hooks --dry-run --json
81
+ npx neurain connect runtime ~/NeurainDemo --lifecycle-hooks --dry-run --json
82
+ npx neurain curator status ~/NeurainDemo --json
83
+ npx neurain curator run ~/NeurainDemo --dry-run --json
84
+ npx neurain recall status ~/NeurainDemo --json
85
+ npx neurain recall rebuild ~/NeurainDemo --dry-run --json
86
+ npx neurain recall search ~/NeurainDemo "rollback lesson" --json
87
+ npx neurain recall semantic-search ~/NeurainDemo "fixed the login bug" --json
88
+ npx neurain recall hybrid-search ~/NeurainDemo "fixed the login bug" --json
89
+ npx neurain recall eval ~/NeurainDemo --json
90
+ npx neurain recall eval ~/NeurainDemo --fixture-size 100 --private-probes 20 --json
91
+ npx neurain recall eval ~/NeurainDemo --case-file recall-cases.json --min-cases 1 --json
92
+ npx neurain recall eval ~/NeurainDemo --semantic --fixture-size 60 --min-cases 50 --json
93
+ npx neurain recall live-eval ~/NeurainDemo --sample-size 60 --json
94
+ npx neurain live-cases scaffold ~/NeurainDemo --sample-size 12 --json
95
+ npx neurain live-cases scaffold ~/NeurainDemo --write --confirm "1건 저장 진행" --output output/live-cases/e23-live-case-pack.json --json
96
+ npx neurain answer eval ~/NeurainDemo --fixture-size 120 --json
97
+ npx neurain answer eval ~/NeurainDemo --case-file answer-cases.json --min-cases 5 --json
98
+ npx neurain lessons eval ~/NeurainDemo --fixture-size 100 --json
99
+ npx neurain lessons eval ~/NeurainDemo --case-file lesson-cases.json --min-cases 4 --json
100
+ npx neurain journal list ~/NeurainDemo
101
+ npx neurain lessons candidates ~/NeurainDemo
102
+ npx neurain capabilities "rollback lesson"
103
+ ```
104
+
105
+ Event journal writes are append-only and require explicit confirmation:
106
+
107
+ ```bash
108
+ npx neurain journal add ~/NeurainDemo --type test --summary "npm test passed after setup" --confirm "1건 저장 진행"
109
+ npx neurain journal verify ~/NeurainDemo
110
+ npx neurain lifecycle emit ~/NeurainDemo --host codex --event turn_end --session-id codex-session-1 --turn-id turn-1 --confirm "1건 저장 진행"
111
+ ```
112
+
113
+ Safe lesson candidates can be promoted through CLI only after human review:
114
+
115
+ ```bash
116
+ npx neurain lessons promote ~/NeurainDemo --candidate-id <candidate-id> --confirm "1건 저장 진행"
117
+ npx neurain lessons rollback ~/NeurainDemo --receipt output/receipts/lessons/<receipt>.json
118
+ ```
119
+
120
+ MCP remains preview-only. It does not silently promote durable lessons.
121
+
122
+ ## Development Status
123
+
124
+ The canonical product development snapshot is maintained in:
125
+
126
+ - `docs/development-status.en.md`
127
+ - `docs/development-status.kr.md`
128
+
129
+ As of 2026-06-09 KST, the package is a publish-ready alpha for private beta or alpha user tests. It is not public SaaS GA. The current verified gates are `npm test` 37/37, `node scripts/readiness.mjs --json` score 100, and `npm run readiness -- --json` score 100.
130
+
131
+ Watch reports are also read-only. They do not start a daemon and do not write durable knowledge. They observe recent text files, event journal entries, recap hints, and lesson candidates so a future review worker can decide what deserves attention.
132
+
133
+ Review worker reports are read-only too. They convert watch signals, journal events, and lesson candidates into manual improvement proposals. They do not call a model, start a daemon, promote a lesson, or write durable wiki knowledge.
134
+
135
+ Scheduler ticks are read-only. They inspect watch signals, decide whether a local review fork should run, and include a review worker report only when thresholds are met. They do not install background jobs, start daemons, call models, promote lessons, or write durable wiki knowledge.
136
+
137
+ Scheduler eval is a separate read-only quality gate. `scheduler eval` checks whether background review triggers turn on for meaningful correction, rollback, review, lesson, test, curator, and journal-integrity signals while staying quiet for ordinary notes. It also checks no-recursion on triggered review reports, private boundary handling only on private-marker cases, case-file size limits, temp cleanup, and broad target-root non-write snapshots. Synthetic fixtures use `--fixture-size`; reviewed live cases can be supplied with `--case-file`.
138
+
139
+ Scheduler monitors are bounded foreground runs. They repeat read-only scheduler ticks for a user-specified number of ticks, do not install background jobs, do not run after the command exits, and do not write durable wiki knowledge.
140
+
141
+ Daemon run is a user-started foreground loop. It repeats scheduler ticks until stopped or until `--max-ticks` is reached. Stop requests are checked during the sleep interval with about one-second polling. It writes only `00_system/neurain/daemon-state.json` as operational state, never writes wiki knowledge, never promotes lessons, never calls models, never calls external tools, and is not exposed through MCP.
142
+
143
+ Lifecycle reports are read-only. Lifecycle emits are append-only host boundary receipts for events such as `session_start`, `turn_start`, `turn_end`, `wrap_complete`, `review_due`, `compaction`, and `resume`. Emits require the exact confirmation phrase. MCP exposes `neurain_lifecycle_report` only, not lifecycle emit, so connected hosts can inspect lineage without writing to it through MCP.
144
+
145
+ Lifecycle hook adapters are connector-specific. In alpha, Claude Code gets a dry-run settings preview that can call `neurain lifecycle hook` from Claude Code hooks. Codex gets a `.codex/hooks.json` preview for SessionStart and Edit or Write PostToolUse review markers. Runtime gets a host-proxy contract for runtimes that can forward direct lifecycle events. The adapters record only boundary metadata and operational turn-pairing state, not prompt body text, transcript file paths, tool stdout, tool stderr, or success stdout in model context. They do not expose a lifecycle write tool through MCP. For lower hook latency, install Neurain globally or replace `npx -y neurain` in the preview snippet with your local `neurain` binary path.
146
+
147
+ Curator reports manage lesson lifecycle safely. `curator status` and `curator run --dry-run` are read-only. A real curator run requires the exact confirmation phrase, writes a snapshot receipt, changes only lesson `Status` fields, protects pinned, human-authored, private, and non-agent-created lessons, never deletes lessons, and can be rolled back from the receipt.
148
+
149
+ Recall search is an optional generated cache. `recall status`, `recall search`, `recall verify`, and `recall eval` are read-only. `recall rebuild` writes only `00_system/neurain/recall.sqlite` and a rebuild receipt, and markdown remains the source of truth. If the SQLite file is deleted, Neurain falls back to markdown search and can rebuild the cache later. Private paths, raw source bodies, secret-like content, instruction-injection content, and recall rebuild receipts are excluded from the index. `recall eval` checks whether safe host-tagged events can be found under the right host filter without leaking into the wrong host. `recall eval --fixture-size 100 --private-probes 20` runs a larger synthetic regression suite without touching the target root. `recall eval --case-file recall-cases.json` runs reviewed recall cases supplied by a human reviewer, also without touching the target root. Both modes gate on host filtering, source-supporting snippets, host isolation, and private leakage. They do not count as semantic recall quality benchmarks by themselves.
150
+
151
+ Answer eval is a separate read-only quality gate. `answer eval` checks whether source-grounded answers stay faithful to cited sources, cite sources accurately, surface conflicts, abstain when evidence is missing, respect private boundaries, and prefer current sources over stale ones. Synthetic fixtures use `--fixture-size`; reviewed live cases can be supplied with `--case-file`. It does not call a model, does not write to the target root, and does not replace external user testing.
152
+
153
+ Lessons eval is a separate read-only self-improvement gate. `lessons eval` checks whether Neurain can detect real lesson candidates, avoid ordinary notes as false positives, and block unsafe secret-like or instruction-injection candidates. Synthetic fixtures use `--fixture-size`; reviewed live cases can be supplied with `--case-file`. It does not call a model and does not write to the target root.
154
+
155
+ Live case scaffolding is the E23 storage-safety bridge between real folders and reviewed case files. `live-cases scaffold` samples eligible local markdown, stores only hash-only source refs, and outputs recall, answer, and lesson case templates that a human reviewer must fill locally. It deliberately reports `reviewed_live_user_evidence: false` and `human_judged: false`; it prepares safe evidence handling but does not fabricate external user proof. With `--write`, it requires the exact confirmation phrase and writes only the redacted pack under `output/live-cases/`.
156
+
157
+ For multi-area vaults, preview commands do not scan every area by default. Use `--area <name>` when you want recap or lesson candidates for one specific area.
158
+
159
+ See also:
160
+
161
+ - `docs/knowledge-os.en.md`
162
+ - `docs/self-improve-90-roadmap.en.md`
163
+ - `docs/connect-runtime.en.md`
164
+
165
+ ## Existing Folder Adoption
166
+
167
+ ```bash
168
+ npx neurain adopt ~/Work --dry-run
169
+ ```
170
+
171
+ Neurain scans first and recommends one of three modes:
172
+
173
+ - `in-place`: clean folder, low risk.
174
+ - `hybrid`: source stays in place, Neurain adds adapters.
175
+ - `copy`: risky folder, secrets, symlinks, or private material detected.
176
+
177
+ Writes require an explicit confirmation phrase shown by the scan.
178
+
179
+ ## MCP
180
+
181
+ The alpha MCP server is stdio-only:
182
+
183
+ ```bash
184
+ npx neurain mcp --root ~/NeurainDemo
185
+ ```
186
+
187
+ It exposes read/capture/scan/preview tools only. It does not silently compile, promote lessons, or overwrite durable wiki knowledge. MCP paths are confined to the configured `--root`.
188
+
189
+ ## Status
190
+
191
+ This is `0.1.0-alpha.0`. It is not a public SaaS GA release. The alpha exists to prove installability, local-first onboarding, Codex, Claude, Gemini, and Runtime connectivity, plus safety receipts.
192
+
193
+ Alpha publish command:
194
+
195
+ ```bash
196
+ npm publish --tag alpha
197
+ ```
198
+
199
+ ## Release Readiness Check
200
+
201
+ ```bash
202
+ npm run readiness
203
+ ```
204
+
205
+ This runs tests, packaging checks, audit, tarball install smoke, host connect dry-runs, and a product leakage scan.
package/SECURITY.md ADDED
@@ -0,0 +1,22 @@
1
+ # Security
2
+
3
+ Neurain alpha is local-first. The package does not include a hosted knowledge store.
4
+
5
+ ## Reporting
6
+
7
+ Report security issues privately before opening a public issue. Until the public GitHub organization is live, use the maintainer contact listed in the release notes.
8
+
9
+ ## Data Boundary
10
+
11
+ - Neurain writes local files inside the folder you choose.
12
+ - MCP tools expose status, search, append-only capture, adoption scan, lesson preview, recap, and capability preview.
13
+ - MCP alpha does not expose silent durable wiki writes or silent lesson promotion.
14
+ - Secret-like capture input is refused.
15
+ - The alpha has no web admin page. Any future admin surface must require authentication before showing controls or sensitive state.
16
+ - Do not place API keys, recovery codes, private keys, or passwords in source files or docs.
17
+
18
+ ## Supported Versions
19
+
20
+ | Version | Supported |
21
+ |---|---|
22
+ | 0.1.x alpha | Security fixes only |
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { runCli } from '../src/cli.mjs';
3
+
4
+ runCli(process.argv.slice(2)).catch((error) => {
5
+ process.stderr.write(`${error.message || error}\n`);
6
+ process.exit(1);
7
+ });
@@ -0,0 +1,22 @@
1
+ # Neurain And Mem0
2
+
3
+ Mem0 is a production memory infrastructure for AI agents and apps. Neurain is a local-first AI Knowledge OS.
4
+
5
+ ## What Neurain Learns From Mem0
6
+
7
+ - one-line install
8
+ - agent-friendly setup
9
+ - MCP as the universal connector
10
+ - clear pricing and trust surface
11
+ - proof through benchmarks and docs
12
+
13
+ ## Where Neurain Is Different
14
+
15
+ - Markdown remains the source of truth.
16
+ - The user's folder is not replaced by a hidden memory database.
17
+ - Durable knowledge writes are review-gated.
18
+ - The product is designed for source-grounded wiki maintenance, not only memory retrieval.
19
+
20
+ ## Product Implication
21
+
22
+ Neurain should copy Mem0's low-friction product surface, not its storage model.
@@ -0,0 +1,48 @@
1
+ # Connect Claude Code
2
+
3
+ Preview:
4
+
5
+ ```bash
6
+ npx neurain connect claude ~/NeurainDemo --dry-run
7
+ ```
8
+
9
+ Apply:
10
+
11
+ ```bash
12
+ npx neurain connect claude ~/NeurainDemo
13
+ ```
14
+
15
+ The command uses Claude Code's official MCP CLI:
16
+
17
+ ```bash
18
+ claude mcp add --scope local -e NEURAIN_ROOT=<folder> neurain -- npx -y neurain mcp --root <folder>
19
+ ```
20
+
21
+ Use `--scope user` or `--scope project` when you want a wider or project-specific configuration.
22
+
23
+ ## Lifecycle Hook Preview
24
+
25
+ Claude Code has command hooks for session and turn boundaries. Neurain can preview a lifecycle hook setup:
26
+
27
+ ```bash
28
+ npx neurain connect claude ~/NeurainDemo --lifecycle-hooks --dry-run
29
+ ```
30
+
31
+ The preview prints a `.claude/settings.local.json` style snippet for:
32
+
33
+ - `SessionStart`
34
+ - `UserPromptSubmit`
35
+ - `Stop`
36
+ - `SessionEnd`
37
+
38
+ When those hooks call `neurain lifecycle hook`, Neurain maps Claude Code hook payloads into lifecycle events such as `session_start`, `turn_start`, `turn_end`, `resume`, `compaction`, and `session_end`.
39
+
40
+ Safety boundary:
41
+
42
+ - The connect command does not edit Claude settings in lifecycle hook alpha.
43
+ - The hook adapter stores no prompt body text.
44
+ - The hook adapter stores no transcript path.
45
+ - The hook adapter runs with `--quiet`, so successful SessionStart and UserPromptSubmit hooks do not inject status text into Claude's model context.
46
+ - The hook adapter writes append-only lifecycle receipts only when the user has copied a command containing the exact confirmation phrase.
47
+ - MCP can report lifecycle lineage, but cannot emit lifecycle events.
48
+ - For lower hook latency, install Neurain globally or replace `npx -y neurain` in the preview snippet with your local `neurain` binary path.
@@ -0,0 +1,51 @@
1
+ # Claude Code 연결
2
+
3
+ Claude Code는 MCP를 통해 Neurain을 local-first Knowledge OS로 사용할 수 있습니다.
4
+
5
+ MCP setup을 preview합니다.
6
+
7
+ ```bash
8
+ npx neurain connect claude ~/NeurainDemo --dry-run
9
+ ```
10
+
11
+ MCP setup을 적용합니다.
12
+
13
+ ```bash
14
+ npx neurain connect claude ~/NeurainDemo
15
+ ```
16
+
17
+ 이 명령은 Claude Code의 공식 MCP CLI를 사용합니다.
18
+
19
+ ```bash
20
+ claude mcp add --scope local -e NEURAIN_ROOT=<folder> neurain -- npx -y neurain mcp --root <folder>
21
+ ```
22
+
23
+ 더 넓은 범위나 project-specific 설정이 필요하면 `--scope user` 또는 `--scope project`를 사용합니다.
24
+
25
+ ## Lifecycle Hook Preview
26
+
27
+ Claude Code는 session과 turn boundary용 command hook을 제공합니다. Neurain은 lifecycle hook setup을 preview할 수 있습니다.
28
+
29
+ ```bash
30
+ npx neurain connect claude ~/NeurainDemo --lifecycle-hooks --dry-run
31
+ ```
32
+
33
+ Preview는 아래 hook을 위한 `.claude/settings.local.json` style snippet을 출력합니다.
34
+
35
+ - `SessionStart`
36
+ - `UserPromptSubmit`
37
+ - `Stop`
38
+ - `SessionEnd`
39
+
40
+ 이 hook들이 `neurain lifecycle hook`을 호출하면 Neurain은 Claude Code hook payload를 `session_start`, `turn_start`, `turn_end`, `resume`, `compaction`, `session_end` 같은 lifecycle event로 매핑합니다.
41
+
42
+ Safety boundary:
43
+
44
+ - Lifecycle hook alpha에서 connect command는 Claude settings를 직접 수정하지 않습니다.
45
+ - Hook adapter는 prompt body text를 저장하지 않습니다.
46
+ - Hook adapter는 transcript path를 저장하지 않습니다.
47
+ - Hook adapter는 custom instruction을 저장하지 않습니다.
48
+ - Hook adapter는 `--quiet`으로 실행되므로 성공한 SessionStart와 UserPromptSubmit hook이 Claude model context에 status text를 주입하지 않습니다.
49
+ - Hook adapter는 사용자가 정확한 확인 문구가 포함된 command를 직접 복사했을 때만 append-only lifecycle receipt를 씁니다.
50
+ - MCP는 lifecycle lineage를 report할 수 있지만 lifecycle event를 emit할 수 없습니다.
51
+ - Hook latency를 낮추려면 Neurain을 global install하거나 preview snippet의 `npx -y neurain`을 local `neurain` binary path로 바꿉니다.
@@ -0,0 +1,38 @@
1
+ # Connect Codex
2
+
3
+ Preview:
4
+
5
+ ```bash
6
+ npx neurain connect codex ~/NeurainDemo --dry-run
7
+ ```
8
+
9
+ Apply:
10
+
11
+ ```bash
12
+ npx neurain connect codex ~/NeurainDemo
13
+ ```
14
+
15
+ The command uses Codex's official MCP CLI:
16
+
17
+ ```bash
18
+ codex mcp add neurain --env NEURAIN_ROOT=<folder> -- npx -y neurain mcp --root <folder>
19
+ ```
20
+
21
+ Neurain does not manually edit Codex config files in alpha.
22
+
23
+ ## Lifecycle Boundary
24
+
25
+ Codex MCP connection is supported in alpha. Neurain can also preview a `.codex/hooks.json` lifecycle setup:
26
+
27
+ Preview the lifecycle hook setup:
28
+
29
+ ```bash
30
+ npx neurain connect codex ~/NeurainDemo --lifecycle-hooks --dry-run
31
+ ```
32
+
33
+ The preview does not edit Codex config. It prints a hook snippet that maps:
34
+
35
+ - `SessionStart` to `session_start`
36
+ - `PostToolUse` after `Edit|Write` to `review_due`
37
+
38
+ The hook calls `neurain lifecycle hook` with the exact confirmation phrase. Neurain stores only lifecycle metadata, not prompt bodies, transcript paths, tool stdout, or tool stderr. Codex can also read `neurain_lifecycle_report` through MCP, but MCP cannot emit lifecycle events.
@@ -0,0 +1,40 @@
1
+ # Codex 연결
2
+
3
+ Codex는 MCP를 통해 Neurain을 local-first Knowledge OS로 사용할 수 있습니다.
4
+
5
+ MCP setup을 preview합니다.
6
+
7
+ ```bash
8
+ npx neurain connect codex ~/NeurainDemo --dry-run
9
+ ```
10
+
11
+ MCP setup을 적용합니다.
12
+
13
+ ```bash
14
+ npx neurain connect codex ~/NeurainDemo
15
+ ```
16
+
17
+ 이 명령은 Codex의 공식 MCP CLI를 사용합니다.
18
+
19
+ ```bash
20
+ codex mcp add neurain --env NEURAIN_ROOT=<folder> -- npx -y neurain mcp --root <folder>
21
+ ```
22
+
23
+ Alpha에서 Neurain은 Codex config file을 직접 수정하지 않습니다.
24
+
25
+ ## Lifecycle Boundary
26
+
27
+ Codex MCP connection은 alpha에서 지원됩니다. Neurain은 `.codex/hooks.json` lifecycle setup도 preview할 수 있습니다.
28
+
29
+ Lifecycle hook setup을 preview합니다.
30
+
31
+ ```bash
32
+ npx neurain connect codex ~/NeurainDemo --lifecycle-hooks --dry-run
33
+ ```
34
+
35
+ Preview는 Codex config를 직접 수정하지 않습니다. 대신 아래 boundary를 매핑하는 hook snippet을 출력합니다.
36
+
37
+ - `SessionStart` -> `session_start`
38
+ - `Edit|Write` 뒤의 `PostToolUse` -> `review_due`
39
+
40
+ Hook은 정확한 confirmation phrase가 포함된 `neurain lifecycle hook`을 호출합니다. Neurain은 lifecycle metadata만 저장하고 prompt body, transcript path, tool stdout, tool stderr는 저장하지 않습니다. Codex는 MCP를 통해 `neurain_lifecycle_report`를 읽을 수 있지만, MCP로 lifecycle event를 emit할 수는 없습니다.
@@ -0,0 +1,71 @@
1
+ # Connect Gemini CLI
2
+
3
+ Version: v0.1
4
+
5
+ Gemini CLI can connect to Neurain through MCP. Neurain uses a bounded tool allowlist so Gemini can read status, search, recall, eval, and preview reports without receiving silent durable-write tools.
6
+
7
+ ## Preview
8
+
9
+ ```bash
10
+ npx neurain connect gemini ~/NeurainDemo --dry-run
11
+ ```
12
+
13
+ The dry-run prints the exact `gemini mcp add` command. It does not change Gemini settings.
14
+
15
+ ## Apply
16
+
17
+ After reviewing the dry-run output, run the same command without `--dry-run`:
18
+
19
+ ```bash
20
+ npx neurain connect gemini ~/NeurainDemo
21
+ ```
22
+
23
+ By default this uses project scope. You can choose scope explicitly:
24
+
25
+ ```bash
26
+ npx neurain connect gemini ~/NeurainDemo --scope user
27
+ npx neurain connect gemini ~/NeurainDemo --scope project
28
+ ```
29
+
30
+ ## Manual Settings Fallback
31
+
32
+ Gemini CLI also supports `mcpServers` in `settings.json`. Use this shape if you prefer manual config:
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "neurain": {
38
+ "command": "npx",
39
+ "args": ["-y", "neurain", "mcp", "--root", "/path/to/NeurainDemo"],
40
+ "env": {
41
+ "NEURAIN_ROOT": "/path/to/NeurainDemo"
42
+ },
43
+ "trust": false,
44
+ "includeTools": [
45
+ "neurain_status",
46
+ "neurain_search",
47
+ "neurain_adopt_scan",
48
+ "neurain_recall_hybrid_search",
49
+ "neurain_answer_quality_eval",
50
+ "neurain_live_cases_scaffold",
51
+ "neurain_wrap_preview"
52
+ ]
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## Lifecycle Boundary
59
+
60
+ Gemini MCP connection is supported. Native Gemini lifecycle hook automation is manual-only in this alpha, so use explicit lifecycle commands if you need boundary receipts:
61
+
62
+ ```bash
63
+ npx neurain lifecycle emit ~/NeurainDemo --host gemini --event turn_end --session-id gemini-session-1 --turn-id turn-1 --confirm "1건 저장 진행"
64
+ ```
65
+
66
+ ## Safety
67
+
68
+ - MCP can preview and evaluate.
69
+ - MCP cannot silently promote lessons or write durable wiki knowledge.
70
+ - The Gemini allowlist omits raw capture by default.
71
+ - Redacted live-case scaffolds return hash-only source refs and no raw source text.