aaak-vault-sync 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,294 @@
1
+ # aaak-vault-sync
2
+
3
+ Sync your Obsidian vault to AAAK format for LLM memory loading. Converts markdown files into compact symbolic summaries that any LLM can scan to load relevant context from your vault.
4
+
5
+ AAAK encoding is provided by [`dialect.py`](https://github.com/milla-jovovich/mempalace/blob/main/mempalace/dialect.py) from the [mempalace](https://github.com/milla-jovovich/mempalace) project.
6
+
7
+ ## How it works
8
+
9
+ 1. `aaak-scan` walks your Obsidian vault and converts each `.md` file to AAAK format using `dialect.py` — a lossy summarization that extracts entities, topics, key sentences, emotions, and flags into a token-efficient representation
10
+ 2. Output files are written to `$VAULT/aaak/` alongside a human/LLM-readable index (`aaak_index.md`)
11
+ 3. A generic prompt template can be used with any LLM to check the index and follow relevant entries to their AAAK summaries (or the original markdown if needed)
12
+ 4. An optional Claude integration can install a skill and CLAUDE.md rule
13
+ 5. A launchd agent (macOS) keeps the index updated hourly in the background
14
+
15
+ **AAAK is lossy** — it summarizes, not compresses. The original files are always preserved. AAAK files point back to their source via a `SOURCE:` header line.
16
+
17
+ ## Requirements
18
+
19
+ - Python 3.7+
20
+ - Node.js 14+ (for the CLI shim and setup script)
21
+ - macOS (for the launchd scheduler, Linux/Windows users can set up a cron job manually)
22
+ - Optional: [Claude Code](https://claude.ai/code) if you want the `/scan-vault` skill and CLAUDE.md memory rule
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npm install -g aaak-vault-sync
28
+ ```
29
+
30
+ Or clone and install locally:
31
+
32
+ ```bash
33
+ git clone https://github.com/yourname/aaak-vault-sync
34
+ cd aaak-vault-sync
35
+ npm install -g .
36
+ ```
37
+
38
+ ## Setup
39
+
40
+ ### 1. Set your vault path
41
+
42
+ Add to your shell profile (`~/.zshrc` or `~/.bashrc`):
43
+
44
+ ```bash
45
+ export OBSIDIAN_VAULT_PATH=/path/to/your/vault
46
+ ```
47
+
48
+ Reload your shell:
49
+
50
+ ```bash
51
+ source ~/.zshrc
52
+ ```
53
+
54
+ ### 2. Run setup
55
+
56
+ ```bash
57
+ npm run setup
58
+ ```
59
+
60
+ This installs two generic things:
61
+
62
+ | What | Where |
63
+ |------|-------|
64
+ | launchd agent (hourly sync) | `~/Library/LaunchAgents/com.aaak.vault-sync.plist` |
65
+ | generic memory-loader prompt | `~/.aaak/generic-memory-loader.md` |
66
+
67
+ Optional Claude integration:
68
+
69
+ ```bash
70
+ npm run setup -- --target claude
71
+ ```
72
+
73
+ That also installs:
74
+
75
+ | What | Where |
76
+ |------|-------|
77
+ | Claude Code skill (`/scan-vault`) | `~/.claude/skills/scan-vault/SKILL.md` |
78
+ | CLAUDE.md memory rule | `~/.claude/CLAUDE.md` (appended) |
79
+
80
+ ### 3. Activate the scheduler
81
+
82
+ ```bash
83
+ launchctl load ~/Library/LaunchAgents/com.aaak.vault-sync.plist
84
+ ```
85
+
86
+ ### 4. Run an initial sync
87
+
88
+ ```bash
89
+ aaak-scan --verbose
90
+ ```
91
+
92
+ This scans your vault, generates AAAK files in `$VAULT/aaak/`, and writes both `aaak_index.md` and `aaak_index.json`.
93
+
94
+ ## Usage
95
+
96
+ ### CLI
97
+
98
+ ```bash
99
+ # Sync new and updated files
100
+ aaak-scan
101
+
102
+ # Show what would change without writing anything
103
+ aaak-scan --dry-run
104
+
105
+ # Verbose output
106
+ aaak-scan --verbose
107
+
108
+ # Force re-scan all files (ignore mtime)
109
+ aaak-scan --force
110
+
111
+ # Combine flags
112
+ aaak-scan --dry-run --verbose
113
+ ```
114
+
115
+ ### Generic LLM integration
116
+
117
+ After setup, you can use this prompt file with any LLM app that supports system prompts or custom instructions:
118
+
119
+ - `~/.aaak/generic-memory-loader.md`
120
+
121
+ That prompt tells the model to:
122
+
123
+ 1. Read `$OBSIDIAN_VAULT_PATH/aaak/aaak_index.md`
124
+ 2. Scan the Topics column for relevant entries
125
+ 3. Read linked AAAK summaries
126
+ 4. Fall back to original markdown via `SOURCE:` if needed
127
+ 5. Optionally use `aaak_index.json` for structured tooling
128
+
129
+ ### Claude Code skill
130
+
131
+ Once setup is complete, invoke from any Claude Code session:
132
+
133
+ ```
134
+ /scan-vault
135
+ ```
136
+
137
+ Reports how many files were converted, updated, or skipped.
138
+
139
+ ### Memory loading
140
+
141
+ For any LLM, use the generated prompt file at `~/.aaak/generic-memory-loader.md`.
142
+
143
+ If you installed the Claude integration, every Claude Code session automatically:
144
+
145
+ 1. Reads `$OBSIDIAN_VAULT_PATH/aaak/aaak_index.md`
146
+ 2. Scans the Topics column for entries relevant to the current task
147
+ 3. Reads linked AAAK files for compressed summaries of relevant docs
148
+ 4. Follows `SOURCE:` lines to original markdown if full detail is needed
149
+
150
+ If `OBSIDIAN_VAULT_PATH` is not set, this step is silently skipped.
151
+
152
+ ## Vault output structure
153
+
154
+ After the first sync, your vault will contain:
155
+
156
+ ```
157
+ your-vault/
158
+ └── aaak/
159
+ ├── aaak_index.md ← LLM-readable index + embedded JSON for sync tracking
160
+ ├── aaak_index.json ← Tool-friendly structured index
161
+ ├── entities.json ← Auto-detected proper noun → code mappings
162
+ ├── note-title.aaak.md ← Compressed AAAK summary of note-title.md
163
+ └── folder--nested.aaak.md ← Nested paths use -- as separator
164
+ ```
165
+
166
+ Each `.aaak.md` file starts with a `SOURCE:` line pointing back to the original:
167
+
168
+ ```
169
+ SOURCE: projects/my-project.md
170
+ ?|?|2026-04-07|my-project
171
+ 0:ALJ+PRF|project_launch_decision|"We decided to launch in Q2"|determ|DECISION
172
+ ```
173
+
174
+ The `aaak_index.md` table looks like:
175
+
176
+ | Source | AAAK | Last Scanned | Topics |
177
+ |--------|------|--------------|--------|
178
+ | `projects/my-project.md` | `aaak/projects--my-project.aaak.md` | 2026-04-07 | project_launch_decision |
179
+
180
+ ## AAAK format
181
+
182
+ AAAK is defined in `dialect.py`, which is part of [mempalace](https://github.com/milla-jovovich/mempalace) — a broader LLM memory system. The `dialect.py` included here is sourced from [`mempalace/dialect.py`](https://github.com/milla-jovovich/mempalace/blob/main/mempalace/dialect.py).
183
+
184
+ The dialect is a structured symbolic summary:
185
+
186
+ ```
187
+ FILE_NUM|PRIMARY_ENTITY|DATE|TITLE ← Header
188
+ ZID:ENTITIES|topic_keywords|"key_quote"|WEIGHT|EMOTIONS|FLAGS ← Zettel
189
+ T:ZID<->ZID|label ← Tunnel (connection)
190
+ ARC:emotion->emotion->emotion ← Emotional arc
191
+ ```
192
+
193
+ **Emotion codes**: `joy`, `fear`, `trust`, `grief`, `wonder`, `rage`, `love`, `hope`, `despair`, `peace`, `anx`, `determ`, `convict`, `frust`, `curious`, `grat`, `satis`, `excite`, and more.
194
+
195
+ **Flags**: `ORIGIN`, `CORE`, `SENSITIVE`, `PIVOT`, `GENESIS`, `DECISION`, `TECHNICAL`
196
+
197
+ Any LLM reads AAAK natively — no special decoder required.
198
+
199
+ ## Entity detection
200
+
201
+ `aaak-scan` automatically detects proper nouns (people, organizations, project names) across your vault and assigns stable 3-character codes:
202
+
203
+ - `Alice Johnson` → `ALJ`
204
+ - `Project Falcon` → `PRF`
205
+ - `Bob Smith` → `BOS`
206
+
207
+ Codes are saved to `$VAULT/aaak/entities.json` and stay stable across runs — new entities are appended, existing codes are never changed.
208
+
209
+ ## Configuration
210
+
211
+ All configuration is via environment variables:
212
+
213
+ | Variable | Required | Description |
214
+ |----------|----------|-------------|
215
+ | `OBSIDIAN_VAULT_PATH` | Yes | Absolute path to your Obsidian vault |
216
+
217
+ No config files needed. The scanner is intentionally zero-config beyond the vault path.
218
+
219
+ ## Scheduling
220
+
221
+ ### macOS (launchd)
222
+
223
+ The setup script installs a launchd agent that runs `aaak-scan` every hour.
224
+
225
+ ```bash
226
+ # Check status
227
+ launchctl list | grep aaak
228
+
229
+ # View logs
230
+ cat /tmp/aaak-vault-sync.log
231
+ cat /tmp/aaak-vault-sync.err
232
+
233
+ # Stop
234
+ launchctl unload ~/Library/LaunchAgents/com.aaak.vault-sync.plist
235
+
236
+ # Start again
237
+ launchctl load ~/Library/LaunchAgents/com.aaak.vault-sync.plist
238
+ ```
239
+
240
+ To change the interval, edit `~/Library/LaunchAgents/com.aaak.vault-sync.plist` and update `StartInterval` (in seconds). Then reload:
241
+
242
+ ```bash
243
+ launchctl unload ~/Library/LaunchAgents/com.aaak.vault-sync.plist
244
+ launchctl load ~/Library/LaunchAgents/com.aaak.vault-sync.plist
245
+ ```
246
+
247
+ ### Linux / Windows (cron)
248
+
249
+ Add a cron job:
250
+
251
+ ```bash
252
+ crontab -e
253
+ ```
254
+
255
+ ```
256
+ 0 * * * * OBSIDIAN_VAULT_PATH=/path/to/vault aaak-scan >> /tmp/aaak-vault-sync.log 2>&1
257
+ ```
258
+
259
+ ## Uninstall
260
+
261
+ ```bash
262
+ # Stop the scheduler
263
+ launchctl unload ~/Library/LaunchAgents/com.aaak.vault-sync.plist
264
+ rm ~/Library/LaunchAgents/com.aaak.vault-sync.plist
265
+
266
+ # Remove the Claude skill
267
+ rm -rf ~/.claude/skills/scan-vault
268
+
269
+ # Remove from CLAUDE.md (delete the "## Obsidian Vault Memory" section)
270
+ # Then uninstall the package
271
+ npm uninstall -g aaak-vault-sync
272
+ ```
273
+
274
+ The `$VAULT/aaak/` directory is not removed, so your AAAK files stay in the vault.
275
+
276
+ ## Project structure
277
+
278
+ ```
279
+ aaak-vault-sync/
280
+ ├── bin/
281
+ │ └── aaak-scan.js ← CLI entry point (Node shim → python scan.py)
282
+ ├── scripts/
283
+ │ └── setup.js ← Installs plist, skill, CLAUDE.md rule
284
+ ├── templates/
285
+ │ ├── com.aaak.vault-sync.plist.template
286
+ │ └── scan-vault-skill.md.template
287
+ ├── scan.py ← Core vault scanner
288
+ ├── dialect.py ← AAAK format encoder/decoder
289
+ └── package.json
290
+ ```
291
+
292
+ ## License
293
+
294
+ MIT
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('child_process');
5
+ const path = require('path');
6
+
7
+ const scanPy = path.join(__dirname, '..', 'scan.py');
8
+ const args = process.argv.slice(2);
9
+
10
+ const result = spawnSync('python3', [scanPy, ...args], {
11
+ stdio: 'inherit',
12
+ env: process.env,
13
+ });
14
+
15
+ if (result.error) {
16
+ if (result.error.code === 'ENOENT') {
17
+ console.error('Error: python3 not found. Install Python 3 and ensure it is on your PATH.');
18
+ } else {
19
+ console.error('Error:', result.error.message);
20
+ }
21
+ process.exit(1);
22
+ }
23
+
24
+ process.exit(result.status ?? 0);