-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathverify-setup.js
More file actions
192 lines (164 loc) · 4.92 KB
/
verify-setup.js
File metadata and controls
192 lines (164 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env node
/**
* Setup Verification Script
*
* Checks that all prerequisites are installed and configured correctly
* for the Context Engine MCP Server.
*/
import { spawn } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const checks = [];
let passed = 0;
let failed = 0;
function log(message, type = 'info') {
const colors = {
success: '\x1b[32m',
error: '\x1b[31m',
warning: '\x1b[33m',
info: '\x1b[36m',
reset: '\x1b[0m',
};
const symbols = {
success: '✓',
error: '✗',
warning: '⚠',
info: 'ℹ',
};
console.log(`${colors[type]}${symbols[type]} ${message}${colors.reset}`);
}
function executeCommand(command, args = []) {
return new Promise((resolve) => {
const proc = spawn(command, args, { shell: true });
let stdout = '';
let stderr = '';
proc.stdout.on('data', (data) => stdout += data.toString());
proc.stderr.on('data', (data) => stderr += data.toString());
proc.on('close', (code) => {
resolve({ code, stdout, stderr });
});
proc.on('error', (error) => {
resolve({ code: -1, stdout, stderr: error.message });
});
});
}
async function checkNodeVersion() {
const result = await executeCommand('node', ['--version']);
if (result.code === 0) {
const version = result.stdout.trim();
const majorVersion = parseInt(version.slice(1).split('.')[0]);
if (majorVersion >= 18) {
log(`Node.js ${version} installed`, 'success');
passed++;
return true;
} else {
log(`Node.js ${version} is too old (need 18+)`, 'error');
failed++;
return false;
}
} else {
log('Node.js not found', 'error');
failed++;
return false;
}
}
async function checkNpmVersion() {
const result = await executeCommand('npm', ['--version']);
if (result.code === 0) {
log(`npm ${result.stdout.trim()} installed`, 'success');
passed++;
return true;
} else {
log('npm not found', 'error');
failed++;
return false;
}
}
async function checkRetrievalConfig() {
const provider = process.env.CE_RETRIEVAL_PROVIDER;
if (!provider || provider.trim() === '' || provider.trim() === 'local_native') {
log('Retrieval provider configuration is local_native-compatible', 'success');
passed++;
return true;
}
log(`Unsupported CE_RETRIEVAL_PROVIDER value: ${provider}`, 'error');
failed++;
return false;
}
async function checkDependencies() {
const packageJsonPath = path.join(__dirname, 'package.json');
if (!fs.existsSync(packageJsonPath)) {
log('package.json not found', 'error');
failed++;
return false;
}
const nodeModulesPath = path.join(__dirname, 'node_modules');
if (!fs.existsSync(nodeModulesPath)) {
log('node_modules not found - run: npm install', 'error');
failed++;
return false;
}
log('Dependencies installed', 'success');
passed++;
return true;
}
async function checkBuild() {
const distPath = path.join(__dirname, 'dist', 'index.js');
if (!fs.existsSync(distPath)) {
log('Build not found - run: npm run build', 'error');
failed++;
return false;
}
log('Project built successfully', 'success');
passed++;
return true;
}
async function checkTypeScript() {
const result = await executeCommand('npx', ['tsc', '--version']);
if (result.code === 0) {
log(`TypeScript ${result.stdout.trim()} available`, 'success');
passed++;
return true;
} else {
log('TypeScript not found', 'error');
failed++;
return false;
}
}
async function main() {
console.log('\n' + '='.repeat(60));
console.log('Context Engine MCP Server - Setup Verification');
console.log('='.repeat(60) + '\n');
log('Checking prerequisites...', 'info');
console.log('');
await checkNodeVersion();
await checkNpmVersion();
await checkTypeScript();
await checkRetrievalConfig();
await checkDependencies();
await checkBuild();
console.log('\n' + '='.repeat(60));
console.log(`Results: ${passed} passed, ${failed} failed`);
console.log('='.repeat(60) + '\n');
if (failed === 0) {
log('All checks passed! You\'re ready to run the server.', 'success');
console.log('\nNext steps:');
console.log(' 1. node dist/index.js --help');
console.log(' 2. node dist/index.js --workspace /path/to/project --index');
console.log(' 3. Configure Codex CLI (see docs/archive/QUICKSTART.md)');
} else {
log('Some checks failed. Please fix the issues above.', 'error');
console.log('\nFor help, see:');
console.log(' - docs/archive/QUICKSTART.md for setup instructions');
console.log(' - docs/archive/TROUBLESHOOTING.md for common issues');
}
console.log('');
process.exit(failed > 0 ? 1 : 0);
}
main().catch((error) => {
console.error('Verification failed:', error);
process.exit(1);
});