refactor: implement dynamic role and level handling with migration support

This commit is contained in:
Lauren ten Hoor
2026-02-15 18:46:00 +08:00
parent 0e24a68882
commit a85f4fd33e
10 changed files with 278 additions and 227 deletions

View File

@@ -15,6 +15,28 @@ import { registerCli } from "./lib/cli.js";
import { registerHeartbeatService } from "./lib/services/heartbeat.js";
import { registerBootstrapHook } from "./lib/bootstrap-hook.js";
import { initRunCommand } from "./lib/run-command.js";
import { ROLE_REGISTRY } from "./lib/roles/index.js";
/** Build the models config schema dynamically from the role registry. */
function buildModelsSchema(): Record<string, unknown> {
const properties: Record<string, unknown> = {};
for (const [roleId, config] of Object.entries(ROLE_REGISTRY)) {
const levelProps: Record<string, unknown> = {};
for (const level of config.levels) {
levelProps[level] = { type: "string" };
}
properties[roleId] = {
type: "object",
description: `${config.displayName} level models`,
properties: levelProps,
};
}
return {
type: "object",
description: "Model mapping per role and level",
properties,
};
}
const plugin = {
id: "devclaw",
@@ -24,38 +46,7 @@ const plugin = {
configSchema: {
type: "object",
properties: {
models: {
type: "object",
description: "Model mapping per role and level",
properties: {
dev: {
type: "object",
description: "Developer level models",
properties: {
junior: { type: "string" },
mid: { type: "string" },
senior: { type: "string" },
},
},
qa: {
type: "object",
description: "QA level models",
properties: {
junior: { type: "string" },
mid: { type: "string" },
senior: { type: "string" },
},
},
architect: {
type: "object",
description: "Architect level models",
properties: {
junior: { type: "string" },
senior: { type: "string" },
},
},
},
},
models: buildModelsSchema(),
projectExecution: {
type: "string",
enum: ["parallel", "sequential"],