granite-mem 0.1.8 → 0.1.11

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) 2026 The Vibe Company
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,289 +1,247 @@
1
1
  # Granite
2
2
 
3
- > A local-first markdown memory system for humans and agents.
4
-
5
- Granite is a simple PKM tool built around plain Markdown files, a small set of opinionated note types, and a fast loop for turning raw notes into useful memory.
6
-
7
- Most PKM tools give you a blank canvas. Granite gives you a working system:
8
-
9
- - capture quickly
10
- - structure ideas without over-designing your workflow
11
- - keep sources, durable notes, syntheses, and outputs connected
12
- - surface what to connect or write next
13
- - stay fully local, scriptable, and agent-friendly
14
-
15
- If you want a flexible framework, there are already many options. Granite is for people who want plain files, strong defaults, and a memory system that starts helping immediately.
16
-
17
- ![Granite note view](docs/screenshots/granite-note.png)
18
-
19
- ## Why Granite
20
-
21
- Granite is built around a simple loop:
22
-
23
- `capture -> link -> recommend -> resurface`
24
-
25
- That means:
26
-
27
- - your notes live as plain Markdown files with YAML frontmatter
28
- - the index is derived state, not the source of truth
29
- - the default note types create just enough structure to stay useful
30
- - custom note types are easy to add in `granite.yml`
31
- - the CLI is predictable for both humans and agents
32
- - the local web UI makes the vault browseable without adding cloud lock-in
33
-
34
- Granite is opinionated where it matters and flexible where it should be.
35
-
36
- ## What Makes It Different
37
-
38
- ### 1. Simple by default
39
-
40
- Granite ships with a small working model instead of an empty workspace:
41
-
42
- - `note` for durable ideas
43
- - `source` for imported or observed source material
44
- - `synthesis` for durable compiled knowledge
45
- - `output` for audience-specific deliverables
46
-
47
- `note -> synthesis -> output`
48
-
49
- This is enough structure to make your notes connect naturally, without forcing you into a heavyweight system.
50
-
51
- ### 2. Custom types without losing the plot
52
-
53
- You can add your own note types in `granite.yml`, but Granite still works out of the box. The product stays simple because the core model is small and every type shares the same mechanics: folder, template, line limit, guidance, and slug strategy.
54
-
55
- ### 3. Agent-native, not just agent-compatible
56
-
57
- Granite is designed to be easy for agents to read and act on:
58
-
59
- - notes are plain files
60
- - metadata is explicit
61
- - commands support `--json`
62
- - Granite ships with an MCP server
63
- - vault structure is predictable
64
- - search, backlinks, and recommendations are available from the CLI
65
-
66
- It works well as a personal system, and it also works as a memory layer for coding agents, assistants, or local automation.
67
-
68
- ## Quickstart
69
-
70
- Clone the repo and install dependencies:
71
-
72
- ```bash
73
- git clone https://github.com/The-Vibe-Company/Granite
74
- cd Granite
75
- npm install
76
- npm run build
77
- npm link
78
- ```
79
-
80
- Create the default vault in `~/.granite` and start capturing:
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/granite-mem"><img src="https://img.shields.io/npm/v/granite-mem?color=111111" alt="npm version"></a>
5
+ <a href="https://www.npmjs.com/package/granite-mem"><img src="https://img.shields.io/npm/dm/granite-mem?color=111111" alt="npm downloads"></a>
6
+ <a href="https://github.com/The-Vibe-Company/Granite/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/The-Vibe-Company/Granite/ci.yml?branch=main&label=tests&color=111111" alt="CI status"></a>
7
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/The-Vibe-Company/Granite?color=111111" alt="MIT license"></a>
8
+ <a href="https://github.com/The-Vibe-Company/Granite/stargazers"><img src="https://img.shields.io/github/stars/The-Vibe-Company/Granite?style=social" alt="GitHub stars"></a>
9
+ </p>
10
+
11
+ > **The personal OS your agent runs on.**
12
+ > Markdown files. One SQLite index. A typed contract your agent already knows how to operate.
13
+
14
+ <p align="center">
15
+ <img src="docs/screenshots/granite-graph.png" alt="Granite constellation graph" width="720">
16
+ </p>
17
+
18
+ <p align="center">
19
+ <b>Install it with your agent.</b> Or run it standalone as a local markdown knowledge graph.
20
+ </p>
21
+
22
+ ---
23
+
24
+ ## The wow moment
25
+
26
+ Paste this into **Claude Code**, **Cursor**, or any MCP-capable agent:
27
+
28
+ ````
29
+ Install Granite as my personal OS.
30
+
31
+ 1. `npm install -g granite-mem`
32
+ 2. `granite init --template founder-os` (vault at ~/.granite)
33
+ 3. `claude mcp add granite -- granite mcp --vault ~/.granite`
34
+ 4. Restart yourself so the MCP server loads.
35
+ 5. Call `granite_wakeup`, then propose three notes you would write
36
+ first based on what you know about me so far. Capture them as
37
+ drafts with --source agent.
38
+ ````
39
+
40
+ Sixty seconds later you have a live vault, a connected agent that **knows how to use it**, and three starter notes in `~/.granite/notes/`. No system prompt. No config. No cloud.
41
+
42
+ That's the thesis of this project.
43
+
44
+ ## See it
45
+
46
+ <table>
47
+ <tr>
48
+ <td width="50%">
49
+ <img src="docs/screenshots/granite-graph.png" alt="Granite constellation graph">
50
+ <br>
51
+ <sub><b>Constellation graph.</b> Browse the vault as communities, hubs, and links.</sub>
52
+ </td>
53
+ <td width="50%">
54
+ <img src="docs/screenshots/granite-search.png" alt="Granite command palette search">
55
+ <br>
56
+ <sub><b>Command palette.</b> Search the vault and jump straight into the graph context.</sub>
57
+ </td>
58
+ </tr>
59
+ <tr>
60
+ <td width="50%">
61
+ <img src="docs/screenshots/granite-preview.png" alt="Granite note preview">
62
+ <br>
63
+ <sub><b>Graph-aware reading.</b> Preview notes without losing the surrounding context.</sub>
64
+ </td>
65
+ <td width="50%">
66
+ <img src="docs/screenshots/granite-note.png" alt="Granite reader view">
67
+ <br>
68
+ <sub><b>Floating reader.</b> Open a note without leaving the constellation.</sub>
69
+ </td>
70
+ </tr>
71
+ </table>
72
+
73
+ ## What is Granite?
74
+
75
+ A local-first markdown store with an opinionated flow. **No AI inside** — just plain files on disk, indexed by SQLite, queried deterministically.
76
+
77
+ - **Imposed flow.** Capture, compile, query, output, lint. The shape is fixed; the content is yours.
78
+ - **Four default note types** — `note`, `source`, `synthesis`, `output`. Add your own in `granite.yml` when your life grows a new shape.
79
+ - **A specialized MCP** that teaches your agent how to use the vault. Drop any MCP-capable agent on it and it knows how to operate, no system prompt required.
80
+
81
+ Your agent brings the intelligence. Granite holds the ground truth.
82
+
83
+ ## Try it standalone
81
84
 
