create-ai-memory 0.15.4 → 0.16.1
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 +56 -12
- package/bin/ai-mem-mcp.js +47 -25
- package/bin/ai-mem-search +10 -0
- package/bin/ai-mem-serve.js +2 -2
- package/install.sh +14 -7
- package/package.json +4 -2
- package/shell/about-me-interview.md +38 -0
- package/shell/about-me-review.md +21 -0
- package/shell/adapters.zsh +122 -2
- package/shell/ai-mem.zsh +307 -80
- package/vault-template/_about_me/expertise.md +15 -0
- package/vault-template/_about_me/interests.md +15 -0
- package/vault-template/_about_me/modes.md +15 -0
- package/vault-template/_about_me/non-negotiables.md +15 -0
- package/vault-template/_about_me/values.md +15 -0
- package/vault-template/_about_me/wants.md +15 -0
- package/web/viewer.html +1 -0
package/README.md
CHANGED
|
@@ -52,7 +52,8 @@ Three layers, each injected at the right scope:
|
|
|
52
52
|
|
|
53
53
|
| Layer | Lives in | Injected | Holds |
|
|
54
54
|
|---|---|---|---|
|
|
55
|
-
| **Global** | `_Global_Profile.md`, `_Standards.md` | every session |
|
|
55
|
+
| **Global** | `_Global_Profile.md`, `_Standards.md` | every session | your rules, commit policy |
|
|
56
|
+
| **About me** | `_about_me/*.md` | every session: hard "no"s in full, the rest as an index | non-negotiables, wants, interests, values, expertise |
|
|
56
57
|
| **Project** | `_projects/<repo>.md` | sessions in that repo | purpose, architecture, constraints, decisions |
|
|
57
58
|
| **Session** | `_session_logs/<repo>/<timestamp>.md` | next session as carryover | what changed, blockers, next steps |
|
|
58
59
|
|
|
@@ -308,11 +309,12 @@ optional. Set `AI_MEM_ROOT` in `~/.zshrc` first if you do not want the default
|
|
|
308
309
|
|
|
309
310
|
| Command | What it does |
|
|
310
311
|
|---|---|
|
|
311
|
-
| `claude-start` · `codex-start` · `agy-start` · `gemini-start` · `cursor-start` · `opencode-start` | Launch
|
|
312
|
+
| `claude-start` · `codex-start` · `agy-start` · `gemini-start` · `cursor-start` · `opencode-start` · `omp-start` | Launch a harness with full vault context and the session-skill picker |
|
|
312
313
|
| `ai-start [project]` | Prepare the session (project note and fresh log) without launching an agent |
|
|
313
314
|
| `ai-context [project]` | Print the vault context block for the current repo, and arm the git commit guard |
|
|
314
315
|
| `ai-note <text>` | Append a timestamped note to today's session log while you work |
|
|
315
316
|
| `ai-lesson <topic-slug> <problem> <solution>` | Append a dated Problem/Solution entry to a cross-project `_lessons/<topic-slug>.md` -- decisions, mistakes, solutions worth recalling outside the current project |
|
|
317
|
+
| `ai-about-me [--review] [harness]` | Fill `_about_me/` by interview. The agent asks one question at a time, asks about real past events before hypotheticals, asks "why does that matter?" to find the reason behind each rule, and writes a note only after you approve its draft. `--review` proposes rules found in 2 or more of your lessons and session logs; you accept, change or reject each one. The harness defaults to the first in `AI_MEM_HARNESSES`. When `_about_me/` holds only placeholders, the next launch tells you once, on stderr, never the agent |
|
|
316
318
|
| `ai-mem-ingest --source-id <id> --title <t> --date <ISO> [...]` | File a distilled external artifact -- a meeting, a recorded call, a video, a voice note -- as one note in `_transcripts/`. Writes the summary, decisions, action items, attendee `[[wikilinks]]` and a link to the source; it never embeds the raw transcript body, because a full transcript is bulk the agent pays for and rarely needs. Re-ingesting the same `--source-id` updates that one note instead of filing a second copy. `ai-mem-search` covers `_transcripts/` with no extra path |
|
|
317
319
|
| `ai-mem-lint [--fix]` | Check the vault's links: orphaned session logs, dangling `previous` links, unreferenced project notes, notes missing the `type:` field, and **dangling `[[wikilinks]]`** -- a link pointing at a note that does not exist (a dead edge in the graph), reported but never auto-removed. `--fix` backfills `type:` into session logs written before the field existed |
|
|
318
320
|
| `ai-mem-search <term> [project]` | Case-insensitive literal search across the vault (or one project's logs). Lessons rank first, and within them by *reinforcement* -- a lesson recalled more often (more dated entries) ranks above a once-seen one -- then by date; archived logs (see `ai-mem-sleep`) are skipped. Paths print relative to a root stated once in the header. Output is capped (`AI_MEM_SEARCH_LIMIT`, default 25) with an explicit `N hidden` notice, because the usual caller is an agent with a finite context window. Also resolves any `[[wikilink]]` on a matched line to its project note -- one hop out along the graph, always on, not a flag to remember |
|
|
@@ -459,6 +461,27 @@ Matching is exact and line-by-line, so anything reworded survives. It fails
|
|
|
459
461
|
note in full. Injecting twice costs tokens; dropping a note costs the agent
|
|
460
462
|
context it was promised.
|
|
461
463
|
|
|
464
|
+
### About me: hard "no"s in full, the rest on demand
|
|
465
|
+
|
|
466
|
+
`_about_me/` holds the human side of the profile as several small notes, not
|
|
467
|
+
one file. One file grows until the note cap cuts it off, like a long profile.
|
|
468
|
+
Each note sets `inject:` in its frontmatter:
|
|
469
|
+
|
|
470
|
+
| `inject:` | What reaches the prompt | Use it for |
|
|
471
|
+
|---|---|---|
|
|
472
|
+
| `always` | the body, at the **top** of the prompt, capped at 1,500 chars (`AI_MEM_ABOUT_ME_MAX_CHARS`) | non-negotiables |
|
|
473
|
+
| anything else | one index line: the file name and its `read_when:` trigger | wants, interests, values, expertise, modes |
|
|
474
|
+
|
|
475
|
+
Hard "no"s are never behind a link: an agent that must open a file to see a
|
|
476
|
+
rule often does not open it. The other notes cost one line each, however long
|
|
477
|
+
they grow, and the `read_when:` trigger tells the agent when to open them.
|
|
478
|
+
|
|
479
|
+
Blockquotes and `[bracketed]` placeholder bullets are notes to you and are
|
|
480
|
+
never injected. A note that holds only those is not listed. A note whose name
|
|
481
|
+
starts with `_` is skipped. Write these notes yourself, or run `ai-about-me`
|
|
482
|
+
to fill them by interview. An agent may propose a change, but a profile the
|
|
483
|
+
agent edits is no longer your own view of yourself.
|
|
484
|
+
|
|
462
485
|
### Every path into the prompt is bounded
|
|
463
486
|
|
|
464
487
|
The launch prompt is paid **every session, in every project**, so anything
|
|
@@ -467,6 +490,7 @@ that can grow without limit is a cost that compounds silently.
|
|
|
467
490
|
| what reaches the prompt | bound |
|
|
468
491
|
|---|---|
|
|
469
492
|
| Profile and standards | **8,000 chars** each for shell launchers; GUI MCP is uncapped by default (`AI_MEM_NOTE_MAX_CHARS`) |
|
|
493
|
+
| `_about_me/` | `inject: always` notes **1,500 chars** each (`AI_MEM_ABOUT_ME_MAX_CHARS`); every other note one index line |
|
|
470
494
|
| Previous session outcome | 4 fields, 500 chars each |
|
|
471
495
|
| Lesson index | 200 slugs, names only |
|
|
472
496
|
| Project note | **a path, not its contents** |
|
|
@@ -617,9 +641,6 @@ refactor and add `hallmark` only when you touch the UI. These are separate,
|
|
|
617
641
|
installable Claude Code skills; the blocks above inline their behavior so a
|
|
618
642
|
session still benefits even on an agent that does not have the skill installed.
|
|
619
643
|
|
|
620
|
-
If you want a queryable knowledge graph of your codebase alongside your memory,
|
|
621
|
-
pair create-ai-memory with [graphify](https://github.com/safishamsi/graphify).
|
|
622
|
-
|
|
623
644
|
## Your vault
|
|
624
645
|
|
|
625
646
|
The vault is a folder of Markdown. Point `AI_MEM_ROOT` at a new directory or at an
|
|
@@ -630,6 +651,11 @@ search over your own AI memory, plus plain `grep` when you want it.
|
|
|
630
651
|
$AI_MEM_ROOT/
|
|
631
652
|
_Global_Profile.md your cross-project rules (injected every session)
|
|
632
653
|
_Standards.md extra shared standards (injected every session)
|
|
654
|
+
_about_me/
|
|
655
|
+
non-negotiables.md hard "no"s (injected every session)
|
|
656
|
+
wants.md, interests.md, who you are (one index line each;
|
|
657
|
+
values.md, expertise.md, read on demand)
|
|
658
|
+
modes.md
|
|
633
659
|
_projects/
|
|
634
660
|
_project_template.md scaffold for new project notes
|
|
635
661
|
<repo>.md per-project durable context
|
|
@@ -646,8 +672,9 @@ $AI_MEM_ROOT/
|
|
|
646
672
|
```
|
|
647
673
|
|
|
648
674
|
Notes are created from templates on first use and never overwritten. Edit
|
|
649
|
-
`_Global_Profile.md
|
|
650
|
-
are sanitized placeholders.
|
|
675
|
+
`_Global_Profile.md`, `_Standards.md` and the notes in `_about_me/` to make them
|
|
676
|
+
yours; the shipped versions are sanitized placeholders. `_about_me/` is seeded
|
|
677
|
+
only when the folder does not exist, so a note you delete stays deleted.
|
|
651
678
|
|
|
652
679
|
## Open Knowledge Format
|
|
653
680
|
|
|
@@ -686,16 +713,24 @@ backfilled `type: ai-session-log` into 350 session log(s)
|
|
|
686
713
|
|
|
687
714
|
Edits in place, preserves frontmatter and body, idempotent.
|
|
688
715
|
|
|
689
|
-
## Add another
|
|
716
|
+
## Add another harness
|
|
690
717
|
|
|
691
|
-
Launchers are
|
|
718
|
+
Launchers are configurable. Each harness is one small adapter, and the
|
|
692
719
|
`<name>-start` function is generated for you. `claude`, `codex`, `agy`,
|
|
693
|
-
`gemini`, `cursor`, and `
|
|
720
|
+
`gemini`, `cursor`, `opencode`, and `omp` ship built in.
|
|
694
721
|
|
|
695
722
|
`agy` is the [Antigravity CLI](https://antigravity.google), which in practice
|
|
696
723
|
has replaced the Gemini CLI. Both adapters ship: `gemini-start` still works
|
|
697
724
|
for anyone using it, and `agy-start` is the one to reach for now.
|
|
698
725
|
|
|
726
|
+
`omp-start` passes the vault as an OMP workspace directory and adds the selected
|
|
727
|
+
session skills through OMP's system-prompt channel. It also tells OMP to use
|
|
728
|
+
and prints the active OMP provider/model selector plus a redacted
|
|
729
|
+
provider-usage snapshot before the TUI opens. The snapshot includes
|
|
730
|
+
weekly/account limits when the provider exposes them. Set
|
|
731
|
+
`AI_MEM_OMP_SHOW_USAGE=0` to skip that preflight check. Plain `omp` is
|
|
732
|
+
unchanged; it does not load the ai-memory vault or session context.
|
|
733
|
+
|
|
699
734
|
To add `aider`:
|
|
700
735
|
|
|
701
736
|
1. Define the adapter in `shell/adapters.zsh`. It receives `$1` memory prompt,
|
|
@@ -708,7 +743,7 @@ To add `aider`:
|
|
|
708
743
|
```
|
|
709
744
|
2. Register it in `~/.zshrc` before sourcing, or edit the default:
|
|
710
745
|
```zsh
|
|
711
|
-
export
|
|
746
|
+
export AI_MEM_HARNESSES="claude codex agy gemini cursor opencode omp aider"
|
|
712
747
|
```
|
|
713
748
|
3. `aider-start` now exists. No core edits.
|
|
714
749
|
|
|
@@ -782,6 +817,11 @@ a standing brief (read context first, search before solving, write back after)
|
|
|
782
817
|
-- without it a model has no reason to suspect a memory exists. Tool
|
|
783
818
|
descriptions stay terse because schemas are re-sent every turn.
|
|
784
819
|
|
|
820
|
+
A GUI session log is created by the first write, not by a read. Each MCP
|
|
821
|
+
server keeps one log path for its lifetime; `add_note` (or an agent that
|
|
822
|
+
writes the session outcome) creates the file there. A conversation that only
|
|
823
|
+
reads context leaves no empty note in the vault.
|
|
824
|
+
|
|
785
825
|
**Do not register this for a terminal agent.** Claude Code, Codex, Gemini and
|
|
786
826
|
opencode have a shell and should call `ai-mem-search` directly.
|
|
787
827
|
|
|
@@ -847,10 +887,14 @@ git -C <repo> config core.hooksPath .githooks
|
|
|
847
887
|
| Env var | Default | Purpose |
|
|
848
888
|
|---|---|---|
|
|
849
889
|
| `AI_MEM_ROOT` | `$HOME/.ai-memory/_Ai_Memory` | Vault root. Point at any folder, including an existing Obsidian vault |
|
|
850
|
-
| `
|
|
890
|
+
| `AI_MEM_HARNESSES` | `claude codex agy gemini cursor opencode omp` | Space-separated harnesses to generate `-start` functions for |
|
|
891
|
+
| `AI_MEM_AGENTS` | compatibility alias | Older installs may keep using this name; `AI_MEM_HARNESSES` takes precedence |
|
|
892
|
+
| `AI_MEM_PREFERRED_HARNESS` | empty | Optional override used by every `*-start`; e.g. `omp` makes `codex-start` launch OMP while keeping the familiar entry point |
|
|
893
|
+
| `AI_MEM_OMP_SHOW_USAGE` | `1` | Show OMP's redacted provider/account usage snapshot before an ai-memory OMP session; set to `0` to skip |
|
|
851
894
|
| `AI_MEM_SKILLS` / `AI_MEM_SKILL_ORDER` | empty | Your per-session skills (see above) |
|
|
852
895
|
| `AI_MEM_LESSON_INDEX_LIMIT` | `200` | Lesson slugs listed in the launch prompt before it truncates to the newest. Names only -- bodies are never injected |
|
|
853
896
|
| `AI_MEM_NOTE_MAX_CHARS` | `8000` for shell launchers; `0` for GUI MCP | Cap on what one inlined note contributes to the launch prompt. Truncation states the real total and the path. `0` disables it |
|
|
897
|
+
| `AI_MEM_ABOUT_ME_MAX_CHARS` | `1500` | Cap on each `inject: always` note in `_about_me/`. Kept small on purpose: these notes are paid for in every session. Truncation states the real total and the path |
|
|
854
898
|
| `AI_MEM_SEARCH_LIMIT` | `25` | Result lines `ai-mem-search` prints before it truncates. The default is sized for an agent's context window; raise it when you are reading the output yourself (see [How search works](#how-search-works)) |
|
|
855
899
|
| `AI_MEM_HOME` | the module's own directory | Exported by the module when it is sourced, not set by you. A cron job, a launchd agent or any non-interactive shell can re-source the module with `zsh -c 'source "$AI_MEM_HOME/ai-mem.zsh"; ...'` instead of a hard-coded path |
|
|
856
900
|
| `AI_MEM_SEARCH_PER_FILE` | `1` | Lines shown per file once the cap binds. Spreads results across notes instead of on the chattiest one; ignored when every match already fits |
|
package/bin/ai-mem-mcp.js
CHANGED
|
@@ -43,6 +43,22 @@ const VERSION = (() => {
|
|
|
43
43
|
}
|
|
44
44
|
})();
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The global session log this server writes to, pinned for its lifetime.
|
|
48
|
+
*
|
|
49
|
+
* Every zsh call is a fresh process, so the path the module picks on
|
|
50
|
+
* `initialize` would be lost by the next call. Pinning it keeps one server
|
|
51
|
+
* on one log. The file itself is created by the first write, so a
|
|
52
|
+
* conversation that only reads leaves no empty note in the vault.
|
|
53
|
+
*/
|
|
54
|
+
let sessionLog = '';
|
|
55
|
+
|
|
56
|
+
/** Remember the "Active session log" path from an ai-context result. */
|
|
57
|
+
function pinSessionLog(text) {
|
|
58
|
+
const m = /^- Active session log: (.+?\.md)(?: -- |$)/m.exec(text || '');
|
|
59
|
+
if (m) sessionLog = m[1];
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
/**
|
|
47
63
|
* Run a zsh snippet with the module sourced, and return its output.
|
|
48
64
|
*
|
|
@@ -64,6 +80,10 @@ function zsh(snippet) {
|
|
|
64
80
|
AI_MEM_NOTE_MAX_CHARS: process.env.AI_MEM_NOTE_MAX_CHARS ?? '0',
|
|
65
81
|
AI_MEM_FORCE_PROJECT: GUI_PROJECT,
|
|
66
82
|
AI_MEM_GLOBALIZE_ROOT: GUI_ROOT,
|
|
83
|
+
AI_MEM_GLOBAL_SESSION: '1',
|
|
84
|
+
// Always set, so a project log exported by a parent *-start shell is
|
|
85
|
+
// never mistaken for this GUI session.
|
|
86
|
+
AI_MEM_ACTIVE_SESSION_LOG: sessionLog,
|
|
67
87
|
},
|
|
68
88
|
maxBuffer: 8 * 1024 * 1024,
|
|
69
89
|
});
|
|
@@ -122,36 +142,33 @@ function insideVault(p) {
|
|
|
122
142
|
* before the first turn.
|
|
123
143
|
*
|
|
124
144
|
* This is what makes a GUI behave like a launcher. In a terminal the vault is
|
|
125
|
-
* pushed into the agent's opening prompt; over MCP
|
|
126
|
-
*
|
|
127
|
-
* tool. Saying so once, up front, is the whole difference.
|
|
145
|
+
* pushed into the agent's opening prompt; over MCP the client must receive a
|
|
146
|
+
* clear context gate before it can act.
|
|
128
147
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* used or not, and clients are free to truncate or ignore the field. A cheap
|
|
133
|
-
* nudge plus one get_context call is both smaller and more robust than a
|
|
134
|
-
* large block that may be silently dropped.
|
|
148
|
+
* Put the non-negotiable rules first because some GUI clients cap or summarize
|
|
149
|
+
* long instruction fields. Keep the full profile and standards after that so
|
|
150
|
+
* clients that preserve the payload have the same source material as CLI runs.
|
|
135
151
|
*/
|
|
136
152
|
const INSTRUCTIONS = [
|
|
153
|
+
'HARD RULES — follow these before doing work:',
|
|
154
|
+
'1. Treat _Global_Profile.md and _Standards.md as active instructions, not optional reference material.',
|
|
155
|
+
'2. Call get_context before answering, editing files, using external tools, or creating a commit. If it fails, stop and report the failure.',
|
|
156
|
+
'3. Call search_memory before solving a non-trivial problem or retrying a blocker.',
|
|
157
|
+
'4. Commit messages require Conventional Commits plus a blank line and a detailed body with a summary and concrete change bullets. Never create a title-only commit.',
|
|
158
|
+
'',
|
|
137
159
|
"This is the user's persistent memory across every AI tool they use: past sessions, project decisions, and lessons learned the hard way.",
|
|
138
160
|
'',
|
|
139
|
-
'
|
|
161
|
+
'The full global profile and standards follow:',
|
|
140
162
|
'--- _Global_Profile.md ---',
|
|
141
163
|
readVaultNote('_Global_Profile.md'),
|
|
142
164
|
'--- _Standards.md ---',
|
|
143
165
|
readVaultNote('_Standards.md'),
|
|
144
166
|
'',
|
|
145
|
-
'
|
|
146
|
-
'
|
|
147
|
-
'When you hit a blocker -- an error you do not understand, an unclear failure, or a second failed attempt at the same thing -- search again before guessing. Lessons rank above session logs, so a hit under _lessons/ is the recorded fix.',
|
|
148
|
-
'Search ONE distinctive word, not a sentence. Matching is literal substring: a whole error line finds nothing, and a bare tool name returns hundreds of irrelevant lines. Pick the most unusual word in the symptom and try two or three separately.',
|
|
167
|
+
'get_context returns the loaded profile, standards, project context, and latest session digest. Its successful result is the context gate for this session.',
|
|
168
|
+
'search_memory may contain a prior solution. Search broadly first; use one distinctive word, not a whole sentence.',
|
|
149
169
|
'',
|
|
150
|
-
'Write back.
|
|
151
|
-
'
|
|
152
|
-
'- add_lesson for something worth recalling in a DIFFERENT project later. Not project trivia -- the transferable part.',
|
|
153
|
-
'',
|
|
154
|
-
'If they ask to see, open or browse their memory rather than search it, call open_graph.',
|
|
170
|
+
'Write back with add_note for decisions, blockers, and next steps. Use add_lesson only for reusable knowledge that matters in a different project.',
|
|
171
|
+
'If the user asks to see or browse memory, call open_graph.',
|
|
155
172
|
].join('\n');
|
|
156
173
|
|
|
157
174
|
// Descriptions stay terse on purpose. Every schema below is re-sent on each
|
|
@@ -173,7 +190,7 @@ const TOOLS = [
|
|
|
173
190
|
},
|
|
174
191
|
{
|
|
175
192
|
name: 'get_context',
|
|
176
|
-
description: '
|
|
193
|
+
description: 'REQUIRED FIRST ACTION. Returns the user\'s active profile, standards, current project note, latest session digest, and lesson topics.',
|
|
177
194
|
inputSchema: {
|
|
178
195
|
type: 'object',
|
|
179
196
|
properties: { project: { type: 'string', description: 'Optional project. Defaults to the GUI global memory project.' } },
|
|
@@ -222,8 +239,12 @@ function callTool(name, args = {}) {
|
|
|
222
239
|
switch (name) {
|
|
223
240
|
case 'search_memory':
|
|
224
241
|
return zsh(`ai-mem-search ${q(args.term)} ${args.project ? q(args.project) : ''}`);
|
|
225
|
-
case 'get_context':
|
|
226
|
-
|
|
242
|
+
case 'get_context': {
|
|
243
|
+
const project = args.project || GUI_PROJECT;
|
|
244
|
+
const result = zsh(`ai-context ${q(project)}`);
|
|
245
|
+
if (result.ok && project === GUI_PROJECT) pinSessionLog(result.text);
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
227
248
|
// ai-note and ai-lesson both push the vault themselves, so a GUI write is
|
|
228
249
|
// committed and backed up exactly like a terminal one -- no separate step
|
|
229
250
|
// for the model to forget.
|
|
@@ -269,9 +290,10 @@ function handle(req) {
|
|
|
269
290
|
if (id === undefined) return;
|
|
270
291
|
|
|
271
292
|
if (method === 'initialize') {
|
|
272
|
-
// Initialize is the GUI equivalent of a CLI launcher:
|
|
273
|
-
// session log even if the model never
|
|
274
|
-
|
|
293
|
+
// Initialize is the GUI equivalent of a CLI launcher: load the context and
|
|
294
|
+
// pin this server's global session log even if the model never calls a
|
|
295
|
+
// tool first. The log file is created by the first write, not here.
|
|
296
|
+
pinSessionLog(zsh(`ai-context ${q(GUI_PROJECT)}`).text);
|
|
275
297
|
return send({
|
|
276
298
|
jsonrpc: '2.0',
|
|
277
299
|
id,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Run the canonical zsh implementation from non-interactive agent shells.
|
|
3
|
+
# OMP and similar harnesses do not inherit interactive zsh functions.
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
|
7
|
+
MODULE="$SCRIPT_DIR/../shell/ai-mem.zsh"
|
|
8
|
+
|
|
9
|
+
exec zsh -f -c 'source "$1"; shift; ai-mem-search "$@"' \
|
|
10
|
+
ai-mem-search "$MODULE" "$@"
|
package/bin/ai-mem-serve.js
CHANGED
|
@@ -41,7 +41,7 @@ const NO_OPEN = ARGS.includes('--no-open');
|
|
|
41
41
|
const PORT = Number(ARGS.find((a) => /^\d+$/.test(a)) || process.env.AI_MEM_PORT || 7777);
|
|
42
42
|
const VIEWER = join(__dirname, '..', 'web', 'viewer.html');
|
|
43
43
|
|
|
44
|
-
/** Recursively collect
|
|
44
|
+
/** Recursively collect active .md files, skipping dotfiles, archives, and templates. */
|
|
45
45
|
function walk(dir, out = []) {
|
|
46
46
|
let entries;
|
|
47
47
|
try {
|
|
@@ -50,7 +50,7 @@ function walk(dir, out = []) {
|
|
|
50
50
|
return out;
|
|
51
51
|
}
|
|
52
52
|
for (const e of entries) {
|
|
53
|
-
if (e.name.startsWith('.')) continue;
|
|
53
|
+
if (e.name.startsWith('.') || e.name === '_archive') continue;
|
|
54
54
|
const p = join(dir, e.name);
|
|
55
55
|
if (e.isDirectory()) walk(p, out);
|
|
56
56
|
else if (extname(e.name) === '.md' && !e.name.endsWith('_template.md')) out.push(p);
|
package/install.sh
CHANGED
|
@@ -72,29 +72,36 @@ banner
|
|
|
72
72
|
# --- gather settings ---------------------------------------------------------
|
|
73
73
|
AI_MEM_ROOT="${AI_MEM_ROOT:-$HOME/.ai-memory/_Ai_Memory}"
|
|
74
74
|
ask AI_MEM_ROOT "Where should your memory vault live?" "$AI_MEM_ROOT"
|
|
75
|
-
|
|
76
|
-
ask
|
|
75
|
+
AI_MEM_HARNESSES="${AI_MEM_HARNESSES:-${AI_MEM_AGENTS:-claude codex agy gemini cursor opencode omp}}"
|
|
76
|
+
ask AI_MEM_HARNESSES "Which harnesses should get <harness>-start launchers?" "$AI_MEM_HARNESSES"
|
|
77
|
+
AI_MEM_PREFERRED_HARNESS="${AI_MEM_PREFERRED_HARNESS:-}"
|
|
78
|
+
ask AI_MEM_PREFERRED_HARNESS "Which harness should *-start use by default? (blank keeps the named launcher)" "$AI_MEM_PREFERRED_HARNESS"
|
|
77
79
|
|
|
78
80
|
# --- scaffold the vault ------------------------------------------------------
|
|
79
81
|
echo
|
|
80
82
|
echo " scaffolding vault at: $AI_MEM_ROOT"
|
|
81
83
|
mkdir -p "$AI_MEM_ROOT/_projects" "$AI_MEM_ROOT/_session_logs" "$AI_MEM_ROOT/_lessons"
|
|
82
84
|
|
|
83
|
-
copy_if_absent() { # never overwrite the user's real notes on a re-run
|
|
85
|
+
copy_if_absent() { # never overwrite the user's real notes on a re-run; -R also copies a folder
|
|
84
86
|
local src="$1" dst="$2"
|
|
85
|
-
if [ -e "$dst" ]; then echo " keep ${dst##*/}"; else cp "$src" "$dst"; echo " create ${dst##*/}"; fi
|
|
87
|
+
if [ -e "$dst" ]; then echo " keep ${dst##*/}"; else cp -R "$src" "$dst"; echo " create ${dst##*/}"; fi
|
|
86
88
|
}
|
|
87
89
|
copy_if_absent "$HERE/vault-template/_Global_Profile.md" "$AI_MEM_ROOT/_Global_Profile.md"
|
|
88
90
|
copy_if_absent "$HERE/vault-template/_Standards.md" "$AI_MEM_ROOT/_Standards.md"
|
|
91
|
+
copy_if_absent "$HERE/vault-template/_about_me" "$AI_MEM_ROOT/_about_me"
|
|
89
92
|
copy_if_absent "$HERE/vault-template/_projects/_project_template.md" "$AI_MEM_ROOT/_projects/_project_template.md"
|
|
90
93
|
copy_if_absent "$HERE/vault-template/_session_logs/_session_template.md" "$AI_MEM_ROOT/_session_logs/_session_template.md"
|
|
91
94
|
copy_if_absent "$HERE/vault-template/_lessons/_lesson_template.md" "$AI_MEM_ROOT/_lessons/_lesson_template.md"
|
|
92
95
|
|
|
93
96
|
# --- assemble the ~/.zshrc lines ---------------------------------------------
|
|
94
97
|
LINES="export AI_MEM_ROOT=\"$AI_MEM_ROOT\""
|
|
95
|
-
if [ "$
|
|
98
|
+
if [ "$AI_MEM_HARNESSES" != "claude codex agy gemini cursor opencode omp" ]; then
|
|
96
99
|
LINES="$LINES
|
|
97
|
-
export
|
|
100
|
+
export AI_MEM_HARNESSES=\"$AI_MEM_HARNESSES\""
|
|
101
|
+
fi
|
|
102
|
+
if [ -n "$AI_MEM_PREFERRED_HARNESS" ]; then
|
|
103
|
+
LINES="$LINES
|
|
104
|
+
export AI_MEM_PREFERRED_HARNESS=\"$AI_MEM_PREFERRED_HARNESS\""
|
|
98
105
|
fi
|
|
99
106
|
LINES="$LINES
|
|
100
107
|
source \"$HERE/shell/ai-mem.zsh\""
|
|
@@ -135,7 +142,7 @@ cat <<EOF
|
|
|
135
142
|
(your memory; safe to back up, sync, or open in Obsidian)
|
|
136
143
|
|
|
137
144
|
From inside any git repo, run: claude-start
|
|
138
|
-
(or codex-start / agy-start / gemini-start / cursor-start / opencode-start)
|
|
145
|
+
(or codex-start / agy-start / gemini-start / cursor-start / opencode-start / omp-start)
|
|
139
146
|
|
|
140
147
|
Optional integrations: see $HERE/hooks/ and the README.
|
|
141
148
|
EOF
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ai-memory",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Persistent,
|
|
3
|
+
"version": "0.16.1",
|
|
4
|
+
"description": "Persistent, harness-agnostic session memory for AI coding CLIs (Claude Code, Codex, Gemini, Cursor, opencode, omp). One Markdown vault, any harness.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-ai-memory": "bin/create-ai-memory.js",
|
|
7
|
+
"ai-mem-search": "bin/ai-mem-search",
|
|
7
8
|
"ai-mem-mcp": "bin/ai-mem-mcp.js",
|
|
8
9
|
"ai-mem-serve": "bin/ai-mem-serve.js"
|
|
9
10
|
},
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
"memory",
|
|
38
39
|
"obsidian",
|
|
39
40
|
"opencode",
|
|
41
|
+
"omp",
|
|
40
42
|
"zsh"
|
|
41
43
|
],
|
|
42
44
|
"homepage": "https://github.com/rambaarde/create-ai-memory#readme",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# About-me interview
|
|
2
|
+
|
|
3
|
+
Your task in this session: interview the user and fill the notes in `_about_me/`.
|
|
4
|
+
Do not start other work. The path of the folder is at the end of this message.
|
|
5
|
+
|
|
6
|
+
## Rules
|
|
7
|
+
|
|
8
|
+
1. Read every note in `_about_me/` before your first question. Do not ask again for what a note already states. Ask about the gaps.
|
|
9
|
+
2. Ask one question per message. Then wait for the answer.
|
|
10
|
+
3. Use open questions. Do not suggest an answer inside the question.
|
|
11
|
+
4. After each answer, say it back in one sentence in the user's words. Then ask the next question.
|
|
12
|
+
5. Ask about real past events first: "Tell me about a time when ...". Use a hypothetical case only to test a rule that the user already stated.
|
|
13
|
+
6. For each rule or want, ask "Why does that matter to you?". Ask again, up to 3 times, until the answer is a value. Use the last answer as the reason of the rule.
|
|
14
|
+
7. Do not add a rule, a want, or a value that the user did not state. Do not praise the user. Do not agree only to please the user.
|
|
15
|
+
8. Do not write a file until the user approves its draft.
|
|
16
|
+
9. The user can stop at any time. Then show the drafts that exist, and write only the drafts that the user approves.
|
|
17
|
+
|
|
18
|
+
## Phases
|
|
19
|
+
|
|
20
|
+
1. Purpose. Ask what the user wants these notes to change in their work with an AI.
|
|
21
|
+
2. Bad events. Ask about a time when an AI did something that the user never wants again. Do the "why" steps. Each result is a candidate for `non-negotiables.md`.
|
|
22
|
+
3. Good events. Ask about a time when a session with an AI went well. Ask what the AI did. Each result is a candidate for `wants.md` or `modes.md`.
|
|
23
|
+
4. Values and interests. Ask what the user wants to still do personally in two years, instead of giving it to an AI. A value has no end: put it in `values.md`. A goal has an end: put it in `interests.md`.
|
|
24
|
+
5. Expertise. Ask where the AI must skip the basics and where it must explain. Put the answers in `expertise.md`.
|
|
25
|
+
6. Edge cases. Make 2 or 3 short scenarios from the earlier answers. For each, ask the user to choose "act" or "ask me first". Use the answers to make the rules exact.
|
|
26
|
+
7. Summary. Show each draft note in full. Ask for approval of each note separately.
|
|
27
|
+
|
|
28
|
+
## Test for a non-negotiable
|
|
29
|
+
|
|
30
|
+
Ask: "Is this still a no if you ask for it casually in the middle of a task?"
|
|
31
|
+
If the answer is yes, the rule goes in `non-negotiables.md`. If the answer is no, the rule goes in `wants.md`.
|
|
32
|
+
|
|
33
|
+
## Format of the notes
|
|
34
|
+
|
|
35
|
+
- Keep the frontmatter of each note. Do not change `inject:` or `read_when:` unless the user asks.
|
|
36
|
+
- Replace the `[bracketed]` placeholder bullets. Keep the `>` guidance lines.
|
|
37
|
+
- Write each rule as one bullet: "* Do X. Why: Y." or "* Do not do X. Why: Y."
|
|
38
|
+
- Keep `non-negotiables.md` shorter than 1500 characters. It is sent in full at the start of every session. If it is longer, ask the user which rule to move to `wants.md`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# About-me review
|
|
2
|
+
|
|
3
|
+
Your task in this session: propose changes to the notes in `_about_me/` from evidence in the vault.
|
|
4
|
+
Do not start other work. The path of the folder is at the end of this message.
|
|
5
|
+
|
|
6
|
+
## Rules
|
|
7
|
+
|
|
8
|
+
1. Read every note in `_about_me/` first.
|
|
9
|
+
2. Read the evidence: the lessons in `_lessons/`, and the "Important Decisions" and "Constraints / Blockers" lines of the 20 newest session logs. Use `ai-mem-search <term>` to find more evidence for a term.
|
|
10
|
+
3. Propose a candidate only when 2 or more different sources show the same pattern. A pattern from one source is not sufficient.
|
|
11
|
+
4. For each candidate, show: the proposed rule, the target note, and each source as a file path with the quoted line.
|
|
12
|
+
5. Call each candidate an inference. Do not state it as a fact about the user.
|
|
13
|
+
6. Show one candidate per message. Ask the user to accept, change, or reject it.
|
|
14
|
+
7. If a candidate conflicts with a current note, show the conflict and ask. Do not replace the current note.
|
|
15
|
+
8. Write only the candidates that the user accepts. Do not change other text in the notes.
|
|
16
|
+
|
|
17
|
+
## Format of the notes
|
|
18
|
+
|
|
19
|
+
- Keep the frontmatter of each note.
|
|
20
|
+
- Write each rule as one bullet: "* Do X. Why: Y." or "* Do not do X. Why: Y."
|
|
21
|
+
- Keep `non-negotiables.md` shorter than 1500 characters.
|
package/shell/adapters.zsh
CHANGED
|
@@ -95,8 +95,128 @@ __ai_adapter_opencode() {
|
|
|
95
95
|
opencode --prompt "$memory_prompt"
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
#
|
|
99
|
-
#
|
|
98
|
+
# omp (Oh My Pi): grant the TUI direct vault access, keep the memory context as
|
|
99
|
+
# the opening message, and put selected session skills in OMP's system prompt
|
|
100
|
+
# channel so they have higher authority than ordinary prompt text. Do not use
|
|
101
|
+
# -p/--print here; that is one-shot mode.
|
|
102
|
+
__ai_omp_model_selector() {
|
|
103
|
+
local requested="${AI_MEM_REQUESTED_LAUNCHER:-omp}"
|
|
104
|
+
local configured="${AI_MEM_OMP_MODEL:-}"
|
|
105
|
+
local mapped="${AI_MEM_OMP_MODELS[$requested]:-}"
|
|
106
|
+
if [[ -n "$mapped" ]]; then
|
|
107
|
+
print -r -- "$mapped"
|
|
108
|
+
return 0
|
|
109
|
+
fi
|
|
110
|
+
if [[ -n "$configured" ]]; then
|
|
111
|
+
print -r -- "$configured"
|
|
112
|
+
return 0
|
|
113
|
+
fi
|
|
114
|
+
if [[ -r "$HOME/.omp/agent/config.yml" ]]; then
|
|
115
|
+
sed -n 's/^[[:space:]]*default:[[:space:]]*//p' "$HOME/.omp/agent/config.yml" | sed -n '1p'
|
|
116
|
+
fi
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
__ai_omp_provider_args() {
|
|
120
|
+
local requested="${AI_MEM_REQUESTED_LAUNCHER:-omp}"
|
|
121
|
+
[[ "$requested" == omp ]] && return 0
|
|
122
|
+
local provider="${AI_MEM_OMP_PROVIDERS[$requested]:-$requested}"
|
|
123
|
+
local model="${AI_MEM_OMP_MODELS[$requested]:-}"
|
|
124
|
+
print -r -- "--provider"
|
|
125
|
+
print -r -- "$provider"
|
|
126
|
+
if [[ -n "$model" ]]; then
|
|
127
|
+
print -r -- "--model"
|
|
128
|
+
print -r -- "$model"
|
|
129
|
+
fi
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
__ai_omp_usage_snapshot() {
|
|
133
|
+
[[ "${AI_MEM_OMP_SHOW_USAGE:-1}" != 0 ]] || return 0
|
|
134
|
+
local usage_snapshot
|
|
135
|
+
usage_snapshot="$(omp usage --redact 2>/dev/null)" || return 0
|
|
136
|
+
[[ -n "$usage_snapshot" ]] || return 0
|
|
137
|
+
print -r -- "ai-memory: OMP provider usage (weekly/account limits):"
|
|
138
|
+
print -r -- "$usage_snapshot"
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
__ai_omp_skill_instructions() {
|
|
142
|
+
local modes="$1" key skill_file skill_root text block=""
|
|
143
|
+
for key in ${(s:|:)modes}; do
|
|
144
|
+
skill_file=""
|
|
145
|
+
for skill_root in "$HOME/.codex/skills" "$HOME/.agents/skills"; do
|
|
146
|
+
if [[ -f "$skill_root/$key/SKILL.md" ]]; then
|
|
147
|
+
skill_file="$skill_root/$key/SKILL.md"
|
|
148
|
+
break
|
|
149
|
+
fi
|
|
150
|
+
done
|
|
151
|
+
|
|
152
|
+
if [[ -n "$skill_file" ]]; then
|
|
153
|
+
block+=$'\n--- local skill '
|
|
154
|
+
block+="$key"
|
|
155
|
+
block+=$' (already loaded locally; do not look up in OMP registry) ---\n'
|
|
156
|
+
block+="$(<"$skill_file")"
|
|
157
|
+
block+=$'\n--- end local skill '
|
|
158
|
+
block+="$key"
|
|
159
|
+
block+=$' ---\n'
|
|
160
|
+
else
|
|
161
|
+
text="${AI_MEM_SKILLS[$key]#*::}"
|
|
162
|
+
[[ -n "$text" ]] || continue
|
|
163
|
+
block+=$'\n--- local session instruction '
|
|
164
|
+
block+="$key"
|
|
165
|
+
block+=$' (already loaded locally; do not look up in OMP registry) ---\n'
|
|
166
|
+
block+="$text"
|
|
167
|
+
block+=$'\n--- end local session instruction '
|
|
168
|
+
block+="$key"
|
|
169
|
+
block+=$' ---\n'
|
|
170
|
+
fi
|
|
171
|
+
done
|
|
172
|
+
print -r -- "$block"
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
__ai_adapter_omp() {
|
|
176
|
+
local memory_prompt="$1" mode_block="$2"
|
|
177
|
+
shift 2 2>/dev/null || true
|
|
178
|
+
local system_prompt model_selector arg previous_arg="" loaded_skills="" provider_args=()
|
|
179
|
+
provider_args=( ${(f)"$(__ai_omp_provider_args)"} )
|
|
180
|
+
model_selector="$(__ai_omp_model_selector)"
|
|
181
|
+
for arg in "$@"; do
|
|
182
|
+
if [[ "$arg" == --model=* ]]; then
|
|
183
|
+
model_selector="${arg#--model=}"
|
|
184
|
+
elif [[ "$previous_arg" == --model ]]; then
|
|
185
|
+
model_selector="$arg"
|
|
186
|
+
fi
|
|
187
|
+
previous_arg="$arg"
|
|
188
|
+
done
|
|
189
|
+
if [[ -n "$model_selector" ]]; then
|
|
190
|
+
print -r -- "ai-memory: OMP provider/model: $model_selector" >&2
|
|
191
|
+
else
|
|
192
|
+
print -r -- "ai-memory: OMP provider/model: OMP default (not resolved)" >&2
|
|
193
|
+
fi
|
|
194
|
+
__ai_omp_usage_snapshot >&2
|
|
195
|
+
loaded_skills="$(__ai_omp_skill_instructions "${AI_SESSION_MODES:-}")"
|
|
196
|
+
[[ -n "$loaded_skills" ]] || loaded_skills="$mode_block"
|
|
197
|
+
system_prompt="You are running inside an ai-memory session. The vault is available at $AI_MEM_ROOT. Read the relevant project and session notes when the user gives a task. The local skill and instruction contents below are already loaded. Do not search OMP's separate skill registry; apply these instructions directly. Wait for the user's task before taking action."
|
|
198
|
+
if [[ -n "$model_selector" ]]; then
|
|
199
|
+
system_prompt+=$'\nCurrent provider/model selector: '
|
|
200
|
+
system_prompt+="$model_selector"
|
|
201
|
+
fi
|
|
202
|
+
local ai_mem_bin="${AI_MEM_HOME:h}/bin"
|
|
203
|
+
if [[ -x "$ai_mem_bin/ai-mem-search" ]]; then
|
|
204
|
+
export PATH="$ai_mem_bin:$PATH"
|
|
205
|
+
system_prompt+=$'\nUse the executable ai-mem-search for vault searches. Do not glob or read session-log files directly when answering memory questions; use ai-mem-search so project scope, archived-log filtering, ranking, and output limits remain correct.'
|
|
206
|
+
fi
|
|
207
|
+
if command -v ai-internet-search >/dev/null 2>&1; then
|
|
208
|
+
system_prompt+=$'\nUse ai-internet-search automatically for explicit web research and current or uncertain external facts. Do not substitute raw web-search guesses when this CLI is available.'
|
|
209
|
+
fi
|
|
210
|
+
if [[ -n "$mode_block" ]]; then
|
|
211
|
+
system_prompt+=$'\n\nActive local skill instructions:\n'
|
|
212
|
+
system_prompt+="$loaded_skills"
|
|
213
|
+
fi
|
|
214
|
+
omp --add-dir "$AI_MEM_ROOT" --append-system-prompt "$system_prompt" \
|
|
215
|
+
$provider_args "$memory_prompt" "$@"
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
# --- Example: add another harness by defining its adapter and listing it in
|
|
219
|
+
# AI_MEM_HARNESSES. aider takes the initial instruction via --message:
|
|
100
220
|
# __ai_adapter_aider() {
|
|
101
221
|
# local memory_prompt="$1"
|
|
102
222
|
# aider --message "$memory_prompt"
|