@lh8ppl/claude-memory-kit 0.1.0 → 0.1.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.
Files changed (38) hide show
  1. package/README.md +77 -0
  2. package/bin/cmk-auto-extract.mjs +62 -0
  3. package/bin/cmk-capture-prompt.mjs +65 -0
  4. package/bin/cmk-capture-turn.mjs +76 -0
  5. package/bin/cmk-compress-lazy.mjs +0 -0
  6. package/bin/cmk-compress-session.mjs +64 -0
  7. package/bin/cmk-daily-distill.mjs +0 -0
  8. package/bin/cmk-inject-context.mjs +69 -0
  9. package/bin/cmk-observe-edit.mjs +57 -0
  10. package/bin/cmk-weekly-curate.mjs +0 -0
  11. package/bin/cmk.mjs +11 -11
  12. package/package.json +10 -2
  13. package/src/audit-log.mjs +1 -0
  14. package/src/claude-md.mjs +212 -212
  15. package/src/doctor.mjs +16 -5
  16. package/src/frontmatter.mjs +73 -73
  17. package/src/install.mjs +49 -1
  18. package/src/merge-facts.mjs +213 -213
  19. package/src/provenance.mjs +217 -217
  20. package/src/reindex.mjs +134 -134
  21. package/src/repair.mjs +26 -96
  22. package/src/settings-hooks.mjs +186 -0
  23. package/src/subcommands.mjs +13 -2
  24. package/template/.gitignore.fragment +12 -12
  25. package/template/CLAUDE.md.template +49 -49
  26. package/template/docs/journey/journey-log.md.template +292 -292
  27. package/template/project/memory/INDEX.md.template +47 -47
  28. package/template/support/cron-jobs/daily-memory-distill.md +15 -15
  29. package/template/support/cron-jobs/nightly-memsearch-index.md +17 -17
  30. package/template/support/cron-jobs/weekly-memory-curator.md +15 -15
  31. package/template/support/milvus-deploy/README.md +57 -57
  32. package/template/support/milvus-deploy/docker-compose.yml +66 -66
  33. package/template/support/scripts/auto-extract-memory.sh +102 -102
  34. package/template/support/scripts/memsearch-index-with-flush.sh +59 -59
  35. package/template/support/scripts/refresh-distill-timestamp.py +35 -35
  36. package/template/support/scripts/register-crons.py +242 -242
  37. package/template/support/scripts/run-daily-distill.sh +67 -67
  38. package/template/support/scripts/run-weekly-curate.sh +58 -58