82
85
  ```bash
86
+ npm install -g granite-mem
83
87
  granite init
84
- granite add "Talked to Alice about local-first sync tradeoffs"
85
- granite new "Local-first sync tradeoffs" --type note
86
- granite list
87
- granite search "sync"
88
- ```
89
-
90
- Start one long-running interface when you need it:
91
-
92
- ```bash
93
- granite serve # local web UI
94
- granite mcp # MCP server for agent clients
95
- ```
96
-
97
- `granite new` does more than create a file. It can immediately suggest related links, tags, and the next note to create, which is the core of Granite's value loop.
98
-
99
- ## Example Workflow
100
-
101
- Capture something quickly:
102
-
103
- ```bash
104
- granite add "Users want fewer note types, but stronger defaults."
105
- ```
106
-
107
- Turn it into a durable note:
108
-
109
- ```bash
110
- granite new "Strong defaults beat infinite flexibility" --type note
88
+ granite serve
111
89
  ```
112
90
 
113
- Find connections:
91
+ That starts with the default knowledge model: `note`, `source`, `synthesis`, and `output`. Add `--template founder-os` when you want people, organizations, meetings, and learnings wired in from the start.
114
92
 
115
- ```bash
116
- granite suggest-links strong-defaults-beat-infinite-flexibility
117
- granite recommend strong-defaults-beat-infinite-flexibility
118
- granite backlinks strong-defaults-beat-infinite-flexibility
119
- ```
93
+ ## Agent-native MCP
120
94
 
