create-ai-memory 0.3.0 → 0.5.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 +2 -0
- package/package.json +1 -1
- package/shell/ai-mem.zsh +80 -0
package/README.md
CHANGED
|
@@ -236,6 +236,8 @@ optional. Set `AI_MEM_ROOT` in `~/.zshrc` first if you do not want the default
|
|
|
236
236
|
| `ai-start [project]` | Prepare the session (project note and fresh log) without launching an agent |
|
|
237
237
|
| `ai-context [project]` | Print the vault context block for the current repo, and arm the git commit guard |
|
|
238
238
|
| `ai-note <text>` | Append a timestamped note to today's session log while you work |
|
|
239
|
+
| `ai-mem-lint` | Check the vault's links: orphaned session logs, dangling `previous` links, unreferenced project notes |
|
|
240
|
+
| `ai-mem-search <term> [project]` | Grep across the vault (or one project's logs) for a term, with `file:line:excerpt` |
|
|
239
241
|
|
|
240
242
|
Project is auto-resolved from the current git repo; pass a name to override.
|
|
241
243
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ai-memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Persistent, agent-agnostic session memory for AI coding CLIs (Claude Code, Codex, Gemini, Cursor, opencode). One Markdown vault, any agent.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-ai-memory": "bin/create-ai-memory.js"
|
package/shell/ai-mem.zsh
CHANGED
|
@@ -545,4 +545,84 @@ ai-note() {
|
|
|
545
545
|
|
|
546
546
|
printf '\n- %s %s\n' "$timestamp" "$note_text" >> "$session_note"
|
|
547
547
|
printf 'Appended to %s\n' "$session_note"
|
|
548
|
+
printf 'Appended to %s\n' "$session_note"
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
# Lints the vault's links: session logs missing a project wikilink, previous
|
|
552
|
+
# links pointing at a note that no longer exists, and project notes nothing
|
|
553
|
+
# links back to. Pure grep/find -- no new dependency, catches exactly the
|
|
554
|
+
# "isolated dots in Graph View" class of problem before you have to notice it
|
|
555
|
+
# by eye.
|
|
556
|
+
ai-mem-lint() {
|
|
557
|
+
local issues=0 f label target found
|
|
558
|
+
|
|
559
|
+
while IFS= read -r -d '' f; do
|
|
560
|
+
[[ "${f:t}" == "_session_template.md" ]] && continue
|
|
561
|
+
|
|
562
|
+
if ! grep -qm1 -E '^project:.*\[\[.*\]\]' "$f" 2>/dev/null; then
|
|
563
|
+
print -r -- "orphaned session log (no project link): $f"
|
|
564
|
+
(( issues++ ))
|
|
565
|
+
fi
|
|
566
|
+
|
|
567
|
+
label="$(grep -m1 '^previous:' "$f" 2>/dev/null)"
|
|
568
|
+
if [[ "$label" == *'[['* ]]; then
|
|
569
|
+
target="${label#*\[\[}"
|
|
570
|
+
target="${target%%\]\]*}"
|
|
571
|
+
found="$(find "${f:h}" -maxdepth 1 -name "${target}.md" -print -quit 2>/dev/null)"
|
|
572
|
+
if [[ -z "$found" ]]; then
|
|
573
|
+
print -r -- "dangling previous link: $f -> [[${target}]] (not found)"
|
|
574
|
+
(( issues++ ))
|
|
575
|
+
fi
|
|
576
|
+
fi
|
|
577
|
+
done < <(find "$AI_MEM_SESSION_DIR" -maxdepth 2 -name "*.md" -print0 2>/dev/null)
|
|
578
|
+
|
|
579
|
+
while IFS= read -r -d '' f; do
|
|
580
|
+
[[ "${f:t}" == "_project_template.md" ]] && continue
|
|
581
|
+
local pname="${f:t:r}"
|
|
582
|
+
if ! grep -rq -- "\[\[${pname}\]\]" "$AI_MEM_SESSION_DIR" 2>/dev/null; then
|
|
583
|
+
print -r -- "unreferenced project note (no session log links to it): $f"
|
|
584
|
+
(( issues++ ))
|
|
585
|
+
fi
|
|
586
|
+
done < <(find "$AI_MEM_PROJECT_DIR" -maxdepth 1 -name "*.md" -print0 2>/dev/null)
|
|
587
|
+
|
|
588
|
+
if (( issues == 0 )); then
|
|
589
|
+
print -r -- "ok: vault links are clean"
|
|
590
|
+
else
|
|
591
|
+
print -r -- "$issues issue(s) found"
|
|
592
|
+
fi
|
|
593
|
+
return $(( issues > 0 ? 1 : 0 ))
|
|
594
|
+
return $(( issues > 0 ? 1 : 0 ))
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
# Full-text search across the vault. Plain grep -- no new dependency, and at
|
|
598
|
+
# vault scale (a personal notes collection, not a codebase) there is no real
|
|
599
|
+
# performance reason to reach for anything faster.
|
|
600
|
+
ai-mem-search() {
|
|
601
|
+
local term="${1:-}"
|
|
602
|
+
local project="${2:-}"
|
|
603
|
+
if [[ -z "$term" ]]; then
|
|
604
|
+
echo "Usage: ai-mem-search <term> [project]"
|
|
605
|
+
return 1
|
|
606
|
+
fi
|
|
607
|
+
|
|
608
|
+
local search_root="$AI_MEM_ROOT"
|
|
609
|
+
if [[ -n "$project" ]]; then
|
|
610
|
+
search_root="$(_ai_mem_project_session_dir "$project")"
|
|
611
|
+
if [[ ! -d "$search_root" ]]; then
|
|
612
|
+
print -r -- "ai-mem-search: no session logs for project '$project'"
|
|
613
|
+
return 1
|
|
614
|
+
fi
|
|
615
|
+
fi
|
|
616
|
+
|
|
617
|
+
local raw
|
|
618
|
+
raw="$(grep -rn --exclude-dir=.git --exclude='_session_template.md' --exclude='_project_template.md' -- "$term" "$search_root" 2>/dev/null)"
|
|
619
|
+
|
|
620
|
+
if [[ -z "$raw" ]]; then
|
|
621
|
+
print -r -- "no matches for '$term' in $search_root"
|
|
622
|
+
return 1
|
|
623
|
+
fi
|
|
624
|
+
|
|
625
|
+
print -r -- "$raw"
|
|
626
|
+
print -r -- "--"
|
|
627
|
+
print -r -- "$(print -r -- "$raw" | wc -l | tr -d ' ') match(es) for '$term'"
|
|
548
628
|
}
|