create-ai-memory 0.15.4 → 0.16.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 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 | who you are, your rules, commit policy |
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 an agent with full vault context and the session-skill picker |
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` and `_Standards.md` to make them yours; the shipped versions
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 agent
716
+ ## Add another harness
690
717
 
691
- Launchers are not hardcoded. Each agent is one small adapter, and the
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 `opencode` ship built in.
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 AI_MEM_AGENTS="claude codex agy gemini cursor opencode aider"
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
 
@@ -847,10 +882,14 @@ git -C <repo> config core.hooksPath .githooks
847
882
  | Env var | Default | Purpose |
848
883
  |---|---|---|
849
884
  | `AI_MEM_ROOT` | `$HOME/.ai-memory/_Ai_Memory` | Vault root. Point at any folder, including an existing Obsidian vault |
850
- | `AI_MEM_AGENTS` | `claude codex agy gemini cursor opencode` | Space-separated agents to generate `-start` functions for |
885
+ | `AI_MEM_HARNESSES` | `claude codex agy gemini cursor opencode omp` | Space-separated harnesses to generate `-start` functions for |
886
+ | `AI_MEM_AGENTS` | compatibility alias | Older installs may keep using this name; `AI_MEM_HARNESSES` takes precedence |
887
+ | `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 |
888
+ | `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
889
  | `AI_MEM_SKILLS` / `AI_MEM_SKILL_ORDER` | empty | Your per-session skills (see above) |
852
890
  | `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
891
  | `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 |
892
+ | `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
893
  | `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
894
  | `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
