- Moved setup logic into dedicated files: agent.ts, config.ts, index.ts, workspace.ts. - Introduced tool-helpers.ts for shared functions across tools, reducing boilerplate. - Updated tools (status, task-comment, task-create, task-update, work-finish, work-start) to utilize new helper functions for workspace resolution and provider creation. - Enhanced error handling and context detection in tools. - Improved project resolution logic to streamline tool execution. - Added new functionality for agent creation and configuration management in setup.
69 lines
2.4 KiB
TypeScript
69 lines
2.4 KiB
TypeScript
/**
|
|
* cli.ts — CLI registration for `openclaw devclaw setup`.
|
|
*
|
|
* Uses Commander.js (provided by OpenClaw plugin SDK context).
|
|
*/
|
|
import type { Command } from "commander";
|
|
import { runSetup } from "./setup/index.js";
|
|
import { ALL_TIERS, DEFAULT_MODELS, type Tier } from "./tiers.js";
|
|
|
|
/**
|
|
* Register the `devclaw` CLI command group on a Commander program.
|
|
*/
|
|
export function registerCli(program: Command): void {
|
|
const devclaw = program
|
|
.command("devclaw")
|
|
.description("DevClaw development pipeline tools");
|
|
|
|
devclaw
|
|
.command("setup")
|
|
.description("Set up DevClaw: create agent, configure models, write workspace files")
|
|
.option("--new-agent <name>", "Create a new agent with this name")
|
|
.option("--agent <id>", "Use an existing agent by ID")
|
|
.option("--workspace <path>", "Direct workspace path")
|
|
.option("--junior <model>", `Junior dev model (default: ${DEFAULT_MODELS.junior})`)
|
|
.option("--medior <model>", `Medior dev model (default: ${DEFAULT_MODELS.medior})`)
|
|
.option("--senior <model>", `Senior dev model (default: ${DEFAULT_MODELS.senior})`)
|
|
.option("--qa <model>", `QA engineer model (default: ${DEFAULT_MODELS.qa})`)
|
|
.action(async (opts) => {
|
|
const models: Partial<Record<Tier, string>> = {};
|
|
if (opts.junior) models.junior = opts.junior;
|
|
if (opts.medior) models.medior = opts.medior;
|
|
if (opts.senior) models.senior = opts.senior;
|
|
if (opts.qa) models.qa = opts.qa;
|
|
|
|
const result = await runSetup({
|
|
newAgentName: opts.newAgent,
|
|
agentId: opts.agent,
|
|
workspacePath: opts.workspace,
|
|
models: Object.keys(models).length > 0 ? models : undefined,
|
|
});
|
|
|
|
if (result.agentCreated) {
|
|
console.log(`Agent "${result.agentId}" created`);
|
|
}
|
|
|
|
console.log("Models configured:");
|
|
for (const tier of ALL_TIERS) {
|
|
console.log(` ${tier}: ${result.models[tier]}`);
|
|
}
|
|
|
|
console.log("Files written:");
|
|
for (const file of result.filesWritten) {
|
|
console.log(` ${file}`);
|
|
}
|
|
|
|
if (result.warnings.length > 0) {
|
|
console.log("\nWarnings:");
|
|
for (const w of result.warnings) {
|
|
console.log(` ${w}`);
|
|
}
|
|
}
|
|
|
|
console.log("\nDone! Next steps:");
|
|
console.log(" 1. Add bot to a Telegram group");
|
|
console.log(' 2. Register a project: "Register project <name> at <repo> for group <id>"');
|
|
console.log(" 3. Create your first issue and pick it up");
|
|
});
|
|
}
|