@stackmemoryai/stackmemory 0.3.17 → 0.3.18

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 (212) hide show
  1. package/dist/cli/commands/skills.js +15 -2
  2. package/dist/cli/commands/skills.js.map +2 -2
  3. package/dist/cli/index.js +113 -834
  4. package/dist/cli/index.js.map +3 -3
  5. package/dist/core/context/dual-stack-manager.js +1 -1
  6. package/dist/core/context/dual-stack-manager.js.map +1 -1
  7. package/dist/core/context/frame-manager.js +3 -0
  8. package/dist/core/context/frame-manager.js.map +2 -2
  9. package/dist/integrations/claude-code/subagent-client.js +106 -3
  10. package/dist/integrations/claude-code/subagent-client.js.map +2 -2
  11. package/dist/servers/railway/config.js +51 -0
  12. package/dist/servers/railway/config.js.map +7 -0
  13. package/dist/servers/railway/index-enhanced.js +156 -0
  14. package/dist/servers/railway/index-enhanced.js.map +7 -0
  15. package/dist/servers/railway/minimal.js +48 -3
  16. package/dist/servers/railway/minimal.js.map +2 -2
  17. package/dist/servers/railway/storage-test.js +455 -0
  18. package/dist/servers/railway/storage-test.js.map +7 -0
  19. package/dist/skills/claude-skills.js +13 -12
  20. package/dist/skills/claude-skills.js.map +2 -2
  21. package/dist/skills/recursive-agent-orchestrator.js +27 -18
  22. package/dist/skills/recursive-agent-orchestrator.js.map +2 -2
  23. package/dist/skills/unified-rlm-orchestrator.js.map +2 -2
  24. package/package.json +6 -18
  25. package/scripts/README-TESTING.md +186 -0
  26. package/scripts/analyze-cli-security.js +288 -0
  27. package/scripts/archive/add-phase-tasks-to-linear.js +163 -0
  28. package/scripts/archive/analyze-linear-duplicates.js +214 -0
  29. package/scripts/archive/analyze-remaining-duplicates.js +230 -0
  30. package/scripts/archive/analyze-sta-duplicates.js +292 -0
  31. package/scripts/archive/analyze-sta-graphql.js +399 -0
  32. package/scripts/archive/cancel-duplicate-tasks.ts +246 -0
  33. package/scripts/archive/check-all-duplicates.ts +419 -0
  34. package/scripts/archive/clean-duplicate-tasks.js +114 -0
  35. package/scripts/archive/cleanup-duplicate-tasks.ts +286 -0
  36. package/scripts/archive/create-phase-tasks.js +387 -0
  37. package/scripts/archive/delete-linear-duplicates.js +182 -0
  38. package/scripts/archive/delete-remaining-duplicates.js +158 -0
  39. package/scripts/archive/delete-sta-duplicates.js +201 -0
  40. package/scripts/archive/delete-sta-oauth.js +201 -0
  41. package/scripts/archive/export-sta-tasks.js +62 -0
  42. package/scripts/archive/install-auto-sync.js +266 -0
  43. package/scripts/archive/install-chromadb-hooks.sh +133 -0
  44. package/scripts/archive/install-enhanced-clear-hooks.sh +431 -0
  45. package/scripts/archive/install-post-task-hooks.sh +289 -0
  46. package/scripts/archive/install-stackmemory-hooks.sh +420 -0
  47. package/scripts/archive/merge-linear-duplicates-safe.ts +362 -0
  48. package/scripts/archive/merge-linear-duplicates.ts +180 -0
  49. package/scripts/archive/remove-sta-tasks.js +70 -0
  50. package/scripts/archive/setup-background-sync.sh +168 -0
  51. package/scripts/archive/setup-claude-auto-triggers.sh +181 -0
  52. package/scripts/archive/setup-claude-autostart.sh +305 -0
  53. package/scripts/archive/setup-git-hooks.sh +25 -0
  54. package/scripts/archive/setup-linear-oauth.sh +46 -0
  55. package/scripts/archive/setup-mcp.sh +113 -0
  56. package/scripts/archive/setup-railway-deployment.sh +81 -0
  57. package/scripts/auto-handoff.sh +262 -0
  58. package/scripts/background-sync-manager.js +416 -0
  59. package/scripts/benchmark-performance.ts +57 -0
  60. package/scripts/check-redis.ts +48 -0
  61. package/scripts/chromadb-auto-loader.sh +128 -0
  62. package/scripts/chromadb-context-loader.js +479 -0
  63. package/scripts/claude-chromadb-hook.js +460 -0
  64. package/scripts/claude-code-wrapper.sh +66 -0
  65. package/scripts/claude-linear-skill.js +455 -0
  66. package/scripts/claude-pre-commit.sh +302 -0
  67. package/scripts/claude-sm-autostart.js +532 -0
  68. package/scripts/claude-sm-setup.sh +367 -0
  69. package/scripts/claude-with-chromadb.sh +69 -0
  70. package/scripts/claude-worktree-manager.sh +323 -0
  71. package/scripts/claude-worktree-monitor.sh +371 -0
  72. package/scripts/claude-worktree-setup.sh +327 -0
  73. package/scripts/clean-linear-backlog.js +273 -0
  74. package/scripts/cleanup-old-sessions.sh +57 -0
  75. package/scripts/codex-wrapper.sh +88 -0
  76. package/scripts/create-sandbox.sh +269 -0
  77. package/scripts/debug-linear-update.js +174 -0
  78. package/scripts/delete-linear-tasks.js +167 -0
  79. package/scripts/deploy.sh +89 -0
  80. package/scripts/deployment/railway.sh +352 -0
  81. package/scripts/deployment/test-deployment.js +194 -0
  82. package/scripts/detect-and-rehydrate.js +162 -0
  83. package/scripts/detect-and-rehydrate.mjs +165 -0
  84. package/scripts/development/create-demo-tasks.js +143 -0
  85. package/scripts/development/debug-frame-test.js +16 -0
  86. package/scripts/development/demo-auto-sync.js +128 -0
  87. package/scripts/development/fix-all-imports.js +213 -0
  88. package/scripts/development/fix-imports.js +229 -0
  89. package/scripts/development/fix-lint-loop.cjs +103 -0
  90. package/scripts/development/fix-project-id.ts +161 -0
  91. package/scripts/development/fix-strict-mode-issues.ts +291 -0
  92. package/scripts/development/reorganize-structure.sh +228 -0
  93. package/scripts/development/test-persistence-direct.js +148 -0
  94. package/scripts/development/test-persistence.js +114 -0
  95. package/scripts/development/test-tasks.js +93 -0
  96. package/scripts/development/update-imports.js +212 -0
  97. package/scripts/fetch-linear-status.js +125 -0
  98. package/scripts/git-hooks/README.md +310 -0
  99. package/scripts/git-hooks/branch-context-manager.sh +342 -0
  100. package/scripts/git-hooks/post-checkout-stackmemory.sh +63 -0
  101. package/scripts/git-hooks/post-commit-stackmemory.sh +305 -0
  102. package/scripts/git-hooks/pre-commit-stackmemory.sh +275 -0
  103. package/scripts/hooks/cleanup-shell.sh +130 -0
  104. package/scripts/hooks/task-complete.sh +114 -0
  105. package/scripts/initialize.ts +129 -0
  106. package/scripts/install-claude-hooks-auto.js +104 -0
  107. package/scripts/install-claude-hooks.sh +133 -0
  108. package/scripts/install-global.sh +296 -0
  109. package/scripts/install.sh +235 -0
  110. package/scripts/linear-auto-sync.js +262 -0
  111. package/scripts/linear-auto-sync.sh +161 -0
  112. package/scripts/linear-sync-daemon.js +150 -0
  113. package/scripts/linear-task-review.js +237 -0
  114. package/scripts/list-linear-tasks.ts +178 -0
  115. package/scripts/mcp-proxy.js +66 -0
  116. package/scripts/opencode-wrapper.sh +85 -0
  117. package/scripts/publish-local.js +74 -0
  118. package/scripts/query-chromadb.ts +201 -0
  119. package/scripts/railway-env-setup.sh +39 -0
  120. package/scripts/reconcile-local-tasks.js +170 -0
  121. package/scripts/recreate-frames-db.js +89 -0
  122. package/scripts/setup/claude-integration.js +138 -0
  123. package/scripts/setup/configure-alias.js +125 -0
  124. package/scripts/setup/configure-codex-alias.js +161 -0
  125. package/scripts/setup/configure-opencode-alias.js +175 -0
  126. package/scripts/setup-claude-integration.js +204 -0
  127. package/scripts/setup-claude-integration.sh +183 -0
  128. package/scripts/setup.sh +31 -0
  129. package/scripts/show-linear-summary.ts +172 -0
  130. package/scripts/stackmemory-auto-handoff.sh +231 -0
  131. package/scripts/stackmemory-daemon.sh +40 -0
  132. package/scripts/start-linear-sync-daemon.sh +141 -0
  133. package/scripts/start-temporal-paradox.sh +214 -0
  134. package/scripts/status.ts +159 -0
  135. package/scripts/sync-and-clean-tasks.js +258 -0
  136. package/scripts/sync-frames-from-railway.js +228 -0
  137. package/scripts/sync-linear-graphql.js +303 -0
  138. package/scripts/sync-linear-tasks.js +186 -0
  139. package/scripts/test-auto-triggers.sh +57 -0
  140. package/scripts/test-browser-mcp.js +74 -0
  141. package/scripts/test-chromadb-full.js +115 -0
  142. package/scripts/test-chromadb-hooks.sh +28 -0
  143. package/scripts/test-chromadb-sync.ts +245 -0
  144. package/scripts/test-cli-security.js +293 -0
  145. package/scripts/test-hooks-persistence.sh +220 -0
  146. package/scripts/test-installation-scenarios.sh +359 -0
  147. package/scripts/test-installation.sh +224 -0
  148. package/scripts/test-mcp.js +163 -0
  149. package/scripts/test-pre-publish-quick.sh +75 -0
  150. package/scripts/test-quality-gates.sh +263 -0
  151. package/scripts/test-railway-db.js +222 -0
  152. package/scripts/test-redis-storage.ts +490 -0
  153. package/scripts/test-rlm-basic.sh +122 -0
  154. package/scripts/test-rlm-comprehensive.sh +260 -0
  155. package/scripts/test-rlm-e2e.sh +268 -0
  156. package/scripts/test-rlm-simple.js +90 -0
  157. package/scripts/test-rlm.js +110 -0
  158. package/scripts/test-session-handoff.sh +165 -0
  159. package/scripts/test-shell-integration.sh +275 -0
  160. package/scripts/testing/ab-test-runner.ts +508 -0
  161. package/scripts/testing/collect-metrics.ts +457 -0
  162. package/scripts/testing/quick-effectiveness-demo.js +187 -0
  163. package/scripts/testing/real-performance-test.js +422 -0
  164. package/scripts/testing/run-effectiveness-tests.sh +176 -0
  165. package/scripts/testing/scripts/testing/ab-test-runner.js +363 -0
  166. package/scripts/testing/scripts/testing/collect-metrics.js +292 -0
  167. package/scripts/testing/simple-effectiveness-test.js +310 -0
  168. package/scripts/testing/src/core/context/context-bridge.js +253 -0
  169. package/scripts/testing/src/core/context/frame-manager.js +746 -0
  170. package/scripts/testing/src/core/context/shared-context-layer.js +437 -0
  171. package/scripts/testing/src/core/database/database-adapter.js +54 -0
  172. package/scripts/testing/src/core/errors/index.js +291 -0
  173. package/scripts/testing/src/core/errors/recovery.js +268 -0
  174. package/scripts/testing/src/core/monitoring/logger.js +145 -0
  175. package/scripts/testing/src/core/retrieval/context-retriever.js +516 -0
  176. package/scripts/testing/src/core/session/index.js +1 -0
  177. package/scripts/testing/src/core/session/session-manager.js +323 -0
  178. package/scripts/testing/src/core/trace/cli-trace-wrapper.js +140 -0
  179. package/scripts/testing/src/core/trace/db-trace-wrapper.js +251 -0
  180. package/scripts/testing/src/core/trace/debug-trace.js +398 -0
  181. package/scripts/testing/src/core/trace/index.js +120 -0
  182. package/scripts/testing/src/core/trace/linear-api-wrapper.js +204 -0
  183. package/scripts/update-linear-status.js +268 -0
  184. package/scripts/update-linear-tasks-fixed.js +284 -0
  185. package/templates/claude-hooks/hooks.json +5 -0
  186. package/templates/claude-hooks/on-clear.js +56 -0
  187. package/templates/claude-hooks/on-startup.js +56 -0
  188. package/templates/claude-hooks/tool-use-trace.js +67 -0
  189. package/dist/features/tui/components/analytics-panel.js +0 -157
  190. package/dist/features/tui/components/analytics-panel.js.map +0 -7
  191. package/dist/features/tui/components/frame-visualizer.js +0 -377
  192. package/dist/features/tui/components/frame-visualizer.js.map +0 -7
  193. package/dist/features/tui/components/pr-tracker.js +0 -135
  194. package/dist/features/tui/components/pr-tracker.js.map +0 -7
  195. package/dist/features/tui/components/session-monitor.js +0 -299
  196. package/dist/features/tui/components/session-monitor.js.map +0 -7
  197. package/dist/features/tui/components/subagent-fleet.js +0 -395
  198. package/dist/features/tui/components/subagent-fleet.js.map +0 -7
  199. package/dist/features/tui/components/task-board.js +0 -1139
  200. package/dist/features/tui/components/task-board.js.map +0 -7
  201. package/dist/features/tui/index.js +0 -408
  202. package/dist/features/tui/index.js.map +0 -7
  203. package/dist/features/tui/services/data-service.js +0 -641
  204. package/dist/features/tui/services/data-service.js.map +0 -7
  205. package/dist/features/tui/services/linear-task-reader.js +0 -102
  206. package/dist/features/tui/services/linear-task-reader.js.map +0 -7
  207. package/dist/features/tui/services/websocket-client.js +0 -162
  208. package/dist/features/tui/services/websocket-client.js.map +0 -7
  209. package/dist/features/tui/terminal-compat.js +0 -220
  210. package/dist/features/tui/terminal-compat.js.map +0 -7
  211. package/dist/features/tui/types.js +0 -1
  212. package/dist/features/tui/types.js.map +0 -7
