opencode-supermemory 0.1.6 → 0.1.8
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 +4 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -13
- package/dist/services/compaction.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,7 +219,10 @@ Create `~/.config/opencode/supermemory.jsonc`:
|
|
|
219
219
|
"containerTagPrefix": "opencode",
|
|
220
220
|
|
|
221
221
|
// Extra keyword patterns for memory detection (regex)
|
|
222
|
-
"keywordPatterns": ["log\\s+this", "write\\s+down"]
|
|
222
|
+
"keywordPatterns": ["log\\s+this", "write\\s+down"],
|
|
223
|
+
|
|
224
|
+
// Context usage ratio that triggers compaction (0-1)
|
|
225
|
+
"compactionThreshold": 0.80
|
|
223
226
|
}
|
|
224
227
|
```
|
|
225
228
|
|
package/dist/config.d.ts
CHANGED
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAyFA,eAAO,MAAM,mBAAmB,oBAAuD,CAAC;AAExF,eAAO,MAAM,MAAM;;;;;;;;;;CAalB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAsC/D,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAsC/D,eAAO,MAAM,iBAAiB,EAAE,MAsc/B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -13709,7 +13709,8 @@ var DEFAULTS = {
|
|
|
13709
13709
|
injectProfile: true,
|
|
13710
13710
|
containerTagPrefix: "opencode",
|
|
13711
13711
|
filterPrompt: "You are a stateful coding agent. Remember all the information, including but not limited to user's coding preferences, tech stack, behaviours, workflows, and any other relevant details.",
|
|
13712
|
-
keywordPatterns: []
|
|
13712
|
+
keywordPatterns: [],
|
|
13713
|
+
compactionThreshold: 0.8
|
|
13713
13714
|
};
|
|
13714
13715
|
function isValidRegex(pattern) {
|
|
13715
13716
|
try {
|
|
@@ -13719,6 +13720,14 @@ function isValidRegex(pattern) {
|
|
|
13719
13720
|
return false;
|
|
13720
13721
|
}
|
|
13721
13722
|
}
|
|
13723
|
+
function validateCompactionThreshold(value) {
|
|
13724
|
+
if (value === undefined || typeof value !== "number" || isNaN(value)) {
|
|
13725
|
+
return DEFAULTS.compactionThreshold;
|
|
13726
|
+
}
|
|
13727
|
+
if (value <= 0 || value > 1)
|
|
13728
|
+
return DEFAULTS.compactionThreshold;
|
|
13729
|
+
return value;
|
|
13730
|
+
}
|
|
13722
13731
|
function loadConfig() {
|
|
13723
13732
|
for (const path2 of CONFIG_FILES) {
|
|
13724
13733
|
if (existsSync(path2)) {
|
|
@@ -13744,7 +13753,8 @@ var CONFIG = {
|
|
|
13744
13753
|
keywordPatterns: [
|
|
13745
13754
|
...DEFAULT_KEYWORD_PATTERNS,
|
|
13746
13755
|
...(fileConfig.keywordPatterns ?? []).filter(isValidRegex)
|
|
13747
|
-
]
|
|
13756
|
+
],
|
|
13757
|
+
compactionThreshold: validateCompactionThreshold(fileConfig.compactionThreshold)
|
|
13748
13758
|
};
|
|
13749
13759
|
function isConfigured() {
|
|
13750
13760
|
return !!SUPERMEMORY_API_KEY;
|
|
@@ -13999,8 +14009,7 @@ var PART_STORAGE = join3(homedir3(), ".opencode", "parts");
|
|
|
13999
14009
|
var DEFAULT_THRESHOLD = 0.8;
|
|
14000
14010
|
var MIN_TOKENS_FOR_COMPACTION = 50000;
|
|
14001
14011
|
var COMPACTION_COOLDOWN_MS = 30000;
|
|
14002
|
-
var
|
|
14003
|
-
var CLAUDE_MODEL_PATTERN = /claude-(opus|sonnet|haiku)/i;
|
|
14012
|
+
var DEFAULT_CONTEXT_LIMIT = 200000;
|
|
14004
14013
|
function createCompactionPrompt(projectMemories) {
|
|
14005
14014
|
const memoriesSection = projectMemories.length > 0 ? `
|
|
14006
14015
|
## Project Knowledge (from Supermemory)
|
|
@@ -14040,9 +14049,6 @@ ${memoriesSection}
|
|
|
14040
14049
|
This context is critical for maintaining continuity after compaction.
|
|
14041
14050
|
`;
|
|
14042
14051
|
}
|
|
14043
|
-
function isSupportedModel(modelID) {
|
|
14044
|
-
return CLAUDE_MODEL_PATTERN.test(modelID);
|
|
14045
|
-
}
|
|
14046
14052
|
function getMessageDir(sessionID) {
|
|
14047
14053
|
if (!existsSync2(MESSAGE_STORAGE))
|
|
14048
14054
|
return null;
|
|
@@ -14218,12 +14224,8 @@ ${summaryContent}`, tags.project, { type: "conversation" });
|
|
|
14218
14224
|
modelID = storedMessage.model.modelID;
|
|
14219
14225
|
}
|
|
14220
14226
|
agent = storedMessage?.agent;
|
|
14221
|
-
if (!isSupportedModel(modelID)) {
|
|
14222
|
-
log("[compaction] skipping unsupported model", { modelID });
|
|
14223
|
-
return;
|
|
14224
|
-
}
|
|
14225
14227
|
const configLimit = getModelLimit?.(providerID, modelID);
|
|
14226
|
-
const contextLimit = configLimit ??
|
|
14228
|
+
const contextLimit = configLimit ?? DEFAULT_CONTEXT_LIMIT;
|
|
14227
14229
|
const totalUsed = tokens.input + tokens.cache.read + tokens.output;
|
|
14228
14230
|
if (totalUsed < MIN_TOKENS_FOR_COMPACTION)
|
|
14229
14231
|
return;
|
|
@@ -14415,7 +14417,33 @@ var SupermemoryPlugin = async (ctx) => {
|
|
|
14415
14417
|
if (!isConfigured()) {
|
|
14416
14418
|
log("Plugin disabled - SUPERMEMORY_API_KEY not set");
|
|
14417
14419
|
}
|
|
14418
|
-
const
|
|
14420
|
+
const modelLimits = new Map;
|
|
14421
|
+
(async () => {
|
|
14422
|
+
try {
|
|
14423
|
+
const response = await ctx.client.provider.list();
|
|
14424
|
+
if (response.data?.all) {
|
|
14425
|
+
for (const provider of response.data.all) {
|
|
14426
|
+
if (provider.models) {
|
|
14427
|
+
for (const [modelId, model] of Object.entries(provider.models)) {
|
|
14428
|
+
if (model.limit?.context) {
|
|
14429
|
+
modelLimits.set(`${provider.id}/${modelId}`, model.limit.context);
|
|
14430
|
+
}
|
|
14431
|
+
}
|
|
14432
|
+
}
|
|
14433
|
+
}
|
|
14434
|
+
}
|
|
14435
|
+
log("Model limits loaded", { count: modelLimits.size });
|
|
14436
|
+
} catch (error45) {
|
|
14437
|
+
log("Failed to fetch model limits", { error: String(error45) });
|
|
14438
|
+
}
|
|
14439
|
+
})();
|
|
14440
|
+
const getModelLimit = (providerID, modelID) => {
|
|
14441
|
+
return modelLimits.get(`${providerID}/${modelID}`);
|
|
14442
|
+
};
|
|
14443
|
+
const compactionHook = isConfigured() && ctx.client ? createCompactionHook(ctx, tags, {
|
|
14444
|
+
threshold: CONFIG.compactionThreshold,
|
|
14445
|
+
getModelLimit
|
|
14446
|
+
}) : null;
|
|
14419
14447
|
return {
|
|
14420
14448
|
"chat.message": async (input, output) => {
|
|
14421
14449
|
if (!isConfigured())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/services/compaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/services/compaction.ts"],"names":[],"mappings":"AAqBA,UAAU,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC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