@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.
- package/dist/cli/claude-sm.js +51 -5
- package/dist/cli/claude-sm.js.map +2 -2
- package/dist/cli/codex-sm.js +52 -19
- package/dist/cli/codex-sm.js.map +2 -2
- package/dist/cli/commands/db.js +143 -0
- package/dist/cli/commands/db.js.map +7 -0
- package/dist/cli/commands/login.js +50 -0
- package/dist/cli/commands/login.js.map +7 -0
- package/dist/cli/commands/migrate.js +178 -0
- package/dist/cli/commands/migrate.js.map +7 -0
- package/dist/cli/commands/onboard.js +158 -2
- package/dist/cli/commands/onboard.js.map +2 -2
- package/dist/cli/commands/skills.js +15 -2
- package/dist/cli/commands/skills.js.map +2 -2
- package/dist/cli/index.js +118 -834
- package/dist/cli/index.js.map +3 -3
- package/dist/core/context/dual-stack-manager.js +1 -1
- package/dist/core/context/dual-stack-manager.js.map +1 -1
- package/dist/core/context/frame-database.js +1 -0
- package/dist/core/context/frame-database.js.map +2 -2
- package/dist/core/context/frame-manager.js +59 -2
- package/dist/core/context/frame-manager.js.map +2 -2
- package/dist/core/database/database-adapter.js +6 -1
- package/dist/core/database/database-adapter.js.map +2 -2
- package/dist/core/database/sqlite-adapter.js +60 -2
- package/dist/core/database/sqlite-adapter.js.map +2 -2
- package/dist/integrations/claude-code/subagent-client.js +106 -3
- package/dist/integrations/claude-code/subagent-client.js.map +2 -2
- package/dist/servers/railway/config.js +51 -0
- package/dist/servers/railway/config.js.map +7 -0
- package/dist/servers/railway/index-enhanced.js +156 -0
- package/dist/servers/railway/index-enhanced.js.map +7 -0
- package/dist/servers/railway/index.js +843 -82
- package/dist/servers/railway/index.js.map +3 -3
- package/dist/servers/railway/minimal.js +48 -3
- package/dist/servers/railway/minimal.js.map +2 -2
- package/dist/servers/railway/storage-test.js +455 -0
- package/dist/servers/railway/storage-test.js.map +7 -0
- package/dist/skills/claude-skills.js +13 -12
- package/dist/skills/claude-skills.js.map +2 -2
- package/dist/skills/recursive-agent-orchestrator.js +27 -18
- package/dist/skills/recursive-agent-orchestrator.js.map +2 -2
- package/dist/skills/unified-rlm-orchestrator.js.map +2 -2
- package/package.json +13 -21
- package/scripts/README-TESTING.md +186 -0
- package/scripts/analyze-cli-security.js +288 -0
- package/scripts/archive/add-phase-tasks-to-linear.js +163 -0
- package/scripts/archive/analyze-linear-duplicates.js +214 -0
- package/scripts/archive/analyze-remaining-duplicates.js +230 -0
- package/scripts/archive/analyze-sta-duplicates.js +292 -0
- package/scripts/archive/analyze-sta-graphql.js +399 -0
- package/scripts/archive/cancel-duplicate-tasks.ts +246 -0
- package/scripts/archive/check-all-duplicates.ts +419 -0
- package/scripts/archive/clean-duplicate-tasks.js +114 -0
- package/scripts/archive/cleanup-duplicate-tasks.ts +286 -0
- package/scripts/archive/create-phase-tasks.js +387 -0
- package/scripts/archive/delete-linear-duplicates.js +182 -0
- package/scripts/archive/delete-remaining-duplicates.js +158 -0
- package/scripts/archive/delete-sta-duplicates.js +201 -0
- package/scripts/archive/delete-sta-oauth.js +201 -0
- package/scripts/archive/export-sta-tasks.js +62 -0
- package/scripts/archive/install-auto-sync.js +266 -0
- package/scripts/archive/install-chromadb-hooks.sh +133 -0
- package/scripts/archive/install-enhanced-clear-hooks.sh +431 -0
- package/scripts/archive/install-post-task-hooks.sh +289 -0
- package/scripts/archive/install-stackmemory-hooks.sh +420 -0
- package/scripts/archive/merge-linear-duplicates-safe.ts +362 -0
- package/scripts/archive/merge-linear-duplicates.ts +180 -0
- package/scripts/archive/remove-sta-tasks.js +70 -0
- package/scripts/archive/setup-background-sync.sh +168 -0
- package/scripts/archive/setup-claude-auto-triggers.sh +181 -0
- package/scripts/archive/setup-claude-autostart.sh +305 -0
- package/scripts/archive/setup-git-hooks.sh +25 -0
- package/scripts/archive/setup-linear-oauth.sh +46 -0
- package/scripts/archive/setup-mcp.sh +113 -0
- package/scripts/archive/setup-railway-deployment.sh +81 -0
- package/scripts/auto-handoff.sh +262 -0
- package/scripts/background-sync-manager.js +416 -0
- package/scripts/benchmark-performance.ts +57 -0
- package/scripts/check-redis.ts +48 -0
- package/scripts/chromadb-auto-loader.sh +128 -0
- package/scripts/chromadb-context-loader.js +479 -0
- package/scripts/claude-chromadb-hook.js +460 -0
- package/scripts/claude-code-wrapper.sh +66 -0
- package/scripts/claude-linear-skill.js +455 -0
- package/scripts/claude-pre-commit.sh +302 -0
- package/scripts/claude-sm-autostart.js +532 -0
- package/scripts/claude-sm-setup.sh +367 -0
- package/scripts/claude-with-chromadb.sh +69 -0
- package/scripts/claude-worktree-manager.sh +323 -0
- package/scripts/claude-worktree-monitor.sh +371 -0
- package/scripts/claude-worktree-setup.sh +327 -0
- package/scripts/clean-linear-backlog.js +273 -0
- package/scripts/cleanup-old-sessions.sh +57 -0
- package/scripts/codex-wrapper.sh +88 -0
- package/scripts/create-sandbox.sh +269 -0
- package/scripts/debug-linear-update.js +174 -0
- package/scripts/delete-linear-tasks.js +167 -0
- package/scripts/deploy.sh +89 -0
- package/scripts/deployment/railway.sh +352 -0
- package/scripts/deployment/test-deployment.js +194 -0
- package/scripts/detect-and-rehydrate.js +162 -0
- package/scripts/detect-and-rehydrate.mjs +165 -0
- package/scripts/development/create-demo-tasks.js +143 -0
- package/scripts/development/debug-frame-test.js +16 -0
- package/scripts/development/demo-auto-sync.js +128 -0
- package/scripts/development/fix-all-imports.js +213 -0
- package/scripts/development/fix-imports.js +229 -0
- package/scripts/development/fix-lint-loop.cjs +103 -0
- package/scripts/development/fix-project-id.ts +161 -0
- package/scripts/development/fix-strict-mode-issues.ts +291 -0
- package/scripts/development/reorganize-structure.sh +228 -0
- package/scripts/development/test-persistence-direct.js +148 -0
- package/scripts/development/test-persistence.js +114 -0
- package/scripts/development/test-tasks.js +93 -0
- package/scripts/development/update-imports.js +212 -0
- package/scripts/fetch-linear-status.js +125 -0
- package/scripts/git-hooks/README.md +310 -0
- package/scripts/git-hooks/branch-context-manager.sh +342 -0
- package/scripts/git-hooks/post-checkout-stackmemory.sh +63 -0
- package/scripts/git-hooks/post-commit-stackmemory.sh +305 -0
- package/scripts/git-hooks/pre-commit-stackmemory.sh +275 -0
- package/scripts/hooks/cleanup-shell.sh +130 -0
- package/scripts/hooks/task-complete.sh +114 -0
- package/scripts/initialize.ts +129 -0
- package/scripts/install-claude-hooks-auto.js +104 -0
- package/scripts/install-claude-hooks.sh +133 -0
- package/scripts/install-global.sh +296 -0
- package/scripts/install.sh +235 -0
- package/scripts/linear-auto-sync.js +262 -0
- package/scripts/linear-auto-sync.sh +161 -0
- package/scripts/linear-sync-daemon.js +150 -0
- package/scripts/linear-task-review.js +237 -0
- package/scripts/list-linear-tasks.ts +178 -0
- package/scripts/mcp-proxy.js +66 -0
- package/scripts/opencode-wrapper.sh +85 -0
- package/scripts/publish-local.js +74 -0
- package/scripts/query-chromadb.ts +201 -0
- package/scripts/railway-env-setup.sh +39 -0
- package/scripts/reconcile-local-tasks.js +170 -0
- package/scripts/recreate-frames-db.js +89 -0
- package/scripts/setup/claude-integration.js +138 -0
- package/scripts/setup/configure-alias.js +125 -0
- package/scripts/setup/configure-codex-alias.js +161 -0
- package/scripts/setup/configure-opencode-alias.js +175 -0
- package/scripts/setup-claude-integration.js +204 -0
- package/scripts/setup-claude-integration.sh +183 -0
- package/scripts/setup-railway-deployment.sh +37 -0
- package/scripts/setup.sh +31 -0
- package/scripts/show-linear-summary.ts +172 -0
- package/scripts/stackmemory-auto-handoff.sh +231 -0
- package/scripts/stackmemory-daemon.sh +40 -0
- package/scripts/start-linear-sync-daemon.sh +141 -0
- package/scripts/start-temporal-paradox.sh +214 -0
- package/scripts/status.ts +159 -0
- package/scripts/sync-and-clean-tasks.js +258 -0
- package/scripts/sync-frames-from-railway.js +228 -0
- package/scripts/sync-linear-graphql.js +303 -0
- package/scripts/sync-linear-tasks.js +186 -0
- package/scripts/test-auto-triggers.sh +57 -0
- package/scripts/test-browser-mcp.js +74 -0
- package/scripts/test-chromadb-full.js +115 -0
- package/scripts/test-chromadb-hooks.sh +28 -0
- package/scripts/test-chromadb-sync.ts +245 -0
- package/scripts/test-cli-security.js +293 -0
- package/scripts/test-hooks-persistence.sh +220 -0
- package/scripts/test-installation-scenarios.sh +359 -0
- package/scripts/test-installation.sh +224 -0
- package/scripts/test-mcp.js +163 -0
- package/scripts/test-pre-publish-quick.sh +75 -0
- package/scripts/test-quality-gates.sh +263 -0
- package/scripts/test-railway-db.js +222 -0
- package/scripts/test-redis-storage.ts +490 -0
- package/scripts/test-rlm-basic.sh +122 -0
- package/scripts/test-rlm-comprehensive.sh +260 -0
- package/scripts/test-rlm-e2e.sh +268 -0
- package/scripts/test-rlm-simple.js +90 -0
- package/scripts/test-rlm.js +110 -0
- package/scripts/test-session-handoff.sh +165 -0
- package/scripts/test-shell-integration.sh +275 -0
- package/scripts/testing/ab-test-runner.ts +508 -0
- package/scripts/testing/collect-metrics.ts +457 -0
- package/scripts/testing/quick-effectiveness-demo.js +187 -0
- package/scripts/testing/real-performance-test.js +422 -0
- package/scripts/testing/run-effectiveness-tests.sh +176 -0
- package/scripts/testing/scripts/testing/ab-test-runner.js +363 -0
- package/scripts/testing/scripts/testing/collect-metrics.js +292 -0
- package/scripts/testing/simple-effectiveness-test.js +310 -0
- package/scripts/testing/src/core/context/context-bridge.js +253 -0
- package/scripts/testing/src/core/context/frame-manager.js +746 -0
- package/scripts/testing/src/core/context/shared-context-layer.js +437 -0
- package/scripts/testing/src/core/database/database-adapter.js +54 -0
- package/scripts/testing/src/core/errors/index.js +291 -0
- package/scripts/testing/src/core/errors/recovery.js +268 -0
- package/scripts/testing/src/core/monitoring/logger.js +145 -0
- package/scripts/testing/src/core/retrieval/context-retriever.js +516 -0
- package/scripts/testing/src/core/session/index.js +1 -0
- package/scripts/testing/src/core/session/session-manager.js +323 -0
- package/scripts/testing/src/core/trace/cli-trace-wrapper.js +140 -0
- package/scripts/testing/src/core/trace/db-trace-wrapper.js +251 -0
- package/scripts/testing/src/core/trace/debug-trace.js +398 -0
- package/scripts/testing/src/core/trace/index.js +120 -0
- package/scripts/testing/src/core/trace/linear-api-wrapper.js +204 -0
- package/scripts/update-linear-status.js +268 -0
- package/scripts/update-linear-tasks-fixed.js +284 -0
- package/scripts/verify-railway-schema.ts +35 -0
- package/templates/claude-hooks/hooks.json +5 -0
- package/templates/claude-hooks/on-clear.js +56 -0
- package/templates/claude-hooks/on-startup.js +56 -0
- package/templates/claude-hooks/tool-use-trace.js +67 -0
- package/dist/features/tui/components/analytics-panel.js +0 -157
- package/dist/features/tui/components/analytics-panel.js.map +0 -7
- package/dist/features/tui/components/frame-visualizer.js +0 -377
- package/dist/features/tui/components/frame-visualizer.js.map +0 -7
- package/dist/features/tui/components/pr-tracker.js +0 -135
- package/dist/features/tui/components/pr-tracker.js.map +0 -7
- package/dist/features/tui/components/session-monitor.js +0 -299
- package/dist/features/tui/components/session-monitor.js.map +0 -7
- package/dist/features/tui/components/subagent-fleet.js +0 -395
- package/dist/features/tui/components/subagent-fleet.js.map +0 -7
- package/dist/features/tui/components/task-board.js +0 -1139
- package/dist/features/tui/components/task-board.js.map +0 -7
- package/dist/features/tui/index.js +0 -408
- package/dist/features/tui/index.js.map +0 -7
- package/dist/features/tui/services/data-service.js +0 -641
- package/dist/features/tui/services/data-service.js.map +0 -7
- package/dist/features/tui/services/linear-task-reader.js +0 -102
- package/dist/features/tui/services/linear-task-reader.js.map +0 -7
- package/dist/features/tui/services/websocket-client.js +0 -162
- package/dist/features/tui/services/websocket-client.js.map +0 -7
- package/dist/features/tui/terminal-compat.js +0 -220
- package/dist/features/tui/terminal-compat.js.map +0 -7
- package/dist/features/tui/types.js +0 -1
- package/dist/features/tui/types.js.map +0 -7
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Automated NPM Deployment Script
|
|
3
|
+
# Usage: ./scripts/deploy.sh [patch|minor|major|version]
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Color codes
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
NC='\033[0m' # No Color
|
|
12
|
+
|
|
13
|
+
# Configuration
|
|
14
|
+
VERSION_TYPE=${1:-patch}
|
|
15
|
+
DRY_RUN=${DRY_RUN:-false}
|
|
16
|
+
|
|
17
|
+
echo -e "${GREEN}š Starting deployment process...${NC}"
|
|
18
|
+
|
|
19
|
+
# Check if we're on main branch
|
|
20
|
+
CURRENT_BRANCH=$(git branch --show-current)
|
|
21
|
+
if [ "$CURRENT_BRANCH" != "main" ]; then
|
|
22
|
+
echo -e "${RED}ā You must be on main branch to deploy${NC}"
|
|
23
|
+
echo "Current branch: $CURRENT_BRANCH"
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# Check for uncommitted changes
|
|
28
|
+
if [ -n "$(git status --porcelain)" ]; then
|
|
29
|
+
echo -e "${RED}ā You have uncommitted changes${NC}"
|
|
30
|
+
git status --short
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# Pull latest changes
|
|
35
|
+
echo -e "${YELLOW}š„ Pulling latest changes...${NC}"
|
|
36
|
+
git pull origin main
|
|
37
|
+
|
|
38
|
+
# Run quality checks
|
|
39
|
+
echo -e "${YELLOW}š§Ŗ Running quality checks...${NC}"
|
|
40
|
+
npm run lint
|
|
41
|
+
npm run test:run
|
|
42
|
+
npm run build
|
|
43
|
+
|
|
44
|
+
# Bump version
|
|
45
|
+
echo -e "${YELLOW}š¦ Bumping version (${VERSION_TYPE})...${NC}"
|
|
46
|
+
if [ "$VERSION_TYPE" = "patch" ] || [ "$VERSION_TYPE" = "minor" ] || [ "$VERSION_TYPE" = "major" ]; then
|
|
47
|
+
NEW_VERSION=$(npm version $VERSION_TYPE --no-git-tag-version)
|
|
48
|
+
else
|
|
49
|
+
NEW_VERSION=$VERSION_TYPE
|
|
50
|
+
npm version $VERSION_TYPE --no-git-tag-version
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Update CLI version constant
|
|
54
|
+
echo -e "${YELLOW}āļø Updating CLI version...${NC}"
|
|
55
|
+
sed -i.bak "s/const VERSION = '[^']*'/const VERSION = '${NEW_VERSION#v}'/" src/cli/index.ts
|
|
56
|
+
rm src/cli/index.ts.bak
|
|
57
|
+
|
|
58
|
+
# Build with new version
|
|
59
|
+
echo -e "${YELLOW}šØ Building with new version...${NC}"
|
|
60
|
+
npm run build
|
|
61
|
+
|
|
62
|
+
# Commit version changes
|
|
63
|
+
echo -e "${YELLOW}š Committing version changes...${NC}"
|
|
64
|
+
git add -A
|
|
65
|
+
git commit -m "chore: Release ${NEW_VERSION}
|
|
66
|
+
|
|
67
|
+
- Bump version to ${NEW_VERSION}
|
|
68
|
+
- Update CLI version constant
|
|
69
|
+
- Update package-lock.json"
|
|
70
|
+
|
|
71
|
+
# Create and push tag
|
|
72
|
+
echo -e "${YELLOW}š·ļø Creating tag...${NC}"
|
|
73
|
+
git tag ${NEW_VERSION}
|
|
74
|
+
|
|
75
|
+
# Push changes and tag
|
|
76
|
+
echo -e "${YELLOW}š¤ Pushing to GitHub...${NC}"
|
|
77
|
+
git push origin main
|
|
78
|
+
git push origin ${NEW_VERSION}
|
|
79
|
+
|
|
80
|
+
echo -e "${GREEN}ā
Deployment preparation complete!${NC}"
|
|
81
|
+
echo -e "${GREEN}š¦ Version ${NEW_VERSION} has been tagged and pushed${NC}"
|
|
82
|
+
echo ""
|
|
83
|
+
echo -e "${YELLOW}Next steps:${NC}"
|
|
84
|
+
echo "1. GitHub Actions will automatically publish to NPM"
|
|
85
|
+
echo "2. Monitor the Actions tab for progress"
|
|
86
|
+
echo "3. Or manually publish with: npm publish"
|
|
87
|
+
echo ""
|
|
88
|
+
echo -e "${GREEN}GitHub Actions URL:${NC}"
|
|
89
|
+
echo "https://github.com/stackmemoryai/stackmemory/actions"
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Runway Deployment Script for StackMemory MCP Server
|
|
4
|
+
# Production deployment with comprehensive checks
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Color codes for output
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m' # No Color
|
|
14
|
+
|
|
15
|
+
# Configuration
|
|
16
|
+
ENVIRONMENT="${1:-production}"
|
|
17
|
+
PROJECT_NAME="stackmemory-mcp"
|
|
18
|
+
REQUIRED_ENV_VARS=(
|
|
19
|
+
"AUTH0_DOMAIN"
|
|
20
|
+
"AUTH0_AUDIENCE"
|
|
21
|
+
"AUTH0_CLIENT_ID"
|
|
22
|
+
"AUTH0_CLIENT_SECRET"
|
|
23
|
+
"DATABASE_URL"
|
|
24
|
+
"REDIS_URL"
|
|
25
|
+
"JWT_SECRET"
|
|
26
|
+
"DATADOG_API_KEY"
|
|
27
|
+
"SENTRY_DSN"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Logging functions
|
|
31
|
+
log_info() {
|
|
32
|
+
echo -e "${BLUE}[INFO]${NC} $1"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
log_success() {
|
|
36
|
+
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
log_warning() {
|
|
40
|
+
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
log_error() {
|
|
44
|
+
echo -e "${RED}[ERROR]${NC} $1"
|
|
45
|
+
exit 1
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# Check prerequisites
|
|
49
|
+
check_prerequisites() {
|
|
50
|
+
log_info "Checking prerequisites..."
|
|
51
|
+
|
|
52
|
+
# Check for required tools
|
|
53
|
+
for tool in docker node npm runway pg_isready redis-cli; do
|
|
54
|
+
if ! command -v $tool &> /dev/null; then
|
|
55
|
+
log_error "$tool is not installed"
|
|
56
|
+
fi
|
|
57
|
+
done
|
|
58
|
+
|
|
59
|
+
# Check Node version
|
|
60
|
+
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
|
|
61
|
+
if [ "$NODE_VERSION" -lt 20 ]; then
|
|
62
|
+
log_error "Node.js 20 or higher is required (current: v$NODE_VERSION)"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# Check environment variables
|
|
66
|
+
for var in "${REQUIRED_ENV_VARS[@]}"; do
|
|
67
|
+
if [ -z "${!var:-}" ]; then
|
|
68
|
+
log_error "Environment variable $var is not set"
|
|
69
|
+
fi
|
|
70
|
+
done
|
|
71
|
+
|
|
72
|
+
log_success "All prerequisites met"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# Run tests
|
|
76
|
+
run_tests() {
|
|
77
|
+
log_info "Running tests..."
|
|
78
|
+
|
|
79
|
+
# Unit tests
|
|
80
|
+
npm test || log_error "Unit tests failed"
|
|
81
|
+
|
|
82
|
+
# Integration tests
|
|
83
|
+
npm run test:integration || log_error "Integration tests failed"
|
|
84
|
+
|
|
85
|
+
# Security scan
|
|
86
|
+
npm audit --production || log_warning "Security vulnerabilities found"
|
|
87
|
+
|
|
88
|
+
log_success "All tests passed"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Build application
|
|
92
|
+
build_application() {
|
|
93
|
+
log_info "Building application..."
|
|
94
|
+
|
|
95
|
+
# Clean previous builds
|
|
96
|
+
rm -rf dist
|
|
97
|
+
|
|
98
|
+
# Install dependencies
|
|
99
|
+
npm ci --production=false
|
|
100
|
+
|
|
101
|
+
# Build TypeScript
|
|
102
|
+
npm run build
|
|
103
|
+
|
|
104
|
+
# Verify build
|
|
105
|
+
if [ ! -f "dist/src/runway/index.js" ]; then
|
|
106
|
+
log_error "Build failed: main entry point not found"
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
log_success "Application built successfully"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Build Docker image
|
|
113
|
+
build_docker_image() {
|
|
114
|
+
log_info "Building Docker image..."
|
|
115
|
+
|
|
116
|
+
# Generate build tag
|
|
117
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
118
|
+
BUILD_TAG="${PROJECT_NAME}:${VERSION}-${ENVIRONMENT}"
|
|
119
|
+
LATEST_TAG="${PROJECT_NAME}:latest-${ENVIRONMENT}"
|
|
120
|
+
|
|
121
|
+
# Build image
|
|
122
|
+
docker build \
|
|
123
|
+
--file Dockerfile.runway \
|
|
124
|
+
--tag "$BUILD_TAG" \
|
|
125
|
+
--tag "$LATEST_TAG" \
|
|
126
|
+
--build-arg NODE_ENV="$ENVIRONMENT" \
|
|
127
|
+
--platform linux/amd64 \
|
|
128
|
+
.
|
|
129
|
+
|
|
130
|
+
# Tag for registry
|
|
131
|
+
REGISTRY_URL="${RUNWAY_REGISTRY:-registry.runway.app}"
|
|
132
|
+
docker tag "$BUILD_TAG" "$REGISTRY_URL/$BUILD_TAG"
|
|
133
|
+
docker tag "$LATEST_TAG" "$REGISTRY_URL/$LATEST_TAG"
|
|
134
|
+
|
|
135
|
+
log_success "Docker image built: $BUILD_TAG"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# Database migrations
|
|
139
|
+
run_migrations() {
|
|
140
|
+
log_info "Running database migrations..."
|
|
141
|
+
|
|
142
|
+
# Check database connection
|
|
143
|
+
if ! pg_isready -d "$DATABASE_URL"; then
|
|
144
|
+
log_error "Cannot connect to database"
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
# Run migrations using docker
|
|
148
|
+
docker run --rm \
|
|
149
|
+
-e DATABASE_URL="$DATABASE_URL" \
|
|
150
|
+
"${PROJECT_NAME}:latest-${ENVIRONMENT}" \
|
|
151
|
+
node dist/src/runway/database/migrate.js
|
|
152
|
+
|
|
153
|
+
log_success "Database migrations completed"
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# Health checks
|
|
157
|
+
perform_health_checks() {
|
|
158
|
+
log_info "Performing health checks..."
|
|
159
|
+
|
|
160
|
+
# Start services locally for testing
|
|
161
|
+
docker-compose -f docker-compose.runway.yml up -d
|
|
162
|
+
|
|
163
|
+
# Wait for services to be ready
|
|
164
|
+
sleep 10
|
|
165
|
+
|
|
166
|
+
# Check application health
|
|
167
|
+
HEALTH_RESPONSE=$(curl -s http://localhost:8080/health)
|
|
168
|
+
if ! echo "$HEALTH_RESPONSE" | grep -q '"healthy":true'; then
|
|
169
|
+
log_error "Health check failed: $HEALTH_RESPONSE"
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
# Check database
|
|
173
|
+
docker exec stackmemory-postgres pg_isready -U stackmemory || log_error "Database not ready"
|
|
174
|
+
|
|
175
|
+
# Check Redis
|
|
176
|
+
docker exec stackmemory-redis redis-cli ping || log_error "Redis not ready"
|
|
177
|
+
|
|
178
|
+
# Stop services
|
|
179
|
+
docker-compose -f docker-compose.runway.yml down
|
|
180
|
+
|
|
181
|
+
log_success "All health checks passed"
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
# Deploy to Runway
|
|
185
|
+
deploy_to_runway() {
|
|
186
|
+
log_info "Deploying to Runway ($ENVIRONMENT)..."
|
|
187
|
+
|
|
188
|
+
# Login to Runway
|
|
189
|
+
runway login || log_error "Failed to login to Runway"
|
|
190
|
+
|
|
191
|
+
# Validate configuration
|
|
192
|
+
runway validate || log_error "Runway configuration validation failed"
|
|
193
|
+
|
|
194
|
+
# Push Docker image
|
|
195
|
+
docker push "$REGISTRY_URL/${PROJECT_NAME}:${VERSION}-${ENVIRONMENT}"
|
|
196
|
+
|
|
197
|
+
# Deploy with canary strategy
|
|
198
|
+
runway deploy \
|
|
199
|
+
--environment "$ENVIRONMENT" \
|
|
200
|
+
--strategy canary \
|
|
201
|
+
--canary-percentage 10 \
|
|
202
|
+
--canary-duration 30m \
|
|
203
|
+
--wait \
|
|
204
|
+
--timeout 600
|
|
205
|
+
|
|
206
|
+
# Verify deployment
|
|
207
|
+
runway status "$PROJECT_NAME" --environment "$ENVIRONMENT"
|
|
208
|
+
|
|
209
|
+
log_success "Deployment successful"
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
# Smoke tests
|
|
213
|
+
run_smoke_tests() {
|
|
214
|
+
log_info "Running smoke tests..."
|
|
215
|
+
|
|
216
|
+
# Get deployment URL
|
|
217
|
+
DEPLOYMENT_URL=$(runway url "$PROJECT_NAME" --environment "$ENVIRONMENT")
|
|
218
|
+
|
|
219
|
+
# Test health endpoint
|
|
220
|
+
curl -f "$DEPLOYMENT_URL/health" || log_error "Health endpoint failed"
|
|
221
|
+
|
|
222
|
+
# Test metrics endpoint
|
|
223
|
+
curl -f "$DEPLOYMENT_URL/metrics" || log_error "Metrics endpoint failed"
|
|
224
|
+
|
|
225
|
+
# Test authentication
|
|
226
|
+
TEST_TOKEN=$(./scripts/get-test-token.sh)
|
|
227
|
+
curl -f -H "Authorization: Bearer $TEST_TOKEN" \
|
|
228
|
+
"$DEPLOYMENT_URL/api/v1/projects" || log_error "Authentication test failed"
|
|
229
|
+
|
|
230
|
+
log_success "Smoke tests passed"
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
# Monitor deployment
|
|
234
|
+
monitor_deployment() {
|
|
235
|
+
log_info "Monitoring deployment for 5 minutes..."
|
|
236
|
+
|
|
237
|
+
START_TIME=$(date +%s)
|
|
238
|
+
MONITOR_DURATION=300 # 5 minutes
|
|
239
|
+
|
|
240
|
+
while true; do
|
|
241
|
+
CURRENT_TIME=$(date +%s)
|
|
242
|
+
ELAPSED=$((CURRENT_TIME - START_TIME))
|
|
243
|
+
|
|
244
|
+
if [ $ELAPSED -gt $MONITOR_DURATION ]; then
|
|
245
|
+
break
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
# Check error rate
|
|
249
|
+
ERROR_RATE=$(runway metrics "$PROJECT_NAME" --metric error_rate --duration 1m)
|
|
250
|
+
if (( $(echo "$ERROR_RATE > 0.05" | bc -l) )); then
|
|
251
|
+
log_warning "High error rate detected: $ERROR_RATE"
|
|
252
|
+
fi
|
|
253
|
+
|
|
254
|
+
# Check latency
|
|
255
|
+
LATENCY=$(runway metrics "$PROJECT_NAME" --metric p95_latency --duration 1m)
|
|
256
|
+
if (( $(echo "$LATENCY > 2000" | bc -l) )); then
|
|
257
|
+
log_warning "High latency detected: ${LATENCY}ms"
|
|
258
|
+
fi
|
|
259
|
+
|
|
260
|
+
sleep 30
|
|
261
|
+
done
|
|
262
|
+
|
|
263
|
+
log_success "Monitoring complete"
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
# Rollback if needed
|
|
267
|
+
rollback_deployment() {
|
|
268
|
+
log_error "Deployment failed, rolling back..."
|
|
269
|
+
|
|
270
|
+
runway rollback "$PROJECT_NAME" \
|
|
271
|
+
--environment "$ENVIRONMENT" \
|
|
272
|
+
--to-previous \
|
|
273
|
+
--wait
|
|
274
|
+
|
|
275
|
+
log_info "Rollback completed"
|
|
276
|
+
exit 1
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
# Notification
|
|
280
|
+
send_notification() {
|
|
281
|
+
local STATUS=$1
|
|
282
|
+
local MESSAGE=$2
|
|
283
|
+
|
|
284
|
+
# Slack notification
|
|
285
|
+
if [ -n "${SLACK_WEBHOOK_URL:-}" ]; then
|
|
286
|
+
curl -X POST "$SLACK_WEBHOOK_URL" \
|
|
287
|
+
-H "Content-Type: application/json" \
|
|
288
|
+
-d "{
|
|
289
|
+
\"text\": \"Deployment $STATUS\",
|
|
290
|
+
\"attachments\": [{
|
|
291
|
+
\"color\": \"$([ "$STATUS" == "SUCCESS" ] && echo "good" || echo "danger")\",
|
|
292
|
+
\"fields\": [{
|
|
293
|
+
\"title\": \"Project\",
|
|
294
|
+
\"value\": \"$PROJECT_NAME\",
|
|
295
|
+
\"short\": true
|
|
296
|
+
}, {
|
|
297
|
+
\"title\": \"Environment\",
|
|
298
|
+
\"value\": \"$ENVIRONMENT\",
|
|
299
|
+
\"short\": true
|
|
300
|
+
}, {
|
|
301
|
+
\"title\": \"Message\",
|
|
302
|
+
\"value\": \"$MESSAGE\"
|
|
303
|
+
}]
|
|
304
|
+
}]
|
|
305
|
+
}"
|
|
306
|
+
fi
|
|
307
|
+
|
|
308
|
+
# Email notification
|
|
309
|
+
if [ -n "${NOTIFICATION_EMAIL:-}" ]; then
|
|
310
|
+
echo "$MESSAGE" | mail -s "Deployment $STATUS: $PROJECT_NAME" "$NOTIFICATION_EMAIL"
|
|
311
|
+
fi
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
# Main deployment flow
|
|
315
|
+
main() {
|
|
316
|
+
log_info "Starting deployment for $PROJECT_NAME to $ENVIRONMENT"
|
|
317
|
+
log_info "================================================"
|
|
318
|
+
|
|
319
|
+
# Set error trap
|
|
320
|
+
trap 'rollback_deployment' ERR
|
|
321
|
+
|
|
322
|
+
# Pre-deployment checks
|
|
323
|
+
check_prerequisites
|
|
324
|
+
|
|
325
|
+
# Build and test
|
|
326
|
+
run_tests
|
|
327
|
+
build_application
|
|
328
|
+
build_docker_image
|
|
329
|
+
|
|
330
|
+
# Local verification
|
|
331
|
+
perform_health_checks
|
|
332
|
+
|
|
333
|
+
# Database setup
|
|
334
|
+
run_migrations
|
|
335
|
+
|
|
336
|
+
# Deploy
|
|
337
|
+
deploy_to_runway
|
|
338
|
+
|
|
339
|
+
# Post-deployment verification
|
|
340
|
+
run_smoke_tests
|
|
341
|
+
monitor_deployment
|
|
342
|
+
|
|
343
|
+
# Success notification
|
|
344
|
+
send_notification "SUCCESS" "Deployment completed successfully"
|
|
345
|
+
|
|
346
|
+
log_success "================================================"
|
|
347
|
+
log_success "Deployment completed successfully!"
|
|
348
|
+
log_success "URL: $(runway url "$PROJECT_NAME" --environment "$ENVIRONMENT")"
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
# Run main function
|
|
352
|
+
main "$@"
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Test Railway deployment
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import https from 'https';
|
|
7
|
+
import http from 'http';
|
|
8
|
+
|
|
9
|
+
const RAILWAY_URL = process.argv[2] || process.env.RAILWAY_URL;
|
|
10
|
+
const API_KEY =
|
|
11
|
+
process.argv[3] ||
|
|
12
|
+
process.env.API_KEY_SECRET ||
|
|
13
|
+
'a232e4cfe79628a729ba3e9ce29476422ebefb78f1db46fb7e8a6f11bebf5e0a';
|
|
14
|
+
|
|
15
|
+
if (!RAILWAY_URL) {
|
|
16
|
+
console.error('Usage: node scripts/test-railway.js <RAILWAY_URL> [API_KEY]');
|
|
17
|
+
console.error(
|
|
18
|
+
'Example: node scripts/test-railway.js https://your-app.railway.app'
|
|
19
|
+
);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.log(`š§Ŗ Testing Railway deployment at: ${RAILWAY_URL}`);
|
|
24
|
+
|
|
25
|
+
async function makeRequest(url, options = {}) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const client = url.startsWith('https:') ? https : http;
|
|
28
|
+
|
|
29
|
+
const req = client.request(url, options, (res) => {
|
|
30
|
+
let data = '';
|
|
31
|
+
res.on('data', (chunk) => (data += chunk));
|
|
32
|
+
res.on('end', () => {
|
|
33
|
+
try {
|
|
34
|
+
resolve({
|
|
35
|
+
status: res.statusCode,
|
|
36
|
+
headers: res.headers,
|
|
37
|
+
data: res.headers['content-type']?.includes('application/json')
|
|
38
|
+
? JSON.parse(data)
|
|
39
|
+
: data,
|
|
40
|
+
});
|
|
41
|
+
} catch (e) {
|
|
42
|
+
resolve({
|
|
43
|
+
status: res.statusCode,
|
|
44
|
+
headers: res.headers,
|
|
45
|
+
data: data,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
req.on('error', reject);
|
|
52
|
+
if (options.body) {
|
|
53
|
+
req.write(options.body);
|
|
54
|
+
}
|
|
55
|
+
req.end();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function runTests() {
|
|
60
|
+
console.log('\nš Running health checks...\n');
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
// 1. Health Check
|
|
64
|
+
console.log('1. Testing health endpoint...');
|
|
65
|
+
const health = await makeRequest(`${RAILWAY_URL}/health`);
|
|
66
|
+
|
|
67
|
+
if (health.status === 200) {
|
|
68
|
+
console.log('ā
Health check passed');
|
|
69
|
+
console.log(' Status:', health.data.status);
|
|
70
|
+
console.log(' Environment:', health.data.environment);
|
|
71
|
+
console.log(' Uptime:', Math.round(health.data.uptime), 'seconds');
|
|
72
|
+
} else {
|
|
73
|
+
console.log('ā Health check failed:', health.status);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 2. Authentication Test
|
|
78
|
+
console.log('\n2. Testing authentication...');
|
|
79
|
+
const authTest = await makeRequest(`${RAILWAY_URL}/api/context/load`, {
|
|
80
|
+
method: 'GET',
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
83
|
+
'Content-Type': 'application/json',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (authTest.status === 200) {
|
|
88
|
+
console.log('ā
Authentication working');
|
|
89
|
+
console.log(' Contexts loaded:', authTest.data.contexts?.length || 0);
|
|
90
|
+
} else {
|
|
91
|
+
console.log('ā Authentication failed:', authTest.status);
|
|
92
|
+
console.log(' Error:', authTest.data?.error || 'Unknown error');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 3. Save Context Test
|
|
96
|
+
console.log('\n3. Testing context save...');
|
|
97
|
+
const saveTest = await makeRequest(`${RAILWAY_URL}/api/context/save`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: {
|
|
100
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
101
|
+
'Content-Type': 'application/json',
|
|
102
|
+
},
|
|
103
|
+
body: JSON.stringify({
|
|
104
|
+
content: 'Railway deployment test context',
|
|
105
|
+
type: 'test',
|
|
106
|
+
metadata: { deployedAt: new Date().toISOString() },
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (saveTest.status === 200) {
|
|
111
|
+
console.log('ā
Context save working');
|
|
112
|
+
console.log(' Context ID:', saveTest.data.id);
|
|
113
|
+
} else {
|
|
114
|
+
console.log('ā Context save failed:', saveTest.status);
|
|
115
|
+
console.log(' Error:', saveTest.data?.error || 'Unknown error');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 4. MCP Tool Test
|
|
119
|
+
console.log('\n4. Testing MCP tool execution...');
|
|
120
|
+
const toolTest = await makeRequest(`${RAILWAY_URL}/api/tools/execute`, {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
headers: {
|
|
123
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
124
|
+
'Content-Type': 'application/json',
|
|
125
|
+
},
|
|
126
|
+
body: JSON.stringify({
|
|
127
|
+
tool: 'load_context',
|
|
128
|
+
params: {
|
|
129
|
+
query: 'test',
|
|
130
|
+
limit: 5,
|
|
131
|
+
},
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (toolTest.status === 200) {
|
|
136
|
+
console.log('ā
MCP tool execution working');
|
|
137
|
+
console.log(
|
|
138
|
+
' Found contexts:',
|
|
139
|
+
toolTest.data.result?.contexts?.length || 0
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
console.log('ā MCP tool execution failed:', toolTest.status);
|
|
143
|
+
console.log(' Error:', toolTest.data?.error || 'Unknown error');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 5. Analytics Test (if enabled)
|
|
147
|
+
console.log('\n5. Testing analytics endpoint...');
|
|
148
|
+
const analyticsTest = await makeRequest(`${RAILWAY_URL}/api/analytics`, {
|
|
149
|
+
method: 'GET',
|
|
150
|
+
headers: {
|
|
151
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (analyticsTest.status === 200) {
|
|
156
|
+
console.log('ā
Analytics working');
|
|
157
|
+
console.log(
|
|
158
|
+
' Total contexts:',
|
|
159
|
+
analyticsTest.data.analytics?.total_contexts || 0
|
|
160
|
+
);
|
|
161
|
+
} else {
|
|
162
|
+
console.log('ā ļø Analytics not available (may be disabled)');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
console.log('\nš Railway deployment test complete!\n');
|
|
166
|
+
console.log(`š Your StackMemory MCP Server is running at: ${RAILWAY_URL}`);
|
|
167
|
+
console.log(`š API Key: ${API_KEY.substring(0, 8)}...`);
|
|
168
|
+
|
|
169
|
+
console.log('\nš Claude.ai MCP Configuration:');
|
|
170
|
+
console.log(`{
|
|
171
|
+
"mcpServers": {
|
|
172
|
+
"stackmemory": {
|
|
173
|
+
"command": "curl",
|
|
174
|
+
"args": [
|
|
175
|
+
"-X", "POST",
|
|
176
|
+
"-H", "Authorization: Bearer ${API_KEY}",
|
|
177
|
+
"-H", "Content-Type: application/json",
|
|
178
|
+
"-d", "{\\"tool\\": \\"load_context\\", \\"params\\": {\\"query\\": \\"\\", \\"limit\\": 10}}",
|
|
179
|
+
"${RAILWAY_URL}/api/tools/execute"
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}`);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.error('ā Test failed:', error.message);
|
|
186
|
+
console.error('\nš Troubleshooting:');
|
|
187
|
+
console.error('1. Check if Railway deployment is complete');
|
|
188
|
+
console.error('2. Verify environment variables are set');
|
|
189
|
+
console.error('3. Check Railway logs for errors');
|
|
190
|
+
console.error('4. Ensure PostgreSQL database is connected');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
runTests();
|