@stackmemoryai/stackmemory 1.12.0 → 1.14.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 (162) hide show
  1. package/LICENSE +131 -64
  2. package/README.md +3 -1
  3. package/bin/claude-sm +16 -1
  4. package/bin/claude-smd +16 -1
  5. package/bin/codex-smd +16 -1
  6. package/bin/gemini-sm +16 -1
  7. package/bin/hermes-sm +21 -0
  8. package/bin/hermes-smd +21 -0
  9. package/bin/opencode-sm +16 -1
  10. package/dist/src/cli/codex-sm.js +51 -11
  11. package/dist/src/cli/commands/brain.js +206 -0
  12. package/dist/src/cli/commands/company-os.js +184 -0
  13. package/dist/src/cli/commands/context.js +5 -0
  14. package/dist/src/cli/commands/operator.js +127 -0
  15. package/dist/src/cli/commands/orchestrate.js +2 -0
  16. package/dist/src/cli/commands/orchestrator.js +3 -2
  17. package/dist/src/cli/commands/patterns.js +254 -0
  18. package/dist/src/cli/commands/portal.js +161 -0
  19. package/dist/src/cli/commands/scaffold.js +92 -0
  20. package/dist/src/cli/commands/setup.js +1 -4
  21. package/dist/src/cli/commands/sync.js +253 -0
  22. package/dist/src/cli/commands/tasks.js +130 -1
  23. package/dist/src/cli/commands/vision.js +221 -0
  24. package/dist/src/cli/hermes-sm.js +224 -0
  25. package/dist/src/cli/index.js +15 -10
  26. package/dist/src/cli/utils/real-cli-bin.js +72 -0
  27. package/dist/src/core/brain/brain-store.js +187 -0
  28. package/dist/src/core/brain/brain-sync.js +193 -0
  29. package/dist/src/core/brain/index.js +78 -0
  30. package/dist/src/core/brain/types.js +10 -0
  31. package/dist/src/core/cache/token-estimator.js +24 -1
  32. package/dist/src/core/config/feature-flags.js +2 -6
  33. package/dist/src/core/context/frame-database.js +44 -0
  34. package/dist/src/core/context/recursive-context-manager.js +1 -1
  35. package/dist/src/core/context/rehydration.js +2 -1
  36. package/dist/src/core/database/sqlite-adapter.js +14 -1
  37. package/dist/src/core/models/model-router.js +33 -1
  38. package/dist/src/core/models/provider-pricing.js +58 -4
  39. package/dist/src/core/patterns/index.js +22 -0
  40. package/dist/src/core/patterns/pattern-applier.js +39 -0
  41. package/dist/src/core/patterns/pattern-observer.js +157 -0
  42. package/dist/src/core/patterns/pattern-store.js +259 -0
  43. package/dist/src/core/patterns/types.js +19 -0
  44. package/dist/src/core/retrieval/llm-context-retrieval.js +5 -4
  45. package/dist/src/core/retrieval/unified-context-assembler.js +11 -66
  46. package/dist/src/core/skill-packs/types.js +14 -1
  47. package/dist/src/core/storage/cloud-sync-manager.js +116 -0
  48. package/dist/src/core/storage/cloud-sync.js +574 -0
  49. package/dist/src/core/storage/two-tier-storage.js +5 -1
  50. package/dist/src/core/tasks/master-tasks-template.js +43 -0
  51. package/dist/src/core/tasks/md-task-parser.js +138 -0
  52. package/dist/src/core/vision/index.js +27 -0
  53. package/dist/src/core/vision/signals.js +79 -0
  54. package/dist/src/core/vision/types.js +22 -0
  55. package/dist/src/core/vision/vision-file.js +146 -0
  56. package/dist/src/core/vision/vision-loop.js +220 -0
  57. package/dist/src/core/wiki/wiki-compiler.js +103 -1
  58. package/dist/src/daemon/daemon-config.js +45 -0
  59. package/dist/src/daemon/services/desire-path-service.js +566 -0
  60. package/dist/src/daemon/services/research-stream-service.js +320 -0
  61. package/dist/src/daemon/services/telemetry-service.js +192 -0
  62. package/dist/src/daemon/unified-daemon.js +28 -1
  63. package/dist/src/features/browser/cli-browser-agent.js +417 -0
  64. package/dist/src/features/browser/stagehand-workflows.js +578 -0
  65. package/dist/src/features/operator/adapter-factory.js +62 -0
  66. package/dist/src/features/operator/browser-adapter.js +109 -0
  67. package/dist/src/features/operator/desktop-adapter.js +125 -0
  68. package/dist/src/features/operator/index.js +39 -0
  69. package/dist/src/features/operator/llm-decision.js +137 -0
  70. package/dist/src/features/operator/operator-logger.js +92 -0
  71. package/dist/src/features/operator/overnight-runner.js +327 -0
  72. package/dist/src/features/operator/screen-adapter.js +91 -0
  73. package/dist/src/features/operator/session-manager.js +127 -0
  74. package/dist/src/features/operator/state-machine.js +227 -0
  75. package/dist/src/features/operator/task-queue.js +81 -0
  76. package/dist/src/features/portal/index.js +26 -0
  77. package/dist/src/features/portal/server.js +240 -0
  78. package/dist/src/features/portal/types.js +14 -0
  79. package/dist/src/features/portal/ui.js +195 -0
  80. package/dist/src/features/tasks/task-aware-context.js +2 -1
  81. package/dist/src/features/tui/simple-monitor.js +0 -23
  82. package/dist/src/features/tui/swarm-monitor.js +8 -66
  83. package/dist/src/{integrations/diffmem/index.js → features/web/client/hooks/use-socket.js} +6 -5
  84. package/dist/src/features/web/client/lib/utils.js +12 -0
  85. package/dist/src/features/web/client/stores/session-store.js +12 -0
  86. package/dist/src/features/web/server/gcp-billing.js +76 -0
  87. package/dist/src/features/web/server/index.js +10 -0
  88. package/dist/src/features/web/server/spend-calculator.js +228 -0
  89. package/dist/src/hooks/schemas.js +4 -1
  90. package/dist/src/integrations/anthropic/client.js +3 -2
  91. package/dist/src/integrations/claude-code/agent-bridge.js +0 -3
  92. package/dist/src/integrations/claude-code/subagent-client.js +218 -11
  93. package/dist/src/integrations/claude-code/task-coordinator.js +2 -1
  94. package/dist/src/integrations/linear/webhook-retry.js +196 -0
  95. package/dist/src/integrations/linear/webhook-server.js +18 -22
  96. package/dist/src/integrations/mcp/handlers/cloud-sync-handlers.js +101 -0
  97. package/dist/src/integrations/mcp/handlers/index.js +27 -52
  98. package/dist/src/integrations/mcp/server.js +122 -335
  99. package/dist/src/integrations/mcp/tool-alias-registry.js +0 -73
  100. package/dist/src/integrations/mcp/tool-definitions.js +111 -510
  101. package/dist/src/mcp/stackmemory-mcp-server.js +404 -379
  102. package/dist/src/orchestrators/multimodal/determinism.js +2 -1
  103. package/dist/src/orchestrators/multimodal/harness.js +2 -1
  104. package/dist/src/skills/recursive-agent-orchestrator.js +2 -4
  105. package/dist/src/utils/process-cleanup.js +1 -7
  106. package/docs/README.md +42 -0
  107. package/docs/guides/README_INSTALL.md +208 -0
  108. package/package.json +18 -9
  109. package/scripts/claude-code-wrapper.sh +11 -0
  110. package/scripts/claude-sm-setup.sh +12 -1
  111. package/scripts/codex-wrapper.sh +11 -0
  112. package/scripts/git-hooks/branch-context-manager.sh +11 -0
  113. package/scripts/git-hooks/post-checkout-stackmemory.sh +11 -0
  114. package/scripts/git-hooks/post-commit-stackmemory.sh +11 -0
  115. package/scripts/git-hooks/pre-commit-stackmemory.sh +11 -0
  116. package/scripts/hooks/cleanup-shell.sh +12 -1
  117. package/scripts/hooks/task-complete.sh +12 -1
  118. package/scripts/install-code-execution-hooks.sh +12 -1
  119. package/scripts/install-sweep-hook.sh +12 -0
  120. package/scripts/install.sh +11 -0
  121. package/scripts/opencode-wrapper.sh +11 -0
  122. package/scripts/portal/cloud-init.yaml +69 -0
  123. package/scripts/portal/setup.sh +69 -0
  124. package/scripts/portal/stackmemory-portal.service +34 -0
  125. package/scripts/setup-claude-integration.sh +12 -1
  126. package/scripts/smoke-init-db.sh +23 -0
  127. package/scripts/stackmemory-daemon.sh +11 -0
  128. package/scripts/verify-dist.cjs +11 -4
  129. package/dist/src/cli/commands/ralph.js +0 -1053
  130. package/dist/src/hooks/diffmem-hooks.js +0 -376
  131. package/dist/src/integrations/diffmem/client.js +0 -208
  132. package/dist/src/integrations/diffmem/config.js +0 -14
  133. package/dist/src/integrations/greptile/client.js +0 -101
  134. package/dist/src/integrations/greptile/config.js +0 -14
  135. package/dist/src/integrations/greptile/index.js +0 -11
  136. package/dist/src/integrations/mcp/handlers/cross-search-handlers.js +0 -188
  137. package/dist/src/integrations/mcp/handlers/diffmem-handlers.js +0 -455
  138. package/dist/src/integrations/mcp/handlers/greptile-handlers.js +0 -456
  139. package/dist/src/integrations/mcp/handlers/provider-handlers.js +0 -227
  140. package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -863
  141. package/dist/src/integrations/ralph/context/context-budget-manager.js +0 -308
  142. package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +0 -354
  143. package/dist/src/integrations/ralph/index.js +0 -17
  144. package/dist/src/integrations/ralph/learning/pattern-learner.js +0 -416
  145. package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
  146. package/dist/src/integrations/ralph/loopmax.js +0 -488
  147. package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js +0 -293
  148. package/dist/src/integrations/ralph/monitoring/swarm-registry.js +0 -107
  149. package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -508
  150. package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -407
  151. package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +0 -495
  152. package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +0 -387
  153. package/dist/src/integrations/ralph/performance/performance-optimizer.js +0 -357
  154. package/dist/src/integrations/ralph/recovery/crash-recovery.js +0 -461
  155. package/dist/src/integrations/ralph/state/state-reconciler.js +0 -420
  156. package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +0 -444
  157. package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +0 -1005
  158. package/dist/src/integrations/ralph/visualization/ralph-debugger.js +0 -635
  159. package/scripts/ralph-loop-implementation.js +0 -404
  160. /package/dist/src/{integrations/diffmem/types.js → core/storage/cloud-sync-types.js} +0 -0
  161. /package/dist/src/{integrations/greptile → features/operator}/types.js +0 -0
  162. /package/dist/src/{integrations/ralph/types.js → features/web/client/next-env.d.js} +0 -0
