opencode-claude-memory 1.7.7 → 2.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/README.md +104 -214
- package/dist/agents.d.ts +12 -0
- package/dist/agents.js +69 -0
- package/dist/config.d.ts +112 -0
- package/dist/config.js +79 -0
- package/dist/extraction/ExtractionCoordinator.d.ts +62 -0
- package/dist/extraction/ExtractionCoordinator.js +386 -0
- package/dist/extraction/autodream.d.ts +33 -0
- package/dist/extraction/autodream.js +85 -0
- package/dist/extraction/forkSession.d.ts +37 -0
- package/dist/extraction/forkSession.js +133 -0
- package/dist/extraction/lock.d.ts +29 -0
- package/dist/extraction/lock.js +191 -0
- package/dist/extraction/prompts.d.ts +5 -0
- package/dist/extraction/prompts.js +78 -0
- package/dist/extraction/state.d.ts +38 -0
- package/dist/extraction/state.js +159 -0
- package/dist/hooks/ignore.d.ts +6 -0
- package/dist/hooks/ignore.js +53 -0
- package/dist/hooks/messages.d.ts +14 -0
- package/dist/hooks/messages.js +96 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +50 -665
- package/dist/prompt/sections.d.ts +7 -0
- package/dist/{prompt.js → prompt/sections.js} +16 -72
- package/dist/prompt/systemPrompt.d.ts +7 -0
- package/dist/prompt/systemPrompt.js +64 -0
- package/dist/recall/RecallCoordinator.d.ts +36 -0
- package/dist/recall/RecallCoordinator.js +140 -0
- package/dist/recall/format.d.ts +17 -0
- package/dist/{recall.js → recall/format.js} +13 -36
- package/dist/{recallSelector.d.ts → recall/selector.d.ts} +26 -16
- package/dist/recall/selector.js +92 -0
- package/dist/sdk.d.ts +12 -0
- package/dist/sdk.js +8 -0
- package/dist/store/MemoryStore.d.ts +41 -0
- package/dist/store/MemoryStore.js +105 -0
- package/dist/store/frontmatter.d.ts +25 -0
- package/dist/store/frontmatter.js +61 -0
- package/dist/store/indexFile.d.ts +15 -0
- package/dist/store/indexFile.js +153 -0
- package/dist/{paths.d.ts → store/paths.d.ts} +7 -6
- package/dist/store/paths.js +187 -0
- package/dist/store/scan.d.ts +29 -0
- package/dist/store/scan.js +112 -0
- package/dist/tools.d.ts +9 -0
- package/dist/tools.js +142 -0
- package/dist/util/exclusiveFile.d.ts +11 -0
- package/dist/util/exclusiveFile.js +108 -0
- package/dist/util/legacyShellHook.d.ts +3 -0
- package/dist/util/legacyShellHook.js +23 -0
- package/dist/util/log.d.ts +6 -0
- package/dist/util/log.js +29 -0
- package/dist/util/ownedSessions.d.ts +7 -0
- package/dist/util/ownedSessions.js +39 -0
- package/dist/util/timeout.d.ts +5 -0
- package/dist/util/timeout.js +39 -0
- package/package.json +15 -8
- package/bin/opencode-memory +0 -1436
- package/dist/memory.d.ts +0 -31
- package/dist/memory.js +0 -224
- package/dist/memoryScan.d.ts +0 -20
- package/dist/memoryScan.js +0 -106
- package/dist/nativeExtraction.d.ts +0 -9
- package/dist/nativeExtraction.js +0 -80
- package/dist/paths.js +0 -141
- package/dist/prompt.d.ts +0 -4
- package/dist/recall.d.ts +0 -12
- package/dist/recallSelector.js +0 -154
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Registry of sub-sessions the plugin created itself (recall selectors, extraction and auto-dream
|
|
2
|
+
// forks). Their events and transforms must be ignored, otherwise a fork's own `session.idle` would
|
|
3
|
+
// trigger another extraction of the fork, and the recall hooks would inject memory into the selector.
|
|
4
|
+
//
|
|
5
|
+
// A fork's `session.idle` can arrive after its `session.delete` HTTP call resolved, so ownership is
|
|
6
|
+
// released with a grace period; `session.deleted` shortens that to a few seconds.
|
|
7
|
+
export class OwnedSessions {
|
|
8
|
+
timers = new Map();
|
|
9
|
+
add(id) {
|
|
10
|
+
const existing = this.timers.get(id);
|
|
11
|
+
if (existing)
|
|
12
|
+
clearTimeout(existing);
|
|
13
|
+
this.timers.set(id, undefined);
|
|
14
|
+
}
|
|
15
|
+
has(id) {
|
|
16
|
+
return id !== undefined && this.timers.has(id);
|
|
17
|
+
}
|
|
18
|
+
release(id, graceMs) {
|
|
19
|
+
if (!this.timers.has(id))
|
|
20
|
+
return;
|
|
21
|
+
const existing = this.timers.get(id);
|
|
22
|
+
if (existing)
|
|
23
|
+
clearTimeout(existing);
|
|
24
|
+
if (graceMs <= 0) {
|
|
25
|
+
this.timers.delete(id);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const timer = setTimeout(() => this.timers.delete(id), graceMs);
|
|
29
|
+
timer.unref?.();
|
|
30
|
+
this.timers.set(id, timer);
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
for (const timer of this.timers.values()) {
|
|
34
|
+
if (timer)
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
}
|
|
37
|
+
this.timers.clear();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare class TimeoutError extends Error {
|
|
2
|
+
constructor(what: string, timeoutMs: number);
|
|
3
|
+
}
|
|
4
|
+
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, error: () => Error): Promise<T>;
|
|
5
|
+
export declare function withDeadline<T>(what: string, timeoutMs: number, call: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Bounded waits for SDK calls. The plugin SDK client disables fetch timeouts, so every request
|
|
2
|
+
// the plugin makes must carry its own deadline; the AbortSignal is passed to the request so a hung
|
|
3
|
+
// connection is actually torn down instead of leaking.
|
|
4
|
+
export class TimeoutError extends Error {
|
|
5
|
+
constructor(what, timeoutMs) {
|
|
6
|
+
super(`${what} timed out after ${timeoutMs}ms`);
|
|
7
|
+
this.name = "TimeoutError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
// The deadline timer is deliberately *not* unref'd: it is cleared as soon as the call settles, and
|
|
11
|
+
// an unref'd timer is the only thing that has to fire when a request hangs. On Windows, Bun's event
|
|
12
|
+
// loop does not wake up for unref'd timers while nothing else is pending (observed on CI), so an
|
|
13
|
+
// unref'd deadline would never expire exactly when it is needed.
|
|
14
|
+
export function withTimeout(promise, timeoutMs, error) {
|
|
15
|
+
let timer;
|
|
16
|
+
const timeout = new Promise((_, reject) => {
|
|
17
|
+
timer = setTimeout(() => reject(error()), timeoutMs);
|
|
18
|
+
});
|
|
19
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
20
|
+
if (timer)
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// Runs `call` with a fresh AbortSignal that fires when the deadline passes. The SDK request
|
|
25
|
+
// options extend `RequestInit`, so the signal cancels the underlying fetch.
|
|
26
|
+
export function withDeadline(what, timeoutMs, call) {
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
let invoked;
|
|
29
|
+
try {
|
|
30
|
+
invoked = Promise.resolve(call(controller.signal));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return Promise.reject(error);
|
|
34
|
+
}
|
|
35
|
+
return withTimeout(invoked, timeoutMs, () => {
|
|
36
|
+
controller.abort();
|
|
37
|
+
return new TimeoutError(what, timeoutMs);
|
|
38
|
+
});
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-claude-memory",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "OpenCode plugin for Claude Code memory: persistent, local-first shared memory with Claude Code-compatible Markdown files, auto extraction, and auto-dream",
|
|
5
|
+
"description": "OpenCode plugin for Claude Code memory: persistent, local-first shared memory with Claude Code-compatible Markdown files, LLM recall, in-process auto extraction, and auto-dream consolidation",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"opencode-memory": "./bin/opencode-memory"
|
|
10
|
-
},
|
|
11
8
|
"exports": {
|
|
12
9
|
".": {
|
|
13
10
|
"types": "./dist/index.d.ts",
|
|
@@ -18,8 +15,16 @@
|
|
|
18
15
|
"files": [
|
|
19
16
|
"dist"
|
|
20
17
|
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"opencode": ">=1.18.0"
|
|
20
|
+
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"build": "tsc -p tsconfig.build.json",
|
|
23
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
24
|
+
"lint": "biome ci .",
|
|
25
|
+
"format": "biome check --write .",
|
|
26
|
+
"test": "bun test",
|
|
27
|
+
"evals": "bun run test/evals/run.ts",
|
|
23
28
|
"prepack": "npm run build"
|
|
24
29
|
},
|
|
25
30
|
"repository": {
|
|
@@ -53,14 +58,16 @@
|
|
|
53
58
|
],
|
|
54
59
|
"license": "MIT",
|
|
55
60
|
"peerDependencies": {
|
|
56
|
-
"@opencode-ai/plugin": "
|
|
61
|
+
"@opencode-ai/plugin": ">=1.18.0"
|
|
57
62
|
},
|
|
58
63
|
"dependencies": {
|
|
59
64
|
"zod": "^3.24.0"
|
|
60
65
|
},
|
|
61
66
|
"devDependencies": {
|
|
67
|
+
"@biomejs/biome": "^2",
|
|
68
|
+
"@opencode-ai/plugin": "^1.18.16",
|
|
62
69
|
"bun-types": "^1.3.11",
|
|
63
|
-
"
|
|
70
|
+
"conventional-changelog-conventionalcommits": "^9",
|
|
64
71
|
"typescript": "^6.0.2"
|
|
65
72
|
}
|
|
66
73
|
}
|