opencode-lcm 0.11.0 → 0.13.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 +16 -3
- package/dist/store.d.ts +20 -4
- package/dist/store.js +456 -314
- package/package.json +1 -1
- package/src/store.ts +556 -360
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Opencode-lcm (Lossless Context Memory)
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/opencode-lcm)
|
|
3
4
|
[](https://github.com/Plutarch01/opencode-lcm/actions/workflows/ci.yml)
|
|
4
5
|
[](https://opensource.org/licenses/MIT)
|
|
5
6
|
|
|
6
|
-
A transparent long-memory plugin for [OpenCode](https://github.com/sst/opencode), based on the [Lossless Context Memory (LCM)](https://papers.voltropy.com/LCM) research. It captures older session context outside the active prompt, compresses it into searchable summaries and artifacts, then automatically recalls relevant details back into the prompt when the current turn needs them. The model does not become smarter, but it behaves much better across long, compacted sessions because important prior context stops disappearing.
|
|
7
|
+
A transparent long-memory plugin for [OpenCode](https://github.com/sst/opencode), based on the [Lossless Context Memory (LCM)](https://papers.voltropy.com/LCM) research by Voltropy. It captures older session context outside the active prompt, compresses it into searchable summaries and artifacts, then automatically recalls relevant details back into the prompt when the current turn needs them. The model does not become smarter, but it behaves much better across long, compacted sessions because important prior context stops disappearing.
|
|
7
8
|
|
|
8
9
|
<!-- Add a demo screenshot or GIF here -->
|
|
9
10
|
<!--  -->
|
|
@@ -31,12 +32,24 @@ OpenCode will automatically download the latest version from npm on startup. No
|
|
|
31
32
|
### From source
|
|
32
33
|
|
|
33
34
|
```sh
|
|
34
|
-
git clone https://github.com/
|
|
35
|
+
git clone https://github.com/Plutarch01/opencode-lcm.git
|
|
35
36
|
cd opencode-lcm
|
|
36
37
|
npm install
|
|
37
38
|
npm run build
|
|
38
39
|
```
|
|
39
40
|
|
|
41
|
+
Then copy or symlink the built plugin into your plugins directory:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
# Project-level
|
|
45
|
+
cp dist/index.js .opencode/plugins/opencode-lcm.js
|
|
46
|
+
|
|
47
|
+
# Or global
|
|
48
|
+
cp dist/index.js ~/.config/opencode/plugins/opencode-lcm.js
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Local plugins in `.opencode/plugins/` or `~/.config/opencode/plugins/` are loaded automatically by OpenCode at startup.
|
|
52
|
+
|
|
40
53
|
## How It Works
|
|
41
54
|
|
|
42
55
|
OpenCode handles compaction normally — when the conversation gets too large, it shrinks the prompt. `opencode-lcm` works alongside that by saving older details *outside* the prompt, then searching that archive later to pull back only what matters.
|
package/dist/store.d.ts
CHANGED
|
@@ -78,8 +78,14 @@ type SqliteRuntimeOptions = {
|
|
|
78
78
|
isBunRuntime?: boolean;
|
|
79
79
|
platform?: string | undefined;
|
|
80
80
|
};
|
|
81
|
+
type CaptureHydrationMode = 'full' | 'targeted';
|
|
82
|
+
type CaptureHydrationOptions = {
|
|
83
|
+
isBunRuntime?: boolean;
|
|
84
|
+
platform?: string | undefined;
|
|
85
|
+
};
|
|
81
86
|
export declare function resolveSqliteRuntimeCandidates(options?: SqliteRuntimeOptions): SqliteRuntime[];
|
|
82
87
|
export declare function resolveSqliteRuntime(options?: SqliteRuntimeOptions): SqliteRuntime;
|
|
88
|
+
export declare function resolveCaptureHydrationMode(options?: CaptureHydrationOptions): CaptureHydrationMode;
|
|
83
89
|
export declare class SqliteLcmStore {
|
|
84
90
|
private readonly options;
|
|
85
91
|
private static readonly deferredPartUpdateDelayMs;
|
|
@@ -89,11 +95,17 @@ export declare class SqliteLcmStore {
|
|
|
89
95
|
private readonly workspaceDirectory;
|
|
90
96
|
private db?;
|
|
91
97
|
private dbReadyPromise?;
|
|
98
|
+
private deferredInitTimer?;
|
|
99
|
+
private deferredInitPromise?;
|
|
100
|
+
private deferredInitRequested;
|
|
101
|
+
private activeOperationCount;
|
|
92
102
|
private readonly pendingPartUpdates;
|
|
93
103
|
private pendingPartUpdateTimer?;
|
|
94
104
|
private pendingPartUpdateFlushPromise?;
|
|
95
105
|
constructor(projectDir: string, options: OpencodeLcmOptions);
|
|
96
106
|
init(): Promise<void>;
|
|
107
|
+
private withStoreActivity;
|
|
108
|
+
private waitForDeferredInitIfRunning;
|
|
97
109
|
private prepareForRead;
|
|
98
110
|
private scheduleDeferredPartUpdateFlush;
|
|
99
111
|
private clearDeferredPartUpdateTimer;
|
|
@@ -105,6 +117,9 @@ export declare class SqliteLcmStore {
|
|
|
105
117
|
private ensureDbReady;
|
|
106
118
|
private openAndInitializeDb;
|
|
107
119
|
private deferredInitCompleted;
|
|
120
|
+
private runDeferredInit;
|
|
121
|
+
private scheduleDeferredInit;
|
|
122
|
+
private ensureDeferredInitComplete;
|
|
108
123
|
private readSchemaVersionSync;
|
|
109
124
|
private assertSupportedSchemaVersionSync;
|
|
110
125
|
private writeSchemaVersionSync;
|
|
@@ -141,10 +156,6 @@ export declare class SqliteLcmStore {
|
|
|
141
156
|
private shouldRecordEvent;
|
|
142
157
|
private shouldSyncDerivedLineageSubtree;
|
|
143
158
|
private shouldCleanupOrphanBlobsForEvent;
|
|
144
|
-
private captureArtifactHydrationMessageIDs;
|
|
145
|
-
private archivedMessageIDs;
|
|
146
|
-
private didArchivedMessagesChange;
|
|
147
|
-
private isArchivedMessage;
|
|
148
159
|
private shouldSyncDerivedSessionStateForEvent;
|
|
149
160
|
private syncAllDerivedSessionStateSync;
|
|
150
161
|
private syncDerivedSessionStateSync;
|
|
@@ -287,6 +298,7 @@ export declare class SqliteLcmStore {
|
|
|
287
298
|
private resolveLineageSync;
|
|
288
299
|
private applyEvent;
|
|
289
300
|
private getResumeSync;
|
|
301
|
+
private materializeSessionRow;
|
|
290
302
|
private readSessionHeaderSync;
|
|
291
303
|
private clearSessionDataSync;
|
|
292
304
|
private readChildSessionsSync;
|
|
@@ -296,6 +308,10 @@ export declare class SqliteLcmStore {
|
|
|
296
308
|
private readSessionSync;
|
|
297
309
|
private prepareSessionForPersistence;
|
|
298
310
|
private sanitizeParentSessionIDSync;
|
|
311
|
+
private readSessionForCaptureSync;
|
|
312
|
+
private readMessageSync;
|
|
313
|
+
private readMessageCountSync;
|
|
314
|
+
private isMessageArchivedSync;
|
|
299
315
|
private persistCapturedSession;
|
|
300
316
|
private persistSession;
|
|
301
317
|
private persistStoredSessionSync;
|