@zibby/core 0.1.5 → 0.1.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zibby/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Core test automation engine with multi-agent and multi-MCP support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"./utils/node-schema-parser.js": "./src/utils/node-schema-parser.js",
|
|
23
23
|
"./templates/register-nodes.js": "./templates/register-nodes.js",
|
|
24
24
|
"./templates": "./templates/index.js",
|
|
25
|
-
"./templates/*": "./templates/*"
|
|
25
|
+
"./templates/*": "./templates/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"test": "vitest run",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"!templates/**/__tests__/",
|
|
61
62
|
"!templates/**/*.test.js",
|
|
62
63
|
"!templates/**/*.spec.js",
|
|
64
|
+
"scripts/",
|
|
63
65
|
"README.md",
|
|
64
66
|
"LICENSE"
|
|
65
67
|
],
|
|
@@ -78,11 +80,9 @@
|
|
|
78
80
|
"dotenv": "^16.4.0",
|
|
79
81
|
"handlebars": "^4.7.8",
|
|
80
82
|
"zod": "^3.23.0",
|
|
83
|
+
"@zibby/mcp-browser": "^0.1.0",
|
|
81
84
|
"zod-to-json-schema": "^3.25.1"
|
|
82
85
|
},
|
|
83
|
-
"optionalDependencies": {
|
|
84
|
-
"@zibby/mcp-browser": "*"
|
|
85
|
-
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@playwright/test": ">=1.49.0",
|
|
88
88
|
"playwright": ">=1.49.0"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Export default workflows as JSON for the backend API
|
|
4
|
+
* Run: node packages/core/scripts/export-default-workflows.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
8
|
+
import { join, dirname } from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { WorkflowGraph } from '../src/framework/graph.js';
|
|
11
|
+
import { buildAnalysisGraph } from '../templates/graphs/analysisGraph.js';
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const outputDir = join(__dirname, '../../../backend/src/data');
|
|
15
|
+
|
|
16
|
+
// Ensure output directory exists
|
|
17
|
+
if (!existsSync(outputDir)) {
|
|
18
|
+
mkdirSync(outputDir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Build and serialize analysis workflow
|
|
22
|
+
console.log('Building analysis workflow...');
|
|
23
|
+
const analysisGraph = new WorkflowGraph();
|
|
24
|
+
buildAnalysisGraph(analysisGraph);
|
|
25
|
+
const serializedAnalysis = analysisGraph.serialize();
|
|
26
|
+
|
|
27
|
+
// Add workflow metadata
|
|
28
|
+
const analysisWorkflow = {
|
|
29
|
+
id: 'default_analysis',
|
|
30
|
+
name: 'Analysis Workflow',
|
|
31
|
+
description: 'Analyzes tickets and generates code implementation',
|
|
32
|
+
...serializedAnalysis,
|
|
33
|
+
createdAt: new Date().toISOString(),
|
|
34
|
+
isDefault: true
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Write to JSON file
|
|
38
|
+
const outputPath = join(outputDir, 'default-workflows.json');
|
|
39
|
+
const workflows = {
|
|
40
|
+
analysis: analysisWorkflow
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
writeFileSync(outputPath, JSON.stringify(workflows, null, 2));
|
|
44
|
+
console.log(`✅ Exported default workflows to ${outputPath}`);
|
|
45
|
+
|
|
46
|
+
// Also export as individual files for clarity
|
|
47
|
+
writeFileSync(
|
|
48
|
+
join(outputDir, 'default-analysis-workflow.json'),
|
|
49
|
+
JSON.stringify(analysisWorkflow, null, 2)
|
|
50
|
+
);
|
|
51
|
+
console.log('✅ Exported individual workflow files');
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Patch cursor-agent CLI to auto-approve MCP tool calls for CI/CD use.
|
|
5
|
+
*
|
|
6
|
+
* This script modifies the cursor-agent source code to bypass the manual
|
|
7
|
+
* approval prompt for MCP tool executions, making it suitable for automated
|
|
8
|
+
* CI/CD pipelines.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* node patch-cursor-mcp.js
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { readFileSync, writeFileSync, existsSync, readdirSync, statSync } from 'fs';
|
|
15
|
+
import { join, dirname } from 'path';
|
|
16
|
+
import { homedir } from 'os';
|
|
17
|
+
import { fileURLToPath } from 'url';
|
|
18
|
+
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = dirname(__filename);
|
|
21
|
+
|
|
22
|
+
function findLatestCursorAgent() {
|
|
23
|
+
const versionsDir = join(homedir(), '.local/share/cursor-agent/versions');
|
|
24
|
+
|
|
25
|
+
if (!existsSync(versionsDir)) {
|
|
26
|
+
console.error(`❌ Cursor agent versions directory not found: ${versionsDir}`);
|
|
27
|
+
console.error(' Make sure cursor-agent is installed: curl https://cursor.com/install -fsS | bash');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const versions = readdirSync(versionsDir)
|
|
32
|
+
.map(name => join(versionsDir, name))
|
|
33
|
+
.filter(path => statSync(path).isDirectory());
|
|
34
|
+
|
|
35
|
+
if (versions.length === 0) {
|
|
36
|
+
console.error(`❌ No cursor-agent versions found in ${versionsDir}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Get the latest version by creation time
|
|
41
|
+
const latestVersion = versions
|
|
42
|
+
.map(path => ({ path, ctime: statSync(path).ctimeMs }))
|
|
43
|
+
.sort((a, b) => b.ctime - a.ctime)[0].path;
|
|
44
|
+
|
|
45
|
+
return join(latestVersion, 'index.js');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function backupFile(filePath) {
|
|
49
|
+
const backupPath = `${filePath }.backup`;
|
|
50
|
+
|
|
51
|
+
if (existsSync(backupPath)) {
|
|
52
|
+
console.log(`ℹ️ Backup already exists: ${backupPath}`);
|
|
53
|
+
return backupPath;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const content = readFileSync(filePath, 'utf8');
|
|
57
|
+
writeFileSync(backupPath, content, 'utf8');
|
|
58
|
+
|
|
59
|
+
console.log(`✅ Backup created: ${backupPath}`);
|
|
60
|
+
return backupPath;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function patchMcpApproval(filePath) {
|
|
64
|
+
const content = readFileSync(filePath, 'utf8');
|
|
65
|
+
|
|
66
|
+
// Check if already patched
|
|
67
|
+
if (content.includes('AUTO-APPROVE MCP TOOLS FOR CI/CD')) {
|
|
68
|
+
console.log('✅ File is already patched!');
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Pattern to match the requestApproval call for MCP
|
|
73
|
+
const pattern = /(\s+const result = await this\.pendingDecisionProvider\.requestApproval\(\{\s+type: OperationType\.Mcp,\s+details: \{\s+name: approvalDetails\.name,\s+toolName: approvalDetails\.toolName,\s+providerIdentifier: approvalDetails\.providerIdentifier,\s+args: approvalDetails\.args,\s+\},\s+toolCallId: args\.toolCallId,\s+\}\);)/;
|
|
74
|
+
|
|
75
|
+
const replacement = ` // AUTO-APPROVE MCP TOOLS FOR CI/CD
|
|
76
|
+
const result = { approved: true };
|
|
77
|
+
/*
|
|
78
|
+
const result = await this.pendingDecisionProvider.requestApproval({
|
|
79
|
+
type: OperationType.Mcp,
|
|
80
|
+
details: {
|
|
81
|
+
name: approvalDetails.name,
|
|
82
|
+
toolName: approvalDetails.toolName,
|
|
83
|
+
providerIdentifier: approvalDetails.providerIdentifier,
|
|
84
|
+
args: approvalDetails.args,
|
|
85
|
+
},
|
|
86
|
+
toolCallId: args.toolCallId,
|
|
87
|
+
});
|
|
88
|
+
*/`;
|
|
89
|
+
|
|
90
|
+
const newContent = content.replace(pattern, replacement);
|
|
91
|
+
|
|
92
|
+
if (newContent === content) {
|
|
93
|
+
console.log('ℹ️ Pattern not found - cursor-agent code structure has changed.');
|
|
94
|
+
console.log(' This is OKAY! Newer versions might not need this patch.');
|
|
95
|
+
console.log(' If auto-approval doesn\'t work, cursor-agent team may have fixed it!');
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
writeFileSync(filePath, newContent, 'utf8');
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function addApprovalKeyLogging(filePath) {
|
|
104
|
+
const content = readFileSync(filePath, 'utf8');
|
|
105
|
+
const lines = content.split('\n');
|
|
106
|
+
|
|
107
|
+
// Check if already added
|
|
108
|
+
if (lines.some(line => line.includes('🔑 APPROVAL KEY'))) {
|
|
109
|
+
console.log('✅ Approval key logging already enabled!');
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Find the line with generateApprovalKey and add logging after it
|
|
114
|
+
let targetLineNum = -1;
|
|
115
|
+
for (let i = 0; i < lines.length; i++) {
|
|
116
|
+
if (lines[i].includes('const approvalKey = generateApprovalKey(serverName, server, this.cwd);')) {
|
|
117
|
+
targetLineNum = i;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (targetLineNum === -1) {
|
|
123
|
+
console.log('⚠️ Could not find approval key generation line');
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Insert the console.log after the generateApprovalKey line
|
|
128
|
+
const indent = ' ';
|
|
129
|
+
const logLine = `${indent}console.log("🔑 APPROVAL KEY:", serverName, "=>", approvalKey);`;
|
|
130
|
+
lines.splice(targetLineNum + 1, 0, logLine);
|
|
131
|
+
|
|
132
|
+
writeFileSync(filePath, lines.join('\n'), 'utf8');
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function main() {
|
|
137
|
+
console.log('🔧 Patching cursor-agent for CI/CD MCP usage...\n');
|
|
138
|
+
console.log('ℹ️ Note: This patch is temporary and may not be needed in future versions.\n');
|
|
139
|
+
|
|
140
|
+
// Find cursor-agent
|
|
141
|
+
const indexFile = findLatestCursorAgent();
|
|
142
|
+
console.log(`📍 Found cursor-agent: ${indexFile}\n`);
|
|
143
|
+
|
|
144
|
+
// Backup
|
|
145
|
+
backupFile(indexFile);
|
|
146
|
+
console.log();
|
|
147
|
+
|
|
148
|
+
// Apply patches
|
|
149
|
+
const patchedApproval = patchMcpApproval(indexFile);
|
|
150
|
+
if (patchedApproval) {
|
|
151
|
+
console.log('✅ Patched MCP tool auto-approval');
|
|
152
|
+
}
|
|
153
|
+
console.log();
|
|
154
|
+
|
|
155
|
+
const patchedLogging = addApprovalKeyLogging(indexFile);
|
|
156
|
+
if (patchedLogging) {
|
|
157
|
+
console.log('✅ Added approval key logging');
|
|
158
|
+
}
|
|
159
|
+
console.log();
|
|
160
|
+
|
|
161
|
+
if (patchedApproval || patchedLogging) {
|
|
162
|
+
console.log('🎉 cursor-agent is now ready for CI/CD!');
|
|
163
|
+
console.log('\nNext steps:');
|
|
164
|
+
console.log('1. Run: cursor-agent mcp list');
|
|
165
|
+
console.log('2. Copy the approval key shown');
|
|
166
|
+
console.log('3. Add it to ~/.cursor/projects/YOUR_PROJECT/mcp-approvals.json');
|
|
167
|
+
console.log('\n⚠️ If cursor-agent updates break this patch, MCP may work without it.');
|
|
168
|
+
} else {
|
|
169
|
+
console.log('ℹ️ No changes needed - already configured or cursor-agent version doesn\'t need patching!');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
main();
|
|
174
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
echo "🚀 Complete CI/CD Setup (from scratch)"
|
|
5
|
+
echo "======================================="
|
|
6
|
+
echo ""
|
|
7
|
+
|
|
8
|
+
# Get the absolute path to the project
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
11
|
+
|
|
12
|
+
echo "📍 Project root: $PROJECT_ROOT"
|
|
13
|
+
echo ""
|
|
14
|
+
|
|
15
|
+
# Check OS
|
|
16
|
+
OS="$(uname -s)"
|
|
17
|
+
echo "🖥️ Detected OS: $OS"
|
|
18
|
+
echo ""
|
|
19
|
+
|
|
20
|
+
# Step 1: Check/Install Node.js
|
|
21
|
+
echo "Step 1: Checking Node.js..."
|
|
22
|
+
if command -v node &> /dev/null; then
|
|
23
|
+
NODE_VERSION=$(node --version)
|
|
24
|
+
echo "✓ Node.js installed: $NODE_VERSION"
|
|
25
|
+
else
|
|
26
|
+
echo "✗ Node.js not found!"
|
|
27
|
+
echo " Install: https://nodejs.org/ or use nvm"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
echo ""
|
|
31
|
+
|
|
32
|
+
# Step 2: Check/Install Python 3
|
|
33
|
+
echo "Step 2: Checking Python 3..."
|
|
34
|
+
if command -v python3 &> /dev/null; then
|
|
35
|
+
PYTHON_VERSION=$(python3 --version)
|
|
36
|
+
echo "✓ Python 3 installed: $PYTHON_VERSION"
|
|
37
|
+
else
|
|
38
|
+
echo "✗ Python 3 not found!"
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
echo ""
|
|
42
|
+
|
|
43
|
+
# Step 3: Install npm dependencies
|
|
44
|
+
echo "Step 3: Installing npm dependencies..."
|
|
45
|
+
cd "$PROJECT_ROOT"
|
|
46
|
+
if [ -f "package.json" ]; then
|
|
47
|
+
npm install --silent > /dev/null 2>&1
|
|
48
|
+
echo "✓ npm dependencies installed"
|
|
49
|
+
else
|
|
50
|
+
echo "✗ package.json not found"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
echo ""
|
|
54
|
+
|
|
55
|
+
# Step 4: Check/Install cursor-agent
|
|
56
|
+
echo "Step 4: Checking cursor-agent..."
|
|
57
|
+
if command -v cursor-agent &> /dev/null; then
|
|
58
|
+
CURSOR_VERSION=$(cursor-agent --version 2>&1 | head -1 || echo "unknown")
|
|
59
|
+
echo "✓ cursor-agent installed: $CURSOR_VERSION"
|
|
60
|
+
else
|
|
61
|
+
echo "⚠️ cursor-agent not found - installing..."
|
|
62
|
+
|
|
63
|
+
if [ "$OS" = "Darwin" ] || [ "$OS" = "Linux" ]; then
|
|
64
|
+
# Install cursor-agent
|
|
65
|
+
curl -fsSL https://cursor.com/install | bash
|
|
66
|
+
|
|
67
|
+
# Add to PATH for current session
|
|
68
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
69
|
+
|
|
70
|
+
if command -v cursor-agent &> /dev/null; then
|
|
71
|
+
echo "✓ cursor-agent installed successfully"
|
|
72
|
+
else
|
|
73
|
+
echo "✗ cursor-agent installation failed"
|
|
74
|
+
echo " Manual install: curl https://cursor.com/install -fsS | bash"
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
else
|
|
78
|
+
echo "✗ Unsupported OS for automatic cursor-agent installation"
|
|
79
|
+
echo " Install manually: https://cursor.com/cli"
|
|
80
|
+
exit 1
|
|
81
|
+
fi
|
|
82
|
+
fi
|
|
83
|
+
echo ""
|
|
84
|
+
|
|
85
|
+
# Step 5: Check CURSOR_API_KEY (REQUIRED for CI/CD)
|
|
86
|
+
echo "Step 5: Checking CURSOR_API_KEY..."
|
|
87
|
+
if [ -z "$CURSOR_API_KEY" ]; then
|
|
88
|
+
echo "⚠️ CURSOR_API_KEY not set"
|
|
89
|
+
echo " ⚠️ REQUIRED for CI/CD - cursor-agent will fail without it!"
|
|
90
|
+
echo " Set it as an environment variable in your CI/CD config"
|
|
91
|
+
echo " Get your key from: https://cursor.com/settings"
|
|
92
|
+
echo ""
|
|
93
|
+
echo " Example (GitLab CI):"
|
|
94
|
+
echo " variables:"
|
|
95
|
+
echo " CURSOR_API_KEY: \$CURSOR_API_KEY"
|
|
96
|
+
echo ""
|
|
97
|
+
else
|
|
98
|
+
echo "✓ CURSOR_API_KEY is set"
|
|
99
|
+
fi
|
|
100
|
+
echo ""
|
|
101
|
+
|
|
102
|
+
# Step 6: Run the official Playwright MCP setup
|
|
103
|
+
echo "Step 6: Setting up official Playwright MCP..."
|
|
104
|
+
echo ""
|
|
105
|
+
bash "$SCRIPT_DIR/setup-official-playwright-mcp.sh"
|
|
106
|
+
|
|
107
|
+
echo ""
|
|
108
|
+
echo "======================================="
|
|
109
|
+
echo "✅ Complete CI/CD setup finished!"
|
|
110
|
+
echo "======================================="
|
|
111
|
+
echo ""
|
|
112
|
+
echo "Ready to use in CI/CD:"
|
|
113
|
+
echo " cursor-agent -p 'Navigate to google.com' --mcp-server playwright-official"
|
|
114
|
+
echo ""
|
|
115
|
+
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# Get script directory for relative imports
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Step 1: Check cursor-agent
|
|
9
|
+
if ! command -v cursor-agent &> /dev/null; then
|
|
10
|
+
echo "⚠️ cursor-agent not found. Installing..."
|
|
11
|
+
curl https://cursor.com/install -fsS | bash
|
|
12
|
+
export PATH="$HOME/.cursor/bin:$HOME/.local/bin:$PATH"
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
# Step 2: Find Node.js absolute paths (Cursor GUI doesn't have shell PATH)
|
|
16
|
+
NODE_PATH=$(which node 2>/dev/null || echo "")
|
|
17
|
+
NPX_PATH=$(which npx 2>/dev/null || echo "")
|
|
18
|
+
NODE_BIN_DIR=$(dirname "$NODE_PATH" 2>/dev/null || echo "")
|
|
19
|
+
|
|
20
|
+
if [ -z "$NODE_PATH" ]; then
|
|
21
|
+
echo "❌ node not found. Please install Node.js"
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
echo " Using Node: $NODE_PATH"
|
|
26
|
+
|
|
27
|
+
# Step 3: Find Zibby MCP Browser (stable IDs + event recording)
|
|
28
|
+
echo "Setting up Zibby MCP Browser..."
|
|
29
|
+
|
|
30
|
+
# Resolve @zibby/mcp-browser from node_modules (works in workspace, global, and npx installs)
|
|
31
|
+
ZIBBY_MCP_PKG=$("$NODE_PATH" -e "try{console.log(require.resolve('@zibby/mcp-browser/package.json',{paths:['$SCRIPT_DIR/..']}))}catch{}" 2>/dev/null)
|
|
32
|
+
if [ -n "$ZIBBY_MCP_PKG" ]; then
|
|
33
|
+
ZIBBY_MCP_BIN="$(dirname "$ZIBBY_MCP_PKG")/bin/mcp-browser-zibby.js"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Fallback: try workspace path (dev only)
|
|
37
|
+
if [ -z "$ZIBBY_MCP_BIN" ] || [ ! -f "$ZIBBY_MCP_BIN" ]; then
|
|
38
|
+
ZIBBY_MCP_DIR="$SCRIPT_DIR/../../mcps/browser"
|
|
39
|
+
if [ -f "$ZIBBY_MCP_DIR/bin/mcp-browser-zibby.js" ]; then
|
|
40
|
+
ZIBBY_MCP_BIN="$ZIBBY_MCP_DIR/bin/mcp-browser-zibby.js"
|
|
41
|
+
fi
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Final fallback: official @playwright/mcp (no stable IDs or event recording)
|
|
45
|
+
if [ -z "$ZIBBY_MCP_BIN" ] || [ ! -f "$ZIBBY_MCP_BIN" ]; then
|
|
46
|
+
PLAYWRIGHT_MCP_PKG=$("$NODE_PATH" -e "try{console.log(require.resolve('@playwright/mcp/package.json',{paths:['$SCRIPT_DIR/..']}))}catch{}" 2>/dev/null)
|
|
47
|
+
if [ -n "$PLAYWRIGHT_MCP_PKG" ]; then
|
|
48
|
+
ZIBBY_MCP_BIN="$(dirname "$PLAYWRIGHT_MCP_PKG")/cli.js"
|
|
49
|
+
echo " ⚠️ Using @playwright/mcp (official) — stable IDs and event recording unavailable"
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
if [ -z "$ZIBBY_MCP_BIN" ] || [ ! -f "$ZIBBY_MCP_BIN" ]; then
|
|
54
|
+
echo "❌ No Playwright MCP found. Run: npm install @zibby/mcp-browser"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
echo " ✅ Zibby MCP Browser ready"
|
|
59
|
+
|
|
60
|
+
# Install ffmpeg for video recording
|
|
61
|
+
echo "🎬 Installing ffmpeg for video recording..."
|
|
62
|
+
if command -v playwright &> /dev/null 2>&1; then
|
|
63
|
+
playwright install ffmpeg > /dev/null 2>&1 && echo " ✅ ffmpeg installed" || echo " ⚠️ Could not install ffmpeg"
|
|
64
|
+
else
|
|
65
|
+
"$NPX_PATH" --yes playwright install ffmpeg > /dev/null 2>&1 && echo " ✅ ffmpeg installed" || echo " ⚠️ Could not install ffmpeg (will disable video)"
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Step 4: Configure MCP
|
|
69
|
+
echo "Configuring Zibby MCP Browser..."
|
|
70
|
+
mkdir -p ~/.cursor
|
|
71
|
+
|
|
72
|
+
# Default viewport size (can be overridden via env)
|
|
73
|
+
VIEWPORT_WIDTH="${ZIBBY_VIEWPORT_WIDTH:-1280}"
|
|
74
|
+
VIEWPORT_HEIGHT="${ZIBBY_VIEWPORT_HEIGHT:-720}"
|
|
75
|
+
VIEWPORT_SIZE="${VIEWPORT_WIDTH}x${VIEWPORT_HEIGHT}"
|
|
76
|
+
|
|
77
|
+
# Build MCP args array
|
|
78
|
+
MCP_ARGS="\"--save-video=${VIEWPORT_SIZE}\", \"--viewport-size=${VIEWPORT_SIZE}\", \"--output-dir=test-results\""
|
|
79
|
+
|
|
80
|
+
# Check if headless mode requested (default is headed)
|
|
81
|
+
if [ "$ZIBBY_HEADLESS" = "1" ]; then
|
|
82
|
+
MCP_ARGS="$MCP_ARGS, \"--headless\""
|
|
83
|
+
echo " Mode: Headless (hidden browser)"
|
|
84
|
+
else
|
|
85
|
+
echo " Mode: Headed (visible browser)"
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
# Check if video recording requested (default is on)
|
|
89
|
+
if [ "$ZIBBY_VIDEO" != "off" ]; then
|
|
90
|
+
echo " Video: Enabled (${VIEWPORT_SIZE})"
|
|
91
|
+
else
|
|
92
|
+
MCP_ARGS="\"--viewport-size=${VIEWPORT_SIZE}\", \"--output-dir=test-results\""
|
|
93
|
+
if [ "$ZIBBY_HEADLESS" = "1" ]; then
|
|
94
|
+
MCP_ARGS="$MCP_ARGS, \"--headless\""
|
|
95
|
+
fi
|
|
96
|
+
echo " Video: Disabled"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# Check if Zibby Cloud MCP should be included
|
|
100
|
+
if [ "$ZIBBY_CLOUD_SYNC" = "1" ]; then
|
|
101
|
+
LOCAL_MCP_PATH="$SCRIPT_DIR/../../mcp-server/src/index.js"
|
|
102
|
+
|
|
103
|
+
if [ -f "$LOCAL_MCP_PATH" ]; then
|
|
104
|
+
MCP_PKG_DIR="$SCRIPT_DIR/../../mcp-server"
|
|
105
|
+
if [ -f "$MCP_PKG_DIR/package.json" ]; then
|
|
106
|
+
echo " 📦 Installing Zibby Cloud MCP dependencies..."
|
|
107
|
+
(cd "$MCP_PKG_DIR" && npm install --silent > /dev/null 2>&1) || echo " ⚠️ Warning: Could not install dependencies"
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
cat > ~/.cursor/mcp.json <<EOF
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"playwright-official": {
|
|
114
|
+
"command": "$NODE_PATH",
|
|
115
|
+
"args": ["$ZIBBY_MCP_BIN", $MCP_ARGS],
|
|
116
|
+
"env": {
|
|
117
|
+
"PATH": "$NODE_BIN_DIR:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
118
|
+
},
|
|
119
|
+
"description": "Zibby MCP Browser - Forked Playwright MCP with stable ID support"
|
|
120
|
+
},
|
|
121
|
+
"zibby": {
|
|
122
|
+
"command": "$NODE_PATH",
|
|
123
|
+
"args": ["$LOCAL_MCP_PATH"],
|
|
124
|
+
"env": {
|
|
125
|
+
"ZIBBY_API_KEY": "${ZIBBY_API_KEY}",
|
|
126
|
+
"PATH": "$NODE_BIN_DIR:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
127
|
+
},
|
|
128
|
+
"description": "Zibby Cloud Sync - Upload test results and artifacts"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
EOF
|
|
133
|
+
echo " + Zibby MCP Browser (stable IDs + event recording)"
|
|
134
|
+
echo " + Zibby Cloud MCP (cloud sync enabled)"
|
|
135
|
+
else
|
|
136
|
+
echo " ⚠️ Cloud sync requested but local MCP server not found"
|
|
137
|
+
cat > ~/.cursor/mcp.json <<EOF
|
|
138
|
+
{
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"playwright-official": {
|
|
141
|
+
"command": "$NODE_PATH",
|
|
142
|
+
"args": ["$ZIBBY_MCP_BIN", $MCP_ARGS],
|
|
143
|
+
"env": {
|
|
144
|
+
"PATH": "$NODE_BIN_DIR:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
145
|
+
},
|
|
146
|
+
"description": "Zibby MCP Browser - Forked Playwright MCP with stable ID support"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
EOF
|
|
151
|
+
echo " + Zibby MCP Browser (stable IDs + event recording)"
|
|
152
|
+
fi
|
|
153
|
+
else
|
|
154
|
+
cat > ~/.cursor/mcp.json <<EOF
|
|
155
|
+
{
|
|
156
|
+
"mcpServers": {
|
|
157
|
+
"playwright-official": {
|
|
158
|
+
"command": "$NODE_PATH",
|
|
159
|
+
"args": ["$ZIBBY_MCP_BIN", $MCP_ARGS],
|
|
160
|
+
"env": {
|
|
161
|
+
"PATH": "$NODE_BIN_DIR:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
162
|
+
},
|
|
163
|
+
"description": "Zibby MCP Browser - Forked Playwright MCP with stable ID support"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
EOF
|
|
168
|
+
echo " + Zibby MCP Browser (stable IDs + event recording)"
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
# Step 5: Patch cursor-agent
|
|
172
|
+
echo "Patching cursor-agent..."
|
|
173
|
+
node "$SCRIPT_DIR/patch-cursor-mcp.js" > /dev/null 2>&1 || echo " (patch may not be needed for your version)"
|
|
174
|
+
|
|
175
|
+
# Step 6: Get approval key
|
|
176
|
+
echo "🔑 Getting approval key..."
|
|
177
|
+
APPROVAL_OUTPUT=$(cursor-agent mcp list 2>&1)
|
|
178
|
+
|
|
179
|
+
APPROVAL_KEY_LINE=$(echo "$APPROVAL_OUTPUT" | grep "🔑 APPROVAL KEY.*playwright-official" | head -1)
|
|
180
|
+
echo "$APPROVAL_KEY_LINE"
|
|
181
|
+
|
|
182
|
+
APPROVAL_KEY=$(echo "$APPROVAL_KEY_LINE" | sed -E 's/.*=> ([^ ]+).*/\1/' | head -1)
|
|
183
|
+
|
|
184
|
+
if [ -z "$APPROVAL_KEY" ]; then
|
|
185
|
+
APPROVAL_KEY=$(echo "$APPROVAL_OUTPUT" | grep -oE 'playwright-official-[a-f0-9]+' | head -1)
|
|
186
|
+
fi
|
|
187
|
+
|
|
188
|
+
if [ -z "$APPROVAL_KEY" ]; then
|
|
189
|
+
echo "⚠️ Could not auto-extract approval key"
|
|
190
|
+
echo " This is OK for development - approval key only needed for CI/CD"
|
|
191
|
+
echo " For CI/CD: Run 'cursor-agent mcp list' and save the key"
|
|
192
|
+
else
|
|
193
|
+
# Step 7: Setup workspace approvals (only if we got the key)
|
|
194
|
+
echo "Configuring approvals..."
|
|
195
|
+
WORKSPACE_PATH="$PWD"
|
|
196
|
+
WORKSPACE_ENCODED=$(echo "$WORKSPACE_PATH" | sed 's|^/||' | sed 's|/|-|g')
|
|
197
|
+
APPROVAL_DIR="$HOME/.cursor/projects/$WORKSPACE_ENCODED"
|
|
198
|
+
APPROVAL_FILE="$APPROVAL_DIR/mcp-approvals.json"
|
|
199
|
+
|
|
200
|
+
mkdir -p "$APPROVAL_DIR"
|
|
201
|
+
cat > "$APPROVAL_FILE" <<EOF
|
|
202
|
+
["$APPROVAL_KEY"]
|
|
203
|
+
EOF
|
|
204
|
+
echo "Auto-approval configured for this workspace"
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
echo ""
|
|
208
|
+
echo "Zibby MCP Browser ready!"
|
|
209
|
+
echo ""
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Run Playwright tests with video recording
|
|
4
|
+
# Usage: ./scripts/test-with-video.sh [test-file] [headed]
|
|
5
|
+
#
|
|
6
|
+
# Examples:
|
|
7
|
+
# ./scripts/test-with-video.sh tests/auth/login.spec.js
|
|
8
|
+
# ./scripts/test-with-video.sh tests/auth/login.spec.js headed
|
|
9
|
+
|
|
10
|
+
TEST_FILE="${1:-tests/}"
|
|
11
|
+
HEADED_FLAG=""
|
|
12
|
+
|
|
13
|
+
if [ "$2" = "headed" ]; then
|
|
14
|
+
HEADED_FLAG="--headed"
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
echo "🎥 Running Playwright tests with video recording..."
|
|
18
|
+
echo " Test: $TEST_FILE"
|
|
19
|
+
echo " Mode: $([ -n "$HEADED_FLAG" ] && echo "Headed (visible)" || echo "Headless")"
|
|
20
|
+
echo ""
|
|
21
|
+
|
|
22
|
+
# Run tests (video is configured in playwright.config.js)
|
|
23
|
+
npx playwright test "$TEST_FILE" --project=chromium $HEADED_FLAG
|
|
24
|
+
|
|
25
|
+
echo ""
|
|
26
|
+
echo "✅ Tests complete!"
|
|
27
|
+
echo ""
|
|
28
|
+
echo "📂 Videos saved in: test-results/"
|
|
29
|
+
echo ""
|
|
30
|
+
|
|
31
|
+
# List videos if any were created
|
|
32
|
+
if ls test-results/*/video.webm 2>/dev/null 1>&2; then
|
|
33
|
+
echo "🎬 Videos created:"
|
|
34
|
+
ls -lh test-results/*/video.webm
|
|
35
|
+
echo ""
|
|
36
|
+
echo "To view videos:"
|
|
37
|
+
echo " 1. Open Finder: open test-results/"
|
|
38
|
+
echo " 2. Or play directly:"
|
|
39
|
+
for video in test-results/*/video.webm; do
|
|
40
|
+
echo " open \"$video\""
|
|
41
|
+
done
|
|
42
|
+
else
|
|
43
|
+
echo "ℹ️ No videos found"
|
|
44
|
+
echo ""
|
|
45
|
+
echo "Video is configured in playwright.config.js:"
|
|
46
|
+
echo " - video: 'on' (always record)"
|
|
47
|
+
echo " - video: 'retain-on-failure' (only failed tests)"
|
|
48
|
+
fi
|
|
49
|
+
|