@bunkercache/opencode-memoir 0.3.0 → 0.3.1
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/dist/index.js +5 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1672,33 +1672,7 @@ var MEMORY_NUDGE_MESSAGE = `[MEMORY TRIGGER DETECTED]
|
|
|
1672
1672
|
The user wants you to remember something. Use the \`memoir\` tool with \`mode: "add"\` to save this information.
|
|
1673
1673
|
Extract the key information and save it as a concise, searchable memory.
|
|
1674
1674
|
Choose an appropriate type: "preference", "pattern", "gotcha", "fact", or "learned".`;
|
|
1675
|
-
function
|
|
1676
|
-
if (chunk.summary) {
|
|
1677
|
-
return chunk.summary;
|
|
1678
|
-
}
|
|
1679
|
-
const messageCount = chunk.content.messages.length;
|
|
1680
|
-
const files = chunk.content.metadata.files_modified?.length || 0;
|
|
1681
|
-
const tools = chunk.content.metadata.tools_used?.slice(0, 3).join(", ") || "none";
|
|
1682
|
-
return `${messageCount} messages, ${files} files modified, tools: ${tools}`;
|
|
1683
|
-
}
|
|
1684
|
-
function formatSessionHistory(chunks) {
|
|
1685
|
-
if (chunks.length === 0) {
|
|
1686
|
-
return "";
|
|
1687
|
-
}
|
|
1688
|
-
const lines = chunks.map((c) => {
|
|
1689
|
-
const date = new Date(c.createdAt * 1000).toLocaleDateString();
|
|
1690
|
-
return `- [${c.id}] (${date}): ${formatChunkSummary(c)}`;
|
|
1691
|
-
});
|
|
1692
|
-
return `
|
|
1693
|
-
## Recent Session History
|
|
1694
|
-
The following past work may be relevant:
|
|
1695
|
-
|
|
1696
|
-
${lines.join(`
|
|
1697
|
-
`)}
|
|
1698
|
-
|
|
1699
|
-
Use \`memoir_expand({ chunk_id: "ch_xxx" })\` to see full details of any chunk.`;
|
|
1700
|
-
}
|
|
1701
|
-
function formatContextInjection(memories, recentChunks) {
|
|
1675
|
+
function formatContextInjection(memories) {
|
|
1702
1676
|
const sections = [];
|
|
1703
1677
|
if (memories.length > 0) {
|
|
1704
1678
|
const memoryLines = memories.map((m) => `- [${m.type}] ${m.content}`);
|
|
@@ -1708,25 +1682,11 @@ The following memories are relevant to this conversation:
|
|
|
1708
1682
|
${memoryLines.join(`
|
|
1709
1683
|
`)}`);
|
|
1710
1684
|
}
|
|
1711
|
-
const historySection = formatSessionHistory(recentChunks);
|
|
1712
|
-
if (historySection) {
|
|
1713
|
-
sections.push(historySection);
|
|
1714
|
-
}
|
|
1715
1685
|
if (sections.length > 0) {
|
|
1716
1686
|
sections.push(`## Memoir Tools
|
|
1717
1687
|
- \`memoir\` - Add or search project memories
|
|
1718
|
-
- \`memoir_history\` -
|
|
1719
|
-
- \`memoir_expand\` - Expand a
|
|
1720
|
-
- Use \`preview_only: true\` to check size before full expansion
|
|
1721
|
-
|
|
1722
|
-
**Context Budget Tip**: Expanded chunks can be large (1000-10000+ tokens each).
|
|
1723
|
-
When exploring history or analyzing multiple chunks, consider delegating to a subagent:
|
|
1724
|
-
\`\`\`
|
|
1725
|
-
Task({
|
|
1726
|
-
prompt: "Use memoir_history and memoir_expand to find and analyze past work on [topic]",
|
|
1727
|
-
subagent_type: "explore"
|
|
1728
|
-
})
|
|
1729
|
-
\`\`\``);
|
|
1688
|
+
- \`memoir_history\` - Browse/search session history (current session by default, use all_sessions: true for past work)
|
|
1689
|
+
- \`memoir_expand\` - Expand a chunk ID to see full details`);
|
|
1730
1690
|
}
|
|
1731
1691
|
return sections.join(`
|
|
1732
1692
|
|
|
@@ -1757,13 +1717,8 @@ async function handleChatMessage(input, output) {
|
|
|
1757
1717
|
if (isFirstMessage) {
|
|
1758
1718
|
injectedSessions.add(sessionID);
|
|
1759
1719
|
const memories = memoryService2.searchRelevant(messageText);
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
const chunkService2 = getChunkService();
|
|
1763
|
-
recentChunks = chunkService2.getRecentSummaryChunks(5);
|
|
1764
|
-
} catch {}
|
|
1765
|
-
if (memories.length > 0 || recentChunks.length > 0) {
|
|
1766
|
-
const contextText = formatContextInjection(memories, recentChunks);
|
|
1720
|
+
if (memories.length > 0) {
|
|
1721
|
+
const contextText = formatContextInjection(memories);
|
|
1767
1722
|
const contextPart = createSyntheticPart(sessionID, messageID || "", contextText);
|
|
1768
1723
|
output.parts.unshift(contextPart);
|
|
1769
1724
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunkercache/opencode-memoir",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A smart memory management plugin for OpenCode that supports nested aggregation of memory, summaries, and file changes that compact in layers with upstream references for lookups.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Chris Tunbridge",
|