@stackmemoryai/stackmemory 1.2.4 → 1.2.6
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 +10 -6
- package/dist/src/cli/claude-sm.js +33 -4
- package/dist/src/cli/codex-sm-danger.js +4 -1
- package/dist/src/cli/commands/skills.js +108 -1
- 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/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 +2 -2
- 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,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
|
-
};
|