@stackmemoryai/stackmemory 0.3.17 → 0.3.19

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 (234) hide show
  1. package/dist/cli/claude-sm.js +51 -5
  2. package/dist/cli/claude-sm.js.map +2 -2
  3. package/dist/cli/codex-sm.js +52 -19
  4. package/dist/cli/codex-sm.js.map +2 -2
  5. package/dist/cli/commands/db.js +143 -0
  6. package/dist/cli/commands/db.js.map +7 -0
  7. package/dist/cli/commands/login.js +50 -0
  8. package/dist/cli/commands/login.js.map +7 -0
  9. package/dist/cli/commands/migrate.js +178 -0
  10. package/dist/cli/commands/migrate.js.map +7 -0
  11. package/dist/cli/commands/onboard.js +158 -2
  12. package/dist/cli/commands/onboard.js.map +2 -2
  13. package/dist/cli/commands/skills.js +15 -2
  14. package/dist/cli/commands/skills.js.map +2 -2
  15. package/dist/cli/index.js +118 -834
  16. package/dist/cli/index.js.map +3 -3
  17. package/dist/core/context/dual-stack-manager.js +1 -1
  18. package/dist/core/context/dual-stack-manager.js.map +1 -1
  19. package/dist/core/context/frame-database.js +1 -0
  20. package/dist/core/context/frame-database.js.map +2 -2
  21. package/dist/core/context/frame-manager.js +59 -2
  22. package/dist/core/context/frame-manager.js.map +2 -2
  23. package/dist/core/database/database-adapter.js +6 -1
  24. package/dist/core/database/database-adapter.js.map +2 -2
  25. package/dist/core/database/sqlite-adapter.js +60 -2
  26. package/dist/core/database/sqlite-adapter.js.map +2 -2
  27. package/dist/integrations/claude-code/subagent-client.js +106 -3
  28. package/dist/integrations/claude-code/subagent-client.js.map +2 -2
  29. package/dist/servers/railway/config.js +51 -0
  30. package/dist/servers/railway/config.js.map +7 -0
  31. package/dist/servers/railway/index-enhanced.js +156 -0
  32. package/dist/servers/railway/index-enhanced.js.map +7 -0
  33. package/dist/servers/railway/index.js +843 -82
  34. package/dist/servers/railway/index.js.map +3 -3
  35. package/dist/servers/railway/minimal.js +48 -3
  36. package/dist/servers/railway/minimal.js.map +2 -2
  37. package/dist/servers/railway/storage-test.js +455 -0
  38. package/dist/servers/railway/storage-test.js.map +7 -0
  39. package/dist/skills/claude-skills.js +13 -12
  40. package/dist/skills/claude-skills.js.map +2 -2
  41. package/dist/skills/recursive-agent-orchestrator.js +27 -18
  42. package/dist/skills/recursive-agent-orchestrator.js.map +2 -2
  43. package/dist/skills/unified-rlm-orchestrator.js.map +2 -2
  44. package/package.json +13 -21
  45. package/scripts/README-TESTING.md +186 -0
  46. package/scripts/analyze-cli-security.js +288 -0
  47. package/scripts/archive/add-phase-tasks-to-linear.js +163 -0
  48. package/scripts/archive/analyze-linear-duplicates.js +214 -0
  49. package/scripts/archive/analyze-remaining-duplicates.js +230 -0
  50. package/scripts/archive/analyze-sta-duplicates.js +292 -0
  51. package/scripts/archive/analyze-sta-graphql.js +399 -0
  52. package/scripts/archive/cancel-duplicate-tasks.ts +246 -0
  53. package/scripts/archive/check-all-duplicates.ts +419 -0
  54. package/scripts/archive/clean-duplicate-tasks.js +114 -0
  55. package/scripts/archive/cleanup-duplicate-tasks.ts +286 -0
  56. package/scripts/archive/create-phase-tasks.js +387 -0
  57. package/scripts/archive/delete-linear-duplicates.js +182 -0
  58. package/scripts/archive/delete-remaining-duplicates.js +158 -0
  59. package/scripts/archive/delete-sta-duplicates.js +201 -0
  60. package/scripts/archive/delete-sta-oauth.js +201 -0
  61. package/scripts/archive/export-sta-tasks.js +62 -0
  62. package/scripts/archive/install-auto-sync.js +266 -0
  63. package/scripts/archive/install-chromadb-hooks.sh +133 -0
  64. package/scripts/archive/install-enhanced-clear-hooks.sh +431 -0
  65. package/scripts/archive/install-post-task-hooks.sh +289 -0
  66. package/scripts/archive/install-stackmemory-hooks.sh +420 -0
  67. package/scripts/archive/merge-linear-duplicates-safe.ts +362 -0
  68. package/scripts/archive/merge-linear-duplicates.ts +180 -0
  69. package/scripts/archive/remove-sta-tasks.js +70 -0
  70. package/scripts/archive/setup-background-sync.sh +168 -0
  71. package/scripts/archive/setup-claude-auto-triggers.sh +181 -0
  72. package/scripts/archive/setup-claude-autostart.sh +305 -0
  73. package/scripts/archive/setup-git-hooks.sh +25 -0
  74. package/scripts/archive/setup-linear-oauth.sh +46 -0
  75. package/scripts/archive/setup-mcp.sh +113 -0
  76. package/scripts/archive/setup-railway-deployment.sh +81 -0
  77. package/scripts/auto-handoff.sh +262 -0
  78. package/scripts/background-sync-manager.js +416 -0
  79. package/scripts/benchmark-performance.ts +57 -0
  80. package/scripts/check-redis.ts +48 -0
  81. package/scripts/chromadb-auto-loader.sh +128 -0
  82. package/scripts/chromadb-context-loader.js +479 -0
  83. package/scripts/claude-chromadb-hook.js +460 -0
  84. package/scripts/claude-code-wrapper.sh +66 -0
  85. package/scripts/claude-linear-skill.js +455 -0
  86. package/scripts/claude-pre-commit.sh +302 -0
  87. package/scripts/claude-sm-autostart.js +532 -0
  88. package/scripts/claude-sm-setup.sh +367 -0
  89. package/scripts/claude-with-chromadb.sh +69 -0
  90. package/scripts/claude-worktree-manager.sh +323 -0
  91. package/scripts/claude-worktree-monitor.sh +371 -0
  92. package/scripts/claude-worktree-setup.sh +327 -0
  93. package/scripts/clean-linear-backlog.js +273 -0
  94. package/scripts/cleanup-old-sessions.sh +57 -0
  95. package/scripts/codex-wrapper.sh +88 -0
  96. package/scripts/create-sandbox.sh +269 -0
  97. package/scripts/debug-linear-update.js +174 -0
  98. package/scripts/delete-linear-tasks.js +167 -0
  99. package/scripts/deploy.sh +89 -0
  100. package/scripts/deployment/railway.sh +352 -0
  101. package/scripts/deployment/test-deployment.js +194 -0
  102. package/scripts/detect-and-rehydrate.js +162 -0
  103. package/scripts/detect-and-rehydrate.mjs +165 -0
  104. package/scripts/development/create-demo-tasks.js +143 -0
  105. package/scripts/development/debug-frame-test.js +16 -0
  106. package/scripts/development/demo-auto-sync.js +128 -0
  107. package/scripts/development/fix-all-imports.js +213 -0
  108. package/scripts/development/fix-imports.js +229 -0
  109. package/scripts/development/fix-lint-loop.cjs +103 -0
  110. package/scripts/development/fix-project-id.ts +161 -0
  111. package/scripts/development/fix-strict-mode-issues.ts +291 -0
  112. package/scripts/development/reorganize-structure.sh +228 -0
  113. package/scripts/development/test-persistence-direct.js +148 -0
  114. package/scripts/development/test-persistence.js +114 -0
  115. package/scripts/development/test-tasks.js +93 -0
  116. package/scripts/development/update-imports.js +212 -0
  117. package/scripts/fetch-linear-status.js +125 -0
  118. package/scripts/git-hooks/README.md +310 -0
  119. package/scripts/git-hooks/branch-context-manager.sh +342 -0
  120. package/scripts/git-hooks/post-checkout-stackmemory.sh +63 -0
  121. package/scripts/git-hooks/post-commit-stackmemory.sh +305 -0
  122. package/scripts/git-hooks/pre-commit-stackmemory.sh +275 -0
  123. package/scripts/hooks/cleanup-shell.sh +130 -0
  124. package/scripts/hooks/task-complete.sh +114 -0
  125. package/scripts/initialize.ts +129 -0
  126. package/scripts/install-claude-hooks-auto.js +104 -0
  127. package/scripts/install-claude-hooks.sh +133 -0
  128. package/scripts/install-global.sh +296 -0
  129. package/scripts/install.sh +235 -0
  130. package/scripts/linear-auto-sync.js +262 -0
  131. package/scripts/linear-auto-sync.sh +161 -0
  132. package/scripts/linear-sync-daemon.js +150 -0
  133. package/scripts/linear-task-review.js +237 -0
  134. package/scripts/list-linear-tasks.ts +178 -0
  135. package/scripts/mcp-proxy.js +66 -0
  136. package/scripts/opencode-wrapper.sh +85 -0
  137. package/scripts/publish-local.js +74 -0
  138. package/scripts/query-chromadb.ts +201 -0
  139. package/scripts/railway-env-setup.sh +39 -0
  140. package/scripts/reconcile-local-tasks.js +170 -0
  141. package/scripts/recreate-frames-db.js +89 -0
  142. package/scripts/setup/claude-integration.js +138 -0
  143. package/scripts/setup/configure-alias.js +125 -0
  144. package/scripts/setup/configure-codex-alias.js +161 -0
  145. package/scripts/setup/configure-opencode-alias.js +175 -0
  146. package/scripts/setup-claude-integration.js +204 -0
  147. package/scripts/setup-claude-integration.sh +183 -0
  148. package/scripts/setup-railway-deployment.sh +37 -0
  149. package/scripts/setup.sh +31 -0
  150. package/scripts/show-linear-summary.ts +172 -0
  151. package/scripts/stackmemory-auto-handoff.sh +231 -0
  152. package/scripts/stackmemory-daemon.sh +40 -0
  153. package/scripts/start-linear-sync-daemon.sh +141 -0
  154. package/scripts/start-temporal-paradox.sh +214 -0
  155. package/scripts/status.ts +159 -0
  156. package/scripts/sync-and-clean-tasks.js +258 -0
  157. package/scripts/sync-frames-from-railway.js +228 -0
  158. package/scripts/sync-linear-graphql.js +303 -0
  159. package/scripts/sync-linear-tasks.js +186 -0
  160. package/scripts/test-auto-triggers.sh +57 -0
  161. package/scripts/test-browser-mcp.js +74 -0
  162. package/scripts/test-chromadb-full.js +115 -0
  163. package/scripts/test-chromadb-hooks.sh +28 -0
  164. package/scripts/test-chromadb-sync.ts +245 -0
  165. package/scripts/test-cli-security.js +293 -0
  166. package/scripts/test-hooks-persistence.sh +220 -0
  167. package/scripts/test-installation-scenarios.sh +359 -0
  168. package/scripts/test-installation.sh +224 -0
  169. package/scripts/test-mcp.js +163 -0
  170. package/scripts/test-pre-publish-quick.sh +75 -0
  171. package/scripts/test-quality-gates.sh +263 -0
  172. package/scripts/test-railway-db.js +222 -0
  173. package/scripts/test-redis-storage.ts +490 -0
  174. package/scripts/test-rlm-basic.sh +122 -0
  175. package/scripts/test-rlm-comprehensive.sh +260 -0
  176. package/scripts/test-rlm-e2e.sh +268 -0
  177. package/scripts/test-rlm-simple.js +90 -0
  178. package/scripts/test-rlm.js +110 -0
  179. package/scripts/test-session-handoff.sh +165 -0
  180. package/scripts/test-shell-integration.sh +275 -0
  181. package/scripts/testing/ab-test-runner.ts +508 -0
  182. package/scripts/testing/collect-metrics.ts +457 -0
  183. package/scripts/testing/quick-effectiveness-demo.js +187 -0
  184. package/scripts/testing/real-performance-test.js +422 -0
  185. package/scripts/testing/run-effectiveness-tests.sh +176 -0
  186. package/scripts/testing/scripts/testing/ab-test-runner.js +363 -0
  187. package/scripts/testing/scripts/testing/collect-metrics.js +292 -0
  188. package/scripts/testing/simple-effectiveness-test.js +310 -0
  189. package/scripts/testing/src/core/context/context-bridge.js +253 -0
  190. package/scripts/testing/src/core/context/frame-manager.js +746 -0
  191. package/scripts/testing/src/core/context/shared-context-layer.js +437 -0
  192. package/scripts/testing/src/core/database/database-adapter.js +54 -0
  193. package/scripts/testing/src/core/errors/index.js +291 -0
  194. package/scripts/testing/src/core/errors/recovery.js +268 -0
  195. package/scripts/testing/src/core/monitoring/logger.js +145 -0
  196. package/scripts/testing/src/core/retrieval/context-retriever.js +516 -0
  197. package/scripts/testing/src/core/session/index.js +1 -0
  198. package/scripts/testing/src/core/session/session-manager.js +323 -0
  199. package/scripts/testing/src/core/trace/cli-trace-wrapper.js +140 -0
  200. package/scripts/testing/src/core/trace/db-trace-wrapper.js +251 -0
  201. package/scripts/testing/src/core/trace/debug-trace.js +398 -0
  202. package/scripts/testing/src/core/trace/index.js +120 -0
  203. package/scripts/testing/src/core/trace/linear-api-wrapper.js +204 -0
  204. package/scripts/update-linear-status.js +268 -0
  205. package/scripts/update-linear-tasks-fixed.js +284 -0
  206. package/scripts/verify-railway-schema.ts +35 -0
  207. package/templates/claude-hooks/hooks.json +5 -0
  208. package/templates/claude-hooks/on-clear.js +56 -0
  209. package/templates/claude-hooks/on-startup.js +56 -0
  210. package/templates/claude-hooks/tool-use-trace.js +67 -0
  211. package/dist/features/tui/components/analytics-panel.js +0 -157
  212. package/dist/features/tui/components/analytics-panel.js.map +0 -7
  213. package/dist/features/tui/components/frame-visualizer.js +0 -377
  214. package/dist/features/tui/components/frame-visualizer.js.map +0 -7
  215. package/dist/features/tui/components/pr-tracker.js +0 -135
  216. package/dist/features/tui/components/pr-tracker.js.map +0 -7
  217. package/dist/features/tui/components/session-monitor.js +0 -299
  218. package/dist/features/tui/components/session-monitor.js.map +0 -7
  219. package/dist/features/tui/components/subagent-fleet.js +0 -395
  220. package/dist/features/tui/components/subagent-fleet.js.map +0 -7
  221. package/dist/features/tui/components/task-board.js +0 -1139
  222. package/dist/features/tui/components/task-board.js.map +0 -7
  223. package/dist/features/tui/index.js +0 -408
  224. package/dist/features/tui/index.js.map +0 -7
  225. package/dist/features/tui/services/data-service.js +0 -641
  226. package/dist/features/tui/services/data-service.js.map +0 -7
  227. package/dist/features/tui/services/linear-task-reader.js +0 -102
  228. package/dist/features/tui/services/linear-task-reader.js.map +0 -7
  229. package/dist/features/tui/services/websocket-client.js +0 -162
  230. package/dist/features/tui/services/websocket-client.js.map +0 -7
  231. package/dist/features/tui/terminal-compat.js +0 -220
  232. package/dist/features/tui/terminal-compat.js.map +0 -7
  233. package/dist/features/tui/types.js +0 -1
  234. package/dist/features/tui/types.js.map +0 -7
