#!/usr/bin/env node
/**
* AskMe Debug Tools CLI
*
* Command-line interface for running debug simulations of MCP tools.
* Provides fast UI development workflow without requiring MCP client.
*/
import { runDebugAskOneQuestion } from './debug-ask-one-question.js';
import { runDebugAskMultipleChoice } from './debug-ask-multiple-choice.js';
import { runDebugChallengeHypothesis } from './debug-challenge-hypothesis.js';
import { runDebugChooseNext } from './debug-choose-next.js';
const TOOLS = {
'ask-one-question': {
name: 'Ask One Question',
description: 'Simulate free-form question with human response',
runner: runDebugAskOneQuestion
},
'ask-multiple-choice': {
name: 'Ask Multiple Choice',
description: 'Simulate multiple choice questions with priority ratings',
runner: runDebugAskMultipleChoice
},
'challenge-hypothesis': {
name: 'Challenge Hypothesis',
description: 'Simulate hypothesis evaluation with agreement levels',
runner: runDebugChallengeHypothesis
},
'choose-next': {
name: 'Choose Next',
description: 'Simulate decision workflow with option selection',
runner: runDebugChooseNext
}
};
function showUsage(): void {
console.error(`
AskMe Debug Tools - MCP Tool Simulation for UI Development
Usage:
npx nx serve askme-debug-tools [tool-name]
node dist/askme-debug-tools/main.js [tool-name]
Available Tools:
${Object.entries(TOOLS).map(([key, tool]) =>
` ${key.padEnd(20)} - ${tool.description}`
).join('\n')}
Examples:
npx nx serve askme-debug-tools ask-one-question
npx nx serve askme-debug-tools ask-multiple-choice
npx nx serve askme-debug-tools challenge-hypothesis
npx nx serve askme-debug-tools choose-next
Each tool will:
1. Start a mock server on port 3000
2. Send realistic test data
3. Wait for UI response (or use mock after timeout)
4. Output formatted LLM result to stdout
5. Exit cleanly
Open http://localhost:3000 in your browser to interact with the UI.
`);
}
async function main(): Promise<void> {
const args = process.argv.slice(2);
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
showUsage();
return;
}
const toolName = args[0];
if (!TOOLS[toolName as keyof typeof TOOLS]) {
console.error(`Error: Unknown tool "${toolName}"`);
console.error('');
showUsage();
process.exit(1);
}
const tool = TOOLS[toolName as keyof typeof TOOLS];
console.error(`Starting debug session for: ${tool.name}`);
console.error(`Description: ${tool.description}`);
console.error('');
try {
await tool.runner();
} catch (error) {
console.error(`Fatal error in ${toolName}:`, error);
process.exit(1);
}
}
// Run if called directly
if (require.main === module) {
main().catch(error => {
console.error('Unexpected error:', error);
process.exit(1);
});
}
export { main, TOOLS };