@@ -1,59 +1,59 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Wraps `memsearch index` to also force a Milvus flush afterward.
4
- #
5
- # Why: Milvus v2.6+ uses the Woodpecker WAL backend, which (unlike v2.5's
6
- # Pulsar) does not auto-flush growing segments on a short timer. As a result,
7
- # `memsearch index` reports "Indexed N chunks" successfully but
8
- # `get_collection_stats` returns 0 rows and search returns no results until
9
- # a manual flush forces the growing segment to seal.
10
- #
11
- # This wrapper runs the index, then issues a flush via pymilvus.
12
- #
13
- # Usage:
14
- # bash scripts/memsearch-index-with-flush.sh context/memory context/sessions context/transcripts
15
- #
16
- # Reads MILVUS_URI from env (falls back to the memsearch config value, then localhost).
17
- # Reads MILVUS_COLLECTION from env (falls back to memsearch config, then "memsearch_chunks").
18
-
19
- # Task Scheduler / launchd / unattended cron contexts don't always inherit
20
- # the user's PATH. Set it up explicitly for the common locations.
21
- case ":$PATH:" in
22
- *":/usr/bin:"*) ;;
23
- *) export PATH="/usr/bin:/usr/local/bin:/opt/homebrew/bin:/c/Program Files/Git/usr/bin:$PATH" ;;
24
- esac
25
-
26
- # On Windows, also add the Python Scripts dir where `memsearch.exe` lands.
27
- if [ -d "/c/Users/$USERNAME/AppData/Local/Programs/Python" ]; then
28
- for d in /c/Users/$USERNAME/AppData/Local/Programs/Python/Python*/Scripts \
29
- /c/Users/$USERNAME/AppData/Local/Programs/Python/Python*; do
30
- [ -d "$d" ] && export PATH="$d:$PATH"
31
- done
32
- fi
33
-
34
- set -euo pipefail
35
-
36
- # Step 1 — index. Pass through all args.
37
- memsearch index "$@"
38
-
39
- # Step 2 — flush.
40
- MILVUS_URI="${MILVUS_URI:-$(memsearch config get milvus.uri 2>/dev/null | tail -n1 | tr -d '\r')}"
41
- MILVUS_COLLECTION="${MILVUS_COLLECTION:-$(memsearch config get milvus.collection 2>/dev/null | tail -n1 | tr -d '\r')}"
42
- MILVUS_URI="${MILVUS_URI:-http://localhost:19530}"
43
- MILVUS_COLLECTION="${MILVUS_COLLECTION:-memsearch_chunks}"
44
-
45
- # Flush only if we're using a remote Milvus (milvus-lite auto-flushes).
46
- case "$MILVUS_URI" in
47
- http://*|https://*|tcp://*)
48
- python -c "
49
- from pymilvus import MilvusClient
50
- client = MilvusClient(uri='${MILVUS_URI}')
51
- client.flush('${MILVUS_COLLECTION}')
52
- stats = client.get_collection_stats('${MILVUS_COLLECTION}')
53
- print(f'Flushed. Collection {stats!r}')
54
- "
55
- ;;
56
- *)
57
- echo "Local milvus-lite detected (${MILVUS_URI}); skipping flush (auto-flush)."
58
- ;;
59
- esac
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Wraps `memsearch index` to also force a Milvus flush afterward.
4
+ #
5
+ # Why: Milvus v2.6+ uses the Woodpecker WAL backend, which (unlike v2.5's
6
+ # Pulsar) does not auto-flush growing segments on a short timer. As a result,
7
+ # `memsearch index` reports "Indexed N chunks" successfully but
8
+ # `get_collection_stats` returns 0 rows and search returns no results until
9
+ # a manual flush forces the growing segment to seal.
10
+ #
11
+ # This wrapper runs the index, then issues a flush via pymilvus.
12
+ #
13
+ # Usage:
14
+ # bash scripts/memsearch-index-with-flush.sh context/memory context/sessions context/transcripts
15
+ #
16
+ # Reads MILVUS_URI from env (falls back to the memsearch config value, then localhost).
17
+ # Reads MILVUS_COLLECTION from env (falls back to memsearch config, then "memsearch_chunks").
18
+
19
+ # Task Scheduler / launchd / unattended cron contexts don't always inherit
20
+ # the user's PATH. Set it up explicitly for the common locations.
21
+ case ":$PATH:" in
22
+ *":/usr/bin:"*) ;;
23
+ *) export PATH="/usr/bin:/usr/local/bin:/opt/homebrew/bin:/c/Program Files/Git/usr/bin:$PATH" ;;
24
+ esac
25
+
26
+ # On Windows, also add the Python Scripts dir where `memsearch.exe` lands.
27
+ if [ -d "/c/Users/$USERNAME/AppData/Local/Programs/Python" ]; then
28
+ for d in /c/Users/$USERNAME/AppData/Local/Programs/Python/Python*/Scripts \
29
+ /c/Users/$USERNAME/AppData/Local/Programs/Python/Python*; do
30
+ [ -d "$d" ] && export PATH="$d:$PATH"
31
+ done
32
+ fi
33
+
34
+ set -euo pipefail
35
+
36
+ # Step 1 — index. Pass through all args.
37
+ memsearch index "$@"
38
+
39
+ # Step 2 — flush.
40
+ MILVUS_URI="${MILVUS_URI:-$(memsearch config get milvus.uri 2>/dev/null | tail -n1 | tr -d '\r')}"
41
+ MILVUS_COLLECTION="${MILVUS_COLLECTION:-$(memsearch config get milvus.collection 2>/dev/null | tail -n1 | tr -d '\r')}"
42
+ MILVUS_URI="${MILVUS_URI:-http://localhost:19530}"
43
+ MILVUS_COLLECTION="${MILVUS_COLLECTION:-memsearch_chunks}"
44
+
45
+ # Flush only if we're using a remote Milvus (milvus-lite auto-flushes).
46
+ case "$MILVUS_URI" in
47
+ http://*|https://*|tcp://*)
48
+ python -c "
49
+ from pymilvus import MilvusClient
50
+ client = MilvusClient(uri='${MILVUS_URI}')
51
+ client.flush('${MILVUS_COLLECTION}')
52
+ stats = client.get_collection_stats('${MILVUS_COLLECTION}')
53
+ print(f'Flushed. Collection {stats!r}')
54
+ "
55
+ ;;
56
+ *)
57
+ echo "Local milvus-lite detected (${MILVUS_URI}); skipping flush (auto-flush)."
58
+ ;;
59
+ esac
@@ -1,35 +1,35 @@
1
- #!/usr/bin/env python3
2
- """
3
- Tiny helper for the daily-memory-distill cron job.
4
-
5
- Rewrites the `<!-- Last distilled: YYYY-MM-DD -->` line in
6
- context/MEMORY.md to today's date. Keeps HC-3 green even when the real
7
- distillation (Claude-driven extraction of facts from sessions/) isn't
8
- wired up yet.
9
-
10
- Usage:
11
- python scripts/refresh-distill-timestamp.py
12
- """
13
- from __future__ import annotations
14
-
15
- import datetime
16
- import re
17
- import sys
18
- from pathlib import Path
19
-
20
- REPO_ROOT = Path(__file__).resolve().parent.parent
21
- MEMORY = REPO_ROOT / "context" / "MEMORY.md"
22
-
23
- if not MEMORY.exists():
24
- print(f"ERROR: {MEMORY} not found", file=sys.stderr)
25
- sys.exit(1)
26
-
27
- today = datetime.date.today().isoformat()
28
- text = MEMORY.read_text(encoding="utf-8")
29
- new_text, n = re.subn(r"Last distilled: \d{4}-\d{2}-\d{2}",
30
- f"Last distilled: {today}", text, count=1)
31
- if n == 0:
32
- print("WARN: no 'Last distilled:' line found in MEMORY.md; nothing to update", file=sys.stderr)
33
- sys.exit(0)
34
- MEMORY.write_text(new_text, encoding="utf-8")
35
- print(f"OK: updated Last distilled to {today}")
1
+ #!/usr/bin/env python3
2
+ """
3
+ Tiny helper for the daily-memory-distill cron job.
4
+
5
+ Rewrites the `<!-- Last distilled: YYYY-MM-DD -->` line in
6
+ context/MEMORY.md to today's date. Keeps HC-3 green even when the real
7
+ distillation (Claude-driven extraction of facts from sessions/) isn't
8
+ wired up yet.
9
+
10
+ Usage:
11
+ python scripts/refresh-distill-timestamp.py
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import datetime
16
+ import re
17
+ import sys
18
+ from pathlib import Path
19
+
20
+ REPO_ROOT = Path(__file__).resolve().parent.parent
21
+ MEMORY = REPO_ROOT / "context" / "MEMORY.md"
22
+
23
+ if not MEMORY.exists():
24
+ print(f"ERROR: {MEMORY} not found", file=sys.stderr)
25
+ sys.exit(1)
26
+
27
+ today = datetime.date.today().isoformat()
28
+ text = MEMORY.read_text(encoding="utf-8")
29
+ new_text, n = re.subn(r"Last distilled: \d{4}-\d{2}-\d{2}",
30
+ f"Last distilled: {today}", text, count=1)
31
+ if n == 0:
32
+ print("WARN: no 'Last distilled:' line found in MEMORY.md; nothing to update", file=sys.stderr)
33
+ sys.exit(0)
34
+ MEMORY.write_text(new_text, encoding="utf-8")
35
+ print(f"OK: updated Last distilled to {today}")