Skip to content

Commit 1f23531

Browse files
emmahydeclaude
andcommitted
refactor: rename semantic-memory to sem-mem throughout codebase
- Rename Python module: src/semantic_memory/ → src/sem_mem/ - Rename class: SemanticMemoryApp → SemMemApp - Update CLI command: semantic-memory → sem-mem - Update all imports, configs, docs, and tests - Fix CI: mock OpenAI embeddings in test_server.py - Add injectable embeddings param to create_app() - Add semver release workflow (.github/workflows/release.yml) - Add one-time setup script (scripts/setup.sh) - Rename skill: using-semantic-memory → using-sem-mem - Update default DB path: ~/.claude/sem-mem/memory.db Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8abbbc8 commit 1f23531

File tree

24 files changed

+266
-76
lines changed

24 files changed

+266
-76
lines changed

.claude-plugin/plugin.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "semantic-memory",
2+
"name": "sem-mem",
33
"version": "1.0.0",
4-
"description": "Teaches Claude how to use the semantic-memory MCP server for persistent knowledge storage, retrieval, and graph traversal. Includes PreCompact hook to preserve insights before context compaction.",
4+
"description": "Teaches Claude how to use the sem-mem MCP server for persistent knowledge storage, retrieval, and graph traversal. Includes PreCompact hook to preserve insights before context compaction.",
55
"author": {
66
"name": "Emma Hyde"
77
},
88
"homepage": "https://github.com/emmahyde/brainspace",
99
"repository": "https://github.com/emmahyde/brainspace",
1010
"license": "MIT",
11-
"keywords": ["semantic-memory", "mcp", "knowledge-graph", "embeddings", "insights"]
11+
"keywords": ["sem-mem", "mcp", "knowledge-graph", "embeddings", "insights"]
1212
}

.github/workflows/release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
# Skip if commit message contains [skip ci] or [skip release]
14+
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip release]')"
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
21+
- name: Determine version bump type
22+
id: bump_type
23+
run: |
24+
# Get PR number from merge commit
25+
PR_NUMBER=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=#)\d+(?=\))' || echo "")
26+
27+
BUMP_TYPE="patch"
28+
29+
# Check commit message for conventional commit patterns
30+
if echo "${{ github.event.head_commit.message }}" | grep -qE "BREAKING CHANGE|^[a-z]+!:"; then
31+
BUMP_TYPE="major"
32+
elif echo "${{ github.event.head_commit.message }}" | grep -qE "^feat:"; then
33+
BUMP_TYPE="minor"
34+
elif [ -n "$PR_NUMBER" ]; then
35+
# Check PR labels if we have a PR number
36+
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' || echo "")
37+
if echo "$LABELS" | grep -q "major"; then
38+
BUMP_TYPE="major"
39+
elif echo "$LABELS" | grep -q "minor"; then
40+
BUMP_TYPE="minor"
41+
fi
42+
fi
43+
44+
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
45+
echo "Detected bump type: $BUMP_TYPE"
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Bump version
50+
id: bump_version
51+
run: |
52+
# Read current version
53+
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
54+
echo "Current version: $CURRENT_VERSION"
55+
56+
# Split version into parts
57+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
58+
59+
# Bump based on type
60+
case "${{ steps.bump_type.outputs.bump_type }}" in
61+
major)
62+
MAJOR=$((MAJOR + 1))
63+
MINOR=0
64+
PATCH=0
65+
;;
66+
minor)
67+
MINOR=$((MINOR + 1))
68+
PATCH=0
69+
;;
70+
patch)
71+
PATCH=$((PATCH + 1))
72+
;;
73+
esac
74+
75+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
76+
echo "New version: $NEW_VERSION"
77+
78+
# Update pyproject.toml
79+
sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
80+
81+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
82+
83+
- name: Commit version bump
84+
run: |
85+
git config user.name "github-actions[bot]"
86+
git config user.email "github-actions[bot]@users.noreply.github.com"
87+
git add pyproject.toml
88+
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }} [skip ci]"
89+
git push
90+
91+
- name: Create tag and release
92+
run: |
93+
TAG="v${{ steps.bump_version.outputs.new_version }}"
94+
git tag "$TAG"
95+
git push origin "$TAG"
96+
97+
# Create GitHub release (this triggers publish.yml)
98+
gh release create "$TAG" \
99+
--title "Release $TAG" \
100+
--generate-notes
101+
env:
102+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CLAUDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ uv run pytest tests/test_storage.py
2222
uv run pytest tests/test_storage.py::TestInsightStoreInit::test_initialize_creates_tables
2323

