- Removed the deprecated tiers.ts file and migrated all related functionality to roles/index.js. - Updated tests and tools to reflect the new role structure, replacing references to "dev", "qa", and "architect" with "developer", "tester", and "architect". - Adjusted workflow configurations and state management to accommodate the new role naming conventions. - Enhanced project registration and health check tools to support dynamic role handling. - Updated task creation, update, and completion processes to align with the new role definitions. - Improved documentation and comments to clarify role responsibilities and usage.
85 lines
3.1 KiB
TypeScript
85 lines
3.1 KiB
TypeScript
/**
|
|
* cli.ts — CLI registration for `openclaw devclaw setup` and `openclaw devclaw heartbeat`.
|
|
*
|
|
* Uses Commander.js (provided by OpenClaw plugin SDK context).
|
|
*/
|
|
import type { Command } from "commander";
|
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
import { runSetup } from "./setup/index.js";
|
|
import { getAllDefaultModels, getAllRoleIds, getLevelsForRole } from "./roles/index.js";
|
|
|
|
/**
|
|
* Register the `devclaw` CLI command group on a Commander program.
|
|
*/
|
|
export function registerCli(program: Command, api: OpenClawPluginApi): void {
|
|
const devclaw = program
|
|
.command("devclaw")
|
|
.description("DevClaw development pipeline tools");
|
|
|
|
const setupCmd = 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");
|
|
|
|
// Register dynamic --<role>-<level> options from registry
|
|
const defaults = getAllDefaultModels();
|
|
for (const role of getAllRoleIds()) {
|
|
for (const level of getLevelsForRole(role)) {
|
|
const flag = `--${role}-${level}`;
|
|
setupCmd.option(`${flag} <model>`, `${role.toUpperCase()} ${level} model (default: ${defaults[role]?.[level] ?? "auto"})`);
|
|
}
|
|
}
|
|
|
|
setupCmd.action(async (opts) => {
|
|
// Build model overrides from CLI flags dynamically
|
|
const models: Record<string, Record<string, string>> = {};
|
|
for (const role of getAllRoleIds()) {
|
|
const roleModels: Record<string, string> = {};
|
|
for (const level of getLevelsForRole(role)) {
|
|
// camelCase key: "testerJunior" for --tester-junior, "developerMedior" for --developer-medior
|
|
const key = `${role}${level.charAt(0).toUpperCase()}${level.slice(1)}`;
|
|
if (opts[key]) roleModels[level] = opts[key];
|
|
}
|
|
if (Object.keys(roleModels).length > 0) models[role] = roleModels;
|
|
}
|
|
|
|
const result = await runSetup({
|
|
api,
|
|
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 [role, levels] of Object.entries(result.models)) {
|
|
for (const [level, model] of Object.entries(levels)) {
|
|
console.log(` ${role}.${level}: ${model}`);
|
|
}
|
|
}
|
|
|
|
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");
|
|
});
|
|
}
|