@stackmemoryai/stackmemory 1.10.4 → 1.12.0

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.
Files changed (95) hide show
  1. package/README.md +104 -23
  2. package/dist/src/cli/claude-sm.js +266 -84
  3. package/dist/src/cli/codex-sm.js +185 -33
  4. package/dist/src/cli/commands/bench.js +209 -2
  5. package/dist/src/cli/commands/cache.js +126 -0
  6. package/dist/src/cli/commands/daemon.js +41 -0
  7. package/dist/src/cli/commands/handoff.js +40 -9
  8. package/dist/src/cli/commands/onboard.js +70 -3
  9. package/dist/src/cli/commands/optimize.js +117 -0
  10. package/dist/src/cli/commands/orchestrate.js +230 -5
  11. package/dist/src/cli/commands/orchestrator.js +312 -24
  12. package/dist/src/cli/commands/pack.js +322 -0
  13. package/dist/src/cli/commands/search.js +40 -1
  14. package/dist/src/cli/commands/setup.js +177 -7
  15. package/dist/src/cli/commands/skills.js +10 -1
  16. package/dist/src/cli/commands/state.js +265 -0
  17. package/dist/src/cli/commands/wiki.js +33 -0
  18. package/dist/src/cli/gemini-sm.js +19 -29
  19. package/dist/src/cli/index.js +90 -29
  20. package/dist/src/cli/opencode-sm.js +38 -21
  21. package/dist/src/cli/utils/determinism-watcher.js +66 -0
  22. package/dist/src/cli/utils/real-cli-bin.js +44 -0
  23. package/dist/src/core/cache/content-cache.js +238 -0
  24. package/dist/src/core/cache/index.js +11 -0
  25. package/dist/src/core/cache/token-estimator.js +16 -0
  26. package/dist/src/core/context/frame-database.js +38 -30
  27. package/dist/src/core/cross-search/cross-project-search.js +269 -0
  28. package/dist/src/core/{merge → cross-search}/index.js +6 -4
  29. package/dist/src/core/database/sqlite-adapter.js +0 -83
  30. package/dist/src/core/extensions/provider-adapter.js +5 -0
  31. package/dist/src/core/models/model-router.js +22 -2
  32. package/dist/src/core/monitoring/logger.js +2 -1
  33. package/dist/src/core/optimization/trace-optimizer.js +413 -0
  34. package/dist/src/core/provenance/confidence-scorer.js +128 -0
  35. package/dist/src/core/provenance/index.js +40 -0
  36. package/dist/src/core/provenance/provenance-store.js +194 -0
  37. package/dist/src/core/provenance/types.js +82 -0
  38. package/dist/src/core/session/project-handoff.js +64 -0
  39. package/dist/src/core/session/session-manager.js +28 -0
  40. package/dist/src/core/shared-state/canonical-store.js +564 -0
  41. package/dist/src/core/skill-packs/index.js +18 -0
  42. package/dist/src/core/skill-packs/parser.js +42 -0
  43. package/dist/src/core/skill-packs/registry.js +224 -0
  44. package/dist/src/core/skill-packs/types.js +66 -0
  45. package/dist/src/core/trace/trace-event-store.js +282 -0
  46. package/dist/src/core/trace/trace-event.js +4 -0
  47. package/dist/src/core/wiki/wiki-compiler.js +219 -0
  48. package/dist/src/daemon/daemon-config.js +7 -0
  49. package/dist/src/daemon/services/github-service.js +126 -0
  50. package/dist/src/daemon/unified-daemon.js +30 -0
  51. package/dist/src/features/sweep/pty-wrapper.js +13 -5
  52. package/dist/src/hooks/schemas.js +2 -0
  53. package/dist/src/integrations/claude-code/subagent-client.js +89 -0
  54. package/dist/src/integrations/github/pr-state.js +158 -0
  55. package/dist/src/integrations/linear/client.js +4 -1
  56. package/dist/src/integrations/mcp/handlers/cross-search-handlers.js +188 -0
  57. package/dist/src/integrations/mcp/handlers/index.js +40 -59
  58. package/dist/src/integrations/mcp/server.js +425 -311
  59. package/dist/src/integrations/mcp/tool-alias-registry.js +370 -0
  60. package/dist/src/integrations/mcp/tool-definitions.js +98 -229
  61. package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +3 -40
  62. package/dist/src/integrations/ralph/learning/pattern-learner.js +1 -20
  63. package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +0 -2
  64. package/dist/src/mcp/stackmemory-mcp-server.js +315 -0
  65. package/dist/src/orchestrators/multimodal/determinism.js +243 -0
  66. package/dist/src/orchestrators/multimodal/harness.js +147 -77
  67. package/dist/src/orchestrators/multimodal/providers.js +44 -3
  68. package/dist/src/utils/hook-installer.js +8 -8
  69. package/package.json +10 -1
  70. package/packs/coding/python-fastapi/instructions.md +60 -0
  71. package/packs/coding/python-fastapi/pack.yaml +28 -0
  72. package/packs/coding/typescript-react/instructions.md +47 -0
  73. package/packs/coding/typescript-react/pack.yaml +28 -0
  74. package/packs/core/commands/capture.md +32 -0
  75. package/packs/core/commands/learn.md +73 -0
  76. package/packs/core/commands/next.md +36 -0
  77. package/packs/core/commands/restart.md +58 -0
  78. package/packs/core/commands/restore.md +29 -0
  79. package/packs/core/commands/start.md +57 -0
  80. package/packs/core/commands/stop.md +65 -0
  81. package/packs/core/commands/summary.md +40 -0
  82. package/packs/core/manifest.json +24 -0
  83. package/packs/ops/decision-recovery/instructions.md +65 -0
  84. package/packs/ops/decision-recovery/pack.yaml +89 -0
  85. package/templates/claude-hooks/doc-ingest.js +76 -0
  86. package/dist/src/cli/commands/team.js +0 -168
  87. package/dist/src/core/context/shared-context-layer.js +0 -620
  88. package/dist/src/core/context/stack-merge-resolver.js +0 -748
  89. package/dist/src/core/merge/conflict-detector.js +0 -430
  90. package/dist/src/core/merge/resolution-engine.js +0 -557
  91. package/dist/src/core/merge/stack-diff.js +0 -531
  92. package/dist/src/core/merge/unified-merge-resolver.js +0 -302
  93. package/dist/src/integrations/mcp/handlers/cord-handlers.js +0 -397
  94. package/dist/src/integrations/mcp/handlers/team-handlers.js +0 -211
  95. /package/dist/src/core/{merge → cache}/types.js +0 -0