@@ -0,0 +1,422 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from 'child_process';
4
+ import { performance } from 'perf_hooks';
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { fileURLToPath } from 'url';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ /**
13
+ * Real performance test for StackMemory
14
+ * This actually measures real operations, not theoretical performance
15
+ */
16
+ class RealPerformanceTest {
17
+ constructor() {
18
+ this.results = {
19
+ timestamp: new Date().toISOString(),
20
+ tests: []
21
+ };
22
+ }
23
+
24
+ log(message, type = 'info') {
25
+ const symbols = {
26
+ success: '✓',
27
+ error: '✗',
28
+ warning: '!',
29
+ info: '→'
30
+ };
31
+ console.log(`${symbols[type] || ''} ${message}`);
32
+ }
33
+
34
+ /**
35
+ * Test 1: Measure actual StackMemory status command performance
36
+ */
37
+ testStatusCommand() {
38
+ this.log('Testing: StackMemory status command performance');
39
+
40
+ const measurements = [];
41
+ const iterations = 3;
42
+
43
+ for (let i = 0; i < iterations; i++) {
44
+ const start = performance.now();
45
+ try {
46
+ // Just check version quickly
47
+ execSync('stackmemory --version', { encoding: 'utf-8', stdio: 'pipe' });
48
+ const duration = performance.now() - start;
49
+ measurements.push(duration);
50
+ this.log(` Run ${i + 1}: ${duration.toFixed(2)}ms`, 'success');
51
+ } catch (error) {
52
+ this.log(` Run ${i + 1}: Failed or timed out`, 'error');
53
+ measurements.push(null);
54
+ }
55
+ }
56
+
57
+ const validMeasurements = measurements.filter(m => m !== null);
58
+ const avg = validMeasurements.length > 0
59
+ ? validMeasurements.reduce((a, b) => a + b, 0) / validMeasurements.length
60
+ : null;
61
+
62
+ const result = {
63
+ test: 'status_command',
64
+ iterations,
65
+ measurements,
66
+ average: avg,
67
+ unit: 'ms'
68
+ };
69
+
70
+ this.results.tests.push(result);
71
+
72
+ if (avg !== null) {
73
+ this.log(`Average: ${avg.toFixed(2)}ms\n`, 'success');
74
+ } else {
75
+ this.log('All runs failed\n', 'error');
76
+ }
77
+
78
+ return result;
79
+ }
80
+
81
+ /**
82
+ * Test 2: Measure context push/pop operations
83
+ */
84
+ testContextOperations() {
85
+ this.log('Testing: Context push/pop operations');
86
+
87
+ const operations = [
88
+ { name: 'version_check', command: 'stackmemory --version' },
89
+ { name: 'tasks_list', command: 'stackmemory tasks list' }
90
+ ];
91
+
92
+ const results = [];
93
+
94
+ for (const op of operations) {
95
+ const start = performance.now();
96
+ try {
97
+ execSync(op.command, { encoding: 'utf-8', stdio: 'pipe' });
98
+ const duration = performance.now() - start;
99
+ this.log(` ${op.name}: ${duration.toFixed(2)}ms`, 'success');
100
+ results.push({ operation: op.name, duration, success: true });
101
+ } catch (error) {
102
+ this.log(` ${op.name}: Failed - ${error.message}`, 'error');
103
+ results.push({ operation: op.name, duration: null, success: false, error: error.message });
104
+ }
105
+ }
106
+
107
+ const totalTime = results
108
+ .filter(r => r.duration !== null)
109
+ .reduce((sum, r) => sum + r.duration, 0);
110
+
111
+ const testResult = {
112
+ test: 'context_operations',
113
+ operations: results,
114
+ totalTime,
115
+ unit: 'ms'
116
+ };
117
+
118
+ this.results.tests.push(testResult);
119
+ this.log(`Total time for all operations: ${totalTime.toFixed(2)}ms\n`, 'info');
120
+
121
+ return testResult;
122
+ }
123
+
124
+ /**
125
+ * Test 3: Measure task operations
126
+ */
127
+ testTaskOperations() {
128
+ this.log('Testing: Task operations');
129
+
130
+ const taskId = `test-${Date.now()}`;
131
+ const operations = [
132
+ { name: 'add_task', command: `stackmemory tasks add "Test task ${taskId}"` },
133
+ { name: 'list_tasks', command: 'stackmemory tasks list' },
134
+ { name: 'show_task', command: `stackmemory tasks show ${taskId}`, optional: true }
135
+ ];
136
+
137
+ const results = [];
138
+
139
+ for (const op of operations) {
140
+ const start = performance.now();
141
+ try {
142
+ const output = execSync(op.command, { encoding: 'utf-8', stdio: 'pipe' });
143
+ const duration = performance.now() - start;
144
+ this.log(` ${op.name}: ${duration.toFixed(2)}ms`, 'success');
145
+ results.push({
146
+ operation: op.name,
147
+ duration,
148
+ success: true,
149
+ outputSize: output.length
150
+ });
151
+ } catch (error) {
152
+ if (op.optional) {
153
+ this.log(` ${op.name}: Skipped (optional)`, 'warning');
154
+ } else {
155
+ this.log(` ${op.name}: Failed - ${error.message}`, 'error');
156
+ }
157
+ results.push({
158
+ operation: op.name,
159
+ duration: null,
160
+ success: false,
161
+ error: error.message
162
+ });
163
+ }
164
+ }
165
+
166
+ const testResult = {
167
+ test: 'task_operations',
168
+ operations: results,
169
+ unit: 'ms'
170
+ };
171
+
172
+ this.results.tests.push(testResult);
173
+ this.log('');
174
+
175
+ return testResult;
176
+ }
177
+
178
+ /**
179
+ * Test 4: Measure database size and file I/O
180
+ */
181
+ testStoragePerformance() {
182
+ this.log('Testing: Storage and file I/O performance');
183
+
184
+ const dbPath = path.join(process.cwd(), '.stackmemory', 'context.db');
185
+ const tasksPath = path.join(process.cwd(), '.stackmemory', 'tasks.jsonl');
186
+
187
+ const results = {
188
+ database: null,
189
+ tasks: null
190
+ };
191
+
192
+ // Check database
193
+ if (fs.existsSync(dbPath)) {
194
+ const stats = fs.statSync(dbPath);
195
+ results.database = {
196
+ exists: true,
197
+ size: stats.size,
198
+ sizeFormatted: `${(stats.size / 1024).toFixed(2)} KB`,
199
+ modified: stats.mtime
200
+ };
201
+ this.log(` Database size: ${results.database.sizeFormatted}`, 'success');
202
+ } else {
203
+ this.log(` Database not found at ${dbPath}`, 'warning');
204
+ results.database = { exists: false };
205
+ }
206
+
207
+ // Check tasks file
208
+ if (fs.existsSync(tasksPath)) {
209
+ const stats = fs.statSync(tasksPath);
210
+ const content = fs.readFileSync(tasksPath, 'utf-8');
211
+ const lineCount = content.split('\n').filter(line => line.trim()).length;
212
+
213
+ results.tasks = {
214
+ exists: true,
215
+ size: stats.size,
216
+ sizeFormatted: `${(stats.size / 1024).toFixed(2)} KB`,
217
+ lineCount,
218
+ modified: stats.mtime
219
+ };
220
+ this.log(` Tasks file: ${results.tasks.sizeFormatted} (${lineCount} tasks)`, 'success');
221
+ } else {
222
+ this.log(` Tasks file not found at ${tasksPath}`, 'warning');
223
+ results.tasks = { exists: false };
224
+ }
225
+
226
+ const testResult = {
227
+ test: 'storage_performance',
228
+ results
229
+ };
230
+
231
+ this.results.tests.push(testResult);
232
+ this.log('');
233
+
234
+ return testResult;
235
+ }
236
+
237
+ /**
238
+ * Test 5: Compare with a baseline (simulated without StackMemory)
239
+ */
240
+ testBaseline() {
241
+ this.log('Testing: Baseline comparison (simulated without StackMemory)');
242
+
243
+ // Simulate what operations would be like without StackMemory
244
+ const baseline = {
245
+ taskListing: {
246
+ withStackMemory: null,
247
+ withoutStackMemory: 5000, // Estimate: 5 seconds to manually check tasks in files
248
+ unit: 'ms'
249
+ },
250
+ taskCreation: {
251
+ withStackMemory: null,
252
+ withoutStackMemory: 30000, // Estimate: 30 seconds to manually create and track task
253
+ unit: 'ms'
254
+ }
255
+ };
256
+
257
+ // Measure actual StackMemory operations
258
+ const start = performance.now();
259
+ try {
260
+ execSync('stackmemory tasks list', { encoding: 'utf-8', stdio: 'pipe' });
261
+ baseline.taskListing.withStackMemory = performance.now() - start;
262
+ this.log(` Task listing with StackMemory: ${baseline.taskListing.withStackMemory.toFixed(2)}ms`, 'success');
263
+ } catch (error) {
264
+ this.log(` Task listing failed: ${error.message}`, 'error');
265
+ }
266
+
267
+ const taskStart = performance.now();
268
+ try {
269
+ execSync('stackmemory tasks add "Performance test task"', { encoding: 'utf-8', stdio: 'pipe' });
270
+ baseline.taskCreation.withStackMemory = performance.now() - taskStart;
271
+ this.log(` Task creation with StackMemory: ${baseline.taskCreation.withStackMemory.toFixed(2)}ms`, 'success');
272
+ } catch (error) {
273
+ this.log(` Task creation failed: ${error.message}`, 'error');
274
+ }
275
+
276
+ // Calculate improvements (if we have data)
277
+ if (baseline.taskListing.withStackMemory !== null) {
278
+ const improvement = ((baseline.taskListing.withoutStackMemory - baseline.taskListing.withStackMemory) /
279
+ baseline.taskListing.withoutStackMemory * 100).toFixed(1);
280
+ this.log(` Task listing improvement: ${improvement}%`, 'info');
281
+ }
282
+
283
+ if (baseline.taskCreation.withStackMemory !== null) {
284
+ const improvement = ((baseline.taskCreation.withoutStackMemory - baseline.taskCreation.withStackMemory) /
285
+ baseline.taskCreation.withoutStackMemory * 100).toFixed(1);
286
+ this.log(` Task creation improvement: ${improvement}%`, 'info');
287
+ }
288
+
289
+ const testResult = {
290
+ test: 'baseline_comparison',
291
+ baseline
292
+ };
293
+
294
+ this.results.tests.push(testResult);
295
+ this.log('');
296
+
297
+ return testResult;
298
+ }
299
+
300
+ /**
301
+ * Generate honest report with real measurements
302
+ */
303
+ generateReport() {
304
+ console.log('='.repeat(60));
305
+ console.log('REAL STACKMEMORY PERFORMANCE TEST RESULTS');
306
+ console.log('='.repeat(60));
307
+ console.log(`\nTest run: ${this.results.timestamp}\n`);
308
+
309
+ // Status command performance
310
+ const statusTest = this.results.tests.find(t => t.test === 'status_command');
311
+ if (statusTest && statusTest.average !== null) {
312
+ console.log('📊 STATUS COMMAND PERFORMANCE');
313
+ console.log('─'.repeat(40));
314
+ console.log(`Average response time: ${statusTest.average.toFixed(2)}ms`);
315
+ console.log(`Samples: ${statusTest.measurements.filter(m => m !== null).length}/${statusTest.iterations}`);
316
+ console.log('');
317
+ }
318
+
319
+ // Context operations
320
+ const contextTest = this.results.tests.find(t => t.test === 'context_operations');
321
+ if (contextTest) {
322
+ console.log('🔄 CONTEXT OPERATIONS PERFORMANCE');
323
+ console.log('─'.repeat(40));
324
+ const successful = contextTest.operations.filter(op => op.success);
325
+ console.log(`Successful operations: ${successful.length}/${contextTest.operations.length}`);
326
+ if (successful.length > 0) {
327
+ console.log(`Total time: ${contextTest.totalTime.toFixed(2)}ms`);
328
+ console.log(`Average per operation: ${(contextTest.totalTime / successful.length).toFixed(2)}ms`);
329
+ }
330
+ console.log('');
331
+ }
332
+
333
+ // Storage
334
+ const storageTest = this.results.tests.find(t => t.test === 'storage_performance');
335
+ if (storageTest) {
336
+ console.log('💾 STORAGE INFORMATION');
337
+ console.log('─'.repeat(40));
338
+ if (storageTest.results.database && storageTest.results.database.exists) {
339
+ console.log(`Database size: ${storageTest.results.database.sizeFormatted}`);
340
+ }
341
+ if (storageTest.results.tasks && storageTest.results.tasks.exists) {
342
+ console.log(`Tasks: ${storageTest.results.tasks.lineCount} tasks in ${storageTest.results.tasks.sizeFormatted}`);
343
+ }
344
+ console.log('');
345
+ }
346
+
347
+ // Baseline comparison
348
+ const baselineTest = this.results.tests.find(t => t.test === 'baseline_comparison');
349
+ if (baselineTest) {
350
+ console.log('⚡ ACTUAL vs ESTIMATED PERFORMANCE');
351
+ console.log('─'.repeat(40));
352
+
353
+ if (baselineTest.baseline.taskListing && baselineTest.baseline.taskListing.withStackMemory !== null) {
354
+ console.log('Task Listing:');
355
+ console.log(` With StackMemory: ${baselineTest.baseline.taskListing.withStackMemory.toFixed(0)}ms`);
356
+ console.log(` Without (estimated): ${(baselineTest.baseline.taskListing.withoutStackMemory / 1000).toFixed(0)}s`);
357
+ }
358
+
359
+ if (baselineTest.baseline.taskCreation && baselineTest.baseline.taskCreation.withStackMemory !== null) {
360
+ console.log('Task Creation:');
361
+ console.log(` With StackMemory: ${baselineTest.baseline.taskCreation.withStackMemory.toFixed(0)}ms`);
362
+ console.log(` Without (estimated): ${(baselineTest.baseline.taskCreation.withoutStackMemory / 1000).toFixed(0)}s`);
363
+ }
364
+ console.log('');
365
+ }
366
+
367
+ // Save results to file
368
+ const resultsPath = path.join(process.cwd(), 'test-results', 'real-performance-results.json');
369
+ const resultsDir = path.dirname(resultsPath);
370
+
371
+ if (!fs.existsSync(resultsDir)) {
372
+ fs.mkdirSync(resultsDir, { recursive: true });
373
+ }
374
+
375
+ fs.writeFileSync(resultsPath, JSON.stringify(this.results, null, 2));
376
+
377
+ console.log('='.repeat(60));
378
+ console.log('SUMMARY');
379
+ console.log('='.repeat(60));
380
+ console.log('\n✅ What we actually measured:');
381
+ console.log(' - Real command execution times');
382
+ console.log(' - Actual file I/O operations');
383
+ console.log(' - True storage sizes');
384
+ console.log('\n⚠️ What we estimated:');
385
+ console.log(' - Manual context recall time (5 min)');
386
+ console.log(' - Manual decision documentation (1 min)');
387
+ console.log('\n📄 Full results saved to:', resultsPath);
388
+ }
389
+
390
+ async run() {
391
+ console.log('Starting real performance tests...\n');
392
+
393
+ try {
394
+ // Check if StackMemory is installed
395
+ try {
396
+ const version = execSync('stackmemory --version', { encoding: 'utf-8' }).trim();
397
+ this.log(`StackMemory version: ${version}\n`, 'success');
398
+ } catch (error) {
399
+ this.log('StackMemory not found. Please install it first.', 'error');
400
+ return;
401
+ }
402
+
403
+ // Run all tests
404
+ this.testStatusCommand();
405
+ this.testContextOperations();
406
+ this.testTaskOperations();
407
+ this.testStoragePerformance();
408
+ this.testBaseline();
409
+
410
+ // Generate report
411
+ this.generateReport();
412
+
413
+ } catch (error) {
414
+ this.log(`Test suite failed: ${error.message}`, 'error');
415
+ console.error(error);
416
+ }
417
+ }
418
+ }
419
+
420
+ // Run the test
421
+ const test = new RealPerformanceTest();
422
+ test.run();
@@ -0,0 +1,176 @@
1
+ #!/bin/bash
2
+
3
+ # StackMemory Effectiveness Testing Runner
4
+ # This script orchestrates the complete testing process
5
+
6
+ set -e
7
+
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
10
+ RESULTS_DIR="$PROJECT_ROOT/test-results"
11
+
12
+ # Colors for output
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ RED='\033[0;31m'
16
+ NC='\033[0m' # No Color
17
+
18
+ echo "=================================================="
19
+ echo "StackMemory Effectiveness Testing Suite"
20
+ echo "=================================================="
21
+ echo ""
22
+
23
+ # Function to print colored output
24
+ print_status() {
25
+ echo -e "${GREEN}[✓]${NC} $1"
26
+ }
27
+
28
+ print_warning() {
29
+ echo -e "${YELLOW}[!]${NC} $1"
30
+ }
31
+
32
+ print_error() {
33
+ echo -e "${RED}[✗]${NC} $1"
34
+ }
35
+
36
+ # Check if StackMemory is installed
37
+ check_stackmemory() {
38
+ if command -v stackmemory &> /dev/null; then
39
+ print_status "StackMemory CLI found"
40
+ stackmemory --version
41
+ else
42
+ print_error "StackMemory CLI not found. Please install it first."
43
+ echo "Run: npm install -g @stackmemoryai/stackmemory"
44
+ exit 1
45
+ fi
46
+ }
47
+
48
+ # Initialize test environment
49
+ init_test_env() {
50
+ print_status "Initializing test environment..."
51
+
52
+ # Create results directory
53
+ mkdir -p "$RESULTS_DIR"
54
+ mkdir -p "$RESULTS_DIR/runs"
55
+ mkdir -p "$RESULTS_DIR/metrics"
56
+
57
+ # Build TypeScript files
58
+ cd "$PROJECT_ROOT"
59
+ print_status "Building TypeScript files..."
60
+ npm run build 2>/dev/null || print_warning "Build completed with warnings"
61
+ }
62
+
63
+ # Run baseline tests (without StackMemory)
64
+ run_baseline() {
65
+ echo ""
66
+ echo "Phase 1: Collecting Baseline Metrics (Without StackMemory)"
67
+ echo "----------------------------------------------------------"
68
+
69
+ # Ensure StackMemory daemon is stopped
70
+ stackmemory-daemon stop 2>/dev/null || true
71
+
72
+ print_status "Running baseline scenarios..."
73
+ node "$SCRIPT_DIR/ab-test-runner.js" scenario multi_session_feature || true
74
+
75
+ print_status "Baseline collection complete"
76
+ }
77
+
78
+ # Run StackMemory tests
79
+ run_with_stackmemory() {
80
+ echo ""
81
+ echo "Phase 2: Testing With StackMemory"
82
+ echo "----------------------------------------------------------"
83
+
84
+ # Start StackMemory daemon
85
+ print_status "Starting StackMemory daemon..."
86
+ stackmemory-daemon start || print_warning "Daemon already running"
87
+
88
+ print_status "Running scenarios with StackMemory..."
89
+ node "$SCRIPT_DIR/ab-test-runner.js" scenario multi_session_feature || true
90
+
91
+ print_status "StackMemory testing complete"
92
+ }
93
+
94
+ # Generate comparison report
95
+ generate_report() {
96
+ echo ""
97
+ echo "Phase 3: Generating Comparison Report"
98
+ echo "----------------------------------------------------------"
99
+
100
+ print_status "Analyzing results..."
101
+ node "$SCRIPT_DIR/collect-metrics.js" report || true
102
+
103
+ if [ -f "$RESULTS_DIR/report.md" ]; then
104
+ print_status "Report generated: $RESULTS_DIR/report.md"
105
+ echo ""
106
+ echo "Summary:"
107
+ head -n 20 "$RESULTS_DIR/report.md"
108
+ else
109
+ print_warning "Report generation failed"
110
+ fi
111
+ }
112
+
113
+ # Quick test mode (for development)
114
+ quick_test() {
115
+ echo "Running quick test..."
116
+
117
+ # Test metric collection
118
+ print_status "Testing metrics collector..."
119
+ node "$SCRIPT_DIR/collect-metrics.js" start with_stackmemory
120
+
121
+ # Test A/B runner
122
+ print_status "Testing A/B test runner..."
123
+ node "$SCRIPT_DIR/ab-test-runner.js" list
124
+
125
+ print_status "Quick test complete"
126
+ }
127
+
128
+ # Main execution
129
+ main() {
130
+ case "${1:-full}" in
131
+ quick)
132
+ check_stackmemory
133
+ init_test_env
134
+ quick_test
135
+ ;;
136
+ baseline)
137
+ check_stackmemory
138
+ init_test_env
139
+ run_baseline
140
+ ;;
141
+ stackmemory)
142
+ check_stackmemory
143
+ init_test_env
144
+ run_with_stackmemory
145
+ ;;
146
+ report)
147
+ generate_report
148
+ ;;
149
+ full)
150
+ check_stackmemory
151
+ init_test_env
152
+ run_baseline
153
+ run_with_stackmemory
154
+ generate_report
155
+ ;;
156
+ *)
157
+ echo "Usage: $0 [quick|baseline|stackmemory|report|full]"
158
+ echo ""
159
+ echo "Commands:"
160
+ echo " quick - Run quick validation tests"
161
+ echo " baseline - Run baseline tests without StackMemory"
162
+ echo " stackmemory - Run tests with StackMemory enabled"
163
+ echo " report - Generate comparison report"
164
+ echo " full - Run complete test suite (default)"
165
+ exit 1
166
+ ;;
167
+ esac
168
+ }
169
+
170
+ # Run main function
171
+ main "$@"
172
+
173
+ echo ""
174
+ echo "=================================================="
175
+ echo "Testing Complete"
176
+ echo "=================================================="