refactor: update task creation to use dynamic initial label from workflow config
This commit is contained in:
@@ -17,16 +17,19 @@ import type { StateLabel } from "../providers/provider.js";
|
||||
import { DEFAULT_WORKFLOW, getStateLabels } from "../workflow.js";
|
||||
import { requireWorkspaceDir, resolveProject, resolveProvider } from "../tool-helpers.js";
|
||||
|
||||
/** Derive the initial state label from the workflow config. */
|
||||
const INITIAL_LABEL = DEFAULT_WORKFLOW.states[DEFAULT_WORKFLOW.initial].label;
|
||||
|
||||
export function createTaskCreateTool(api: OpenClawPluginApi) {
|
||||
return (ctx: ToolContext) => ({
|
||||
name: "task_create",
|
||||
label: "Task Create",
|
||||
description: `Create a new task (issue) in the project's issue tracker. Use this to file bugs, features, or tasks from chat.
|
||||
|
||||
**IMPORTANT:** Always creates in "Planning" unless the user explicitly asks to start work immediately. Never set label to "To Do" on your own — "Planning" issues require human review before entering the queue.
|
||||
**IMPORTANT:** Always creates in "${INITIAL_LABEL}" unless the user explicitly asks to start work immediately. Never set label to "To Do" on your own — "${INITIAL_LABEL}" issues require human review before entering the queue.
|
||||
|
||||
Examples:
|
||||
- Default: { title: "Fix login bug" } → created in Planning
|
||||
- Default: { title: "Fix login bug" } → created in ${INITIAL_LABEL}
|
||||
- User says "create and start working": { title: "Implement auth", description: "...", label: "To Do" }`,
|
||||
parameters: {
|
||||
type: "object",
|
||||
@@ -46,7 +49,7 @@ Examples:
|
||||
},
|
||||
label: {
|
||||
type: "string",
|
||||
description: `State label. Defaults to "Planning" — only use "To Do" when the user explicitly asks to start work immediately.`,
|
||||
description: `State label. Defaults to "${INITIAL_LABEL}" — only use "To Do" when the user explicitly asks to start work immediately.`,
|
||||
enum: getStateLabels(DEFAULT_WORKFLOW),
|
||||
},
|
||||
assignees: {
|
||||
@@ -65,7 +68,7 @@ Examples:
|
||||
const groupId = params.projectGroupId as string;
|
||||
const title = params.title as string;
|
||||
const description = (params.description as string) ?? "";
|
||||
const label = (params.label as StateLabel) ?? "Planning";
|
||||
const label = (params.label as StateLabel) ?? INITIAL_LABEL;
|
||||
const assignees = (params.assignees as string[] | undefined) ?? [];
|
||||
const pickup = (params.pickup as boolean) ?? false;
|
||||
const workspaceDir = requireWorkspaceDir(ctx);
|
||||
|
||||
Reference in New Issue
Block a user