create-ai-memory 0.16.3 → 0.16.4
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 +4 -4
- package/package.json +1 -1
- package/shell/ai-mem.zsh +66 -26
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ sequenceDiagram
|
|
|
94
94
|
Agent->>Backup: commit + push, if the vault is git-backed
|
|
95
95
|
Note over Vault: nothing overwritten -- a fresh file every session
|
|
96
96
|
Note over Sleep: overnight, unattended -- installed by ai-mem-sleep-schedule
|
|
97
|
-
Sleep->>Vault: archive
|
|
97
|
+
Sleep->>Vault: archive unfilled logs after a day, logs older than 90d (newest 5 filled kept)
|
|
98
98
|
Sleep->>Vault: lint links, flag dangling wikilinks and consolidation candidates
|
|
99
99
|
Sleep->>Backup: commit + push the archive move, if the vault is git-backed
|
|
100
100
|
Note over Vault,Sleep: _lessons/ are never archived and never pruned
|
|
@@ -316,9 +316,9 @@ optional. Set `AI_MEM_ROOT` in `~/.zshrc` first if you do not want the default
|
|
|
316
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
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 |
|
|
318
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 |
|
|
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 |
|
|
319
|
+
| `ai-mem-lint [--fix]` | Check the vault's links: orphaned session logs, dangling `previous` links (a link to a log in the project's `_archive/` resolves, as it does in Obsidian), 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 |
|
|
320
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 |
|
|
321
|
-
| `ai-mem-sleep [--apply]` | The vault's "bedtime" pass: archive stale session logs, flag consolidation candidates, and lint, in one run. Session logs older than `AI_MEM_SLEEP_DAYS` (default 90) move out of the hot search path -- always keeping the newest `AI_MEM_SLEEP_KEEP` (default 5) per project -- while `_lessons/` are never touched, because durable failure->fix knowledge is exactly what must survive. Dry-run by default; `--apply` moves logs into each project's `_archive/` (reversible via git) and backs up |
|
|
321
|
+
| `ai-mem-sleep [--apply]` | The vault's "bedtime" pass: archive stale session logs, flag consolidation candidates, and lint, in one run. Session logs older than `AI_MEM_SLEEP_DAYS` (default 90) move out of the hot search path -- always keeping the newest `AI_MEM_SLEEP_KEEP` (default 5) filled logs per project -- while `_lessons/` are never touched, because durable failure->fix knowledge is exactly what must survive. An **unfilled** log -- the template with nothing written, plus at most an Auto Session Log that saw no commits and a clean tree -- is archived once it is dated before yesterday, and never takes a KEEP slot: most sessions close without a note, and counting them pushed every real log out of the hot set. Dry-run by default; `--apply` moves logs into each project's `_archive/` (reversible via git) and backs up |
|
|
322
322
|
| `ai-mem-sleep-schedule [--install\|--uninstall] [--at HH:MM]` | Run the bedtime pass on its own, nightly (default 03:00). macOS installs a launchd agent; other platforms a crontab entry. The scheduled job sources the module first, since a cron/launchd shell does not read `~/.zshrc`. Dry-run by default -- prints exactly what it would install; `--install` schedules it, `--uninstall` removes it |
|
|
323
323
|
| `ai-mem-serve [port] [--no-open]` | Open the vault as a browsable graph on `127.0.0.1`. Agents run this for you when you ask to see your memory (see [Graph view](#graph-view)) |
|
|
324
324
|
| `ai-mem-vault-backup` | Commit and push the vault if it's git-backed. `ai-note`/`ai-lesson` already call this; use it directly after editing a session log or project note by hand |
|
|
@@ -551,7 +551,7 @@ away what was hard to learn.
|
|
|
551
551
|
|---|---|---|
|
|
552
552
|
| **Strengthen** | A lesson recalled again ranks higher, not just newer -- long-term potentiation for the vault. | `ai-mem-search` ranking |
|
|
553
553
|
| **Consolidate** | Many session logs about one thing distil into a single durable lesson. | `ai-lesson` |
|
|
554
|
-
| **Decay** | Old session logs move out of the hot search path into `_archive/`, still on disk and in git. | `ai-mem-sleep` |
|
|
554
|
+
| **Decay** | Old session logs move out of the hot search path into `_archive/`, still on disk and in git. Unfilled logs go after a day. | `ai-mem-sleep` |
|
|
555
555
|
| **Prune (detect)** | A dangling `[[wikilink]]` -- a dead edge -- is surfaced, never auto-removed. | `ai-mem-lint` |
|
|
556
556
|
| **Schedule** | Run the whole pass nightly on its own. | `ai-mem-sleep-schedule` |
|
|
557
557
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ai-memory",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
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",
|
package/shell/ai-mem.zsh
CHANGED
|
@@ -1381,7 +1381,7 @@ ai-mem-lint() {
|
|
|
1381
1381
|
__ai_mem_paths
|
|
1382
1382
|
local fix=0
|
|
1383
1383
|
[[ "${1:-}" == "--fix" ]] && fix=1
|
|
1384
|
-
local issues=0 f label target
|
|
1384
|
+
local issues=0 f label target
|
|
1385
1385
|
# Open Knowledge Format names exactly one required frontmatter field:
|
|
1386
1386
|
# `type`. Every note the vault ships already declares one except session
|
|
1387
1387
|
# logs, which predate the field -- so a vault that has been in use carries
|
|
@@ -1403,8 +1403,10 @@ ai-mem-lint() {
|
|
|
1403
1403
|
if [[ "$label" == *'[['* ]]; then
|
|
1404
1404
|
target="${label#*\[\[}"
|
|
1405
1405
|
target="${target%%\]\]*}"
|
|
1406
|
-
|
|
1407
|
-
|
|
1406
|
+
# ai-mem-sleep moves older logs into the project's _archive/, and
|
|
1407
|
+
# Obsidian resolves a link by basename anywhere in the vault. A
|
|
1408
|
+
# link to an archived log still opens, so it is not dangling.
|
|
1409
|
+
if [[ ! -f "${f:h}/${target}.md" && ! -f "${f:h}/_archive/${target}.md" ]]; then
|
|
1408
1410
|
print -r -- "dangling previous link: $f -> [[${target}]] (not found)"
|
|
1409
1411
|
(( issues++ ))
|
|
1410
1412
|
fi
|
|
@@ -1530,6 +1532,27 @@ ai-mem-lint() {
|
|
|
1530
1532
|
return $(( issues > 0 ? 1 : 0 ))
|
|
1531
1533
|
}
|
|
1532
1534
|
|
|
1535
|
+
# Prints each given session log that holds nothing a later session can use:
|
|
1536
|
+
# frontmatter, the template heading, [placeholder] bullets, and at most an
|
|
1537
|
+
# Auto Session Log block that recorded no commits and a clean tree. These are
|
|
1538
|
+
# sessions that were opened and closed with nothing written. One awk pass over
|
|
1539
|
+
# all files. A 0-byte file is never printed, so it is never archived.
|
|
1540
|
+
__ai_mem_unfilled_logs() {
|
|
1541
|
+
(( $# )) || return 0
|
|
1542
|
+
awk '
|
|
1543
|
+
function flush() { if (cur != "" && !content) print cur }
|
|
1544
|
+
FNR == 1 { flush(); cur = FILENAME; content = 0; fm = ($0 == "---"); if (fm) next }
|
|
1545
|
+
content { next }
|
|
1546
|
+
fm { if ($0 == "---") fm = 0; next }
|
|
1547
|
+
/^[[:space:]]*$/ || $0 == "# Session Outcome" || $0 == "# Global Session Notes" { next }
|
|
1548
|
+
/^\* \*\*[^*]+:\*\*[[:space:]]*\[.*\]$/ && !/\[\[/ { next }
|
|
1549
|
+
$0 == "## Auto Session Log" || /^_Auto-generated .*_$/ || /^\* \*\*(Repo|Branch):\*\* / { next }
|
|
1550
|
+
$0 == "* **Commits this session:**" || $0 == "- (no commits this session)" { next }
|
|
1551
|
+
$0 == "* **Uncommitted changes at last checkpoint:**" || $0 == "- (working tree clean)" { next }
|
|
1552
|
+
{ content = 1 }
|
|
1553
|
+
END { flush() }
|
|
1554
|
+
' "$@" 2>/dev/null
|
|
1555
|
+
}
|
|
1533
1556
|
|
|
1534
1557
|
# ai-mem-sleep: the vault's "bedtime" pass -- consolidation, decay and lint in
|
|
1535
1558
|
# one run, modelled on how a brain sleeps. It NEVER prunes a lesson: the
|
|
@@ -1538,9 +1561,14 @@ ai-mem-lint() {
|
|
|
1538
1561
|
# and even they are ARCHIVED (moved under the project's _archive/, which
|
|
1539
1562
|
# ai-mem-search skips), never deleted -- git keeps every move reversible.
|
|
1540
1563
|
#
|
|
1564
|
+
# Unfilled logs (see __ai_mem_unfilled_logs) are archived once they are dated
|
|
1565
|
+
# before yesterday, whatever KEEP says, and they do not count toward KEEP. Most
|
|
1566
|
+
# sessions are opened and closed without a note, so counting them let empty
|
|
1567
|
+
# templates push every real log out of the hot set.
|
|
1568
|
+
#
|
|
1541
1569
|
# Dry run by default: it reports what would move and nothing changes on disk.
|
|
1542
1570
|
# --apply performs the archive moves and backs the vault up. Tunables:
|
|
1543
|
-
# AI_MEM_SLEEP_KEEP newest logs per project
|
|
1571
|
+
# AI_MEM_SLEEP_KEEP newest filled logs per project kept hot (default 5)
|
|
1544
1572
|
# AI_MEM_SLEEP_DAYS archive logs older than this many days (default 90)
|
|
1545
1573
|
# AI_MEM_SLEEP_CONSOLIDATE flag a project with this many hot logs (default 8)
|
|
1546
1574
|
ai-mem-sleep() {
|
|
@@ -1555,13 +1583,17 @@ ai-mem-sleep() {
|
|
|
1555
1583
|
# Cut-off date as a string. Filenames carry YYYY-MM-DD, which sorts and
|
|
1556
1584
|
# compares chronologically as text, so no BSD-vs-GNU `date` parsing is
|
|
1557
1585
|
# needed -- strftime on an epoch offset is portable and dependency-free.
|
|
1558
|
-
local cutoff
|
|
1586
|
+
local cutoff empty_cutoff
|
|
1559
1587
|
cutoff="$(strftime '%Y-%m-%d' $(( EPOCHSECONDS - days * 86400 )))"
|
|
1588
|
+
# ponytail: dated before yesterday = at least 24h old. A session still
|
|
1589
|
+
# running after that long loses its log to the archive; the Stop hook then
|
|
1590
|
+
# skips the missing file. Raise this if multi-day sessions become normal.
|
|
1591
|
+
empty_cutoff="$(strftime '%Y-%m-%d' $(( EPOCHSECONDS - 86400 )))"
|
|
1560
1592
|
|
|
1561
1593
|
if (( apply )); then
|
|
1562
|
-
print -r -- "ai-mem-sleep: applying. Keep newest $keep per project; archive session logs dated before $cutoff."
|
|
1594
|
+
print -r -- "ai-mem-sleep: applying. Keep newest $keep filled logs per project; archive session logs dated before $cutoff, and unfilled logs dated before $empty_cutoff."
|
|
1563
1595
|
else
|
|
1564
|
-
print -r -- "ai-mem-sleep: dry run (nothing moves). Keep newest $keep per project; would archive logs dated before $cutoff."
|
|
1596
|
+
print -r -- "ai-mem-sleep: dry run (nothing moves). Keep newest $keep filled logs per project; would archive logs dated before $cutoff, and unfilled logs dated before $empty_cutoff."
|
|
1565
1597
|
fi
|
|
1566
1598
|
print -r -- "Lessons are never touched -- only ephemeral session logs, and they are archived, not deleted."
|
|
1567
1599
|
print -r -- "--"
|
|
@@ -1574,7 +1606,7 @@ ai-mem-sleep() {
|
|
|
1574
1606
|
|
|
1575
1607
|
local -i total_archived=0
|
|
1576
1608
|
local project pdir log sidecar stem logdate
|
|
1577
|
-
local -a logs stale
|
|
1609
|
+
local -a logs filled unfilled stale empty
|
|
1578
1610
|
local -i i hot remaining
|
|
1579
1611
|
for pdir in "$sessions_root"/*(/N); do
|
|
1580
1612
|
project="${pdir:t}"
|
|
@@ -1585,33 +1617,41 @@ ai-mem-sleep() {
|
|
|
1585
1617
|
# is date order within one project. (On) sorts by name, descending.
|
|
1586
1618
|
logs=( "$pdir"/*.md(N.On) )
|
|
1587
1619
|
(( ${#logs} )) || continue
|
|
1620
|
+
unfilled=( ${(f)"$(__ai_mem_unfilled_logs "${logs[@]}")"} )
|
|
1621
|
+
filled=( ${logs:|unfilled} )
|
|
1622
|
+
|
|
1623
|
+
empty=()
|
|
1624
|
+
for log in "${unfilled[@]}"; do
|
|
1625
|
+
stem="${${log:t:r}%%_*}"; logdate="${stem: -10}"
|
|
1626
|
+
[[ "$logdate" =~ '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' ]] || continue # not a dated log
|
|
1627
|
+
[[ "$logdate" < "$empty_cutoff" ]] && empty+=( "$log" )
|
|
1628
|
+
done
|
|
1588
1629
|
|
|
1589
|
-
# The newest KEEP stay hot however old they are, so a
|
|
1590
|
-
# keeps a readable recent history instead of emptying out.
|
|
1591
|
-
hot=$(( keep < ${#
|
|
1630
|
+
# The newest KEEP filled logs stay hot however old they are, so a
|
|
1631
|
+
# dormant project keeps a readable recent history instead of emptying out.
|
|
1632
|
+
hot=$(( keep < ${#filled} ? keep : ${#filled} ))
|
|
1592
1633
|
stale=()
|
|
1593
|
-
for (( i = hot + 1; i <= ${#
|
|
1594
|
-
log="${
|
|
1634
|
+
for (( i = hot + 1; i <= ${#filled}; i++ )); do
|
|
1635
|
+
log="${filled[i]}"
|
|
1595
1636
|
stem="${${log:t:r}%%_*}" # "proj-2026-08-20_10-00-00.md" -> "proj-2026-08-20"
|
|
1596
1637
|
logdate="${stem: -10}" # -> "2026-08-20"
|
|
1597
1638
|
[[ "$logdate" =~ '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' ]] || continue # not a dated log
|
|
1598
1639
|
[[ "$logdate" < "$cutoff" ]] || continue # not old enough
|
|
1599
1640
|
stale+=( "$log" )
|
|
1600
1641
|
done
|
|
1601
|
-
remaining=$(( ${#
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
fi
|
|
1613
|
-
(( total_archived += ${#stale} ))
|
|
1642
|
+
remaining=$(( ${#filled} - ${#stale} ))
|
|
1643
|
+
|
|
1644
|
+
(( ${#empty} )) && print -r -- "$project: ${#empty} unfilled log(s) to archive (nothing was recorded in them)"
|
|
1645
|
+
(( ${#stale} )) && print -r -- "$project: ${#stale} log(s) to archive (of ${#filled} filled, keeping newest $hot)"
|
|
1646
|
+
if (( apply && ${#stale} + ${#empty} )); then
|
|
1647
|
+
mkdir -p "$pdir/_archive"
|
|
1648
|
+
for log in "${stale[@]}" "${empty[@]}"; do
|
|
1649
|
+
mv -- "$log" "$pdir/_archive/"
|
|
1650
|
+
sidecar="${log:r}.startsha"
|
|
1651
|
+
[[ -f "$sidecar" ]] && mv -- "$sidecar" "$pdir/_archive/"
|
|
1652
|
+
done
|
|
1614
1653
|
fi
|
|
1654
|
+
(( total_archived += ${#stale} + ${#empty} ))
|
|
1615
1655
|
|
|
1616
1656
|
# Consolidation candidate: many still-hot logs are unconsolidated
|
|
1617
1657
|
# knowledge -- a nudge to distil them into a durable lesson.
|