Files
devclaw-gitea/lib/tools/onboard.ts
Lauren ten Hoor d7178bb8e5 refactor: reorganize task management imports and update task handling tools
- Updated import paths for task management providers in task-comment, task-create, and task-update tools.
- Removed deprecated task-complete and task-pickup tools, replacing them with work-finish and work-start tools for improved task handling.
- Enhanced work-finish and work-start tools to streamline task completion and pickup processes, including context-aware detection and auto-scheduling features.
- Updated package.json to include build scripts and main entry point.
- Modified tsconfig.json to enable output directory, declaration files, and source maps for better TypeScript support.
2026-02-10 21:39:41 +08:00

51 lines
2.2 KiB
TypeScript

/**
* onboard — Conversational DevClaw onboarding.
*
* Returns step-by-step guidance. Call this before setup.
*/
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
import { jsonResult } from "openclaw/plugin-sdk";
import type { ToolContext } from "../types.js";
import { isPluginConfigured, hasWorkspaceFiles, buildOnboardToolContext, buildReconfigContext } from "../onboarding.js";
import { detectContext, generateGuardrails } from "../context-guard.js";
export function createOnboardTool(api: OpenClawPluginApi) {
return (ctx: ToolContext) => ({
name: "onboard",
label: "Onboard",
description: "Start DevClaw onboarding workflow. Returns step-by-step QA-style guidance. Call this first, then setup with collected answers.",
parameters: {
type: "object",
properties: {
mode: { type: "string", enum: ["first-run", "reconfigure"], description: "Auto-detected if omitted." },
},
},
async execute(_id: string, params: Record<string, unknown>) {
const devClawAgentIds = ((api.pluginConfig as Record<string, unknown>)?.devClawAgentIds as string[] | undefined) ?? [];
const context = await detectContext(ctx, devClawAgentIds);
if (context.type === "group") {
return jsonResult({
success: false, error: "Onboarding should not be done in group chats.",
recommendation: "Use a direct message instead.",
contextGuidance: generateGuardrails(context),
});
}
const configured = isPluginConfigured(api.pluginConfig as Record<string, unknown>);
const hasWorkspace = await hasWorkspaceFiles(ctx.workspaceDir);
const mode = params.mode ? (params.mode as "first-run" | "reconfigure")
: configured && hasWorkspace ? "reconfigure" : "first-run";
const instructions = mode === "first-run" ? buildOnboardToolContext() : buildReconfigContext(api.pluginConfig as Record<string, unknown>);
return jsonResult({
success: true, mode, configured, instructions,
contextGuidance: generateGuardrails(context),
nextSteps: ["Follow instructions above", "Call setup with collected answers", mode === "first-run" ? "Register a project afterward" : null].filter(Boolean),
});
},
});
}