opencode-fractal-memory 0.6.3 → 0.6.5

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
@@ -168,6 +168,8 @@ Create `~/.config/opencode/opencode-mem.json` to customize (optional — all def
168
168
  | `criticalContextThreshold` | float | `0.8` | Token usage ratio for critical warning |
169
169
  | `defaultTtlDays` | int | `0` | Default TTL for new nodes (0 = no expiry) |
170
170
  | `enableMiddleTermCapture` | bool | `true` | Save middle-term snapshots before compression |
171
+ | `management.enabled` | bool | `false` | Auto-start the management web UI on plugin init |
172
+ | `management.port` | int | `8787` | Port for the management server |
171
173
  | `autoFileSummarization.enabled` | bool | `false` | Auto-summarize files on read |
172
174
 
173
175
  ## Advanced Features
@@ -360,11 +362,13 @@ A local web UI for browsing, searching, and editing memory — available when th
360
362
 
361
363
  ### Starting
362
364
 
365
+ The server starts automatically when `management.enabled: true` is set in your config (see [Configuration](#configuration)), or manually:
366
+
363
367
  ```bash
364
368
  bun run view
365
369
  ```
366
370
 
367
- Opens at [http://localhost:8787](http://localhost:8787). The server also starts automatically with OpenCode.
371
+ Opens at [http://localhost:8787](http://localhost:8787). The server starts as a background process and auto-stops on plugin shutdown.
368
372
 
369
373
  ### Usage
370
374
 
@@ -1,4 +1,47 @@
1
- export function startManagementServer(_store, _directory, _config) {
2
- // No-op: management server is now a standalone CLI
3
- // Run: bun run ~/.config/opencode/node_modules/opencode-fractal-memory/dist/management-standalone.js
1
+ import * as path from "node:path";
2
+ import { memLog } from "./logging";
3
+ let activeProcess = null;
4
+ export function startManagementServer(_store, directory, config) {
5
+ if (activeProcess) {
6
+ memLog("warn", "management", "Management server already running, killing old instance");
7
+ stopManagementServer();
8
+ }
9
+ const standalonePath = path.join(__dirname, "management-standalone.js");
10
+ try {
11
+ const proc = Bun.spawn(["bun", standalonePath], {
12
+ env: {
13
+ ...process.env,
14
+ MGMT_PORT: String(config.port),
15
+ MGMT_PROJECT_DIR: directory,
16
+ },
17
+ stdio: ["ignore", "pipe", "pipe"],
18
+ });
19
+ activeProcess = proc;
20
+ proc.exited.then((code) => {
21
+ memLog("info", "management", `Management server exited (code: ${code})`);
22
+ if (activeProcess === proc)
23
+ activeProcess = null;
24
+ });
25
+ memLog("info", "management", `Management server started on http://localhost:${config.port} (pid: ${proc.pid})`);
26
+ }
27
+ catch (err) {
28
+ memLog("error", "management", "Failed to start management server", {
29
+ error: err instanceof Error ? err.message : String(err),
30
+ standalonePath,
31
+ });
32
+ }
33
+ }
34
+ export function stopManagementServer() {
35
+ if (activeProcess) {
36
+ try {
37
+ activeProcess.kill("SIGTERM");
38
+ memLog("info", "management", `Management server process ${activeProcess.pid} killed`);
39
+ }
40
+ catch (err) {
41
+ memLog("warn", "management", "Error killing management server", {
42
+ error: err instanceof Error ? err.message : String(err),
43
+ });
44
+ }
45
+ activeProcess = null;
46
+ }
4
47
  }
@@ -2,6 +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
6
  export const MemoryPlugin = async (ctx) => {
6
7
  const { directory, client } = ctx;
7
8
  const t0 = perfNow();
@@ -40,6 +41,7 @@ export const MemoryPlugin = async (ctx) => {
40
41
  ...(autoRetrieveHook || {}),
41
42
  tool: toolMap,
42
43
  cleanup: async () => {
44
+ stopManagementServer();
43
45
  await store.close();
44
46
  },
45
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fractal-memory",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "Fractal memory system for OpenCode with semantic search and automatic compression.",
5
5
  "main": "dist/plugin.js",
6
6
  "exports": {