opencode-fractal-memory 0.6.2 → 0.6.4

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.
@@ -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,23 +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 { VERSION } from "../version";
6
- function showToast(serverUrl, version) {
7
- setTimeout(() => {
8
- const url = `${serverUrl.origin}/tui/show-toast`;
9
- fetch(url, {
10
- method: "POST",
11
- headers: { "Content-Type": "application/json" },
12
- body: JSON.stringify({
13
- title: "Fractal Memory",
14
- message: `v${version} loaded`,
15
- variant: "info",
16
- }),
17
- }).catch((err) => {
18
- memLog("warn", "init", "Toast notification failed", { error: String(err), serverUrl: serverUrl.origin });
19
- });
20
- }, 2000);
21
- }
5
+ import { stopManagementServer } from "../management-server";
22
6
  export const MemoryPlugin = async (ctx) => {
23
7
  const { directory, client } = ctx;
24
8
  const t0 = perfNow();
@@ -52,12 +36,12 @@ export const MemoryPlugin = async (ctx) => {
52
36
  const handlers = createHookHandlers(store, client, memConfig, ruleCache, ruleCacheDirty, sessionInjectionLock, latestUserMessage);
53
37
  const toolMap = createToolMap(store, journalTools, client);
54
38
  memLog("info", "init", "Plugin initialization completed", { totalDurationMs: perfNow() - t0 });
55
- showToast(ctx.serverUrl, VERSION);
56
39
  return {
57
40
  ...handlers,
58
41
  ...(autoRetrieveHook || {}),
59
42
  tool: toolMap,
60
43
  cleanup: async () => {
44
+ stopManagementServer();
61
45
  await store.close();
62
46
  },
63
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fractal-memory",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Fractal memory system for OpenCode with semantic search and automatic compression.",
5
5
  "main": "dist/plugin.js",
6
6
  "exports": {