|
1 | 1 | --- |
2 | 2 | name: manager-worker-dispatch |
3 | | -description: Use this skill to manage and dispatch tasks to workers. Triggers include: any request to break a task into subtasks and assign them to workers or bots; listing, creating, or selecting workers via the manager_worker_api; sending @-mention messages to workers inside a room; coordinating sequential or parallel multi-worker execution pipelines; dispatching frontend, backend, or QA work to the right worker by capability. Do NOT use for generic project planning, single-agent tasks. |
| 3 | +description: Use this skill to break an admin request into capability-aligned subtasks, provision or reuse workers through manager_worker_api, write the dispatch plan to todo.json, and start sequential task tracking. Do NOT use for generic planning or single-agent execution. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Manager Worker Dispatch |
7 | 7 |
|
8 | | -Interpret the admin request, break it into capability-aligned subtasks, and dispatch each subtask through the real CSGClaw API. |
| 8 | +Break an admin request into clear tasks, choose workers by capability, and dispatch them through the real CSGClaw API in sequence. |
9 | 9 |
|
10 | | -Use the bundled script for deterministic API calls instead of rewriting request code inline. |
| 10 | +Reuse the bundled script instead of writing ad hoc requests. |
| 11 | +Check the script help for the current CLI surface instead of reading reference docs. |
11 | 12 |
|
12 | 13 | ## Workflow |
13 | 14 |
|
14 | | -1. Read the admin request and split it into concrete deliverables. |
15 | | -2. Infer the required capability for each deliverable. |
16 | | -3. List existing workers with `scripts/manager_worker_api.py list-workers`. |
17 | | -4. Reuse an existing worker when its `description` matches the needed capability and scope. |
18 | | -5. Create a worker when no existing worker description clearly matches. |
19 | | -6. Add the worker to the target room when needed. |
20 | | -7. Dispatch the subtask by having a bot send a message in that room, and make sure every manager-to-worker message starts with an `@` prefix, for example `@bob 你来写前端代码`. |
21 | | -8. If the request is sequential, wait for the previous worker to finish before dispatching the next worker with another `@` message. |
22 | | -9. If the request is parallel, dispatch multiple workers at the same time with separate `@` messages. |
23 | | - |
24 | | -Keep assignments specific. Include the expected output, scope, and capability. |
| 15 | +1. Break the admin request into concrete deliverables. |
| 16 | +2. Match each task to the needed capability; run `list-workers` first, reuse by matching `description`, and create a worker only when needed. |
| 17 | +3. Ensure the required workers have joined the target room. |
| 18 | +4. Choose a suitable project directory under `~/.picoclaw/workspace/projects`; create a short slug directory if none fits. |
| 19 | +5. Write or overwrite `todo.json` in that directory as the only source of truth for the current dispatch plan. |
| 20 | +6. Start `scripts/manager_worker_api.py start-tracking` against that `todo.json`. |
| 21 | + |
| 22 | +## todo.json |
| 23 | + |
| 24 | +`todo.json` must be valid JSON. |
| 25 | + |
| 26 | +- Single task: write one task object. |
| 27 | +- Multiple tasks: write `{ "tasks": [...] }`; array order is dispatch order. |
| 28 | + |
| 29 | +Each task should keep these fields: |
| 30 | + |
| 31 | +- `id`: task number, required, use `1`, `2`, `3` in dispatch order |
| 32 | +- `assignee`: owner, usually a worker name or role-like label |
| 33 | +- `category`: short task type such as `feature`, `bug`, or `test` |
| 34 | +- `description`: task summary |
| 35 | +- `steps`: array of execution steps |
| 36 | +- `passes`: completion state, usually `false` at the start |
| 37 | +- `progress_note`: progress, result, or blocker note, usually an empty string at the start |
| 38 | + |
| 39 | +`id` must always be present and should increase sequentially with the task order in `todo.json`. |
| 40 | + |
| 41 | +Example: |
| 42 | + |
| 43 | +```json |
| 44 | +{ |
| 45 | + "tasks": [ |
| 46 | + { |
| 47 | + "id": 1, |
| 48 | + "assignee": "frontend", |
| 49 | + "category": "feature", |
| 50 | + "description": "Build the settings page UI and connect the save action.", |
| 51 | + "steps": [ |
| 52 | + "Implement the settings page layout", |
| 53 | + "Connect the save action to the API", |
| 54 | + "Reply to the manager with the implementation summary" |
| 55 | + ], |
| 56 | + "passes": false, |
| 57 | + "progress_note": "" |
| 58 | + }, |
| 59 | + { |
| 60 | + "id": 2, |
| 61 | + "assignee": "qa", |
| 62 | + "category": "test", |
| 63 | + "description": "Validate the main settings page flows after frontend delivery.", |
| 64 | + "steps": [ |
| 65 | + "Verify the main edit and save flows", |
| 66 | + "Record regressions and blockers", |
| 67 | + "Reply to the manager with QA results" |
| 68 | + ], |
| 69 | + "passes": false, |
| 70 | + "progress_note": "" |
| 71 | + } |
| 72 | + ] |
| 73 | +} |
| 74 | +``` |
25 | 75 |
|
26 | 76 | ## Capability Mapping |
27 | 77 |
|
28 | | -Map work to worker descriptions before calling the API. Do not select a worker by its `role` field. Read each worker's `description` and choose the one whose described responsibility best matches the task. |
| 78 | +Choose workers by `description`, not just by `role`. |
29 | 79 |
|
30 | | -- Frontend UI, page work, styling, interaction: `frontend` |
31 | | -- APIs, services, storage, data flow: `backend` |
32 | | -- Validation, regression checks, acceptance checks: `qa` |
33 | | -- Cross-cutting coordination or unclear requests: split the task first, then assign |
| 80 | +- `frontend`: UI, page work, styling, interaction |
| 81 | +- `backend`: APIs, services, storage, data flow |
| 82 | +- `qa`: validation, regression, acceptance checks |
34 | 83 |
|
35 | | -If the admin request implies several capabilities, create one assignment per capability instead of sending one broad task to a single worker. |
| 84 | +Split cross-capability work into multiple tasks instead of giving one vague package to a single worker. |
36 | 85 |
|
37 | 86 | ## Script Usage |
38 | 87 |
|
39 | | -Use `scripts/manager_worker_api.py` for API operations. |
40 | | - |
41 | | -Common commands: |
42 | | - |
43 | 88 | ```bash |
44 | 89 | cd ~/.picoclaw/workspace/skills/manager-worker-dispatch |
45 | 90 | python scripts/manager_worker_api.py list-workers |
46 | 91 | python scripts/manager_worker_api.py create-worker --name alex --description "qa regression testing" |
47 | 92 | python scripts/manager_worker_api.py join-worker --room-id room-123 --worker-id u-alex |
48 | | -python scripts/manager_worker_api.py send-message --room-id room-123 --text "@alex 你来进行测试,验证登录流程并记录回归风险" |
49 | | -python scripts/manager_worker_api.py ensure-and-dispatch --room-id room-123 --name bob --description "frontend ui styling interaction" --task "你来写前端代码,实现设置页 UI" --dry-run |
| 93 | +python scripts/manager_worker_api.py start-tracking --room-id room-123 --todo-path ~/.picoclaw/workspace/projects/demo/todo.json |
| 94 | +python scripts/manager_worker_api.py stop-tracking --todo-path ~/.picoclaw/workspace/projects/demo/todo.json |
50 | 95 | ``` |
51 | | - |
52 | | -Read `references/api-contract.md` before changing endpoint names, payload fields, or environment variables. |
53 | | - |
54 | | -When the script runs inside a CSGClaw box, it reads these environment variables automatically: |
55 | | - |
56 | | -- `CSGCLAW_BASE_URL` |
57 | | -- `CSGCLAW_ACCESS_TOKEN` |
| 96 | +Use `python scripts/manager_worker_api.py -h` to inspect the latest commands, flags, and environment variable fallbacks before invoking or updating the workflow. |
58 | 97 |
|
59 | 98 | ## Operating Rules |
60 | 99 |
|
61 | | -- Prefer an existing worker whose `description` matches the task before creating a new one. |
62 | | -- Keep worker names short and stable. |
63 | | -- Add the worker to the room before dispatching the task when the room does not already include that worker. |
64 | | -- When the manager assigns work, always prefix the worker mention with `@`, and tell the worker to reply with `@` as well. |
65 | | -- For sequential work, do not dispatch the next worker until the previous worker has completed. |
66 | | -- For parallel work, multiple workers may be dispatched together with separate `@` messages. |
67 | | -- Use `--dry-run` first when endpoint compatibility is uncertain. |
68 | | -- If the API response shape differs from the documented assumptions, patch the script instead of improvising ad hoc requests. |
| 100 | +- Reuse workers before creating new ones. |
| 101 | +- Keep `todo.json` aligned with the actual assignment being dispatched. |
| 102 | +- Do not casually reorder tasks in the sequential flow. |
| 103 | +- Let `start-tracking` drive dispatch from `todo.json`; do not duplicate that logic in manual room-message procedures. |
| 104 | +- If the API response shape differs from expectations, patch the script instead of improvising around it. |
0 commit comments