@@ -0,0 +1,260 @@
1
+ #!/bin/bash
2
+
3
+ # Comprehensive RLM End-to-End Test
4
+ echo "============================================"
5
+ echo "Comprehensive RLM End-to-End Test"
6
+ echo "Testing all RLM orchestrator capabilities"
7
+ echo "============================================"
8
+ echo ""
9
+
10
+ # Colors for output
11
+ GREEN='\033[0;32m'
12
+ RED='\033[0;31m'
13
+ YELLOW='\033[1;33m'
14
+ BLUE='\033[0;34m'
15
+ NC='\033[0m'
16
+
17
+ # Results tracking
18
+ TOTAL_TESTS=0
19
+ PASSED_TESTS=0
20
+ FAILED_TESTS=0
21
+
22
+ # Test function
23
+ test_rlm() {
24
+ local test_name="$1"
25
+ local test_input="$2"
26
+ local check_for="$3"
27
+
28
+ echo -e "${BLUE}Testing: $test_name${NC}"
29
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
30
+
31
+ OUTPUT=$(stackmemory skills rlm "$test_input" 2>&1)
32
+
33
+ if echo "$OUTPUT" | grep -q "$check_for"; then
34
+ echo -e "${GREEN} ✓ PASSED: Found '$check_for'${NC}"
35
+ PASSED_TESTS=$((PASSED_TESTS + 1))
36
+ return 0
37
+ else
38
+ echo -e "${RED} ✗ FAILED: Did not find '$check_for'${NC}"
39
+ FAILED_TESTS=$((FAILED_TESTS + 1))
40
+ return 1
41
+ fi
42
+ }
43
+
44
+ # Build the project
45
+ echo "Building project..."
46
+ npm run build > /dev/null 2>&1
47
+
48
+ echo ""
49
+ echo "Running comprehensive tests..."
50
+ echo "------------------------------"
51
+ echo ""
52
+
53
+ # Test 1: Basic execution
54
+ echo "1. Basic RLM Execution Tests"
55
+ echo "=============================="
56
+ test_rlm "Execution completion" "Write a simple function" "RLM execution completed"
57
+ test_rlm "Frame creation" "Create hello world" "Created frame"
58
+ test_rlm "Frame closure" "Simple task" "Closed frame"
59
+ test_rlm "Planning phase" "Design a feature" "planning subagent"
60
+ test_rlm "Review phase" "Review this code" "Review stage.*complete"
61
+ test_rlm "Quality check" "Optimize performance" "Quality threshold met"
62
+
63
+ echo ""
64
+ echo "2. Subagent Orchestration Tests"
65
+ echo "================================="
66
+ test_rlm "Planning agent" "Plan a complex feature" "Spawning planning subagent"
67
+ test_rlm "Review agent" "Review and improve code" "Spawning review subagent"
68
+ test_rlm "Mock response handling" "Generate tests" "Review stage 1 complete"
69
+
70
+ echo ""
71
+ echo "3. Multi-Stage Review Tests"
72
+ echo "============================="
73
+ OUTPUT=$(stackmemory skills rlm "Complex refactoring task" 2>&1)
74
+ echo "$OUTPUT" | grep -E "Review stage [0-9]" | while read -r line; do
75
+ echo -e "${GREEN} ✓ Found: $line${NC}"
76
+ done
77
+
78
+ echo ""
79
+ echo "4. Execution Metrics Tests"
80
+ echo "============================"
81
+ OUTPUT=$(stackmemory skills rlm "Create API endpoint" 2>&1)
82
+ echo -e "${BLUE}Checking metrics...${NC}"
83
+
84
+ if echo "$OUTPUT" | grep -q "Total tokens:"; then
85
+ echo -e "${GREEN} ✓ Token tracking present${NC}"
86
+ PASSED_TESTS=$((PASSED_TESTS + 1))
87
+ else
88
+ echo -e "${RED} ✗ Token tracking missing${NC}"
89
+ FAILED_TESTS=$((FAILED_TESTS + 1))
90
+ fi
91
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
92
+
93
+ if echo "$OUTPUT" | grep -q "Estimated cost:"; then
94
+ echo -e "${GREEN} ✓ Cost estimation present${NC}"
95
+ PASSED_TESTS=$((PASSED_TESTS + 1))
96
+ else
97
+ echo -e "${RED} ✗ Cost estimation missing${NC}"
98
+ FAILED_TESTS=$((FAILED_TESTS + 1))
99
+ fi
100
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
101
+
102
+ if echo "$OUTPUT" | grep -q "Duration:"; then
103
+ echo -e "${GREEN} ✓ Duration tracking present${NC}"
104
+ PASSED_TESTS=$((PASSED_TESTS + 1))
105
+ else
106
+ echo -e "${RED} ✗ Duration tracking missing${NC}"
107
+ FAILED_TESTS=$((FAILED_TESTS + 1))
108
+ fi
109
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
110
+
111
+ echo ""
112
+ echo "5. Error Recovery Tests"
113
+ echo "========================"
114
+ test_rlm "Empty input handling" "" "RLM execution"
115
+ test_rlm "Retry mechanism" "Task with retries" "Retrying node"
116
+
117
+ echo ""
118
+ echo "6. Complex Feature Tests"
119
+ echo "========================="
120
+ # Test with a complex multi-line feature request
121
+ COMPLEX_FEATURE=$(cat <<'EOF'
122
+ Create a complete user authentication system with:
123
+ - JWT token generation
124
+ - Password hashing with bcrypt
125
+ - Email verification
126
+ - Rate limiting
127
+ - Session management
128
+ - OAuth integration
129
+ EOF
130
+ )
131
+
132
+ OUTPUT=$(stackmemory skills rlm "$COMPLEX_FEATURE" 2>&1)
133
+ if echo "$OUTPUT" | grep -q "RLM execution completed"; then
134
+ echo -e "${GREEN} ✓ Complex feature handled${NC}"
135
+ PASSED_TESTS=$((PASSED_TESTS + 1))
136
+ else
137
+ echo -e "${RED} ✗ Complex feature failed${NC}"
138
+ FAILED_TESTS=$((FAILED_TESTS + 1))
139
+ fi
140
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
141
+
142
+ echo ""
143
+ echo "7. Improvements & Suggestions Tests"
144
+ echo "====================================="
145
+ OUTPUT=$(stackmemory skills rlm "Improve this function" 2>&1)
146
+ if echo "$OUTPUT" | grep -q "Improvements:"; then
147
+ echo -e "${GREEN} ✓ Improvements generated${NC}"
148
+ echo " Improvements found:"
149
+ echo "$OUTPUT" | grep -A 3 "Improvements:" | tail -3 | sed 's/^/ /'
150
+ PASSED_TESTS=$((PASSED_TESTS + 1))
151
+ else
152
+ echo -e "${RED} ✗ No improvements generated${NC}"
153
+ FAILED_TESTS=$((FAILED_TESTS + 1))
154
+ fi
155
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
156
+
157
+ echo ""
158
+ echo "8. Database Persistence Tests"
159
+ echo "=============================="
160
+ echo -e "${BLUE}Checking database operations...${NC}"
161
+
162
+ # Get initial frame count
163
+ INITIAL_STATUS=$(stackmemory status 2>&1)
164
+ INITIAL_FRAMES=$(echo "$INITIAL_STATUS" | grep -oE "Frames: [0-9]+" | awk '{print $2}' || echo "0")
165
+
166
+ # Execute a task
167
+ stackmemory skills rlm "Test task for persistence" > /dev/null 2>&1
168
+
169
+ # Get new frame count
170
+ FINAL_STATUS=$(stackmemory status 2>&1)
171
+ FINAL_FRAMES=$(echo "$FINAL_STATUS" | grep -oE "Frames: [0-9]+" | awk '{print $2}' || echo "0")
172
+
173
+ echo " Initial frames: ${INITIAL_FRAMES:-0}"
174
+ echo " Final frames: ${FINAL_FRAMES:-0}"
175
+
176
+ if [ "${FINAL_FRAMES:-0}" -ge "${INITIAL_FRAMES:-0}" ]; then
177
+ echo -e "${GREEN} ✓ Database operations working${NC}"
178
+ PASSED_TESTS=$((PASSED_TESTS + 1))
179
+ else
180
+ echo -e "${YELLOW} ⚠ Frame count decreased (cleanup may have occurred)${NC}"
181
+ fi
182
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
183
+
184
+ echo ""
185
+ echo "9. Performance Tests"
186
+ echo "===================="
187
+ echo -e "${BLUE}Testing execution speed...${NC}"
188
+
189
+ START_TIME=$(date +%s%N)
190
+ stackmemory skills rlm "Quick task" > /dev/null 2>&1
191
+ END_TIME=$(date +%s%N)
192
+ DURATION=$(( (END_TIME - START_TIME) / 1000000 ))
193
+
194
+ echo " Execution time: ${DURATION}ms"
195
+
196
+ if [ "$DURATION" -lt 5000 ]; then
197
+ echo -e "${GREEN} ✓ Fast execution (< 5 seconds)${NC}"
198
+ PASSED_TESTS=$((PASSED_TESTS + 1))
199
+ else
200
+ echo -e "${YELLOW} ⚠ Slow execution (> 5 seconds)${NC}"
201
+ fi
202
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
203
+
204
+ echo ""
205
+ echo "10. Integration Tests"
206
+ echo "====================="
207
+ echo -e "${BLUE}Testing full workflow...${NC}"
208
+
209
+ # Create a test file with multiple requirements
210
+ cat > /tmp/full-test.md << 'EOF'
211
+ # Complete Feature Implementation
212
+ Build a REST API with the following:
213
+ 1. User CRUD operations
214
+ 2. Authentication middleware
215
+ 3. Input validation
216
+ 4. Error handling
217
+ 5. Unit tests
218
+ 6. API documentation
219
+ EOF
220
+
221
+ OUTPUT=$(stackmemory skills rlm "$(cat /tmp/full-test.md)" 2>&1)
222
+
223
+ # Check for all major components
224
+ COMPONENTS=("planning" "review" "Quality" "Improvements" "RLM execution completed")
225
+ for component in "${COMPONENTS[@]}"; do
226
+ TOTAL_TESTS=$((TOTAL_TESTS + 1))
227
+ if echo "$OUTPUT" | grep -q "$component"; then
228
+ echo -e "${GREEN} ✓ $component found${NC}"
229
+ PASSED_TESTS=$((PASSED_TESTS + 1))
230
+ else
231
+ echo -e "${RED} ✗ $component missing${NC}"
232
+ FAILED_TESTS=$((FAILED_TESTS + 1))
233
+ fi
234
+ done
235
+
236
+ # Clean up
237
+ rm -f /tmp/full-test.md
238
+
239
+ echo ""
240
+ echo "============================================"
241
+ echo "Test Summary"
242
+ echo "============================================"
243
+ echo -e "Total tests run: ${TOTAL_TESTS}"
244
+ echo -e "${GREEN}Tests passed: ${PASSED_TESTS}${NC}"
245
+ echo -e "${RED}Tests failed: ${FAILED_TESTS}${NC}"
246
+
247
+ SUCCESS_RATE=$(( (PASSED_TESTS * 100) / TOTAL_TESTS ))
248
+ echo -e "Success rate: ${SUCCESS_RATE}%"
249
+
250
+ echo ""
251
+ if [ "$FAILED_TESTS" -eq 0 ]; then
252
+ echo -e "${GREEN}✨ All tests passed! RLM system is fully operational.${NC}"
253
+ exit 0
254
+ elif [ "$SUCCESS_RATE" -ge 80 ]; then
255
+ echo -e "${YELLOW}⚠️ Most tests passed (${SUCCESS_RATE}%). System is mostly operational.${NC}"
256
+ exit 0
257
+ else
258
+ echo -e "${RED}❌ Too many failures (${SUCCESS_RATE}% success). System needs attention.${NC}"
259
+ exit 1
260
+ fi
@@ -0,0 +1,268 @@
1
+ #!/bin/bash
2
+
3
+ # StackMemory RLM End-to-End Test Script
4
+ # Tests all aspects of the RLM orchestrator system
5
+
6
+ set -e
7
+
8
+ echo "========================================="
9
+ echo "StackMemory RLM End-to-End Test Suite"
10
+ echo "========================================="
11
+ echo ""
12
+
13
+ # Colors for output
14
+ RED='\033[0;31m'
15
+ GREEN='\033[0;32m'
16
+ YELLOW='\033[1;33m'
17
+ NC='\033[0m' # No Color
18
+
19
+ # Test counter
20
+ TESTS_PASSED=0
21
+ TESTS_FAILED=0
22
+
23
+ # Function to run a test
24
+ run_test() {
25
+ local test_name="$1"
26
+ local test_command="$2"
27
+
28
+ echo -e "${YELLOW}Running test: $test_name${NC}"
29
+
30
+ if eval "$test_command" > /tmp/rlm-test-output.txt 2>&1; then
31
+ echo -e "${GREEN}✓ PASSED: $test_name${NC}"
32
+ ((TESTS_PASSED++))
33
+ return 0
34
+ else
35
+ echo -e "${RED}✗ FAILED: $test_name${NC}"
36
+ echo "Error output:"
37
+ tail -n 20 /tmp/rlm-test-output.txt
38
+ ((TESTS_FAILED++))
39
+ return 1
40
+ fi
41
+ }
42
+
43
+ # Function to check output contains string
44
+ check_output() {
45
+ local search_string="$1"
46
+ if grep -q "$search_string" /tmp/rlm-test-output.txt; then
47
+ return 0
48
+ else
49
+ echo "Expected output not found: $search_string"
50
+ return 1
51
+ fi
52
+ }
53
+
54
+ # Build the project first
55
+ echo "Building project..."
56
+ npm run build > /dev/null 2>&1
57
+
58
+ echo ""
59
+ echo "Starting RLM tests..."
60
+ echo ""
61
+
62
+ # Test 1: Simple feature request
63
+ echo "Test 1: Simple Feature Implementation"
64
+ cat > /tmp/test-simple.md << 'EOF'
65
+ # Simple Calculator Function
66
+ Create a function that adds two numbers together.
67
+ Requirements:
68
+ - Function name: addNumbers
69
+ - Takes two parameters: a and b
70
+ - Returns the sum
71
+ - Include type checking
72
+ EOF
73
+
74
+ run_test "Simple feature execution" "stackmemory skills rlm \"\$(cat /tmp/test-simple.md)\" 2>&1"
75
+ if [ $? -eq 0 ]; then
76
+ run_test "Simple feature completion" "check_output 'RLM execution completed'"
77
+ run_test "Simple feature frames" "check_output 'Created frame'"
78
+ run_test "Simple feature planning" "check_output 'planning subagent'"
79
+ run_test "Simple feature review" "check_output 'Review stage.*complete'"
80
+ fi
81
+
82
+ # Test 2: Complex API feature
83
+ echo ""
84
+ echo "Test 2: Complex API Implementation"
85
+ cat > /tmp/test-api.md << 'EOF'
86
+ # REST API for Task Management
87
+ Create a complete REST API for task management:
88
+ - GET /tasks - List all tasks with pagination
89
+ - GET /tasks/:id - Get single task
90
+ - POST /tasks - Create task with validation
91
+ - PUT /tasks/:id - Update task
92
+ - DELETE /tasks/:id - Soft delete task
93
+ Requirements:
94
+ - Express.js with TypeScript
95
+ - Input validation using Joi or Zod
96
+ - Error handling middleware
97
+ - Unit tests with Jest
98
+ - API documentation
99
+ EOF
100
+
101
+ run_test "Complex API execution" "stackmemory skills rlm \"\$(cat /tmp/test-api.md)\""
102
+ if [ $? -eq 0 ]; then
103
+ run_test "Complex API planning phase" "check_output 'Spawning planning subagent'"
104
+ run_test "Complex API review stage" "check_output 'Review stage.*complete'"
105
+ fi
106
+
107
+ # Test 3: Refactoring request
108
+ echo ""
109
+ echo "Test 3: Code Refactoring"
110
+ cat > /tmp/test-refactor.md << 'EOF'
111
+ # Refactor Legacy Code
112
+ Refactor the following patterns:
113
+ - Convert callbacks to async/await
114
+ - Extract common logic into utilities
115
+ - Add proper error handling
116
+ - Improve variable naming
117
+ - Add TypeScript types
118
+ EOF
119
+
120
+ run_test "Refactoring execution" "stackmemory skills rlm \"\$(cat /tmp/test-refactor.md)\""
121
+
122
+ # Test 4: Test generation
123
+ echo ""
124
+ echo "Test 4: Test Generation"
125
+ cat > /tmp/test-generate.md << 'EOF'
126
+ # Generate Comprehensive Test Suite
127
+ Create tests for a user authentication module:
128
+ - Unit tests for validation logic
129
+ - Integration tests for API endpoints
130
+ - Mock external services
131
+ - Test error scenarios
132
+ - Achieve 90% coverage
133
+ EOF
134
+
135
+ run_test "Test generation execution" "stackmemory skills rlm \"\$(cat /tmp/test-generate.md)\""
136
+ if [ $? -eq 0 ]; then
137
+ run_test "Test generation quality check" "check_output 'Quality threshold met'"
138
+ fi
139
+
140
+ # Test 5: Documentation task
141
+ echo ""
142
+ echo "Test 5: Documentation Generation"
143
+ cat > /tmp/test-docs.md << 'EOF'
144
+ # API Documentation
145
+ Generate comprehensive documentation:
146
+ - API endpoint descriptions
147
+ - Request/response examples
148
+ - Authentication details
149
+ - Error codes
150
+ - Usage examples
151
+ EOF
152
+
153
+ run_test "Documentation execution" "stackmemory skills rlm \"\$(cat /tmp/test-docs.md)\""
154
+
155
+ # Test 6: Performance optimization
156
+ echo ""
157
+ echo "Test 6: Performance Optimization"
158
+ cat > /tmp/test-perf.md << 'EOF'
159
+ # Optimize Database Queries
160
+ Improve performance:
161
+ - Add appropriate indexes
162
+ - Optimize N+1 queries
163
+ - Implement caching layer
164
+ - Add query pagination
165
+ - Profile slow queries
166
+ EOF
167
+
168
+ run_test "Performance optimization execution" "stackmemory skills rlm \"\$(cat /tmp/test-perf.md)\""
169
+
170
+ # Test 7: Security review
171
+ echo ""
172
+ echo "Test 7: Security Review"
173
+ cat > /tmp/test-security.md << 'EOF'
174
+ # Security Audit
175
+ Review and fix security issues:
176
+ - SQL injection prevention
177
+ - XSS protection
178
+ - CSRF tokens
179
+ - Input sanitization
180
+ - Authentication checks
181
+ EOF
182
+
183
+ run_test "Security review execution" "stackmemory skills rlm \"\$(cat /tmp/test-security.md)\""
184
+
185
+ # Test 8: Database persistence
186
+ echo ""
187
+ echo "Test 8: Database Frame Persistence"
188
+ run_test "Check frame persistence" "stackmemory status | grep -E 'Frames: [0-9]+'"
189
+
190
+ # Test 9: Parallel execution test
191
+ echo ""
192
+ echo "Test 9: Parallel Task Execution"
193
+ cat > /tmp/test-parallel.md << 'EOF'
194
+ # Multiple Independent Tasks
195
+ Execute these tasks in parallel:
196
+ 1. Generate user model
197
+ 2. Create API routes
198
+ 3. Write test cases
199
+ 4. Setup database schema
200
+ 5. Create documentation
201
+ EOF
202
+
203
+ run_test "Parallel execution" "stackmemory skills rlm \"\$(cat /tmp/test-parallel.md)\""
204
+
205
+ # Test 10: Error recovery
206
+ echo ""
207
+ echo "Test 10: Error Recovery"
208
+ cat > /tmp/test-error.md << 'EOF'
209
+ # Handle Errors Gracefully
210
+ This has some problematic requirements:
211
+ - Use undefined library XYZ123
212
+ - Connect to non-existent service
213
+ - Still produce meaningful output
214
+ EOF
215
+
216
+ run_test "Error recovery execution" "stackmemory skills rlm \"\$(cat /tmp/test-error.md)\""
217
+
218
+ # Test 11: Quality threshold testing
219
+ echo ""
220
+ echo "Test 11: Quality Threshold"
221
+ run_test "Quality threshold check" "stackmemory skills rlm \"Write a hello world function\" | grep -E 'Quality threshold met: .* >= 0.85'"
222
+
223
+ # Test 12: Token and cost tracking
224
+ echo ""
225
+ echo "Test 12: Metrics Tracking"
226
+ run_test "Token tracking" "stackmemory skills rlm \"Create a simple function\" | grep -E 'Total tokens:'"
227
+ run_test "Cost estimation" "stackmemory skills rlm \"Create a simple function\" | grep -E 'Estimated cost:'"
228
+
229
+ # Test 13: Subagent types
230
+ echo ""
231
+ echo "Test 13: All Subagent Types"
232
+ for agent in "planning" "code" "testing" "linting" "review" "improve" "context"; do
233
+ run_test "Subagent $agent" "stackmemory skills rlm \"Task requiring $agent\" | grep -i \"$agent\""
234
+ done
235
+
236
+ # Test 14: Frame lifecycle
237
+ echo ""
238
+ echo "Test 14: Frame Lifecycle"
239
+ OUTPUT=$(stackmemory skills rlm "Quick task" 2>&1)
240
+ echo "$OUTPUT" > /tmp/rlm-test-output.txt
241
+ run_test "Frame created" "check_output 'Created frame'"
242
+ run_test "Frame closed" "check_output 'Closed frame'"
243
+
244
+ # Test 15: Mock mode verification
245
+ echo ""
246
+ echo "Test 15: Mock Mode Active"
247
+ run_test "Mock mode enabled" "stackmemory skills rlm \"Test task\" | grep -E 'mockMode: true|Mock .* subagent completed successfully'"
248
+
249
+ # Clean up test files
250
+ rm -f /tmp/test-*.md
251
+ rm -f /tmp/rlm-test-output.txt
252
+
253
+ # Summary
254
+ echo ""
255
+ echo "========================================="
256
+ echo "Test Results Summary"
257
+ echo "========================================="
258
+ echo -e "${GREEN}Tests Passed: $TESTS_PASSED${NC}"
259
+ echo -e "${RED}Tests Failed: $TESTS_FAILED${NC}"
260
+ echo ""
261
+
262
+ if [ $TESTS_FAILED -eq 0 ]; then
263
+ echo -e "${GREEN}✓ All tests passed successfully!${NC}"
264
+ exit 0
265
+ else
266
+ echo -e "${RED}✗ Some tests failed. Please review the output above.${NC}"
267
+ exit 1
268
+ fi
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+
3
+ import 'dotenv/config';
4
+ import { ClaudeCodeSubagentClient } from '../dist/integrations/claude-code/subagent-client.js';
5
+
6
+ async function testRLMSimple() {
7
+ console.log('🚀 Testing RLM Subagent Client (Simple Mode)...\n');
8
+
9
+ try {
10
+ // Initialize the subagent client
11
+ console.log('🤖 Creating Subagent Client...');
12
+ const client = new ClaudeCodeSubagentClient();
13
+
14
+ // Test with different subagent types
15
+ const testCases = [
16
+ {
17
+ type: 'planning',
18
+ task: 'Create a simple hello world function',
19
+ context: { language: 'JavaScript', style: 'functional' }
20
+ },
21
+ {
22
+ type: 'code',
23
+ task: 'Implement a hello world function in JavaScript',
24
+ context: { requirements: 'Should return "Hello, World!"' }
25
+ },
26
+ {
27
+ type: 'testing',
28
+ task: 'Generate tests for a hello world function',
29
+ context: { code: 'function hello() { return "Hello, World!"; }' }
30
+ }
31
+ ];
32
+
33
+ for (const testCase of testCases) {
34
+ console.log(`\n📝 Testing ${testCase.type} subagent:`);
35
+ console.log(` Task: "${testCase.task}"`);
36
+
37
+ // Use mock mode for testing
38
+ const result = await client.mockTaskToolExecution({
39
+ type: testCase.type,
40
+ task: testCase.task,
41
+ context: testCase.context
42
+ });
43
+
44
+ if (result.success) {
45
+ console.log(` ✅ Success!`);
46
+ console.log(` ⏱️ Duration: ${result.duration}ms`);
47
+ console.log(` 📊 Tokens: ~${result.tokens || 'N/A'}`);
48
+
49
+ if (testCase.type === 'planning' && result.result?.tasks) {
50
+ console.log(` 📋 Generated ${result.result.tasks.length} subtasks`);
51
+ } else if (testCase.type === 'code' && result.result?.implementation) {
52
+ console.log(` 💻 Generated code (${result.result.implementation.length} chars)`);
53
+ } else if (testCase.type === 'testing' && result.result?.tests) {
54
+ console.log(` 🧪 Generated ${result.result.tests.length} test cases`);
55
+ }
56
+ } else {
57
+ console.log(` ❌ Failed: ${result.error}`);
58
+ }
59
+ }
60
+
61
+ console.log('\n\n🎯 Testing Parallel Execution:');
62
+ const parallelRequests = [
63
+ { type: 'code', task: 'Create add function', context: {} },
64
+ { type: 'code', task: 'Create subtract function', context: {} },
65
+ { type: 'testing', task: 'Test math functions', context: {} }
66
+ ];
67
+
68
+ console.log(` Executing ${parallelRequests.length} subagents in parallel...`);
69
+ const startTime = Date.now();
70
+
71
+ const results = await client.executeParallel(
72
+ parallelRequests.map(req => ({ ...req, type: req.type }))
73
+ );
74
+
75
+ const duration = Date.now() - startTime;
76
+ const successful = results.filter(r => r.success).length;
77
+
78
+ console.log(` ⏱️ Completed in ${duration}ms`);
79
+ console.log(` ✅ ${successful}/${results.length} successful`);
80
+
81
+ console.log('\n✨ Test complete!');
82
+
83
+ } catch (error) {
84
+ console.error('💥 Test failed:', error);
85
+ process.exit(1);
86
+ }
87
+ }
88
+
89
+ // Run the test
90
+ testRLMSimple().catch(console.error);