rowboat/apps/cli/bin/app.js

127 lines
4 KiB
JavaScript
Raw Normal View History

2025-11-05 13:28:38 +05:30
#!/usr/bin/env node
2025-11-15 01:51:22 +05:30
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
2025-11-21 10:32:24 +05:30
import { app, modelConfig, updateState, importExample, listExamples } from '../dist/app.js';
2025-11-05 13:28:38 +05:30
2025-11-15 01:51:22 +05:30
yargs(hideBin(process.argv))
2025-11-18 20:38:14 +05:30
2025-11-15 01:51:22 +05:30
.command(
"$0",
"Run rowboatx",
(y) => y
2025-11-18 20:38:14 +05:30
.option("agent", {
type: "string",
2025-11-21 11:43:59 +05:30
description: "The agent to run",
default: "copilot",
2025-11-18 20:38:14 +05:30
})
.option("run_id", {
type: "string",
description: "Continue an existing run",
})
.option("input", {
type: "string",
description: "The input to the agent",
})
.option("no-interactive", {
type: "boolean",
description: "Do not interact with the user",
default: false,
}),
2025-11-21 11:43:59 +05:30
(argv) => {
app({
agent: argv.agent,
2025-11-15 01:51:22 +05:30
runId: argv.run_id,
input: argv.input,
2025-11-16 20:58:31 +05:30
noInteractive: argv.noInteractive,
2025-11-15 01:51:22 +05:30
});
}
)
2025-11-21 10:32:24 +05:30
.command(
"sync-example <example>",
"Import an example workflow by name",
(y) => y.positional("example", {
type: "string",
description: "The example to import",
}),
async (argv) => {
const exampleName = String(argv.example).trim();
try {
const imported = await importExample(exampleName);
2025-11-21 11:43:59 +05:30
2025-11-21 10:32:24 +05:30
// Build output message
const output = [
`✓ Imported example '${exampleName}'`,
` Agents: ${imported.importedAgents.join(", ")}`,
` Primary: ${imported.entryAgent}`,
];
2025-11-21 11:43:59 +05:30
2025-11-21 10:32:24 +05:30
if (imported.addedServers.length > 0) {
output.push(` MCP servers added: ${imported.addedServers.join(", ")}`);
}
if (imported.skippedServers.length > 0) {
output.push(` MCP servers skipped (already configured): ${imported.skippedServers.join(", ")}`);
}
2025-11-21 11:43:59 +05:30
2025-11-21 10:32:24 +05:30
console.log(output.join("\n"));
2025-11-21 11:43:59 +05:30
2025-11-21 10:32:24 +05:30
if (imported.postInstallInstructions) {
console.log("\n" + "=".repeat(60));
console.log("POST-INSTALL INSTRUCTIONS");
console.log("=".repeat(60));
console.log(imported.postInstallInstructions);
console.log("=".repeat(60) + "\n");
}
2025-11-21 11:43:59 +05:30
2025-11-21 10:32:24 +05:30
console.log(`\nRun: rowboatx --agent ${imported.entryAgent}`);
} catch (error) {
console.error("Error:", error?.message ?? error);
process.exit(1);
}
}
)
.command(
"list-example",
"List all available example workflows",
(y) => y,
async () => {
try {
const examples = await listExamples();
if (examples.length === 0) {
console.error("No packaged examples are available to list.");
return;
}
for (const example of examples) {
console.log(example);
}
} catch (error) {
console.error(error?.message ?? error);
process.exit(1);
}
}
)
2025-11-20 16:41:41 +05:30
.command(
"model-config",
"Select model",
(y) => y,
(argv) => {
modelConfig();
}
)
2025-11-18 20:38:14 +05:30
.command(
"update-state <agent> <run_id>",
"Update state for a run",
(y) => y
.positional("agent", {
type: "string",
description: "The agent to run",
})
.positional("run_id", {
type: "string",
description: "The run id to update",
}),
(argv) => {
updateState(argv.agent, argv.run_id);
}
)
.parse();