mlgym-deploy 3.0.6 → 3.0.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/index.js +64 -7
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import crypto from 'crypto';
|
|
|
17
17
|
const execAsync = promisify(exec);
|
|
18
18
|
|
|
19
19
|
// Current version of this MCP server - INCREMENT FOR WORKFLOW FIXES
|
|
20
|
-
const CURRENT_VERSION = '3.0.
|
|
20
|
+
const CURRENT_VERSION = '3.0.8'; // Added extensive MCP >>> debug logging throughout deployment workflow
|
|
21
21
|
const PACKAGE_NAME = 'mlgym-deploy';
|
|
22
22
|
|
|
23
23
|
// Debug logging configuration - ENABLED BY DEFAULT
|
|
@@ -705,25 +705,38 @@ CMD ["/bin/sh"]`;
|
|
|
705
705
|
async function prepareProject(args) {
|
|
706
706
|
const { local_path = '.', project_type, framework, package_manager } = args;
|
|
707
707
|
const absolutePath = path.resolve(local_path);
|
|
708
|
+
log.info('MCP >>> [prepareProject-func] Called with local_path:', local_path);
|
|
709
|
+
log.debug('MCP >>> [prepareProject-func] Resolved absolutePath:', absolutePath);
|
|
710
|
+
log.debug('MCP >>> [prepareProject-func] project_type:', project_type, 'framework:', framework);
|
|
708
711
|
|
|
709
712
|
const actions = [];
|
|
710
713
|
|
|
711
714
|
try {
|
|
712
715
|
// Check if Dockerfile exists
|
|
713
716
|
const dockerfilePath = path.join(absolutePath, 'Dockerfile');
|
|
717
|
+
log.debug('MCP >>> [prepareProject-func] Dockerfile path:', dockerfilePath);
|
|
714
718
|
let dockerfileExists = false;
|
|
715
719
|
|
|
716
720
|
try {
|
|
717
721
|
await fs.access(dockerfilePath);
|
|
718
722
|
dockerfileExists = true;
|
|
723
|
+
log.info('MCP >>> [prepareProject-func] Dockerfile already exists at', dockerfilePath);
|
|
719
724
|
actions.push('Dockerfile already exists - skipping generation');
|
|
720
|
-
} catch {
|
|
725
|
+
} catch {
|
|
726
|
+
log.info('MCP >>> [prepareProject-func] Dockerfile does not exist, will generate');
|
|
727
|
+
}
|
|
721
728
|
|
|
722
729
|
// Generate Dockerfile if missing
|
|
723
730
|
if (!dockerfileExists && project_type !== 'unknown') {
|
|
731
|
+
log.info('MCP >>> [prepareProject-func] Generating Dockerfile...');
|
|
724
732
|
const dockerfile = generateDockerfile(project_type, framework, package_manager);
|
|
733
|
+
log.debug('MCP >>> [prepareProject-func] Generated Dockerfile length:', dockerfile.length, 'bytes');
|
|
734
|
+
log.info('MCP >>> [prepareProject-func] Writing Dockerfile to:', dockerfilePath);
|
|
725
735
|
await fs.writeFile(dockerfilePath, dockerfile);
|
|
736
|
+
log.success('MCP >>> [prepareProject-func] ✅ Dockerfile written successfully!');
|
|
726
737
|
actions.push(`Generated Dockerfile for ${project_type}/${framework || 'generic'}`);
|
|
738
|
+
} else if (project_type === 'unknown') {
|
|
739
|
+
log.warning('MCP >>> [prepareProject-func] Project type is unknown, skipping Dockerfile generation');
|
|
727
740
|
}
|
|
728
741
|
|
|
729
742
|
// Check/create .gitignore
|
|
@@ -1121,44 +1134,59 @@ async function initProject(args) {
|
|
|
1121
1134
|
}
|
|
1122
1135
|
|
|
1123
1136
|
// Create initial commit and push (like CLI does)
|
|
1137
|
+
log.info('MCP >>> [initProject] Starting git commit and push...');
|
|
1138
|
+
log.debug('MCP >>> [initProject] Working directory:', absolutePath);
|
|
1124
1139
|
const gitSteps = [];
|
|
1125
1140
|
let pushSucceeded = false;
|
|
1126
1141
|
|
|
1127
1142
|
try {
|
|
1128
1143
|
// Check if there are any files to commit
|
|
1144
|
+
log.info('MCP >>> [initProject] Checking git status...');
|
|
1129
1145
|
const { stdout: statusOutput } = await execAsync('git status --porcelain', { cwd: absolutePath });
|
|
1146
|
+
log.debug('MCP >>> [initProject] Git status output:', statusOutput.trim() || '(clean)');
|
|
1130
1147
|
|
|
1131
1148
|
if (statusOutput.trim()) {
|
|
1132
1149
|
// There are uncommitted changes
|
|
1150
|
+
log.info('MCP >>> [initProject] Uncommitted changes detected, staging files...');
|
|
1133
1151
|
gitSteps.push('Adding files to git');
|
|
1134
1152
|
await execAsync('git add .', { cwd: absolutePath });
|
|
1153
|
+
log.success('MCP >>> [initProject] Files staged (git add .)');
|
|
1135
1154
|
|
|
1155
|
+
log.info('MCP >>> [initProject] Creating commit...');
|
|
1136
1156
|
gitSteps.push('Creating initial commit');
|
|
1137
1157
|
await execAsync('git commit -m "Initial MLGym deployment"', { cwd: absolutePath });
|
|
1158
|
+
log.success('MCP >>> [initProject] Commit created');
|
|
1138
1159
|
} else {
|
|
1139
1160
|
// Check if there are any commits at all
|
|
1161
|
+
log.info('MCP >>> [initProject] No uncommitted changes, checking for existing commits...');
|
|
1140
1162
|
try {
|
|
1141
1163
|
await execAsync('git rev-parse HEAD', { cwd: absolutePath });
|
|
1164
|
+
log.info('MCP >>> [initProject] Repository already has commits');
|
|
1142
1165
|
gitSteps.push('Repository already has commits');
|
|
1143
1166
|
} catch {
|
|
1144
1167
|
// No commits yet, create an initial one
|
|
1168
|
+
log.warning('MCP >>> [initProject] No commits found, creating initial README...');
|
|
1145
1169
|
gitSteps.push('Creating README for initial commit');
|
|
1146
1170
|
const readmePath = path.join(absolutePath, 'README.md');
|
|
1147
1171
|
if (!await fs.access(readmePath).then(() => true).catch(() => false)) {
|
|
1148
1172
|
await fs.writeFile(readmePath, `# ${name}\n\n${description}\n\nDeployed with MLGym\n`);
|
|
1173
|
+
log.info('MCP >>> [initProject] README.md created');
|
|
1149
1174
|
}
|
|
1150
1175
|
await execAsync('git add .', { cwd: absolutePath });
|
|
1151
1176
|
await execAsync('git commit -m "Initial MLGym deployment"', { cwd: absolutePath });
|
|
1177
|
+
log.success('MCP >>> [initProject] Initial commit created with README');
|
|
1152
1178
|
}
|
|
1153
1179
|
}
|
|
1154
1180
|
|
|
1155
1181
|
// Push to trigger webhook and deployment
|
|
1182
|
+
log.info('MCP >>> [initProject] Pushing to GitLab...');
|
|
1183
|
+
log.debug('MCP >>> [initProject] Git remote URL:', gitUrl);
|
|
1156
1184
|
gitSteps.push('Pushing to GitLab to trigger deployment');
|
|
1157
1185
|
console.error('Executing: git push -u mlgym main');
|
|
1158
1186
|
await execAsync('git push -u mlgym main', { cwd: absolutePath });
|
|
1159
1187
|
gitSteps.push('✅ Successfully pushed to GitLab');
|
|
1160
1188
|
pushSucceeded = true;
|
|
1161
|
-
|
|
1189
|
+
log.success('MCP >>> [initProject] ✅ Git push completed successfully!');
|
|
1162
1190
|
|
|
1163
1191
|
} catch (pushError) {
|
|
1164
1192
|
console.error('❌ Git push failed:', pushError.message);
|
|
@@ -1531,30 +1559,38 @@ class DeploymentWorkflow {
|
|
|
1531
1559
|
}
|
|
1532
1560
|
}
|
|
1533
1561
|
|
|
1534
|
-
async prepareProject(projectType, framework, packageManager) {
|
|
1562
|
+
async prepareProject(localPath, projectType, framework, packageManager) {
|
|
1535
1563
|
this.currentStep = 'preparation';
|
|
1536
1564
|
this.addStep('prepare_project', 'running');
|
|
1565
|
+
log.info('MCP >>> [prepareProject] Starting with localPath:', localPath);
|
|
1537
1566
|
|
|
1538
1567
|
try {
|
|
1539
1568
|
// Check if Dockerfile exists
|
|
1540
|
-
const analysis = this.projectAnalysis || await analyzeProject(
|
|
1569
|
+
const analysis = this.projectAnalysis || await analyzeProject(localPath);
|
|
1570
|
+
log.debug('MCP >>> [prepareProject] has_dockerfile:', analysis.has_dockerfile);
|
|
1541
1571
|
|
|
1542
1572
|
if (analysis.has_dockerfile) {
|
|
1573
|
+
log.info('MCP >>> [prepareProject] Dockerfile already exists, skipping generation');
|
|
1543
1574
|
this.updateLastStep('skipped', 'Dockerfile already exists');
|
|
1544
1575
|
return { skipped: true, reason: 'Dockerfile already exists' };
|
|
1545
1576
|
}
|
|
1546
1577
|
|
|
1547
1578
|
// Generate Dockerfile
|
|
1579
|
+
log.info('MCP >>> [prepareProject] Generating Dockerfile...');
|
|
1580
|
+
log.debug('MCP >>> [prepareProject] Type:', projectType || analysis.project_type, 'Framework:', framework || analysis.framework);
|
|
1548
1581
|
const prepResult = await prepareProject({
|
|
1549
|
-
local_path:
|
|
1582
|
+
local_path: localPath,
|
|
1550
1583
|
project_type: projectType || analysis.project_type,
|
|
1551
1584
|
framework: framework || analysis.framework,
|
|
1552
1585
|
package_manager: packageManager || 'npm'
|
|
1553
1586
|
});
|
|
1587
|
+
log.success('MCP >>> [prepareProject] Dockerfile generated successfully');
|
|
1588
|
+
log.debug('MCP >>> [prepareProject] Actions:', prepResult.actions);
|
|
1554
1589
|
|
|
1555
1590
|
this.updateLastStep('completed', prepResult.actions);
|
|
1556
1591
|
return prepResult;
|
|
1557
1592
|
} catch (error) {
|
|
1593
|
+
log.error('MCP >>> [prepareProject] FAILED:', error.message);
|
|
1558
1594
|
this.updateLastStep('failed', error.message);
|
|
1559
1595
|
throw error;
|
|
1560
1596
|
}
|
|
@@ -1631,13 +1667,21 @@ async function deployProject(args) {
|
|
|
1631
1667
|
package_manager = 'npm'
|
|
1632
1668
|
} = args;
|
|
1633
1669
|
|
|
1670
|
+
log.info('MCP >>> Starting deployment workflow');
|
|
1671
|
+
log.debug('MCP >>> Arguments:', { project_name, hostname, local_path, project_type, framework, package_manager });
|
|
1672
|
+
|
|
1634
1673
|
try {
|
|
1635
1674
|
// Step 1: Ensure authenticated
|
|
1675
|
+
log.info('MCP >>> STEP 1: Authenticating...');
|
|
1636
1676
|
await workflow.ensureAuth(email, password);
|
|
1677
|
+
log.success('MCP >>> STEP 1: Authentication complete');
|
|
1637
1678
|
|
|
1638
1679
|
// Step 2: Check if project already exists
|
|
1680
|
+
log.info('MCP >>> STEP 2: Checking for existing project in', local_path);
|
|
1639
1681
|
const existing = await workflow.checkExisting(local_path);
|
|
1640
1682
|
if (existing && existing.exists) {
|
|
1683
|
+
log.warning('MCP >>> Project already exists:', existing.name);
|
|
1684
|
+
|
|
1641
1685
|
return {
|
|
1642
1686
|
content: [{
|
|
1643
1687
|
type: 'text',
|
|
@@ -1659,22 +1703,35 @@ async function deployProject(args) {
|
|
|
1659
1703
|
}]
|
|
1660
1704
|
};
|
|
1661
1705
|
}
|
|
1706
|
+
log.success('MCP >>> STEP 2: No existing project found, proceeding with deployment');
|
|
1662
1707
|
|
|
1663
1708
|
// Step 3: Analyze project (auto-detect type and framework)
|
|
1709
|
+
log.info('MCP >>> STEP 3: Analyzing project...');
|
|
1664
1710
|
const analysis = await workflow.analyzeProject(local_path);
|
|
1711
|
+
log.success('MCP >>> STEP 3: Analysis complete -', analysis.project_type, '/', analysis.framework);
|
|
1712
|
+
log.debug('MCP >>> Detected files:', analysis.detected_files);
|
|
1665
1713
|
|
|
1666
1714
|
// Step 4: Prepare project (generate Dockerfile if needed)
|
|
1667
|
-
|
|
1715
|
+
log.info('MCP >>> STEP 4: Preparing project (Dockerfile generation)...');
|
|
1716
|
+
log.debug('MCP >>> Using local_path:', local_path);
|
|
1717
|
+
const prepResult = await workflow.prepareProject(local_path, project_type, framework, package_manager);
|
|
1718
|
+
log.success('MCP >>> STEP 4: Project preparation complete');
|
|
1719
|
+
log.debug('MCP >>> Preparation actions:', prepResult);
|
|
1668
1720
|
|
|
1669
1721
|
// Step 5: Create GitLab project and deploy
|
|
1722
|
+
log.info('MCP >>> STEP 5: Creating GitLab project and deploying...');
|
|
1723
|
+
log.debug('MCP >>> Project params:', { name: project_name, hostname: hostname || project_name, local_path });
|
|
1670
1724
|
const deployResult = await workflow.createAndDeployProject({
|
|
1671
1725
|
name: project_name,
|
|
1672
1726
|
description: project_description,
|
|
1673
1727
|
hostname: hostname || project_name,
|
|
1674
1728
|
local_path
|
|
1675
1729
|
});
|
|
1730
|
+
log.success('MCP >>> STEP 5: Deployment complete!');
|
|
1731
|
+
log.debug('MCP >>> Deploy result:', { project_id: deployResult.project?.id, deployment_url: deployResult.project?.deployment_url });
|
|
1676
1732
|
|
|
1677
1733
|
// Success response
|
|
1734
|
+
log.success('MCP >>> ✅ Full deployment workflow completed successfully!');
|
|
1678
1735
|
return {
|
|
1679
1736
|
content: [{
|
|
1680
1737
|
type: 'text',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mlgym-deploy",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "MCP server for MLGym - Added debug logging with
|
|
3
|
+
"version": "3.0.8",
|
|
4
|
+
"description": "MCP server for MLGym - Added extensive debug logging with MCP >>> prefix",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|