mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
- Add tool-detector.ts (6 CLI tools: claude, codex, opencode, cline, kilocode, continue) - Add config-generator/ factory + 6 generators (JSON + YAML) - Add doctor/checks.ts for CLI tool health checks - Add log-streamer.ts for usage log streaming - Add @omniroute/opencode-provider npm package - Add 5 CLI commands: config, status, logs, update, provider - Add 3 API routes: config, detect, apply - Update bin/omniroute.mjs, bin/cli/index.mjs, package.json - Update docs: SETUP_GUIDE.md, CLI-TOOLS.md - All tests pass (4302/4326, 24 pre-existing failures unchanged)
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
import readline from "node:readline";
|
|
|
|
export function createPrompt() {
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout,
|
|
});
|
|
|
|
function ask(question, defaultValue = "") {
|
|
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
|
return new Promise((resolve) => {
|
|
rl.question(`${question}${suffix}: `, (answer) => {
|
|
const trimmed = answer.trim();
|
|
resolve(trimmed || defaultValue);
|
|
});
|
|
});
|
|
}
|
|
|
|
function askSecret(question) {
|
|
return new Promise((resolve) => {
|
|
let prompted = false;
|
|
const saved = rl._writeToOutput.bind(rl);
|
|
rl._writeToOutput = function (str) {
|
|
if (!prompted) {
|
|
rl.output.write(str);
|
|
if (str.endsWith(": ")) prompted = true;
|
|
return;
|
|
}
|
|
// Suppress character echo; allow only newlines through
|
|
if (str === "\r\n" || str === "\n" || str === "\r") rl.output.write("\n");
|
|
};
|
|
rl.question(`${question}: `, (answer) => {
|
|
rl._writeToOutput = saved;
|
|
resolve(answer.trim());
|
|
});
|
|
});
|
|
}
|
|
|
|
function close() {
|
|
rl.close();
|
|
}
|
|
|
|
return { ask, askSecret, close };
|
|
}
|
|
|
|
export function printHeading(title) {
|
|
console.log(`\n\x1b[1m\x1b[36m${title}\x1b[0m\n`);
|
|
}
|
|
|
|
export function printSuccess(message) {
|
|
console.log(`\x1b[32m✔ ${message}\x1b[0m`);
|
|
}
|
|
|
|
export function printInfo(message) {
|
|
console.log(`\x1b[2m${message}\x1b[0m`);
|
|
}
|
|
|
|
export function printError(message) {
|
|
console.log(`\x1b[31m✖ ${message}\x1b[0m`);
|
|
}
|