@stackmemoryai/stackmemory 0.3.16 → 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 (213) hide show
  1. package/README.md +48 -2
  2. package/dist/cli/commands/skills.js +15 -2
  3. package/dist/cli/commands/skills.js.map +2 -2
  4. package/dist/cli/index.js +113 -834
  5. package/dist/cli/index.js.map +3 -3
  6. package/dist/core/context/dual-stack-manager.js +1 -1
  7. package/dist/core/context/dual-stack-manager.js.map +1 -1
  8. package/dist/core/context/frame-manager.js +3 -0
  9. package/dist/core/context/frame-manager.js.map +2 -2
  10. package/dist/integrations/claude-code/subagent-client.js +106 -3
  11. package/dist/integrations/claude-code/subagent-client.js.map +2 -2
  12. package/dist/servers/railway/config.js +51 -0
  13. package/dist/servers/railway/config.js.map +7 -0
  14. package/dist/servers/railway/index-enhanced.js +156 -0
  15. package/dist/servers/railway/index-enhanced.js.map +7 -0
  16. package/dist/servers/railway/minimal.js +48 -3
  17. package/dist/servers/railway/minimal.js.map +2 -2
  18. package/dist/servers/railway/storage-test.js +455 -0
  19. package/dist/servers/railway/storage-test.js.map +7 -0
  20. package/dist/skills/claude-skills.js +13 -12
  21. package/dist/skills/claude-skills.js.map +2 -2
  22. package/dist/skills/recursive-agent-orchestrator.js +27 -18
  23. package/dist/skills/recursive-agent-orchestrator.js.map +2 -2
  24. package/dist/skills/unified-rlm-orchestrator.js.map +2 -2
  25. package/package.json +6 -18
  26. package/scripts/README-TESTING.md +186 -0
  27. package/scripts/analyze-cli-security.js +288 -0
  28. package/scripts/archive/add-phase-tasks-to-linear.js +163 -0
  29. package/scripts/archive/analyze-linear-duplicates.js +214 -0
  30. package/scripts/archive/analyze-remaining-duplicates.js +230 -0
  31. package/scripts/archive/analyze-sta-duplicates.js +292 -0
  32. package/scripts/archive/analyze-sta-graphql.js +399 -0
  33. package/scripts/archive/cancel-duplicate-tasks.ts +246 -0
  34. package/scripts/archive/check-all-duplicates.ts +419 -0
  35. package/scripts/archive/clean-duplicate-tasks.js +114 -0
  36. package/scripts/archive/cleanup-duplicate-tasks.ts +286 -0
  37. package/scripts/archive/create-phase-tasks.js +387 -0
  38. package/scripts/archive/delete-linear-duplicates.js +182 -0
  39. package/scripts/archive/delete-remaining-duplicates.js +158 -0
  40. package/scripts/archive/delete-sta-duplicates.js +201 -0
  41. package/scripts/archive/delete-sta-oauth.js +201 -0
  42. package/scripts/archive/export-sta-tasks.js +62 -0
  43. package/scripts/archive/install-auto-sync.js +266 -0
  44. package/scripts/archive/install-chromadb-hooks.sh +133 -0
  45. package/scripts/archive/install-enhanced-clear-hooks.sh +431 -0
  46. package/scripts/archive/install-post-task-hooks.sh +289 -0
  47. package/scripts/archive/install-stackmemory-hooks.sh +420 -0
  48. package/scripts/archive/merge-linear-duplicates-safe.ts +362 -0
  49. package/scripts/archive/merge-linear-duplicates.ts +180 -0
  50. package/scripts/archive/remove-sta-tasks.js +70 -0
  51. package/scripts/archive/setup-background-sync.sh +168 -0
  52. package/scripts/archive/setup-claude-auto-triggers.sh +181 -0
  53. package/scripts/archive/setup-claude-autostart.sh +305 -0
  54. package/scripts/archive/setup-git-hooks.sh +25 -0
  55. package/scripts/archive/setup-linear-oauth.sh +46 -0
  56. package/scripts/archive/setup-mcp.sh +113 -0
  57. package/scripts/archive/setup-railway-deployment.sh +81 -0
  58. package/scripts/auto-handoff.sh +262 -0
  59. package/scripts/background-sync-manager.js +416 -0
  60. package/scripts/benchmark-performance.ts +57 -0
  61. package/scripts/check-redis.ts +48 -0
  62. package/scripts/chromadb-auto-loader.sh +128 -0
  63. package/scripts/chromadb-context-loader.js +479 -0
  64. package/scripts/claude-chromadb-hook.js +460 -0
  65. package/scripts/claude-code-wrapper.sh +66 -0
  66. package/scripts/claude-linear-skill.js +455 -0
  67. package/scripts/claude-pre-commit.sh +302 -0
  68. package/scripts/claude-sm-autostart.js +532 -0
  69. package/scripts/claude-sm-setup.sh +367 -0
  70. package/scripts/claude-with-chromadb.sh +69 -0
  71. package/scripts/claude-worktree-manager.sh +323 -0
  72. package/scripts/claude-worktree-monitor.sh +371 -0
  73. package/scripts/claude-worktree-setup.sh +327 -0
  74. package/scripts/clean-linear-backlog.js +273 -0
  75. package/scripts/cleanup-old-sessions.sh +57 -0
  76. package/scripts/codex-wrapper.sh +88 -0
  77. package/scripts/create-sandbox.sh +269 -0
  78. package/scripts/debug-linear-update.js +174 -0
  79. package/scripts/delete-linear-tasks.js +167 -0
  80. package/scripts/deploy.sh +89 -0
  81. package/scripts/deployment/railway.sh +352 -0
  82. package/scripts/deployment/test-deployment.js +194 -0
  83. package/scripts/detect-and-rehydrate.js +162 -0
  84. package/scripts/detect-and-rehydrate.mjs +165 -0
  85. package/scripts/development/create-demo-tasks.js +143 -0
  86. package/scripts/development/debug-frame-test.js +16 -0
  87. package/scripts/development/demo-auto-sync.js +128 -0
  88. package/scripts/development/fix-all-imports.js +213 -0
  89. package/scripts/development/fix-imports.js +229 -0
  90. package/scripts/development/fix-lint-loop.cjs +103 -0
  91. package/scripts/development/fix-project-id.ts +161 -0
  92. package/scripts/development/fix-strict-mode-issues.ts +291 -0
  93. package/scripts/development/reorganize-structure.sh +228 -0
  94. package/scripts/development/test-persistence-direct.js +148 -0
  95. package/scripts/development/test-persistence.js +114 -0
  96. package/scripts/development/test-tasks.js +93 -0
  97. package/scripts/development/update-imports.js +212 -0
  98. package/scripts/fetch-linear-status.js +125 -0
  99. package/scripts/git-hooks/README.md +310 -0
  100. package/scripts/git-hooks/branch-context-manager.sh +342 -0
  101. package/scripts/git-hooks/post-checkout-stackmemory.sh +63 -0
  102. package/scripts/git-hooks/post-commit-stackmemory.sh +305 -0
  103. package/scripts/git-hooks/pre-commit-stackmemory.sh +275 -0
  104. package/scripts/hooks/cleanup-shell.sh +130 -0
  105. package/scripts/hooks/task-complete.sh +114 -0
  106. package/scripts/initialize.ts +129 -0
  107. package/scripts/install-claude-hooks-auto.js +104 -0
  108. package/scripts/install-claude-hooks.sh +133 -0
  109. package/scripts/install-global.sh +296 -0
  110. package/scripts/install.sh +235 -0
  111. package/scripts/linear-auto-sync.js +262 -0
  112. package/scripts/linear-auto-sync.sh +161 -0
  113. package/scripts/linear-sync-daemon.js +150 -0
  114. package/scripts/linear-task-review.js +237 -0
  115. package/scripts/list-linear-tasks.ts +178 -0
  116. package/scripts/mcp-proxy.js +66 -0
  117. package/scripts/opencode-wrapper.sh +85 -0
  118. package/scripts/publish-local.js +74 -0
  119. package/scripts/query-chromadb.ts +201 -0
  120. package/scripts/railway-env-setup.sh +39 -0
  121. package/scripts/reconcile-local-tasks.js +170 -0
  122. package/scripts/recreate-frames-db.js +89 -0
  123. package/scripts/setup/claude-integration.js +138 -0
  124. package/scripts/setup/configure-alias.js +125 -0
  125. package/scripts/setup/configure-codex-alias.js +161 -0
  126. package/scripts/setup/configure-opencode-alias.js +175 -0
  127. package/scripts/setup-claude-integration.js +204 -0
  128. package/scripts/setup-claude-integration.sh +183 -0
  129. package/scripts/setup.sh +31 -0
  130. package/scripts/show-linear-summary.ts +172 -0
  131. package/scripts/stackmemory-auto-handoff.sh +231 -0
  132. package/scripts/stackmemory-daemon.sh +40 -0
  133. package/scripts/start-linear-sync-daemon.sh +141 -0
  134. package/scripts/start-temporal-paradox.sh +214 -0
  135. package/scripts/status.ts +159 -0
  136. package/scripts/sync-and-clean-tasks.js +258 -0
  137. package/scripts/sync-frames-from-railway.js +228 -0
  138. package/scripts/sync-linear-graphql.js +303 -0
  139. package/scripts/sync-linear-tasks.js +186 -0
  140. package/scripts/test-auto-triggers.sh +57 -0
  141. package/scripts/test-browser-mcp.js +74 -0
  142. package/scripts/test-chromadb-full.js +115 -0
  143. package/scripts/test-chromadb-hooks.sh +28 -0
  144. package/scripts/test-chromadb-sync.ts +245 -0
  145. package/scripts/test-cli-security.js +293 -0
  146. package/scripts/test-hooks-persistence.sh +220 -0
  147. package/scripts/test-installation-scenarios.sh +359 -0
  148. package/scripts/test-installation.sh +224 -0
  149. package/scripts/test-mcp.js +163 -0
  150. package/scripts/test-pre-publish-quick.sh +75 -0
  151. package/scripts/test-quality-gates.sh +263 -0
  152. package/scripts/test-railway-db.js +222 -0
  153. package/scripts/test-redis-storage.ts +490 -0
  154. package/scripts/test-rlm-basic.sh +122 -0
  155. package/scripts/test-rlm-comprehensive.sh +260 -0
  156. package/scripts/test-rlm-e2e.sh +268 -0
  157. package/scripts/test-rlm-simple.js +90 -0
  158. package/scripts/test-rlm.js +110 -0
  159. package/scripts/test-session-handoff.sh +165 -0
  160. package/scripts/test-shell-integration.sh +275 -0
  161. package/scripts/testing/ab-test-runner.ts +508 -0
  162. package/scripts/testing/collect-metrics.ts +457 -0
  163. package/scripts/testing/quick-effectiveness-demo.js +187 -0
  164. package/scripts/testing/real-performance-test.js +422 -0
  165. package/scripts/testing/run-effectiveness-tests.sh +176 -0
  166. package/scripts/testing/scripts/testing/ab-test-runner.js +363 -0
  167. package/scripts/testing/scripts/testing/collect-metrics.js +292 -0
  168. package/scripts/testing/simple-effectiveness-test.js +310 -0
  169. package/scripts/testing/src/core/context/context-bridge.js +253 -0
  170. package/scripts/testing/src/core/context/frame-manager.js +746 -0
  171. package/scripts/testing/src/core/context/shared-context-layer.js +437 -0
  172. package/scripts/testing/src/core/database/database-adapter.js +54 -0
  173. package/scripts/testing/src/core/errors/index.js +291 -0
  174. package/scripts/testing/src/core/errors/recovery.js +268 -0
  175. package/scripts/testing/src/core/monitoring/logger.js +145 -0
  176. package/scripts/testing/src/core/retrieval/context-retriever.js +516 -0
  177. package/scripts/testing/src/core/session/index.js +1 -0
  178. package/scripts/testing/src/core/session/session-manager.js +323 -0
  179. package/scripts/testing/src/core/trace/cli-trace-wrapper.js +140 -0
  180. package/scripts/testing/src/core/trace/db-trace-wrapper.js +251 -0
  181. package/scripts/testing/src/core/trace/debug-trace.js +398 -0
  182. package/scripts/testing/src/core/trace/index.js +120 -0
  183. package/scripts/testing/src/core/trace/linear-api-wrapper.js +204 -0
  184. package/scripts/update-linear-status.js +268 -0
  185. package/scripts/update-linear-tasks-fixed.js +284 -0
  186. package/templates/claude-hooks/hooks.json +5 -0
  187. package/templates/claude-hooks/on-clear.js +56 -0
  188. package/templates/claude-hooks/on-startup.js +56 -0
  189. package/templates/claude-hooks/tool-use-trace.js +67 -0
  190. package/dist/features/tui/components/analytics-panel.js +0 -157
  191. package/dist/features/tui/components/analytics-panel.js.map +0 -7
  192. package/dist/features/tui/components/frame-visualizer.js +0 -377
  193. package/dist/features/tui/components/frame-visualizer.js.map +0 -7
  194. package/dist/features/tui/components/pr-tracker.js +0 -135
  195. package/dist/features/tui/components/pr-tracker.js.map +0 -7
  196. package/dist/features/tui/components/session-monitor.js +0 -299
  197. package/dist/features/tui/components/session-monitor.js.map +0 -7
  198. package/dist/features/tui/components/subagent-fleet.js +0 -395
  199. package/dist/features/tui/components/subagent-fleet.js.map +0 -7
  200. package/dist/features/tui/components/task-board.js +0 -1139
  201. package/dist/features/tui/components/task-board.js.map +0 -7
  202. package/dist/features/tui/index.js +0 -408
  203. package/dist/features/tui/index.js.map +0 -7
  204. package/dist/features/tui/services/data-service.js +0 -641
  205. package/dist/features/tui/services/data-service.js.map +0 -7
  206. package/dist/features/tui/services/linear-task-reader.js +0 -102
  207. package/dist/features/tui/services/linear-task-reader.js.map +0 -7
  208. package/dist/features/tui/services/websocket-client.js +0 -162
  209. package/dist/features/tui/services/websocket-client.js.map +0 -7
  210. package/dist/features/tui/terminal-compat.js +0 -220
  211. package/dist/features/tui/terminal-compat.js.map +0 -7
  212. package/dist/features/tui/types.js +0 -1
  213. package/dist/features/tui/types.js.map +0 -7