2424
# Run MCP server directly
25-
uv run semantic-memory
25+
uv run sem-mem
2626
```
2727

2828
## Architecture
@@ -31,17 +31,17 @@ uv run semantic-memory
3131

3232
**Data flow (search):** Query → embed → cosine similarity search in `InsightStore`, or subject-based lookup, or graph traversal via shared-subject relations.
3333

34-
### Source layout (`src/semantic_memory/`)
34+
### Source layout (`src/sem_mem/`)
3535

3636
- **`models.py`**`Frame` enum (CAUSAL, CONSTRAINT, PATTERN, EQUIVALENCE, TAXONOMY, PROCEDURE), `Insight`, `GitContext`, `SearchResult`
3737
- **`normalizer.py`** — LLM decomposition/classification via Anthropic API (or Bedrock). Uses `DECOMPOSE_PROMPT` and `CLASSIFY_PROMPT`
3838
- **`embeddings.py`** — Embedding generation (OpenAI or Bedrock Titan), L2-normalized float32 vectors. `create_embedding_engine()` factory selects provider.
3939
- **`storage.py`**`InsightStore` class: SQLite persistence, migration system, subject indexing, knowledge graph queries
40-
- **`server.py`**`SemanticMemoryApp` orchestrator + MCP tool definitions (9 tools: `store_insight`, `search_insights`, `list_insights`, `update_insight`, `forget`, `search_by_subject`, `related_insights`, `add_subject_relation`, `get_subject_relations`)
40+
- **`server.py`**`SemMemApp` orchestrator + MCP tool definitions (9 tools: `store_insight`, `search_insights`, `list_insights`, `update_insight`, `forget`, `search_by_subject`, `related_insights`, `add_subject_relation`, `get_subject_relations`)
4141

4242
### Database
4343

44-
Default location: `~/.claude/semantic-memory/memory.db` (override with `MEMORY_DB_PATH` env var).
44+
Default location: `~/.claude/sem-mem/memory.db` (override with `MEMORY_DB_PATH` env var).
4545

4646
Four tables: `insights`, `subjects` (with `insight_subjects` junction), `insight_relations`, `subject_relations`. Schema versioned via `schema_versions` table.
4747

@@ -72,4 +72,4 @@ Migrations are Python functions in `storage.py` (named `_migrate_NNN_*`), tracke
7272

7373
## Plugin
7474

75-
This repo is also a Claude Code plugin (`claude plugin install semantic-memory@brainspace`). Plugin files live at the repo root: `.claude-plugin/`, `skills/`, `hooks/`. Includes a `using-semantic-memory` skill and a `PreCompact` hook.
75+
This repo is also a Claude Code plugin (`claude plugin install sem-mem@brainspace`). Plugin files live at the repo root: `.claude-plugin/`, `skills/`, `hooks/`. Includes a `using-sem-mem` skill and a `PreCompact` hook.

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# semantic-memory
1+
# sem-mem
22

33
An MCP server that gives AI agents persistent, intent-based memory. Text is decomposed into atomic insights, classified into semantic frames, embedded as vectors, and stored in a SQLite knowledge graph with subject indexing.
44

@@ -43,14 +43,14 @@ export AWS_REGION=us-east-1
4343
### 3. Install the Claude Code plugin
4444

4545
```bash
46-
claude plugin install semantic-memory@brainspace
46+
claude plugin install sem-mem@brainspace
4747
```
4848

4949
### 4. Verify
5050

5151
```bash
5252
uv run pytest # 85 tests pass
53-
uv run semantic-memory # server starts
53+
uv run sem-mem # server starts
5454
```
5555

5656
## Configuration
@@ -61,7 +61,7 @@ uv run semantic-memory # server starts
6161
|---|---|---|
6262
| `OPENAI_API_KEY` | Yes* | Embedding generation via OpenAI (text-embedding-3-small) |
6363
| `ANTHROPIC_API_KEY` | Yes* | Insight normalization via Anthropic (Claude Haiku) |
64-
| `MEMORY_DB_PATH` | No | Database path. Default: `~/.claude/semantic-memory/memory.db` |
64+
| `MEMORY_DB_PATH` | No | Database path. Default: `~/.claude/sem-mem/memory.db` |
6565
| `EMBEDDING_PROVIDER` | No | `openai` (default) or `bedrock` |
6666
| `LLM_PROVIDER` | No | `anthropic` (default) or `bedrock` |
6767
| `AWS_PROFILE` | No | AWS SSO profile name (required for Bedrock) |
@@ -78,14 +78,14 @@ Add to your MCP settings (see `mcp-config-example.json`):
7878
```json
7979
{
8080
"mcpServers": {
81-
"semantic-memory": {
81+
"sem-mem": {
8282
"command": "python3",
83-
"args": ["-m", "semantic_memory.server"],
83+
"args": ["-m", "sem_mem.server"],
8484
"env": {
85-
"MEMORY_DB_PATH": "~/.claude/semantic-memory/memory.db",
85+
"MEMORY_DB_PATH": "~/.claude/sem-mem/memory.db",
8686
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
8787
},
88-
"cwd": "/path/to/semantic-memory/src"
88+
"cwd": "/path/to/sem-mem/src"
8989
}
9090
}
9191
}
@@ -98,17 +98,17 @@ To use AWS Bedrock instead of OpenAI/Anthropic APIs:
9898
```json
9999
{
100100
"mcpServers": {
101-
"semantic-memory": {
101+
"sem-mem": {
102102
"command": "python3",
103-
"args": ["-m", "semantic_memory.server"],
103+
"args": ["-m", "sem_mem.server"],
104104
"env": {
105-
"MEMORY_DB_PATH": "~/.claude/semantic-memory/memory.db",
105+
"MEMORY_DB_PATH": "~/.claude/sem-mem/memory.db",
106106
"EMBEDDING_PROVIDER": "bedrock",
107107
"LLM_PROVIDER": "bedrock",
108108
"AWS_PROFILE": "your-sso-profile",
109109
"AWS_REGION": "us-east-1"
110110
},
111-
"cwd": "/path/to/semantic-memory/src"
111+
"cwd": "/path/to/sem-mem/src"
112112
}
113113
}
114114
}
@@ -212,9 +212,9 @@ Migrations run automatically on startup. Currently at version 4.
212212
This repo is also a Claude Code plugin. Install with:
213213

214214
```bash
215-
claude plugin install semantic-memory@brainspace
215+
claude plugin install sem-mem@brainspace
216216
```
217217

218218
Includes:
219-
- **Skill** (`using-semantic-memory`) — search strategy guide, subject kinds/relations reference, best practices
219+
- **Skill** (`using-sem-mem`) — search strategy guide, subject kinds/relations reference, best practices
220220
- **PreCompact hook** — prompts Claude to store key insights before context compaction

hooks/hooks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "Semantic Memory hooks — preserves knowledge before context compaction",
2+
"description": "Sem-Mem hooks — preserves knowledge before context compaction",
33
"hooks": {
44
"PreCompact": [
55
{

hooks/scripts/pre-compact.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# otherwise be lost when the conversation window is compacted.
55
#
66
# Strategy: Read hook input, output a system message instructing Claude
7-
# to store key insights via semantic-memory MCP tools before compaction.
7+
# to store key insights via sem-mem MCP tools before compaction.
88

99
set -euo pipefail
1010

mcp-config-example.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"mcpServers": {
3-
"semantic-memory": {
3+
"sem-mem": {
44
"command": "python3",
5-
"args": ["-m", "semantic_memory.server"],
5+
"args": ["-m", "sem_mem.server"],
66
"env": {
7-
"MEMORY_DB_PATH": "~/.claude/semantic-memory/memory.db",
7+
"MEMORY_DB_PATH": "~/.claude/sem-mem/memory.db",
88
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
99
},
10-
"cwd": "/path/to/semantic-memory/src"
10+
"cwd": "/path/to/sem-mem/src"
1111
},
12-
"semantic-memory-bedrock": {
12+
"sem-mem-bedrock": {
1313
"command": "python3",
14-
"args": ["-m", "semantic_memory.server"],
14+
"args": ["-m", "sem_mem.server"],
1515
"env": {
16-
"MEMORY_DB_PATH": "~/.claude/semantic-memory/memory.db",
16+
"MEMORY_DB_PATH": "~/.claude/sem-mem/memory.db",
1717
"EMBEDDING_PROVIDER": "bedrock",
1818
"LLM_PROVIDER": "bedrock",
1919
"AWS_PROFILE": "your-sso-profile",
2020
"AWS_REGION": "us-east-1"
2121
},
22-
"cwd": "/path/to/semantic-memory/src"
22+
"cwd": "/path/to/sem-mem/src"
2323
}
2424
}
2525
}

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ dev = [
1919
]
2020

2121
[project.scripts]
22-
semantic-memory = "semantic_memory.server:main"
22+
sem-mem = "sem_mem.server:main"
2323

2424
[build-system]
2525
requires = ["hatchling"]
2626
build-backend = "hatchling.build"
2727

2828
[tool.hatch.build.targets.wheel]
29-
packages = ["src/semantic_memory"]
29+
packages = ["src/sem_mem"]
3030

3131
[tool.pytest.ini_options]
3232
asyncio_mode = "auto"

scripts/generate_dummy_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# Add src to path
1212
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
1313

14-
from semantic_memory.embeddings import EmbeddingEngine
15-
from semantic_memory.models import Frame, Insight
16-
from semantic_memory.storage import InsightStore
14+
from sem_mem.embeddings import EmbeddingEngine
15+
from sem_mem.models import Frame, Insight
16+
from sem_mem.storage import InsightStore
1717

1818

1919
# Template components for generating realistic insights

scripts/setup.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
# One-time setup script for the sem-mem MCP server.
3+
# Usage: bash scripts/setup.sh
4+
# Safe to run multiple times (idempotent).
5+
set -euo pipefail
6+
7+
GREEN='\033[0;32m'
8+
YELLOW='\033[1;33m'
9+
RED='\033[0;31m'
10+
NC='\033[0m'
11+
12+
info() { printf "${GREEN}[OK]${NC} %s\n" "$1"; }
13+
warn() { printf "${YELLOW}[WARN]${NC} %s\n" "$1"; }
14+
error() { printf "${RED}[ERROR]${NC} %s\n" "$1"; }
15+
16+
# 1. Check for uv, install if missing
17+
if command -v uv &>/dev/null; then
18+
info "uv is already installed ($(uv --version))"
19+
else
20+
warn "uv not found -- installing..."
21+
curl -LsSf https://astral.sh/uv/install.sh | sh
22+
export PATH="$HOME/.local/bin:$PATH"
23+
info "uv installed ($(uv --version))"
24+
fi
25+
26+
# 2. Install the sem-mem package
27+
if uv tool list 2>/dev/null | grep -q '^sem-mem '; then
28+
info "sem-mem is already installed"
29+
else
30+
echo "Installing sem-mem..."
31+
uv tool install sem-mem
32+
info "sem-mem installed"
33+
fi
34+
35+
# 3. Create default DB directory
36+
DB_DIR="$HOME/.claude/sem-mem"
37+
mkdir -p "$DB_DIR"
38+
info "Database directory ready: $DB_DIR"
39+
40+
# 4. Check required environment variables
41+
MISSING=0
42+
for var in OPENAI_API_KEY ANTHROPIC_API_KEY; do
43+
if [[ -z "${!var:-}" ]]; then
44+
warn "Environment variable $var is not set (required for default providers)"
45+
MISSING=1
46+
else
47+
info "$var is set"
48+
fi
49+
done
50+
51+
if [[ "$MISSING" -eq 1 ]]; then
52+
echo ""
53+
warn "You can skip OPENAI_API_KEY / ANTHROPIC_API_KEY if using Bedrock providers:"
54+
echo " export EMBEDDING_PROVIDER=bedrock"
55+
echo " export LLM_PROVIDER=bedrock"
56+
echo " export AWS_PROFILE=<your-profile>"
57+
fi
58+
59+
# 5. Summary
60+
echo ""
61+
echo "========================================="
62+
echo " sem-mem setup complete"
63+
echo "========================================="
64+
echo ""
65+
echo "Run the MCP server:"
66+
echo " uv tool run sem-mem"
67+
echo ""
68+
echo "Or install as a Claude Code plugin:"
69+
echo " claude plugin install sem-mem@brainspace"
70+
echo ""
71+
echo "Default database location:"
72+
echo " $DB_DIR/memory.db"
73+
echo ""

0 commit comments

Comments
 (0)