121
- Open the local UI:
95
+ > "A thin MCP server exposes capabilities. A strong MCP server shapes behavior."
122
96
 
123
- ```bash
124
- granite serve
125
- ```
97
+ Granite's MCP surface is intention-first:
126
98
 
127
- Then browse notes, search the vault, inspect backlinks, and explore the graph locally.
99
+ - `granite_wakeup` to orient
100
+ - `granite_research_topic` to inspect existing knowledge before writing
101
+ - `granite_query` for structured filters over typed notes
102
+ - `granite_compile_context` to assemble a graph-aware brief
103
+ - `granite_plan_garden` to decide what to improve next
104
+ - `granite_capture_knowledge` to write with protocol fields and type contracts
128
105
 
129
- ![Granite graph view](docs/screenshots/granite-graph.png)
106
+ The point is not to give an agent a file browser. The point is to give it a workflow it can follow.
130
107
 
131
- ## Custom Note Types
108
+ ## Types as active contracts
132
109
 
133
- Granite is intentionally small, but not rigid. Add a type in `granite.yml` when your workflow genuinely needs it:
110
+ This is what makes the agent feel native rather than bolted-on.
134
111
 
135
112
  ```yaml
113
+ # granite.yml — every note type is an executable contract
136
114
  note_types:
137
- idea:
138
- folder: notes/ideas
139
- description: Early product ideas worth pressure-testing
140
- template: |
141
- ## Problem
142
-
143
- ## Insight
115
+ meeting:
116
+ folder: notes/meetings
117
+ fields:
118
+ date: { type: date, required: true }
119
+ organization: { type: wikilink, target_types: [organization] }
120
+ attendees: { type: wikilink, target_types: [person] }
121
+ on_create:
122
+ - { action: set_default, field: date, value: "${today}" }
123
+ - { action: resolve_wikilinks, fields: [organization, attendees], auto_stub: true }
124
+ indexed_fields: [date, organization]
125
+ lifecycle:
126
+ states: [active, archived]
127
+ transitions:
128
+ - { from: active, to: archived, trigger: stale_days, days: 180 }
129
+ ```
130
+
131
+ - `set_default` — fills `${today}` automatically
132
+ - `resolve_wikilinks + auto_stub` — turns `organization: Acme Corp` into the slug `acme-corp`, creating the org note if missing (with a globally-unique slug so nothing gets silently overwritten)
133
+ - `indexed_fields` — makes `granite_query { type: meeting, where: { date: { gte: "2026-01-01" } } }` O(1) and deterministic
134
+ - `lifecycle` — `granite doctor` surfaces stale notes so gardening never drifts
135
+
136
+ Add a type when your life has a new shape. The core stays small. For the formal protocol, see [docs/GRANITE_OBJECT_STANDARD.md](docs/GRANITE_OBJECT_STANDARD.md).
137
+
138
+ ## Templates
144
139
 
145
- ## Why now
146
-
147
- ## Next step
148
- line_limit: 120
149
- warn_only: true
150
- slug_format: title
151
- instructions: Capture the idea clearly, then link it to a source, note, or synthesis.
140
+ ```bash
141
+ granite init # minimal: note / source / synthesis / output
142
+ granite init --template founder-os # + person / organization / meeting / learning
152
143
  ```
153
144
 
154
- The point is not to create 30 note types. The point is to add a type only when it makes your memory system sharper.
145
+ `founder-os` is the full personal-OS starter: people you talk to, orgs you work with, meetings you had, things you learned. Eight types, already wired with hooks, indexed fields, and lifecycles. Open `templates/founder-os.yml` — it's 150 lines of pure YAML.
155
146
 
156
- ## Protocol Fields
147
+ ## The hard boundary
157
148
 
158
- Granite keeps the core schema small, but now includes a few shared fields that help both humans and agents work safely in the same vault:
149
+ Granite will **never**:
159
150
 
160
- - `status`: `inbox | active | archived`
161
- - `source`: `human | agent | extraction`
162
- - `review_state`: `draft | reviewed | locked`
163
- - `durability`: `canonical | working | ephemeral`
164
- - `derived_from`: list of note IDs or slugs used as provenance
151
+ - embed an LLM, run prompts, or hold an API key
152
+ - compute embeddings or ship a vector store
153
+ - run background agents or a scheduler
154
+ - add overlapping CLI/MCP endpoints that blur the loop
165
155
 