@@ -0,0 +1,224 @@
1
+ #!/bin/bash
2
+ # StackMemory Pre-Publish Installation Test Suite
3
+ # Tests all installation aspects before npm publish
4
+
5
+ set -e # Exit on any error
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
9
+ TEST_DIR="/tmp/stackmemory-install-test"
10
+ PASS_COUNT=0
11
+ FAIL_COUNT=0
12
+ TOTAL_TESTS=0
13
+
14
+ # Colors for output
15
+ RED='\033[0;31m'
16
+ GREEN='\033[0;32m'
17
+ YELLOW='\033[1;33m'
18
+ BLUE='\033[0;34m'
19
+ NC='\033[0m' # No Color
20
+
21
+ # Logging functions
22
+ log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
23
+ log_success() { echo -e "${GREEN}[PASS]${NC} $1"; ((PASS_COUNT++)); ((TOTAL_TESTS++)); }
24
+ log_error() { echo -e "${RED}[FAIL]${NC} $1"; ((FAIL_COUNT++)); ((TOTAL_TESTS++)); }
25
+ log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
26
+
27
+ # Test runner function
28
+ run_test() {
29
+ local test_name="$1"
30
+ local test_command="$2"
31
+
32
+ log_info "Running: $test_name"
33
+
34
+ if eval "$test_command" > /tmp/test_output.log 2>&1; then
35
+ log_success "$test_name"
36
+ return 0
37
+ else
38
+ log_error "$test_name"
39
+ log_warn "Output: $(cat /tmp/test_output.log)"
40
+ return 1
41
+ fi
42
+ }
43
+
44
+ # Test functions
45
+ test_build_success() {
46
+ cd "$PROJECT_ROOT"
47
+ npm run build
48
+ }
49
+
50
+ test_cli_executable() {
51
+ cd "$PROJECT_ROOT"
52
+ node dist/cli/index.js --version > /dev/null
53
+ }
54
+
55
+ test_cli_help() {
56
+ cd "$PROJECT_ROOT"
57
+ node dist/cli/index.js --help | grep -q "Lossless memory runtime"
58
+ }
59
+
60
+ test_cli_commands() {
61
+ cd "$PROJECT_ROOT"
62
+ # Test basic commands don't crash
63
+ timeout 10s node dist/cli/index.js init --help > /dev/null
64
+ timeout 10s node dist/cli/index.js status --help > /dev/null
65
+ timeout 10s node dist/cli/index.js context --help > /dev/null
66
+ }
67
+
68
+ test_package_json_valid() {
69
+ cd "$PROJECT_ROOT"
70
+ # Check required fields exist
71
+ node -e "
72
+ const pkg = require('./package.json');
73
+ if (!pkg.name || !pkg.version || !pkg.bin || !pkg.main) {
74
+ process.exit(1);
75
+ }
76
+ if (!pkg.bin.stackmemory || !pkg.bin['codex-sm']) {
77
+ process.exit(1);
78
+ }
79
+ "
80
+ }
81
+
82
+ test_npm_pack() {
83
+ cd "$PROJECT_ROOT"
84
+ npm pack --dry-run > /dev/null
85
+ }
86
+
87
+ test_shell_integration_scripts() {
88
+ # Test shell integration files exist and are valid
89
+ [ -f "$HOME/.stackmemory/shell-integration.sh" ]
90
+ [ -f "$HOME/.stackmemory/shell-integration-consolidated.sh" ]
91
+
92
+ # Test they can be sourced without errors
93
+ bash -n "$HOME/.stackmemory/shell-integration.sh"
94
+ bash -n "$HOME/.stackmemory/shell-integration-consolidated.sh"
95
+ }
96
+
97
+ test_binaries_exist() {
98
+ # Test required binaries exist
99
+ [ -f "$HOME/.stackmemory/bin/stackmemory" ]
100
+ [ -x "$HOME/.stackmemory/bin/stackmemory" ]
101
+ [ -f "$HOME/.stackmemory/bin/stackmemory-daemon" ]
102
+ [ -x "$HOME/.stackmemory/bin/stackmemory-daemon" ]
103
+ [ -f "$HOME/.stackmemory/bin/stackmemory-monitor" ]
104
+ [ -x "$HOME/.stackmemory/bin/stackmemory-monitor" ]
105
+ [ -f "$HOME/.stackmemory/bin/sm-review" ]
106
+ [ -x "$HOME/.stackmemory/bin/sm-review" ]
107
+ }
108
+
109
+ test_binary_functionality() {
110
+ # Test each binary works
111
+ timeout 5s "$HOME/.stackmemory/bin/stackmemory" --version > /dev/null
112
+ timeout 5s "$HOME/.stackmemory/bin/stackmemory-daemon" status > /dev/null || true
113
+ timeout 5s "$HOME/.stackmemory/bin/stackmemory-monitor" config > /dev/null
114
+ timeout 5s "$HOME/.stackmemory/bin/sm-review" > /dev/null || true
115
+ }
116
+
117
+ test_fresh_install_simulation() {
118
+ # Create clean test environment
119
+ rm -rf "$TEST_DIR"
120
+ mkdir -p "$TEST_DIR"
121
+ cd "$TEST_DIR"
122
+
123
+ # Create a test package from current build
124
+ cd "$PROJECT_ROOT"
125
+ TARBALL=$(npm pack 2>/dev/null | tail -1)
126
+
127
+ # Test installation in clean environment
128
+ cd "$TEST_DIR"
129
+ npm init -y > /dev/null 2>&1
130
+ npm install "$PROJECT_ROOT/$TARBALL" > /dev/null 2>&1
131
+
132
+ # Test installed CLI works
133
+ timeout 5s ./node_modules/.bin/stackmemory --version > /dev/null
134
+
135
+ # Cleanup
136
+ cd "$PROJECT_ROOT"
137
+ rm -f "$TARBALL"
138
+ rm -rf "$TEST_DIR"
139
+ }
140
+
141
+ test_typescript_compilation() {
142
+ cd "$PROJECT_ROOT"
143
+ npx tsc --noEmit
144
+ }
145
+
146
+ test_lint_passes() {
147
+ cd "$PROJECT_ROOT"
148
+ npm run lint > /dev/null 2>&1 || true # Don't fail on lint warnings
149
+ }
150
+
151
+ test_dependencies_security() {
152
+ cd "$PROJECT_ROOT"
153
+ npm audit --audit-level=high
154
+ }
155
+
156
+ test_git_status_clean() {
157
+ cd "$PROJECT_ROOT"
158
+ # Ensure no uncommitted changes that could affect build
159
+ git diff --quiet && git diff --cached --quiet
160
+ }
161
+
162
+ # Main test execution
163
+ main() {
164
+ echo "============================================"
165
+ echo " StackMemory Pre-Publish Test Suite"
166
+ echo "============================================"
167
+ echo
168
+
169
+ log_info "Starting installation validation tests..."
170
+ echo
171
+
172
+ # Core build tests
173
+ echo "šŸ”Ø Build & Compilation Tests"
174
+ run_test "Build succeeds without errors" "test_build_success"
175
+ run_test "TypeScript compilation check" "test_typescript_compilation"
176
+ run_test "Lint check passes" "test_lint_passes"
177
+ echo
178
+
179
+ # CLI functionality tests
180
+ echo "⚔ CLI Functionality Tests"
181
+ run_test "CLI is executable" "test_cli_executable"
182
+ run_test "CLI help displays correctly" "test_cli_help"
183
+ run_test "CLI commands load without errors" "test_cli_commands"
184
+ echo
185
+
186
+ # Package validation
187
+ echo "šŸ“¦ Package Validation Tests"
188
+ run_test "package.json structure valid" "test_package_json_valid"
189
+ run_test "npm pack succeeds" "test_npm_pack"
190
+ run_test "Git status is clean" "test_git_status_clean"
191
+ echo
192
+
193
+ # Installation tests
194
+ echo "šŸ’¾ Installation Tests"
195
+ run_test "Shell integration scripts valid" "test_shell_integration_scripts"
196
+ run_test "Required binaries exist" "test_binaries_exist"
197
+ run_test "Binary functionality works" "test_binary_functionality"
198
+ run_test "Fresh install simulation" "test_fresh_install_simulation"
199
+ echo
200
+
201
+ # Security tests
202
+ echo "šŸ”’ Security Tests"
203
+ run_test "Dependencies security audit" "test_dependencies_security"
204
+ echo
205
+
206
+ # Results summary
207
+ echo "============================================"
208
+ echo " Test Results Summary"
209
+ echo "============================================"
210
+ echo -e "Total tests: ${TOTAL_TESTS}"
211
+ echo -e "${GREEN}Passed: ${PASS_COUNT}${NC}"
212
+ echo -e "${RED}Failed: ${FAIL_COUNT}${NC}"
213
+
214
+ if [ $FAIL_COUNT -eq 0 ]; then
215
+ echo -e "\n${GREEN}āœ… All tests passed! Ready for npm publish.${NC}"
216
+ exit 0
217
+ else
218
+ echo -e "\n${RED}āŒ Some tests failed. Please fix issues before publishing.${NC}"
219
+ exit 1
220
+ fi
221
+ }
222
+
223
+ # Run main function
224
+ main "$@"
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Test script for StackMemory MCP Server
5
+ * Simulates Claude Desktop MCP client
6
+ */
7
+
8
+ import { spawn } from 'child_process';
9
+ import { createInterface } from 'readline';
10
+
11
+ console.log('🧪 StackMemory MCP Test Client');
12
+ console.log('==============================\n');
13
+
14
+ // Start the MCP server
15
+ const server = spawn(
16
+ 'node',
17
+ ['dist/src/cli/cli.js', 'mcp-server', '--project', process.cwd()],
18
+ {
19
+ stdio: ['pipe', 'pipe', 'pipe'],
20
+ env: {
21
+ ...process.env,
22
+ LINEAR_API_KEY: process.env.LINEAR_API_KEY || '',
23
+ },
24
+ }
25
+ );
26
+
27
+ // Handle server output
28
+ const rl = createInterface({
29
+ input: server.stdout,
30
+ crlfDelay: Infinity,
31
+ });
32
+
33
+ rl.on('line', (line) => {
34
+ try {
35
+ const msg = JSON.parse(line);
36
+ console.log('šŸ“„ Server response:', JSON.stringify(msg, null, 2));
37
+ handleServerMessage(msg);
38
+ } catch (e) {
39
+ // Non-JSON output
40
+ if (line.trim()) {
41
+ console.log('šŸ“ Server output:', line);
42
+ }
43
+ }
44
+ });
45
+
46
+ // Handle server errors
47
+ server.stderr.on('data', (data) => {
48
+ const output = data.toString().trim();
49
+ if (output && !output.includes('MCP Server started')) {
50
+ console.error('āŒ Server error:', output);
51
+ }
52
+ });
53
+
54
+ // Handle server message
55
+ function handleServerMessage(msg) {
56
+ if (msg.method === 'notifications/initialized') {
57
+ console.log('\nāœ… Server initialized successfully!\n');
58
+ testTools();
59
+ }
60
+ }
61
+
62
+ // Send JSON-RPC message to server
63
+ function sendMessage(message) {
64
+ const json = JSON.stringify(message);
65
+ console.log('šŸ“¤ Sending:', json);
66
+ server.stdin.write(json + '\n');
67
+ }
68
+
69
+ // Initialize connection
70
+ console.log('\nšŸš€ Initializing MCP connection...\n');
71
+ sendMessage({
72
+ jsonrpc: '2.0',
73
+ method: 'initialize',
74
+ params: {
75
+ protocolVersion: '2024-11-05',
76
+ capabilities: {
77
+ roots: {
78
+ listChanged: true,
79
+ },
80
+ sampling: {},
81
+ },
82
+ clientInfo: {
83
+ name: 'test-client',
84
+ version: '1.0.0',
85
+ },
86
+ },
87
+ id: 1,
88
+ });
89
+
90
+ // Test available tools
91
+ async function testTools() {
92
+ console.log('šŸ“‹ Listing available tools...\n');
93
+
94
+ // List tools
95
+ sendMessage({
96
+ jsonrpc: '2.0',
97
+ method: 'tools/list',
98
+ params: {},
99
+ id: 2,
100
+ });
101
+
102
+ // Wait a bit then test save_context
103
+ setTimeout(() => {
104
+ console.log('\nšŸ”§ Testing save_context tool...\n');
105
+ sendMessage({
106
+ jsonrpc: '2.0',
107
+ method: 'tools/call',
108
+ params: {
109
+ name: 'save_context',
110
+ arguments: {
111
+ content: 'Test context from MCP test client',
112
+ importance: 0.8,
113
+ tags: ['test', 'mcp'],
114
+ },
115
+ },
116
+ id: 3,
117
+ });
118
+ }, 1000);
119
+
120
+ // Test load_context
121
+ setTimeout(() => {
122
+ console.log('\nšŸ”§ Testing load_context tool...\n');
123
+ sendMessage({
124
+ jsonrpc: '2.0',
125
+ method: 'tools/call',
126
+ params: {
127
+ name: 'load_context',
128
+ arguments: {
129
+ query: 'test',
130
+ limit: 5,
131
+ },
132
+ },
133
+ id: 4,
134
+ });
135
+ }, 2000);
136
+
137
+ // Test repo_status
138
+ setTimeout(() => {
139
+ console.log('\nšŸ”§ Testing repo_status tool...\n');
140
+ sendMessage({
141
+ jsonrpc: '2.0',
142
+ method: 'tools/call',
143
+ params: {
144
+ name: 'repo_status',
145
+ arguments: {},
146
+ },
147
+ id: 5,
148
+ });
149
+ }, 3000);
150
+
151
+ // Exit after tests
152
+ setTimeout(() => {
153
+ console.log('\nāœ… All tests completed!\n');
154
+ process.exit(0);
155
+ }, 5000);
156
+ }
157
+
158
+ // Handle process termination
159
+ process.on('SIGINT', () => {
160
+ console.log('\nšŸ‘‹ Shutting down...');
161
+ server.kill();
162
+ process.exit(0);
163
+ });
@@ -0,0 +1,75 @@
1
+ #!/bin/bash
2
+ # Quick Pre-Publish Test Suite
3
+ # Essential tests that must pass before npm publish
4
+
5
+ set -e
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
9
+
10
+ # Colors
11
+ GREEN='\033[0;32m'
12
+ RED='\033[0;31m'
13
+ BLUE='\033[0;34m'
14
+ NC='\033[0m'
15
+
16
+ log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
17
+ log_success() { echo -e "${GREEN}[PASS]${NC} $1"; }
18
+ log_error() { echo -e "${RED}[FAIL]${NC} $1"; exit 1; }
19
+
20
+ echo "============================================"
21
+ echo " StackMemory Quick Pre-Publish Tests"
22
+ echo "============================================"
23
+ echo
24
+
25
+ # Essential build test
26
+ log_info "Testing build..."
27
+ cd "$PROJECT_ROOT"
28
+ npm run build > /dev/null 2>&1 || log_error "Build failed"
29
+ log_success "Build succeeds"
30
+
31
+ # Essential CLI test
32
+ log_info "Testing CLI functionality..."
33
+ if node dist/cli/index.js --version > /dev/null 2>&1; then
34
+ log_success "CLI is executable"
35
+ else
36
+ log_error "CLI execution failed"
37
+ fi
38
+
39
+ # Package structure test
40
+ log_info "Testing package structure..."
41
+ npm pack --dry-run > /dev/null 2>&1 || log_error "npm pack failed"
42
+ log_success "Package structure valid"
43
+
44
+ # Shell integration existence test
45
+ log_info "Testing shell integration binaries..."
46
+ if [ -f "$HOME/.stackmemory/bin/stackmemory" ] && [ -x "$HOME/.stackmemory/bin/stackmemory" ]; then
47
+ log_success "Shell integration binaries exist"
48
+ else
49
+ log_error "Shell integration binaries missing"
50
+ fi
51
+
52
+ # Quick binary functionality test
53
+ log_info "Testing binary functionality..."
54
+ if "$HOME/.stackmemory/bin/stackmemory" --version > /dev/null 2>&1; then
55
+ log_success "Shell integration works"
56
+ else
57
+ log_error "Shell integration binary failed"
58
+ fi
59
+
60
+ # Lint check
61
+ log_info "Testing lint..."
62
+ npm run lint > /dev/null 2>&1 || log_error "Lint failed"
63
+ log_success "Lint passes"
64
+
65
+ # Git status check
66
+ log_info "Checking git status..."
67
+ if git diff --quiet && git diff --cached --quiet; then
68
+ log_success "Git working directory is clean"
69
+ else
70
+ log_error "Git working directory has uncommitted changes"
71
+ fi
72
+
73
+ echo
74
+ echo -e "${GREEN}āœ… All essential pre-publish tests passed!${NC}"
75
+ echo -e "${GREEN}Ready for npm publish.${NC}"