@stackmemoryai/stackmemory 1.2.4 → 1.2.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 +17 -7
- package/dist/src/cli/claude-sm.js +33 -4
- package/dist/src/cli/codex-sm-danger.js +4 -1
- package/dist/src/cli/commands/ralph.js +3 -3
- package/dist/src/cli/commands/skills.js +108 -1
- package/dist/src/core/extensions/provider-adapter.js +5 -13
- package/dist/src/core/models/model-router.js +3 -5
- package/dist/src/hooks/daemon.js +0 -8
- package/dist/src/integrations/linear/webhook.js +0 -16
- package/dist/src/integrations/mcp/handlers/index.js +0 -8
- package/dist/src/integrations/mcp/handlers/trace-handlers.js +3 -0
- package/dist/src/integrations/mcp/server.js +0 -130
- package/dist/src/integrations/mcp/tool-definitions.js +9 -94
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +6 -6
- package/dist/src/skills/claude-skills.js +37 -1
- package/dist/src/skills/theory-skill.js +191 -0
- package/dist/src/utils/hook-installer.js +8 -0
- package/package.json +21 -8
- package/templates/claude-hooks/theory-capture.js +100 -0
- package/dist/src/hooks/graphiti-hooks.js +0 -253
- package/dist/src/integrations/graphiti/client.js +0 -115
- package/dist/src/integrations/graphiti/config.js +0 -17
- package/dist/src/integrations/graphiti/linear-graphiti-bridge.js +0 -115
- package/dist/src/integrations/graphiti/types.js +0 -4
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
import { logger } from "../core/monitoring/logger.js";
|
|
6
|
-
import { GraphitiClient } from "../integrations/graphiti/client.js";
|
|
7
|
-
import { DEFAULT_GRAPHITI_CONFIG } from "../integrations/graphiti/config.js";
|
|
8
|
-
class GraphitiHooks {
|
|
9
|
-
client;
|
|
10
|
-
config;
|
|
11
|
-
constructor(config = {}) {
|
|
12
|
-
this.config = { ...DEFAULT_GRAPHITI_CONFIG, ...config };
|
|
13
|
-
this.client = new GraphitiClient(this.config);
|
|
14
|
-
}
|
|
15
|
-
register(emitter) {
|
|
16
|
-
if (!this.config.enabled) {
|
|
17
|
-
logger.debug("Graphiti hooks disabled");
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
emitter.registerHandler("session_start", this.onSessionStart.bind(this));
|
|
21
|
-
emitter.registerHandler("file_change", this.onFileChange.bind(this));
|
|
22
|
-
emitter.registerHandler("session_end", this.onSessionEnd.bind(this));
|
|
23
|
-
emitter.registerHandler("input_idle", this.onInputIdle.bind(this));
|
|
24
|
-
emitter.registerHandler("context_switch", this.onContextSwitch.bind(this));
|
|
25
|
-
emitter.registerHandler("prompt_submit", this.onPromptSubmit.bind(this));
|
|
26
|
-
emitter.registerHandler("tool_use", this.onToolUse.bind(this));
|
|
27
|
-
emitter.registerHandler(
|
|
28
|
-
"suggestion_ready",
|
|
29
|
-
this.onSuggestionReady.bind(this)
|
|
30
|
-
);
|
|
31
|
-
emitter.registerHandler("agent_start", this.onAgentStart.bind(this));
|
|
32
|
-
emitter.registerHandler("agent_complete", this.onAgentComplete.bind(this));
|
|
33
|
-
emitter.registerHandler("agent_error", this.onAgentError.bind(this));
|
|
34
|
-
logger.info("Graphiti hooks registered", {
|
|
35
|
-
endpoint: this.config.endpoint,
|
|
36
|
-
backend: this.config.backend,
|
|
37
|
-
maxHops: this.config.maxHops
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async onSessionStart(event) {
|
|
41
|
-
try {
|
|
42
|
-
const status = await this.client.getStatus();
|
|
43
|
-
if (!status.connected) {
|
|
44
|
-
logger.warn("Graphiti not available - operating in degraded mode");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const episode = {
|
|
48
|
-
type: "session_start",
|
|
49
|
-
content: event.data || {},
|
|
50
|
-
timestamp: Date.now(),
|
|
51
|
-
source: "stackmemory",
|
|
52
|
-
metadata: { severity: "info" }
|
|
53
|
-
};
|
|
54
|
-
await this.client.upsertEpisode(episode);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
logger.debug("Graphiti session_start failed", {
|
|
57
|
-
error: error instanceof Error ? error.message : String(error)
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async onFileChange(event) {
|
|
62
|
-
const fileEvent = event;
|
|
63
|
-
try {
|
|
64
|
-
const episode = {
|
|
65
|
-
type: "file_change",
|
|
66
|
-
content: {
|
|
67
|
-
path: fileEvent.data.path,
|
|
68
|
-
changeType: fileEvent.data.changeType,
|
|
69
|
-
size: typeof fileEvent.data.content === "string" ? fileEvent.data.content.length : void 0
|
|
70
|
-
},
|
|
71
|
-
timestamp: Date.now(),
|
|
72
|
-
source: "stackmemory"
|
|
73
|
-
};
|
|
74
|
-
await this.client.upsertEpisode(episode);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
logger.debug("Graphiti file_change episode failed", {
|
|
77
|
-
error: error instanceof Error ? error.message : String(error)
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async onSessionEnd(event) {
|
|
82
|
-
try {
|
|
83
|
-
const episode = {
|
|
84
|
-
type: "session_end",
|
|
85
|
-
content: event.data || {},
|
|
86
|
-
timestamp: Date.now(),
|
|
87
|
-
source: "stackmemory"
|
|
88
|
-
};
|
|
89
|
-
await this.client.upsertEpisode(episode);
|
|
90
|
-
} catch (error) {
|
|
91
|
-
logger.debug("Graphiti session_end failed", {
|
|
92
|
-
error: error instanceof Error ? error.message : String(error)
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
async onInputIdle(event) {
|
|
97
|
-
const idle = event;
|
|
98
|
-
try {
|
|
99
|
-
const episode = {
|
|
100
|
-
type: "input_idle",
|
|
101
|
-
content: {
|
|
102
|
-
idleDuration: idle.data.idleDuration,
|
|
103
|
-
lastInput: idle.data.lastInput
|
|
104
|
-
},
|
|
105
|
-
timestamp: Date.now(),
|
|
106
|
-
source: "stackmemory"
|
|
107
|
-
};
|
|
108
|
-
await this.client.upsertEpisode(episode);
|
|
109
|
-
} catch (error) {
|
|
110
|
-
logger.debug("Graphiti input_idle episode failed", {
|
|
111
|
-
error: error instanceof Error ? error.message : String(error)
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async onContextSwitch(event) {
|
|
116
|
-
const ctx = event;
|
|
117
|
-
try {
|
|
118
|
-
const episode = {
|
|
119
|
-
type: "context_switch",
|
|
120
|
-
content: {
|
|
121
|
-
fromBranch: ctx.data.fromBranch,
|
|
122
|
-
toBranch: ctx.data.toBranch,
|
|
123
|
-
fromProject: ctx.data.fromProject,
|
|
124
|
-
toProject: ctx.data.toProject
|
|
125
|
-
},
|
|
126
|
-
timestamp: Date.now(),
|
|
127
|
-
source: "stackmemory"
|
|
128
|
-
};
|
|
129
|
-
await this.client.upsertEpisode(episode);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
logger.debug("Graphiti context_switch episode failed", {
|
|
132
|
-
error: error instanceof Error ? error.message : String(error)
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async onPromptSubmit(event) {
|
|
137
|
-
try {
|
|
138
|
-
const episode = {
|
|
139
|
-
type: "prompt_submit",
|
|
140
|
-
content: event.data || {},
|
|
141
|
-
timestamp: Date.now(),
|
|
142
|
-
source: "stackmemory"
|
|
143
|
-
};
|
|
144
|
-
await this.client.upsertEpisode(episode);
|
|
145
|
-
} catch (error) {
|
|
146
|
-
logger.debug("Graphiti prompt_submit episode failed", {
|
|
147
|
-
error: error instanceof Error ? error.message : String(error)
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
async onToolUse(event) {
|
|
152
|
-
try {
|
|
153
|
-
const episode = {
|
|
154
|
-
type: "tool_use",
|
|
155
|
-
content: event.data || {},
|
|
156
|
-
timestamp: Date.now(),
|
|
157
|
-
source: "stackmemory"
|
|
158
|
-
};
|
|
159
|
-
await this.client.upsertEpisode(episode);
|
|
160
|
-
} catch (error) {
|
|
161
|
-
logger.debug("Graphiti tool_use episode failed", {
|
|
162
|
-
error: error instanceof Error ? error.message : String(error)
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
async onSuggestionReady(event) {
|
|
167
|
-
const suggestion = event;
|
|
168
|
-
try {
|
|
169
|
-
const episode = {
|
|
170
|
-
type: "suggestion_ready",
|
|
171
|
-
content: {
|
|
172
|
-
source: suggestion.data.source,
|
|
173
|
-
confidence: suggestion.data.confidence,
|
|
174
|
-
preview: suggestion.data.preview
|
|
175
|
-
},
|
|
176
|
-
timestamp: Date.now(),
|
|
177
|
-
source: "stackmemory"
|
|
178
|
-
};
|
|
179
|
-
await this.client.upsertEpisode(episode);
|
|
180
|
-
} catch (error) {
|
|
181
|
-
logger.debug("Graphiti suggestion_ready episode failed", {
|
|
182
|
-
error: error instanceof Error ? error.message : String(error)
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async onAgentStart(event) {
|
|
187
|
-
const e = event;
|
|
188
|
-
try {
|
|
189
|
-
const episode = {
|
|
190
|
-
type: "agent_start",
|
|
191
|
-
content: { agentType: e.data.agentType, task: e.data.task },
|
|
192
|
-
timestamp: Date.now(),
|
|
193
|
-
source: "stackmemory"
|
|
194
|
-
};
|
|
195
|
-
await this.client.upsertEpisode(episode);
|
|
196
|
-
} catch (error) {
|
|
197
|
-
logger.debug("Graphiti agent_start episode failed", {
|
|
198
|
-
error: error instanceof Error ? error.message : String(error)
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
async onAgentComplete(event) {
|
|
203
|
-
const e = event;
|
|
204
|
-
try {
|
|
205
|
-
const episode = {
|
|
206
|
-
type: "agent_complete",
|
|
207
|
-
content: { ...e.data },
|
|
208
|
-
timestamp: Date.now(),
|
|
209
|
-
source: "stackmemory"
|
|
210
|
-
};
|
|
211
|
-
await this.client.upsertEpisode(episode);
|
|
212
|
-
} catch (error) {
|
|
213
|
-
logger.debug("Graphiti agent_complete episode failed", {
|
|
214
|
-
error: error instanceof Error ? error.message : String(error)
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
async onAgentError(event) {
|
|
219
|
-
const e = event;
|
|
220
|
-
try {
|
|
221
|
-
const episode = {
|
|
222
|
-
type: "agent_error",
|
|
223
|
-
content: { agentType: e.data.agentType, error: e.data.error },
|
|
224
|
-
timestamp: Date.now(),
|
|
225
|
-
source: "stackmemory"
|
|
226
|
-
};
|
|
227
|
-
await this.client.upsertEpisode(episode);
|
|
228
|
-
} catch (error) {
|
|
229
|
-
logger.debug("Graphiti agent_error episode failed", {
|
|
230
|
-
error: error instanceof Error ? error.message : String(error)
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// Expose a simple temporal query helper for future MCP tooling
|
|
235
|
-
async buildTemporalContext(query = {}) {
|
|
236
|
-
const now = Date.now();
|
|
237
|
-
const q = {
|
|
238
|
-
query: query.query || void 0,
|
|
239
|
-
entityTypes: query.entityTypes || void 0,
|
|
240
|
-
relationTypes: query.relationTypes || void 0,
|
|
241
|
-
validFrom: query.validFrom ?? now - 1e3 * 60 * 60 * 24 * 30,
|
|
242
|
-
// 30d default
|
|
243
|
-
validTo: query.validTo ?? now,
|
|
244
|
-
maxHops: query.maxHops ?? this.config.maxHops,
|
|
245
|
-
k: query.k ?? 20,
|
|
246
|
-
rerank: query.rerank ?? true
|
|
247
|
-
};
|
|
248
|
-
return this.client.queryTemporal(q);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
export {
|
|
252
|
-
GraphitiHooks
|
|
253
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
import { DEFAULT_GRAPHITI_CONFIG } from "./config.js";
|
|
6
|
-
class GraphitiClientError extends Error {
|
|
7
|
-
constructor(message, code, statusCode) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.code = code;
|
|
10
|
-
this.statusCode = statusCode;
|
|
11
|
-
this.name = "GraphitiClientError";
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
class GraphitiClient {
|
|
15
|
-
endpoint;
|
|
16
|
-
timeout;
|
|
17
|
-
maxRetries;
|
|
18
|
-
namespace;
|
|
19
|
-
constructor(config = {}) {
|
|
20
|
-
const merged = { ...DEFAULT_GRAPHITI_CONFIG, ...config };
|
|
21
|
-
this.endpoint = merged.endpoint.replace(/\/$/, "");
|
|
22
|
-
this.timeout = merged.timeoutMs;
|
|
23
|
-
this.maxRetries = merged.maxRetries;
|
|
24
|
-
this.namespace = merged.projectNamespace || "default";
|
|
25
|
-
}
|
|
26
|
-
async request(path, options = {}) {
|
|
27
|
-
const controller = new AbortController();
|
|
28
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
29
|
-
let lastError;
|
|
30
|
-
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
31
|
-
try {
|
|
32
|
-
const res = await fetch(`${this.endpoint}${path}`, {
|
|
33
|
-
...options,
|
|
34
|
-
signal: controller.signal,
|
|
35
|
-
headers: {
|
|
36
|
-
"Content-Type": "application/json",
|
|
37
|
-
...options.headers || {}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
clearTimeout(timeoutId);
|
|
41
|
-
if (!res.ok) {
|
|
42
|
-
const msg = await res.text().catch(() => res.statusText);
|
|
43
|
-
throw new GraphitiClientError(
|
|
44
|
-
`Request failed: ${msg}`,
|
|
45
|
-
"HTTP_ERROR",
|
|
46
|
-
res.status
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return await res.json();
|
|
50
|
-
} catch (err) {
|
|
51
|
-
lastError = err;
|
|
52
|
-
if (err instanceof GraphitiClientError) throw err;
|
|
53
|
-
if (err.name === "AbortError") {
|
|
54
|
-
throw new GraphitiClientError("Request timeout", "TIMEOUT");
|
|
55
|
-
}
|
|
56
|
-
if (attempt < this.maxRetries) {
|
|
57
|
-
await new Promise((r) => setTimeout(r, Math.pow(2, attempt) * 100));
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
clearTimeout(timeoutId);
|
|
63
|
-
throw new GraphitiClientError(
|
|
64
|
-
lastError?.message || "Network error",
|
|
65
|
-
"NETWORK_ERROR"
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
// Episodes
|
|
69
|
-
async upsertEpisode(episode) {
|
|
70
|
-
const payload = { ...episode, namespace: this.namespace };
|
|
71
|
-
const res = await this.request(`/episodes`, {
|
|
72
|
-
method: "POST",
|
|
73
|
-
body: JSON.stringify(payload)
|
|
74
|
-
});
|
|
75
|
-
return res;
|
|
76
|
-
}
|
|
77
|
-
// Entities
|
|
78
|
-
async upsertEntities(entities) {
|
|
79
|
-
const payload = { entities, namespace: this.namespace };
|
|
80
|
-
return this.request(`/entities:batchUpsert`, {
|
|
81
|
-
method: "POST",
|
|
82
|
-
body: JSON.stringify(payload)
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
// Relations
|
|
86
|
-
async upsertRelations(edges) {
|
|
87
|
-
const payload = { edges, namespace: this.namespace };
|
|
88
|
-
return this.request(`/relations:batchUpsert`, {
|
|
89
|
-
method: "POST",
|
|
90
|
-
body: JSON.stringify(payload)
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
// Temporal query + hybrid retrieval
|
|
94
|
-
async queryTemporal(query) {
|
|
95
|
-
const payload = { ...query, namespace: this.namespace };
|
|
96
|
-
return this.request(`/query/temporal`, {
|
|
97
|
-
method: "POST",
|
|
98
|
-
body: JSON.stringify(payload)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
// Health/status
|
|
102
|
-
async getStatus() {
|
|
103
|
-
try {
|
|
104
|
-
return await this.request(
|
|
105
|
-
`/status?namespace=${encodeURIComponent(this.namespace)}`
|
|
106
|
-
);
|
|
107
|
-
} catch {
|
|
108
|
-
return { connected: false };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
export {
|
|
113
|
-
GraphitiClient,
|
|
114
|
-
GraphitiClientError
|
|
115
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
const DEFAULT_GRAPHITI_CONFIG = {
|
|
6
|
-
enabled: !!process.env.GRAPHITI_ENDPOINT,
|
|
7
|
-
endpoint: process.env.GRAPHITI_ENDPOINT?.replace(/\/$/, "") || "http://localhost:8080",
|
|
8
|
-
backend: process.env.GRAPHITI_BACKEND || "neo4j",
|
|
9
|
-
projectNamespace: process.env.STACKMEMORY_PROJECT_ID || "default",
|
|
10
|
-
timeoutMs: 5e3,
|
|
11
|
-
maxRetries: 2,
|
|
12
|
-
maxTokens: 1600,
|
|
13
|
-
maxHops: 2
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
DEFAULT_GRAPHITI_CONFIG
|
|
17
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
import { logger } from "../../core/monitoring/logger.js";
|
|
6
|
-
import { GraphitiClient } from "./client.js";
|
|
7
|
-
class LinearGraphitiBridge {
|
|
8
|
-
client;
|
|
9
|
-
constructor(config = {}) {
|
|
10
|
-
this.client = new GraphitiClient(config);
|
|
11
|
-
}
|
|
12
|
-
async processWebhook(payload) {
|
|
13
|
-
const { action, data } = payload;
|
|
14
|
-
const now = Date.now();
|
|
15
|
-
try {
|
|
16
|
-
const episode = {
|
|
17
|
-
type: `linear_issue_${action}`,
|
|
18
|
-
content: {
|
|
19
|
-
identifier: data.identifier,
|
|
20
|
-
title: data.title,
|
|
21
|
-
action,
|
|
22
|
-
state: data.state?.name,
|
|
23
|
-
priority: data.priority,
|
|
24
|
-
assignee: data.assignee?.name
|
|
25
|
-
},
|
|
26
|
-
timestamp: now,
|
|
27
|
-
source: "linear"
|
|
28
|
-
};
|
|
29
|
-
await this.client.upsertEpisode(episode);
|
|
30
|
-
if (action === "remove") return;
|
|
31
|
-
const entities = [
|
|
32
|
-
{
|
|
33
|
-
type: "Issue",
|
|
34
|
-
name: data.identifier,
|
|
35
|
-
summary: data.title,
|
|
36
|
-
properties: {
|
|
37
|
-
linearId: data.id,
|
|
38
|
-
state: data.state?.name,
|
|
39
|
-
priority: data.priority
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
if (data.assignee) {
|
|
44
|
-
entities.push({
|
|
45
|
-
type: "Person",
|
|
46
|
-
name: data.assignee.name,
|
|
47
|
-
properties: {
|
|
48
|
-
linearId: data.assignee.id,
|
|
49
|
-
email: data.assignee.email
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (data.team) {
|
|
54
|
-
entities.push({
|
|
55
|
-
type: "Team",
|
|
56
|
-
name: data.team.name,
|
|
57
|
-
properties: { linearId: data.team.id, key: data.team.key }
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
if (data.labels?.length) {
|
|
61
|
-
for (const label of data.labels) {
|
|
62
|
-
entities.push({
|
|
63
|
-
type: "Label",
|
|
64
|
-
name: label.name,
|
|
65
|
-
properties: { linearId: label.id, color: label.color }
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const entityResult = await this.client.upsertEntities(entities);
|
|
70
|
-
const issueId = entityResult.ids[0];
|
|
71
|
-
const relations = [];
|
|
72
|
-
let idx = 1;
|
|
73
|
-
if (data.assignee) {
|
|
74
|
-
relations.push({
|
|
75
|
-
fromId: issueId,
|
|
76
|
-
toId: entityResult.ids[idx],
|
|
77
|
-
type: "ASSIGNED_TO",
|
|
78
|
-
validFrom: now
|
|
79
|
-
});
|
|
80
|
-
idx++;
|
|
81
|
-
}
|
|
82
|
-
if (data.team) {
|
|
83
|
-
relations.push({
|
|
84
|
-
fromId: issueId,
|
|
85
|
-
toId: entityResult.ids[idx],
|
|
86
|
-
type: "BELONGS_TO",
|
|
87
|
-
validFrom: now
|
|
88
|
-
});
|
|
89
|
-
idx++;
|
|
90
|
-
}
|
|
91
|
-
if (data.labels?.length) {
|
|
92
|
-
for (let i = 0; i < data.labels.length; i++) {
|
|
93
|
-
relations.push({
|
|
94
|
-
fromId: issueId,
|
|
95
|
-
toId: entityResult.ids[idx + i],
|
|
96
|
-
type: "HAS_LABEL",
|
|
97
|
-
validFrom: now
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (relations.length > 0) {
|
|
102
|
-
await this.client.upsertRelations(relations);
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
logger.debug("Linear-Graphiti bridge error", {
|
|
106
|
-
action,
|
|
107
|
-
identifier: data.identifier,
|
|
108
|
-
error: error instanceof Error ? error.message : String(error)
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
export {
|
|
114
|
-
LinearGraphitiBridge
|
|
115
|
-
};
|