hive-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.
- package/LICENSE +21 -0
- package/README.md +207 -0
- package/dist/embed.d.ts +16 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +84 -0
- package/dist/embed.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/store.d.ts +57 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +993 -0
- package/dist/store.js.map +1 -0
- package/dist/tools.d.ts +15 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +457 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +73 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 moonx010
|
|
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,207 @@
|
|
|
1
|
+
# Hive Memory
|
|
2
|
+
|
|
3
|
+
> Cross-project memory layer for AI coding agents.
|
|
4
|
+
|
|
5
|
+
Hive Memory is an [MCP](https://modelcontextprotocol.io) server that gives AI coding agents persistent memory across projects. It stores decisions, learnings, session progress, and project context in a local knowledge base — so your agent can pick up where it left off, even across different workspaces.
|
|
6
|
+
|
|
7
|
+
## Why Hive Memory?
|
|
8
|
+
|
|
9
|
+
AI coding agents have memory, but it's scoped to a single project:
|
|
10
|
+
|
|
11
|
+
| | Scope | Cross-project | Groups & shared guides | Session continuity |
|
|
12
|
+
|---|---|---|---|---|
|
|
13
|
+
| **Claude Code** (MEMORY.md) | Single project | No | No | Manual |
|
|
14
|
+
| **Codex** (built-in memory) | Single project | No | No | No |
|
|
15
|
+
| **Hive Memory** | All projects | Yes | Yes | Automatic |
|
|
16
|
+
|
|
17
|
+
Hive Memory sits **above** these tools as a meta-layer. It doesn't replace them — it connects them.
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g hive-memory
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Claude Code
|
|
28
|
+
|
|
29
|
+
Add to `~/.claude/settings.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"hive-memory": {
|
|
35
|
+
"command": "hive-memory"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Claude Desktop
|
|
42
|
+
|
|
43
|
+
Add to your Claude Desktop config (`claude_desktop_config.json`):
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"mcpServers": {
|
|
48
|
+
"hive-memory": {
|
|
49
|
+
"command": "hive-memory"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Cursor
|
|
56
|
+
|
|
57
|
+
Add to `.cursor/mcp.json` in your project:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"mcpServers": {
|
|
62
|
+
"hive-memory": {
|
|
63
|
+
"command": "hive-memory"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Agent Instructions
|
|
70
|
+
|
|
71
|
+
Hive Memory works best when your AI agent knows *when* to call the tools. Copy the provided instruction templates into your agent's instruction file:
|
|
72
|
+
|
|
73
|
+
| Agent | Instruction file | Template |
|
|
74
|
+
|-------|-----------------|----------|
|
|
75
|
+
| Claude Code | `~/.claude/CLAUDE.md` | [`claude-md-template.md`](docs/claude-md-template.md) |
|
|
76
|
+
| Codex | `~/AGENTS.md` or `./AGENTS.md` | [`codex-md-template.md`](docs/codex-md-template.md) |
|
|
77
|
+
|
|
78
|
+
See the [full setup guide](docs/setup.md) for step-by-step instructions.
|
|
79
|
+
|
|
80
|
+
## How It Works
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
84
|
+
│ Claude │ │ Cursor │ │ Codex │
|
|
85
|
+
│ Code │ │ │ │ │
|
|
86
|
+
│ (Proj A) │ │ (Proj B) │ │ (Proj C) │
|
|
87
|
+
└────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
88
|
+
│ │ │
|
|
89
|
+
└────────────────┼────────────────┘
|
|
90
|
+
│ MCP (stdio)
|
|
91
|
+
┌─────────────┐
|
|
92
|
+
│ Hive Memory │
|
|
93
|
+
│ MCP Server │
|
|
94
|
+
└──────┬──────┘
|
|
95
|
+
│
|
|
96
|
+
┌──────▼──────┐
|
|
97
|
+
│ ~/.cortex/ │
|
|
98
|
+
│ (local JSON │
|
|
99
|
+
│ + Markdown)│
|
|
100
|
+
└─────────────┘
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**No cloud. No accounts. Everything stays on your machine.**
|
|
104
|
+
|
|
105
|
+
Hive Memory stores all data under `~/.cortex/` as plain JSON and Markdown files. Each project gets its own subdirectory with summaries, memories, and session logs.
|
|
106
|
+
|
|
107
|
+
## Tools Reference
|
|
108
|
+
|
|
109
|
+
### Project Management
|
|
110
|
+
|
|
111
|
+
| Tool | Description |
|
|
112
|
+
|------|-------------|
|
|
113
|
+
| `project_register` | Register a new project with Hive Memory |
|
|
114
|
+
| `project_list` | List all registered projects with status |
|
|
115
|
+
| `project_update` | Update project metadata or status |
|
|
116
|
+
| `project_search` | Search projects by name, description, or tags |
|
|
117
|
+
| `project_status` | Get current context: summary, focus, last session |
|
|
118
|
+
| `project_onboard` | Auto-discover projects in a directory |
|
|
119
|
+
|
|
120
|
+
### Memory
|
|
121
|
+
|
|
122
|
+
| Tool | Description |
|
|
123
|
+
|------|-------------|
|
|
124
|
+
| `memory_store` | Store a decision, learning, or note |
|
|
125
|
+
| `memory_recall` | Search and recall relevant memories |
|
|
126
|
+
|
|
127
|
+
### Sessions
|
|
128
|
+
|
|
129
|
+
| Tool | Description |
|
|
130
|
+
|------|-------------|
|
|
131
|
+
| `session_save` | Save session progress — what was done, what's next |
|
|
132
|
+
|
|
133
|
+
### Groups
|
|
134
|
+
|
|
135
|
+
| Tool | Description |
|
|
136
|
+
|------|-------------|
|
|
137
|
+
| `group_create` | Create a group to organize related projects |
|
|
138
|
+
| `group_list` | List all groups |
|
|
139
|
+
| `group_update` | Update group metadata, add/remove projects |
|
|
140
|
+
| `group_context` | Get shared guides and member project info |
|
|
141
|
+
| `group_guide_save` | Save a shared guide document for a group |
|
|
142
|
+
|
|
143
|
+
## Configuration
|
|
144
|
+
|
|
145
|
+
### Data Directory
|
|
146
|
+
|
|
147
|
+
By default, Hive Memory stores data in `~/.cortex/`. Override with:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
CORTEX_DATA_DIR=/custom/path hive-memory
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Or in your MCP config:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"mcpServers": {
|
|
158
|
+
"hive-memory": {
|
|
159
|
+
"command": "hive-memory",
|
|
160
|
+
"env": {
|
|
161
|
+
"CORTEX_DATA_DIR": "/custom/path"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Local Context File (.cortex.md)
|
|
169
|
+
|
|
170
|
+
Hive Memory writes a `.cortex.md` file in each registered project directory. This file contains a snapshot of the project's current context — summary, recent session, and next tasks. It's auto-generated and can be added to `.gitignore`.
|
|
171
|
+
|
|
172
|
+
## Semantic Search
|
|
173
|
+
|
|
174
|
+
Hive Memory includes an optional native module (Rust + NAPI) for embedding-based semantic search. Without it, Hive Memory uses keyword matching which works well for most use cases.
|
|
175
|
+
|
|
176
|
+
To enable semantic search:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
cd native && npm install && npm run build
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This requires a Rust toolchain. The native module is **not included in the npm package** — build it locally if needed.
|
|
183
|
+
|
|
184
|
+
## Development
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# Install dependencies
|
|
188
|
+
npm install
|
|
189
|
+
|
|
190
|
+
# Build TypeScript
|
|
191
|
+
npm run build
|
|
192
|
+
|
|
193
|
+
# Dev mode with auto-reload
|
|
194
|
+
npm run dev
|
|
195
|
+
|
|
196
|
+
# Type check
|
|
197
|
+
npm run typecheck
|
|
198
|
+
|
|
199
|
+
# Run tests
|
|
200
|
+
npm test
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed contribution guidelines.
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
[MIT](LICENSE)
|
package/dist/embed.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface EmbedSearchResult {
|
|
2
|
+
id: string;
|
|
3
|
+
distance: number;
|
|
4
|
+
metadata: string | null;
|
|
5
|
+
}
|
|
6
|
+
export declare class EmbedService {
|
|
7
|
+
private index;
|
|
8
|
+
available: boolean;
|
|
9
|
+
init(dataDir: string): Promise<void>;
|
|
10
|
+
addText(id: string, text: string, metadata?: string): void;
|
|
11
|
+
search(query: string, limit: number): EmbedSearchResult[];
|
|
12
|
+
remove(id: string): void;
|
|
13
|
+
count(): number;
|
|
14
|
+
close(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=embed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAiC;IACvC,SAAS,UAAS;IAEnB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB1C,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAS1D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB,EAAE;IASzD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IASxB,KAAK,IAAI,MAAM;IASf,KAAK,IAAI,IAAI;CASd"}
|
package/dist/embed.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { join, dirname } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { platform, arch } from "node:os";
|
|
6
|
+
export class EmbedService {
|
|
7
|
+
index = null;
|
|
8
|
+
available = false;
|
|
9
|
+
async init(dataDir) {
|
|
10
|
+
try {
|
|
11
|
+
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const projectRoot = dirname(thisDir); // up from src/ or dist/
|
|
13
|
+
const nodeName = `cortex-embed.${platform()}-${arch()}.node`;
|
|
14
|
+
const nativePath = join(projectRoot, "native", nodeName);
|
|
15
|
+
if (!existsSync(nativePath)) {
|
|
16
|
+
this.available = false;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Use createRequire for .node native addons (ESM import doesn't work for them)
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
21
|
+
const mod = require(nativePath);
|
|
22
|
+
const dbPath = join(dataDir, "embeddings.db");
|
|
23
|
+
const cacheDir = join(dataDir, "models");
|
|
24
|
+
this.index = new mod.EmbedIndex(dbPath, cacheDir, 384);
|
|
25
|
+
this.available = true;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Native module not available — fall back to keyword search
|
|
29
|
+
this.available = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
addText(id, text, metadata) {
|
|
33
|
+
if (!this.index)
|
|
34
|
+
return;
|
|
35
|
+
try {
|
|
36
|
+
this.index.addText(id, text, metadata);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Silently fail — never break the main flow
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
search(query, limit) {
|
|
43
|
+
if (!this.index)
|
|
44
|
+
return [];
|
|
45
|
+
try {
|
|
46
|
+
return this.index.searchText(query, limit);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
remove(id) {
|
|
53
|
+
if (!this.index)
|
|
54
|
+
return;
|
|
55
|
+
try {
|
|
56
|
+
this.index.remove(id);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Silently fail
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
count() {
|
|
63
|
+
if (!this.index)
|
|
64
|
+
return 0;
|
|
65
|
+
try {
|
|
66
|
+
return this.index.count();
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
close() {
|
|
73
|
+
if (!this.index)
|
|
74
|
+
return;
|
|
75
|
+
try {
|
|
76
|
+
this.index.close();
|
|
77
|
+
this.index = null;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Silently fail
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=embed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.js","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AA8BzC,MAAM,OAAO,YAAY;IACf,KAAK,GAA4B,IAAI,CAAC;IACvC,SAAS,GAAG,KAAK,CAAC;IAEzB,KAAK,CAAC,IAA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AAC,MAAM,CAAC;YACP,4CAA4C;QAC9C,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,KAAa;QACjC,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,MAAM,CAAC,EAAU;QACf,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,gBAAgB;QAClB,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,gBAAgB;QAClB,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import { CortexStore } from "./store.js";
|
|
7
|
+
import { registerTools } from "./tools.js";
|
|
8
|
+
const DATA_DIR = process.env["CORTEX_DATA_DIR"] ?? join(homedir(), ".cortex");
|
|
9
|
+
async function main() {
|
|
10
|
+
const store = new CortexStore({
|
|
11
|
+
dataDir: DATA_DIR,
|
|
12
|
+
localContext: { filename: ".cortex.md" },
|
|
13
|
+
});
|
|
14
|
+
await store.init();
|
|
15
|
+
const server = new McpServer({
|
|
16
|
+
name: "cortex",
|
|
17
|
+
version: "1.0.0", // Keep in sync with package.json
|
|
18
|
+
});
|
|
19
|
+
registerTools(server, store);
|
|
20
|
+
const transport = new StdioServerTransport();
|
|
21
|
+
await server.connect(transport);
|
|
22
|
+
}
|
|
23
|
+
main().catch((err) => {
|
|
24
|
+
console.error("Cortex failed to start:", err);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,QAAQ,GACZ,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAE/D,KAAK,UAAU,IAAI;IACjB,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC;QAC5B,OAAO,EAAE,QAAQ;QACjB,YAAY,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE;KACzC,CAAC,CAAC;IACH,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;IAEnB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,OAAO,EAAE,iCAAiC;KACpD,CAAC,CAAC;IAEH,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE7B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ProjectIndex, ProjectEntry, ProjectSummary, SessionSummary, MemoryEntry, MemoryCategory, CortexConfig, GroupEntry, GroupIndex, OnboardCandidate } from "./types.js";
|
|
2
|
+
export declare class CortexStore {
|
|
3
|
+
private dataDir;
|
|
4
|
+
private localContextFilename;
|
|
5
|
+
private embed;
|
|
6
|
+
constructor(config: CortexConfig);
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
private get indexPath();
|
|
9
|
+
getIndex(): Promise<ProjectIndex>;
|
|
10
|
+
saveIndex(index: ProjectIndex): Promise<void>;
|
|
11
|
+
searchProjects(query: string, limit?: number): Promise<ProjectEntry[]>;
|
|
12
|
+
listProjects(statusFilter?: "active" | "paused" | "archived"): Promise<ProjectEntry[]>;
|
|
13
|
+
upsertProject(entry: ProjectEntry): Promise<void>;
|
|
14
|
+
updateProjectStatus(projectId: string, status: "active" | "paused" | "archived"): Promise<boolean>;
|
|
15
|
+
updateProjectMeta(projectId: string, updates: Partial<Pick<ProjectEntry, "name" | "description" | "tags" | "path">>): Promise<boolean>;
|
|
16
|
+
private projectDir;
|
|
17
|
+
getProjectSummary(projectId: string): Promise<ProjectSummary | null>;
|
|
18
|
+
saveProjectSummary(summary: ProjectSummary): Promise<void>;
|
|
19
|
+
getProjectStatus(projectId: string): Promise<string | null>;
|
|
20
|
+
saveProjectStatus(projectId: string, content: string): Promise<void>;
|
|
21
|
+
saveSession(projectId: string, session: SessionSummary): Promise<void>;
|
|
22
|
+
storeMemory(projectId: string, category: MemoryCategory, content: string, tags: string[]): Promise<MemoryEntry>;
|
|
23
|
+
recallMemories(query: string, projectId?: string, limit?: number): Promise<{
|
|
24
|
+
project: string;
|
|
25
|
+
category: string;
|
|
26
|
+
snippet: string;
|
|
27
|
+
score?: number;
|
|
28
|
+
}[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Write a .cortex.md into the project's actual directory.
|
|
31
|
+
* This gives Claude Code immediate detailed context when opening that project.
|
|
32
|
+
*/
|
|
33
|
+
syncLocalContext(projectId: string): Promise<string | null>;
|
|
34
|
+
private get groupIndexPath();
|
|
35
|
+
private groupDir;
|
|
36
|
+
getGroupIndex(): Promise<GroupIndex>;
|
|
37
|
+
saveGroupIndex(index: GroupIndex): Promise<void>;
|
|
38
|
+
createGroup(entry: Omit<GroupEntry, "createdAt" | "lastActive">): Promise<GroupEntry>;
|
|
39
|
+
getGroupContext(groupId: string, detail?: "brief" | "full"): Promise<string | null>;
|
|
40
|
+
addProjectToGroup(groupId: string, projectId: string): Promise<boolean>;
|
|
41
|
+
removeProjectFromGroup(groupId: string, projectId: string): Promise<boolean>;
|
|
42
|
+
searchGroups(query: string): Promise<GroupEntry[]>;
|
|
43
|
+
saveGroupGuide(groupId: string, filename: string, content: string): Promise<string>;
|
|
44
|
+
storeGroupMemory(groupId: string, category: MemoryCategory, content: string, tags: string[]): Promise<MemoryEntry>;
|
|
45
|
+
recallGroupMemories(groupId: string, query: string, limit?: number): Promise<{
|
|
46
|
+
project: string;
|
|
47
|
+
category: string;
|
|
48
|
+
snippet: string;
|
|
49
|
+
score?: number;
|
|
50
|
+
}[]>;
|
|
51
|
+
scanForProjects(rootPath: string, depth?: number): Promise<OnboardCandidate[]>;
|
|
52
|
+
private detectProject;
|
|
53
|
+
private reindexAll;
|
|
54
|
+
private readJson;
|
|
55
|
+
private writeJson;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,KAAK,CAAsB;gBAEvB,MAAM,EAAE,YAAY;IAK1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B,OAAO,KAAK,SAAS,GAEpB;IAEK,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAsEjE,YAAY,CAChB,YAAY,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAC9C,OAAO,CAAC,YAAY,EAAE,CAAC;IAYpB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBjD,mBAAmB,CACvB,SA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