@theglitchking/semantic-memory 1.0.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 (68) hide show
  1. package/.claude-plugin/marketplace.json +71 -0
  2. package/.claude-plugin/plugin.json +34 -0
  3. package/CHANGELOG.md +233 -0
  4. package/LICENSE +21 -0
  5. package/README.md +91 -0
  6. package/bin/semantic-memory +2 -0
  7. package/bin/semantic-sidekick +2 -0
  8. package/commands/healthcheck.md +6 -0
  9. package/commands/mode.md +65 -0
  10. package/commands/normalize-config.md +6 -0
  11. package/commands/policy.md +16 -0
  12. package/commands/relink.md +6 -0
  13. package/commands/status.md +6 -0
  14. package/commands/update.md +6 -0
  15. package/commands/vault.md +21 -0
  16. package/dist/chunk-25EIQWXL.js +651 -0
  17. package/dist/chunk-25EIQWXL.js.map +1 -0
  18. package/dist/chunk-CAN2GWUG.js +88 -0
  19. package/dist/chunk-CAN2GWUG.js.map +1 -0
  20. package/dist/chunk-CXTRTCIK.js +762 -0
  21. package/dist/chunk-CXTRTCIK.js.map +1 -0
  22. package/dist/chunk-E2Z4J4MK.js +180 -0
  23. package/dist/chunk-E2Z4J4MK.js.map +1 -0
  24. package/dist/chunk-HODDRXJK.js +169 -0
  25. package/dist/chunk-HODDRXJK.js.map +1 -0
  26. package/dist/chunk-JPQHNG3R.js +147 -0
  27. package/dist/chunk-JPQHNG3R.js.map +1 -0
  28. package/dist/chunk-PZ5AY32C.js +10 -0
  29. package/dist/chunk-PZ5AY32C.js.map +1 -0
  30. package/dist/cli/index.d.ts +1 -0
  31. package/dist/cli/index.js +505 -0
  32. package/dist/cli/index.js.map +1 -0
  33. package/dist/core/embed-worker.d.ts +2 -0
  34. package/dist/core/embed-worker.js +121 -0
  35. package/dist/core/embed-worker.js.map +1 -0
  36. package/dist/core/index.d.ts +486 -0
  37. package/dist/core/index.js +62 -0
  38. package/dist/core/index.js.map +1 -0
  39. package/dist/indexer-KD6UTXZB.js +8 -0
  40. package/dist/indexer-KD6UTXZB.js.map +1 -0
  41. package/dist/lint-GMXQF4RW.js +11 -0
  42. package/dist/lint-GMXQF4RW.js.map +1 -0
  43. package/dist/log-LQXIJXIA.js +10 -0
  44. package/dist/log-LQXIJXIA.js.map +1 -0
  45. package/dist/mcp/server.d.ts +16 -0
  46. package/dist/mcp/server.js +4925 -0
  47. package/dist/mcp/server.js.map +1 -0
  48. package/dist/schema-F3RTY6SQ.js +12 -0
  49. package/dist/schema-F3RTY6SQ.js.map +1 -0
  50. package/dist/search-27WYAI24.js +202 -0
  51. package/dist/search-27WYAI24.js.map +1 -0
  52. package/docs/compat-matrix.md +127 -0
  53. package/docs/corpora-json.md +150 -0
  54. package/docs/regression-snapshot.md +122 -0
  55. package/docs/smart-middle-activation.md +97 -0
  56. package/hooks/hooks.json +39 -0
  57. package/hooks/reconcile.js +171 -0
  58. package/hooks/session-start.js +81 -0
  59. package/hooks/vault-context.js +503 -0
  60. package/package.json +97 -0
  61. package/scripts/link-skills.js +25 -0
  62. package/scripts/pre-commit-lint.sh +42 -0
  63. package/skills/outage-silence/SKILL.md +72 -0
  64. package/skills/research-mode/SKILL.md +84 -0
  65. package/skills/semantic-first/SKILL.md +117 -0
  66. package/skills/semantic-first/evals/evals.json +37 -0
  67. package/skills/semantic-first/references/vault-frontmatter.md +133 -0
  68. package/skills/vault-first/SKILL.md +100 -0
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "semantic-memory-marketplace",
3
+ "owner": {
4
+ "name": "TheGlitchKing",
5
+ "email": "theglitchking@users.noreply.github.com"
6
+ },
7
+ "metadata": {
8
+ "description": "Single-plugin marketplace for semantic-memory — the unified memory-layer plugin (rebrand of semantic-sidekick at v1.0.0). One MCP server, multiple typed corpora, unified cross-corpus knowledge graph, conditional tool registration, drift detection, and human↔code translation.",
9
+ "version": "1.0.0"
10
+ },
11
+ "plugins": [
12
+ {
13
+ "name": "semantic-memory",
14
+ "description": "Unified memory-layer plugin for Claude Code. One MCP server, multiple typed corpora (vault / code / plans / docs / research / project-map), unified cross-corpus knowledge graph, conditional tool registration based on active corpora, in-process drift detection, and human↔code translation. Rebrand of semantic-sidekick at v1.0.0; existing semantic-sidekick plugins continue to work under the legacy name during the transition period.",
15
+ "version": "1.0.0",
16
+ "author": {
17
+ "name": "TheGlitchKing"
18
+ },
19
+ "homepage": "https://github.com/TheGlitchKing/semantic-sidekick",
20
+ "repository": "https://github.com/TheGlitchKing/semantic-sidekick.git",
21
+ "license": "MIT",
22
+ "keywords": [
23
+ "mcp",
24
+ "model-context-protocol",
25
+ "memory-layer",
26
+ "semantic-search",
27
+ "knowledge-graph",
28
+ "multi-corpus",
29
+ "code-search",
30
+ "drift-detection",
31
+ "translation",
32
+ "markdown",
33
+ "vault",
34
+ "activation",
35
+ "routing",
36
+ "hooks",
37
+ "skills",
38
+ "vault-first",
39
+ "research-mode",
40
+ "outage-silence",
41
+ "provenance",
42
+ "synthesize-note",
43
+ "ingest-source",
44
+ "karpathy-wiki",
45
+ "claude-code",
46
+ "claude"
47
+ ],
48
+ "category": "search",
49
+ "tags": [
50
+ "claude-plugin",
51
+ "mcp-server",
52
+ "memory-layer",
53
+ "semantic-search",
54
+ "knowledge-graph",
55
+ "multi-corpus",
56
+ "drift-detection",
57
+ "translation",
58
+ "activation-hooks",
59
+ "mode-routing",
60
+ "provenance",
61
+ "vault",
62
+ "markdown"
63
+ ],
64
+ "source": {
65
+ "source": "npm",
66
+ "package": "@theglitchking/semantic-memory"
67
+ },
68
+ "strict": true
69
+ }
70
+ ]
71
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "semantic-memory",
3
+ "description": "Unified memory-layer plugin for Claude Code. One MCP server, multiple typed corpora (vault / code / plans / docs / research / project-map), unified cross-corpus knowledge graph, conditional tool registration, in-process drift detection, and human↔code translation. Rebrand of `semantic-sidekick` at v1.0.0 — see CHANGELOG for migration.",
4
+ "version": "1.0.0",
5
+ "author": {
6
+ "name": "TheGlitchKing",
7
+ "email": "theglitchking@users.noreply.github.com"
8
+ },
9
+ "license": "MIT",
10
+ "homepage": "https://github.com/TheGlitchKing/semantic-sidekick",
11
+ "repository": "https://github.com/TheGlitchKing/semantic-sidekick",
12
+ "keywords": [
13
+ "mcp",
14
+ "memory-layer",
15
+ "semantic-search",
16
+ "knowledge-graph",
17
+ "multi-corpus",
18
+ "markdown",
19
+ "vault",
20
+ "code-search",
21
+ "drift-detection",
22
+ "translation",
23
+ "activation",
24
+ "routing",
25
+ "hooks",
26
+ "skills",
27
+ "vault-first",
28
+ "research-mode",
29
+ "outage-silence",
30
+ "provenance",
31
+ "synthesize-note",
32
+ "ingest-source"
33
+ ]
34
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,233 @@
1
+ # Changelog
2
+
3
+ All notable changes to semantic-memory (formerly semantic-sidekick) will be documented here.
4
+
5
+ ## [1.0.0] - 2026-05-07 — Rebrand to `semantic-memory`
6
+
7
+ ### Renamed (publication identity)
8
+
9
+ - **npm package**: `@theglitchking/semantic-sidekick` → `@theglitchking/semantic-memory`
10
+ - **Claude Code plugin name**: `semantic-sidekick` → `semantic-memory`
11
+ - **Marketplace name**: `semantic-sidekick-marketplace` → `semantic-memory-marketplace`
12
+ - **MCP server name**: `semantic-sidekick` → `semantic-memory` (announced in initialize handshake)
13
+ - **CLI binary**: `bin/semantic-memory` is the new primary; `bin/semantic-sidekick` is preserved as an alias during the transition
14
+
15
+ ### Why
16
+
17
+ `semantic-sidekick` framed the plugin as a "vault helper" because that's what it was at v0.x. v1.0.0 introduces a multi-corpus architecture: vault, code, plans, docs, research, project-map. The plugin is no longer a sidekick — it's the unified memory layer for Claude Code. The new name reflects the actual scope.
18
+
19
+ ### Preserved (no migration required for existing installs)
20
+
21
+ - **Internal storage layout** is unchanged: `<project>/.semantic-sidekick-index/` continues to be the index directory, `~/.semantic-sidekick/models/` continues to be the model cache. Existing users do NOT need to re-index or re-download models when they upgrade.
22
+ - **All 33 existing MCP tools** remain registered under the same names with the same input schemas and the same output structures. The regression-snapshot suite (`test/regression/`) gates this guarantee — every tool's surface is bit-for-bit preserved.
23
+ - **The `--read-only` mode** continues to suppress the same 12 write tools (21-tool surface).
24
+ - **All existing slash commands, hooks, skills, and capture flow** are unchanged.
25
+ - **`bin/semantic-sidekick` shell command** continues to work as an alias for `bin/semantic-memory`.
26
+ - **Configuration files** (`.claude/semantic-sidekick.json`, `.claude/.semantic-sidekick-update-cache.json`) keep their names. The claude-plugin-runtime `pluginName: "semantic-sidekick"` is preserved so update tracking continues without state loss.
27
+
28
+ ### Phase 2.0.0a (this release) — what shipped
29
+
30
+ This is the **mechanical rebrand** portion of Phase 2.0.0 of the unified memory-layer plan tracked in `~/workspace/the-glitch-kingdom/persistent-planning/.planning/layered-planning-with-mcp-and-hewtd-frontmatter/task_plan.md`. It includes:
31
+
32
+ - All publication-identity renames listed above
33
+ - Preview docs for the planned multi-corpus architecture (`docs/corpora-json.md`, `docs/smart-middle-activation.md`)
34
+ - README rebrand framing
35
+ - Bin alias for `semantic-memory`
36
+
37
+ ### Phase 2.0.0b (next release) — what's coming
38
+
39
+ The actual multi-corpus refactor — registry-driven indexer, per-corpus search verbs (`search_vault`, `search_code`, ...), `search_all` cross-corpus verb, smart-middle first-run detection, `corpora.json` schema implementation — ships in a follow-up PR. Until that lands, semantic-memory's runtime behavior is identical to semantic-sidekick 0.2.5.
40
+
41
+ ### Migration for existing users
42
+
43
+ ```bash
44
+ # Uninstall the old plugin
45
+ /plugin uninstall semantic-sidekick
46
+
47
+ # Install the new one (same marketplace repo, new plugin name)
48
+ /plugin marketplace add https://github.com/TheGlitchKing/semantic-sidekick
49
+ /plugin install semantic-memory@semantic-memory-marketplace
50
+ ```
51
+
52
+ Or for npm/global installs:
53
+
54
+ ```bash
55
+ npm uninstall -g @theglitchking/semantic-sidekick
56
+ npm install -g @theglitchking/semantic-memory
57
+ ```
58
+
59
+ Or as a project devDependency:
60
+
61
+ ```bash
62
+ npm uninstall @theglitchking/semantic-sidekick
63
+ npm install --save-dev @theglitchking/semantic-memory
64
+ ```
65
+
66
+ Existing on-disk state (the index, model cache, hooks, skills, slash commands) requires no changes. The new package reads from the same paths as the old one.
67
+
68
+ ### Inter-PR dependencies (this release)
69
+
70
+ - Hard-depends on: nothing (the regression-snapshot baseline already lives on main and gates this release)
71
+ - Soft-coupled with: hit-em-with-the-docs#3 (HEWTD 2.2.0 — `tier: "plan"` schema extension); persistent-planning#1 (3.0.0 lg-mode). Neither blocks this release; both ship coordinated for a coherent ecosystem-wide v1.0 launch.
72
+
73
+ ## [0.2.5] - 2026-04-28
74
+
75
+ ### Fixed
76
+ - **`<vault-context>` hook injected an unconditional cite-or-deflect imperative
77
+ on every prompt.** The injected block ended with `Instructions: Read the top
78
+ hits ... cite filenames in your response. If none of these actually answer
79
+ the question, say "not in vault" and name the nearest misses.` That string is
80
+ more specific and immediate than the CLAUDE.md rule that says "ignore on
81
+ non-lookup prompts," so models in consumer projects (e.g. RE-InvestorHub)
82
+ obeyed the inline string and blurted citations like
83
+ `Vault citation: keycloak-custom-image.md unrelated — not in vault for this`
84
+ on debugging, status, and directive prompts.
85
+
86
+ Fix: rewrote the Instructions string in `hooks/vault-context.js` to be
87
+ conditional and aligned with the CLAUDE.md cite-or-deflect rule — apply only
88
+ on project prose lookups; ignore silently on meta/tool/debugging/status/
89
+ directive/conversational prompts; explicitly forbid the "X unrelated"
90
+ narration. Also gated `main()` on script invocation so the hook can be
91
+ imported by tests, and added a regression test asserting the new shape.
92
+ Suite: 189/189.
93
+
94
+ ## [0.2.4] - 2026-04-26
95
+
96
+ ### Fixed
97
+ - **Stop hook emitted invalid output shape on early-exit paths.** The `183aa30`
98
+ fix patched `emitStop()` and the catch block to write `{}` instead of the
99
+ SessionStart-shaped `{hookSpecificOutput: {hookEventName: "Stop"}}` envelope
100
+ (Stop's schema rejects `hookSpecificOutput`). But two earlier short-circuits
101
+ in `main()` — when `findVaultPath` or `findCliBin` returns null — were still
102
+ routing through the generic `emit()` helper, which wrote the broken envelope
103
+ unconditionally. This surfaced in projects where Claude opened in a subdir
104
+ without a local `.mcp.json` or local `node_modules/@theglitchking/...`,
105
+ producing `Stop hook error: Hook JSON output validation failed — (root):
106
+ Invalid input` on every response.
107
+
108
+ Fix: introduced `emitNoop(eventName)` helper that branches on Stop and writes
109
+ `{}` for it. Wired into both early-exits and the catch block. Two regression
110
+ assertions added to `test/phase4/mode-hook.test.ts` covering the no-vault
111
+ and no-CLI-bin paths. Suite: 188/188.
112
+
113
+ ## [0.2.3] - 2026-04-22
114
+
115
+ ### Fixed
116
+ - **`vault-first` skill + CLAUDE.md rule over-triggered "not in vault"
117
+ deflection.** The rule was written as "cite or deflect on every answer";
118
+ in practice the UserPromptSubmit hook injects `<vault-context>` on *every*
119
+ prompt (including meta-questions, debugging, yes/no, directives, and
120
+ conversational turns), so Claude was opening every response with "not in
121
+ vault" regardless of whether the prompt was actually a vault-eligible
122
+ project lookup.
123
+
124
+ Fix: the cite-or-deflect rule now explicitly applies only when the *user's
125
+ question shape* is a project/operational lookup. Meta/tool/debug/status/
126
+ directive prompts → silently ignore the injected block. The filter is the
127
+ user's intent, not the hook's output. Updated in both `skills/vault-first/SKILL.md`
128
+ and the CLAUDE.md rule block.
129
+
130
+ ## [0.2.2] - 2026-04-22
131
+
132
+ ### Fixed
133
+ - **Docs MCP (`semantic-sidekick`) was silently removed by reconcile on every
134
+ SessionStart when `hit-em-with-the-docs` was enabled per-project but not
135
+ globally.** `reconcile.js:hewtdEnabled()` only checked `~/.claude/settings.json`;
136
+ per-project enablement (project `.claude/settings.json` or `.claude/settings.local.json`)
137
+ was ignored. Since isOurEntry recognized the docs entry as ours, the reconcile
138
+ removal path deleted it on every boot.
139
+ - Fix: `hewtdEnabled(projectRoot)` now checks all three scopes (user, project,
140
+ project-local) and returns true if hewtd is enabled in any of them. The docs
141
+ MCP now persists correctly for project-scope installs.
142
+
143
+ ## [0.2.1] - 2026-04-22
144
+
145
+ ### Fixed (critical)
146
+ - **SessionStart hook no longer crashes with `ERR_MODULE_NOT_FOUND` when
147
+ installed via `/plugin install`.** Claude Code's plugin extractor unpacks
148
+ the npm tarball but does not run `npm install` — so `hooks/session-start.js`'s
149
+ static `import { runSessionStart } from "@theglitchking/claude-plugin-runtime"`
150
+ failed at load time, producing the reported errors:
151
+
152
+ SessionStart:resume hook error
153
+ Failed with non-blocking status code: node:internal/modules/cjs/loader:1386
154
+ Failed with non-blocking status code: node:internal/modules/package_json_reader:314
155
+
156
+ Fix: rewrite `session-start.js` so the critical path (reconcile .mcp.json,
157
+ ensure .claude/.vault) uses zero external deps — `reconcile.js` is pure
158
+ node built-ins. The `claude-plugin-runtime` integration (auto-update policy)
159
+ is now a best-effort dynamic import — skipped silently when not resolvable.
160
+ The hook always emits a valid SessionStart response and never blocks the
161
+ session, even if every optional component is missing.
162
+
163
+ ## [0.2.0] - 2026-04-22
164
+
165
+ ### Phase 1 — Activation layer
166
+ - `vault-first` skill at `skills/vault-first/SKILL.md` with cite-or-deflect contract.
167
+ - SessionStart + UserPromptSubmit hooks backed by `hooks/vault-context.js`. Seeded search on session start; fingerprinted per-prompt injection with suppression of recent duplicates.
168
+ - CLAUDE.md vault-first rule block enforcing cite-or-deflect at system-prompt level.
169
+ - New `semantic-sidekick search` CLI subcommand (hybrid / text-only / JSON output) — hooks shell out instead of running an MCP client.
170
+ - 10-prompt conversational test suite at `test/phase1/run.js`. Pass criterion ≥7/10; current ≥9/10.
171
+
172
+ ### Phase 2 — Structure + capture
173
+ - Minimal default schema (`src/core/schema-default.ts`) with four types (note, decision, gotcha, source) + provenance fields + lint policy. Bootstrappable via `install_schema` MCP tool or `semantic-sidekick install-schema` CLI.
174
+ - `apply_patch` MCP tool — atomic multi-note ChangeSet with pre-check, schema validation, reverse-order rollback, dry-run.
175
+ - `synthesize_note` MCP tool — answer + sources → filed note with auto-wikilinks, routed through apply_patch.
176
+ - Lint suite: `find_schema_violations`, `find_missing_provenance`, `find_stale`, `lint_vault` (full report). MCP tools + `semantic-sidekick lint` CLI + `scripts/pre-commit-lint.sh` template.
177
+ - Stop hook with capture-cue detection (`\bbecause\b`, `\bthe fix was\b`, etc.) → `decision: "block"` prompt at session close.
178
+ - Parsed-doc cache (`.semantic-sidekick-index/docs.cache.json`) — hook latency dropped ~6s → ~0.7s (9x).
179
+
180
+ ### Phase 3 — Ingest + maintenance
181
+ - `ingest_source` MCP tool — source + extracted units → atomic ChangeSet with derived_from wiring. Auto-logs `kind=ingest` on success.
182
+ - Structured `log.md` at vault root: human bullet line + machine-readable `yaml event` blocks per entry. `log_event` + `log_query` MCP tools.
183
+ - Hierarchical INDEX.md auto-regen on apply_patch (creates/deletes/moves). Overflow signal at 100 entries.
184
+ - `find_broken_links` lint — cross-note wikilink validation, skips code blocks.
185
+ - `regenerate_index` MCP tool for manual regen.
186
+
187
+ ### Phase 4 — Routing + transitions
188
+ - `research-mode` skill — aggressive vault behavior for sustained investigation; every source filed; synthesis mandatory on exit.
189
+ - `outage-silence` skill — incident mode; suppresses auto-vault; forces postmortem on exit.
190
+ - `/mode` slash command — explicit mode setter (ground truth). Writes `.claude/.sidekick-mode`.
191
+ - `/vault <query>` slash command — explicit vault search, works in any mode including outage-silence.
192
+ - CLAUDE.md routing rule — visible `[research]` / `[outage]` prefix, transition-capture contract.
193
+ - Mode-aware hooks: UserPromptSubmit suppresses in outage-silence; Stop branches per mode (research-synthesis / outage-postmortem / vault-first generic).
194
+ - SessionStart resets mode to `vault-first` (relevance-decay at session boundary).
195
+
196
+ ### Phase 4.5 — Auto-logging + state-delta preload
197
+ - `apply_patch` / `synthesize_note` / `ingest_source` auto-log `kind=error` on failure, `kind=synthesis` / `kind=ingest` on success.
198
+ - Hook crashes auto-log `kind=error` with stack excerpt (no longer stderr-only and lost).
199
+ - SessionStart injects `<vault-state-since date="…">` block — 14-day log.md summary + 6 most recent entries. Future-Claude boots with "what past-me did this week."
200
+ - Mode drift (session ended in non-default mode) auto-logs `kind=mode_change` at next SessionStart.
201
+ - New CLI subcommands `log-event` + `log-query` so hooks and CI scripts write/read log.md without importing core.
202
+
203
+ ### Plugin packaging
204
+ - `.claude-plugin/plugin.json` + `marketplace.json` updated for Phase 1–4.5 scope (category: knowledge).
205
+ - `hooks/hooks.json` declares SessionStart + UserPromptSubmit + Stop hooks against `${CLAUDE_PLUGIN_ROOT}/hooks/vault-context.js`.
206
+ - `package.json` `files[]` now ships `skills/{vault-first,research-mode,outage-silence}` and `scripts/pre-commit-lint.sh`.
207
+
208
+ ### Fixes
209
+ - Stop hook output shape corrected — uses top-level `decision` / `reason` instead of `hookSpecificOutput` (which Claude Code rejects for Stop).
210
+ - CLI `lint --json` stdout flush fixed — large JSON payloads were truncating mid-array when `process.exit` ran before flush.
211
+ - `src/core/index.ts` exports all Phase 2/3 public APIs (applyPatch, buildSynthesizeChangeSet, buildIngestChangeSet, lintVault, logEvent/logQuery, schema helpers).
212
+
213
+ ### Tests
214
+ - 186/186 tests passing (from 139 at 0.1.0).
215
+ - 47 new tests across schema, patch, synthesize, lint, ingest, log, index-regen, mode-hook, state-delta, auto-logging.
216
+
217
+ ### Docs
218
+ - Full operator's manual in `.documentation/`: INDEX + 14 topic docs + 4 per-phase change logs. See `.documentation/INDEX.md`.
219
+
220
+ ## [0.1.0] - 2026-04-21
221
+
222
+ ### Forked from semantic-pages 0.10.0
223
+ Initial fork. Package renamed, bin renamed (`semantic-sidekick`), MCP server identifier changed, index directory changed (`.semantic-sidekick-index`). All retrieval functionality inherited unchanged from semantic-pages.
224
+
225
+ ### Planned (per `.planning/semantic-sidekick/task_plan.md`)
226
+ - **Phase 1**: Activation layer — SessionStart + UserPromptSubmit hooks, `vault-first` skill with conversational cue detection, CLAUDE.md rule. Hypothesis test: does the vault get used without explicit invocation?
227
+ - **Phase 2**: Structure — `vault.schema.yml`, provenance frontmatter, `apply_patch` MCP tool, `synthesize_note`, cheap lint.
228
+ - **Phase 3**: Ingest + maintenance — `ingest_source`, structured log, hierarchical indexes.
229
+ - **Phase 4**: Routing — mode skills (research / default / outage), signal weighting, transition capture.
230
+ - **Phase 5**: Advanced — contradiction detection, situation snapshots, calibration loop.
231
+
232
+ ### Heritage
233
+ Upstream substrate tracked at `git@github-glitch:TheGlitchKing/semantic-pages.git` (remote `upstream`, push disabled). Substrate fixes are cherry-picked from upstream; semantic-sidekick does not push back.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TheGlitchKing
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.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # semantic-memory (formerly semantic-sidekick)
2
+
3
+ > A shelf is retrievable. A prosthesis is present.
4
+ > A vault is local. Memory is layered.
5
+
6
+ > **v1.0.0 rebrand** — `semantic-sidekick` → `semantic-memory`. The npm package, plugin name, MCP server name, and marketplace identity all change. **Internal storage layout (`.semantic-sidekick-index/`, `~/.semantic-sidekick/models/`) is preserved** — existing installs continue to read their indices and model caches without re-indexing or re-downloading. See [CHANGELOG.md](./CHANGELOG.md) for the full migration. The `bin/semantic-sidekick` command remains as an alias for `bin/semantic-memory` during the transition.
7
+
8
+ semantic-memory is the unified memory-layer plugin for Claude Code. **One MCP server, multiple typed corpora** (vault, code, plans, docs, research, project-map), a unified cross-corpus knowledge graph, conditional tool registration based on which corpora are active, in-process drift detection, and human↔code translation via the babel-fish glossary side-channel.
9
+
10
+ The original semantic-sidekick framing — activation / mode-routing / capture layer on top of [semantic-pages](https://github.com/TheGlitchKing/semantic-pages) — is preserved as the `vault` corpus's behavior. What's new in 1.0.0 is the multi-corpus architecture that absorbs documentation, code, plans, research, and babel-fish project-maps into the same MCP surface.
11
+
12
+ ## Status
13
+
14
+ **Phases 1–4 shipped** (2026-04-22). Layers 2–5 fully implemented and committed to `feat/sidekick-layers`. Phase 5 (advanced calibration + contradiction detection) is explicitly gated per the plan ("only build when Phase 4 has been in use for ≥2 weeks and a specific failure demands it").
15
+
16
+ | Phase | What it adds | Commit |
17
+ |---|---|---|
18
+ | **1 — Activation** | `vault-first` skill + SessionStart/UserPromptSubmit hooks + CLAUDE.md cite-or-deflect rule | `c8f722f` |
19
+ | **2 — Structure + Capture** | schema, `apply_patch`, `synthesize_note`, lint (schema/provenance/stale), Stop-hook capture-on-close, parsed-doc cache (9x hook speedup) | `1807c58` |
20
+ | **3 — Ingest + Maintenance** | `ingest_source`, structured `log.md` + `log_event`/`log_query`, hierarchical index auto-regen, broken-link lint | `b8d4492` |
21
+ | **4 — Routing + Transitions** | `research-mode` + `outage-silence` skills, `/mode` + `/vault` commands, mode-aware hooks, transition-capture prompts | `75ee813` |
22
+
23
+ Per-phase design docs live in `.documentation/phase-{1..4}-*.md`.
24
+
25
+ ## Quickstart as a Claude Code plugin
26
+
27
+ ```bash
28
+ # Add the marketplace (from git)
29
+ /plugin marketplace add https://github.com/TheGlitchKing/semantic-sidekick
30
+
31
+ # Install the plugin
32
+ /plugin install semantic-sidekick
33
+ ```
34
+
35
+ On install:
36
+ - `.mcp.json` is reconciled to point at `.claude/.vault` (or your `--notes <path>`).
37
+ - Skills (`vault-first`, `research-mode`, `outage-silence`) are linked into `.claude/skills/`.
38
+ - Hooks (`SessionStart`, `UserPromptSubmit`, `Stop`) register from `hooks/hooks.json`.
39
+ - Commands (`/mode`, `/vault`) become available.
40
+
41
+ First run: `semantic-sidekick --notes ./path/to/vault --reindex` to build the vector index (writes `.semantic-sidekick-index/`). Subsequent hook calls hit the cache in <1s.
42
+
43
+ ## Using the modes
44
+
45
+ | Command | Effect |
46
+ |---|---|
47
+ | `/mode research` | Enter research-mode. Every source introduced gets filed via `ingest_source`; mandatory `synthesize_note` on exit. Visible `[research]` prefix. |
48
+ | `/mode outage-silence` | Enter outage-silence. No proactive vault search. Terse responses. Postmortem drafted as `synthesize_note` on exit. Visible `[outage]` prefix. |
49
+ | `/mode vault-first` | Return to default. Project-scoped prose questions trigger vault consultation with cite-or-deflect. |
50
+ | `/mode status` | Print the current mode. |
51
+ | `/vault <query>` | Explicit vault query. Always works, even in outage-silence. |
52
+
53
+ ## 33 MCP tools shipped
54
+
55
+ Search (4): `search_semantic`, `search_text`, `search_graph`, `search_hybrid`
56
+ Read (3): `read_note`, `read_multiple_notes`, `list_notes`
57
+ Write (4): `create_note`, `update_note`, `delete_note`, `move_note`
58
+ Metadata (4): `get_frontmatter`, `update_frontmatter`, `manage_tags`, `rename_tag`
59
+ Graph (4): `backlinks`, `forwardlinks`, `graph_path`, `graph_statistics`
60
+ System (2): `get_stats`, `reindex`
61
+ **Patch/Synthesis (4):** `apply_patch`, `synthesize_note`, `ingest_source`, `install_schema`
62
+ **Lint (4):** `find_schema_violations`, `find_missing_provenance`, `find_stale`, `find_broken_links`, `lint_vault`
63
+ **Log/Maintenance (3):** `log_event`, `log_query`, `regenerate_index`
64
+
65
+ ## Relationship to semantic-pages
66
+
67
+ - **Substrate** (retrieval, graph, MCP tools): inherited unchanged from semantic-pages.
68
+ - **Upstream remote** tracks semantic-pages for cherry-picking substrate fixes. Push is disabled; sidekick does not push back.
69
+ - **What's net-new in sidekick**: activation hooks, mode-routing skills, capture workflows (ingest/synthesize), lint suite, provenance + schema layer.
70
+
71
+ ## Architecture (five layers)
72
+
73
+ 1. **Substrate** — markdown vault + hybrid search + graph + MCP (inherited)
74
+ 2. **Structure** — schema, provenance frontmatter, atomic `apply_patch`, structured log
75
+ 3. **Workflows** — `ingest_source`, `synthesize_note`, lint suite
76
+ 4. **Activation** — SessionStart / UserPromptSubmit / Stop hooks, `vault-first` skill, CLAUDE.md rules
77
+ 5. **Routing** — mode skills (research / default / outage), signal weighting, transition capture
78
+
79
+ See the originating design discussion in `.planning/semantic-sidekick/` for rationale and phase-by-phase build plan.
80
+
81
+ ## Development
82
+
83
+ ```bash
84
+ npm install
85
+ npm run build
86
+ node dist/cli/index.js --version
87
+ ```
88
+
89
+ ## License
90
+
91
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/cli/index.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/cli/index.js";
@@ -0,0 +1,6 @@
1
+ ---
2
+ description: Verify the local semantic-sidekick install starts cleanly; self-heals npx-cache ERR_MODULE_NOT_FOUND
3
+ allowed-tools: Bash(npx:*)
4
+ ---
5
+
6
+ Run `npx --no @theglitchking/semantic-sidekick healthcheck` and relay the output. If it reports a fragile `.mcp.json` form, suggest running `/semantic-sidekick:normalize-config`.
@@ -0,0 +1,65 @@
1
+ ---
2
+ description: Set or query the active semantic-sidekick mode (vault-first | research | outage-silence)
3
+ argument-hint: "[research|vault-first|outage-silence|status]"
4
+ allowed-tools: Bash(cat:*), Bash(cp:*), Bash(test:*), Bash(node:*), Read, Write
5
+ ---
6
+
7
+ # /mode — semantic-sidekick mode control
8
+
9
+ The user invoked `/mode $ARGUMENTS`. This is the explicit ground-truth override for the semantic-sidekick routing layer.
10
+
11
+ ## Your job
12
+
13
+ 1. **Parse `$ARGUMENTS`** — expected values: `research`, `vault-first`, `outage-silence`, `status` (or empty = status).
14
+
15
+ 2. **Read current mode** from `.claude/.sidekick-mode` (a plain text file containing just the mode name). If the file doesn't exist, the current mode is `vault-first` (default).
16
+
17
+ 3. **If the arg is `status` or empty**, print the current mode and exit:
18
+ ```
19
+ current mode: <mode>
20
+ ```
21
+
22
+ 4. **If the arg is a valid mode name** (`research`, `vault-first`, `outage-silence`), do the transition:
23
+
24
+ a. **If transitioning OUT of `research`** → emit the research-exit synthesis prompt:
25
+ > Exiting research-mode. Before switching: the session accumulated source notes and findings. Draft a `synthesize_note` now (dry-run first via `mcp__semantic-vault__synthesize_note` with `dry_run: true`, then apply if the preview looks right). Confirm with the user that the synthesis is filed before finishing the mode change.
26
+
27
+ b. **If transitioning OUT of `outage-silence`** → emit the outage-exit postmortem prompt:
28
+ > Exiting outage-silence. The incident is (presumably) resolved. Before switching: draft a postmortem as a `synthesize_note` with `type: gotcha` (or `decision` if the fix is architectural) covering timeline, root cause, fix, and preventive actions. Dry-run first, confirm with the user, then apply.
29
+
30
+ c. **Write the new mode** to `.claude/.sidekick-mode` (single line, no trailing newline noise):
31
+ ```bash
32
+ mkdir -p .claude && printf '%s' "<new-mode>" > .claude/.sidekick-mode
33
+ ```
34
+
35
+ d. **Report the transition** to the user in one line:
36
+ ```
37
+ mode: <old> → <new>
38
+ ```
39
+
40
+ e. If the new mode is `research` or `outage-silence`, invoke the corresponding skill (the skill description will carry you forward). The `vault-first` default is already ambient.
41
+
42
+ 5. **If the arg is an unknown value**, print a one-line error listing the valid values and exit.
43
+
44
+ ## Notes
45
+
46
+ - The mode file is per-project, stored in `.claude/.sidekick-mode`. It persists across sessions.
47
+ - `SessionStart` resets the mode to `vault-first` if the file is missing or contains an invalid value.
48
+ - You (Claude) are also the router — the mode file is a signal, not a command. Even without `/mode`, skill descriptions route based on conversational cues. `/mode` is the explicit override.
49
+
50
+ ## Example
51
+
52
+ User: `/mode research`
53
+
54
+ You (on read): current mode is `vault-first` → transitioning to `research` → no exit-capture needed (not leaving research or outage). Write the file. Report:
55
+ ```
56
+ mode: vault-first → research
57
+ ```
58
+ Then follow the `research-mode` skill going forward.
59
+
60
+ User: `/mode vault-first`
61
+
62
+ You (on read): current mode is `research` → transitioning out of research → emit the synthesis prompt FIRST, wait for the user's go-ahead or confirmation that synthesis is filed, then write the file. Report:
63
+ ```
64
+ mode: research → vault-first
65
+ ```
@@ -0,0 +1,6 @@
1
+ ---
2
+ description: Rewrite fragile npx-@latest entries in .mcp.json to the stable node-against-node_modules form
3
+ allowed-tools: Bash(npx:*)
4
+ ---
5
+
6
+ Run `npx --no @theglitchking/semantic-sidekick normalize-config` and report the result to the user. Mention that `.mcp.json.bak` was created as a safety backup, and that the MCPs need to be toggled in `/mcp` to pick up the change.
@@ -0,0 +1,16 @@
1
+ ---
2
+ description: Get or set the semantic-sidekick update policy (auto | nudge | off)
3
+ allowed-tools: Bash(npx:*)
4
+ argument-hint: "[auto|nudge|off]"
5
+ ---
6
+
7
+ Arguments: $ARGUMENTS
8
+
9
+ - If `$ARGUMENTS` is empty, run `npx --no @theglitchking/semantic-sidekick policy` and report the current policy and config path.
10
+ - If `$ARGUMENTS` is one of `auto`, `nudge`, `off`, run `npx --no @theglitchking/semantic-sidekick policy $ARGUMENTS` and confirm the new setting to the user.
11
+ - If `$ARGUMENTS` is anything else, tell the user the valid values are `auto`, `nudge`, `off`.
12
+
13
+ Policies:
14
+ - `auto` — auto-run `npm update @theglitchking/semantic-sidekick` at session start when a newer version is available.
15
+ - `nudge` — print a one-liner when a newer version is available (default).
16
+ - `off` — do not check for updates.
@@ -0,0 +1,6 @@
1
+ ---
2
+ description: Re-run the skill linker — refresh symlinks from node_modules into .claude/skills/
3
+ allowed-tools: Bash(npx:*)
4
+ ---
5
+
6
+ Run `npx --no @theglitchking/semantic-sidekick relink` and report the result.
@@ -0,0 +1,6 @@
1
+ ---
2
+ description: Show installed version, latest available version, current update policy, and hook registration state
3
+ allowed-tools: Bash(npx:*)
4
+ ---
5
+
6
+ Run `npx --no @theglitchking/semantic-sidekick status` and relay the output to the user verbatim.
@@ -0,0 +1,6 @@
1
+ ---
2
+ description: Update semantic-sidekick to the latest version (runs npm update + re-links skills)
3
+ allowed-tools: Bash(npx:*)
4
+ ---
5
+
6
+ Run `npx --no @theglitchking/semantic-sidekick update` and report the before/after versions to the user. If the project doesn't have a local install, fall back to `npx -y @theglitchking/semantic-sidekick update` and note that in your summary.
@@ -0,0 +1,21 @@
1
+ ---
2
+ description: Explicit vault search — escape hatch that works in any mode including outage-silence
3
+ argument-hint: "<natural-language query>"
4
+ allowed-tools: mcp__semantic-vault__search_hybrid, mcp__semantic-vault__read_note, mcp__semantic-vault__get_stats
5
+ ---
6
+
7
+ # /vault — explicit vault search
8
+
9
+ The user typed `/vault $ARGUMENTS`. This is the explicit vault query that overrides mode gating.
10
+
11
+ Even in `outage-silence` mode (which suppresses auto-vault activity), `/vault <query>` is always respected.
12
+
13
+ ## Your job
14
+
15
+ 1. **Run `mcp__semantic-vault__search_hybrid`** with `$ARGUMENTS` as the query.
16
+ 2. **Read the top 2–3 hits in full** via `mcp__semantic-vault__read_note`.
17
+ 3. **Answer the query using those notes**, citing the paths.
18
+ 4. **Do not** file anything (no `ingest_source` / `synthesize_note`) unless the user follows up asking to. This is a read path.
19
+ 5. **Stay in the current mode** — don't let a `/vault` call exit outage-silence or enter research-mode.
20
+
21
+ If the query doesn't return useful hits, say "not in vault" and name the closest misses.