@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,296 @@
1
+ #!/bin/bash
2
+ # StackMemory Global Installation Script
3
+ # Makes StackMemory available across all Claude Code instances and git repos
4
+
5
+ set -e
6
+
7
+ echo "🌍 Installing StackMemory globally..."
8
+
9
+ # Determine installation directory
10
+ INSTALL_DIR="$HOME/.stackmemory"
11
+ BIN_DIR="$HOME/.local/bin"
12
+ CONFIG_DIR="$HOME/.config/claude"
13
+
14
+ # Create directories
15
+ mkdir -p "$INSTALL_DIR"
16
+ mkdir -p "$BIN_DIR"
17
+ mkdir -p "$CONFIG_DIR"
18
+
19
+ # Get the current directory (where stackmemory source is)
20
+ SOURCE_DIR="$(pwd)"
21
+
22
+ echo "📦 Installing StackMemory to $INSTALL_DIR..."
23
+
24
+ # Copy core files to global installation
25
+ cp -r "$SOURCE_DIR/src" "$INSTALL_DIR/"
26
+ cp -r "$SOURCE_DIR/scripts" "$INSTALL_DIR/"
27
+ cp -r "$SOURCE_DIR/attention-scoring" "$INSTALL_DIR/"
28
+ cp -r "$SOURCE_DIR/p2p-sync" "$INSTALL_DIR/"
29
+ cp "$SOURCE_DIR/package.json" "$INSTALL_DIR/"
30
+ cp "$SOURCE_DIR/tsconfig.json" "$INSTALL_DIR/"
31
+
32
+ # Install dependencies in global location
33
+ cd "$INSTALL_DIR"
34
+ npm install --production
35
+ npm run build
36
+
37
+ # Create global binary wrapper
38
+ cat > "$BIN_DIR/stackmemory" << 'EOF'
39
+ #!/usr/bin/env node
40
+ const { spawn } = require('child_process');
41
+ const path = require('path');
42
+ const os = require('os');
43
+
44
+ const installDir = path.join(os.homedir(), '.stackmemory');
45
+ const mcpServer = path.join(installDir, 'dist', 'src', 'mcp-server.js');
46
+
47
+ // Start the MCP server with current directory as project root
48
+ const child = spawn('node', [mcpServer], {
49
+ env: {
50
+ ...process.env,
51
+ PROJECT_ROOT: process.cwd()
52
+ },
53
+ stdio: 'inherit'
54
+ });
55
+
56
+ child.on('exit', (code) => {
57
+ process.exit(code);
58
+ });
59
+ EOF
60
+
61
+ chmod +x "$BIN_DIR/stackmemory"
62
+
63
+ # Create auto-init script for any git repo
64
+ cat > "$BIN_DIR/stackmemory-init" << 'EOF'
65
+ #!/bin/bash
66
+ # Auto-initialize StackMemory in any git repository
67
+
68
+ if [ ! -d ".git" ]; then
69
+ echo "⚠️ Not a git repository"
70
+ exit 1
71
+ fi
72
+
73
+ if [ ! -d ".stackmemory" ]; then
74
+ echo "🚀 Initializing StackMemory in $(pwd)..."
75
+ mkdir -p .stackmemory
76
+
77
+ # Create config
78
+ cat > .stackmemory/config.json << EOC
79
+ {
80
+ "projectId": "$(basename $(pwd))",
81
+ "userId": "$USER",
82
+ "teamId": "local",
83
+ "initialized": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
84
+ }
85
+ EOC
86
+
87
+ # Create initial frames file
88
+ echo '{"id":"init_'$(date +%s)'","type":"system","content":"StackMemory initialized","timestamp":'$(date +%s)'}' > .stackmemory/frames.jsonl
89
+
90
+ # Add to .gitignore if needed
91
+ if ! grep -q ".stackmemory" .gitignore 2>/dev/null; then
92
+ echo -e "\n# StackMemory\n.stackmemory/*.db\n.stackmemory/*.db-*" >> .gitignore
93
+ fi
94
+
95
+ echo "✅ StackMemory initialized!"
96
+ else
97
+ echo "✓ StackMemory already initialized"
98
+ fi
99
+ EOF
100
+
101
+ chmod +x "$BIN_DIR/stackmemory-init"
102
+
103
+ # Create global MCP configuration for Claude Code
104
+ echo "📝 Configuring Claude Code MCP globally..."
105
+
106
+ MCP_CONFIG_FILE="$CONFIG_DIR/mcp.json"
107
+
108
+ # Create or update MCP config
109
+ if [ -f "$MCP_CONFIG_FILE" ]; then
110
+ # Backup existing config
111
+ cp "$MCP_CONFIG_FILE" "$MCP_CONFIG_FILE.backup"
112
+ echo "📋 Backed up existing config to $MCP_CONFIG_FILE.backup"
113
+ fi
114
+
115
+ cat > "$MCP_CONFIG_FILE" << EOF
116
+ {
117
+ "mcpServers": {
118
+ "stackmemory": {
119
+ "command": "$BIN_DIR/stackmemory",
120
+ "args": [],
121
+ "env": {
122
+ "STACKMEMORY_GLOBAL": "true"
123
+ },
124
+ "autoStart": true,
125
+ "alwaysEnabled": true
126
+ }
127
+ }
128
+ }
129
+ EOF
130
+
131
+ # Create shell integration for automatic initialization
132
+ echo "🐚 Setting up shell integration..."
133
+
134
+ # Add to bashrc/zshrc
135
+ SHELL_CONFIGS=("$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.bash_profile")
136
+
137
+ for config in "${SHELL_CONFIGS[@]}"; do
138
+ if [ -f "$config" ]; then
139
+ if ! grep -q "stackmemory-auto-init" "$config"; then
140
+ cat >> "$config" << 'EOF'
141
+
142
+ # StackMemory auto-initialization
143
+ stackmemory-auto-init() {
144
+ if [ -d ".git" ] && [ ! -d ".stackmemory" ]; then
145
+ echo "🎯 Git repo detected. Initialize StackMemory? (y/n)"
146
+ read -n 1 -r
147
+ echo
148
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
149
+ stackmemory-init
150
+ fi
151
+ fi
152
+ }
153
+
154
+ # Auto-check on directory change (for zsh)
155
+ if [ -n "$ZSH_VERSION" ]; then
156
+ chpwd() {
157
+ stackmemory-auto-init
158
+ }
159
+ fi
160
+
161
+ # Auto-check on cd (for bash)
162
+ if [ -n "$BASH_VERSION" ]; then
163
+ cd() {
164
+ builtin cd "$@" && stackmemory-auto-init
165
+ }
166
+ fi
167
+
168
+ # Add stackmemory to PATH
169
+ export PATH="$HOME/.local/bin:$PATH"
170
+ EOF
171
+ echo "✓ Added StackMemory to $config"
172
+ fi
173
+ fi
174
+ done
175
+
176
+ # Create systemd service for Linux or LaunchAgent for macOS
177
+ if [[ "$OSTYPE" == "darwin"* ]]; then
178
+ # macOS - Create LaunchAgent
179
+ LAUNCH_AGENT_DIR="$HOME/Library/LaunchAgents"
180
+ mkdir -p "$LAUNCH_AGENT_DIR"
181
+
182
+ cat > "$LAUNCH_AGENT_DIR/com.stackmemory.agent.plist" << EOF
183
+ <?xml version="1.0" encoding="UTF-8"?>
184
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
185
+ <plist version="1.0">
186
+ <dict>
187
+ <key>Label</key>
188
+ <string>com.stackmemory.agent</string>
189
+ <key>ProgramArguments</key>
190
+ <array>
191
+ <string>$BIN_DIR/stackmemory-watcher</string>
192
+ </array>
193
+ <key>RunAtLoad</key>
194
+ <true/>
195
+ <key>KeepAlive</key>
196
+ <false/>
197
+ <key>StandardErrorPath</key>
198
+ <string>/tmp/stackmemory.err</string>
199
+ <key>StandardOutPath</key>
200
+ <string>/tmp/stackmemory.out</string>
201
+ </dict>
202
+ </plist>
203
+ EOF
204
+
205
+ # Create watcher script
206
+ cat > "$BIN_DIR/stackmemory-watcher" << 'EOF'
207
+ #!/bin/bash
208
+ # StackMemory Watcher - Monitors for new git repos
209
+
210
+ while true; do
211
+ # Check if Claude Code is running
212
+ if pgrep -x "Claude" > /dev/null || pgrep -x "code" > /dev/null; then
213
+ # Find git repos in common directories
214
+ for dir in ~/Documents ~/Developer ~/Projects ~/Code; do
215
+ if [ -d "$dir" ]; then
216
+ find "$dir" -type d -name ".git" -maxdepth 3 2>/dev/null | while read gitdir; do
217
+ repo_dir="$(dirname "$gitdir")"
218
+ if [ ! -d "$repo_dir/.stackmemory" ]; then
219
+ touch "$repo_dir/.stackmemory-available"
220
+ fi
221
+ done
222
+ fi
223
+ done
224
+ fi
225
+ sleep 300 # Check every 5 minutes
226
+ done
227
+ EOF
228
+
229
+ chmod +x "$BIN_DIR/stackmemory-watcher"
230
+
231
+ # Load the LaunchAgent
232
+ launchctl load "$LAUNCH_AGENT_DIR/com.stackmemory.agent.plist" 2>/dev/null || true
233
+
234
+ echo "✅ Created macOS LaunchAgent for automatic detection"
235
+
236
+ elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
237
+ # Linux - Create systemd service
238
+ SYSTEMD_DIR="$HOME/.config/systemd/user"
239
+ mkdir -p "$SYSTEMD_DIR"
240
+
241
+ cat > "$SYSTEMD_DIR/stackmemory.service" << EOF
242
+ [Unit]
243
+ Description=StackMemory Auto-Detection Service
244
+ After=graphical-session.target
245
+
246
+ [Service]
247
+ Type=simple
248
+ ExecStart=$BIN_DIR/stackmemory-watcher
249
+ Restart=on-failure
250
+ RestartSec=10
251
+
252
+ [Install]
253
+ WantedBy=default.target
254
+ EOF
255
+
256
+ # Enable the service
257
+ systemctl --user daemon-reload
258
+ systemctl --user enable stackmemory.service
259
+ systemctl --user start stackmemory.service
260
+
261
+ echo "✅ Created systemd service for automatic detection"
262
+ fi
263
+
264
+ # Create VS Code extension recommendation
265
+ cat > "$INSTALL_DIR/vscode-integration.json" << 'EOF'
266
+ {
267
+ "recommendations": [
268
+ "continue.continue",
269
+ "github.copilot"
270
+ ],
271
+ "stackmemory": {
272
+ "enabled": true,
273
+ "autoInit": true
274
+ }
275
+ }
276
+ EOF
277
+
278
+ echo ""
279
+ echo "✅ StackMemory installed globally!"
280
+ echo ""
281
+ echo "🎯 Features enabled:"
282
+ echo " • Auto-detection in git repositories"
283
+ echo " • Global MCP server for Claude Code"
284
+ echo " • Shell integration (cd auto-init)"
285
+ echo " • Background monitoring service"
286
+ echo ""
287
+ echo "📝 Commands available globally:"
288
+ echo " stackmemory - Start MCP server in current directory"
289
+ echo " stackmemory-init - Initialize in current git repo"
290
+ echo ""
291
+ echo "🔄 Next steps:"
292
+ echo " 1. Restart your terminal (or run: source ~/.bashrc)"
293
+ echo " 2. Restart Claude Code to load MCP configuration"
294
+ echo " 3. Navigate to any git repo - StackMemory will auto-prompt"
295
+ echo ""
296
+ echo "🚀 StackMemory is now available in ALL your projects!"
@@ -0,0 +1,235 @@
1
+ #!/bin/bash
2
+ # StackMemory Universal Installer
3
+ # Works across ALL Claude Code instances automatically
4
+
5
+ set -e
6
+
7
+ YELLOW='\033[1;33m'
8
+ GREEN='\033[0;32m'
9
+ BLUE='\033[0;34m'
10
+ RED='\033[0;31m'
11
+ NC='\033[0m' # No Color
12
+
13
+ echo -e "${BLUE}🚀 StackMemory Universal Installer${NC}\n"
14
+
15
+ # Detect OS
16
+ OS="unknown"
17
+ if [[ "$OSTYPE" == "darwin"* ]]; then
18
+ OS="macos"
19
+ elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
20
+ OS="linux"
21
+ else
22
+ echo -e "${RED}Unsupported OS: $OSTYPE${NC}"
23
+ exit 1
24
+ fi
25
+
26
+ # Set paths based on OS
27
+ if [ "$OS" = "macos" ]; then
28
+ MCP_CONFIG_DIR="$HOME/Library/Application Support/Claude"
29
+ ALT_MCP_DIR="$HOME/.config/claude"
30
+ elif [ "$OS" = "linux" ]; then
31
+ MCP_CONFIG_DIR="$HOME/.config/claude"
32
+ ALT_MCP_DIR="$HOME/.local/share/claude"
33
+ fi
34
+
35
+ INSTALL_DIR="$HOME/.stackmemory"
36
+ CURRENT_DIR="$(pwd)"
37
+
38
+ echo -e "${YELLOW}Installing StackMemory globally...${NC}\n"
39
+
40
+ # 1. Install to home directory
41
+ echo -e "${GREEN}[1/5]${NC} Setting up StackMemory in $INSTALL_DIR"
42
+ mkdir -p "$INSTALL_DIR"
43
+
44
+ # Copy all necessary files
45
+ cp -r "$CURRENT_DIR/src" "$INSTALL_DIR/" 2>/dev/null || true
46
+ cp -r "$CURRENT_DIR/attention-scoring" "$INSTALL_DIR/" 2>/dev/null || true
47
+ cp -r "$CURRENT_DIR/p2p-sync" "$INSTALL_DIR/" 2>/dev/null || true
48
+ cp "$CURRENT_DIR/package.json" "$INSTALL_DIR/"
49
+ cp "$CURRENT_DIR/tsconfig.json" "$INSTALL_DIR/"
50
+
51
+ # 2. Install dependencies
52
+ echo -e "${GREEN}[2/5]${NC} Installing dependencies..."
53
+ cd "$INSTALL_DIR"
54
+ npm install --silent --production 2>/dev/null || npm install --production
55
+
56
+ # 3. Build TypeScript
57
+ echo -e "${GREEN}[3/5]${NC} Building TypeScript files..."
58
+ npm run build --silent 2>/dev/null || npm run build
59
+
60
+ # 4. Create global MCP config
61
+ echo -e "${GREEN}[4/5]${NC} Configuring Claude Code MCP..."
62
+
63
+ # Try both possible config directories
64
+ for CONFIG_DIR in "$MCP_CONFIG_DIR" "$ALT_MCP_DIR"; do
65
+ if [ ! -d "$CONFIG_DIR" ]; then
66
+ mkdir -p "$CONFIG_DIR"
67
+ fi
68
+
69
+ MCP_CONFIG="$CONFIG_DIR/claude_desktop_config.json"
70
+
71
+ # Create or update MCP configuration
72
+ if [ -f "$MCP_CONFIG" ]; then
73
+ # Backup existing
74
+ cp "$MCP_CONFIG" "$MCP_CONFIG.backup.$(date +%s)"
75
+
76
+ # Parse and update existing config
77
+ node -e "
78
+ const fs = require('fs');
79
+ const configPath = '$MCP_CONFIG';
80
+ let config = {};
81
+ try {
82
+ config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
83
+ } catch (e) {
84
+ config = {};
85
+ }
86
+
87
+ if (!config.mcpServers) {
88
+ config.mcpServers = {};
89
+ }
90
+
91
+ config.mcpServers.stackmemory = {
92
+ command: 'node',
93
+ args: ['$INSTALL_DIR/dist/src/mcp-server.js'],
94
+ env: {
95
+ STACKMEMORY_GLOBAL: 'true'
96
+ }
97
+ };
98
+
99
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
100
+ console.log('✓ Updated MCP config at ' + configPath);
101
+ "
102
+ else
103
+ # Create new config
104
+ cat > "$MCP_CONFIG" << EOF
105
+ {
106
+ "mcpServers": {
107
+ "stackmemory": {
108
+ "command": "node",
109
+ "args": ["$INSTALL_DIR/dist/src/mcp-server.js"],
110
+ "env": {
111
+ "STACKMEMORY_GLOBAL": "true"
112
+ }
113
+ }
114
+ }
115
+ }
116
+ EOF
117
+ echo -e "✓ Created MCP config at $MCP_CONFIG"
118
+ fi
119
+ done
120
+
121
+ # 5. Create command-line tool
122
+ echo -e "${GREEN}[5/5]${NC} Creating global command..."
123
+
124
+ # Create bin directory if it doesn't exist
125
+ mkdir -p "$HOME/.local/bin"
126
+
127
+ # Create the global stackmemory command
128
+ cat > "$HOME/.local/bin/stackmemory" << 'EOF'
129
+ #!/usr/bin/env node
130
+
131
+ const { spawn } = require('child_process');
132
+ const path = require('path');
133
+ const fs = require('fs');
134
+ const os = require('os');
135
+
136
+ const installDir = path.join(os.homedir(), '.stackmemory');
137
+ const mcpServer = path.join(installDir, 'dist', 'src', 'mcp-server.js');
138
+
139
+ // Check if we're in a git repo
140
+ function isGitRepo() {
141
+ try {
142
+ require('child_process').execSync('git rev-parse --git-dir', { stdio: 'ignore' });
143
+ return true;
144
+ } catch (e) {
145
+ return false;
146
+ }
147
+ }
148
+
149
+ // Auto-initialize if in git repo
150
+ if (isGitRepo() && !fs.existsSync('.stackmemory')) {
151
+ console.log('🎯 Initializing StackMemory in this repository...');
152
+
153
+ fs.mkdirSync('.stackmemory', { recursive: true });
154
+
155
+ const config = {
156
+ projectId: path.basename(process.cwd()),
157
+ userId: process.env.USER || 'default',
158
+ initialized: new Date().toISOString()
159
+ };
160
+
161
+ fs.writeFileSync('.stackmemory/config.json', JSON.stringify(config, null, 2));
162
+ fs.writeFileSync('.stackmemory/frames.jsonl', '');
163
+
164
+ // Add to .gitignore
165
+ if (fs.existsSync('.gitignore')) {
166
+ const gitignore = fs.readFileSync('.gitignore', 'utf8');
167
+ if (!gitignore.includes('.stackmemory')) {
168
+ fs.appendFileSync('.gitignore', '\n# StackMemory\n.stackmemory/*.db\n.stackmemory/*.db-*\n');
169
+ }
170
+ }
171
+
172
+ console.log('✅ StackMemory initialized!');
173
+ }
174
+
175
+ // Handle commands
176
+ const command = process.argv[2];
177
+
178
+ switch(command) {
179
+ case 'init':
180
+ // Already handled above
181
+ break;
182
+ case 'status':
183
+ require(path.join(installDir, 'dist', 'scripts', 'status.js'));
184
+ break;
185
+ case 'test':
186
+ require(path.join(installDir, 'dist', 'test', 'test-framework.js'));
187
+ break;
188
+ default:
189
+ // Start MCP server
190
+ const child = spawn('node', [mcpServer], {
191
+ env: { ...process.env, PROJECT_ROOT: process.cwd() },
192
+ stdio: 'inherit'
193
+ });
194
+ child.on('exit', code => process.exit(code));
195
+ }
196
+ EOF
197
+
198
+ chmod +x "$HOME/.local/bin/stackmemory"
199
+
200
+ # Add to PATH if not already there
201
+ add_to_path() {
202
+ local shell_rc="$1"
203
+ if [ -f "$shell_rc" ]; then
204
+ if ! grep -q "/.local/bin" "$shell_rc"; then
205
+ echo '' >> "$shell_rc"
206
+ echo '# StackMemory' >> "$shell_rc"
207
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$shell_rc"
208
+ echo -e "✓ Added to PATH in $shell_rc"
209
+ fi
210
+ fi
211
+ }
212
+
213
+ add_to_path "$HOME/.bashrc"
214
+ add_to_path "$HOME/.zshrc"
215
+ add_to_path "$HOME/.bash_profile"
216
+
217
+ echo ""
218
+ echo -e "${GREEN}✅ StackMemory installed successfully!${NC}"
219
+ echo ""
220
+ echo -e "${BLUE}🎯 Installation Complete:${NC}"
221
+ echo " • Global MCP server configured for Claude Code"
222
+ echo " • Command 'stackmemory' available globally"
223
+ echo " • Auto-detects git repositories"
224
+ echo ""
225
+ echo -e "${YELLOW}⚠️ Required Actions:${NC}"
226
+ echo " 1. Restart Claude Code to load the MCP server"
227
+ echo " 2. Run: source ~/.bashrc (or restart terminal)"
228
+ echo ""
229
+ echo -e "${GREEN}📝 Test Installation:${NC}"
230
+ echo " cd any-git-repo"
231
+ echo " stackmemory init # Initialize in repo"
232
+ echo " stackmemory status # Check status"
233
+ echo " stackmemory test # Run test suite"
234
+ echo ""
235
+ echo -e "${BLUE}The MCP server is now available in ALL Claude Code instances!${NC}"