opencode-fractal-memory 0.6.10 → 0.6.12

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 CHANGED
@@ -409,7 +409,7 @@ Opens at [http://localhost:8787](http://localhost:8787). The server starts as a
409
409
 
410
410
  When OpenCode loads the plugin, `initStorage()` runs automatically:
411
411
 
412
- 1. **SQLite database** — created at `<project>/.opencode/memory.db` with all tables and indexes
412
+ 1. **SQLite database** — created at `~/.config/opencode/memory.db` with all tables and indexes. Project-scope nodes are stored alongside global nodes with a `project_name` discriminator column
413
413
  2. **Seed nodes** — rule nodes, built-in playbooks (6), and skills (9) inserted into `memory_nodes`
414
414
  3. **Model files** — `ensureModels()` checks `~/.config/opencode/models/` and downloads ONNX + tokenizer (~24 MB) if missing
415
415
  4. **Agent files** — `ensureAgentFiles()` copies `agent/` directory to `~/.config/opencode/agent/`
@@ -464,43 +464,44 @@ Use `--ignore-scripts` to avoid trust prompts. Models download automatically on
464
464
  ## Architecture
465
465
 
466
466
  ```
467
- ┌──────────────────────────────────────────────────┐
468
- │ Plugin Layer (plugin/index.ts)
469
- ┌──────────┬──────────┬──────────┬───────────┐
470
- │ │ Memory │ Skills │ Journal │ Auto- │ │
471
- │ │ Store │ (nodes) │ Store │ Retrieve │ │
472
- └────┬─────┴────┬─────┴────┬─────┴─────┬─────┘
473
- │ │ │ │ │
474
- ┌────┴──────────┴──────────┴───────────┴─────┐
475
- │ │ SQLite (.opencode/memory.db) │ │
476
- │ │ - memory_nodes (labels, content, embeds) │ │
477
- │ │ - type: "note" / "skill" / "playbook" │ │
478
- │ │ - sticky playbooks/skills never pruned │ │
479
- │ │ - metadata.steps for playbook steps │ │
480
- │ │ - memory_links (wiki-link crossrefs) │ │
481
- │ │ - bm25_index (full-text search) │ │
482
- │ │ - injection_metrics / session_metrics │ │
483
- └─────────────────────────────────────────────┘
484
-
485
- ┌─────────────────────────────────────────────┐
486
- HNSW Vector Index (in-memory, 384-dim) │ │
487
- └─────────────────────────────────────────────┘
488
-
489
- ┌─────────────────────────────────────────────┐
490
- ONNX Embedding Model (all-MiniLM-L6-v2) │ │
491
- │ onnxruntime-web + @huggingface/tokenizers │
492
- └─────────────────────────────────────────────┘
493
- └──────────────────────────────────────────────────┘
467
+ ┌──────────────────────────────────────────────────────┐
468
+ │ Plugin Layer (plugin/index.ts)
469
+ ┌──────────┬──────────┬──────────┬───────────────┐
470
+ │ │ Memory │ Skills │ Journal │ Auto- │ │
471
+ │ │ Store │ (nodes) │ Store │ Retrieve │ │
472
+ └────┬─────┴────┬─────┴────┬─────┴───────┬───────┘
473
+ │ │ │ │
474
+ ┌────┴──────────┴──────────┴─────────────┴───────┐
475
+ │ │ SQLite (~/.config/opencode/memory.db) │ │
476
+ │ │ - memory_nodes (labels, content, embeds) │ │
477
+ │ │ - scope: "global" | "project" │ │
478
+ │ │ - project_name (for project-scope nodes) │ │
479
+ │ │ - type: "note" / "skill" / "playbook" │ │
480
+ │ │ - sticky playbooks/skills never pruned │ │
481
+ │ │ - metadata.steps for playbook steps │ │
482
+ │ │ - memory_links (wiki-link crossrefs) │ │
483
+ - bm25_index (full-text search)
484
+ - injection_metrics / session_metrics │ │
485
+ └─────────────────────────────────────────────────┘
486
+
487
+ ┌─────────────────────────────────────────────────┐
488
+ HNSW Vector Index (in-memory, 384-dim) │ │
489
+ └─────────────────────────────────────────────────┘
490
+
491
+ ┌─────────────────────────────────────────────────┐
492
+ │ ONNX Embedding Model (all-MiniLM-L6-v2) │
493
+ │ │ onnxruntime-web + @huggingface/tokenizers │ │
494
+ │ └─────────────────────────────────────────────────┘ │
495
+ └──────────────────────────────────────────────────────┘
494
496
  ```
495
497
 
496
498
  ## Storage
497
499
 
498
- Two SQLite databases:
500
+ Unified SQLite database with `project_name` discriminator:
499
501
 
500
- | Scope | Path | Purpose |
501
- |---|---|---|
502
- | Global | `~/.config/opencode/memory.db` | Rules, persona, preferences, shared across projects |
503
- | Project | `<project>/.opencode/memory.db` | Project-specific memory, nodes, playbooks, journal |
502
+ | Path | Purpose |
503
+ |---|---|
504
+ | `~/.config/opencode/memory.db` | Global rules, persona, preferences (scope=global) + project-specific memory, nodes, playbooks (scope=project, discriminated by `project_name`) |
504
505
 
505
506
  ## License
506
507
 
@@ -1,12 +1,22 @@
1
1
  import * as path from "node:path";
2
2
  import { memLog } from "./logging";
3
3
  let activeProcess = null;
4
+ let mgmtConfig = null;
5
+ export function isManagementServerRunning() {
6
+ return activeProcess !== null;
7
+ }
8
+ export function ensureManagementServer() {
9
+ if (mgmtConfig && mgmtConfig.enabled) {
10
+ startManagementServer(null, mgmtConfig.directory, { enabled: true, port: mgmtConfig.port });
11
+ }
12
+ }
4
13
  export function startManagementServer(_store, directory, config) {
5
14
  if (activeProcess) {
6
15
  memLog("warn", "management", "Management server already running, killing old instance");
7
16
  stopManagementServer();
8
17
  }
9
18
  const standalonePath = path.join(__dirname, "management-standalone.js");
19
+ mgmtConfig = { enabled: config.enabled, port: config.port, directory };
10
20
  try {
11
21
  const proc = Bun.spawn(["bun", standalonePath], {
12
22
  env: {
@@ -15,6 +25,7 @@ export function startManagementServer(_store, directory, config) {
15
25
  MGMT_PROJECT_DIR: directory,
16
26
  },
17
27
  stdio: ["ignore", "pipe", "pipe"],
28
+ deathSignal: "SIGKILL",
18
29
  });
19
30
  activeProcess = proc;
20
31
  proc.exited.then((code) => {
@@ -34,7 +45,7 @@ export function startManagementServer(_store, directory, config) {
34
45
  export function stopManagementServer() {
35
46
  if (activeProcess) {
36
47
  try {
37
- activeProcess.kill("SIGTERM");
48
+ activeProcess.kill("SIGKILL");
38
49
  memLog("info", "management", `Management server process ${activeProcess.pid} killed`);
39
50
  }
40
51
  catch (err) {
@@ -2,7 +2,7 @@ import { initStorage, loadPluginConfig, seedRuleNodes, backfillData, scheduleBac
2
2
  import { createHookHandlers } from "./hooks";
3
3
  import { createToolMap } from "./tools";
4
4
  import { memLog, perfNow } from "../logging";
5
- import { stopManagementServer } from "../management-server";
5
+ import { stopManagementServer, ensureManagementServer } from "../management-server";
6
6
  export const MemoryPlugin = async (ctx) => {
7
7
  const { directory, client } = ctx;
8
8
  const t0 = perfNow();
@@ -40,9 +40,15 @@ export const MemoryPlugin = async (ctx) => {
40
40
  ...handlers,
41
41
  ...(autoRetrieveHook || {}),
42
42
  tool: toolMap,
43
- cleanup: async () => {
43
+ "session.created": async (event) => {
44
+ const existing = handlers["session.created"];
45
+ if (existing) {
46
+ await existing(event);
47
+ }
48
+ ensureManagementServer();
49
+ },
50
+ "session.deleted": async () => {
44
51
  stopManagementServer();
45
- await store.close();
46
52
  },
47
53
  };
48
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fractal-memory",
3
- "version": "0.6.10",
3
+ "version": "0.6.12",
4
4
  "description": "Fractal memory system for OpenCode with semantic search and automatic compression.",
5
5
  "main": "dist/plugin.js",
6
6
  "exports": {