smart-claude-memory-mcp 2.1.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.
Files changed (104) hide show
  1. package/.claude-plugin/plugin.json +38 -0
  2. package/CHANGELOG.md +52 -0
  3. package/LICENSE +21 -0
  4. package/README.md +790 -0
  5. package/dist/chunker.js +33 -0
  6. package/dist/chunker.js.map +1 -0
  7. package/dist/config.js +23 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/curriculum/daemon.js +190 -0
  10. package/dist/curriculum/daemon.js.map +1 -0
  11. package/dist/curriculum/scanner.js +237 -0
  12. package/dist/curriculum/scanner.js.map +1 -0
  13. package/dist/index.js +429 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/lib/migrations.js +128 -0
  16. package/dist/lib/migrations.js.map +1 -0
  17. package/dist/ollama.js +59 -0
  18. package/dist/ollama.js.map +1 -0
  19. package/dist/project-detect.js +102 -0
  20. package/dist/project-detect.js.map +1 -0
  21. package/dist/project.js +26 -0
  22. package/dist/project.js.map +1 -0
  23. package/dist/sleep/daemon.js +215 -0
  24. package/dist/sleep/daemon.js.map +1 -0
  25. package/dist/sleep/miner.js +285 -0
  26. package/dist/sleep/miner.js.map +1 -0
  27. package/dist/supabase.js +405 -0
  28. package/dist/supabase.js.map +1 -0
  29. package/dist/telemetry/emit.js +19 -0
  30. package/dist/telemetry/emit.js.map +1 -0
  31. package/dist/telemetry/pruner.js +141 -0
  32. package/dist/telemetry/pruner.js.map +1 -0
  33. package/dist/telemetry/types.js +2 -0
  34. package/dist/telemetry/types.js.map +1 -0
  35. package/dist/tools/backlog.js +599 -0
  36. package/dist/tools/backlog.js.map +1 -0
  37. package/dist/tools/batch-freeze-patterns.js +243 -0
  38. package/dist/tools/batch-freeze-patterns.js.map +1 -0
  39. package/dist/tools/bloat-audit.js +101 -0
  40. package/dist/tools/bloat-audit.js.map +1 -0
  41. package/dist/tools/checkpoint.js +259 -0
  42. package/dist/tools/checkpoint.js.map +1 -0
  43. package/dist/tools/compact.js +60 -0
  44. package/dist/tools/compact.js.map +1 -0
  45. package/dist/tools/conflict.js +102 -0
  46. package/dist/tools/conflict.js.map +1 -0
  47. package/dist/tools/curriculum.js +225 -0
  48. package/dist/tools/curriculum.js.map +1 -0
  49. package/dist/tools/frozen-cache.js +106 -0
  50. package/dist/tools/frozen-cache.js.map +1 -0
  51. package/dist/tools/health.js +368 -0
  52. package/dist/tools/health.js.map +1 -0
  53. package/dist/tools/hygiene.js +309 -0
  54. package/dist/tools/hygiene.js.map +1 -0
  55. package/dist/tools/image.js +107 -0
  56. package/dist/tools/image.js.map +1 -0
  57. package/dist/tools/list-global-patterns.js +101 -0
  58. package/dist/tools/list-global-patterns.js.map +1 -0
  59. package/dist/tools/orchestrator.js +113 -0
  60. package/dist/tools/orchestrator.js.map +1 -0
  61. package/dist/tools/policy.js +90 -0
  62. package/dist/tools/policy.js.map +1 -0
  63. package/dist/tools/refactor.js +220 -0
  64. package/dist/tools/refactor.js.map +1 -0
  65. package/dist/tools/save.js +42 -0
  66. package/dist/tools/save.js.map +1 -0
  67. package/dist/tools/search.js +189 -0
  68. package/dist/tools/search.js.map +1 -0
  69. package/dist/tools/setup.js +868 -0
  70. package/dist/tools/setup.js.map +1 -0
  71. package/dist/tools/shared-schemas.js +24 -0
  72. package/dist/tools/shared-schemas.js.map +1 -0
  73. package/dist/tools/skills.js +174 -0
  74. package/dist/tools/skills.js.map +1 -0
  75. package/dist/tools/sleep.js +239 -0
  76. package/dist/tools/sleep.js.map +1 -0
  77. package/dist/tools/sovereign-constitution.js +319 -0
  78. package/dist/tools/sovereign-constitution.js.map +1 -0
  79. package/dist/tools/summarize.js +55 -0
  80. package/dist/tools/summarize.js.map +1 -0
  81. package/dist/tools/sync.js +255 -0
  82. package/dist/tools/sync.js.map +1 -0
  83. package/dist/tools/system_dashboard.js +181 -0
  84. package/dist/tools/system_dashboard.js.map +1 -0
  85. package/dist/tools/update-rule.js +15 -0
  86. package/dist/tools/update-rule.js.map +1 -0
  87. package/dist/tools/verification.js +333 -0
  88. package/dist/tools/verification.js.map +1 -0
  89. package/dist/trajectory/daemon.js +270 -0
  90. package/dist/trajectory/daemon.js.map +1 -0
  91. package/dist/trajectory/stripper.js +124 -0
  92. package/dist/trajectory/stripper.js.map +1 -0
  93. package/dist/trajectory/summarizer.js +77 -0
  94. package/dist/trajectory/summarizer.js.map +1 -0
  95. package/dist/transactions/checkpoint.js +272 -0
  96. package/dist/transactions/checkpoint.js.map +1 -0
  97. package/dist/verification-gate.js +43 -0
  98. package/dist/verification-gate.js.map +1 -0
  99. package/dist/version.js +16 -0
  100. package/dist/version.js.map +1 -0
  101. package/hooks/README.md +54 -0
  102. package/hooks/md-policy.py +497 -0
  103. package/marketplace.json +13 -0
  104. package/package.json +66 -0
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "smart-claude-memory",
3
+ "version": "2.1.0",
4
+ "description": "Sovereign memory protocol for Claude Code — typed, dual-scope, observability-grade. Bring your own empty Supabase project; the plugin handles the rest.",
5
+ "author": {
6
+ "name": "NABILNET.AI",
7
+ "url": "https://nabilnet.ai"
8
+ },
9
+ "homepage": "https://nabilnet.ai",
10
+ "mcpServers": {
11
+ "smart-claude-memory": {
12
+ "command": "node",
13
+ "args": ["${CLAUDE_PLUGIN_ROOT}/dist/index.js"],
14
+ "env": {
15
+ "SUPABASE_URL": "${SUPABASE_URL}",
16
+ "SUPABASE_SECRET_KEY": "${SUPABASE_SECRET_KEY}",
17
+ "SUPABASE_POOLER_URL": "${SUPABASE_POOLER_URL}",
18
+ "OLLAMA_HOST": "${OLLAMA_HOST:-http://localhost:11434}",
19
+ "OLLAMA_EMBED_MODEL": "${OLLAMA_EMBED_MODEL:-nomic-embed-text}",
20
+ "MEMORY_ROOTS": "${MEMORY_ROOTS}",
21
+ "EMBED_DIM": "${EMBED_DIM:-768}"
22
+ }
23
+ }
24
+ },
25
+ "hooks": {
26
+ "PreToolUse": [
27
+ {
28
+ "matcher": "Write|Edit|Bash",
29
+ "hooks": [
30
+ {
31
+ "type": "command",
32
+ "command": "python \"${CLAUDE_PLUGIN_ROOT}/hooks/md-policy.py\""
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
38
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ ## [2.0.1] — 2026-05-14
4
+
5
+ **v2.0.1 — Tech-Debt & Operational-Hygiene Patch**
6
+
7
+ Pays off two pieces of debt carried out of v2.0.0 so the BYO-Supabase boot path becomes mathematically re-runnable. Zero schema-shape change, zero new features, zero new tool surface.
8
+
9
+ ### Fixed
10
+ - **Migrations 010/011/012/015 — every `CREATE FUNCTION` now uses `CREATE OR REPLACE FUNCTION`** (10 functions, Backlog #131). Eliminates the duplicate-function-signature failure mode on migration re-apply, e.g. when a recovery-path operator deletes a ledger row and the apply loop replays the file. Every other DDL class in `scripts/` (extensions, tables, indexes, schemas, types, policies, triggers, `ADD COLUMN`, `ADD CONSTRAINT`) was already guarded — confirmed by the Session 26 read-only audit.
11
+ - **Migrations 005/014 — `INSERT INTO archive_backlog ... SELECT FROM moved` inside the `archive_done_backlog` RPC body gained bare `ON CONFLICT DO NOTHING`.** Note: this INSERT only runs when the RPC is called at runtime, not at migration apply time — so it is defensive call-time hygiene against a PK-collision failure mode in the archive flow, not strictly a migration-replay fix. The Session 26 audit conflated it with apply-time risk; the patch was kept on the v2.0.1 release because the call-time guarantee is independently useful.
12
+ - **Migration ledger denylist removed (Backlog #130).** `006_smoke.sql` and `006_verify.sql` were companion validation scripts that shared `scripts/` with real numbered migrations, forcing `loadMigrationFiles()` to maintain an explicit `excluded` Set. Both fixtures now live under `tests/sql_fixtures/`; `loadMigrationFiles()` collapsed to a single regex filter. The "every `0NN_*.sql` in `scripts/` is a migration" contract is now structural, not denylist-enforced.
13
+
14
+ ### Added
15
+ - **Static idempotency check in `tests/migrations.test.ts`.** Parses every migration body and flags any top-level CREATE statement that lacks its idempotency guard (`OR REPLACE` for functions; `IF NOT EXISTS` for tables / indexes / extensions / `ADD COLUMN`). Runs unconditionally — no DB, no env flag, no live state — in <2 ms. The earlier provisional design used a destructive opt-in runtime re-apply test against `public.schema_migrations`; that approach was rejected because (a) shared-infra safeguards correctly block the truncate, and (b) the 18 migration bodies use `public.*` qualifiers throughout, which makes a clean temp-schema replay infeasible without a parser-level rewrite. Static analysis catches the regression class the audit identified and runs on every contributor's machine.
16
+
17
+ ### Notes
18
+ - `schema_migrations.sha256` values for the 6 patched files diverge from what is recorded on already-applied dev DBs. This is silent and harmless: `applyPendingMigrations()` acts on filename presence only — applied rows are not re-validated — and fresh BYO-Supabase installs ship with the new hashes.
19
+ - The MCP server's tool surface is unchanged at 39 tools.
20
+ - The 18 schema migrations remain at version 18; only their re-runnability has improved.
21
+
22
+ ## [2.0.0] — 2026-05-14
23
+
24
+ **v2.0.0 GA — Plugin Marketplace Release**
25
+
26
+ Smart-Claude-Memory is now installable as a Claude Code Plugin. Zero manual `~/.claude.json` edits, zero manual schema apply, zero hand-edited `~/.claude/settings.json` — first `init_project()` bootstraps an empty Supabase DB and verifies your Ollama models in one call.
27
+
28
+ ### Added
29
+ - `.claude-plugin/plugin.json` manifest — installable via Claude Code marketplace; auto-wires the MCP server (with env passthrough for the 7 SCM vars) and the `md-policy.py` PreToolUse hook (`Write|Edit|Bash` matcher).
30
+ - `schema_migrations(filename, sha256, applied_at)` ledger table + idempotent apply-all CLI (`npm run schema`); re-runs are no-ops. Legacy single-file mode preserved for emergencies.
31
+ - `src/lib/migrations.ts` shared helper (`ensureLedger`, `loadMigrationFiles`, `listPendingMigrations`, `applyPendingMigrations`).
32
+ - `init_project` auto-applies pending migrations on first call against a fresh `pg.Client`. Surfaces a new `migrations` check + top-level `migrations: { applied, skipped, total }` block. Errors gracefully convert to `not_ready` without crashing the MCP server.
33
+ - `init_project` Ollama models preflight: queries `${OLLAMA_HOST}/api/tags` and verifies `moondream` + `nomic-embed-text` are pulled. Missing models surface a `partial` status with the exact `Run: ollama pull <names>` command. 5s timeout via `AbortController`.
34
+ - `scripts/backfill-ledger.ts` one-shot operational utility to sync `schema_migrations` for pre-existing DBs.
35
+ - `marketplace.json` for Claude Code marketplace publication.
36
+
37
+ ### Changed
38
+ - Health enum extended: `"healthy" | "pending" | "degraded" | "down"`. Daemons within a 15-minute boot grace window report `pending` instead of `down`. Top-level `overall` no longer falsely promoted to `down` on cold boot. `pending` ranks below `degraded` (SEVERITY 0.5).
39
+ - `pg` promoted from `devDependencies` → `dependencies` (runtime use in `init_project`).
40
+ - README install ritual reduced from 5 steps to 3 (plugin install → empty Supabase + pull Ollama models → set 3 env vars).
41
+ - ARCHITECTURE.md gains a `## 7. Plugin Distribution` section covering manifest semantics, the migration ledger boot path, hook injection, and the pending/grace health state.
42
+
43
+ ### Fixed
44
+ - `tests/trajectory-daemon.test.ts` key-count assertion (7 → 9) brought in sync with the per-tick token counters added in `58dc6d1` (Session 24).
45
+
46
+ ### Migrated from 2.0.0-rc1
47
+ - All Observability Epic work (4 daemons + GLOBAL Vault + system_dashboard) carried over unchanged.
48
+ - No breaking changes to existing tool surfaces.
49
+
50
+ ### Notes
51
+ - The MCP server's tool surface is unchanged at 39 tools.
52
+ - The 18 schema migrations are unchanged; only the apply mechanism evolved.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NABILNET.AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.