opcode-pg-memory 2.2.3 → 2.2.4
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/cli.js +28 -0
- package/dist/index.js +32 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4956,6 +4956,7 @@ import { join } from "node:path";
|
|
|
4956
4956
|
import { homedir } from "node:os";
|
|
4957
4957
|
var OPENCODE_CONFIG_DIR = join(homedir(), ".config", "opencode");
|
|
4958
4958
|
var OPENCODE_COMMAND_DIR = join(OPENCODE_CONFIG_DIR, "command");
|
|
4959
|
+
var OPENCODE_SKILLS_DIR = join(homedir(), ".config", "opencode", "skills");
|
|
4959
4960
|
var PLUGIN_NAME = "opcode-pg-memory";
|
|
4960
4961
|
var REPO_URL = "https://github.com/Vbs313/opcode-pg-memory";
|
|
4961
4962
|
var PG_MEMORY_INIT_COMMAND = `---
|
|
@@ -5100,6 +5101,32 @@ function createReflectCommand() {
|
|
|
5100
5101
|
console.log("Created /pg-memory-reflect command");
|
|
5101
5102
|
return true;
|
|
5102
5103
|
}
|
|
5104
|
+
var PG_MEMORY_SKILL = `# pg-memory — Long-term Memory for OpenCode
|
|
5105
|
+
|
|
5106
|
+
You have access to persistent long-term memory via the pg-memory plugin. Use it to search historical knowledge and reflect on completed work.
|
|
5107
|
+
|
|
5108
|
+
## Available Tools
|
|
5109
|
+
|
|
5110
|
+
### recall_memory — Search Historical Memories
|
|
5111
|
+
Search for relevant entities, observations, and reflections from past sessions.
|
|
5112
|
+
Call BEFORE starting any new task.
|
|
5113
|
+
- recall_memory({ query: "your task goal" })
|
|
5114
|
+
|
|
5115
|
+
### hindsight_reflect — Summarize Session
|
|
5116
|
+
Extract reusable patterns and lessons.
|
|
5117
|
+
Call AFTER completing significant work.
|
|
5118
|
+
- hindsight_reflect({ trigger_type: "manual" })
|
|
5119
|
+
|
|
5120
|
+
## Best Practice
|
|
5121
|
+
Always call recall_memory(query=<current task goal>) before working on a new problem.
|
|
5122
|
+
`;
|
|
5123
|
+
function createSkill() {
|
|
5124
|
+
mkdirSync(OPENCODE_SKILLS_DIR, { recursive: true });
|
|
5125
|
+
const skillPath = join(OPENCODE_SKILLS_DIR, "pg-memory.md");
|
|
5126
|
+
writeFileSync(skillPath, PG_MEMORY_SKILL);
|
|
5127
|
+
console.log("Created pg-memory skill");
|
|
5128
|
+
return true;
|
|
5129
|
+
}
|
|
5103
5130
|
function printHelp() {
|
|
5104
5131
|
console.log(`
|
|
5105
5132
|
pg-memory - PostgreSQL-backed long-term memory for OpenCode
|
|
@@ -5145,6 +5172,7 @@ OpenCode PG Memory installer
|
|
|
5145
5172
|
createInitCommand();
|
|
5146
5173
|
createSyncCommand();
|
|
5147
5174
|
createReflectCommand();
|
|
5175
|
+
createSkill();
|
|
5148
5176
|
console.log(`
|
|
5149
5177
|
Setup complete!`);
|
|
5150
5178
|
console.log(`
|
package/dist/index.js
CHANGED
|
@@ -20463,6 +20463,7 @@ var OpenCodePGMemory = async (ctx) => {
|
|
|
20463
20463
|
const cacheManager = plugin.getCacheManager();
|
|
20464
20464
|
const logger = createLogger("plugin");
|
|
20465
20465
|
const injectedSessions = new Set;
|
|
20466
|
+
const injectedSystemPrompt = new Set;
|
|
20466
20467
|
return {
|
|
20467
20468
|
event: async (input) => {
|
|
20468
20469
|
const { type, properties } = input.event;
|
|
@@ -20675,6 +20676,36 @@ var OpenCodePGMemory = async (ctx) => {
|
|
|
20675
20676
|
console.error("[PG Memory] Error in tool.execute.after:", error);
|
|
20676
20677
|
}
|
|
20677
20678
|
},
|
|
20679
|
+
"experimental.chat.system.transform": async (input, output) => {
|
|
20680
|
+
try {
|
|
20681
|
+
const sessionId = input.sessionID || "default";
|
|
20682
|
+
if (injectedSystemPrompt.has(sessionId))
|
|
20683
|
+
return;
|
|
20684
|
+
injectedSystemPrompt.add(sessionId);
|
|
20685
|
+
output.system = output.system || [];
|
|
20686
|
+
output.system.push(`## PG Memory Tools Available
|
|
20687
|
+
|
|
20688
|
+
You have access to long-term memory via the pg-memory plugin. These tools help you reuse knowledge across sessions:
|
|
20689
|
+
|
|
20690
|
+
### recall_memory — search historical memories
|
|
20691
|
+
Call this BEFORE starting any new task. It retrieves relevant entities, observations, and reflections from past sessions.
|
|
20692
|
+
- Example: recall_memory({ query: "database connection pool tuning" })
|
|
20693
|
+
- Best practice: always pass your current task goal as the query
|
|
20694
|
+
|
|
20695
|
+
### hindsight_reflect — reflect on session
|
|
20696
|
+
Call this AFTER completing significant work to extract reusable patterns.
|
|
20697
|
+
- Example: hindsight_reflect({ trigger_type: "manual" })
|
|
20698
|
+
- Reflexions are automatically available in future sessions
|
|
20699
|
+
|
|
20700
|
+
### When to use
|
|
20701
|
+
- Before diving into a new problem → recall_memory(query=<your goal>)
|
|
20702
|
+
- After completing a major task → hindsight_reflect()
|
|
20703
|
+
- When you need historical context about a specific topic → recall_memory(topic_segment_id=<id>)
|
|
20704
|
+
`);
|
|
20705
|
+
} catch (error) {
|
|
20706
|
+
console.error("[PG Memory] Error in system.transform:", error);
|
|
20707
|
+
}
|
|
20708
|
+
},
|
|
20678
20709
|
"experimental.session.compacting": async (input, output) => {
|
|
20679
20710
|
try {
|
|
20680
20711
|
if (ctx.client?.tui?.showToast) {
|
|
@@ -20879,6 +20910,7 @@ function formatMemoryContext(facts) {
|
|
|
20879
20910
|
const score = f2.relevanceScore ? ` (${(f2.relevanceScore * 100).toFixed(0)}%)` : "";
|
|
20880
20911
|
lines.push(`- [${typeLabel}${tierLabel}] ${f2.content.substring(0, 200)}${score}`);
|
|
20881
20912
|
}
|
|
20913
|
+
lines.push("", 'Tip: Use recall_memory(query="...") to search more specific memories, or /pg-memory-reflect to summarize this session.');
|
|
20882
20914
|
return lines.join(`
|
|
20883
20915
|
`);
|
|
20884
20916
|
}
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":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