@ephemushroom/opencode-claude-mem 0.6.2 → 0.7.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.
@@ -2,101 +2,30 @@ export interface WorkerEndpoint {
2
2
  readonly host: string;
3
3
  readonly port: number;
4
4
  }
5
- export type AutoStartResult = 'already-running' | 'started' | 'no-bun' | 'spawn-failed' | 'timeout' | 'skipped';
6
- export type SearchOrder = 'date_desc' | 'date_asc' | 'relevance';
7
- export interface SearchOptions {
8
- readonly query?: string;
9
- readonly limit?: number;
10
- readonly project?: string;
11
- readonly platformSource?: string;
12
- readonly type?: string;
13
- readonly obs_type?: string;
14
- readonly dateStart?: string;
15
- readonly dateEnd?: string;
16
- readonly offset?: number;
17
- readonly orderBy?: SearchOrder;
18
- }
19
- export interface ObservedMetadata {
20
- readonly observedModel?: string;
21
- readonly observedBilling?: string;
5
+ export interface ProjectCounts {
6
+ readonly observations: number;
7
+ readonly summaries: number;
8
+ readonly sessions: number;
22
9
  }
23
10
  export declare function parseWorkerEndpoint(env: Record<string, string | undefined>, rawSettings: string | null): WorkerEndpoint;
24
- export declare function buildSearchParams(options: SearchOptions): URLSearchParams;
11
+ /**
12
+ * The Worker's SQLite database: CLAUDE_MEM_DATA_DIR from env, then settings, then
13
+ * ~/.claude-mem. Null when the Worker is not on this machine, because a local file would
14
+ * then describe a different store.
15
+ */
16
+ export declare function resolveDatabasePath(env: Record<string, string | undefined>, rawSettings: string | null, home: string): string | null;
17
+ /** Read-only per-project counts; null on a missing, locked or unexpected database. */
18
+ export declare function readProjectCounts(path: string, project: string): Promise<ProjectCounts | null>;
25
19
  export declare function getWorkerBaseUrl(): string;
26
20
  export declare class WorkerClient {
27
21
  private static readonly BASE_URL;
28
- /** Per-process guard so multiple OpenCode windows don't all spawn workers. */
29
- private static autoStartPromise;
30
- /**
31
- * Check if the worker is healthy
32
- */
33
- static isHealthy(): Promise<boolean>;
34
- /**
35
- * Ensure the worker is running. If healthy, returns true. Otherwise tries
36
- * to spawn it via `bunx claude-mem start` in the background and resolves
37
- * once the worker reports healthy or the timeout is reached.
38
- *
39
- * Idempotent + serialised within the process via `autoStartPromise`.
40
- */
41
- static ensureRunning(): Promise<boolean>;
42
- /**
43
- * Try to auto-start the Claude-Mem worker via `bunx claude-mem start`.
44
- *
45
- * Behaviour:
46
- * - If the worker is already healthy, returns 'already-running' immediately.
47
- * - If `bun` is not on PATH, returns 'no-bun' without attempting to spawn.
48
- * - Otherwise spawns a detached `bunx claude-mem start` process and polls
49
- * /api/health for ~8 seconds. Returns 'started' on success, 'timeout' on
50
- * failure to come up, 'spawn-failed' if the spawn itself errored.
51
- *
52
- * Concurrent calls share the same in-flight promise.
53
- */
54
- static tryAutoStart(): Promise<AutoStartResult>;
55
- private static runAutoStart;
56
- /**
57
- * Locate the `bun` executable. Prefers Bun's own runtime detector when the
58
- * plugin is loaded inside Bun (which OpenCode currently is), then falls back
59
- * to PATH probing via `process.env.PATH`.
60
- */
61
- private static findBun;
62
- /**
63
- * Initialize a session
64
- */
65
- static sessionInit(contentSessionId: string, project: string, prompt: string): Promise<{
66
- sessionDbId: number;
67
- promptNumber: number;
68
- skipped?: boolean;
69
- reason?: string;
70
- } | null>;
71
- /**
72
- * Send observation
73
- */
74
- static sendObservation(contentSessionId: string, toolName: string, toolInput: unknown, toolResponse: unknown, cwd: string, toolUseId?: string): Promise<boolean>;
22
+ private static readonly DATABASE_PATH;
75
23
  /**
76
- * Trigger summarization
24
+ * Per-project counts, read from the Worker's database in read-only mode. The Worker's
25
+ * HTTP API only reports global totals. Null when the database is remote, missing,
26
+ * locked or of an unknown schema; the sidebar then falls back to the global totals.
77
27
  */
78
- static summarize(contentSessionId: string, lastUserMessage: string, lastAssistantMessage: string, metadata?: ObservedMetadata): Promise<boolean>;
79
- /**
80
- * Get pre-formatted context for system prompt injection.
81
- * Uses /api/context/inject which returns rich markdown with observations + session summaries.
82
- */
83
- static getContext(project: string): Promise<string | null>;
84
- /**
85
- * Timeline: get chronological context around an observation anchor or query.
86
- * Mirrors the upstream MCP `timeline` tool (GET /api/timeline).
87
- */
88
- static timeline(options: {
89
- project: string;
90
- anchor?: number;
91
- query?: string;
92
- depthBefore?: number;
93
- depthAfter?: number;
94
- }): Promise<string>;
95
- /**
96
- * Fetch full observation details by IDs.
97
- * Mirrors the upstream MCP `get_observations` tool (POST /api/observations/batch).
98
- */
99
- static getObservations(ids: number[], project?: string): Promise<string>;
28
+ static getProjectCounts(project: string): Promise<ProjectCounts | null>;
100
29
  /**
101
30
  * Fetch worker + database stats plus processing status for the sidebar view.
102
31
  * Combines GET /api/stats and GET /api/processing-status; null when offline.
@@ -118,6 +47,7 @@ export declare class WorkerClient {
118
47
  static getRecentSummaries(project: string, limit: number): Promise<{
119
48
  id: number;
120
49
  request: string;
50
+ at: number | null;
121
51
  }[]>;
122
52
  /**
123
53
  * Recent observations for the sidebar (GET /api/observations).
@@ -126,6 +56,11 @@ export declare class WorkerClient {
126
56
  id: number;
127
57
  type: string;
128
58
  title: string;
59
+ at: number | null;
129
60
  }[]>;
130
- static search(options: SearchOptions): Promise<string>;
61
+ /**
62
+ * One observation (GET /api/observation/:id) or session summary (GET /api/session/:id)
63
+ * for the detail dialog; null when missing or offline.
64
+ */
65
+ static getDetail(kind: 'summary' | 'observation', id: number): Promise<Record<string, unknown> | null>;
131
66
  }
package/package.json CHANGED
@@ -1,26 +1,12 @@
1
1
  {
2
2
  "name": "@ephemushroom/opencode-claude-mem",
3
- "version": "0.6.2",
4
- "description": "OpenCode plugin for Claude-Mem persistent memory system",
5
- "main": "./dist/package-server.js",
6
- "types": "./dist/package-server.d.ts",
3
+ "version": "0.7.0",
4
+ "description": "OpenCode Memory sidebar for Claude-Mem; pairs with the official claude-mem OpenCode plugin",
7
5
  "type": "module",
8
6
  "files": [
9
7
  "dist"
10
8
  ],
11
9
  "exports": {
12
- ".": {
13
- "types": "./dist/package-server.d.ts",
14
- "import": "./dist/package-server.js"
15
- },
16
- "./v2": {
17
- "types": "./dist/v2.d.ts",
18
- "import": "./dist/v2.js"
19
- },
20
- "./server": {
21
- "types": "./dist/package-server.d.ts",
22
- "import": "./dist/package-server.js"
23
- },
24
10
  "./tui": {
25
11
  "types": "./dist/package-tui.d.ts",
26
12
  "import": "./dist/package-tui.js"
@@ -31,7 +17,7 @@
31
17
  }
32
18
  },
33
19
  "scripts": {
34
- "build": "bun build src/index.ts --outfile dist/index.js --target bun --format esm && bun build src/v2.ts --outfile dist/v2.js --target bun --format esm && bun build src/tui.ts --outfile dist/tui.js --target bun --format esm --external @opentui/solid --external solid-js && bun build src/cli.ts --outfile dist/cli.js --target bun --format esm --external @opentui/solid --external solid-js && bun build src/package-server.ts --outdir dist --target bun --format esm --external '*' && bun src/build-tui-bridge.ts && tsc -p tsconfig.build.json --emitDeclarationOnly",
20
+ "build": "bun build src/tui.ts --outfile dist/tui.js --target bun --format esm --external @opentui/solid --external solid-js && bun build src/cli.ts --outfile dist/cli.js --target bun --format esm --external @opentui/solid --external solid-js && bun src/build-tui-bridge.ts && tsc -p tsconfig.build.json --emitDeclarationOnly",
35
21
  "dev": "tsc --watch",
36
22
  "clean": "rm -rf dist",
37
23
  "lint": "oxlint",
@@ -61,19 +47,16 @@
61
47
  "access": "public"
62
48
  },
63
49
  "dependencies": {
64
- "@opentui/solid": "0.5.10"
50
+ "@opentui/solid": "0.8.1"
65
51
  },
66
52
  "devDependencies": {
67
- "@opencode-ai/plugin": "^1.14.41",
68
- "@opencode-ai/plugin-v2": "npm:@opencode-ai/plugin@0.0.0-beta-19151",
69
- "@opencode-ai/theme": "^0.0.0-next-17030",
70
- "@opencode/plugin": "2.0.16",
71
- "@opencode/theme": "2.0.16",
72
- "@opentui/core": "0.5.10",
53
+ "@opencode/plugin": "2.2.7",
54
+ "@opencode/theme": "2.2.7",
55
+ "@opentui/core": "0.8.1",
73
56
  "@types/bun": "latest",
74
57
  "oxfmt": "^0.33.0",
75
58
  "oxlint": "^1.63.0",
76
- "solid-js": "1.9.14",
59
+ "solid-js": "1.9.17",
77
60
  "typescript": "^5.9.3",
78
61
  "zod": "4.1.8"
79
62
  }
@@ -1,17 +0,0 @@
1
- import type { InjectionOptions } from './memory-options';
2
- import { MemoryWorker } from './memory-worker';
3
- export declare class FileContext {
4
- private readonly sessions;
5
- private readonly options;
6
- private readonly worker;
7
- constructor(options: InjectionOptions, worker?: typeof MemoryWorker);
8
- read(session: string, input: {
9
- readonly tool: string;
10
- readonly args: unknown;
11
- }, location: {
12
- readonly directory: string;
13
- readonly project: string;
14
- }): Promise<string>;
15
- delete(session: string): void;
16
- clear(): void;
17
- }
package/dist/index.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { type Plugin } from '@opencode-ai/plugin';
2
- /**
3
- * OpenCode Plugin for Claude-Mem
4
- *
5
- * Hooks used:
6
- * - `event` — session lifecycle (session.created, session.idle, session.compacted,
7
- * session.deleted, message.updated, file.edited)
8
- * - `tool.execute.after` — capture tool observations
9
- * - `experimental.chat.system.transform` — inject memory context into system prompt
10
- * - `experimental.session.compacting` — preserve memory context during compaction
11
- * - `chat.message` — session init with real user prompt
12
- *
13
- * Memory context is automatically injected into every conversation via system prompt.
14
- * No manual commands needed - the plugin works transparently in the background.
15
- */
16
- export declare const ClaudeMemPlugin: Plugin;
17
- declare const _default: {
18
- server: Plugin;
19
- };
20
- export default _default;