@@ -1,168 +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 { Command } from "commander";
6
- import Database from "better-sqlite3";
7
- import { join } from "path";
8
- import { existsSync } from "fs";
9
- import { v4 as uuidv4 } from "uuid";
10
- import { FrameManager } from "../../core/context/index.js";
11
- const VALID_TYPES = [
12
- "FACT",
13
- "DECISION",
14
- "CONSTRAINT",
15
- "INTERFACE_CONTRACT",
16
- "TODO",
17
- "RISK"
18
- ];
19
- const MAX_CONTENT_LENGTH = 2e3;
20
- function findProjectRoot(startDir) {
21
- let dir = startDir;
22
- for (let i = 0; i < 20; i++) {
23
- if (existsSync(join(dir, ".stackmemory", "context.db"))) {
24
- return dir;
25
- }
26
- const parent = join(dir, "..");
27
- if (parent === dir) break;
28
- dir = parent;
29
- }
30
- return null;
31
- }
32
- function createTeamCommands() {
33
- const team = new Command("team").description(
34
- "Team shared context (cross-agent memory)"
35
- );
36
- team.command("share").description("Share context with other agents (creates shared anchor)").requiredOption("-c, --content <text>", "Anchor text to share").option(
37
- "-t, --type <type>",
38
- "Anchor type (FACT|DECISION|CONSTRAINT|TODO|RISK)",
39
- "FACT"
40
- ).option("-p, --priority <n>", "Priority 1-10", "7").option(
41
- "--source <src>",
42
- "Origin: subagent|teammate-idle|task-complete|manual",
43
- "manual"
44
- ).option("--agent-id <id>", "Source agent ID").option("--task-id <id>", "Source task ID").action(async (options) => {
45
- const projectRoot = findProjectRoot(process.cwd());
46
- if (!projectRoot) {
47
- console.error(
48
- 'StackMemory not initialized. Run "stackmemory init" first.'
49
- );
50
- process.exitCode = 1;
51
- return;
52
- }
53
- const dbPath = join(projectRoot, ".stackmemory", "context.db");
54
- const db = new Database(dbPath);
55
- db.pragma("journal_mode = WAL");
56
- try {
57
- let projectId = "default";
58
- try {
59
- const row = db.prepare(`SELECT value FROM metadata WHERE key = 'project_id'`).get();
60
- if (row?.value) projectId = row.value;
61
- } catch {
62
- }
63
- const frameManager = new FrameManager(db, projectId, {
64
- skipContextBridge: true
65
- });
66
- let frameId = frameManager.getCurrentFrameId();
67
- if (!frameId) {
68
- frameId = frameManager.createFrame({
69
- type: "tool_scope",
70
- name: "team_share"
71
- });
72
- }
73
- const type = options.type.toUpperCase();
74
- if (!VALID_TYPES.includes(type)) {
75
- console.error(
76
- `Invalid type "${type}". Must be one of: ${VALID_TYPES.join(", ")}`
77
- );
78
- process.exitCode = 1;
79
- return;
80
- }
81
- const content = options.content.slice(0, MAX_CONTENT_LENGTH);
82
- const priority = Math.max(1, Math.min(10, parseInt(options.priority)));
83
- const runId = process.env["CLAUDE_INSTANCE_ID"] || process.env["STACKMEMORY_RUN_ID"] || uuidv4();
84
- const metadata = {
85
- shared: true,
86
- sharedBy: runId,
87
- sharedAt: Date.now(),
88
- source: options.source
89
- };
90
- if (options.agentId) metadata.agentId = options.agentId;
91
- if (options.taskId) metadata.taskId = options.taskId;
92
- frameManager.addAnchor(type, content, priority, metadata);
93
- console.log(
94
- `Shared [${type}] (priority ${priority}): ${content.slice(0, 80)}${content.length > 80 ? "..." : ""}`
95
- );
96
- } catch (error) {
97
- console.error("Failed to share context:", error.message);
98
- process.exitCode = 1;
99
- } finally {
100
- db.close();
101
- }
102
- });
103
- team.command("list").description("List recent shared context from all agents").option("-l, --limit <n>", "Max results", "10").option("--since <epoch>", "Filter by timestamp (ms since epoch)").action(async (options) => {
104
- const projectRoot = findProjectRoot(process.cwd());
105
- if (!projectRoot) {
106
- console.error(
107
- 'StackMemory not initialized. Run "stackmemory init" first.'
108
- );
109
- process.exitCode = 1;
110
- return;
111
- }
112
- const dbPath = join(projectRoot, ".stackmemory", "context.db");
113
- const db = new Database(dbPath);
114
- try {
115
- let projectId = "default";
116
- try {
117
- const row = db.prepare(`SELECT value FROM metadata WHERE key = 'project_id'`).get();
118
- if (row?.value) projectId = row.value;
119
- } catch {
120
- }
121
- const limit = parseInt(options.limit) || 10;
122
- const since = options.since ? parseInt(options.since) : void 0;
123
- const params = [projectId];
124
- let whereExtra = "";
125
- if (since) {
126
- whereExtra = " AND a.created_at > ?";
127
- params.push(Math.floor(since / 1e3));
128
- }
129
- params.push(limit);
130
- const rows = db.prepare(
131
- `SELECT a.*, f.name as frame_name, f.run_id
132
- FROM anchors a
133
- JOIN frames f ON a.frame_id = f.frame_id
134
- WHERE f.project_id = ?
135
- AND a.metadata LIKE '%"shared":true%'${whereExtra}
136
- ORDER BY a.priority DESC, a.created_at DESC
137
- LIMIT ?`
138
- ).all(...params);
139
- if (rows.length === 0) {
140
- console.log("No shared context found.");
141
- return;
142
- }
143
- console.log(`
144
- Shared Context (${rows.length} anchors):
145
- `);
146
- for (const row of rows) {
147
- const meta = JSON.parse(row.metadata || "{}");
148
- const date = new Date(row.created_at * 1e3).toLocaleString();
149
- const source = meta.source || "unknown";
150
- const runSlice = row.run_id?.slice(0, 8) || "?";
151
- console.log(
152
- ` [${row.type}] p${row.priority} | ${row.text.slice(0, 100)}${row.text.length > 100 ? "..." : ""}`
153
- );
154
- console.log(` source: ${source} | run: ${runSlice} | ${date}`);
155
- }
156
- console.log("");
157
- } catch (error) {
158
- console.error("Failed to list context:", error.message);
159
- process.exitCode = 1;
160
- } finally {
161
- db.close();
162
- }
163
- });
164
- return team;
165
- }
166
- export {
167
- createTeamCommands
168
- };