Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

Commit 999a49b

Browse files
committed
feat: ok logs
1 parent 7ed8bb2 commit 999a49b

2 files changed

Lines changed: 39 additions & 30 deletions

File tree

packages/cli/src/build.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ async function buildWidget(entry: string, projectPath: string, minify = true) {
9898
}
9999

100100
export async function buildWidgets(projectPath: string, watch = false) {
101-
console.log(`🔨 Building UI widgets with esbuild${watch ? ' (watch mode)' : ''}...`)
102-
103101
const srcDir = path.join(projectPath, SRC_DIR)
104102
const outDir = path.join(projectPath, OUT_DIR)
105103

@@ -108,10 +106,15 @@ export async function buildWidgets(projectPath: string, watch = false) {
108106

109107
// Find all TSX entries
110108
const entries = await globby([`${srcDir}/**/*.tsx`])
111-
console.log(`📦 Found ${entries.length} widget files`)
109+
110+
if (!watch) {
111+
console.log(`Building ${entries.length} widget files...`)
112+
}
112113

113114
if (watch) {
114-
// Watch mode
115+
// Watch mode - create contexts for each entry but don't log individual watching messages
116+
const contexts = []
117+
115118
for (const entry of entries) {
116119
const relativePath = path.relative(projectPath, entry)
117120
const route = toRoute(relativePath)
@@ -128,7 +131,7 @@ export async function buildWidgets(projectPath: string, watch = false) {
128131
sourcemap: true,
129132
minify: false,
130133
outdir: path.join(pageOutDir, 'assets'),
131-
logLevel: 'info',
134+
logLevel: 'silent',
132135
loader: {
133136
'.svg': 'file',
134137
'.png': 'file',
@@ -169,21 +172,22 @@ export async function buildWidgets(projectPath: string, watch = false) {
169172
}],
170173
})
171174

172-
await ctx.watch()
173-
console.log(`👀 Watching ${baseName}...`)
175+
contexts.push(ctx)
174176
}
175177

176-
console.log('👀 Watching for changes... Press Ctrl+C to stop.')
178+
// Start watching all contexts
179+
for (const ctx of contexts) {
180+
await ctx.watch()
181+
}
177182
}
178183
else {
179184
// Build once
180185
for (const entry of entries) {
181-
console.log(`🔨 Building ${path.parse(entry).name}...`)
182186
const { baseName, route } = await buildWidget(entry, projectPath)
183-
console.log(` Built ${baseName} -> ${route}`)
187+
console.log(`\x1b[32m✓\x1b[0m Built ${baseName} -> ${route}`)
184188
}
185189

186-
console.log('🎉 Build complete!')
190+
console.log('Build complete!')
187191
}
188192
}
189193

packages/cli/src/index.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const program = new Command();
1111
program
1212
.name('mcp-use')
1313
.description('MCP CLI tool')
14-
.version('0.1.0');
14+
.version('2.0.1');
1515

