laminark 0.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.
- package/README.md +147 -0
- package/package.json +65 -0
- package/plugin/.claude-plugin/plugin.json +13 -0
- package/plugin/.mcp.json +12 -0
- package/plugin/CLAUDE.md +10 -0
- package/plugin/commands/recall.md +55 -0
- package/plugin/commands/remember.md +34 -0
- package/plugin/commands/resume.md +45 -0
- package/plugin/commands/stash.md +34 -0
- package/plugin/commands/status.md +33 -0
- package/plugin/dist/analysis/worker.d.ts +1 -0
- package/plugin/dist/analysis/worker.js +233 -0
- package/plugin/dist/analysis/worker.js.map +1 -0
- package/plugin/dist/config-t8LZeB-u.mjs +90 -0
- package/plugin/dist/config-t8LZeB-u.mjs.map +1 -0
- package/plugin/dist/hooks/handler.d.ts +286 -0
- package/plugin/dist/hooks/handler.d.ts.map +1 -0
- package/plugin/dist/hooks/handler.js +2413 -0
- package/plugin/dist/hooks/handler.js.map +1 -0
- package/plugin/dist/index.d.ts +447 -0
- package/plugin/dist/index.d.ts.map +1 -0
- package/plugin/dist/index.js +7334 -0
- package/plugin/dist/index.js.map +1 -0
- package/plugin/dist/observations-CorAAc1A.d.mts +192 -0
- package/plugin/dist/observations-CorAAc1A.d.mts.map +1 -0
- package/plugin/dist/tool-registry-e710BvXq.mjs +3574 -0
- package/plugin/dist/tool-registry-e710BvXq.mjs.map +1 -0
- package/plugin/hooks/hooks.json +78 -0
- package/plugin/laminark.db +0 -0
- package/plugin/package.json +17 -0
- package/plugin/scripts/README.md +65 -0
- package/plugin/scripts/bump-version.sh +42 -0
- package/plugin/scripts/dev-sync.sh +58 -0
- package/plugin/scripts/ensure-deps.sh +15 -0
- package/plugin/scripts/install.sh +139 -0
- package/plugin/scripts/local-install.sh +138 -0
- package/plugin/scripts/uninstall.sh +133 -0
- package/plugin/scripts/update.sh +39 -0
- package/plugin/scripts/verify-install.sh +87 -0
- package/plugin/skills/status/SKILL.md +6 -0
- package/plugin/ui/activity.js +197 -0
- package/plugin/ui/app.js +1612 -0
- package/plugin/ui/graph.js +2560 -0
- package/plugin/ui/help/activity-feed.png +0 -0
- package/plugin/ui/help/analysis-panel.png +0 -0
- package/plugin/ui/help/graph-toolbar.png +0 -0
- package/plugin/ui/help/graph-view.png +0 -0
- package/plugin/ui/help/settings.png +0 -0
- package/plugin/ui/help/timeline.png +0 -0
- package/plugin/ui/help.js +932 -0
- package/plugin/ui/index.html +756 -0
- package/plugin/ui/settings.js +1414 -0
- package/plugin/ui/styles.css +3856 -0
- package/plugin/ui/timeline.js +652 -0
- package/plugin/ui/tools.js +826 -0
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Laminark
|
|
2
|
+
|
|
3
|
+
Persistent adaptive memory for Claude Code. Automatically captures observations from your coding sessions, classifies them using LLM-based curation, and surfaces relevant context when you need it.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Automatic observation capture via Claude Code hooks (Write, Edit, Bash, etc.)
|
|
8
|
+
- LLM-based classification: discoveries, problems, solutions (noise filtered out)
|
|
9
|
+
- Full-text search with BM25 ranking
|
|
10
|
+
- Knowledge graph with entity and relationship tracking
|
|
11
|
+
- Cross-session memory scoped per project
|
|
12
|
+
- Web UI for browsing observations and graph
|
|
13
|
+
- Duplicate detection and secret redaction
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### Quick Install (Recommended)
|
|
18
|
+
|
|
19
|
+
One command — no git clone needed:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
curl -fsSL https://raw.githubusercontent.com/NoobyNull/Laminark/master/plugin/scripts/install.sh | bash
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This will:
|
|
26
|
+
1. Install `laminark` globally via npm
|
|
27
|
+
2. Register the MCP server with Claude Code
|
|
28
|
+
3. Configure hooks in `~/.claude/settings.json`
|
|
29
|
+
|
|
30
|
+
### Local Installation (Development)
|
|
31
|
+
|
|
32
|
+
For local development or testing:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git clone https://github.com/NoobyNull/Laminark.git
|
|
36
|
+
cd Laminark
|
|
37
|
+
npm install
|
|
38
|
+
npm run build
|
|
39
|
+
./plugin/scripts/local-install.sh
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This uses `npm link` so changes to the repo are reflected immediately after rebuilding.
|
|
43
|
+
|
|
44
|
+
### Manual Installation (Advanced)
|
|
45
|
+
|
|
46
|
+
If you need manual control:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Install the package
|
|
50
|
+
npm install -g laminark
|
|
51
|
+
|
|
52
|
+
# Register MCP server
|
|
53
|
+
claude mcp add-json laminark '{"command":"laminark-server"}' -s user
|
|
54
|
+
|
|
55
|
+
# Configure hooks manually in ~/.claude/settings.json
|
|
56
|
+
# (see install.sh for the hook structure)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Post-Installation
|
|
60
|
+
|
|
61
|
+
Verify installation:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# If installed from repo:
|
|
65
|
+
./plugin/scripts/verify-install.sh
|
|
66
|
+
|
|
67
|
+
# Or check manually:
|
|
68
|
+
npm list -g laminark && claude mcp list | grep laminark
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Laminark will now run in every Claude Code session. Each project's memory is isolated by directory path -- Project A and Project B never share data, but each project remembers across sessions.
|
|
72
|
+
|
|
73
|
+
### Updating
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm update -g laminark
|
|
77
|
+
# Or: ./plugin/scripts/update.sh
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Uninstalling
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
claude mcp remove laminark -s user
|
|
84
|
+
npm uninstall -g laminark
|
|
85
|
+
# Then remove laminark hook entries from ~/.claude/settings.json
|
|
86
|
+
# Optionally: rm -rf ~/.laminark (deletes all memories)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Recommended: GSD (Get Shit Done)
|
|
90
|
+
|
|
91
|
+
Laminark pairs well with [GSD](https://github.com/gsd-framework/gsd) by [@gsd-framework](https://github.com/gsd-framework), a structured workflow plugin for Claude Code. While Laminark handles persistent memory and context, GSD provides project planning, phased execution, and atomic commits. Together they give Claude Code sessions continuity (Laminark) and structure (GSD).
|
|
92
|
+
|
|
93
|
+
> **Note:** GSD is an independent project. Its authors do not endorse or recommend Laminark. This is our recommendation based on how well the two tools complement each other.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
claude plugin add gsd
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The install scripts will offer to install GSD automatically if it isn't already present.
|
|
100
|
+
|
|
101
|
+
## Why User-Level?
|
|
102
|
+
|
|
103
|
+
- Works in every project automatically -- no per-project `.mcp.json` needed
|
|
104
|
+
- Cross-session memory persists for each project
|
|
105
|
+
- Single database at `~/.laminark/data.db`, scoped by project hash
|
|
106
|
+
- Hooks and MCP tools are available everywhere
|
|
107
|
+
|
|
108
|
+
## Data Storage
|
|
109
|
+
|
|
110
|
+
All data is stored in a single SQLite database at `~/.laminark/data.db`. Each project is identified by a SHA-256 hash of its directory path, ensuring complete isolation between projects.
|
|
111
|
+
|
|
112
|
+
## MCP Tools
|
|
113
|
+
|
|
114
|
+
| Tool | Description |
|
|
115
|
+
|------|-------------|
|
|
116
|
+
| `save_memory` | Save an observation with optional title |
|
|
117
|
+
| `recall` | Search, view, purge, or restore memories |
|
|
118
|
+
| `query_graph` | Query the knowledge graph for entities and relationships |
|
|
119
|
+
| `graph_stats` | View knowledge graph statistics |
|
|
120
|
+
| `topic_context` | Show recently stashed context threads |
|
|
121
|
+
| `status` | Show Laminark status and statistics |
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm install
|
|
127
|
+
npm run build
|
|
128
|
+
npm test
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Release History
|
|
132
|
+
|
|
133
|
+
See [CHANGELOG.md](CHANGELOG.md) for detailed release notes.
|
|
134
|
+
|
|
135
|
+
**Versioning:** Laminark uses `MILESTONE.PHASE.SEQUENTIAL` format (e.g., v2.21.0) aligned with GSD workflow phases.
|
|
136
|
+
|
|
137
|
+
**Latest Releases:**
|
|
138
|
+
- **v2.21.0** (2026-02-14) - Phase 21: Graph Visualization (Milestone v2.2 complete)
|
|
139
|
+
- **v2.18.0** (2026-02-14) - Phase 18: Agent SDK Migration (Milestone v2.1 complete)
|
|
140
|
+
- **v2.16.0** (2026-02-10) - Phase 16: Staleness Management (Milestone v2.0 complete)
|
|
141
|
+
- **v1.8.0** (2026-02-09) - Phase 8: Web Visualization (Milestone v1.0 complete)
|
|
142
|
+
|
|
143
|
+
See [.planning/MILESTONES.md](.planning/MILESTONES.md) for comprehensive milestone documentation.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
ISC
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "laminark",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Persistent adaptive memory for Claude Code",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"laminark-server": "./plugin/dist/index.js",
|
|
8
|
+
"laminark-hook": "./plugin/dist/hooks/handler.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "./plugin/dist/index.js",
|
|
11
|
+
"types": "./plugin/dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"plugin"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22.0.0"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsdown",
|
|
20
|
+
"check": "tsc --noEmit",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"install:local": "./plugin/scripts/local-install.sh",
|
|
25
|
+
"install:global": "./plugin/scripts/install.sh",
|
|
26
|
+
"update": "./plugin/scripts/update.sh",
|
|
27
|
+
"uninstall": "./plugin/scripts/uninstall.sh",
|
|
28
|
+
"verify": "./plugin/scripts/verify-install.sh",
|
|
29
|
+
"sync": "./plugin/scripts/dev-sync.sh",
|
|
30
|
+
"dev": "npm run build && npm run sync"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/NoobyNull/Laminark.git"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"claude",
|
|
38
|
+
"memory",
|
|
39
|
+
"mcp",
|
|
40
|
+
"sqlite"
|
|
41
|
+
],
|
|
42
|
+
"license": "ISC",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/NoobyNull/Laminark/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/NoobyNull/Laminark#readme",
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.42",
|
|
49
|
+
"@hono/node-server": "^1.19.9",
|
|
50
|
+
"@huggingface/transformers": "^3.8.1",
|
|
51
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
52
|
+
"better-sqlite3": "^12.6.2",
|
|
53
|
+
"hono": "^4.11.9",
|
|
54
|
+
"sqlite-vec": "^0.1.7-alpha.2",
|
|
55
|
+
"zod": "^4.3.6"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
59
|
+
"@types/node": "^25.2.2",
|
|
60
|
+
"tsdown": "^0.20.3",
|
|
61
|
+
"tsx": "^4.21.0",
|
|
62
|
+
"typescript": "^5.9.3",
|
|
63
|
+
"vitest": "^4.0.18"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "laminark",
|
|
3
|
+
"description": "Persistent adaptive memory for Claude Code. Automatic observation capture, semantic search, topic detection, knowledge graph, and web visualization.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "NoobyNull"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/NoobyNull/Laminark",
|
|
9
|
+
"repository": "https://github.com/NoobyNull/Laminark",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"keywords": ["memory", "mcp", "sqlite", "knowledge-graph", "semantic-search"],
|
|
12
|
+
"skills": "./skills/"
|
|
13
|
+
}
|
package/plugin/.mcp.json
ADDED
package/plugin/CLAUDE.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Memory & Context
|
|
2
|
+
|
|
3
|
+
When you need to recall prior work, decisions, or context:
|
|
4
|
+
- **First** query Laminark's memory tools (`recall`, `query_graph`, `query_branches`) before resorting to grep/glob searches
|
|
5
|
+
- Use `recall` with keyword searches to find past observations, decisions, and findings
|
|
6
|
+
- Use `query_graph` to find relationships between files, decisions, and problems
|
|
7
|
+
- Use `query_branches` to see work history - what was investigated, fixed, built, and where it left off
|
|
8
|
+
- Use `show_branch` to trace the full arc of a specific work unit (investigation -> diagnosis -> planning -> execution -> verification)
|
|
9
|
+
- Use `save_memory` to persist important decisions, findings, and reference material
|
|
10
|
+
- Only fall back to raw file searches (Grep, Glob) when Laminark has no relevant results
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# /laminark:recall
|
|
2
|
+
|
|
3
|
+
Search Laminark memories by description or topic.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
/laminark:recall {description of what you're looking for}
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
When the user invokes this command:
|
|
12
|
+
|
|
13
|
+
1. Take the text provided after the command as the search query
|
|
14
|
+
2. Call the `search` MCP tool with:
|
|
15
|
+
- `query`: The user's search description
|
|
16
|
+
- `limit`: 10 (show top 10 results)
|
|
17
|
+
3. Present the results to the user in a readable format:
|
|
18
|
+
- Show each result with its relevance score, a content snippet, the source, and when it was created
|
|
19
|
+
- Group results by relevance tier if helpful (highly relevant, somewhat relevant)
|
|
20
|
+
- If results include memories from different sessions, note which session they came from
|
|
21
|
+
|
|
22
|
+
## Response Format
|
|
23
|
+
|
|
24
|
+
Present results like this:
|
|
25
|
+
|
|
26
|
+
**Memory Search: "{query}"**
|
|
27
|
+
|
|
28
|
+
Found {N} relevant memories:
|
|
29
|
+
|
|
30
|
+
1. **[{score}% match]** {content snippet, first 200 chars}
|
|
31
|
+
_{source} | {relative time}_
|
|
32
|
+
|
|
33
|
+
2. **[{score}% match]** {content snippet}
|
|
34
|
+
_{source} | {relative time}_
|
|
35
|
+
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
_Use the search tool for more specific queries, or get_observations for full details on any memory._
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
User: /laminark:recall authentication decisions
|
|
43
|
+
Action: Call search with query="authentication decisions"
|
|
44
|
+
Response: Show top results about auth-related memories with scores and snippets
|
|
45
|
+
|
|
46
|
+
User: /laminark:recall what database did we choose
|
|
47
|
+
Action: Call search with query="what database did we choose"
|
|
48
|
+
Response: Show results mentioning database selection decisions
|
|
49
|
+
|
|
50
|
+
## Notes
|
|
51
|
+
|
|
52
|
+
- Results use hybrid search (keyword + semantic) for best matching
|
|
53
|
+
- If no results are found, suggest the user try different search terms or check if they have saved any memories yet
|
|
54
|
+
- If no query is provided after the command, ask the user what they'd like to search for
|
|
55
|
+
- For detailed view of any result, Claude can use the get_observations MCP tool with the observation ID
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# /laminark:remember
|
|
2
|
+
|
|
3
|
+
Save a memory to Laminark for future retrieval.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
/laminark:remember {text to remember}
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
When the user invokes this command:
|
|
12
|
+
|
|
13
|
+
1. Take the text provided after the command as the memory content
|
|
14
|
+
2. Call the `save_memory` MCP tool with:
|
|
15
|
+
- `content`: The user's text exactly as provided
|
|
16
|
+
- `source`: "slash:remember" (identifies this as an explicit user save)
|
|
17
|
+
3. Confirm to the user that the memory has been saved
|
|
18
|
+
4. Show a brief snippet of what was saved (first 100 characters)
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
User: /laminark:remember The auth system uses JWT with 15-minute expiry and refresh tokens stored in httpOnly cookies
|
|
23
|
+
Action: Call save_memory with content="The auth system uses JWT with 15-minute expiry and refresh tokens stored in httpOnly cookies" and source="slash:remember"
|
|
24
|
+
Response: "Saved to memory: 'The auth system uses JWT with 15-minute expiry and refresh tokens stored in httpOnly cookies'"
|
|
25
|
+
|
|
26
|
+
User: /laminark:remember We decided to use Postgres instead of MySQL for the new service because of JSONB support
|
|
27
|
+
Action: Call save_memory with the full text
|
|
28
|
+
Response: "Saved to memory: 'We decided to use Postgres instead of MySQL for the new serv...'"
|
|
29
|
+
|
|
30
|
+
## Notes
|
|
31
|
+
|
|
32
|
+
- Memories saved via /laminark:remember are high-priority in search results (source: "slash:remember")
|
|
33
|
+
- These memories persist across sessions and are included in session context injection
|
|
34
|
+
- If no text is provided after the command, ask the user what they'd like to remember
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# /laminark:resume
|
|
2
|
+
|
|
3
|
+
Resume a previously stashed context thread, or list all available stashed threads.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
/laminark:resume
|
|
8
|
+
/laminark:resume {stash-id}
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
|
|
12
|
+
When the user invokes this command:
|
|
13
|
+
|
|
14
|
+
### List mode (no ID provided)
|
|
15
|
+
|
|
16
|
+
1. Call the `topic_context` MCP tool with no arguments (or limit: 5)
|
|
17
|
+
2. Present the stashed threads as a numbered list showing:
|
|
18
|
+
- Topic label
|
|
19
|
+
- How long ago it was stashed
|
|
20
|
+
- Brief summary (first 80 characters)
|
|
21
|
+
3. Tell the user they can resume a specific thread by providing its ID
|
|
22
|
+
|
|
23
|
+
### Resume mode (ID provided)
|
|
24
|
+
|
|
25
|
+
1. Call the `topic_context` MCP tool to look up the stash
|
|
26
|
+
2. Restore the context from the stash observations into the conversation
|
|
27
|
+
3. Confirm to the user which thread was resumed and how many observations were restored
|
|
28
|
+
4. Summarize the key context from the restored thread so the user can pick up where they left off
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
User: /laminark:resume
|
|
33
|
+
Action: Call topic_context to list stashed threads
|
|
34
|
+
Response: Show numbered list of available threads with topic labels and timestamps
|
|
35
|
+
|
|
36
|
+
User: /laminark:resume abc123def456
|
|
37
|
+
Action: Resume the specific stash, inject its context
|
|
38
|
+
Response: "Resumed: 'JWT authentication' -- Context restored with 5 observations. Here's where you left off: ..."
|
|
39
|
+
|
|
40
|
+
## Notes
|
|
41
|
+
|
|
42
|
+
- Only threads with status "stashed" are shown (already resumed threads are excluded)
|
|
43
|
+
- Resuming a thread marks it as "resumed" so it no longer appears in the list
|
|
44
|
+
- The restored context includes observation snapshots from the time of stashing
|
|
45
|
+
- If no stashed threads exist, inform the user they are working in a single thread
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# /laminark:stash
|
|
2
|
+
|
|
3
|
+
Manually stash the current session's context for later retrieval.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
/laminark:stash [optional label]
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
When the user invokes this command:
|
|
12
|
+
|
|
13
|
+
1. Call the `save_memory` MCP tool to persist current observations, then call the stash handler to snapshot the current session
|
|
14
|
+
2. If a label is provided after the command, use it as the stash topic label
|
|
15
|
+
3. If no label is provided, one is generated automatically from the earliest observation
|
|
16
|
+
4. Confirm to the user that their context was stashed
|
|
17
|
+
5. Show the topic label and remind them about /laminark:resume
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
User: /laminark:stash authentication implementation
|
|
22
|
+
Action: Stash current session context with label "authentication implementation"
|
|
23
|
+
Response: "Context stashed: 'authentication implementation'. Use /laminark:resume to return to it."
|
|
24
|
+
|
|
25
|
+
User: /laminark:stash
|
|
26
|
+
Action: Stash current session context with auto-generated label
|
|
27
|
+
Response: "Context stashed: 'Initial project setup and configur...'. Use /laminark:resume to return to it."
|
|
28
|
+
|
|
29
|
+
## Notes
|
|
30
|
+
|
|
31
|
+
- Stashing preserves a snapshot of the current session's observations
|
|
32
|
+
- The stash remains available across sessions until resumed or deleted
|
|
33
|
+
- Use /laminark:resume to list available stashes or restore a specific one
|
|
34
|
+
- Automatic stashing also occurs when topic shifts are detected during normal work
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# /laminark:status
|
|
2
|
+
|
|
3
|
+
Show Laminark system status: connection info, memory count, token estimates, and capabilities.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
/laminark:status
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
When the user invokes this command:
|
|
12
|
+
|
|
13
|
+
1. Call the `status` MCP tool with no arguments
|
|
14
|
+
2. Present the returned dashboard directly to the user
|
|
15
|
+
|
|
16
|
+
The tool returns a formatted status report including:
|
|
17
|
+
- **Connection**: project path, project hash, database path, uptime
|
|
18
|
+
- **Capabilities**: vector search availability, embedding worker status
|
|
19
|
+
- **Memories**: observation count, embedded count, session count, stashed threads
|
|
20
|
+
- **Tokens**: estimated total tokens across all stored memories
|
|
21
|
+
- **Knowledge Graph**: node and edge counts
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
User: /laminark:status
|
|
26
|
+
Action: Call the status MCP tool
|
|
27
|
+
Response: Display the formatted status dashboard
|
|
28
|
+
|
|
29
|
+
## Notes
|
|
30
|
+
|
|
31
|
+
- This is a read-only diagnostic command with no side effects
|
|
32
|
+
- Token estimates use the ~4 chars/token heuristic
|
|
33
|
+
- Uptime reflects time since the MCP server process started
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { t as getConfigDir } from "../config-t8LZeB-u.mjs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parentPort } from "node:worker_threads";
|
|
4
|
+
|
|
5
|
+
//#region src/analysis/engines/local-onnx.ts
|
|
6
|
+
/**
|
|
7
|
+
* Local ONNX embedding engine using @huggingface/transformers.
|
|
8
|
+
*
|
|
9
|
+
* Loads BGE Small EN v1.5 (quantized q8) via dynamic import() for
|
|
10
|
+
* zero startup cost (DQ-04). Model files are cached in ~/.laminark/models/.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Embedding engine backed by BGE Small EN v1.5 running locally via ONNX Runtime.
|
|
14
|
+
*
|
|
15
|
+
* All public methods catch errors internally and return null/false.
|
|
16
|
+
*/
|
|
17
|
+
var LocalOnnxEngine = class {
|
|
18
|
+
pipe = null;
|
|
19
|
+
ready = false;
|
|
20
|
+
/**
|
|
21
|
+
* Lazily loads the model via dynamic import().
|
|
22
|
+
*
|
|
23
|
+
* - Uses `@huggingface/transformers` loaded at runtime (not bundled)
|
|
24
|
+
* - Caches model files in ~/.laminark/models/
|
|
25
|
+
* - Returns false on any error (missing runtime, download failure, etc.)
|
|
26
|
+
*/
|
|
27
|
+
async initialize() {
|
|
28
|
+
try {
|
|
29
|
+
const { pipeline, env } = await import("@huggingface/transformers");
|
|
30
|
+
env.cacheDir = join(getConfigDir(), "models");
|
|
31
|
+
this.pipe = await pipeline("feature-extraction", "Xenova/bge-small-en-v1.5", { dtype: "q8" });
|
|
32
|
+
this.ready = true;
|
|
33
|
+
return true;
|
|
34
|
+
} catch {
|
|
35
|
+
this.ready = false;
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Embeds a single text string into a 384-dimensional vector.
|
|
41
|
+
*
|
|
42
|
+
* Returns null if:
|
|
43
|
+
* - Engine not initialized
|
|
44
|
+
* - Input is empty/whitespace
|
|
45
|
+
* - Pipeline throws
|
|
46
|
+
*/
|
|
47
|
+
async embed(text) {
|
|
48
|
+
if (!this.ready || !this.pipe) return null;
|
|
49
|
+
if (!text || text.trim().length === 0) return null;
|
|
50
|
+
try {
|
|
51
|
+
const output = await this.pipe(text, {
|
|
52
|
+
pooling: "cls",
|
|
53
|
+
normalize: true
|
|
54
|
+
});
|
|
55
|
+
return Float32Array.from(output.data);
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Embeds multiple texts, preserving order.
|
|
62
|
+
*
|
|
63
|
+
* Returns null for any text that was empty or failed.
|
|
64
|
+
*/
|
|
65
|
+
async embedBatch(texts) {
|
|
66
|
+
const results = [];
|
|
67
|
+
for (const text of texts) if (!text || text.trim().length === 0) results.push(null);
|
|
68
|
+
else results.push(await this.embed(text));
|
|
69
|
+
return results;
|
|
70
|
+
}
|
|
71
|
+
/** BGE Small EN v1.5 produces 384-dimensional embeddings. */
|
|
72
|
+
dimensions() {
|
|
73
|
+
return 384;
|
|
74
|
+
}
|
|
75
|
+
/** Engine identifier. */
|
|
76
|
+
name() {
|
|
77
|
+
return "bge-small-en-v1.5-q8";
|
|
78
|
+
}
|
|
79
|
+
/** Whether the model loaded successfully. */
|
|
80
|
+
isReady() {
|
|
81
|
+
return this.ready;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/analysis/engines/keyword-only.ts
|
|
87
|
+
/**
|
|
88
|
+
* Embedding engine that produces no embeddings.
|
|
89
|
+
*
|
|
90
|
+
* Acts as a silent fallback so that the rest of the system can
|
|
91
|
+
* operate in keyword-only mode without special-casing missing engines.
|
|
92
|
+
*/
|
|
93
|
+
var KeywordOnlyEngine = class {
|
|
94
|
+
/** Always returns null -- no model available. */
|
|
95
|
+
async embed() {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
/** Returns array of nulls matching input length. */
|
|
99
|
+
async embedBatch(texts) {
|
|
100
|
+
return texts.map(() => null);
|
|
101
|
+
}
|
|
102
|
+
/** No dimensions -- no model. */
|
|
103
|
+
dimensions() {
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
/** Engine identifier. */
|
|
107
|
+
name() {
|
|
108
|
+
return "keyword-only";
|
|
109
|
+
}
|
|
110
|
+
/** Intentionally returns false -- this engine has no model. */
|
|
111
|
+
async initialize() {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
/** Always false -- no model loaded. */
|
|
115
|
+
isReady() {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/analysis/embedder.ts
|
|
122
|
+
/**
|
|
123
|
+
* EmbeddingEngine interface and factory.
|
|
124
|
+
*
|
|
125
|
+
* Defines the pluggable abstraction for text embedding.
|
|
126
|
+
* All consumers depend on this interface -- never on concrete engines.
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* Creates and initializes an embedding engine.
|
|
130
|
+
*
|
|
131
|
+
* Attempts LocalOnnxEngine first. If initialization fails (missing model,
|
|
132
|
+
* ONNX runtime unavailable, etc.), falls back to KeywordOnlyEngine.
|
|
133
|
+
*
|
|
134
|
+
* Never throws -- always returns a valid engine.
|
|
135
|
+
*/
|
|
136
|
+
async function createEmbeddingEngine() {
|
|
137
|
+
const onnxEngine = new LocalOnnxEngine();
|
|
138
|
+
if (await onnxEngine.initialize()) return onnxEngine;
|
|
139
|
+
return new KeywordOnlyEngine();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/analysis/worker.ts
|
|
144
|
+
/**
|
|
145
|
+
* Worker thread entry point for off-main-thread embedding.
|
|
146
|
+
*
|
|
147
|
+
* Receives embed/embed_batch/shutdown messages from the main thread via
|
|
148
|
+
* parentPort, runs the embedding engine, and responds with Float32Array
|
|
149
|
+
* results using zero-copy transfer.
|
|
150
|
+
*
|
|
151
|
+
* Compiled as a separate tsdown entry point to dist/analysis/worker.js.
|
|
152
|
+
*/
|
|
153
|
+
if (!parentPort) throw new Error("worker.ts must be run as a Worker thread");
|
|
154
|
+
const port = parentPort;
|
|
155
|
+
async function init() {
|
|
156
|
+
let engineName = "keyword-only";
|
|
157
|
+
let dimensions = 0;
|
|
158
|
+
try {
|
|
159
|
+
const engine = await createEmbeddingEngine();
|
|
160
|
+
engineName = engine.name();
|
|
161
|
+
dimensions = engine.dimensions();
|
|
162
|
+
port.postMessage({
|
|
163
|
+
type: "ready",
|
|
164
|
+
engineName,
|
|
165
|
+
dimensions
|
|
166
|
+
});
|
|
167
|
+
port.on("message", async (msg) => {
|
|
168
|
+
if (msg.type === "embed") try {
|
|
169
|
+
const embedding = await engine.embed(msg.text);
|
|
170
|
+
if (embedding === null) port.postMessage({
|
|
171
|
+
type: "embed_result",
|
|
172
|
+
id: msg.id,
|
|
173
|
+
embedding: null
|
|
174
|
+
});
|
|
175
|
+
else {
|
|
176
|
+
const buf = embedding.buffer;
|
|
177
|
+
port.postMessage({
|
|
178
|
+
type: "embed_result",
|
|
179
|
+
id: msg.id,
|
|
180
|
+
embedding
|
|
181
|
+
}, [buf]);
|
|
182
|
+
}
|
|
183
|
+
} catch {
|
|
184
|
+
port.postMessage({
|
|
185
|
+
type: "embed_result",
|
|
186
|
+
id: msg.id,
|
|
187
|
+
embedding: null
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
else if (msg.type === "embed_batch") try {
|
|
191
|
+
const embeddings = await engine.embedBatch(msg.texts);
|
|
192
|
+
const transferList = [];
|
|
193
|
+
for (const emb of embeddings) if (emb !== null) transferList.push(emb.buffer);
|
|
194
|
+
port.postMessage({
|
|
195
|
+
type: "embed_batch_result",
|
|
196
|
+
id: msg.id,
|
|
197
|
+
embeddings
|
|
198
|
+
}, transferList);
|
|
199
|
+
} catch {
|
|
200
|
+
port.postMessage({
|
|
201
|
+
type: "embed_batch_result",
|
|
202
|
+
id: msg.id,
|
|
203
|
+
embeddings: msg.texts.map(() => null)
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
else if (msg.type === "shutdown") process.exit(0);
|
|
207
|
+
});
|
|
208
|
+
} catch {
|
|
209
|
+
port.postMessage({
|
|
210
|
+
type: "ready",
|
|
211
|
+
engineName,
|
|
212
|
+
dimensions
|
|
213
|
+
});
|
|
214
|
+
port.on("message", (msg) => {
|
|
215
|
+
if (msg.type === "embed") port.postMessage({
|
|
216
|
+
type: "embed_result",
|
|
217
|
+
id: msg.id,
|
|
218
|
+
embedding: null
|
|
219
|
+
});
|
|
220
|
+
else if (msg.type === "embed_batch") port.postMessage({
|
|
221
|
+
type: "embed_batch_result",
|
|
222
|
+
id: msg.id,
|
|
223
|
+
embeddings: msg.texts.map(() => null)
|
|
224
|
+
});
|
|
225
|
+
else if (msg.type === "shutdown") process.exit(0);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
init();
|
|
230
|
+
|
|
231
|
+
//#endregion
|
|
232
|
+
export { };
|
|
233
|
+
//# sourceMappingURL=worker.js.map
|