@agents-at-scale/ark 0.1.34 → 0.1.35-rc.1
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/dist/arkServices.d.ts +50 -0
- package/dist/arkServices.js +153 -0
- package/dist/charts/charts.d.ts +5 -0
- package/dist/charts/charts.js +6 -0
- package/dist/charts/dependencies.d.ts +6 -0
- package/dist/charts/dependencies.js +50 -0
- package/dist/charts/types.d.ts +40 -0
- package/dist/charts/types.js +1 -0
- package/dist/commands/agents/index.d.ts +2 -0
- package/dist/commands/agents/index.js +56 -0
- package/dist/commands/agents/selector.d.ts +8 -0
- package/dist/commands/agents/selector.js +53 -0
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.js +53 -0
- package/dist/commands/chat/index.d.ts +2 -0
- package/dist/commands/chat/index.js +45 -0
- package/dist/commands/chat.d.ts +2 -0
- package/dist/commands/chat.js +45 -0
- package/dist/commands/cluster/get.d.ts +2 -0
- package/dist/commands/cluster/get.js +39 -0
- package/dist/commands/cluster/index.js +2 -4
- package/dist/commands/completion/index.d.ts +2 -0
- package/dist/commands/completion/index.js +268 -0
- package/dist/commands/completion.js +159 -2
- package/dist/commands/config/index.d.ts +2 -0
- package/dist/commands/config/index.js +42 -0
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.js +38 -321
- package/dist/commands/dashboard/index.d.ts +3 -0
- package/dist/commands/dashboard/index.js +39 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.js +39 -0
- package/dist/commands/dev/index.d.ts +2 -0
- package/dist/commands/dev/index.js +9 -0
- package/dist/commands/dev/tool/check.d.ts +2 -0
- package/dist/commands/dev/tool/check.js +142 -0
- package/dist/commands/dev/tool/clean.d.ts +2 -0
- package/dist/commands/dev/tool/clean.js +153 -0
- package/dist/commands/dev/tool/generate.d.ts +2 -0
- package/dist/commands/dev/tool/generate.js +28 -0
- package/dist/commands/dev/tool/index.d.ts +2 -0
- package/dist/commands/dev/tool/index.js +14 -0
- package/dist/commands/dev/tool/init.d.ts +2 -0
- package/dist/commands/dev/tool/init.js +320 -0
- package/dist/commands/dev/tool/shared.d.ts +5 -0
- package/dist/commands/dev/tool/shared.js +256 -0
- package/dist/commands/dev/tool/status.d.ts +2 -0
- package/dist/commands/dev/tool/status.js +136 -0
- package/dist/commands/dev/tool.d.ts +2 -0
- package/dist/commands/dev/tool.js +559 -0
- package/dist/commands/generate/config.js +5 -24
- package/dist/commands/generate/generators/mcpserver.d.ts +2 -1
- package/dist/commands/generate/generators/mcpserver.js +26 -5
- package/dist/commands/install/index.d.ts +6 -0
- package/dist/commands/install/index.js +165 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.js +147 -0
- package/dist/commands/models/create.d.ts +1 -0
- package/dist/commands/models/create.js +213 -0
- package/dist/commands/models/index.d.ts +2 -0
- package/dist/commands/models/index.js +65 -0
- package/dist/commands/models/selector.d.ts +8 -0
- package/dist/commands/models/selector.js +53 -0
- package/dist/commands/routes/index.d.ts +2 -0
- package/dist/commands/routes/index.js +101 -0
- package/dist/commands/routes.d.ts +2 -0
- package/dist/commands/routes.js +101 -0
- package/dist/commands/status/index.d.ts +3 -0
- package/dist/commands/status/index.js +33 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +33 -0
- package/dist/commands/targets/index.d.ts +2 -0
- package/dist/commands/targets/index.js +65 -0
- package/dist/commands/targets.d.ts +2 -0
- package/dist/commands/targets.js +65 -0
- package/dist/commands/teams/index.d.ts +2 -0
- package/dist/commands/teams/index.js +54 -0
- package/dist/commands/teams/selector.d.ts +8 -0
- package/dist/commands/teams/selector.js +55 -0
- package/dist/commands/tools/index.d.ts +2 -0
- package/dist/commands/tools/index.js +54 -0
- package/dist/commands/tools/selector.d.ts +8 -0
- package/dist/commands/tools/selector.js +53 -0
- package/dist/commands/uninstall/index.d.ts +2 -0
- package/dist/commands/uninstall/index.js +84 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.js +83 -0
- package/dist/components/ChatUI.d.ts +16 -0
- package/dist/components/ChatUI.js +801 -0
- package/dist/components/StatusView.d.ts +10 -0
- package/dist/components/StatusView.js +39 -0
- package/dist/components/statusChecker.d.ts +10 -13
- package/dist/components/statusChecker.js +128 -65
- package/dist/config.js +3 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -36
- package/dist/lib/arkApiClient.d.ts +53 -0
- package/dist/lib/arkApiClient.js +102 -0
- package/dist/lib/arkApiProxy.d.ts +9 -0
- package/dist/lib/arkApiProxy.js +22 -0
- package/dist/lib/arkServiceProxy.d.ts +14 -0
- package/dist/lib/arkServiceProxy.js +93 -0
- package/dist/lib/arkStatus.d.ts +5 -0
- package/dist/lib/arkStatus.js +20 -0
- package/dist/lib/chatClient.d.ts +33 -0
- package/dist/lib/chatClient.js +101 -0
- package/dist/lib/cluster.d.ts +2 -1
- package/dist/lib/cluster.js +27 -3
- package/dist/lib/commandUtils.d.ts +4 -0
- package/dist/lib/commandUtils.js +18 -0
- package/dist/lib/commandUtils.test.d.ts +1 -0
- package/dist/lib/commandUtils.test.js +44 -0
- package/dist/lib/config.d.ts +24 -80
- package/dist/lib/config.js +68 -205
- package/dist/lib/config.test.d.ts +1 -0
- package/dist/lib/config.test.js +93 -0
- package/dist/lib/dev/tools/analyzer.d.ts +30 -0
- package/dist/lib/dev/tools/analyzer.js +190 -0
- package/dist/lib/dev/tools/discover_tools.py +392 -0
- package/dist/lib/dev/tools/mcp-types.d.ts +28 -0
- package/dist/lib/dev/tools/mcp-types.js +86 -0
- package/dist/lib/dev/tools/types.d.ts +50 -0
- package/dist/lib/dev/tools/types.js +1 -0
- package/dist/lib/output.d.ts +36 -0
- package/dist/lib/output.js +89 -0
- package/dist/lib/types.d.ts +8 -3
- package/dist/types/types.d.ts +40 -0
- package/dist/types/types.js +1 -0
- package/dist/ui/MainMenu.js +158 -90
- package/dist/ui/statusFormatter.d.ts +4 -1
- package/dist/ui/statusFormatter.js +91 -19
- package/package.json +16 -4
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import yaml from 'yaml';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import output from '../../../lib/output.js';
|
|
9
|
+
export async function generateProjectFiles(toolPath, options = {
|
|
10
|
+
interactive: true,
|
|
11
|
+
dryRun: false,
|
|
12
|
+
overwrite: false,
|
|
13
|
+
}) {
|
|
14
|
+
const absolutePath = path.resolve(toolPath);
|
|
15
|
+
const arkConfigPath = path.join(absolutePath, '.ark.yaml');
|
|
16
|
+
// Check if .ark.yaml exists
|
|
17
|
+
if (!fs.existsSync(arkConfigPath)) {
|
|
18
|
+
output.error('.ark.yaml not found. Run "ark dev tool init" first.');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
// Load .ark.yaml
|
|
22
|
+
const arkConfig = yaml.parse(fs.readFileSync(arkConfigPath, 'utf-8'));
|
|
23
|
+
const generateSpinner = options.dryRun
|
|
24
|
+
? null
|
|
25
|
+
: ora('Generating project files...').start();
|
|
26
|
+
try {
|
|
27
|
+
// Find template directory - templates are in the source tree
|
|
28
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
29
|
+
const distDir = path.dirname(path.dirname(path.dirname(path.dirname(currentFile)))); // Goes to dist/
|
|
30
|
+
const arkCliDir = path.dirname(distDir); // Goes to ark-cli/
|
|
31
|
+
const templateDir = path.join(arkCliDir, 'templates', 'python-mcp-tool');
|
|
32
|
+
if (!fs.existsSync(templateDir)) {
|
|
33
|
+
if (generateSpinner) {
|
|
34
|
+
generateSpinner.fail('Template directory not found');
|
|
35
|
+
}
|
|
36
|
+
console.log(chalk.yellow('Could not find templates at: ' + templateDir));
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// Use a Set to track all generated items (both files and directories)
|
|
40
|
+
const generatedItems = new Set();
|
|
41
|
+
const skippedItems = new Set();
|
|
42
|
+
const errors = [];
|
|
43
|
+
// Process all files and directories in the template directory
|
|
44
|
+
processTemplateDirectory(templateDir, absolutePath, arkConfig, options, {
|
|
45
|
+
generatedItems,
|
|
46
|
+
skippedItems,
|
|
47
|
+
errors,
|
|
48
|
+
});
|
|
49
|
+
if (!options.dryRun) {
|
|
50
|
+
if (generatedItems.size > 0) {
|
|
51
|
+
generateSpinner.succeed(`Generated ${generatedItems.size} file(s)`);
|
|
52
|
+
// Show the generated files after stopping the spinner
|
|
53
|
+
if (options.interactive && generatedItems.size > 0) {
|
|
54
|
+
// Sort items for consistent display
|
|
55
|
+
const sortedItems = Array.from(generatedItems).sort();
|
|
56
|
+
sortedItems.forEach((item) => {
|
|
57
|
+
console.log(chalk.green(` ✓ Generated ${item}`));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (skippedItems.size > 0) {
|
|
62
|
+
generateSpinner.warn(`No new files generated (${skippedItems.size} already exist)`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
generateSpinner.warn('No files to generate');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (errors.length > 0 && options.interactive) {
|
|
69
|
+
console.log(chalk.red('Errors:'));
|
|
70
|
+
errors.forEach((e) => console.log(chalk.red(` - ${e}`)));
|
|
71
|
+
}
|
|
72
|
+
return generatedItems.size > 0;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (!options.dryRun && generateSpinner) {
|
|
76
|
+
generateSpinner.fail('Failed to generate project files');
|
|
77
|
+
}
|
|
78
|
+
if (options.interactive) {
|
|
79
|
+
console.log(chalk.red(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function processTemplateDirectory(sourceDir, targetDir, arkConfig, options, stats, rootTargetDir) {
|
|
85
|
+
// Track the root target directory for relative path calculations
|
|
86
|
+
const actualRootTargetDir = rootTargetDir || targetDir;
|
|
87
|
+
// Check if this directory needs to be created
|
|
88
|
+
const dirExists = fs.existsSync(targetDir);
|
|
89
|
+
// Create target directory if it doesn't exist
|
|
90
|
+
if (!options.dryRun && !dirExists) {
|
|
91
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
92
|
+
// Track the directory creation (relative to root)
|
|
93
|
+
const relativePath = path.relative(actualRootTargetDir, targetDir);
|
|
94
|
+
if (relativePath) {
|
|
95
|
+
// Don't add empty string for root directory
|
|
96
|
+
stats.generatedItems.add(`${relativePath}/`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const entries = fs.readdirSync(sourceDir, { withFileTypes: true });
|
|
100
|
+
for (const entry of entries) {
|
|
101
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
102
|
+
if (entry.isDirectory()) {
|
|
103
|
+
// Recursively process subdirectories
|
|
104
|
+
const targetSubDir = path.join(targetDir, entry.name);
|
|
105
|
+
if (options.dryRun) {
|
|
106
|
+
const relativePath = path.relative(actualRootTargetDir, targetSubDir);
|
|
107
|
+
console.log(chalk.cyan(`\n=== ${relativePath}/ directory ===`));
|
|
108
|
+
console.log(`Directory: ${entry.name}`);
|
|
109
|
+
console.log(chalk.cyan(`=== END ${relativePath}/ directory ===\n`));
|
|
110
|
+
}
|
|
111
|
+
processTemplateDirectory(sourcePath, targetSubDir, arkConfig, options, stats, actualRootTargetDir);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Process file - check if it's a template
|
|
115
|
+
const isTemplate = entry.name.startsWith('template.');
|
|
116
|
+
const targetFileName = isTemplate
|
|
117
|
+
? entry.name.replace('template.', '')
|
|
118
|
+
: entry.name;
|
|
119
|
+
const targetPath = path.join(targetDir, targetFileName);
|
|
120
|
+
// Make target path relative to the original target directory for display
|
|
121
|
+
const displayPath = path.relative(actualRootTargetDir, targetPath);
|
|
122
|
+
// Check if file already exists
|
|
123
|
+
const fileExists = fs.existsSync(targetPath);
|
|
124
|
+
if (!options.dryRun && !options.overwrite && fileExists) {
|
|
125
|
+
if (options.interactive) {
|
|
126
|
+
console.log(chalk.yellow(` Skipping ${displayPath} (already exists)`));
|
|
127
|
+
}
|
|
128
|
+
stats.skippedItems.add(displayPath);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
let content;
|
|
133
|
+
if (isTemplate) {
|
|
134
|
+
// Process template file with helm - pass the actual root target directory
|
|
135
|
+
content = processTemplateFile(sourcePath, targetFileName, arkConfig, options, actualRootTargetDir);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Regular file, just read it
|
|
139
|
+
content = fs.readFileSync(sourcePath, 'utf-8');
|
|
140
|
+
}
|
|
141
|
+
// In dry-run mode, print to stdout; otherwise write the file
|
|
142
|
+
if (options.dryRun) {
|
|
143
|
+
console.log(chalk.cyan(`\n=== ${displayPath} ===`));
|
|
144
|
+
console.log(content);
|
|
145
|
+
console.log(chalk.cyan(`=== END ${displayPath} ===\n`));
|
|
146
|
+
stats.generatedItems.add(displayPath);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
fs.writeFileSync(targetPath, content);
|
|
150
|
+
stats.generatedItems.add(displayPath);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
const errorMsg = `${displayPath}: ${err instanceof Error ? err.message : 'Unknown error'}`;
|
|
155
|
+
stats.errors.push(errorMsg);
|
|
156
|
+
if (options.dryRun) {
|
|
157
|
+
console.log(chalk.red(`Error processing ${displayPath}: ${err instanceof Error ? err.message : 'Unknown error'}`));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function processTemplateFile(templatePath, targetFileName, arkConfig, options, rootTargetDir) {
|
|
164
|
+
// Prepare consistent values structure for all templates
|
|
165
|
+
const projectName = arkConfig.project?.name ||
|
|
166
|
+
path.basename(rootTargetDir || path.dirname(templatePath));
|
|
167
|
+
const values = {
|
|
168
|
+
project: {
|
|
169
|
+
name: projectName,
|
|
170
|
+
type: arkConfig.project?.type || 'pyproject',
|
|
171
|
+
platform: arkConfig.project?.platform || 'python3',
|
|
172
|
+
version: arkConfig.project?.version || '0.1.0',
|
|
173
|
+
framework: arkConfig.project?.framework || 'fastmcp',
|
|
174
|
+
description: arkConfig.project?.description || `${projectName} MCP tool`,
|
|
175
|
+
},
|
|
176
|
+
python: {
|
|
177
|
+
version: '3.11', // Default Python version
|
|
178
|
+
module_name: projectName.replace(/-/g, '_'), // Convert kebab-case to snake_case
|
|
179
|
+
},
|
|
180
|
+
mcp: {
|
|
181
|
+
transport: arkConfig.mcp?.transport || 'sse', // Default to SSE for Kubernetes
|
|
182
|
+
port: arkConfig.mcp?.port || 8080,
|
|
183
|
+
healthCheck: arkConfig.mcp?.transport !== 'stdio', // No health checks for stdio
|
|
184
|
+
},
|
|
185
|
+
devspace: {
|
|
186
|
+
namespace: 'default',
|
|
187
|
+
image: {
|
|
188
|
+
repository: projectName, // Default repository name
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
// Create temp directory for helm processing
|
|
193
|
+
const tempDir = path.join('/tmp', `ark-helm-${Date.now()}`);
|
|
194
|
+
const tempChartDir = path.join(tempDir, 'chart');
|
|
195
|
+
const tempTemplatesDir = path.join(tempChartDir, 'templates');
|
|
196
|
+
fs.mkdirSync(tempTemplatesDir, { recursive: true });
|
|
197
|
+
try {
|
|
198
|
+
// Write minimal Chart.yaml
|
|
199
|
+
fs.writeFileSync(path.join(tempChartDir, 'Chart.yaml'), 'apiVersion: v2\nname: temp\nversion: 0.1.0\n');
|
|
200
|
+
// Write values file
|
|
201
|
+
const tempValuesFile = path.join(tempDir, 'values.yaml');
|
|
202
|
+
fs.writeFileSync(tempValuesFile, yaml.stringify(values));
|
|
203
|
+
// Determine if this is a YAML file
|
|
204
|
+
const isYamlFile = targetFileName.endsWith('.yaml') || targetFileName.endsWith('.yml');
|
|
205
|
+
// For dotfiles, replace the leading dot with 'dot' for helm processing
|
|
206
|
+
const helmTemplateName = targetFileName.startsWith('.')
|
|
207
|
+
? 'dot' + targetFileName.substring(1)
|
|
208
|
+
: targetFileName;
|
|
209
|
+
if (isYamlFile) {
|
|
210
|
+
// Copy YAML files directly
|
|
211
|
+
fs.copyFileSync(templatePath, path.join(tempTemplatesDir, helmTemplateName));
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// Wrap non-YAML content in a YAML structure for helm
|
|
215
|
+
const originalContent = fs.readFileSync(templatePath, 'utf-8');
|
|
216
|
+
const wrappedContent = `# Wrapped for helm processing\ncontent: |\n${originalContent
|
|
217
|
+
.split('\n')
|
|
218
|
+
.map((line) => ' ' + line)
|
|
219
|
+
.join('\n')}`;
|
|
220
|
+
fs.writeFileSync(path.join(tempTemplatesDir, helmTemplateName + '.yaml'), wrappedContent);
|
|
221
|
+
}
|
|
222
|
+
// Run helm template to process the file
|
|
223
|
+
const actualHelmFile = isYamlFile
|
|
224
|
+
? helmTemplateName
|
|
225
|
+
: helmTemplateName + '.yaml';
|
|
226
|
+
const helmCommand = `helm template temp ${tempChartDir} --values ${tempValuesFile} -s templates/${actualHelmFile}`;
|
|
227
|
+
let content;
|
|
228
|
+
try {
|
|
229
|
+
content = execSync(helmCommand, {
|
|
230
|
+
encoding: 'utf-8',
|
|
231
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
232
|
+
});
|
|
233
|
+
// Remove the YAML document separator that helm adds
|
|
234
|
+
content = content.replace(/^---\n/, '');
|
|
235
|
+
// Remove helm's source comment
|
|
236
|
+
content = content.replace(/^# Source:.*\n/gm, '');
|
|
237
|
+
// For non-YAML files, extract the content from the wrapped YAML
|
|
238
|
+
if (!isYamlFile) {
|
|
239
|
+
// Parse the YAML to extract the content field
|
|
240
|
+
const yamlContent = yaml.parse(content);
|
|
241
|
+
content = yamlContent.content || '';
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
catch (helmError) {
|
|
245
|
+
const errorMsg = helmError.stderr || helmError.message || 'Unknown error';
|
|
246
|
+
throw new Error(`Failed to template ${targetFileName}: ${errorMsg}`);
|
|
247
|
+
}
|
|
248
|
+
return content;
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
// Clean up temp directory
|
|
252
|
+
if (fs.existsSync(tempDir)) {
|
|
253
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import output from '../../../lib/output.js';
|
|
6
|
+
import { ArkDevToolAnalyzer } from '../../../lib/dev/tools/analyzer.js';
|
|
7
|
+
import { toMCPTool } from '../../../lib/dev/tools/mcp-types.js';
|
|
8
|
+
async function statusTool(toolPath, options) {
|
|
9
|
+
const absolutePath = path.resolve(toolPath);
|
|
10
|
+
const analyzer = new ArkDevToolAnalyzer();
|
|
11
|
+
const isJson = options.output === 'json';
|
|
12
|
+
// Build up result object as we go
|
|
13
|
+
const result = {
|
|
14
|
+
path: absolutePath,
|
|
15
|
+
projectRoot: null,
|
|
16
|
+
error: null,
|
|
17
|
+
platform: null,
|
|
18
|
+
projectType: null,
|
|
19
|
+
projectName: null,
|
|
20
|
+
projectVersion: null,
|
|
21
|
+
hasFastmcp: false,
|
|
22
|
+
fastmcpVersion: null,
|
|
23
|
+
tools: [],
|
|
24
|
+
toolDiscoveryError: null
|
|
25
|
+
};
|
|
26
|
+
if (!isJson) {
|
|
27
|
+
console.log();
|
|
28
|
+
}
|
|
29
|
+
// Single spinner for all analysis (skip for JSON output)
|
|
30
|
+
const analyzeSpinner = isJson ? null : ora(`analyzing ${absolutePath}`).start();
|
|
31
|
+
// Small delay to let user see what's happening (skip for JSON)
|
|
32
|
+
if (!isJson) {
|
|
33
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
34
|
+
}
|
|
35
|
+
// Collect all information
|
|
36
|
+
const project = await analyzer.discoverProject(absolutePath);
|
|
37
|
+
if (!project || !project.exists) {
|
|
38
|
+
result.error = 'path not found';
|
|
39
|
+
if (isJson) {
|
|
40
|
+
console.log(JSON.stringify(result, null, 2));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
analyzeSpinner.stop();
|
|
44
|
+
output.error(`path not found: ${absolutePath}`);
|
|
45
|
+
}
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
if (!project.is_directory) {
|
|
49
|
+
result.error = 'path is not a directory';
|
|
50
|
+
if (isJson) {
|
|
51
|
+
console.log(JSON.stringify(result, null, 2));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
analyzeSpinner.stop();
|
|
55
|
+
output.error(`path is not a directory: ${absolutePath}`);
|
|
56
|
+
}
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
if (!project.platform) {
|
|
60
|
+
result.error = 'platform unknown - no pyproject.toml or requirements.txt found';
|
|
61
|
+
if (isJson) {
|
|
62
|
+
console.log(JSON.stringify(result, null, 2));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
analyzeSpinner.stop();
|
|
66
|
+
output.error(`no pyproject.toml or requirements.txt found in: ${absolutePath}`);
|
|
67
|
+
}
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
// Update result with project info
|
|
71
|
+
result.platform = project.platform;
|
|
72
|
+
result.projectType = project.project_type;
|
|
73
|
+
result.projectName = project.project_name;
|
|
74
|
+
result.projectVersion = project.project_version;
|
|
75
|
+
result.hasFastmcp = project.has_fastmcp;
|
|
76
|
+
result.fastmcpVersion = project.fastmcp_version;
|
|
77
|
+
result.projectRoot = absolutePath; // Store the project root
|
|
78
|
+
// Discover tools recursively in the project
|
|
79
|
+
const rawTools = [];
|
|
80
|
+
try {
|
|
81
|
+
const projectTools = await analyzer.findProjectTools(absolutePath);
|
|
82
|
+
if (projectTools && projectTools.tools) {
|
|
83
|
+
rawTools.push(...projectTools.tools);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
result.toolDiscoveryError = error instanceof Error ? error.message : 'Unknown error';
|
|
88
|
+
}
|
|
89
|
+
// Store tools in the appropriate format
|
|
90
|
+
result.tools = isJson ? rawTools.map(toMCPTool) : rawTools;
|
|
91
|
+
if (isJson) {
|
|
92
|
+
// Output raw JSON
|
|
93
|
+
console.log(JSON.stringify(result, null, 2));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
analyzeSpinner.succeed('analysis complete');
|
|
97
|
+
console.log();
|
|
98
|
+
// Display summary in cleaner format
|
|
99
|
+
output.section(path.basename(absolutePath));
|
|
100
|
+
// Platform
|
|
101
|
+
output.statusCheck('found', 'platform', result.platform);
|
|
102
|
+
// Project type with name and version in gray
|
|
103
|
+
let projectDetails = '';
|
|
104
|
+
if (result.projectName) {
|
|
105
|
+
projectDetails = result.projectName;
|
|
106
|
+
if (result.projectVersion) {
|
|
107
|
+
projectDetails += ` v${result.projectVersion}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
output.statusCheck('found', 'project', result.projectType, projectDetails);
|
|
111
|
+
// Framework with version in gray
|
|
112
|
+
if (result.hasFastmcp) {
|
|
113
|
+
const fastmcpDetails = result.fastmcpVersion ? `v${result.fastmcpVersion}` : undefined;
|
|
114
|
+
output.statusCheck('found', 'framework', 'fastmcp', fastmcpDetails);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
output.statusCheck('missing', 'framework', 'fastmcp');
|
|
118
|
+
}
|
|
119
|
+
// Tools with details
|
|
120
|
+
output.statusCheck('found', 'tools', result.tools.length.toString());
|
|
121
|
+
if (result.tools.length > 0) {
|
|
122
|
+
for (const tool of result.tools) {
|
|
123
|
+
const description = tool.docstring ? tool.docstring.split('\n')[0] : '';
|
|
124
|
+
console.log(chalk.gray(` - ${tool.name}: ${description}`));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export function createStatusCommand() {
|
|
129
|
+
const statusCommand = new Command('status');
|
|
130
|
+
statusCommand
|
|
131
|
+
.description('Check the status of an MCP tool project')
|
|
132
|
+
.argument('<path>', 'Path to the tool directory')
|
|
133
|
+
.option('-o, --output <format>', 'Output format (json)', 'text')
|
|
134
|
+
.action(statusTool);
|
|
135
|
+
return statusCommand;
|
|
136
|
+
}
|