init project

This commit is contained in:
root
2026-07-31 13:12:54 -04:00
parent 0da92d5e02
commit f3863f760c
7215 changed files with 1860260 additions and 1 deletions
+49
View File
@@ -0,0 +1,49 @@
import { config } from '../../config.js';
import { detectProject, resolvePackage } from '../../lib/frameworks/detect.js';
import { resolveTarget } from '../../lib/frameworks/resolve.js';
import { runCommand } from '../../lib/runCommand.js';
import { errorResult, jsonResult, packageSchema, targetSchema, toErrorMessage } from '../shared.js';
export function registerBuildProjectTool(server) {
server.registerTool('build_project', {
title: 'Build Project',
description: 'Run the production build: the JS bundle build for React, or `composer install --no-dev --optimize-autoloader` for Laravel/CodeIgniter. Surfaces build errors/warnings. Optional `package` scopes to a monorepo package.',
inputSchema: { target: targetSchema, package: packageSchema },
}, async ({ target, package: packageName }) => {
try {
const root = packageName
? resolvePackage(config.workspaceRoot, packageName).pkg.absolutePath
: config.workspaceRoot;
const detected = detectProject(root);
const { adapter, target: resolvedTarget } = resolveTarget(detected, target);
const cmd = adapter.buildCommand();
if (!cmd) {
return jsonResult({
target: resolvedTarget,
package: packageName ?? null,
adapter: adapter.label,
ran: false,
message: 'No build command configured for this project (no "build" script found).',
});
}
const result = await runCommand(cmd.command, cmd.args, {
cwd: cmd.cwd,
timeoutMs: config.scaffoldCommandTimeoutMs,
});
return jsonResult({
target: resolvedTarget,
package: packageName ?? null,
adapter: adapter.label,
ran: true,
exitCode: result.exitCode,
timedOut: result.timedOut,
failed: result.failed,
output: result.output,
cwd: result.cwd,
});
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=buildProject.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"buildProject.js","sourceRoot":"","sources":["../../../src/tools/workflow/buildProject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAi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,wBAAwB;aAC3C,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;gBAChB,MAAM,EAAE,cAAc;gBACtB,OAAO,EAAE,WAAW,IAAI,IAAI;gBAC5B,OAAO,EAAE,OAAO,CAAC,KAAK;gBACtB,GAAG,EAAE,IAAI;gBACT,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
+97
View File
@@ -0,0 +1,97 @@
import fs from 'node:fs';
import { z } from 'zod';
import { config } from '../../config.js';
import { resolveWorkspacePath } from '../../lib/sandbox.js';
import { runCommand } from '../../lib/runCommand.js';
import { errorResult, jsonResult, targetSchema, toErrorMessage } from '../shared.js';
/**
* Deploy is deliberately opt-in and project-defined: rather than guessing at
* Vercel/Netlify/Forge credentials, it runs a script the project itself
* defines (deploy.ps1 on Windows, deploy.sh elsewhere) at the workspace
* root. Optionally pushes a Docker image when registryPush is set.
*/
export function registerDeployProjectTool(server) {
server.registerTool('deploy_project', {
title: 'Deploy Project',
description: 'Run the project-defined deploy step: deploy.ps1 (Windows) or deploy.sh (macOS/Linux) at the workspace root. ' +
'Requires confirm: true. Optional registryPush runs `docker push` after the deploy script (also confirm-gated). ' +
'The server never holds deployment credentials itself.',
inputSchema: {
target: targetSchema,
confirm: z
.boolean()
.optional()
.describe('Must be true; deliberate opt-in for a destructive/external-effect operation.'),
registryPush: z
.string()
.optional()
.describe('Optional Docker image reference to push after the deploy script succeeds.'),
},
}, async ({ confirm, target, registryPush }) => {
void target;
if (confirm !== true)
return errorResult('confirm: true is required to run deploy_project.');
try {
let deployResult;
if (process.platform === 'win32') {
const scriptPath = resolveWorkspacePath(config.workspaceRoot, 'deploy.ps1');
if (!fs.existsSync(scriptPath)) {
return errorResult(`No deploy.ps1 found at the workspace root (${config.workspaceRoot}). Add one that performs your deployment, then retry.`);
}
const result = await runCommand('powershell', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptPath], { cwd: config.workspaceRoot, timeoutMs: config.scaffoldCommandTimeoutMs });
deployResult = {
ranScript: 'deploy.ps1',
exitCode: result.exitCode,
timedOut: result.timedOut,
failed: result.failed,
output: result.output,
cwd: result.cwd,
};
if (result.failed)
return jsonResult({ ...deployResult, registryPush: null });
}
else {
const scriptPath = resolveWorkspacePath(config.workspaceRoot, 'deploy.sh');
if (!fs.existsSync(scriptPath)) {
return errorResult(`No deploy.sh found at the workspace root (${config.workspaceRoot}). Add one that performs your deployment, then retry.`);
}
const result = await runCommand('sh', [scriptPath], {
cwd: config.workspaceRoot,
timeoutMs: config.scaffoldCommandTimeoutMs,
});
deployResult = {
ranScript: 'deploy.sh',
exitCode: result.exitCode,
timedOut: result.timedOut,
failed: result.failed,
output: result.output,
cwd: result.cwd,
};
if (result.failed)
return jsonResult({ ...deployResult, registryPush: null });
}
let pushResult = null;
if (registryPush) {
if (registryPush.includes('--force') || /\s/.test(registryPush)) {
return errorResult('Invalid registryPush image reference.');
}
const pushed = await runCommand('docker', ['push', registryPush], {
cwd: config.workspaceRoot,
timeoutMs: config.scaffoldCommandTimeoutMs,
});
pushResult = {
image: registryPush,
exitCode: pushed.exitCode,
failed: pushed.failed,
timedOut: pushed.timedOut,
output: pushed.output,
};
}
return jsonResult({ ...deployResult, registryPush: pushResult });
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=deployProject.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"deployProject.js","sourceRoot":"","sources":["../../../src/tools/workflow/deployProject.ts"],"names":[],"mappings":"AAAA,OAAO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M;oBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;iBAChB,CAAC;gBACF,IAAI,MAAM,CAAC,MAAM;oBAAE,OAAO,UAAU,CAAC,EAAE,GAAG,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;YAChF,CAAC;YAED,IAAI,UAAU,GAAmC,IAAI,CAAC;YACtD,IAAI,YAAY,EAAE,CAAC;gBACjB,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;oBAChE,OAAO,WAAW,CAAC,uCAAuC,CAAC,CAAC;gBAC9D,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;oBAChE,GAAG,EAAE,MAAM,CAAC,aAAa;oBACzB,SAAS,EAAE,MAAM,CAAC,wBAAwB;iBAC3C,CAAC,CAAC;gBACH,UAAU,GAAG;oBACX,KAAK,EAAE,YAAY;oBACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB,CAAC;YACJ,CAAC;YAED,OAAO,UAAU,CAAC,EAAE,GAAG,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;QACnE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
+53
View File
@@ -0,0 +1,53 @@
import { z } from 'zod';
import { config } from '../../config.js';
import { detectProject, detectWorkspace, resolvePackage, summarizeDetection, summarizeWorkspace, } from '../../lib/frameworks/detect.js';
import { errorResult, jsonResult, toErrorMessage } from '../shared.js';
export function registerDetectFrameworkTool(server) {
server.registerTool('detect_framework', {
title: 'Detect Framework',
description: 'Inspect the workspace (or a monorepo package) and report which framework adapter(s) were detected: laravel, codeigniter, symfony, django, rails, react, vue, nuxt, a backend+frontend combination, or generic. Call this first.',
inputSchema: {
package: z
.string()
.optional()
.describe('Optional monorepo package name/path to inspect instead of the workspace root.'),
includeWorkspace: z
.boolean()
.optional()
.default(false)
.describe('If true, also include a packages[] summary from detect_workspace.'),
},
}, async ({ package: packageName, includeWorkspace }) => {
try {
const root = packageName
? resolvePackage(config.workspaceRoot, packageName).pkg.absolutePath
: config.workspaceRoot;
const detected = detectProject(root);
const summary = summarizeDetection(detected);
if (includeWorkspace) {
summary.workspace = summarizeWorkspace(detectWorkspace(config.workspaceRoot));
}
if (packageName)
summary.package = packageName;
return jsonResult(summary);
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
export function registerDetectWorkspaceTool(server) {
server.registerTool('detect_workspace', {
title: 'Detect Workspace Packages',
description: 'Scan the workspace for monorepo packages (apps/*, packages/*, services/*, frontend/client/web, package.json workspaces, pnpm-workspace.yaml) and report each packages detected framework adapter(s).',
inputSchema: {},
}, async () => {
try {
return jsonResult(summarizeWorkspace(detectWorkspace(config.workspaceRoot)));
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=detectFramework.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"detectFramework.js","sourceRoot":"","sources":["../../../src/tools/workflow/detectFramework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EACL,aAAa,EACb,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,UAAU,2BAA2B,CAAC,MAAi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,EACT,uMAAuM;QACzM,WAAW,EAAE,EAAE;KAChB,EACD,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,OAAO,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
+22
View File
@@ -0,0 +1,22 @@
import { registerDetectFrameworkTool, registerDetectWorkspaceTool } from './detectFramework.js';
import { registerRunInstallTool } from './runInstall.js';
import { registerRunScriptTool } from './runScript.js';
import { registerStartDevServerTool } from './startDevServer.js';
import { registerProcessControlTools } from './processControls.js';
import { registerRunLintTool } from './runLint.js';
import { registerRunTestsTool } from './runTests.js';
import { registerBuildProjectTool } from './buildProject.js';
import { registerDeployProjectTool } from './deployProject.js';
export function registerWorkflowTools(server) {
registerDetectFrameworkTool(server);
registerDetectWorkspaceTool(server);
registerRunInstallTool(server);
registerRunScriptTool(server);
registerStartDevServerTool(server);
registerProcessControlTools(server);
registerRunLintTool(server);
registerRunTestsTool(server);
registerBuildProjectTool(server);
registerDeployProjectTool(server);
}
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/workflow/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnC,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACjC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
+39
View File
@@ -0,0 +1,39 @@
import { z } from 'zod';
import { processManager } from '../../lib/processManager.js';
import { errorResult, jsonResult, toErrorMessage } from '../shared.js';
export function registerProcessControlTools(server) {
server.registerTool('stop_process', {
title: 'Stop Process',
description: 'Stop a previously started background process (a dev server from start_dev_server, or a backgrounded run_script call).',
inputSchema: { processId: z.string() },
}, async ({ processId }) => {
try {
return jsonResult(processManager.stop(processId));
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
server.registerTool('get_process_logs', {
title: 'Get Process Logs',
description: 'Fetch buffered stdout/stderr output and current status for a background process started by start_dev_server or run_script.',
inputSchema: {
processId: z.string(),
tail: z.number().int().positive().optional().describe('Only return the last N log lines.'),
},
}, async ({ processId, tail }) => {
try {
const { info, logs } = processManager.getLogs(processId, tail);
return jsonResult({ ...info, logs });
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
server.registerTool('list_processes', {
title: 'List Processes',
description: 'List every background process tracked by this server (dev servers, backgrounded scripts) with their current status.',
inputSchema: {},
}, async () => jsonResult({ processes: processManager.list() }));
}
//# sourceMappingURL=processControls.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"processControls.js","sourceRoot":"","sources":["../../../src/tools/workflow/processControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,UAAU,2BAA2B,CAAC,MAAiB;IAC3D,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,uHAAuH;QACzH,WAAW,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;KACvC,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;QACtB,IAAI,CAAC;YACH,OAAO,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EACT,4HAA4H;QAC9H,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;YACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;SAC3F;KACF,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,IAAI,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC/D,OAAO,UAAU,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,qHAAqH;QAClI,WAAW,EAAE,EAAE;KAChB,EACD,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,CAC7D,CAAC;AACJ,CAAC"}
+62
View File
@@ -0,0 +1,62 @@
import { config } from '../../config.js';
import { detectProject, resolvePackage } from '../../lib/frameworks/detect.js';
import { runCommand } from '../../lib/runCommand.js';
import { errorResult, jsonResult, packageSchema, targetSchema, toErrorMessage } from '../shared.js';
export function registerRunInstallTool(server) {
server.registerTool('run_install', {
title: 'Install Dependencies',
description: 'Install project dependencies via the detected adapter(s): composer for PHP backends, pip/poetry/uv for Django, bundle for Rails, and/or npm/pnpm/yarn/bun for React/Vue/Nuxt. Installs both sides when present unless `target` narrows it. Optional `package` scopes to a monorepo package.',
inputSchema: { target: targetSchema, package: packageSchema },
}, async ({ target, package: packageName }) => {
try {
const root = packageName
? resolvePackage(config.workspaceRoot, packageName).pkg.absolutePath
: config.workspaceRoot;
const detected = detectProject(root);
const jobs = [];
if (target) {
const adapter = target === 'backend' ? detected.backend : detected.frontend;
if (!adapter)
return errorResult(`target "${target}" was requested, but no such project was detected.`);
jobs.push({ label: target, adapter });
}
else if (detected.backend || detected.frontend) {
if (detected.backend)
jobs.push({ label: 'backend', adapter: detected.backend });
if (detected.frontend)
jobs.push({ label: 'frontend', adapter: detected.frontend });
}
else {
jobs.push({ label: 'primary', adapter: detected.primary });
}
const results = [];
for (const job of jobs) {
try {
const cmd = job.adapter.installCommand();
const result = await runCommand(cmd.command, cmd.args, {
cwd: cmd.cwd,
timeoutMs: config.scaffoldCommandTimeoutMs,
});
results.push({
target: job.label,
adapter: job.adapter.label,
package: packageName ?? null,
exitCode: result.exitCode,
timedOut: result.timedOut,
failed: result.failed,
output: result.output,
cwd: result.cwd,
});
}
catch (error) {
results.push({ target: job.label, adapter: job.adapter.label, error: toErrorMessage(error) });
}
}
return jsonResult({ results });
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=runInstall.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runInstall.js","sourceRoot":"","sources":["../../../src/tools/workflow/runInstall.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEpG,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,6RAA6R;QAC/R,WAAW,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE;KAC9D,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE;QACzC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,WAAW;gBACtB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,YAAY;gBACpE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;YACzB,MAAM,QAAQ,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,MAAM,CAAC,wBAAwB;qBAC3C,CAAC,CAAC;oBACH,OAAO,CAAC,IAAI,CAAC;wBACX,MAAM,EAAE,GAAG,CAAC,KAAK;wBACjB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK;wBAC1B,OAAO,EAAE,WAAW,IAAI,IAAI;wBAC5B,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;qBAChB,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAChG,CAAC;YACH,CAAC;YACD,OAAO,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
+51
View File
@@ -0,0 +1,51 @@
import { z } from 'zod';
import { config } from '../../config.js';
import { detectProject, resolvePackage } from '../../lib/frameworks/detect.js';
import { resolveTarget } from '../../lib/frameworks/resolve.js';
import { runCommand } from '../../lib/runCommand.js';
import { errorResult, jsonResult, packageSchema, targetSchema, toErrorMessage } from '../shared.js';
export function registerRunLintTool(server) {
server.registerTool('run_lint', {
title: 'Run Lint / Format',
description: "Run the project's linter/formatter: ESLint/Prettier for React, Laravel Pint/PHP-CS-Fixer for Laravel, or PHP_CodeSniffer/PHP-CS-Fixer for CodeIgniter (whichever is configured). Returns diagnostics. Optional `package` scopes to a monorepo package.",
inputSchema: {
target: targetSchema,
package: packageSchema,
fix: z.boolean().optional().default(false).describe('Apply auto-fixes instead of only reporting.'),
},
}, async ({ target, package: packageName, fix }) => {
try {
const root = packageName
? resolvePackage(config.workspaceRoot, packageName).pkg.absolutePath
: config.workspaceRoot;
const detected = detectProject(root);
const { adapter, target: resolvedTarget } = resolveTarget(detected, target);
const cmd = adapter.lintCommand(fix);
if (!cmd) {
return jsonResult({
target: resolvedTarget,
package: packageName ?? null,
adapter: adapter.label,
ran: false,
message: 'No lint/format command configured for this project.',
});
}
const result = await runCommand(cmd.command, cmd.args, { cwd: cmd.cwd });
return jsonResult({
target: resolvedTarget,
package: packageName ?? null,
adapter: adapter.label,
ran: true,
exitCode: result.exitCode,
timedOut: result.timedOut,
failed: result.failed,
output: result.output,
cwd: result.cwd,
});
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=runLint.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runLint.js","sourceRoot":"","sources":["../../../src/tools/workflow/runLint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEpG,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CACjB,UAAU,EACV;QACE,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,wPAAwP;QAC1P,WAAW,EAAE;YACX,MAAM,EAAE,YAAY;YACpB,OAAO,EA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E,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
+56
View File
@@ -0,0 +1,56 @@
import { z } from 'zod';
import { config } from '../../config.js';
import { detectProject, resolvePackage } from '../../lib/frameworks/detect.js';
import { resolveTarget } from '../../lib/frameworks/resolve.js';
import { detectJsPackageManager, runScriptCommandFor } from '../../lib/frameworks/packageManager.js';
import { runCommand } from '../../lib/runCommand.js';
import { processManager } from '../../lib/processManager.js';
import { errorResult, jsonResult, packageSchema, targetSchema, toErrorMessage } from '../shared.js';
export function registerRunScriptTool(server) {
server.registerTool('run_script', {
title: 'Run package.json Script',
description: 'Run an npm/pnpm/yarn/bun script from package.json. Runs in the foreground and waits for completion by default; set background: true for long-running scripts (watchers, servers) and manage them via get_process_logs/stop_process. Optional `package` scopes to a monorepo package.',
inputSchema: {
script: z.string().describe('The package.json script name to run, e.g. "build" or "dev".'),
target: targetSchema,
package: packageSchema,
background: z
.boolean()
.optional()
.default(false)
.describe('Run as a tracked background process instead of waiting for it to finish.'),
extraArgs: z.array(z.string()).optional().describe('Extra arguments forwarded to the script.'),
},
}, async ({ script, target, package: packageName, background, extraArgs }) => {
try {
const scopeRoot = packageName
? resolvePackage(config.workspaceRoot, packageName).pkg.absolutePath
: config.workspaceRoot;
const detected = detectProject(scopeRoot);
const { adapter, target: resolvedTarget } = resolveTarget(detected, target, 'frontend');
const root = adapter.root;
const pm = detectJsPackageManager(root);
const { command, args } = runScriptCommandFor(pm, script, extraArgs ?? []);
if (background) {
const info = processManager.start({ label: `run_script:${script}`, command, args, cwd: root });
return jsonResult({ started: true, target: resolvedTarget, package: packageName ?? null, ...info });
}
const result = await runCommand(command, args, { cwd: root });
return jsonResult({
target: resolvedTarget,
package: packageName ?? null,
exitCode: result.exitCode,
timedOut: result.timedOut,
failed: result.failed,
output: result.output,
cwd: result.cwd,
command: result.command,
args: result.args,
});
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=runScript.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runScript.js","sourceRoot":"","sources":["../../../src/tools/workflow/runScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEpG,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,CAAC,YAAY,CACjB,YAAY,EACZ;QACE,KAAK,EAAE,yBAAyB;QAChC,WAAW,EACT,sRAAsR;QACxR,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6DAA6D,CAAC;YAC1F,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,aAAa;YACtB,UAAU,EAAE,CAAC;iBACV,OAAO,EAAE;iBACT,QAAQ,EAAE;iBACV,OAAO,CAAC,KAAK,CAAC;iBACd,QAAQ,CAAC,0EAA0E,CAAC;YACvF,SAAS,EAAE,CA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AAE,CAAC,CAAC;YAC9D,OAAO,UAAU,CAAC;gBAChB,MAAM,EAAE,cAAc;gBACtB,OAAO,EAAE,WAAW,IAAI,IAAI;gBAC5B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
+57
View File
@@ -0,0 +1,57 @@
import { z } from 'zod';
import { config } from '../../config.js';
import { detectProject, resolvePackage } from '../../lib/frameworks/detect.js';
import { resolveTarget } from '../../lib/frameworks/resolve.js';
import { runCommand } from '../../lib/runCommand.js';
import { errorResult, jsonResult, packageSchema, targetSchema, toErrorMessage } from '../shared.js';
export function registerRunTestsTool(server) {
server.registerTool('run_tests', {
title: 'Run Tests',
description: 'Run the project test suite via the detected adapter (e.g. Vitest/Jest for JS frontends, PHPUnit/Pest for PHP, manage.py test for Django, rails test for Rails). Optional `package` scopes to a monorepo package.',
inputSchema: {
target: targetSchema,
package: packageSchema,
extraArgs: z
.array(z.string())
.optional()
.describe('Extra CLI arguments forwarded to the test runner, e.g. ["--filter", "UserTest"].'),
},
}, async ({ target, package: packageName, extraArgs }) => {
try {
const root = packageName
? resolvePackage(config.workspaceRoot, packageName).pkg.absolutePath
: config.workspaceRoot;
const detected = detectProject(root);
const { adapter, target: resolvedTarget } = resolveTarget(detected, target);
const cmd = adapter.testCommand(extraArgs ?? []);
if (!cmd) {
return jsonResult({
target: resolvedTarget,
package: packageName ?? null,
adapter: adapter.label,
ran: false,
message: 'No test runner detected for this project (no "test" script, and no vendor/bin/phpunit or vendor/bin/pest).',
});
}
const result = await runCommand(cmd.command, cmd.args, {
cwd: cmd.cwd,
timeoutMs: config.scaffoldCommandTimeoutMs,
});
return jsonResult({
target: resolvedTarget,
package: packageName ?? null,
adapter: adapter.label,
ran: true,
exitCode: result.exitCode,
timedOut: result.timedOut,
failed: result.failed,
output: result.output,
cwd: result.cwd,
});
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=runTests.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runTests.js","sourceRoot":"","sources":["../../../src/tools/workflow/runTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEpG,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IACpD,MAAM,CAAC,YAAY,CACjB,WAAW,EACX;QACE,KAAK,EAAE,WAAW;QAClB,WAAW,EACT,kNAAkN;QACpN,WAAW,EAAE;YACX,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,aAAa;YACtB,SAAS,EAAE,CAAC;iBACT,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;iBACjB,QAAQ,EAAE;iBACV,QAAQ,CAAC,kFAAkF,CAAC;SAChG;KACF,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE;QACpD,IAAI,CAAC;YAC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AAO,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
+58
View File
@@ -0,0 +1,58 @@
import { z } from 'zod';
import { config } from '../../config.js';
import { detectProject, resolvePackage } from '../../lib/frameworks/detect.js';
import { resolveTarget } from '../../lib/frameworks/resolve.js';
import { processManager } from '../../lib/processManager.js';
import { errorResult, jsonResult, packageSchema, targetSchema, toErrorMessage } from '../shared.js';
export function registerStartDevServerTool(server) {
server.registerTool('start_dev_server', {
title: 'Start Dev Server',
description: 'Start the project dev server as a tracked background process and wait for its ready signal. ' +
'Laravel uses `vendor/bin/sail up` (or docker compose up) when Sail is present; otherwise php artisan serve / spark / Vite/CRA/Next. ' +
'Returns a processId for get_process_logs/stop_process. Optional `package` scopes to a monorepo package.',
inputSchema: {
target: targetSchema,
package: packageSchema,
timeoutMs: z
.number()
.int()
.positive()
.optional()
.describe('How long to wait for the ready signal before returning anyway. Defaults to 30s.'),
},
}, async ({ target, package: packageName, timeoutMs }) => {
try {
const root = packageName
? resolvePackage(config.workspaceRoot, packageName).pkg.absolutePath
: config.workspaceRoot;
const detected = detectProject(root);
const { adapter, target: resolvedTarget } = resolveTarget(detected, target, 'frontend');
const cmd = adapter.devCommand();
const info = processManager.start({
label: `dev-server:${adapter.kind}`,
command: cmd.command,
args: cmd.args,
cwd: cmd.cwd,
});
const { matchedLine, timedOut } = await processManager.waitForLog(info.id, adapter.readyPattern(), timeoutMs ?? config.defaultReadyTimeoutMs);
const urlMatch = matchedLine?.match(/https?:\/\/\S+/i);
return jsonResult({
processId: info.id,
target: resolvedTarget,
package: packageName ?? null,
adapter: adapter.label,
ready: Boolean(matchedLine),
timedOut,
readyLine: matchedLine,
url: urlMatch ? urlMatch[0].replace(/[.,)\]]+$/, '') : null,
hint: timedOut
? 'No ready signal seen within the timeout; the server may still be starting (or failed). Check get_process_logs.'
: 'Use get_process_logs to tail output and stop_process to shut it down when done.',
});
}
catch (error) {
return errorResult(toErrorMessage(error));
}
});
}
//# sourceMappingURL=startDevServer.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"startDevServer.js","sourceRoot":"","sources":["../../../src/tools/workflow/startDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEpG,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAC1D,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EACT,8FAA8F;YAC9F,sIAAsI;YACtI,yGAAyG;QAC3G,WAAW,EAAE;YACX,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,aAAa;YACtB,SAAS,EAAE,CAAC;iBACT,MAAM,EAAE;iBACR,GAAG,EAAE;iBACL,QAAQ,EAAE;iBACV,QAAQ,EAAE;iBACV,QAAQ,CAAC,iFAAiF,CAAC;SAC/F;KACF,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE;QACpD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,WAAW;gBACtB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,YAAY;gBACpE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;YACzB,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM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