-
Notifications
You must be signed in to change notification settings - Fork 13
Labels
Description
Description:
Summary
Currently, the runCliCommand function in src/util.ts executes commands without ensuring that the output format is JSON. This could lead to inconsistent output formats that are harder to parse.
Current Behavior
The runCliCommand function executes commands as-is:
const subprocess = spawn(command, {
shell: true,
timeout: 120000,
});Proposed Enhancement
Modify runCliCommand to automatically append --output json to commands if it's not already present. This would ensure:
- Consistent JSON output for easier parsing
- Better error handling and response processing
- More reliable integration with MCP server responses
Example Implementation
export async function runCliCommand(command: string): Promise<string> {
// Ensure --output json is always present
if (!command.includes('--output')) {
command = `${command} --output json`;
}
return new Promise((resolve, reject) => {
const subprocess = spawn(command, {
shell: true,
timeout: 120000,
});
// ... rest of implementation
});
}Benefits
- Guarantees parseable JSON responses
- Reduces potential errors from text parsing
Copilot