895
  | `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
@@ -64,6 +64,7 @@ function zsh(snippet) {
64
64
  AI_MEM_NOTE_MAX_CHARS: process.env.AI_MEM_NOTE_MAX_CHARS ?? '0',
65
65
  AI_MEM_FORCE_PROJECT: GUI_PROJECT,
66
66
  AI_MEM_GLOBALIZE_ROOT: GUI_ROOT,
67
+ AI_MEM_GLOBAL_SESSION: '1',
67
68
  },
68
69
  maxBuffer: 8 * 1024 * 1024,
69
70
  });
@@ -122,36 +123,33 @@ function insideVault(p) {
122
123
  * before the first turn.
123
124
  *
124
125
  * 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 nothing is pushed, and a
126
- * model with no reason to suspect a memory exists will simply never call a
127
- * tool. Saying so once, up front, is the whole difference.
126
+ * pushed into the agent's opening prompt; over MCP the client must receive a
127
+ * clear context gate before it can act.
128
128
  *
129
- * Kept deliberately short and free of bulk. The obvious move is to inline the
130
- * profile, standards and lesson list here so a GUI gets everything the
131
- * launcher injects -- but instructions are paid on every connection whether
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.
129
+ * Put the non-negotiable rules first because some GUI clients cap or summarize
130
+ * long instruction fields. Keep the full profile and standards after that so
131
+ * clients that preserve the payload have the same source material as CLI runs.
135
132
  */
136
133
  const INSTRUCTIONS = [
134
+ 'HARD RULES — follow these before doing work:',
135
+ '1. Treat _Global_Profile.md and _Standards.md as active instructions, not optional reference material.',
136
+ '2. Call get_context before answering, editing files, using external tools, or creating a commit. If it fails, stop and report the failure.',
137
+ '3. Call search_memory before solving a non-trivial problem or retrying a blocker.',
138
+ '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.',
139
+ '',
137
140
  "This is the user's persistent memory across every AI tool they use: past sessions, project decisions, and lessons learned the hard way.",
138
141
  '',
139
- 'These global profile and standards are active instructions for this session:',
142
+ 'The full global profile and standards follow:',
140
143
  '--- _Global_Profile.md ---',
141
144
  readVaultNote('_Global_Profile.md'),
142
145
  '--- _Standards.md ---',
143
146
  readVaultNote('_Standards.md'),
144
147
  '',
145
- 'Before answering anything about their work, call get_context. It returns their profile, standards, the current project note, and what the last session concluded.',
146
- 'Before solving a problem, call search_memory -- they may have solved it already, and repeating a solved mistake is the failure this vault exists to prevent. Search broadly first; too specific a first query is the usual way to miss something.',
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.',
149
- '',
150
- 'Write back. A session that only reads leaves nothing behind, and the next one starts cold:',
151
- '- add_note for what happened, decided, or broke during this session.',
152
- '- add_lesson for something worth recalling in a DIFFERENT project later. Not project trivia -- the transferable part.',
148
+ 'get_context returns the loaded profile, standards, project context, and latest session digest. Its successful result is the context gate for this session.',
149
+ 'search_memory may contain a prior solution. Search broadly first; use one distinctive word, not a whole sentence.',
153
150
  '',
154
- 'If they ask to see, open or browse their memory rather than search it, call open_graph.',
151
+ 'Write back with add_note for decisions, blockers, and next steps. Use add_lesson only for reusable knowledge that matters in a different project.',
152
+ 'If the user asks to see or browse memory, call open_graph.',
155
153
  ].join('\n');
156
154
 
157
155
  // Descriptions stay terse on purpose. Every schema below is re-sent on each
@@ -173,7 +171,7 @@ const TOOLS = [
173
171
  },
174
172
  {
175
173
  name: 'get_context',
176
- description: 'The user\'s profile, standards, current project note, last session digest, and known lesson topics.',
174
+ description: 'REQUIRED FIRST ACTION. Returns the user\'s active profile, standards, current project note, latest session digest, and lesson topics.',
177
175
  inputSchema: {
178
176
  type: 'object',
179
177
  properties: { project: { type: 'string', description: 'Optional project. Defaults to the GUI global memory project.' } },
@@ -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" "$@"
@@ -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 every .md file in the vault, skipping dotfiles and templates. */
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
- AI_MEM_AGENTS="${AI_MEM_AGENTS:-claude codex agy gemini cursor opencode}"
76
- ask AI_MEM_AGENTS "Which agents should get <agent>-start launchers?" "$AI_MEM_AGENTS"
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 [ "$AI_MEM_AGENTS" != "claude codex agy gemini cursor opencode" ]; then
98
+ if [ "$AI_MEM_HARNESSES" != "claude codex agy gemini cursor opencode omp" ]; then
96
99
  LINES="$LINES
97
- export AI_MEM_AGENTS=\"$AI_MEM_AGENTS\""
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.15.4",
4
- "description": "Persistent, agent-agnostic session memory for AI coding CLIs (Claude Code, Codex, Gemini, Cursor, opencode). One Markdown vault, any agent.",
3
+ "version": "0.16.0",
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.
@@ -95,8 +95,128 @@ __ai_adapter_opencode() {
95
95
  opencode --prompt "$memory_prompt"
96
96
  }
97
97
 
98
- # --- Example: add another agent by defining its adapter and listing it in
99
- # AI_MEM_AGENTS. aider takes the initial instruction via --message:
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"
package/shell/ai-mem.zsh CHANGED
@@ -1,8 +1,8 @@
1
1
  # === AI CLI + Obsidian memory ===
2
2
  # Portable, agent-agnostic session memory. Source this from ~/.zshrc after
3
3
  # exporting AI_MEM_ROOT to point at your vault. Zsh-only (uses print -r, ${(s)},
4
- # and associative arrays). Add a new agent by defining __ai_adapter_<name> in adapters.zsh and
5
- # listing it in AI_MEM_AGENTS; a matching <name>-start function is generated.
4
+ # and associative arrays). Add a new harness by defining __ai_adapter_<name> in adapters.zsh and
5
+ # listing it in AI_MEM_HARNESSES; a matching <name>-start function is generated.
6
6
  #
7
7
  # Private helpers are named __ai_* with TWO leading underscores, deliberately.
8
8
  # Claude Code snapshots the interactive shell and replays that snapshot for
@@ -47,6 +47,18 @@ if [[ -d "$AI_MEM_ROOT" ]]; then
47
47
  AI_MEM_ROOT="$(cd "$AI_MEM_ROOT" && pwd -P)"
48
48
  fi
49
49
  export AI_MEM_ROOT
50
+ # Paths derived from AI_MEM_ROOT. Every function that reads them calls this
51
+ # first rather than trusting the exports made at source time: a shell can carry
52
+ # the functions without the exports (Claude Code's Bash tool replays a snapshot
53
+ # of functions, and only inherited variables survive), and then AI_MEM_SESSION_DIR
54
+ # is empty -- ai-mem-sleep reported "no session logs at -- nothing to do".
55
+ # Only empty ones are filled, so a caller that points one of them elsewhere keeps it.
56
+ __ai_mem_paths() {
57
+ export AI_MEM_GLOBAL="${AI_MEM_GLOBAL:-$AI_MEM_ROOT/_Global_Profile.md}"
58
+ export AI_MEM_STANDARDS="${AI_MEM_STANDARDS:-$AI_MEM_ROOT/_Standards.md}"
59
+ export AI_MEM_PROJECT_DIR="${AI_MEM_PROJECT_DIR:-$AI_MEM_ROOT/_projects}"
60
+ export AI_MEM_SESSION_DIR="${AI_MEM_SESSION_DIR:-$AI_MEM_ROOT/_session_logs}"
61
+ }
50
62
  export AI_MEM_GLOBAL="$AI_MEM_ROOT/_Global_Profile.md"
51
63
  export AI_MEM_STANDARDS="$AI_MEM_ROOT/_Standards.md"
52
64
  export AI_MEM_PROJECT_DIR="$AI_MEM_ROOT/_projects"
@@ -299,6 +311,7 @@ __ai_mem_resolve_project() {
299
311
  }
300
312
 
301
313
  __ai_mem_project_session_dir() {
314
+ __ai_mem_paths
302
315
  local project_name="${1:-}"
303
316
  if [[ -z "$project_name" ]]; then
304
317
  project_name="$(__ai_mem_resolve_project)"
@@ -314,44 +327,10 @@ __ai_mem_project_session_dir() {
314
327
  print -r -- "$AI_MEM_SESSION_DIR/$project_name"
315
328
  }
316
329
 
317
- __ai_mem_graphify_repo_root() {
318
- local git_root=""
319
- git_root="$(git rev-parse --show-toplevel 2>/dev/null)" || true
320
- if [[ -n "$git_root" ]]; then
321
- print -r -- "$git_root"
322
- else
323
- print -r -- "$PWD"
324
- fi
325
- }
326
-
327
- __ai_mem_graphify_context() {
328
- local repo_root="$(__ai_mem_graphify_repo_root)"
329
- local graph_root="$repo_root/graphify-out"
330
- local graph_json="$graph_root/graph.json"
331
- local graph_report="$graph_root/GRAPH_REPORT.md"
332
- local graph_wiki="$graph_root/wiki/index.md"
333
-
334
- if [[ ! -f "$graph_json" ]]; then
335
- return 0
336
- fi
337
-
338
- export AI_GRAPHIFY_ROOT="$graph_root"
339
- export AI_GRAPHIFY_GRAPH_JSON="$graph_json"
340
-
341
- printf '%s\n' \
342
- "Graphify context:" \
343
- "- Knowledge graph available at: $graph_root" \
344
- "- Use graphify query/path/explain before raw grep for codebase or architecture questions." \
345
- "- Read the graph report for broad overviews: $graph_report"
346
-
347
- if [[ -f "$graph_wiki" ]]; then
348
- printf '%s\n' "- Use the wiki index for broad navigation: $graph_wiki"
349
- fi
350
- }
351
-
352
330
  # Returns the newest saved session log for the current project.
353
331
  # The active run gets a fresh log, so this only feeds carryover context.
354
332
  __ai_mem_latest_session_log() {
333
+ __ai_mem_paths
355
334
  local project_name="${1:-}"
356
335
  if [[ -z "$project_name" ]]; then
357
336
  project_name="$(__ai_mem_resolve_project)"
@@ -391,6 +370,7 @@ __ai_mem_latest_session_log() {
391
370
  # Idempotent and additive: it never overwrites a file the user already has, so a
392
371
  # plugin-manager install (source only, no install.sh) still gets a working vault.
393
372
  __ai_mem_ensure_vault() {
373
+ __ai_mem_paths
394
374
  [[ -d "$AI_MEM_TEMPLATE_SRC" ]] || return 0
395
375
  mkdir -p "$AI_MEM_PROJECT_DIR" "$AI_MEM_SESSION_DIR" "$AI_MEM_ROOT/_lessons"
396
376
  local rel
@@ -404,6 +384,15 @@ __ai_mem_ensure_vault() {
404
384
  fi
405
385
  done
406
386
 
387
+ # _about_me/ is seeded as a whole, only when the folder does not exist.
388
+ # Seeding per file would bring back a note the user deleted on purpose,
389
+ # at every launch.
390
+ local about_src="$AI_MEM_TEMPLATE_SRC/_about_me" about_dst="$AI_MEM_ROOT/_about_me"
391
+ if [[ -d "$about_src" && ! -e "$about_dst" ]]; then
392
+ __ai_mem_guard "$about_dst" || return 1
393
+ cp -R "$about_src" "$about_dst"
394
+ fi
395
+
407
396
  # Seeding only fills in a MISSING file, which is right -- these are the
408
397
  # user's notes and templates, and an upgrade must not overwrite edits they
409
398
  # made. But that leaves an existing vault on whatever templates it had
@@ -446,6 +435,7 @@ __ai_mem_ensure_vault() {
446
435
  }
447
436
 
448
437
  __ai_mem_prepare_session() {
438
+ __ai_mem_paths
449
439
  local project_name="${1:-}"
450
440
  if [[ -z "$project_name" ]]; then
451
441
  project_name="$(__ai_mem_resolve_project)"
@@ -453,7 +443,16 @@ __ai_mem_prepare_session() {
453
443
 
454
444
  __ai_mem_ensure_vault || return 1
455
445
 
456
- local project_note="$AI_MEM_PROJECT_DIR/${project_name}.md"
446
+ # GUI/MCP memory has no repository project. Keep its session records
447
+ # lightweight instead of copying repository-oriented templates.
448
+ local global_session=0
449
+ [[ "${AI_MEM_GLOBAL_SESSION:-}" == "1" ]] && global_session=1
450
+
451
+ local project_note=""
452
+ if (( ! global_session )); then
453
+ project_note="$AI_MEM_PROJECT_DIR/${project_name}.md"
454
+ fi
455
+
457
456
  local project_session_dir
458
457
  project_session_dir="$(__ai_mem_project_session_dir "$project_name")"
459
458
  local previous_session_note=""
@@ -461,12 +460,14 @@ __ai_mem_prepare_session() {
461
460
  local session_stamp="$(date +%Y-%m-%d_%H-%M-%S)"
462
461
  local session_note="$project_session_dir/${project_name}-${session_stamp}.md"
463
462
 
464
- __ai_mem_guard "$project_note" || return 1
463
+ if (( ! global_session )); then
464
+ __ai_mem_guard "$project_note" || return 1
465
+ fi
465
466
  __ai_mem_guard "$session_note" || return 1
466
467
 
467
468
  mkdir -p "$AI_MEM_PROJECT_DIR" "$AI_MEM_SESSION_DIR" "$project_session_dir"
468
469
 
469
- if [[ ! -f "$project_note" ]]; then
470
+ if (( ! global_session )) && [[ ! -f "$project_note" ]]; then
470
471
  PROJECT_NAME="$project_name" perl -0pe 's/\[Insert Project Name\]/$ENV{PROJECT_NAME}/g' \
471
472
  "$AI_MEM_PROJECT_DIR/_project_template.md" > "$project_note"
472
473
  fi
@@ -491,8 +492,13 @@ __ai_mem_prepare_session() {
491
492
  # Context reads can follow a GUI write in the same second. Reusing an
492
493
  # existing timestamped note preserves Live Notes and any other append.
493
494
  if [[ ! -f "$session_note" ]]; then
494
- SESSION_DATE="$(date +%Y-%m-%d)" PROJECT_NAME="$project_name" PREV_LINK="$prev_link" perl -0pe 's/\{\{date\}\}/$ENV{SESSION_DATE}/g; s/\{\{project_name\}\}/$ENV{PROJECT_NAME}/g; s/\{\{previous_session_link\}\}/$ENV{PREV_LINK}/g' \
495
- "$AI_MEM_SESSION_DIR/_session_template.md" > "$session_note"
495
+ if (( global_session )); then
496
+ local session_date="$(date +%Y-%m-%d)"
497
+ print -rl -- "---" "type: ai-global-session" "date: $session_date" "previous: \"$prev_link\"" "---" "" "# Global Session Notes" > "$session_note"
498
+ else
499
+ SESSION_DATE="$(date +%Y-%m-%d)" PROJECT_NAME="$project_name" PREV_LINK="$prev_link" perl -0pe 's/\{\{date\}\}/$ENV{SESSION_DATE}/g; s/\{\{project_name\}\}/$ENV{PROJECT_NAME}/g; s/\{\{previous_session_link\}\}/$ENV{PREV_LINK}/g' \
500
+ "$AI_MEM_SESSION_DIR/_session_template.md" > "$session_note"
501
+ fi
496
502
  fi
497
503
 
498
504
  export AI_MEM_ACTIVE_PROJECT="$project_name"
@@ -563,7 +569,136 @@ __ai_mem_lesson_index() {
563
569
  return 0
564
570
  }
565
571
 
572
+ # The human side of the profile: who the user is, what they want, and what
573
+ # they refuse. It lives in _about_me/ as several small notes rather than one
574
+ # file, because one file grows until the note cap truncates it -- which is
575
+ # exactly what happens to a long _Global_Profile.md.
576
+ #
577
+ # Each note says in frontmatter how it reaches the agent:
578
+ # inject: always -> body inlined at the TOP of the prompt. For hard
579
+ # "no"s: a rule the agent must open a file to see is
580
+ # a rule it will often never see.
581
+ # anything else -> one index line naming the file and `read_when:`,
582
+ # the trigger that tells the agent WHEN to open it.
583
+ # A bare link with no trigger is routinely ignored.
584
+ # An `always` note is capped separately and tightly (AI_MEM_ABOUT_ME_MAX_CHARS),
585
+ # so growth there shows up as a truncation notice instead of silent bloat.
586
+ #
587
+ # A note that is still only template scaffolding (headings, blockquotes,
588
+ # [bracketed] placeholder bullets) is skipped: pointing the agent at a blank
589
+ # template reads as context and carries none. Blockquotes and placeholder
590
+ # bullets are also dropped from an injected body -- they are notes to the
591
+ # user, and every character there is paid for in every session. Notes whose
592
+ # name starts with `_` are skipped, matching every other folder's templates.
593
+ #
594
+ # Usage: __ai_mem_about_me always|index
595
+ __ai_mem_about_me() {
596
+ local mode="${1:-}" dir="$AI_MEM_ROOT/_about_me"
597
+ [[ -d "$dir" ]] || return 0
598
+
599
+ local -a notes
600
+ notes=("$dir"/*.md(N.on))
601
+ (( $#notes )) || return 0
602
+
603
+ local f fm inject read_when body cap="${AI_MEM_ABOUT_ME_MAX_CHARS:-1500}"
604
+ local -a index_lines
605
+ for f in $notes; do
606
+ [[ "${f:t}" == _* ]] && continue
607
+ __ai_mem_guard "$f" || return 1
608
+
609
+ # Frontmatter only when line 1 opens it, so prose can never pose as
610
+ # a declaration (same rule as mirror_of).
611
+ fm=""
612
+ [[ "$(head -1 "$f")" == "---" ]] && fm="$(sed -n '2,/^---$/p' "$f")"
613
+ # Values may be YAML-quoted; sed strips the key, surrounding space,
614
+ # and one pair of quotes.
615
+ inject="$(print -r -- "$fm" | sed -n "s/^inject:[[:space:]]*[\"']\{0,1\}\([^\"']*\)[\"']\{0,1\}[[:space:]]*\$/\1/p" | head -1)"
616
+ read_when="$(print -r -- "$fm" | sed -n "s/^read_when:[[:space:]]*[\"']\{0,1\}\([^\"']*\)[\"']\{0,1\}[[:space:]]*\$/\1/p" | head -1)"
617
+
618
+ # Body without frontmatter, blockquotes, or placeholder bullets; empty
619
+ # when nothing but scaffolding is left.
620
+ body="$(awk '
621
+ NR == 1 && $0 == "---" { fm = 1; next }
622
+ fm { if ($0 == "---") fm = 0; next }
623
+ /^>/ || /^[*-][[:space:]]+\[[^]]*\][[:space:]]*$/ { next }
624
+ /^[[:space:]]*$/ { if (n && lines[n] != "") lines[++n] = ""; next }
625
+ { lines[++n] = $0 }
626
+ !/^#/ { filled = 1 }
627
+ END { if (filled) for (i = 1; i <= n; i++) print lines[i] }
628
+ ' "$f")"
629
+ [[ -n "${body//[[:space:]]/}" ]] || continue
630
+
631
+ if [[ "$inject" == always ]]; then
632
+ [[ "$mode" == always ]] || continue
633
+ print -r -- "- About me -- ${f:t} (always in force):"
634
+ AI_MEM_NOTE_MAX_CHARS="$cap" __ai_mem_cap_note "$body" "$f"
635
+ print
636
+ else
637
+ [[ "$mode" == index ]] || continue
638
+ index_lines+=(" * ${f:t}: ${read_when:-read when relevant to the task} -- $f")
639
+ fi
640
+ done
641
+
642
+ if [[ "$mode" == index ]] && (( $#index_lines )); then
643
+ print -r -- "- About me -- more notes, NOT included here. Read a file with \`cat\` when its trigger applies:"
644
+ print -rl -- $index_lines
645
+ fi
646
+ return 0
647
+ }
648
+
649
+ # Tell the HUMAN, once per vault, that _about_me/ is still blank. It goes to
650
+ # stderr and never into the prompt: an agent told "this is empty" at every
651
+ # launch would nag the user about it in every session. The marker lives in
652
+ # the vault, so each vault (and each test fixture) is hinted independently.
653
+ __ai_mem_about_me_hint() {
654
+ local dir="$AI_MEM_ROOT/_about_me"
655
+ local marker="$dir/.about-me-hinted"
656
+ [[ -d "$dir" && ! -e "$marker" ]] || return 0
657
+ [[ -z "$(__ai_mem_about_me index 2>/dev/null)" ]] || return 0
658
+ print -r -- "ai-memory: _about_me/ has only placeholders. Run 'ai-about-me' to fill it by interview. (Shown once.)" >&2
659
+ __ai_mem_guard "$marker" && : > "$marker"
660
+ return 0
661
+ }
662
+
663
+ # Fill _about_me/ by interview, or review it against the vault's evidence.
664
+ #
665
+ # ai-about-me [harness] interview: one question at a time
666
+ # ai-about-me --review [harness] propose rules from lessons and session logs
667
+ #
668
+ # The agent is started like <harness>-start, with the protocol from
669
+ # about-me-interview.md or about-me-review.md as the session's task. The
670
+ # protocols are written for the agent: ask before writing, draft for approval,
671
+ # never add a rule the user did not state. A self-edited profile stops being
672
+ # the user's own view of themselves.
673
+ ai-about-me() {
674
+ __ai_mem_paths
675
+ local mode=interview
676
+ case "${1:-}" in
677
+ --review) mode=review; shift ;;
678
+ -h|--help)
679
+ print -r -- "usage: ai-about-me [--review] [harness]"
680
+ print -r -- " Interview: the agent asks one question at a time and fills _about_me/ after you approve each draft."
681
+ print -r -- " --review: the agent proposes rules from your lessons and session logs; you accept or reject each one."
682
+ return 0 ;;
683
+ -*) print -r -- "ai-about-me: unknown option '$1' (see ai-about-me --help)" >&2; return 1 ;;
684
+ esac
685
+
686
+ local protocol="$AI_MEM_HOME/about-me-$mode.md"
687
+ if [[ ! -f "$protocol" ]]; then
688
+ print -r -- "ai-about-me: protocol file not found: $protocol" >&2
689
+ return 1
690
+ fi
691
+ local launcher="${1:-${${(z)AI_MEM_HARNESSES}[1]}}"
692
+ (( $# )) && shift
693
+
694
+ __ai_mem_ensure_vault || return 1
695
+ local task
696
+ task="$(<"$protocol")"$'\n\n'"The notes are in: $AI_MEM_ROOT/_about_me/"
697
+ AI_MEM_SESSION_TASK="$task" __ai_session_start "$launcher" "$@"
698
+ }
699
+
566
700
  __ai_mem_context_prompt() {
701
+ __ai_mem_paths
567
702
  local project_note="${1:-}"
568
703
  local previous_session_note="${2:-}"
569
704
  local session_note="${3:-}"
@@ -606,16 +741,27 @@ __ai_mem_context_prompt() {
606
741
  if [[ -f "$project_note" ]] && grep -q '\[What problem this repository solves\]' "$project_note" 2>/dev/null; then
607
742
  project_state=" -- NOT YET FILLED IN: it is still the blank template, so it holds no context. Read the repo (README, package manifest, AGENTS.md/CLAUDE.md, recent git log) and fill it in early in this session; every future session on this repo starts from it."
608
743
  fi
744
+ local project_label="$project_note"
745
+ [[ -n "$project_label" ]] || project_label="none (GUI/MCP global memory; no repository context)"
746
+ # Hard "no"s go first: models follow early instructions most reliably,
747
+ # and the note cap truncates from the end. The index sits with the other
748
+ # pointers. Each block carries its own trailing newline so an absent
749
+ # _about_me/ leaves the prompt byte-identical to before.
750
+ local about_always about_index
751
+ about_always="$(__ai_mem_about_me always)" || return 1
752
+ about_index="$(__ai_mem_about_me index)" || return 1
753
+ [[ -n "$about_always" ]] && about_always+=$'\n\n'
754
+ [[ -n "$about_index" ]] && about_index+=$'\n'
609
755
 
610
756
  cat <<EOF
611
757
  Read these notes before doing anything else:
612
- - Global profile:
758
+ ${about_always}- Global profile:
613
759
  $(__ai_mem_note_contents "$AI_MEM_GLOBAL")
614
760
 
615
761
  - Standards:
616
762
  $(__ai_mem_note_contents "$AI_MEM_STANDARDS")
617
763
 
618
- - Project context: $project_note$project_state
764
+ ${about_index}- Project context: $project_label$project_state
619
765
  $previous_session_block
620
766
  - Active session log: $session_note
621
767
  $(__ai_mem_lesson_index)
@@ -623,7 +769,7 @@ $(__ai_mem_lesson_index)
623
769
  Use the Obsidian vault as the persistent memory layer.
624
770
  Treat the global profile and standards note as the shared baseline for every run.
625
771
  Keep durable preferences and project facts in the vault, and keep the active session log updated with decisions, blockers, and next steps.
626
- For anything not covered above -- a decision from further back, a different project, a health check on the vault's links -- run \`ai-mem-search <term> [project]\` or \`ai-mem-lint\` yourself; both are zsh functions from the sourced module, so \`command -v\` finds them but \`which\` under bash will not. Search is case-insensitive and matches literally, and its output is capped: if it reports results hidden, narrow with a project argument or a more specific term rather than assuming you have seen everything. Start broad and narrow from there -- a first query that is too specific is the usual way to miss what you were looking for.
772
+ For anything not covered above -- a decision from further back, a different project, a health check on the vault's links -- run \`ai-mem-search <term> [project]\` or \`ai-mem-lint\` yourself. Search is case-insensitive and matches literally, and its output is capped: if it reports results hidden, narrow with a project argument or a more specific term rather than assuming you have seen everything. Start broad and narrow from there -- a first query that is too specific is the usual way to miss what you were looking for.
627
773
  When you hit a blocker -- an error you do not immediately understand, a test failing for an unclear reason, a decision you cannot settle from the code in front of you, or a second failed attempt at the same thing -- search the vault BEFORE guessing again. You have likely been here before, and \`_lessons/\` exists because the answer usually was written down; lessons are ranked above session logs in the results, so a hit under \`_lessons/\` is the recorded fix.
628
774
  Search ONE distinctive word, not a sentence. Matching is literal substring, so a whole error line ('command not found: sed') finds nothing while 'command not found' finds it, and a bare tool name ('sed', 'git') returns hundreds of irrelevant lines. Pick the most unusual word in the symptom and try two or three of them separately.
629
775
  If the user asks to see, open or browse their memory rather than search it, run \`ai-mem-serve\` -- it opens the vault as a graph in their browser, and is safe to run again if it is already up.
@@ -633,6 +779,7 @@ EOF
633
779
 
634
780
  # Mark the current shell as having loaded AI vault context for the active repo.
635
781
  __ai_mem_mark_commit_ready() {
782
+ __ai_mem_paths
636
783
  local project_name="${1:-}"
637
784
  local source="${2:-ai-context}"
638
785
  local ready_dir="$AI_MEM_SESSION_DIR/.context-ready"
@@ -681,6 +828,7 @@ __ai_mem_export_active() {
681
828
  }
682
829
 
683
830
  ai-start() {
831
+ __ai_mem_paths
684
832
  local project_name="${1:-}"
685
833
  shift || true
686
834
 
@@ -746,6 +894,19 @@ __ai_yesno() {
746
894
  typeset -gA AI_MEM_SKILLS
747
895
  typeset -ga AI_MEM_SKILL_ORDER
748
896
 
897
+ # When OMP is the preferred harness, preserve the requested *-start provider.
898
+ # Override these maps before sourcing this file when a provider uses a custom
899
+ # OMP name or model. An unmapped launcher falls back to its own name.
900
+ typeset -gA AI_MEM_OMP_PROVIDERS
901
+ typeset -gA AI_MEM_OMP_MODELS
902
+ [[ -n "${AI_MEM_OMP_PROVIDERS[codex]:-}" ]] || AI_MEM_OMP_PROVIDERS[codex]=openai-codex
903
+ [[ -n "${AI_MEM_OMP_PROVIDERS[claude]:-}" ]] || AI_MEM_OMP_PROVIDERS[claude]=anthropic
904
+ [[ -n "${AI_MEM_OMP_PROVIDERS[gemini]:-}" ]] || AI_MEM_OMP_PROVIDERS[gemini]=google
905
+ [[ -n "${AI_MEM_OMP_PROVIDERS[agy]:-}" ]] || AI_MEM_OMP_PROVIDERS[agy]=google
906
+ [[ -n "${AI_MEM_OMP_PROVIDERS[opencode]:-}" ]] || AI_MEM_OMP_PROVIDERS[opencode]=opencode
907
+ [[ -n "${AI_MEM_OMP_PROVIDERS[cursor]:-}" ]] || AI_MEM_OMP_PROVIDERS[cursor]=cursor
908
+ [[ -n "${AI_MEM_OMP_MODELS[claude]:-}" ]] || AI_MEM_OMP_MODELS[claude]=claude-sonnet-4-5
909
+
749
910
  # Ask which optional skills to enable. Each is independent; answer y/n per skill.
750
911
  # Echoes a pipe-joined list of chosen keys; empty means a plain session.
751
912
  __ai_session_modes_pick() {
@@ -770,11 +931,20 @@ __ai_session_modes_instructions() {
770
931
 
771
932
  # Start an AI client with the shared memory block and the chosen session mode.
772
933
  __ai_session_start() {
773
- local launcher="${1:-}"
934
+ local requested_launcher="${1:-}"
935
+ local launcher="${AI_MEM_PREFERRED_HARNESS:-$requested_launcher}"
774
936
  if (( $# > 0 )); then
775
937
  shift
776
938
  fi
777
939
 
940
+ if [[ -n "${AI_MEM_PREFERRED_HARNESS:-}" && "$requested_launcher" != "$launcher" ]]; then
941
+ echo "ai-memory: $requested_launcher-start is using preferred harness $launcher" >&2
942
+ fi
943
+ # Keep the user's requested launcher visible to a preferred harness. This
944
+ # lets one OMP harness route codex-start and claude-start to different
945
+ # providers instead of silently using OMP's default provider for both.
946
+ export AI_MEM_REQUESTED_LAUNCHER="$requested_launcher"
947
+
778
948
  # Warn (never block) if this shell is running a stale copy. Everything
779
949
  # below would otherwise succeed quietly using the old behaviour, and the
780
950
  # only symptom is a fix that appears not to have worked.
@@ -791,7 +961,7 @@ __ai_session_start() {
791
961
  # session log is created. Cursor is exempt: its adapter falls back to opening
792
962
  # the app when the `cursor` CLI is absent.
793
963
  if [[ "$launcher" != cursor ]] && ! command -v "$launcher" >/dev/null 2>&1; then
794
- echo "ai-memory: '$launcher' CLI not found on PATH. Install it, or drop it from AI_MEM_AGENTS." >&2
964
+ echo "ai-memory: '$launcher' CLI not found on PATH. Install it, or remove it from AI_MEM_HARNESSES." >&2
795
965
  return 1
796
966
  fi
797
967
 
@@ -803,7 +973,12 @@ __ai_session_start() {
803
973
  __ai_mem_export_active "$active_project" "$previous_session_note" "$session_note"
804
974
 
805
975
  local session_modes mode_block
806
- session_modes="$(__ai_session_modes_pick)" || return 1
976
+ if [[ -n "${AI_MEM_MANUAL_SKILLS:-}" ]]; then
977
+ # One-off opt-in for skills that should not appear in the startup picker.
978
+ session_modes="$AI_MEM_MANUAL_SKILLS"
979
+ else
980
+ session_modes="$(__ai_session_modes_pick)" || return 1
981
+ fi
807
982
  mode_block="$(__ai_session_modes_instructions "$session_modes")"
808
983
 
809
984
  # AI_SESSION_MODES carries the chosen skill keys; AI_SESSION_STYLE_LABEL
@@ -814,14 +989,10 @@ __ai_session_start() {
814
989
  local memory_prompt
815
990
  memory_prompt="$(__ai_mem_context_prompt "$project_note" "$previous_session_note" "$session_note")"
816
991
 
817
- local graphify_context=""
818
- graphify_context="$(__ai_mem_graphify_context)" || return 1
819
- if [[ -n "$graphify_context" ]]; then
820
- memory_prompt+=$'\n\n'
821
- memory_prompt+="$graphify_context"
822
- fi
823
-
824
- if [[ -n "$mode_block" ]]; then
992
+ # OMP receives the selected skill files through its system-prompt channel;
993
+ # do not duplicate the short picker blocks in its opening user message,
994
+ # where OMP can mistake names such as "caveman skill" for skill:// refs.
995
+ if [[ -n "$mode_block" && "$launcher" != omp ]]; then
825
996
  memory_prompt+=$'\n\n'
826
997
  memory_prompt+="$mode_block"
827
998
  fi
@@ -829,6 +1000,15 @@ __ai_session_start() {
829
1000
  memory_prompt+=$'\n\n'
830
1001
  memory_prompt+="$session_prompt"
831
1002
  fi
1003
+ # A task for the whole session (e.g. the ai-about-me interview). It rides
1004
+ # in the opening message only: adapters also forward "$@" as CLI args,
1005
+ # so passing it as an argument would send it twice to some harnesses.
1006
+ if [[ -n "${AI_MEM_SESSION_TASK:-}" ]]; then
1007
+ memory_prompt+=$'\n\n'
1008
+ memory_prompt+="$AI_MEM_SESSION_TASK"
1009
+ else
1010
+ __ai_mem_about_me_hint
1011
+ fi
832
1012
 
833
1013
  __ai_mem_mark_commit_ready "$active_project" "$launcher-start" || return 1
834
1014
 
@@ -842,12 +1022,14 @@ __ai_session_start() {
842
1022
  "__ai_adapter_$launcher" "$memory_prompt" "$mode_block" "$@"
843
1023
  }
844
1024
 
845
- # Load the agent adapters, then generate a <name>-start launcher for every
846
- # registered agent that has a matching adapter. Users extend by appending to
847
- # AI_MEM_AGENTS (space-separated) and defining __ai_adapter_<name>.
1025
+ # Load the harness adapters, then generate a <name>-start launcher for every
1026
+ # registered harness that has a matching adapter. AI_MEM_HARNESSES is preferred;
1027
+ # AI_MEM_AGENTS remains a compatibility alias for existing installs.
848
1028
  source "$AI_MEM_HOME/adapters.zsh"
849
- : "${AI_MEM_AGENTS:=claude codex agy gemini cursor opencode}"
850
- for _ai_agent in ${(z)AI_MEM_AGENTS}; do
1029
+ : "${AI_MEM_HARNESSES:=${AI_MEM_AGENTS:-claude codex agy gemini cursor opencode omp}}"
1030
+ export AI_MEM_HARNESSES
1031
+ export AI_MEM_AGENTS="$AI_MEM_HARNESSES"
1032
+ for _ai_agent in ${(z)AI_MEM_HARNESSES}; do
851
1033
  if typeset -f "__ai_adapter_$_ai_agent" >/dev/null; then
852
1034
  # A same-named alias (e.g. from another plugin) makes zsh refuse to
853
1035
  # `eval` a function definition of that name at all -- "defining
@@ -864,6 +1046,7 @@ __ai_mem_current_project() {
864
1046
  }
865
1047
 
866
1048
  __ai_mem_today_session_log() {
1049
+ __ai_mem_paths
867
1050
  local project_name="${1:-}"
868
1051
  if [[ -z "$project_name" ]]; then
869
1052
  project_name="$(__ai_mem_resolve_project)"
@@ -1126,6 +1309,7 @@ ai-mem-ingest() {
1126
1309
  # "isolated dots in Graph View" class of problem before you have to notice it
1127
1310
  # by eye.
1128
1311
  ai-mem-lint() {
1312
+ __ai_mem_paths
1129
1313
  local fix=0
1130
1314
  [[ "${1:-}" == "--fix" ]] && fix=1
1131
1315
  local issues=0 f label target found
@@ -1291,6 +1475,7 @@ ai-mem-lint() {
1291
1475
  # AI_MEM_SLEEP_DAYS archive logs older than this many days (default 90)
1292
1476
  # AI_MEM_SLEEP_CONSOLIDATE flag a project with this many hot logs (default 8)
1293
1477
  ai-mem-sleep() {
1478
+ __ai_mem_paths
1294
1479
  local apply=0
1295
1480
  [[ "${1:-}" == "--apply" ]] && apply=1
1296
1481
 
@@ -1489,6 +1674,7 @@ ai-mem-sleep-schedule() {
1489
1674
  # because a flag only helps if whoever's calling this remembers it exists,
1490
1675
  # and the whole point is not depending on that.
1491
1676
  ai-mem-search() {
1677
+ __ai_mem_paths
1492
1678
  local term="${1:-}"
1493
1679
  local project="${2:-}"
1494
1680
  if [[ -z "$term" ]]; then
@@ -0,0 +1,15 @@
1
+ ---
2
+ type: ai-about-me
3
+ inject: index
4
+ read_when: before you explain something or decide how much detail to give
5
+ ---
6
+
7
+ # Expertise
8
+
9
+ > Write this note yourself. An agent may propose a change, but it must not
10
+ > edit this note without your approval. ai-mem does not inject this note. It
11
+ > puts one index line in the prompt: the file name and `read_when`. Replace
12
+ > the [bracketed] bullets. A note that has only placeholders is not listed.
13
+
14
+ * [Strong in: ... -- skip the basics here]
15
+ * [Learning: ... -- explain these]
@@ -0,0 +1,15 @@
1
+ ---
2
+ type: ai-about-me
3
+ inject: index
4
+ read_when: before you take a shortcut on design, on architecture, or on a skill I want to learn
5
+ ---
6
+
7
+ # Interests
8
+
9
+ > Write this note yourself. An agent may propose a change, but it must not
10
+ > edit this note without your approval. ai-mem does not inject this note. It
11
+ > puts one index line in the prompt: the file name and `read_when`. Replace
12
+ > the [bracketed] bullets. A note that has only placeholders is not listed.
13
+
14
+ * [A long-term goal that outranks a quick shortcut, e.g. "I keep architecture decisions: show the tradeoff, do not decide for me"]
15
+ * [A skill you want to keep practising yourself instead of handing it to the agent]
@@ -0,0 +1,15 @@
1
+ ---
2
+ type: ai-about-me
3
+ inject: index
4
+ read_when: when it is not clear if I want you to act now or to explore options first
5
+ ---
6
+
7
+ # Modes
8
+
9
+ > Write this note yourself. An agent may propose a change, but it must not
10
+ > edit this note without your approval. ai-mem does not inject this note. It
11
+ > puts one index line in the prompt: the file name and `read_when`. Replace
12
+ > the [bracketed] bullets. A note that has only placeholders is not listed.
13
+
14
+ * [Acceleration: the words you use when you know the next step and want it done fast]
15
+ * [Exploration: the words you use when you are unsure and want options with evidence]
@@ -0,0 +1,15 @@
1
+ ---
2
+ type: ai-about-me
3
+ inject: always
4
+ ---
5
+
6
+ # Non-negotiables
7
+
8
+ > Hard "no"s. ai-mem injects this note in full at the top of every session,
9
+ > capped at 1500 characters (AI_MEM_ABOUT_ME_MAX_CHARS). Keep it short. Give
10
+ > each rule its reason, so the agent can apply it to cases the rule does not
11
+ > name. Write this note yourself. An agent may propose a change, but it must
12
+ > not edit this note without your approval.
13
+
14
+ * Do not agree with me only to please me. If my request conflicts with evidence or with these notes, say so first and show the evidence. Why: a stored user profile makes models agree more (Jain et al., CHI '26).
15
+ * [Another hard "no" -- and why it matters to you]
@@ -0,0 +1,15 @@
1
+ ---
2
+ type: ai-about-me
3
+ inject: index
4
+ read_when: when you judge whether work is good enough to hand back
5
+ ---
6
+
7
+ # Values
8
+
9
+ > Write this note yourself. An agent may propose a change, but it must not
10
+ > edit this note without your approval. ai-mem does not inject this note. It
11
+ > puts one index line in the prompt: the file name and `read_when`. Replace
12
+ > the [bracketed] bullets. A note that has only placeholders is not listed.
13
+
14
+ * [What "good work" means to you]
15
+ * [A tradeoff you always resolve the same way, e.g. correctness before speed]
@@ -0,0 +1,15 @@
1
+ ---
2
+ type: ai-about-me
3
+ inject: index
4
+ read_when: before you plan work or choose an approach
5
+ ---
6
+
7
+ # Wants
8
+
9
+ > Write this note yourself. An agent may propose a change, but it must not
10
+ > edit this note without your approval. ai-mem does not inject this note. It
11
+ > puts one index line in the prompt: the file name and `read_when`. Replace
12
+ > the [bracketed] bullets. A note that has only placeholders is not listed.
13
+
14
+ * [How you like work to be done -- a default you may override per task]
15
+ * [What a good answer looks like to you]
package/web/viewer.html CHANGED
@@ -207,6 +207,7 @@ const TYPE_COLOR = {
207
207
  'ai-session-log': '#8b8681',
208
208
  'ai-global-profile': '#b45309',
209
209
  'ai-standards': '#b45309',
210
+ 'ai-about-me': '#b45309',
210
211
  'proposal': '#7c3aed',
211
212
  'untyped': '#a8a29a',
212
213
  };