@stackmemoryai/stackmemory 1.2.7 → 1.2.8
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 +3 -3
- package/dist/src/cli/commands/digest.js +73 -0
- package/dist/src/cli/index.js +2 -0
- package/dist/src/core/digest/chronological-digest.js +143 -0
- package/dist/src/core/digest/index.js +1 -0
- package/dist/src/integrations/mcp/server.js +473 -247
- package/dist/src/integrations/mcp/tool-definitions.js +567 -50
- package/package.json +2 -2
- package/templates/claude-hooks/session-rescue.sh +3 -0
- /package/templates/claude-hooks/{auto-background-hook.js → archive/auto-background-hook.js} +0 -0
- /package/templates/claude-hooks/{hook-config.json → archive/hook-config.json} +0 -0
- /package/templates/claude-hooks/{hooks.json → archive/hooks.json} +0 -0
- /package/templates/claude-hooks/{on-compact-detected → archive/on-compact-detected} +0 -0
- /package/templates/claude-hooks/{on-exit → archive/on-exit} +0 -0
- /package/templates/claude-hooks/{post-edit-sweep.js → archive/post-edit-sweep.js} +0 -0
- /package/templates/claude-hooks/{pre-tool-use → archive/pre-tool-use} +0 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Lossless, project-scoped memory for AI coding tools. **[Website](https://stackme
|
|
|
14
14
|
StackMemory is a **production-ready memory runtime** for AI coding tools that preserves full project context across sessions:
|
|
15
15
|
|
|
16
16
|
- **Zero-config setup** — `stackmemory init` just works
|
|
17
|
-
- **
|
|
17
|
+
- **55 MCP tools** for Claude Code integration (context, tasks, Linear, traces, discovery, cord, team)
|
|
18
18
|
- **FTS5 full-text search** with BM25 scoring and hybrid retrieval
|
|
19
19
|
- **Full Linear integration** with bidirectional sync and OAuth/API key support
|
|
20
20
|
- **Context persistence** that survives `/clear` operations
|
|
@@ -57,7 +57,7 @@ Tools forget decisions and constraints between sessions. StackMemory makes conte
|
|
|
57
57
|
|
|
58
58
|
## Features
|
|
59
59
|
|
|
60
|
-
- **MCP tools** for Claude Code:
|
|
60
|
+
- **MCP tools** for Claude Code: 56 tools across context, tasks, Linear, traces, planning, discovery, cord, team, and more
|
|
61
61
|
- **FTS5 search**: full-text search with BM25 scoring, hybrid retrieval, and smart thresholds
|
|
62
62
|
- **Skills**: `/spec` (iterative spec generation), `/linear-run` (task execution via RLM)
|
|
63
63
|
- **Hooks**: automatic context save, task tracking, Linear sync, PROMPT_PLAN updates, cord tracing
|
|
@@ -356,7 +356,7 @@ See [docs/cli.md](https://github.com/stackmemoryai/stackmemory/blob/main/docs/cl
|
|
|
356
356
|
## Documentation
|
|
357
357
|
|
|
358
358
|
- [Getting Started](./docs/GETTING_STARTED.md) — Quick start guide (5 minutes)
|
|
359
|
-
- [MCP Tools Reference](https://stackmemoryai.github.io/stackmemory/tools.html) — All
|
|
359
|
+
- [MCP Tools Reference](https://stackmemoryai.github.io/stackmemory/tools.html) — All 55 MCP tools
|
|
360
360
|
- [CLI Reference](./docs/cli.md) — Full command reference
|
|
361
361
|
- [Setup Guide](./docs/SETUP.md) — Advanced setup options
|
|
362
362
|
- [Development Guide](./docs/DEVELOPMENT.md) — Contributing and development
|
|
@@ -0,0 +1,73 @@
|
|
|
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 { Command } from "commander";
|
|
6
|
+
import Database from "better-sqlite3";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
import { existsSync, writeFileSync, mkdirSync } from "fs";
|
|
9
|
+
import { execSync } from "child_process";
|
|
10
|
+
import {
|
|
11
|
+
generateChronologicalDigest
|
|
12
|
+
} from "../../core/digest/chronological-digest.js";
|
|
13
|
+
function findProjectRoot() {
|
|
14
|
+
let dir = process.cwd();
|
|
15
|
+
while (dir !== "/") {
|
|
16
|
+
if (existsSync(join(dir, ".git"))) return dir;
|
|
17
|
+
dir = join(dir, "..");
|
|
18
|
+
}
|
|
19
|
+
return process.cwd();
|
|
20
|
+
}
|
|
21
|
+
function getProjectId(projectRoot) {
|
|
22
|
+
let identifier;
|
|
23
|
+
try {
|
|
24
|
+
identifier = execSync("git config --get remote.origin.url", {
|
|
25
|
+
cwd: projectRoot,
|
|
26
|
+
stdio: "pipe",
|
|
27
|
+
timeout: 5e3
|
|
28
|
+
}).toString().trim();
|
|
29
|
+
} catch {
|
|
30
|
+
identifier = projectRoot;
|
|
31
|
+
}
|
|
32
|
+
const cleaned = identifier.replace(/\.git$/, "").replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
|
|
33
|
+
return cleaned.substring(cleaned.length - 50) || "unknown";
|
|
34
|
+
}
|
|
35
|
+
function createDigestCommands() {
|
|
36
|
+
const digest = new Command("digest").description("Generate chronological activity digest").argument("<period>", "Time period: today, yesterday, or week").option("-o, --output <path>", "Custom output path").action((period, options) => {
|
|
37
|
+
const validPeriods = ["today", "yesterday", "week"];
|
|
38
|
+
if (!validPeriods.includes(period)) {
|
|
39
|
+
console.error(
|
|
40
|
+
`Invalid period "${period}". Use: ${validPeriods.join(", ")}`
|
|
41
|
+
);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const projectRoot = findProjectRoot();
|
|
45
|
+
const dbPath = join(projectRoot, ".stackmemory", "context.db");
|
|
46
|
+
if (!existsSync(dbPath)) {
|
|
47
|
+
console.error(
|
|
48
|
+
"No StackMemory database found. Run stackmemory in a project first."
|
|
49
|
+
);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
const db = new Database(dbPath, { readonly: true });
|
|
53
|
+
const projectId = getProjectId(projectRoot);
|
|
54
|
+
try {
|
|
55
|
+
const markdown = generateChronologicalDigest(
|
|
56
|
+
db,
|
|
57
|
+
period,
|
|
58
|
+
projectId
|
|
59
|
+
);
|
|
60
|
+
const smDir = join(projectRoot, ".stackmemory");
|
|
61
|
+
if (!existsSync(smDir)) mkdirSync(smDir, { recursive: true });
|
|
62
|
+
const outputPath = options.output || join(smDir, `${period}.md`);
|
|
63
|
+
writeFileSync(outputPath, markdown);
|
|
64
|
+
console.log(`Digest written to ${outputPath}`);
|
|
65
|
+
} finally {
|
|
66
|
+
db.close();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return digest;
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
createDigestCommands
|
|
73
|
+
};
|
package/dist/src/cli/index.js
CHANGED
|
@@ -54,6 +54,7 @@ import { createPingCommand } from "./commands/ping.js";
|
|
|
54
54
|
import { createAuditCommand } from "./commands/audit.js";
|
|
55
55
|
import { createStatsCommand } from "./commands/stats.js";
|
|
56
56
|
import { createBenchCommand } from "./commands/bench.js";
|
|
57
|
+
import { createDigestCommands } from "./commands/digest.js";
|
|
57
58
|
import chalk from "chalk";
|
|
58
59
|
import * as fs from "fs";
|
|
59
60
|
import * as path from "path";
|
|
@@ -501,6 +502,7 @@ program.addCommand(createModelCommand());
|
|
|
501
502
|
program.addCommand(createAuditCommand());
|
|
502
503
|
program.addCommand(createStatsCommand());
|
|
503
504
|
program.addCommand(createBenchCommand());
|
|
505
|
+
program.addCommand(createDigestCommands());
|
|
504
506
|
registerSetupCommands(program);
|
|
505
507
|
program.command("mm-spike").description(
|
|
506
508
|
"Run multi-agent planning/implementation spike (planner/implementer/critic)"
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
function getTimeRange(period) {
|
|
6
|
+
const now = /* @__PURE__ */ new Date();
|
|
7
|
+
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
8
|
+
switch (period) {
|
|
9
|
+
case "today": {
|
|
10
|
+
return {
|
|
11
|
+
start: Math.floor(todayStart.getTime() / 1e3),
|
|
12
|
+
end: Math.floor(now.getTime() / 1e3),
|
|
13
|
+
label: `Today \u2014 ${todayStart.toISOString().slice(0, 10)}`
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
case "yesterday": {
|
|
17
|
+
const yesterdayStart = new Date(todayStart);
|
|
18
|
+
yesterdayStart.setDate(yesterdayStart.getDate() - 1);
|
|
19
|
+
return {
|
|
20
|
+
start: Math.floor(yesterdayStart.getTime() / 1e3),
|
|
21
|
+
end: Math.floor(todayStart.getTime() / 1e3),
|
|
22
|
+
label: `Yesterday \u2014 ${yesterdayStart.toISOString().slice(0, 10)}`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
case "week": {
|
|
26
|
+
const weekStart = new Date(todayStart);
|
|
27
|
+
weekStart.setDate(weekStart.getDate() - 7);
|
|
28
|
+
return {
|
|
29
|
+
start: Math.floor(weekStart.getTime() / 1e3),
|
|
30
|
+
end: Math.floor(now.getTime() / 1e3),
|
|
31
|
+
label: `Week \u2014 ${weekStart.toISOString().slice(0, 10)} to ${todayStart.toISOString().slice(0, 10)}`
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function formatDate(epoch) {
|
|
37
|
+
return new Date(epoch * 1e3).toISOString().slice(0, 10);
|
|
38
|
+
}
|
|
39
|
+
function generateChronologicalDigest(db, period, projectId) {
|
|
40
|
+
const { start, end, label } = getTimeRange(period);
|
|
41
|
+
let frames = db.prepare(
|
|
42
|
+
`SELECT frame_id, name, type, state, created_at, closed_at, inputs, outputs
|
|
43
|
+
FROM frames
|
|
44
|
+
WHERE project_id = ? AND created_at >= ? AND created_at < ?
|
|
45
|
+
ORDER BY created_at ASC`
|
|
46
|
+
).all(projectId, start, end);
|
|
47
|
+
if (frames.length === 0 && projectId !== "default") {
|
|
48
|
+
frames = db.prepare(
|
|
49
|
+
`SELECT frame_id, name, type, state, created_at, closed_at, inputs, outputs
|
|
50
|
+
FROM frames
|
|
51
|
+
WHERE project_id = 'default' AND created_at >= ? AND created_at < ?
|
|
52
|
+
ORDER BY created_at ASC`
|
|
53
|
+
).all(start, end);
|
|
54
|
+
}
|
|
55
|
+
if (frames.length === 0) {
|
|
56
|
+
return `# ${label}
|
|
57
|
+
|
|
58
|
+
No activity recorded.
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
const frameIds = frames.map((f) => f.frame_id);
|
|
62
|
+
const placeholders = frameIds.map(() => "?").join(",");
|
|
63
|
+
const anchors = db.prepare(
|
|
64
|
+
`SELECT anchor_id, frame_id, type, text, priority, created_at
|
|
65
|
+
FROM anchors
|
|
66
|
+
WHERE frame_id IN (${placeholders})
|
|
67
|
+
ORDER BY priority DESC, created_at ASC`
|
|
68
|
+
).all(...frameIds);
|
|
69
|
+
const events = db.prepare(
|
|
70
|
+
`SELECT event_id, frame_id, event_type, payload, ts
|
|
71
|
+
FROM events
|
|
72
|
+
WHERE frame_id IN (${placeholders}) AND event_type IN ('tool_call', 'decision')
|
|
73
|
+
ORDER BY ts ASC`
|
|
74
|
+
).all(...frameIds);
|
|
75
|
+
const anchorsByFrame = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const a of anchors) {
|
|
77
|
+
const list = anchorsByFrame.get(a.frame_id) || [];
|
|
78
|
+
list.push(a);
|
|
79
|
+
anchorsByFrame.set(a.frame_id, list);
|
|
80
|
+
}
|
|
81
|
+
const eventsByFrame = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const e of events) {
|
|
83
|
+
const list = eventsByFrame.get(e.frame_id) || [];
|
|
84
|
+
list.push(e);
|
|
85
|
+
eventsByFrame.set(e.frame_id, list);
|
|
86
|
+
}
|
|
87
|
+
const framesByDate = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const f of frames) {
|
|
89
|
+
const date = formatDate(f.created_at);
|
|
90
|
+
const list = framesByDate.get(date) || [];
|
|
91
|
+
list.push(f);
|
|
92
|
+
framesByDate.set(date, list);
|
|
93
|
+
}
|
|
94
|
+
const lines = [`# ${label}
|
|
95
|
+
`];
|
|
96
|
+
const renderFrame = (f) => {
|
|
97
|
+
lines.push(`## ${f.name} (${f.type}, ${f.state})`);
|
|
98
|
+
const frameAnchors = anchorsByFrame.get(f.frame_id) || [];
|
|
99
|
+
const frameEvents = eventsByFrame.get(f.frame_id) || [];
|
|
100
|
+
for (const a of frameAnchors.slice(0, 8)) {
|
|
101
|
+
lines.push(`- ${a.type}: ${a.text}`);
|
|
102
|
+
}
|
|
103
|
+
const files = /* @__PURE__ */ new Set();
|
|
104
|
+
for (const e of frameEvents) {
|
|
105
|
+
try {
|
|
106
|
+
const payload = JSON.parse(e.payload);
|
|
107
|
+
if (payload.arguments?.file_path)
|
|
108
|
+
files.add(payload.arguments.file_path);
|
|
109
|
+
if (payload.arguments?.path) files.add(payload.arguments.path);
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (files.size > 0) {
|
|
114
|
+
lines.push(`- ${files.size} files touched`);
|
|
115
|
+
}
|
|
116
|
+
lines.push("");
|
|
117
|
+
};
|
|
118
|
+
if (period === "week") {
|
|
119
|
+
for (const [date, dateFrames] of framesByDate) {
|
|
120
|
+
lines.push(`### ${date}
|
|
121
|
+
`);
|
|
122
|
+
for (const f of dateFrames) {
|
|
123
|
+
renderFrame(f);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
for (const f of frames) {
|
|
128
|
+
renderFrame(f);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const completed = frames.filter((f) => f.state === "completed").length;
|
|
132
|
+
const active = frames.filter((f) => f.state === "active").length;
|
|
133
|
+
lines.push("---");
|
|
134
|
+
lines.push(
|
|
135
|
+
`*${frames.length} frames total: ${completed} completed, ${active} active*`
|
|
136
|
+
);
|
|
137
|
+
lines.push(`*Generated: ${(/* @__PURE__ */ new Date()).toISOString()}*
|
|
138
|
+
`);
|
|
139
|
+
return lines.join("\n");
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
generateChronologicalDigest
|
|
143
|
+
};
|