@@ -6,6 +6,7 @@ import {
6
6
  createPrivacyFilter
7
7
  } from "./privacy-filter.js";
8
8
  import { logger } from "../monitoring/logger.js";
9
+ import { estimateTokens } from "../cache/token-estimator.js";
9
10
  const DEFAULT_UNIFIED_CONTEXT_CONFIG = {
10
11
  totalTokenBudget: 8e3,
11
12
  userKnowledgeBudget: 0.2,
@@ -16,10 +17,6 @@ const DEFAULT_UNIFIED_CONTEXT_CONFIG = {
16
17
  // 10%
17
18
  privacyMode: "standard"
18
19
  };
19
- function estimateTokens(content) {
20
- if (!content) return 0;
21
- return Math.ceil(content.length / 4);
22
- }
23
20
  function truncateToTokenBudget(content, tokenBudget) {
24
21
  if (!content) return "";
25
22
  const estimatedTokens = estimateTokens(content);
@@ -36,12 +33,10 @@ function truncateToTokenBudget(content, tokenBudget) {
36
33
  }
37
34
  class UnifiedContextAssembler {
38
35
  stackMemoryRetrieval;
39
- diffMemHooks;
40
36
  config;
41
37
  privacyFilter;
42
- constructor(stackMemoryRetrieval, diffMemHooks, config = {}) {
38
+ constructor(stackMemoryRetrieval, config = {}) {
43
39
  this.stackMemoryRetrieval = stackMemoryRetrieval;
44
- this.diffMemHooks = diffMemHooks;
45
40
  this.config = { ...DEFAULT_UNIFIED_CONTEXT_CONFIG, ...config };
46
41
  this.privacyFilter = createPrivacyFilter(this.config.privacyMode);
47
42
  const totalAllocation = this.config.userKnowledgeBudget + this.config.taskContextBudget + this.config.systemContextBudget;
@@ -69,11 +64,10 @@ class UnifiedContextAssembler {
69
64
  const systemContextBudget = Math.floor(
70
65
  this.config.totalTokenBudget * this.config.systemContextBudget
71
66
  );
72
- const {
73
- content: userKnowledge,
74
- memories: diffMemMemories,
75
- available: diffMemAvailable
76
- } = await this.gatherUserKnowledge(query, userKnowledgeBudget);
67
+ const { content: userKnowledge } = await this.gatherUserKnowledge(
68
+ query,
69
+ userKnowledgeBudget
70
+ );
77
71
  const userKnowledgeFiltered = this.privacyFilter.filter(userKnowledge);
78
72
  totalPrivacyFiltered += userKnowledgeFiltered.redactedCount;
79
73
  const filteredUserKnowledge = truncateToTokenBudget(
@@ -110,8 +104,6 @@ class UnifiedContextAssembler {
110
104
  budget: this.config.totalTokenBudget
111
105
  };
112
106
  const metadata = {
113
- diffMemAvailable,
114
- diffMemMemories,
115
107
  stackMemoryFrames: frameCount,
116
108
  privacyFiltered: totalPrivacyFiltered
117
109
  };
@@ -131,53 +123,10 @@ class UnifiedContextAssembler {
131
123
  };
132
124
  }
133
125
  /**
134
- * Gather user knowledge from DiffMem
135
- */
136
- async gatherUserKnowledge(query, tokenBudget) {
137
- if (!this.diffMemHooks) {
138
- return { content: "", memories: 0, available: false };
139
- }
140
- try {
141
- const status = await this.diffMemHooks.getStatus();
142
- if (!status.connected) {
143
- logger.debug("DiffMem not connected");
144
- return { content: "", memories: 0, available: false };
145
- }
146
- const memories = await this.diffMemHooks.getRelevantMemories(query, 10);
147
- if (memories.length === 0) {
148
- return { content: "", memories: 0, available: true };
149
- }
150
- const sections = ["## User Knowledge"];
151
- const byCategory = /* @__PURE__ */ new Map();
152
- for (const memory of memories) {
153
- const existing = byCategory.get(memory.category) || [];
154
- existing.push(memory);
155
- byCategory.set(memory.category, existing);
156
- }
157
- for (const [category, categoryMemories] of byCategory) {
158
- sections.push(`
159
- ### ${this.formatCategory(category)}`);
160
- for (const memory of categoryMemories) {
161
- const confidence = memory.confidence >= 0.8 ? "(high confidence)" : memory.confidence >= 0.5 ? "" : "(tentative)";
162
- sections.push(`- ${memory.content} ${confidence}`);
163
- }
164
- }
165
- const content = sections.join("\n");
166
- return {
167
- content: truncateToTokenBudget(content, tokenBudget),
168
- memories: memories.length,
169
- available: true
170
- };
171
- } catch (error) {
172
- logger.warn("Failed to gather user knowledge from DiffMem", { error });
173
- return { content: "", memories: 0, available: false };
174
- }
175
- }
176
- /**
177
- * Format category name for display
126
+ * Gather user knowledge (stub — memory service removed in v1.14)
178
127
  */
179
- formatCategory(category) {
180
- return category.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
128
+ async gatherUserKnowledge(_query, _tokenBudget) {
129
+ return { content: "", memories: 0, available: false };
181
130
  }
182
131
  /**
183
132
  * Gather task context from StackMemory
@@ -258,12 +207,8 @@ class UnifiedContextAssembler {
258
207
  }
259
208
  }
260
209
  }
261
- function createUnifiedContextAssembler(stackMemoryRetrieval, diffMemHooks = null, config = {}) {
262
- return new UnifiedContextAssembler(
263
- stackMemoryRetrieval,
264
- diffMemHooks,
265
- config
266
- );
210
+ function createUnifiedContextAssembler(stackMemoryRetrieval, config = {}) {
211
+ return new UnifiedContextAssembler(stackMemoryRetrieval, config);
267
212
  }
268
213
  export {
269
214
  DEFAULT_UNIFIED_CONTEXT_CONFIG,
@@ -37,6 +37,18 @@ const SkillPackExampleSchema = z.object({
37
37
  input: z.string().min(1),
38
38
  output: z.string().min(1)
39
39
  });
40
+ const KnownLicenseSchema = z.enum([
41
+ "MIT",
42
+ "Apache-2.0",
43
+ "ISC",
44
+ "BSD-2-Clause",
45
+ "BSD-3-Clause",
46
+ "CC-BY-4.0",
47
+ "CC-BY-SA-4.0",
48
+ "CC0-1.0",
49
+ "UNLICENSED"
50
+ ]);
51
+ const LicenseSchema = KnownLicenseSchema.or(z.string().min(1));
40
52
  const PackNameSchema = z.string().min(1).regex(
41
53
  /^[\w-]+\/[\w-]+$/,
42
54
  'name must be namespace/pack-name (e.g. "coding/typescript-react")'
@@ -46,7 +58,7 @@ const SkillPackManifestSchema = z.object({
46
58
  version: SemverSchema,
47
59
  description: z.string().min(1),
48
60
  author: z.string().min(1),
49
- license: z.string().default("MIT"),
61
+ license: LicenseSchema.default("MIT"),
50
62
  runtime: SkillPackRuntimeSchema.optional(),
51
63
  ingestion: SkillPackIngestionSchema.optional(),
52
64
  ontology: SkillPackOntologySchema.optional(),
@@ -55,6 +67,7 @@ const SkillPackManifestSchema = z.object({
55
67
  instructions: z.string().optional()
56
68
  });
57
69
  export {
70
+ KnownLicenseSchema,
58
71
  SkillPackExampleSchema,
59
72
  SkillPackIngestionSchema,
60
73
  SkillPackManifestSchema,
@@ -0,0 +1,116 @@
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 { EventEmitter } from "events";
6
+ import { CloudSyncEngine } from "./cloud-sync.js";
7
+ import { logger } from "../monitoring/logger.js";
8
+ class CloudSyncManager extends EventEmitter {
9
+ engine;
10
+ config;
11
+ periodicTimer;
12
+ debounceTimer;
13
+ running = false;
14
+ constructor(db, config) {
15
+ super();
16
+ this.config = config;
17
+ this.engine = new CloudSyncEngine(db, config);
18
+ }
19
+ /**
20
+ * Start the sync manager (periodic sync if configured)
21
+ */
22
+ start() {
23
+ if (this.running) return;
24
+ this.running = true;
25
+ if (this.config.autoSync && this.config.syncIntervalMs > 0) {
26
+ this.periodicTimer = setInterval(() => {
27
+ this.performPush("periodic").catch(
28
+ (e) => logger.error("Periodic cloud sync failed", { error: String(e) })
29
+ );
30
+ }, this.config.syncIntervalMs);
31
+ }
32
+ logger.info("Cloud sync manager started", {
33
+ autoSync: this.config.autoSync,
34
+ intervalMs: this.config.syncIntervalMs
35
+ });
36
+ }
37
+ /**
38
+ * Stop the sync manager
39
+ */
40
+ stop() {
41
+ if (!this.running) return;
42
+ this.running = false;
43
+ if (this.periodicTimer) {
44
+ clearInterval(this.periodicTimer);
45
+ this.periodicTimer = void 0;
46
+ }
47
+ if (this.debounceTimer) {
48
+ clearTimeout(this.debounceTimer);
49
+ this.debounceTimer = void 0;
50
+ }
51
+ logger.info("Cloud sync manager stopped");
52
+ }
53
+ /**
54
+ * Schedule a debounced push (used by frame lifecycle hooks)
55
+ */
56
+ scheduleDebouncedPush(trigger) {
57
+ if (!this.config.enabled || !this.running) return;
58
+ if (this.debounceTimer) {
59
+ clearTimeout(this.debounceTimer);
60
+ }
61
+ this.debounceTimer = setTimeout(() => {
62
+ this.debounceTimer = void 0;
63
+ this.performPush(trigger).catch(
64
+ (e) => logger.error("Debounced cloud sync push failed", {
65
+ error: String(e)
66
+ })
67
+ );
68
+ }, this.config.debounceMs);
69
+ }
70
+ /**
71
+ * Perform a push
72
+ */
73
+ async performPush(trigger, force = false) {
74
+ const result = await this.engine.push(force);
75
+ this.emit("push", { trigger, result });
76
+ return result;
77
+ }
78
+ /**
79
+ * Perform a pull
80
+ */
81
+ async performPull(trigger, tables) {
82
+ const result = await this.engine.pull(tables);
83
+ this.emit("pull", { trigger, result });
84
+ return result;
85
+ }
86
+ /**
87
+ * Get sync status
88
+ */
89
+ getStatus() {
90
+ return this.engine.status();
91
+ }
92
+ /**
93
+ * Check if manager is running
94
+ */
95
+ isRunning() {
96
+ return this.running;
97
+ }
98
+ }
99
+ const DEFAULT_SYNC_MANAGER_CONFIG = {
100
+ batchSize: 100,
101
+ conflictResolution: "newest_wins",
102
+ generationalPolicy: {
103
+ youngMaxAgeDays: 1,
104
+ matureMaxAgeDays: 7
105
+ },
106
+ timeoutMs: 3e4,
107
+ retryAttempts: 3,
108
+ retryBaseDelayMs: 1e3,
109
+ autoSync: false,
110
+ syncIntervalMs: 0,
111
+ debounceMs: 5e3
112
+ };
113
+ export {
114
+ CloudSyncManager,
115
+ DEFAULT_SYNC_MANAGER_CONFIG
116
+ };