1616
// Helper to check if server is ready
1717
async function waitForServer(port: number, maxAttempts = 30): Promise<boolean> {
@@ -35,7 +35,7 @@ function runCommand(command: string, args: string[], cwd: string): Promise<void>
3535
const proc = spawn(command, args, {
3636
cwd,
3737
stdio: 'inherit',
38-
shell: true,
38+
shell: false,
3939
});
4040

4141
proc.on('error', reject);
@@ -57,10 +57,12 @@ program
5757
try {
5858
const projectPath = path.resolve(options.path);
5959

60+
console.log('\x1b[36m\x1b[1mmcp-use\x1b[0m \x1b[90mVersion: 2.0.1\x1b[0m\n');
61+
6062
// Run tsc first
61-
console.log('🔨 Building TypeScript...');
63+
console.log('Building TypeScript...');
6264
await runCommand('npx', ['tsc'], projectPath);
63-
console.log(' TypeScript build complete!');
65+
console.log('\x1b[32m✓\x1b[0m TypeScript build complete!');
6466

6567
// Then build widgets
6668
await buildWidgets(projectPath, false);
@@ -81,7 +83,7 @@ program
8183
const projectPath = path.resolve(options.path);
8284
const port = parseInt(options.port, 10);
8385

84-
console.log('🚀 Starting development mode...\n');
86+
console.log('\x1b[36m\x1b[1mmcp-use\x1b[0m \x1b[90mVersion: 2.0.1\x1b[0m\n');
8587

8688
// Find the main source file
8789
let serverFile = 'src/server.ts';
@@ -95,22 +97,20 @@ program
9597
const processes: any[] = [];
9698

9799
// 1. TypeScript watch
98-
console.log('📦 Starting TypeScript compiler in watch mode...');
99100
const tscProc = spawn('npx', ['tsc', '--watch'], {
100101
cwd: projectPath,
101102
stdio: 'pipe',
102-
shell: true,
103+
shell: false,
103104
});
104105
tscProc.stdout?.on('data', (data) => {
105106
const output = data.toString();
106107
if (output.includes('Watching for file changes')) {
107-
console.log(' TypeScript compiler watching...');
108+
console.log('\x1b[32m✓\x1b[0m TypeScript compiler watching...');
108109
}
109110
});
110111
processes.push(tscProc);
111112

112113
// 2. Widget builder watch - run in background
113-
console.log('🎨 Starting widget builder in watch mode...');
114114
buildWidgets(projectPath, true).catch((error) => {
115115
console.error('Widget builder failed:', error);
116116
});
@@ -119,31 +119,34 @@ program
119119
await new Promise(resolve => setTimeout(resolve, 2000));
120120

121121
// 3. Server with tsx
122-
console.log(`🌐 Starting server at http://localhost:${port}...`);
123122
const serverProc = spawn('npx', ['tsx', 'watch', serverFile], {
124123
cwd: projectPath,
125-
stdio: 'inherit',
126-
shell: true,
124+
stdio: 'pipe',
125+
shell: false,
127126
env: { ...process.env, PORT: String(port) },
128127
});
129128
processes.push(serverProc);
130129

131130
// Auto-open inspector if enabled
132131
if (options.open) {
133-
console.log('⏳ Waiting for server to be ready...');
132+
const startTime = Date.now();
134133
const ready = await waitForServer(port);
135134
if (ready) {
136135
const inspectorUrl = `http://localhost:${port}/inspector`;
137-
console.log(`\n🔍 Opening inspector at ${inspectorUrl}...\n`);
136+
const mcpUrl = `http://localhost:${port}/mcp`;
137+
const readyTime = Date.now() - startTime;
138+
console.log(`\n\x1b[32m✓\x1b[0m Ready in ${readyTime}ms`);
139+
console.log(`Local: http://localhost:${port}`);
140+
console.log(`Network: http://localhost:${port}`);
141+
console.log(`MCP: ${mcpUrl}`);
142+
console.log(`Inspector: ${inspectorUrl}\n`);
138143
await open(inspectorUrl);
139-
} else {
140-
console.log('\n⚠️ Server did not start in time, skipping auto-open');
141144
}
142145
}
143146

144147
// Handle cleanup
145148
const cleanup = () => {
146-
console.log('\n\n🛑 Shutting down...');
149+
console.log('\n\nShutting down...');
147150
processes.forEach(proc => proc.kill());
148151
process.exit(0);
149152
};
@@ -169,6 +172,8 @@ program
169172
const projectPath = path.resolve(options.path);
170173
const port = parseInt(options.port, 10);
171174

175+
console.log('\x1b[36m\x1b[1mmcp-use\x1b[0m \x1b[90mVersion: 2.0.1\x1b[0m\n');
176+
172177
// Find the built server file
173178
let serverFile = 'dist/server.js';
174179
try {
@@ -177,7 +182,7 @@ program
177182
serverFile = 'dist/index.js';
178183
}
179184

180-
console.log('🚀 Starting production server...');
185+
console.log('Starting production server...');
181186
const serverProc = spawn('node', [serverFile], {
182187
cwd: projectPath,
183188
stdio: 'inherit',
@@ -186,7 +191,7 @@ program
186191

187192
// Handle cleanup
188193
const cleanup = () => {
189-
console.log('\n\n🛑 Shutting down...');
194+
console.log('\n\nShutting down...');
190195
serverProc.kill();
191196
process.exit(0);
192197
};

0 commit comments

Comments
 (0)