@programinglive/dev-workflow-mcp-server 1.7.11 → 1.7.13
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/.dockerignore +60 -0
- package/.env.example +1 -0
- package/.env.production +16 -0
- package/CHANGELOG.md +35 -0
- package/Dockerfile +32 -0
- package/README.md +20 -0
- package/db/migrations/002_create_users_table.sql +22 -0
- package/db/migrations/003_create_workflow_history.sql +14 -0
- package/db/migrations/004_fix_workflow_history.sql +3 -0
- package/docker-compose.yml +24 -0
- package/docs/GCP_DEPLOYMENT.md +298 -0
- package/docs/product/PRD.md +1 -1
- package/docs/release-notes/RELEASE_NOTES.md +34 -0
- package/package.json +7 -2
- package/scripts/add-user.js +52 -0
- package/scripts/create-admin.js +47 -0
- package/scripts/deploy-gcloud.ps1 +160 -0
- package/scripts/deploy-gcloud.sh +154 -0
- package/scripts/health-check.js +50 -0
- package/scripts/test-history.js +56 -0
- package/web/__tests__/api/workflow-history.test.js +61 -0
- package/web/app/api/history-fallback/route.ts +56 -0
- package/web/app/docs/page.tsx +1 -1
- package/web/app/history/page.tsx +213 -0
- package/web/app/layout.tsx +1 -1
- package/web/app/login/page.tsx +144 -0
- package/web/app/page.tsx +0 -2
- package/web/components/Hero.tsx +1 -1
- package/web/components/History.tsx +63 -16
- package/web/components/Navbar.tsx +111 -9
- package/web/lib/auth.js +75 -0
- package/web/middleware/auth.js +26 -0
- package/web/next.config.ts +8 -1
- package/web/package-lock.json +239 -54
- package/web/package.json +10 -5
- package/web/scripts/db-query-history.js +120 -0
- package/web/scripts/smoke-test.js +30 -0
- package/web/server.js +171 -18
- package/verify-db-mysql.js +0 -92
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import pg from 'pg';
|
|
4
|
+
import { createUser } from '../web/lib/auth.js';
|
|
5
|
+
|
|
6
|
+
const { Pool } = pg;
|
|
7
|
+
|
|
8
|
+
// Get database configuration from environment
|
|
9
|
+
const dbUrl = process.env.DEV_WORKFLOW_DB_URL;
|
|
10
|
+
|
|
11
|
+
if (!dbUrl) {
|
|
12
|
+
console.error('Error: DEV_WORKFLOW_DB_URL environment variable is not set');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const pool = new Pool({ connectionString: dbUrl });
|
|
17
|
+
|
|
18
|
+
async function createAdminUser() {
|
|
19
|
+
const username = process.env.ADMIN_USERNAME || 'admin';
|
|
20
|
+
const password = process.env.ADMIN_PASSWORD || 'admin123';
|
|
21
|
+
const email = process.env.ADMIN_EMAIL || 'admin@example.com';
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
// Check if admin user already exists
|
|
25
|
+
const existing = await pool.query('SELECT id FROM users WHERE username = $1', [username]);
|
|
26
|
+
|
|
27
|
+
if (existing.rows.length > 0) {
|
|
28
|
+
console.log(`✓ Admin user '${username}' already exists`);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Create admin user
|
|
33
|
+
const user = await createUser(pool, username, password, email);
|
|
34
|
+
console.log(`✓ Created admin user: ${user.username}`);
|
|
35
|
+
console.log(` Email: ${user.email}`);
|
|
36
|
+
console.log(` Password: ${password}`);
|
|
37
|
+
console.log('\n⚠️ Please change the password after first login!');
|
|
38
|
+
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error creating admin user:', error.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
} finally {
|
|
43
|
+
await pool.end();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
createAdminUser();
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# GCP Deployment Script using gcloud CLI (PowerShell)
|
|
2
|
+
# This script deploys the dev-workflow MCP server to a GCP Compute Engine instance
|
|
3
|
+
|
|
4
|
+
$ErrorActionPreference = "Stop"
|
|
5
|
+
|
|
6
|
+
# Configuration - Update these values
|
|
7
|
+
$PROJECT_ID = if ($env:GCP_PROJECT_ID) { $env:GCP_PROJECT_ID } else { "edmee-project" }
|
|
8
|
+
$INSTANCE_NAME = if ($env:GCP_INSTANCE_NAME) { $env:GCP_INSTANCE_NAME } else { "docker-almi" }
|
|
9
|
+
$ZONE = if ($env:GCP_ZONE) { $env:GCP_ZONE } else { "asia-southeast2-a" }
|
|
10
|
+
$INSTANCE_USER = if ($env:GCP_INSTANCE_USER) { $env:GCP_INSTANCE_USER } else { "dhika" }
|
|
11
|
+
|
|
12
|
+
Write-Host "🚀 Deploying dev-workflow MCP server to GCP..." -ForegroundColor Cyan
|
|
13
|
+
Write-Host "Project: $PROJECT_ID"
|
|
14
|
+
Write-Host "Instance: $INSTANCE_NAME"
|
|
15
|
+
Write-Host "Zone: $ZONE"
|
|
16
|
+
Write-Host ""
|
|
17
|
+
|
|
18
|
+
# Check if gcloud is installed
|
|
19
|
+
if (!(Get-Command gcloud -ErrorAction SilentlyContinue)) {
|
|
20
|
+
Write-Host "❌ gcloud CLI is not installed" -ForegroundColor Red
|
|
21
|
+
Write-Host "Please install it from: https://cloud.google.com/sdk/docs/install"
|
|
22
|
+
exit 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Set the project
|
|
26
|
+
Write-Host "📋 Setting GCP project..." -ForegroundColor Yellow
|
|
27
|
+
gcloud config set project $PROJECT_ID
|
|
28
|
+
|
|
29
|
+
# Get instance external IP
|
|
30
|
+
Write-Host "🔍 Getting instance external IP..." -ForegroundColor Yellow
|
|
31
|
+
$EXTERNAL_IP = gcloud compute instances describe $INSTANCE_NAME `
|
|
32
|
+
--zone=$ZONE `
|
|
33
|
+
--format="get(networkInterfaces[0].accessConfigs[0].natIP)"
|
|
34
|
+
|
|
35
|
+
if ([string]::IsNullOrEmpty($EXTERNAL_IP)) {
|
|
36
|
+
Write-Host "❌ Could not get instance external IP" -ForegroundColor Red
|
|
37
|
+
exit 1
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Write-Host "✅ Instance IP: $EXTERNAL_IP" -ForegroundColor Green
|
|
41
|
+
Write-Host ""
|
|
42
|
+
|
|
43
|
+
# Test SSH connection
|
|
44
|
+
Write-Host "🔐 Testing SSH connection..." -ForegroundColor Yellow
|
|
45
|
+
try {
|
|
46
|
+
$testResult = gcloud compute ssh "$INSTANCE_USER@$INSTANCE_NAME" `
|
|
47
|
+
--zone=$ZONE `
|
|
48
|
+
--command="echo 'Connection successful'" 2>&1
|
|
49
|
+
Write-Host "✅ SSH connection successful" -ForegroundColor Green
|
|
50
|
+
} catch {
|
|
51
|
+
Write-Host "❌ Cannot connect to instance via SSH" -ForegroundColor Red
|
|
52
|
+
Write-Host "Please ensure:"
|
|
53
|
+
Write-Host " 1. SSH keys are configured in GCP"
|
|
54
|
+
Write-Host " 2. Firewall allows SSH (port 22)"
|
|
55
|
+
Write-Host " 3. Instance is running"
|
|
56
|
+
exit 1
|
|
57
|
+
}
|
|
58
|
+
Write-Host ""
|
|
59
|
+
|
|
60
|
+
# Copy files to instance
|
|
61
|
+
Write-Host "📦 Copying project files to instance..." -ForegroundColor Yellow
|
|
62
|
+
gcloud compute scp --recurse `
|
|
63
|
+
--zone=$ZONE `
|
|
64
|
+
. "$INSTANCE_USER@${INSTANCE_NAME}:~/dev-workflow-mcp-server/" `
|
|
65
|
+
--exclude=".git" `
|
|
66
|
+
--exclude="node_modules" `
|
|
67
|
+
--exclude=".state" `
|
|
68
|
+
--exclude="dist"
|
|
69
|
+
|
|
70
|
+
Write-Host "✅ Files copied successfully" -ForegroundColor Green
|
|
71
|
+
Write-Host ""
|
|
72
|
+
|
|
73
|
+
# Create deployment script for remote execution
|
|
74
|
+
$deployScript = @'
|
|
75
|
+
set -e
|
|
76
|
+
|
|
77
|
+
cd ~/dev-workflow-mcp-server
|
|
78
|
+
|
|
79
|
+
echo "📥 Installing Docker if not present..."
|
|
80
|
+
if ! command -v docker &> /dev/null; then
|
|
81
|
+
curl -fsSL https://get.docker.com -o get-docker.sh
|
|
82
|
+
sudo sh get-docker.sh
|
|
83
|
+
sudo usermod -aG docker $USER
|
|
84
|
+
rm get-docker.sh
|
|
85
|
+
echo "✅ Docker installed"
|
|
86
|
+
else
|
|
87
|
+
echo "✅ Docker already installed"
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
echo "📥 Installing Docker Compose if not present..."
|
|
91
|
+
if ! command -v docker-compose &> /dev/null; then
|
|
92
|
+
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
93
|
+
sudo chmod +x /usr/local/bin/docker-compose
|
|
94
|
+
echo "✅ Docker Compose installed"
|
|
95
|
+
else
|
|
96
|
+
echo "✅ Docker Compose already installed"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
echo "⚙️ Configuring environment..."
|
|
100
|
+
if [ ! -f .env ]; then
|
|
101
|
+
cp .env.production .env
|
|
102
|
+
echo "⚠️ Created .env file from template"
|
|
103
|
+
echo "⚠️ Please update the passwords in .env before production use!"
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
echo "🛑 Stopping existing containers..."
|
|
107
|
+
docker-compose down 2>/dev/null || true
|
|
108
|
+
|
|
109
|
+
echo "🏗️ Building Docker images..."
|
|
110
|
+
docker-compose build --no-cache
|
|
111
|
+
|
|
112
|
+
echo "🚀 Starting containers..."
|
|
113
|
+
docker-compose up -d
|
|
114
|
+
|
|
115
|
+
echo "⏳ Waiting for services to be healthy..."
|
|
116
|
+
sleep 15
|
|
117
|
+
|
|
118
|
+
echo "📊 Checking container status..."
|
|
119
|
+
docker-compose ps
|
|
120
|
+
|
|
121
|
+
echo ""
|
|
122
|
+
echo "✅ Deployment complete!"
|
|
123
|
+
echo ""
|
|
124
|
+
echo "Container logs:"
|
|
125
|
+
docker-compose logs --tail=20
|
|
126
|
+
'@
|
|
127
|
+
|
|
128
|
+
# Run deployment commands on the instance
|
|
129
|
+
Write-Host "🚀 Running deployment on instance..." -ForegroundColor Yellow
|
|
130
|
+
$deployScript | gcloud compute ssh "$INSTANCE_USER@$INSTANCE_NAME" `
|
|
131
|
+
--zone=$ZONE `
|
|
132
|
+
--command="bash -s"
|
|
133
|
+
|
|
134
|
+
Write-Host ""
|
|
135
|
+
Write-Host "🎉 Deployment successful!" -ForegroundColor Green
|
|
136
|
+
Write-Host ""
|
|
137
|
+
Write-Host "📝 Next steps:" -ForegroundColor Cyan
|
|
138
|
+
Write-Host "1. SSH into instance and update .env with secure passwords:"
|
|
139
|
+
Write-Host " gcloud compute ssh $INSTANCE_USER@$INSTANCE_NAME --zone=$ZONE"
|
|
140
|
+
Write-Host " cd ~/dev-workflow-mcp-server"
|
|
141
|
+
Write-Host " nano .env"
|
|
142
|
+
Write-Host ""
|
|
143
|
+
Write-Host "2. Update your local MCP client config:" -ForegroundColor Cyan
|
|
144
|
+
Write-Host @"
|
|
145
|
+
{
|
|
146
|
+
"mcpServers": {
|
|
147
|
+
"dev-workflow": {
|
|
148
|
+
"command": "gcloud",
|
|
149
|
+
"args": [
|
|
150
|
+
"compute", "ssh", "$INSTANCE_USER@$INSTANCE_NAME",
|
|
151
|
+
"--zone=$ZONE",
|
|
152
|
+
"--command=docker exec -i dev-workflow-mcp node /app/index.js"
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
"@
|
|
158
|
+
Write-Host ""
|
|
159
|
+
Write-Host "3. Test the connection:" -ForegroundColor Cyan
|
|
160
|
+
Write-Host " gcloud compute ssh $INSTANCE_USER@$INSTANCE_NAME --zone=$ZONE --command='docker exec -i dev-workflow-mcp node /app/index.js call get_workflow_status'"
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# GCP Deployment Script using gcloud CLI
|
|
3
|
+
# This script deploys the dev-workflow MCP server to a GCP Compute Engine instance
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Configuration - Update these values
|
|
8
|
+
PROJECT_ID="${GCP_PROJECT_ID:-edmee-project}"
|
|
9
|
+
INSTANCE_NAME="${GCP_INSTANCE_NAME:-docker-almi}"
|
|
10
|
+
ZONE="${GCP_ZONE:-asia-southeast2-a}"
|
|
11
|
+
INSTANCE_USER="${GCP_INSTANCE_USER:-dhika}"
|
|
12
|
+
|
|
13
|
+
echo "🚀 Deploying dev-workflow MCP server to GCP..."
|
|
14
|
+
echo "Project: $PROJECT_ID"
|
|
15
|
+
echo "Instance: $INSTANCE_NAME"
|
|
16
|
+
echo "Zone: $ZONE"
|
|
17
|
+
echo ""
|
|
18
|
+
|
|
19
|
+
# Check if gcloud is installed
|
|
20
|
+
if ! command -v gcloud &> /dev/null; then
|
|
21
|
+
echo "❌ gcloud CLI is not installed"
|
|
22
|
+
echo "Please install it from: https://cloud.google.com/sdk/docs/install"
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# Set the project
|
|
27
|
+
echo "📋 Setting GCP project..."
|
|
28
|
+
gcloud config set project "$PROJECT_ID"
|
|
29
|
+
|
|
30
|
+
# Get instance external IP
|
|
31
|
+
echo "🔍 Getting instance external IP..."
|
|
32
|
+
EXTERNAL_IP=$(gcloud compute instances describe "$INSTANCE_NAME" \
|
|
33
|
+
--zone="$ZONE" \
|
|
34
|
+
--format="get(networkInterfaces[0].accessConfigs[0].natIP)")
|
|
35
|
+
|
|
36
|
+
if [ -z "$EXTERNAL_IP" ]; then
|
|
37
|
+
echo "❌ Could not get instance external IP"
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
echo "✅ Instance IP: $EXTERNAL_IP"
|
|
42
|
+
echo ""
|
|
43
|
+
|
|
44
|
+
# Test SSH connection
|
|
45
|
+
echo "🔐 Testing SSH connection..."
|
|
46
|
+
if ! gcloud compute ssh "$INSTANCE_USER@$INSTANCE_NAME" \
|
|
47
|
+
--zone="$ZONE" \
|
|
48
|
+
--command="echo 'Connection successful'" &> /dev/null; then
|
|
49
|
+
echo "❌ Cannot connect to instance via SSH"
|
|
50
|
+
echo "Please ensure:"
|
|
51
|
+
echo " 1. SSH keys are configured in GCP"
|
|
52
|
+
echo " 2. Firewall allows SSH (port 22)"
|
|
53
|
+
echo " 3. Instance is running"
|
|
54
|
+
exit 1
|
|
55
|
+
fi
|
|
56
|
+
echo "✅ SSH connection successful"
|
|
57
|
+
echo ""
|
|
58
|
+
|
|
59
|
+
# Copy files to instance
|
|
60
|
+
echo "📦 Copying project files to instance..."
|
|
61
|
+
gcloud compute scp --recurse \
|
|
62
|
+
--zone="$ZONE" \
|
|
63
|
+
. "$INSTANCE_USER@$INSTANCE_NAME:~/dev-workflow-mcp-server/" \
|
|
64
|
+
--exclude=".git" \
|
|
65
|
+
--exclude="node_modules" \
|
|
66
|
+
--exclude=".state" \
|
|
67
|
+
--exclude="dist"
|
|
68
|
+
|
|
69
|
+
echo "✅ Files copied successfully"
|
|
70
|
+
echo ""
|
|
71
|
+
|
|
72
|
+
# Run deployment commands on the instance
|
|
73
|
+
echo "🚀 Running deployment on instance..."
|
|
74
|
+
gcloud compute ssh "$INSTANCE_USER@$INSTANCE_NAME" \
|
|
75
|
+
--zone="$ZONE" \
|
|
76
|
+
--command="bash -s" << 'ENDSSH'
|
|
77
|
+
set -e
|
|
78
|
+
|
|
79
|
+
cd ~/dev-workflow-mcp-server
|
|
80
|
+
|
|
81
|
+
echo "📥 Installing Docker if not present..."
|
|
82
|
+
if ! command -v docker &> /dev/null; then
|
|
83
|
+
curl -fsSL https://get.docker.com -o get-docker.sh
|
|
84
|
+
sudo sh get-docker.sh
|
|
85
|
+
sudo usermod -aG docker $USER
|
|
86
|
+
rm get-docker.sh
|
|
87
|
+
echo "✅ Docker installed"
|
|
88
|
+
else
|
|
89
|
+
echo "✅ Docker already installed"
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
echo "📥 Installing Docker Compose if not present..."
|
|
93
|
+
if ! command -v docker-compose &> /dev/null; then
|
|
94
|
+
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
95
|
+
sudo chmod +x /usr/local/bin/docker-compose
|
|
96
|
+
echo "✅ Docker Compose installed"
|
|
97
|
+
else
|
|
98
|
+
echo "✅ Docker Compose already installed"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
echo "⚙️ Configuring environment..."
|
|
102
|
+
if [ ! -f .env ]; then
|
|
103
|
+
cp .env.production .env
|
|
104
|
+
echo "⚠️ Created .env file from template"
|
|
105
|
+
echo "⚠️ Please update the passwords in .env before production use!"
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
echo "🛑 Stopping existing containers..."
|
|
109
|
+
docker-compose down 2>/dev/null || true
|
|
110
|
+
|
|
111
|
+
echo "🏗️ Building Docker images..."
|
|
112
|
+
docker-compose build --no-cache
|
|
113
|
+
|
|
114
|
+
echo "🚀 Starting containers..."
|
|
115
|
+
docker-compose up -d
|
|
116
|
+
|
|
117
|
+
echo "⏳ Waiting for services to be healthy..."
|
|
118
|
+
sleep 15
|
|
119
|
+
|
|
120
|
+
echo "📊 Checking container status..."
|
|
121
|
+
docker-compose ps
|
|
122
|
+
|
|
123
|
+
echo ""
|
|
124
|
+
echo "✅ Deployment complete!"
|
|
125
|
+
echo ""
|
|
126
|
+
echo "Container logs:"
|
|
127
|
+
docker-compose logs --tail=20
|
|
128
|
+
ENDSSH
|
|
129
|
+
|
|
130
|
+
echo ""
|
|
131
|
+
echo "🎉 Deployment successful!"
|
|
132
|
+
echo ""
|
|
133
|
+
echo "📝 Next steps:"
|
|
134
|
+
echo "1. SSH into instance and update .env with secure passwords:"
|
|
135
|
+
echo " gcloud compute ssh $INSTANCE_USER@$INSTANCE_NAME --zone=$ZONE"
|
|
136
|
+
echo " cd ~/dev-workflow-mcp-server"
|
|
137
|
+
echo " nano .env"
|
|
138
|
+
echo ""
|
|
139
|
+
echo "2. Update your local MCP client config:"
|
|
140
|
+
echo " {"
|
|
141
|
+
echo " \"mcpServers\": {"
|
|
142
|
+
echo " \"dev-workflow\": {"
|
|
143
|
+
echo " \"command\": \"gcloud\","
|
|
144
|
+
echo " \"args\": ["
|
|
145
|
+
echo " \"compute\", \"ssh\", \"$INSTANCE_USER@$INSTANCE_NAME\","
|
|
146
|
+
echo " \"--zone=$ZONE\","
|
|
147
|
+
echo " \"--command=docker exec -i dev-workflow-mcp node /app/index.js\""
|
|
148
|
+
echo " ]"
|
|
149
|
+
echo " }"
|
|
150
|
+
echo " }"
|
|
151
|
+
echo " }"
|
|
152
|
+
echo ""
|
|
153
|
+
echo "3. Test the connection:"
|
|
154
|
+
echo " gcloud compute ssh $INSTANCE_USER@$INSTANCE_NAME --zone=$ZONE --command='docker exec -i dev-workflow-mcp node /app/index.js call get_workflow_status'"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
import pg from 'pg';
|
|
3
|
+
const { Client } = pg;
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import dotenv from 'dotenv';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
|
|
12
|
+
// Load env from root
|
|
13
|
+
const envPath = path.resolve(__dirname, '../.env');
|
|
14
|
+
if (fs.existsSync(envPath)) {
|
|
15
|
+
dotenv.config({ path: envPath });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function healthCheck() {
|
|
19
|
+
console.log('--- Database Health Check ---');
|
|
20
|
+
|
|
21
|
+
if (!process.env.DEV_WORKFLOW_DB_URL) {
|
|
22
|
+
console.error('❌ DEV_WORKFLOW_DB_URL is missing!');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const client = new Client({
|
|
27
|
+
connectionString: process.env.DEV_WORKFLOW_DB_URL,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
await client.connect();
|
|
32
|
+
console.log('✅ Connectivity: OK');
|
|
33
|
+
|
|
34
|
+
// Simple query to verify schema access
|
|
35
|
+
const res = await client.query('SELECT count(*) as count FROM workflow_history');
|
|
36
|
+
console.log(`✅ Schema Access: OK (Found ${res.rows[0].count} history entries)`);
|
|
37
|
+
|
|
38
|
+
// Check users table
|
|
39
|
+
const users = await client.query('SELECT count(*) as count FROM users');
|
|
40
|
+
console.log(`✅ Auth Table: OK (Found ${users.rows[0].count} users)`);
|
|
41
|
+
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error('❌ Health Check Failed:', err.message);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
} finally {
|
|
46
|
+
await client.end();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
healthCheck();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
import { exec } from 'child_process';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import util from 'util';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const execPromise = util.promisify(exec);
|
|
10
|
+
|
|
11
|
+
async function testHistoryScript() {
|
|
12
|
+
console.log('--- Testing db-query-history.js execution ---');
|
|
13
|
+
|
|
14
|
+
// Simulate what route.ts does:
|
|
15
|
+
// 1. Path to script
|
|
16
|
+
// 2. Env vars
|
|
17
|
+
// 3. Child process exec
|
|
18
|
+
|
|
19
|
+
const scriptPath = path.join(__dirname, '../web/scripts/db-query-history.js');
|
|
20
|
+
console.log('Script Path:', scriptPath);
|
|
21
|
+
|
|
22
|
+
// Simulate "programinglive" session if possible, or empty string (fallback to admin)
|
|
23
|
+
// We don't have a valid session ID handy without login, so let's pass empty, which triggers the fallback logic (find admin/any user)
|
|
24
|
+
const sid = '';
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const { stdout, stderr } = await execPromise(`node "${scriptPath}" "${sid}"`, {
|
|
28
|
+
env: { ...process.env, DEV_WORKFLOW_DB_URL: process.env.DEV_WORKFLOW_DB_URL }
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log('STDOUT:', stdout);
|
|
32
|
+
if (stderr) console.error('STDERR:', stderr);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const data = JSON.parse(stdout);
|
|
36
|
+
console.log('✅ Success! Parsed JSON:', data);
|
|
37
|
+
if (data.history && data.history.length === 0) {
|
|
38
|
+
console.warn('⚠️ History is empty (check user_id linkage)');
|
|
39
|
+
}
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error('❌ Failed to parse JSON:', e.message);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.error('❌ Execution Failed:', err.message);
|
|
46
|
+
console.error('STDOUT:', err.stdout);
|
|
47
|
+
console.error('STDERR:', err.stderr);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// We need to load .env for this test script itself to run?
|
|
52
|
+
// Actually the exec inherits process.env.
|
|
53
|
+
// But we are running THIS script with node, so we need dotenv here if relying on process.env passing through.
|
|
54
|
+
import 'dotenv/config'; // simplistic load
|
|
55
|
+
|
|
56
|
+
testHistoryScript();
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const request = require('supertest');
|
|
2
|
+
const express = require('express');
|
|
3
|
+
|
|
4
|
+
describe('Workflow History API', () => {
|
|
5
|
+
let app;
|
|
6
|
+
let server;
|
|
7
|
+
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
// Mock Express app for testing
|
|
10
|
+
app = express();
|
|
11
|
+
app.use(express.json());
|
|
12
|
+
|
|
13
|
+
// Mock session middleware
|
|
14
|
+
app.use((req, res, next) => {
|
|
15
|
+
req.session = { userId: 1 };
|
|
16
|
+
next();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Mock history endpoint
|
|
20
|
+
app.get('/api/workflow/history', async (req, res) => {
|
|
21
|
+
// Mock response
|
|
22
|
+
res.json({
|
|
23
|
+
history: [
|
|
24
|
+
{
|
|
25
|
+
id: 1,
|
|
26
|
+
task_type: 'feature',
|
|
27
|
+
description: 'Test feature',
|
|
28
|
+
commit_message: 'feat: test commit',
|
|
29
|
+
completed_at: new Date().toISOString(),
|
|
30
|
+
tests_passed: true,
|
|
31
|
+
documentation_type: 'README'
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('GET /api/workflow/history returns workflow history', async () => {
|
|
39
|
+
const response = await request(app)
|
|
40
|
+
.get('/api/workflow/history')
|
|
41
|
+
.expect(200);
|
|
42
|
+
|
|
43
|
+
expect(response.body).toHaveProperty('history');
|
|
44
|
+
expect(Array.isArray(response.body.history)).toBe(true);
|
|
45
|
+
expect(response.body.history.length).toBeGreaterThan(0);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('History items have required fields', async () => {
|
|
49
|
+
const response = await request(app)
|
|
50
|
+
.get('/api/workflow/history')
|
|
51
|
+
.expect(200);
|
|
52
|
+
|
|
53
|
+
const item = response.body.history[0];
|
|
54
|
+
expect(item).toHaveProperty('id');
|
|
55
|
+
expect(item).toHaveProperty('task_type');
|
|
56
|
+
expect(item).toHaveProperty('description');
|
|
57
|
+
expect(item).toHaveProperty('commit_message');
|
|
58
|
+
expect(item).toHaveProperty('completed_at');
|
|
59
|
+
expect(item).toHaveProperty('tests_passed');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { cookies } from 'next/headers';
|
|
3
|
+
import { exec } from 'child_process';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import util from 'util';
|
|
6
|
+
|
|
7
|
+
const execPromise = util.promisify(exec);
|
|
8
|
+
|
|
9
|
+
export const dynamic = 'force-dynamic';
|
|
10
|
+
|
|
11
|
+
export async function GET(request: Request) {
|
|
12
|
+
try {
|
|
13
|
+
const cookieStore = await cookies();
|
|
14
|
+
const sidCookie = cookieStore.get('connect.sid');
|
|
15
|
+
|
|
16
|
+
// Pass SID (even if undefined, script has fallback)
|
|
17
|
+
const sid = sidCookie ? sidCookie.value : '';
|
|
18
|
+
|
|
19
|
+
const scriptPath = path.join(process.cwd(), 'scripts', 'db-query-history.js');
|
|
20
|
+
const env = { ...process.env };
|
|
21
|
+
|
|
22
|
+
// Execute node script, passing SID as argument
|
|
23
|
+
const { stdout, stderr } = await execPromise(`node "${scriptPath}" "${sid}"`, { env });
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Find start of JSON by looking for specific signature
|
|
27
|
+
const jsonStart = stdout.indexOf('{"history":');
|
|
28
|
+
const jsonEnd = stdout.lastIndexOf('}');
|
|
29
|
+
|
|
30
|
+
if (jsonStart === -1 || jsonEnd === -1) {
|
|
31
|
+
throw new Error('No valid history JSON found in output');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const jsonStr = stdout.substring(jsonStart, jsonEnd + 1);
|
|
35
|
+
const data = JSON.parse(jsonStr);
|
|
36
|
+
|
|
37
|
+
if (data.error) {
|
|
38
|
+
console.error('History Script Error:', data.error);
|
|
39
|
+
return NextResponse.json(data, { status: 500 });
|
|
40
|
+
}
|
|
41
|
+
return NextResponse.json(data);
|
|
42
|
+
} catch (e: any) {
|
|
43
|
+
console.error('History API Parse Error:', e.message);
|
|
44
|
+
console.error('STDOUT:', stdout);
|
|
45
|
+
console.error('STDERR:', stderr);
|
|
46
|
+
return NextResponse.json({
|
|
47
|
+
error: 'Failed to parse script output',
|
|
48
|
+
details: e.message,
|
|
49
|
+
stdoutSnippet: stdout.slice(0, 200)
|
|
50
|
+
}, { status: 500 });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
} catch (error: any) {
|
|
54
|
+
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
55
|
+
}
|
|
56
|
+
}
|
package/web/app/docs/page.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export default function DocsPage() {
|
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
24
|
<div className="bg-emerald-50 dark:bg-emerald-500/10 border border-emerald-200 dark:border-emerald-500/20 rounded-lg p-4 mb-8">
|
|
25
|
-
<p className="text-emerald-700 dark:text-emerald-400 font-semibold">Version: 1.
|
|
25
|
+
<p className="text-emerald-700 dark:text-emerald-400 font-semibold">Version: 1.7.11</p>
|
|
26
26
|
</div>
|
|
27
27
|
|
|
28
28
|
<h2 className="text-3xl font-bold mt-12 mb-6 text-gray-900 dark:text-white">Features</h2>
|