opencode-graphiti 0.1.5 → 0.1.7
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 +35 -18
- package/esm/src/config.d.ts.map +1 -1
- package/esm/src/config.js +4 -2
- package/esm/src/handlers/chat.d.ts +2 -1
- package/esm/src/handlers/chat.d.ts.map +1 -1
- package/esm/src/handlers/chat.js +100 -49
- package/esm/src/handlers/compacting.d.ts +1 -0
- package/esm/src/handlers/compacting.d.ts.map +1 -1
- package/esm/src/handlers/compacting.js +2 -1
- package/esm/src/handlers/event.d.ts +2 -2
- package/esm/src/handlers/event.d.ts.map +1 -1
- package/esm/src/handlers/event.js +52 -1
- package/esm/src/handlers/system.d.ts +11 -0
- package/esm/src/handlers/system.d.ts.map +1 -0
- package/esm/src/handlers/system.js +18 -0
- package/esm/src/index.d.ts.map +1 -1
- package/esm/src/index.js +8 -2
- package/esm/src/services/client.d.ts +8 -1
- package/esm/src/services/client.d.ts.map +1 -1
- package/esm/src/services/client.js +23 -0
- package/esm/src/services/compaction.d.ts +10 -0
- package/esm/src/services/compaction.d.ts.map +1 -1
- package/esm/src/services/compaction.js +106 -18
- package/esm/src/services/context-limit.d.ts +2 -8
- package/esm/src/services/context-limit.d.ts.map +1 -1
- package/esm/src/services/context-limit.js +3 -1
- package/esm/src/services/context.d.ts +27 -2
- package/esm/src/services/context.d.ts.map +1 -1
- package/esm/src/services/context.js +107 -13
- package/esm/src/services/logger.d.ts.map +1 -1
- package/esm/src/services/logger.js +1 -2
- package/esm/src/session.d.ts +6 -25
- package/esm/src/session.d.ts.map +1 -1
- package/esm/src/session.js +4 -7
- package/esm/src/types/index.d.ts +8 -2
- package/esm/src/types/index.d.ts.map +1 -1
- package/package.json +2 -3
- package/script/src/config.d.ts.map +1 -1
- package/script/src/config.js +4 -2
- package/script/src/handlers/chat.d.ts +2 -1
- package/script/src/handlers/chat.d.ts.map +1 -1
- package/script/src/handlers/chat.js +99 -48
- package/script/src/handlers/compacting.d.ts +1 -0
- package/script/src/handlers/compacting.d.ts.map +1 -1
- package/script/src/handlers/compacting.js +2 -1
- package/script/src/handlers/event.d.ts +2 -2
- package/script/src/handlers/event.d.ts.map +1 -1
- package/script/src/handlers/event.js +52 -1
- package/script/src/handlers/system.d.ts +11 -0
- package/script/src/handlers/system.d.ts.map +1 -0
- package/script/src/handlers/system.js +21 -0
- package/script/src/index.d.ts.map +1 -1
- package/script/src/index.js +8 -2
- package/script/src/services/client.d.ts +8 -1
- package/script/src/services/client.d.ts.map +1 -1
- package/script/src/services/client.js +23 -0
- package/script/src/services/compaction.d.ts +10 -0
- package/script/src/services/compaction.d.ts.map +1 -1
- package/script/src/services/compaction.js +108 -17
- package/script/src/services/context-limit.d.ts +2 -8
- package/script/src/services/context-limit.d.ts.map +1 -1
- package/script/src/services/context-limit.js +3 -1
- package/script/src/services/context.d.ts +27 -2
- package/script/src/services/context.d.ts.map +1 -1
- package/script/src/services/context.js +118 -14
- package/script/src/services/logger.d.ts.map +1 -1
- package/script/src/services/logger.js +1 -35
- package/script/src/session.d.ts +6 -25
- package/script/src/session.d.ts.map +1 -1
- package/script/src/session.js +4 -7
- package/script/src/types/index.d.ts +8 -2
- package/script/src/types/index.d.ts.map +1 -1
- package/esm/_dnt.shims.d.ts +0 -6
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -61
- package/script/_dnt.shims.d.ts +0 -6
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -65
package/README.md
CHANGED
|
@@ -22,12 +22,16 @@ reminded of recent project context — regardless of what survived the summary.
|
|
|
22
22
|
|
|
23
23
|
This plugin connects to a Graphiti MCP server and:
|
|
24
24
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
25
|
+
- Searches Graphiti for relevant facts and entities on each user message
|
|
26
|
+
- Injects memories into the system prompt via
|
|
27
|
+
`experimental.chat.system.transform`, keeping session titles clean
|
|
28
|
+
- Detects context drift using Jaccard similarity and re-injects when the
|
|
29
|
+
conversation topic shifts
|
|
27
30
|
- Buffers user and assistant messages, flushing them to Graphiti on idle or
|
|
28
31
|
before compaction
|
|
29
32
|
- Preserves key facts during context compaction
|
|
30
33
|
- Saves compaction summaries as episodes so knowledge survives across boundaries
|
|
34
|
+
- Annotates stale facts and filters expired ones automatically
|
|
31
35
|
- Scopes memories per project (and per user) using directory-based group IDs
|
|
32
36
|
|
|
33
37
|
## Prerequisites
|
|
@@ -104,8 +108,12 @@ Create a config file at `~/.config/opencode/graphiti.jsonc`:
|
|
|
104
108
|
// Prefix for project group IDs (e.g. "opencode-my-project")
|
|
105
109
|
"groupIdPrefix": "opencode",
|
|
106
110
|
|
|
107
|
-
//
|
|
108
|
-
|
|
111
|
+
// Jaccard similarity threshold (0–1) below which memory is re-injected
|
|
112
|
+
// Lower values mean the topic must drift further before re-injection
|
|
113
|
+
"driftThreshold": 0.5,
|
|
114
|
+
|
|
115
|
+
// Number of days after which facts are annotated as stale
|
|
116
|
+
"factStaleDays": 30
|
|
109
117
|
}
|
|
110
118
|
```
|
|
111
119
|
|
|
@@ -114,27 +122,36 @@ values.
|
|
|
114
122
|
|
|
115
123
|
## How It Works
|
|
116
124
|
|
|
117
|
-
### Memory
|
|
125
|
+
### Memory Search and Caching (`chat.message`)
|
|
118
126
|
|
|
119
|
-
On
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
On each user message the plugin searches Graphiti for facts and entities
|
|
128
|
+
relevant to the message content. Results are split into project and user scopes
|
|
129
|
+
(70% / 30% budget), deduplicated, filtered for validity, annotated with
|
|
130
|
+
staleness if older than `factStaleDays`, and formatted as Markdown. The
|
|
131
|
+
formatted context is cached on the session state for the system prompt hook to
|
|
132
|
+
pick up.
|
|
123
133
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
field is unavailable, the plugin falls back to prepending synthetic parts.
|
|
134
|
+
On the very first message of a session, the plugin also loads the most recent
|
|
135
|
+
session snapshot episode to prime the conversation with prior context.
|
|
127
136
|
|
|
128
137
|
The injection budget is calculated dynamically: 5% of the model's context limit
|
|
129
138
|
(resolved from the provider list) multiplied by 4 characters per token.
|
|
130
139
|
|
|
131
|
-
###
|
|
140
|
+
### System Prompt Injection (`experimental.chat.system.transform`)
|
|
141
|
+
|
|
142
|
+
A separate hook reads the cached memory context and appends it to the system
|
|
143
|
+
prompt array. This approach keeps memory out of user message parts, which
|
|
144
|
+
prevents it from influencing session titles or being treated as user
|
|
145
|
+
instructions. The cache is cleared after injection so stale context is not
|
|
146
|
+
re-injected on subsequent LLM calls within the same turn.
|
|
147
|
+
|
|
148
|
+
### Drift-Based Re-injection (`chat.message`)
|
|
132
149
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
project
|
|
150
|
+
After the first injection, the plugin monitors for context drift on every user
|
|
151
|
+
message. It searches Graphiti for the current message and compares the returned
|
|
152
|
+
fact UUIDs against the previously injected set using Jaccard similarity. When
|
|
153
|
+
similarity drops below `driftThreshold` (default 0.5), the memory cache is
|
|
154
|
+
refreshed with project-scoped results only (no user scope).
|
|
138
155
|
|
|
139
156
|
### Message Buffering (`event`)
|
|
140
157
|
|
package/esm/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgBvD;;GAEG;AACH,wBAAgB,UAAU,IAAI,cAAc,CAc3C"}
|
package/esm/src/config.js
CHANGED
|
@@ -3,12 +3,14 @@ import * as z from "zod/mini";
|
|
|
3
3
|
const DEFAULT_CONFIG = {
|
|
4
4
|
endpoint: "http://localhost:8000/mcp",
|
|
5
5
|
groupIdPrefix: "opencode",
|
|
6
|
-
|
|
6
|
+
driftThreshold: 0.5,
|
|
7
|
+
factStaleDays: 30,
|
|
7
8
|
};
|
|
8
9
|
const GraphitiConfigSchema = z.object({
|
|
9
10
|
endpoint: z.string(),
|
|
10
11
|
groupIdPrefix: z.string(),
|
|
11
|
-
|
|
12
|
+
driftThreshold: z.number(),
|
|
13
|
+
factStaleDays: z.number(),
|
|
12
14
|
});
|
|
13
15
|
/**
|
|
14
16
|
* Load Graphiti configuration from JSONC files with defaults applied.
|
|
@@ -7,7 +7,8 @@ type ChatMessageOutput = Parameters<ChatMessageHook>[1];
|
|
|
7
7
|
/** Dependencies for the chat message handler. */
|
|
8
8
|
export interface ChatHandlerDeps {
|
|
9
9
|
sessionManager: SessionManager;
|
|
10
|
-
|
|
10
|
+
driftThreshold: number;
|
|
11
|
+
factStaleDays: number;
|
|
11
12
|
client: GraphitiClient;
|
|
12
13
|
}
|
|
13
14
|
/** Creates the `chat.message` hook handler. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/src/handlers/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/src/handlers/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAO5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,KAAK,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAC1D,KAAK,gBAAgB,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK,iBAAiB,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAExD,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,+CAA+C;AAC/C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,IAiJvC,eAAe,gBAAgB,EAAE,QAAQ,iBAAiB,mBA6EzE"}
|
package/esm/src/handlers/chat.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { calculateInjectionBudget } from "../services/context-limit.js";
|
|
2
|
-
import { formatMemoryContext } from "../services/context.js";
|
|
2
|
+
import { deduplicateContext, formatMemoryContext, } from "../services/context.js";
|
|
3
3
|
import { logger } from "../services/logger.js";
|
|
4
4
|
import { extractTextFromParts } from "../utils.js";
|
|
5
5
|
/** Creates the `chat.message` hook handler. */
|
|
6
6
|
export function createChatHandler(deps) {
|
|
7
|
-
const { sessionManager,
|
|
8
|
-
const
|
|
9
|
-
if (part.type !== "text")
|
|
10
|
-
return true;
|
|
11
|
-
if (part.id?.startsWith("graphiti-memory-"))
|
|
12
|
-
return false;
|
|
13
|
-
if (part.id?.startsWith("graphiti-refresh-"))
|
|
14
|
-
return false;
|
|
15
|
-
return true;
|
|
16
|
-
});
|
|
17
|
-
const injectMemoryContext = async (state, messageText, output, prefix, useUserScope, characterBudget, shouldReinject) => {
|
|
7
|
+
const { sessionManager, driftThreshold, factStaleDays, client } = deps;
|
|
8
|
+
const searchAndCacheMemoryContext = async (state, messageText, useUserScope, characterBudget, seedFactUuids) => {
|
|
18
9
|
const userGroupId = state.userGroupId;
|
|
19
10
|
const projectFactsPromise = client.searchFacts({
|
|
20
11
|
query: messageText,
|
|
@@ -47,45 +38,85 @@ export function createChatHandler(deps) {
|
|
|
47
38
|
userFactsPromise,
|
|
48
39
|
userNodesPromise,
|
|
49
40
|
]);
|
|
50
|
-
const projectContext =
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
const projectContext = deduplicateContext({
|
|
42
|
+
facts: projectFacts,
|
|
43
|
+
nodes: projectNodes,
|
|
44
|
+
});
|
|
45
|
+
const userContext = deduplicateContext({
|
|
46
|
+
facts: userFacts,
|
|
47
|
+
nodes: userNodes,
|
|
48
|
+
});
|
|
49
|
+
const projectContextString = formatMemoryContext(projectContext.facts, projectContext.nodes, { factStaleDays });
|
|
50
|
+
const userContextString = formatMemoryContext(userContext.facts, userContext.nodes, { factStaleDays });
|
|
51
|
+
if (!projectContextString && !userContextString)
|
|
53
52
|
return;
|
|
53
|
+
let snapshotPrimer = "";
|
|
54
|
+
if (useUserScope && characterBudget > 0) {
|
|
55
|
+
try {
|
|
56
|
+
const episodes = await client.getEpisodes({
|
|
57
|
+
groupId: state.groupId,
|
|
58
|
+
lastN: 10,
|
|
59
|
+
});
|
|
60
|
+
const snapshot = episodes
|
|
61
|
+
.filter((episode) => {
|
|
62
|
+
const description = episode.sourceDescription ??
|
|
63
|
+
episode.source_description ?? "";
|
|
64
|
+
return description === "session-snapshot";
|
|
65
|
+
})
|
|
66
|
+
.sort((a, b) => {
|
|
67
|
+
const aTime = a.created_at ? Date.parse(a.created_at) : 0;
|
|
68
|
+
const bTime = b.created_at ? Date.parse(b.created_at) : 0;
|
|
69
|
+
return bTime - aTime;
|
|
70
|
+
})[0];
|
|
71
|
+
if (snapshot?.content) {
|
|
72
|
+
const snapshotBudget = Math.min(characterBudget, 1200);
|
|
73
|
+
snapshotPrimer = [
|
|
74
|
+
"## Session Snapshot",
|
|
75
|
+
"> Most recent session snapshot; use to restore active strategy and open questions.",
|
|
76
|
+
"",
|
|
77
|
+
snapshot.content.slice(0, snapshotBudget),
|
|
78
|
+
].join("\n");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
logger.error("Failed to load session snapshot", { err });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
54
85
|
const projectBudget = useUserScope
|
|
55
86
|
? Math.floor(characterBudget * 0.7)
|
|
56
87
|
: characterBudget;
|
|
57
88
|
const userBudget = characterBudget - projectBudget;
|
|
58
|
-
const truncatedProject =
|
|
59
|
-
const truncatedUser = useUserScope
|
|
60
|
-
|
|
89
|
+
const truncatedProject = projectContextString.slice(0, projectBudget);
|
|
90
|
+
const truncatedUser = useUserScope
|
|
91
|
+
? userContextString.slice(0, userBudget)
|
|
92
|
+
: "";
|
|
93
|
+
const memoryContext = [snapshotPrimer, truncatedProject, truncatedUser]
|
|
61
94
|
.filter((section) => section.trim().length > 0)
|
|
62
95
|
.join("\n\n")
|
|
63
96
|
.slice(0, characterBudget);
|
|
64
97
|
if (!memoryContext)
|
|
65
98
|
return;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
messageID: output.message.id,
|
|
85
|
-
synthetic: true,
|
|
86
|
-
});
|
|
99
|
+
const allFactUuids = [
|
|
100
|
+
...projectContext.facts.map((fact) => fact.uuid),
|
|
101
|
+
...userContext.facts.map((fact) => fact.uuid),
|
|
102
|
+
];
|
|
103
|
+
const factUuids = seedFactUuids ?? Array.from(new Set(allFactUuids));
|
|
104
|
+
state.cachedMemoryContext = memoryContext;
|
|
105
|
+
logger.info(`Cached ${projectFacts.length + userFacts.length} facts and ${projectNodes.length + userNodes.length} nodes for system prompt injection`);
|
|
106
|
+
state.lastInjectionFactUuids = factUuids;
|
|
107
|
+
};
|
|
108
|
+
const computeJaccardSimilarity = (left, right) => {
|
|
109
|
+
if (left.length === 0 && right.length === 0)
|
|
110
|
+
return 1;
|
|
111
|
+
const leftSet = new Set(left);
|
|
112
|
+
const rightSet = new Set(right);
|
|
113
|
+
let intersection = 0;
|
|
114
|
+
for (const value of leftSet) {
|
|
115
|
+
if (rightSet.has(value))
|
|
116
|
+
intersection += 1;
|
|
87
117
|
}
|
|
88
|
-
|
|
118
|
+
const union = leftSet.size + rightSet.size - intersection;
|
|
119
|
+
return union === 0 ? 1 : intersection / union;
|
|
89
120
|
};
|
|
90
121
|
return async ({ sessionID }, output) => {
|
|
91
122
|
if (await sessionManager.isSubagentSession(sessionID)) {
|
|
@@ -112,19 +143,39 @@ export function createChatHandler(deps) {
|
|
|
112
143
|
messageLength: messageText.length,
|
|
113
144
|
});
|
|
114
145
|
const shouldInjectOnFirst = !state.injectedMemories;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
146
|
+
let shouldReinject = false;
|
|
147
|
+
let currentFactUuids = null;
|
|
148
|
+
if (!shouldInjectOnFirst) {
|
|
149
|
+
try {
|
|
150
|
+
const driftFacts = await client.searchFacts({
|
|
151
|
+
query: messageText,
|
|
152
|
+
groupIds: [state.groupId],
|
|
153
|
+
maxFacts: 20,
|
|
154
|
+
});
|
|
155
|
+
currentFactUuids = driftFacts.map((fact) => fact.uuid);
|
|
156
|
+
const similarity = computeJaccardSimilarity(currentFactUuids, state.lastInjectionFactUuids);
|
|
157
|
+
shouldReinject = similarity < driftThreshold;
|
|
158
|
+
if (!shouldReinject) {
|
|
159
|
+
logger.debug("Skipping reinjection; similarity above threshold", {
|
|
160
|
+
sessionID,
|
|
161
|
+
similarity,
|
|
162
|
+
});
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
logger.error("Failed to check topic drift, skipping reinjection", {
|
|
168
|
+
sessionID,
|
|
169
|
+
err,
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
121
174
|
try {
|
|
122
|
-
const prefix = shouldReinject ? "graphiti-refresh-" : "graphiti-memory-";
|
|
123
175
|
const useUserScope = shouldInjectOnFirst;
|
|
124
176
|
const characterBudget = calculateInjectionBudget(state.contextLimit);
|
|
125
|
-
await
|
|
177
|
+
await searchAndCacheMemoryContext(state, messageText, useUserScope, characterBudget, currentFactUuids);
|
|
126
178
|
state.injectedMemories = true;
|
|
127
|
-
state.lastInjectionMessageCount = state.messageCount;
|
|
128
179
|
}
|
|
129
180
|
catch (err) {
|
|
130
181
|
logger.error("Failed to inject memories:", err);
|
|
@@ -9,6 +9,7 @@ export interface CompactingHandlerDeps {
|
|
|
9
9
|
sessionManager: SessionManager;
|
|
10
10
|
client: GraphitiClient;
|
|
11
11
|
defaultGroupId: string;
|
|
12
|
+
factStaleDays: number;
|
|
12
13
|
}
|
|
13
14
|
/** Creates the `experimental.session.compacting` hook handler. */
|
|
14
15
|
export declare function createCompactingHandler(deps: CompactingHandlerDeps): ({ sessionID }: CompactingInput, output: CompactingOutput) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compacting.d.ts","sourceRoot":"","sources":["../../../src/src/handlers/compacting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,KAAK,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAC;AAC5E,KAAK,eAAe,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,gBAAgB,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"compacting.d.ts","sourceRoot":"","sources":["../../../src/src/handlers/compacting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,KAAK,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAC;AAC5E,KAAK,eAAe,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,gBAAgB,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,kEAAkE;AAClE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,IAI/D,eAAe,eAAe,EAC9B,QAAQ,gBAAgB,mBA0B3B"}
|
|
@@ -3,7 +3,7 @@ import { calculateInjectionBudget } from "../services/context-limit.js";
|
|
|
3
3
|
import { logger } from "../services/logger.js";
|
|
4
4
|
/** Creates the `experimental.session.compacting` hook handler. */
|
|
5
5
|
export function createCompactingHandler(deps) {
|
|
6
|
-
const { sessionManager, client, defaultGroupId } = deps;
|
|
6
|
+
const { sessionManager, client, defaultGroupId, factStaleDays } = deps;
|
|
7
7
|
return async ({ sessionID }, output) => {
|
|
8
8
|
const state = sessionManager.getState(sessionID);
|
|
9
9
|
if (!state?.isMain) {
|
|
@@ -20,6 +20,7 @@ export function createCompactingHandler(deps) {
|
|
|
20
20
|
user: state.userGroupId,
|
|
21
21
|
},
|
|
22
22
|
contextStrings: output.context,
|
|
23
|
+
factStaleDays,
|
|
23
24
|
});
|
|
24
25
|
if (additionalContext.length > 0) {
|
|
25
26
|
output.context.push(...additionalContext);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Hooks } from "@opencode-ai/plugin";
|
|
2
|
+
import type { OpencodeClient } from "@opencode-ai/sdk";
|
|
2
3
|
import type { GraphitiClient } from "../services/client.js";
|
|
3
|
-
import type { ProviderListClient } from "../services/context-limit.js";
|
|
4
4
|
import type { SessionManager } from "../session.js";
|
|
5
5
|
type EventHook = NonNullable<Hooks["event"]>;
|
|
6
6
|
type EventInput = Parameters<EventHook>[0];
|
|
@@ -9,7 +9,7 @@ export interface EventHandlerDeps {
|
|
|
9
9
|
sessionManager: SessionManager;
|
|
10
10
|
client: GraphitiClient;
|
|
11
11
|
defaultGroupId: string;
|
|
12
|
-
sdkClient:
|
|
12
|
+
sdkClient: OpencodeClient;
|
|
13
13
|
directory: string;
|
|
14
14
|
groupIdPrefix: string;
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/src/handlers/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/src/handlers/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,KAAK,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7C,KAAK,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3C,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wCAAwC;AACxC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,IAkDzC,WAAW,UAAU,mBAkLpC"}
|
|
@@ -6,6 +6,41 @@ import { isTextPart, makeUserGroupId } from "../utils.js";
|
|
|
6
6
|
export function createEventHandler(deps) {
|
|
7
7
|
const { sessionManager, client, defaultGroupId, sdkClient, directory, groupIdPrefix, } = deps;
|
|
8
8
|
const defaultUserGroupId = makeUserGroupId(groupIdPrefix);
|
|
9
|
+
const buildSessionSnapshot = (sessionId, messages) => {
|
|
10
|
+
const recentMessages = messages.slice(-12);
|
|
11
|
+
const recentAssistant = [...recentMessages]
|
|
12
|
+
.reverse()
|
|
13
|
+
.find((message) => message.startsWith("Assistant:"))
|
|
14
|
+
?.replace(/^Assistant:\s*/, "")
|
|
15
|
+
.trim();
|
|
16
|
+
const recentUser = [...recentMessages]
|
|
17
|
+
.reverse()
|
|
18
|
+
.find((message) => message.startsWith("User:"))
|
|
19
|
+
?.replace(/^User:\s*/, "")
|
|
20
|
+
.trim();
|
|
21
|
+
const questionRegex = /[^\n\r?]{3,200}\?/g;
|
|
22
|
+
const questions = recentMessages
|
|
23
|
+
.flatMap((message) => {
|
|
24
|
+
const text = message.replace(/^(User|Assistant):\s*/, "");
|
|
25
|
+
return text.match(questionRegex) ?? [];
|
|
26
|
+
})
|
|
27
|
+
.map((question) => question.trim());
|
|
28
|
+
const uniqueQuestions = Array.from(new Set(questions)).slice(0, 6);
|
|
29
|
+
const lines = [];
|
|
30
|
+
lines.push(`Session ${sessionId} working snapshot`);
|
|
31
|
+
if (recentUser)
|
|
32
|
+
lines.push(`Recent user focus: ${recentUser}`);
|
|
33
|
+
if (recentAssistant) {
|
|
34
|
+
lines.push(`Recent assistant focus: ${recentAssistant}`);
|
|
35
|
+
}
|
|
36
|
+
if (uniqueQuestions.length > 0) {
|
|
37
|
+
lines.push("Open questions:");
|
|
38
|
+
for (const question of uniqueQuestions) {
|
|
39
|
+
lines.push(`- ${question}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return lines.join("\n");
|
|
43
|
+
};
|
|
9
44
|
return async ({ event }) => {
|
|
10
45
|
try {
|
|
11
46
|
if (event.type === "session.created") {
|
|
@@ -24,7 +59,7 @@ export function createEventHandler(deps) {
|
|
|
24
59
|
groupId: defaultGroupId,
|
|
25
60
|
userGroupId: defaultUserGroupId,
|
|
26
61
|
injectedMemories: false,
|
|
27
|
-
|
|
62
|
+
lastInjectionFactUuids: [],
|
|
28
63
|
messageCount: 0,
|
|
29
64
|
pendingMessages: [],
|
|
30
65
|
contextLimit: 200_000,
|
|
@@ -71,6 +106,22 @@ export function createEventHandler(deps) {
|
|
|
71
106
|
logger.debug("Ignoring non-main idle session:", sessionId);
|
|
72
107
|
return;
|
|
73
108
|
}
|
|
109
|
+
try {
|
|
110
|
+
const snapshotContent = buildSessionSnapshot(sessionId, state.pendingMessages);
|
|
111
|
+
if (snapshotContent.trim()) {
|
|
112
|
+
await client.addEpisode({
|
|
113
|
+
name: `Snapshot: ${sessionId}`,
|
|
114
|
+
episodeBody: snapshotContent,
|
|
115
|
+
groupId: state.groupId,
|
|
116
|
+
source: "text",
|
|
117
|
+
sourceDescription: "session-snapshot",
|
|
118
|
+
});
|
|
119
|
+
logger.info("Saved session snapshot", { sessionId });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
logger.error("Failed to save session snapshot", { sessionId, err });
|
|
124
|
+
}
|
|
74
125
|
await sessionManager.flushPendingMessages(sessionId, "Buffered messages from OpenCode session", 50);
|
|
75
126
|
return;
|
|
76
127
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hooks } from "@opencode-ai/plugin";
|
|
2
|
+
import type { SessionManager } from "../session.js";
|
|
3
|
+
type SystemTransformHook = NonNullable<Hooks["experimental.chat.system.transform"]>;
|
|
4
|
+
type SystemTransformInput = Parameters<SystemTransformHook>[0];
|
|
5
|
+
type SystemTransformOutput = Parameters<SystemTransformHook>[1];
|
|
6
|
+
export interface SystemHandlerDeps {
|
|
7
|
+
sessionManager: SessionManager;
|
|
8
|
+
}
|
|
9
|
+
export declare function createSystemHandler(deps: SystemHandlerDeps): ({ sessionID }: SystemTransformInput, output: SystemTransformOutput) => Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../src/src/handlers/system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,KAAK,mBAAmB,GAAG,WAAW,CACpC,KAAK,CAAC,oCAAoC,CAAC,CAC5C,CAAC;AACF,KAAK,oBAAoB,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,KAAK,qBAAqB,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhE,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,IAMvD,eAAe,oBAAoB,EACnC,QAAQ,qBAAqB,mBAYhC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { logger } from "../services/logger.js";
|
|
2
|
+
export function createSystemHandler(deps) {
|
|
3
|
+
const { sessionManager } = deps;
|
|
4
|
+
// Assumes chat.message hook completes before system.transform fires for the same turn.
|
|
5
|
+
// deno-lint-ignore require-await
|
|
6
|
+
return async ({ sessionID }, output) => {
|
|
7
|
+
if (!sessionID)
|
|
8
|
+
return;
|
|
9
|
+
const state = sessionManager.getState(sessionID);
|
|
10
|
+
if (!state?.isMain)
|
|
11
|
+
return;
|
|
12
|
+
if (!state.cachedMemoryContext)
|
|
13
|
+
return;
|
|
14
|
+
output.system.push(state.cachedMemoryContext);
|
|
15
|
+
state.cachedMemoryContext = undefined;
|
|
16
|
+
logger.info("Injected memory context into system prompt");
|
|
17
|
+
};
|
|
18
|
+
}
|
package/esm/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAW/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAW/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAuDtB,CAAC"}
|
package/esm/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { loadConfig } from "./config.js";
|
|
|
2
2
|
import { createChatHandler } from "./handlers/chat.js";
|
|
3
3
|
import { createCompactingHandler } from "./handlers/compacting.js";
|
|
4
4
|
import { createEventHandler } from "./handlers/event.js";
|
|
5
|
+
import { createSystemHandler } from "./handlers/system.js";
|
|
5
6
|
import { GraphitiClient } from "./services/client.js";
|
|
6
7
|
import { logger } from "./services/logger.js";
|
|
7
8
|
import { SessionManager } from "./session.js";
|
|
@@ -27,19 +28,24 @@ export const graphiti = async (input) => {
|
|
|
27
28
|
sessionManager,
|
|
28
29
|
client,
|
|
29
30
|
defaultGroupId,
|
|
30
|
-
sdkClient
|
|
31
|
+
sdkClient,
|
|
31
32
|
directory: input.directory,
|
|
32
33
|
groupIdPrefix: config.groupIdPrefix,
|
|
33
34
|
}),
|
|
34
35
|
"chat.message": createChatHandler({
|
|
35
36
|
sessionManager,
|
|
36
|
-
|
|
37
|
+
driftThreshold: config.driftThreshold,
|
|
38
|
+
factStaleDays: config.factStaleDays,
|
|
37
39
|
client,
|
|
38
40
|
}),
|
|
39
41
|
"experimental.session.compacting": createCompactingHandler({
|
|
40
42
|
sessionManager,
|
|
41
43
|
client,
|
|
42
44
|
defaultGroupId,
|
|
45
|
+
factStaleDays: config.factStaleDays,
|
|
46
|
+
}),
|
|
47
|
+
"experimental.chat.system.transform": createSystemHandler({
|
|
48
|
+
sessionManager,
|
|
43
49
|
}),
|
|
44
50
|
};
|
|
45
51
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraphitiFact, GraphitiNode } from "../types/index.js";
|
|
1
|
+
import type { GraphitiEpisode, GraphitiFact, GraphitiNode } from "../types/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Graphiti MCP client wrapper for connecting, querying,
|
|
4
4
|
* and persisting episodes with basic reconnection handling.
|
|
@@ -57,6 +57,13 @@ export declare class GraphitiClient {
|
|
|
57
57
|
groupIds?: string[];
|
|
58
58
|
maxNodes?: number;
|
|
59
59
|
}): Promise<GraphitiNode[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieve recent episodes for a group.
|
|
62
|
+
*/
|
|
63
|
+
getEpisodes(params: {
|
|
64
|
+
groupId?: string;
|
|
65
|
+
lastN?: number;
|
|
66
|
+
}): Promise<GraphitiEpisode[]>;
|
|
60
67
|
/**
|
|
61
68
|
* Check whether the Graphiti MCP server is reachable.
|
|
62
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/src/services/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAC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ACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAsB3B;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAqB9B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;CAQpC"}
|
|
@@ -215,6 +215,29 @@ export class GraphitiClient {
|
|
|
215
215
|
return [];
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Retrieve recent episodes for a group.
|
|
220
|
+
*/
|
|
221
|
+
async getEpisodes(params) {
|
|
222
|
+
try {
|
|
223
|
+
const result = await this.callTool("get_episodes", {
|
|
224
|
+
group_id: params.groupId,
|
|
225
|
+
last_n: params.lastN,
|
|
226
|
+
});
|
|
227
|
+
if (Array.isArray(result))
|
|
228
|
+
return result;
|
|
229
|
+
if (result &&
|
|
230
|
+
typeof result === "object" &&
|
|
231
|
+
Array.isArray(result.episodes)) {
|
|
232
|
+
return result.episodes;
|
|
233
|
+
}
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
logger.error("getEpisodes error:", err);
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
218
241
|
/**
|
|
219
242
|
* Check whether the Graphiti MCP server is reachable.
|
|
220
243
|
*/
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { GraphitiFact, GraphitiNode } from "../types/index.js";
|
|
2
|
+
export declare const classifyFacts: (facts: GraphitiFact[], now: Date) => {
|
|
3
|
+
decisions: GraphitiFact[];
|
|
4
|
+
active: GraphitiFact[];
|
|
5
|
+
background: GraphitiFact[];
|
|
6
|
+
};
|
|
7
|
+
export declare const takeFactsWithinBudget: (facts: GraphitiFact[], budget: number, formatOptions: {
|
|
8
|
+
factStaleDays: number;
|
|
9
|
+
now: Date;
|
|
10
|
+
}) => GraphitiFact[];
|
|
2
11
|
/**
|
|
3
12
|
* Persist a compaction summary episode when enabled.
|
|
4
13
|
*/
|
|
@@ -38,5 +47,6 @@ export declare function getCompactionContext(params: {
|
|
|
38
47
|
user?: string;
|
|
39
48
|
};
|
|
40
49
|
contextStrings: string[];
|
|
50
|
+
factStaleDays?: number;
|
|
41
51
|
}): Promise<string[]>;
|
|
42
52
|
//# sourceMappingURL=compaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../../src/src/services/compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../../src/src/services/compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA0BpE,eAAO,MAAM,aAAa,GACxB,OAAO,YAAY,EAAE,EACrB,KAAK,IAAI,KACR;IACD,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,UAAU,EAAE,YAAY,EAAE,CAAC;CA4B5B,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,OAAO,YAAY,EAAE,EACrB,QAAQ,MAAM,EACd,eAAe;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,KAClD,YAAY,EAoBd,CAAC;AAEF;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE;IAC7C,MAAM,EAAE;QACN,UAAU,EAAE,CAAC,IAAI,EAAE;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,WAAW,EAAE,MAAM,CAAC;YACpB,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,M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