166
- These fields are intentionally lightweight:
156
+ This is why your agent can be trusted with write access. The vault is a **deterministic substrate**. The intelligence is yours (or Claude's, or GPT's, or whoever you pay this quarter).
167
157
 
168
- - `review_state` is the editorial state
169
- - `durability` distinguishes durable knowledge from working material or situational outputs
170
- - `derived_from` is the minimal provenance hook for syntheses and outputs
158
+ ## Protocol fields
171
159
 
172
- Granite does not impose a full agent workflow in the core. Richer conventions such as agent traces or synthesis policies are better handled in templates, skills, and team protocol.
160
+ Every note carries five shared fields so humans and agents share ground truth:
173
161
 
174
- ## Local-First Architecture
162
+ | Field | Values | Purpose |
163
+ |----------------|---------------------------------------|--------------------------------------|
164
+ | `status` | `inbox` · `active` · `archived` | operational state |
165
+ | `source` | `human` · `agent` · `extraction` | who wrote it |
166
+ | `review_state` | `draft` · `reviewed` · `locked` | editorial state |
167
+ | `durability` | `canonical` · `working` · `ephemeral` | keep / may drift / throwaway |
168
+ | `derived_from` | `[slug, …]` | provenance for syntheses and outputs |
175
169
 
176
- Granite keeps the source of truth boring and durable:
170
+ Your agent reads these before writing and sets them as it works. You inherit a fully auditable trail.
177
171
 
178
- - notes are Markdown files
179
- - metadata lives in YAML frontmatter
180
- - the default vault lives in `~/.granite`
181
- - vault configuration lives in `~/.granite/granite.yml`
182
- - full-text search and link resolution are backed by a local SQLite index in `~/.granite/index.db`
183
- - the index can be rebuilt from the files at any time
172
+ ## Local-first, by design
184
173
 
185
- This keeps the system transparent, portable, and inspectable.
174
+ - Markdown files are the source of truth; the SQLite index in `~/.granite/index.db` is derived state and can be rebuilt at any time
175
+ - no cloud, no telemetry, no account
176
+ - `git init` your vault and you have versioning for free
177
+ - `granite serve` gives you a local web UI — browse, search, explore the graph
178
+ - `granite daemon start` runs MCP + web UI in one background process
186
179
 
187
- ## Agent-Friendly CLI
180
+ ## Direct sync
188
181
 
189
- Many commands support JSON output:
182
+ Granite sync is direct machine-to-machine. Run it over LAN, Tailscale, or a private DNS name; there is no relay, hosted worker, billing tier, or cloud authority.
190
183
 
191
184
  ```bash
192
- granite new "Sync constraints" --type note --review-state reviewed --durability canonical --json
193
- granite list --json
194
- granite show sync-constraints --json
195
- granite search "constraints" --json
196
- granite backlinks sync-constraints --json
197
- granite recommend sync-constraints --json
198
- ```
199
-
200
- That makes Granite a useful substrate for local workflows, scripts, and agent memory.
185
+ # Machine A
186
+ granite sync access grant ipad --role read
187
+ granite sync access grant desktop --role write
188
+ granite sync serve --host 0.0.0.0 --port 8765
201
189
 
202
- ## MCP Server
190
+ # Read-only Machine B
191
+ granite sync remote add macbook http://100.x.y.z:8765 --token <read-token>
192
+ granite sync pull macbook
193
+ granite sync watch macbook --direction pull --interval 30
203
194
 
204
- Granite ships with an MCP server so LLM clients can control the vault directly through tools, resources, and prompts.
205
-
206
- Start it over stdio for local MCP clients:
207
-
208
- ```bash
209
- granite mcp --vault /path/to/vault
195
+ # Write-capable Machine C
196
+ granite sync remote add macbook http://100.x.y.z:8765 --token <write-token>
197
+ granite sync run macbook
198
+ granite sync watch macbook --interval 30
210
199
  ```
211
200
 
212
- Start it over Streamable HTTP:
201
+ Conflicts default to manual preservation with `.conflict.<device>.<timestamp>.md` files. For a personal multi-device setup, pick the device that wins conflicts:
213
202
 
214
203
  ```bash
215
- granite mcp --transport http --host 127.0.0.1 --port 3321
204
+ granite sync config --policy primary-wins --primary-this-device
216
205
  ```
217
206
 
