feat(migration): implement workspace layout migration and testing
- Added `migrate-layout.ts` to handle migration from old workspace layouts to the new `devclaw/` structure. - Introduced `migrate-layout.test.ts` for comprehensive tests covering various migration scenarios. - Updated `workspace.ts` to ensure default files are created post-migration, including `workflow.yaml` and role-specific prompts. - Refactored role instruction handling to accommodate new directory structure. - Enhanced project registration to scaffold prompt files in the new `devclaw/projects/<project>/prompts/` directory. - Adjusted setup tool descriptions and logic to reflect changes in file structure. - Updated templates to align with the new workflow configuration and role instructions.
This commit is contained in:
@@ -15,6 +15,7 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { readProjects } from "../projects.js";
|
||||
import { log as auditLog } from "../audit.js";
|
||||
import { DATA_DIR } from "../setup/migrate-layout.js";
|
||||
import { checkWorkerHealth, scanOrphanedLabels, fetchGatewaySessions, type SessionLookup } from "./health.js";
|
||||
import { projectTick } from "./tick.js";
|
||||
import { createProvider } from "../providers/index.js";
|
||||
@@ -115,7 +116,7 @@ export function registerHeartbeatService(api: OpenClawPluginApi) {
|
||||
|
||||
/**
|
||||
* Discover DevClaw agents by scanning which agent workspaces have projects.
|
||||
* Self-discovering: any agent whose workspace contains projects/projects.json is processed.
|
||||
* Self-discovering: any agent whose workspace contains projects.json is processed.
|
||||
* Also checks the default workspace (agents.defaults.workspace) for projects.
|
||||
*/
|
||||
function discoverAgents(config: {
|
||||
@@ -131,7 +132,7 @@ function discoverAgents(config: {
|
||||
for (const a of config.agents?.list || []) {
|
||||
if (!a.workspace) continue;
|
||||
try {
|
||||
if (fs.existsSync(path.join(a.workspace, "projects", "projects.json"))) {
|
||||
if (hasProjects(a.workspace)) {
|
||||
agents.push({ agentId: a.id, workspace: a.workspace });
|
||||
seen.add(a.workspace);
|
||||
}
|
||||
@@ -142,7 +143,7 @@ function discoverAgents(config: {
|
||||
const defaultWorkspace = config.agents?.defaults?.workspace;
|
||||
if (defaultWorkspace && !seen.has(defaultWorkspace)) {
|
||||
try {
|
||||
if (fs.existsSync(path.join(defaultWorkspace, "projects", "projects.json"))) {
|
||||
if (hasProjects(defaultWorkspace)) {
|
||||
agents.push({ agentId: "main", workspace: defaultWorkspace });
|
||||
}
|
||||
} catch { /* skip */ }
|
||||
@@ -151,6 +152,15 @@ function discoverAgents(config: {
|
||||
return agents;
|
||||
}
|
||||
|
||||
/** Check if a workspace has a projects.json (new or old locations). */
|
||||
function hasProjects(workspace: string): boolean {
|
||||
return (
|
||||
fs.existsSync(path.join(workspace, DATA_DIR, "projects.json")) ||
|
||||
fs.existsSync(path.join(workspace, "projects.json")) ||
|
||||
fs.existsSync(path.join(workspace, "projects", "projects.json"))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run one heartbeat tick for all agents.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user