218
- The server exposes:
219
-
220
- - tools for vault overview, list/get/search, create/update, backlinks, link suggestions, recommendations, and doctor
221
- - resources for `granite.yml`, vault overview, note types, and individual notes via `granite://notes/{slug}`
222
- - prompts for refining notes and reviewing links/next steps
223
-
224
- The note payloads exposed through MCP include the shared protocol fields (`status`, `source`, `review_state`, `durability`, `derived_from`) so clients can make safer decisions without Granite embedding any model-specific logic.
207
+ MCP is scoped to one vault per server. Launch a read-only MCP server when an agent should inspect a synced vault without mutating it:
225
208
 
226
- Example stdio client configuration:
227
-
228
- ```json
229
- {
230
- "command": "granite",
231
- "args": ["mcp", "--vault", "/path/to/vault"]
232
- }
209
+ ```bash
210
+ granite mcp --vault ~/.granite --role read
211
+ granite mcp --vault ~/.granite --role write
233
212
  ```
234
213
 
235
- ## Commands
214
+ For the full CLI, run `granite --help`. For development, see [CLAUDE.md](CLAUDE.md).
236
215
 
237
- ```bash
238
- granite init
239
- granite new <title> [--type <type>] [--source <source>] [--status <status>] [--review-state <state>] [--durability <durability>] [--derived-from <refs>] [--json]
240
- granite add [text] [--json]
241
- granite list [--type <type>] [--json]
242
- granite edit <slug> [--body <text>] [--append <text>] [--title <title>] [--tag <tags>] [--alias <aliases>] [--status <status>] [--source <source>] [--review-state <state>] [--durability <durability>] [--derived-from <refs>]
243
- granite open <slug>
244
- granite show <slug> [--json] [--body]
245
- granite search <query> [--json]
246
- granite backlinks <slug> [--json]
247
- granite suggest-links <slug> [--json]
248
- granite recommend <slug> [--json]
249
- granite types
250
- granite doctor
251
- granite serve [-p <port>]
252
- granite mcp [--vault <path>] [--transport <stdio|http>]
253
- ```
216
+ ## Roadmap & status
254
217
 
255
- ## Development
218
+ Granite is pre-1.0. The current release is **v0.1.9**, with the major agent-native loop pieces now in place: typed contracts, wakeup snapshots, deterministic garden planning, document import, daemon mode, and the constellation graph.
256
219
 
257
- ```bash
258
- npm run build
259
- npm run dev
260
- npm run test
261
- npm run test:watch
262
- npm run lint
263
- ```
220
+ Read [CHANGELOG.md](CHANGELOG.md) for release history. The product boundary stays fixed: Granite stores and indexes local knowledge; agents bring the intelligence.
264
221
 
265
- Run a single test file:
222
+ ## Contributing
266
223
 
267
- ```bash
268
- npx vitest run test/core/note.test.ts
269
- ```
224
+ Issues and focused PRs are welcome.
270
225
 
271
- Run the CLI without building:
226
+ For local development, read [CLAUDE.md](CLAUDE.md). The key product rule is simple: no embedded LLM, no vector store, no autonomous scheduler inside Granite.
272
227
 
273
- ```bash
274
- npx tsx src/index.ts <command>
275
- ```
228
+ > Karpathy wrote that there was room for "an incredible new product instead of a hacky collection of scripts" around LLM knowledge bases.
229
+ >
230
+ > Granite is the product that answers that call.
231
+ >
232
+ > — [@karpathy on LLM knowledge bases](https://x.com/karpathy/status/2039805659525644595)
276
233
 
277
234
  ## Philosophy
278
235
 
279
- Granite is built on a few beliefs:
280
-
281
236
  - local-first beats cloud dependence for personal memory
282
- - plain Markdown beats proprietary formats
283
- - strong defaults beat blank canvases
284
- - relationships between notes matter more than visual chrome
285
- - a good PKM should help you decide what to connect or write next
237
+ - plain markdown beats proprietary formats
238
+ - **types as active contracts** beat types as folders
286
239
  - tools for humans should also be legible to agents
287
- - protocol belongs in the core, agent policy belongs outside it
240
+ - protocol belongs in the core; **agent policy belongs outside it**
241
+ - a personal OS is a thing you own — not a thing you rent
242
+
243
+ ---
288
244
 
289
- If that sounds right, Granite is the tool.
245
+ <p align="center">
246
+ <sub>Ship your agent a home. Then give it the keys.</sub>
247
+ </p>