@cleocode/skills 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dispatch-config.json +404 -0
- package/index.d.ts +178 -0
- package/index.js +405 -0
- package/package.json +14 -0
- package/profiles/core.json +7 -0
- package/profiles/full.json +10 -0
- package/profiles/minimal.json +7 -0
- package/profiles/recommended.json +7 -0
- package/provider-skills-map.json +97 -0
- package/skills/_shared/cleo-style-guide.md +84 -0
- package/skills/_shared/manifest-operations.md +810 -0
- package/skills/_shared/placeholders.json +433 -0
- package/skills/_shared/skill-chaining-patterns.md +237 -0
- package/skills/_shared/subagent-protocol-base.md +223 -0
- package/skills/_shared/task-system-integration.md +232 -0
- package/skills/_shared/testing-framework-config.md +110 -0
- package/skills/ct-cleo/SKILL.md +490 -0
- package/skills/ct-cleo/references/anti-patterns.md +19 -0
- package/skills/ct-cleo/references/loom-lifecycle.md +136 -0
- package/skills/ct-cleo/references/orchestrator-constraints.md +55 -0
- package/skills/ct-cleo/references/session-protocol.md +162 -0
- package/skills/ct-codebase-mapper/SKILL.md +82 -0
- package/skills/ct-contribution/SKILL.md +521 -0
- package/skills/ct-contribution/templates/contribution-init.json +21 -0
- package/skills/ct-dev-workflow/SKILL.md +423 -0
- package/skills/ct-docs-lookup/SKILL.md +66 -0
- package/skills/ct-docs-review/SKILL.md +175 -0
- package/skills/ct-docs-write/SKILL.md +108 -0
- package/skills/ct-documentor/SKILL.md +231 -0
- package/skills/ct-epic-architect/SKILL.md +305 -0
- package/skills/ct-epic-architect/references/bug-epic-example.md +172 -0
- package/skills/ct-epic-architect/references/commands.md +201 -0
- package/skills/ct-epic-architect/references/feature-epic-example.md +210 -0
- package/skills/ct-epic-architect/references/migration-epic-example.md +244 -0
- package/skills/ct-epic-architect/references/output-format.md +92 -0
- package/skills/ct-epic-architect/references/patterns.md +284 -0
- package/skills/ct-epic-architect/references/refactor-epic-example.md +412 -0
- package/skills/ct-epic-architect/references/research-epic-example.md +226 -0
- package/skills/ct-epic-architect/references/shell-escaping.md +86 -0
- package/skills/ct-epic-architect/references/skill-aware-execution.md +195 -0
- package/skills/ct-grade/SKILL.md +230 -0
- package/skills/ct-grade/agents/analysis-reporter.md +203 -0
- package/skills/ct-grade/agents/blind-comparator.md +157 -0
- package/skills/ct-grade/agents/scenario-runner.md +134 -0
- package/skills/ct-grade/eval-viewer/__pycache__/generate_grade_review.cpython-314.pyc +0 -0
- package/skills/ct-grade/eval-viewer/generate_grade_review.py +1138 -0
- package/skills/ct-grade/eval-viewer/generate_grade_viewer.py +544 -0
- package/skills/ct-grade/eval-viewer/generate_review.py +283 -0
- package/skills/ct-grade/eval-viewer/grade-review.html +1574 -0
- package/skills/ct-grade/eval-viewer/viewer.html +219 -0
- package/skills/ct-grade/evals/evals.json +94 -0
- package/skills/ct-grade/references/ab-test-methodology.md +150 -0
- package/skills/ct-grade/references/domains.md +137 -0
- package/skills/ct-grade/references/grade-spec.md +236 -0
- package/skills/ct-grade/references/scenario-playbook.md +234 -0
- package/skills/ct-grade/references/token-tracking.md +120 -0
- package/skills/ct-grade/scripts/__pycache__/audit_analyzer.cpython-314.pyc +0 -0
- package/skills/ct-grade/scripts/__pycache__/run_ab_test.cpython-314.pyc +0 -0
- package/skills/ct-grade/scripts/__pycache__/run_all.cpython-314.pyc +0 -0
- package/skills/ct-grade/scripts/__pycache__/token_tracker.cpython-314.pyc +0 -0
- package/skills/ct-grade/scripts/audit_analyzer.py +279 -0
- package/skills/ct-grade/scripts/generate_report.py +283 -0
- package/skills/ct-grade/scripts/run_ab_test.py +504 -0
- package/skills/ct-grade/scripts/run_all.py +287 -0
- package/skills/ct-grade/scripts/setup_run.py +183 -0
- package/skills/ct-grade/scripts/token_tracker.py +630 -0
- package/skills/ct-grade-v2-1/SKILL.md +237 -0
- package/skills/ct-grade-v2-1/agents/analysis-reporter.md +203 -0
- package/skills/ct-grade-v2-1/agents/blind-comparator.md +157 -0
- package/skills/ct-grade-v2-1/agents/scenario-runner.md +179 -0
- package/skills/ct-grade-v2-1/evals/evals.json +74 -0
- package/skills/ct-grade-v2-1/grade-viewer/__pycache__/build_op_stats.cpython-314.pyc +0 -0
- package/skills/ct-grade-v2-1/grade-viewer/__pycache__/generate_grade_review.cpython-314.pyc +0 -0
- package/skills/ct-grade-v2-1/grade-viewer/build_op_stats.py +174 -0
- package/skills/ct-grade-v2-1/grade-viewer/eval-analysis.json +41 -0
- package/skills/ct-grade-v2-1/grade-viewer/eval-report.md +34 -0
- package/skills/ct-grade-v2-1/grade-viewer/generate_grade_review.py +1023 -0
- package/skills/ct-grade-v2-1/grade-viewer/generate_grade_viewer.py +548 -0
- package/skills/ct-grade-v2-1/grade-viewer/grade-review-eval.html +613 -0
- package/skills/ct-grade-v2-1/grade-viewer/grade-review.html +1532 -0
- package/skills/ct-grade-v2-1/grade-viewer/viewer.html +620 -0
- package/skills/ct-grade-v2-1/manifest-entry.json +31 -0
- package/skills/ct-grade-v2-1/references/ab-testing.md +233 -0
- package/skills/ct-grade-v2-1/references/domains-ssot.md +156 -0
- package/skills/ct-grade-v2-1/references/grade-spec-v2.md +167 -0
- package/skills/ct-grade-v2-1/references/playbook-v2.md +393 -0
- package/skills/ct-grade-v2-1/references/token-tracking.md +202 -0
- package/skills/ct-grade-v2-1/scripts/generate_report.py +419 -0
- package/skills/ct-grade-v2-1/scripts/run_ab_test.py +493 -0
- package/skills/ct-grade-v2-1/scripts/run_scenario.py +396 -0
- package/skills/ct-grade-v2-1/scripts/setup_run.py +207 -0
- package/skills/ct-grade-v2-1/scripts/token_tracker.py +175 -0
- package/skills/ct-memory/SKILL.md +84 -0
- package/skills/ct-orchestrator/INSTALL.md +61 -0
- package/skills/ct-orchestrator/README.md +69 -0
- package/skills/ct-orchestrator/SKILL.md +380 -0
- package/skills/ct-orchestrator/manifest-entry.json +19 -0
- package/skills/ct-orchestrator/orchestrator-prompt.txt +17 -0
- package/skills/ct-orchestrator/references/SUBAGENT-PROTOCOL-BLOCK.md +66 -0
- package/skills/ct-orchestrator/references/autonomous-operation.md +167 -0
- package/skills/ct-orchestrator/references/lifecycle-gates.md +98 -0
- package/skills/ct-orchestrator/references/orchestrator-compliance.md +271 -0
- package/skills/ct-orchestrator/references/orchestrator-handoffs.md +85 -0
- package/skills/ct-orchestrator/references/orchestrator-patterns.md +164 -0
- package/skills/ct-orchestrator/references/orchestrator-recovery.md +113 -0
- package/skills/ct-orchestrator/references/orchestrator-spawning.md +271 -0
- package/skills/ct-orchestrator/references/orchestrator-tokens.md +180 -0
- package/skills/ct-research-agent/SKILL.md +226 -0
- package/skills/ct-skill-creator/.cleo/.context-state.json +13 -0
- package/skills/ct-skill-creator/.cleo/logs/cleo.2026-03-07.1.log +24 -0
- package/skills/ct-skill-creator/.cleo/tasks.db +0 -0
- package/skills/ct-skill-creator/SKILL.md +356 -0
- package/skills/ct-skill-creator/agents/analyzer.md +276 -0
- package/skills/ct-skill-creator/agents/comparator.md +204 -0
- package/skills/ct-skill-creator/agents/grader.md +225 -0
- package/skills/ct-skill-creator/assets/eval_review.html +146 -0
- package/skills/ct-skill-creator/eval-viewer/__pycache__/generate_review.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/eval-viewer/generate_review.py +471 -0
- package/skills/ct-skill-creator/eval-viewer/viewer.html +1325 -0
- package/skills/ct-skill-creator/manifest-entry.json +17 -0
- package/skills/ct-skill-creator/references/dynamic-context.md +228 -0
- package/skills/ct-skill-creator/references/frontmatter.md +83 -0
- package/skills/ct-skill-creator/references/invocation-control.md +165 -0
- package/skills/ct-skill-creator/references/output-patterns.md +86 -0
- package/skills/ct-skill-creator/references/provider-deployment.md +175 -0
- package/skills/ct-skill-creator/references/schemas.md +430 -0
- package/skills/ct-skill-creator/references/workflows.md +28 -0
- package/skills/ct-skill-creator/scripts/__init__.py +1 -0
- package/skills/ct-skill-creator/scripts/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/aggregate_benchmark.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/generate_report.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/improve_description.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/init_skill.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/quick_validate.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/run_eval.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/run_loop.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/__pycache__/utils.cpython-314.pyc +0 -0
- package/skills/ct-skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/skills/ct-skill-creator/scripts/generate_report.py +326 -0
- package/skills/ct-skill-creator/scripts/improve_description.py +247 -0
- package/skills/ct-skill-creator/scripts/init_skill.py +306 -0
- package/skills/ct-skill-creator/scripts/package_skill.py +110 -0
- package/skills/ct-skill-creator/scripts/quick_validate.py +97 -0
- package/skills/ct-skill-creator/scripts/run_eval.py +310 -0
- package/skills/ct-skill-creator/scripts/run_loop.py +328 -0
- package/skills/ct-skill-creator/scripts/utils.py +47 -0
- package/skills/ct-skill-validator/SKILL.md +178 -0
- package/skills/ct-skill-validator/agents/ecosystem-checker.md +151 -0
- package/skills/ct-skill-validator/assets/valid-skill-example.md +13 -0
- package/skills/ct-skill-validator/evals/eval_set.json +14 -0
- package/skills/ct-skill-validator/evals/evals.json +52 -0
- package/skills/ct-skill-validator/manifest-entry.json +20 -0
- package/skills/ct-skill-validator/references/cleo-ecosystem-rules.md +163 -0
- package/skills/ct-skill-validator/references/validation-rules.md +168 -0
- package/skills/ct-skill-validator/scripts/__init__.py +0 -0
- package/skills/ct-skill-validator/scripts/__pycache__/audit_body.cpython-314.pyc +0 -0
- package/skills/ct-skill-validator/scripts/__pycache__/check_ecosystem.cpython-314.pyc +0 -0
- package/skills/ct-skill-validator/scripts/__pycache__/generate_validation_report.cpython-314.pyc +0 -0
- package/skills/ct-skill-validator/scripts/__pycache__/validate.cpython-314.pyc +0 -0
- package/skills/ct-skill-validator/scripts/audit_body.py +242 -0
- package/skills/ct-skill-validator/scripts/check_ecosystem.py +169 -0
- package/skills/ct-skill-validator/scripts/check_manifest.py +172 -0
- package/skills/ct-skill-validator/scripts/generate_validation_report.py +442 -0
- package/skills/ct-skill-validator/scripts/validate.py +422 -0
- package/skills/ct-spec-writer/SKILL.md +189 -0
- package/skills/ct-stickynote/README.md +14 -0
- package/skills/ct-stickynote/SKILL.md +46 -0
- package/skills/ct-task-executor/SKILL.md +296 -0
- package/skills/ct-validator/SKILL.md +216 -0
- package/skills/manifest.json +469 -0
- package/skills.json +281 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Orchestrator: Error Recovery
|
|
2
|
+
|
|
3
|
+
> Referenced from: @skills/ct-orchestrator/SKILL.md
|
|
4
|
+
> Load when: Need details on error handling, recovery procedures, context budget monitoring, or session lifecycle management
|
|
5
|
+
|
|
6
|
+
## Error Recovery
|
|
7
|
+
|
|
8
|
+
| Failure | Detection | Recovery |
|
|
9
|
+
|---------|-----------|----------|
|
|
10
|
+
| No output file | `test -f <path>` fails | Re-spawn with clearer instructions |
|
|
11
|
+
| No manifest entry | `{{RESEARCH_SHOW_CMD}}` fails | Manual entry or re-spawn |
|
|
12
|
+
| Task not completed | Status != done | Orchestrator completes manually |
|
|
13
|
+
| Partial status | `status: partial` | Spawn continuation agent |
|
|
14
|
+
| Blocked status | `status: blocked` | Flag for human review |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Context Budget Monitoring
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Check current context usage
|
|
22
|
+
cleo orchestrator context
|
|
23
|
+
|
|
24
|
+
# With specific token count
|
|
25
|
+
cleo orchestrator context --tokens 5000
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Status Thresholds**:
|
|
29
|
+
| Status | Usage | Action |
|
|
30
|
+
|--------|-------|--------|
|
|
31
|
+
| `ok` | <70% | Continue orchestration |
|
|
32
|
+
| `warning` | 70-89% | Delegate current work soon |
|
|
33
|
+
| `critical` | >=90% | STOP - Delegate immediately |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Session Lifecycle Management
|
|
38
|
+
|
|
39
|
+
Orchestrator sessions may span multiple Claude conversations. This is expected and supported by design.
|
|
40
|
+
|
|
41
|
+
### Session Timeout and Retention
|
|
42
|
+
|
|
43
|
+
| Setting | Default | Description |
|
|
44
|
+
|---------|---------|-------------|
|
|
45
|
+
| Session timeout | 72 hours | Active sessions auto-end after 72h inactivity |
|
|
46
|
+
| Auto-end threshold | 7 days | `retention.autoEndActiveAfterDays` config |
|
|
47
|
+
| Stale session cleanup | Manual | Use `cleo session gc` for cleanup |
|
|
48
|
+
|
|
49
|
+
**Key points:**
|
|
50
|
+
- Sessions can legitimately span multiple days of work
|
|
51
|
+
- Long-running orchestration work is expected
|
|
52
|
+
- Sessions persist across Claude conversation boundaries
|
|
53
|
+
|
|
54
|
+
### Cleanup Commands
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Standard garbage collection (ended/suspended sessions only)
|
|
58
|
+
cleo session gc
|
|
59
|
+
|
|
60
|
+
# Include stale active sessions (>7 days old by default)
|
|
61
|
+
cleo session gc --include-active
|
|
62
|
+
|
|
63
|
+
# Preview what would be cleaned
|
|
64
|
+
cleo session gc --dry-run
|
|
65
|
+
cleo session gc --include-active --dry-run
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Configuration
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# View current retention settings
|
|
72
|
+
cleo config get retention
|
|
73
|
+
|
|
74
|
+
# Adjust auto-end threshold for active sessions
|
|
75
|
+
cleo config set retention.autoEndActiveAfterDays 14 # Extend to 2 weeks
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Best Practices
|
|
79
|
+
|
|
80
|
+
1. **Session end on completion**: Always end sessions when work completes
|
|
81
|
+
```bash
|
|
82
|
+
cleo session end --note "Epic T1575 phase 1 complete"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
2. **Session suspend for long waits**: Suspend when blocked on external factors
|
|
86
|
+
```bash
|
|
87
|
+
cleo session suspend --note "Awaiting code review"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
3. **Periodic cleanup**: Run garbage collection periodically to remove stale sessions
|
|
91
|
+
```bash
|
|
92
|
+
cleo session gc --include-active
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
4. **Multi-day work**: No need to restart sessions daily - orchestrator sessions are designed for extended work periods
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Validation
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Full protocol validation
|
|
103
|
+
cleo orchestrator validate
|
|
104
|
+
|
|
105
|
+
# Validate for specific epic
|
|
106
|
+
cleo orchestrator validate --epic T1575
|
|
107
|
+
|
|
108
|
+
# Validate specific subagent output
|
|
109
|
+
cleo orchestrator validate --subagent research-id-2026-01-18
|
|
110
|
+
|
|
111
|
+
# Manifest only
|
|
112
|
+
cleo orchestrator validate --manifest
|
|
113
|
+
```
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# Orchestrator: Subagent Spawning
|
|
2
|
+
|
|
3
|
+
> Referenced from: @skills/ct-orchestrator/SKILL.md
|
|
4
|
+
> Load when: Need details on spawning subagents, skill dispatch, template selection, or programmatic spawning workflows
|
|
5
|
+
|
|
6
|
+
## Subagent Spawning
|
|
7
|
+
|
|
8
|
+
### Quick Spawn Workflow
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# 1. Get next ready task
|
|
12
|
+
cleo orchestrator next --epic T1575
|
|
13
|
+
|
|
14
|
+
# 2. Generate spawn command with prompt
|
|
15
|
+
cleo orchestrator spawn T1586
|
|
16
|
+
|
|
17
|
+
# 3. Or specify a skill template
|
|
18
|
+
cleo orchestrator spawn T1586 --template ct-research-agent
|
|
19
|
+
cleo orchestrator spawn T1586 --template RESEARCH-AGENT # aliases work
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Manual Spawn (when CLI spawn unavailable)
|
|
23
|
+
|
|
24
|
+
Use Task tool with `subagent_type="general-purpose"` and include:
|
|
25
|
+
1. Subagent protocol block (RFC 2119 requirements)
|
|
26
|
+
2. Context from previous agents (manifest `key_findings` ONLY)
|
|
27
|
+
3. Clear task definition and completion criteria
|
|
28
|
+
|
|
29
|
+
### Spawn Output
|
|
30
|
+
|
|
31
|
+
The `spawn` command returns:
|
|
32
|
+
- `taskId`: Target task
|
|
33
|
+
- `template`: Skill used
|
|
34
|
+
- `topicSlug`: Slugified topic name
|
|
35
|
+
- `outputFile`: Expected output filename
|
|
36
|
+
- `prompt`: Complete prompt ready for Task tool
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Skill Dispatch Rules
|
|
41
|
+
|
|
42
|
+
Use the appropriate skill for each task type. The `spawn` command accepts skill names in multiple formats.
|
|
43
|
+
|
|
44
|
+
### Skill Selection Matrix
|
|
45
|
+
|
|
46
|
+
| Task Type | Skill | Trigger Keywords |
|
|
47
|
+
|-----------|-------|------------------|
|
|
48
|
+
| Generic implementation | `ct-task-executor` | "implement", "execute task", "do the work", "build component" |
|
|
49
|
+
| Research/investigation | `ct-research-agent` | "research", "investigate", "gather info", "explore options" |
|
|
50
|
+
| Epic/project planning | `ct-epic-architect` | "create epic", "plan tasks", "decompose", "wave planning" |
|
|
51
|
+
| Specification writing | `ct-spec-writer` | "write spec", "define protocol", "RFC", "specification" |
|
|
52
|
+
| Test writing (BATS) | `ct-test-writer-bats` | "write tests", "BATS", "bash tests", "integration tests" |
|
|
53
|
+
| Bash library creation | `ct-library-implementer-bash` | "create library", "bash functions", "lib/*.sh" |
|
|
54
|
+
| Compliance validation | `ct-validator` | "validate", "verify", "check compliance", "audit" |
|
|
55
|
+
| Documentation | `ct-documentor` | "write docs", "document", "update README" |
|
|
56
|
+
|
|
57
|
+
### Skill Name Aliases
|
|
58
|
+
|
|
59
|
+
The `spawn` command supports multiple name formats:
|
|
60
|
+
|
|
61
|
+
| Format | Example |
|
|
62
|
+
|--------|---------|
|
|
63
|
+
| Full name | `ct-task-executor`, `ct-research-agent` |
|
|
64
|
+
| Uppercase | `TASK-EXECUTOR`, `RESEARCH-AGENT` |
|
|
65
|
+
| Lowercase | `task-executor`, `research-agent` |
|
|
66
|
+
| Short aliases | `EXECUTOR`, `RESEARCH`, `BATS`, `SPEC` |
|
|
67
|
+
|
|
68
|
+
### Skill Paths
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
skills/ct-epic-architect/SKILL.md
|
|
72
|
+
skills/ct-spec-writer/SKILL.md
|
|
73
|
+
skills/ct-research-agent/SKILL.md
|
|
74
|
+
skills/ct-test-writer-bats/SKILL.md
|
|
75
|
+
skills/ct-library-implementer-bash/SKILL.md
|
|
76
|
+
skills/ct-task-executor/SKILL.md
|
|
77
|
+
skills/ct-validator/SKILL.md
|
|
78
|
+
skills/ct-documentor/SKILL.md
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Complete Spawning Workflow
|
|
84
|
+
|
|
85
|
+
### Automated Workflow (Recommended)
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Step 1: Get ready task
|
|
89
|
+
cleo orchestrator next --epic T1575
|
|
90
|
+
# Returns: { nextTask: { id: "T1586", title: "...", priority: "high" } }
|
|
91
|
+
|
|
92
|
+
# Step 2: Generate spawn prompt (handles all token injection)
|
|
93
|
+
spawn_result=$(cleo orchestrator spawn T1586)
|
|
94
|
+
|
|
95
|
+
# Step 3: Extract prompt and use with Task tool
|
|
96
|
+
prompt=$(echo "$spawn_result" | jq -r '.result.prompt')
|
|
97
|
+
# Pass $prompt to Task tool
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Programmatic Spawning with orchestrator_spawn_for_task()
|
|
103
|
+
|
|
104
|
+
For advanced automation, use the `orchestrator_spawn_for_task()` function from `lib/orchestrator-spawn.sh`. This consolidates the manual 6-step workflow into a single function call.
|
|
105
|
+
|
|
106
|
+
### Basic Usage
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
source lib/orchestrator-spawn.sh
|
|
110
|
+
|
|
111
|
+
# Prepare complete subagent prompt for a task
|
|
112
|
+
prompt=$(orchestrator_spawn_for_task "T1234")
|
|
113
|
+
|
|
114
|
+
# With explicit skill override (bypasses auto-dispatch)
|
|
115
|
+
prompt=$(orchestrator_spawn_for_task "T1234" "ct-research-agent")
|
|
116
|
+
|
|
117
|
+
# With target model validation
|
|
118
|
+
prompt=$(orchestrator_spawn_for_task "T1234" "" "sonnet")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### What orchestrator_spawn_for_task() Does
|
|
122
|
+
|
|
123
|
+
The function performs these steps automatically:
|
|
124
|
+
|
|
125
|
+
| Step | Action | Details |
|
|
126
|
+
|------|--------|---------|
|
|
127
|
+
| 1 | Read task from CLEO | `cleo show T1234 --format json` |
|
|
128
|
+
| 2 | Select skill | Auto-dispatch from task type/labels or use override |
|
|
129
|
+
| 3 | Validate skill | Check compatibility with target model |
|
|
130
|
+
| 4 | Inject protocol | Load skill template + subagent protocol |
|
|
131
|
+
| 5 | Set tokens | `{{TASK_ID}}`, `{{DATE}}`, `{{TOPIC_SLUG}}`, `{{EPIC_ID}}` |
|
|
132
|
+
| 6 | **Validate protocol** | **MANDATORY check for SUBAGENT PROTOCOL marker** |
|
|
133
|
+
| 7 | Return prompt | Complete JSON with prompt ready for Task tool |
|
|
134
|
+
|
|
135
|
+
### Protocol Validation (MANDATORY)
|
|
136
|
+
|
|
137
|
+
Step 6 validates that the generated prompt contains the `SUBAGENT PROTOCOL` marker. This is **mandatory** and will fail loudly if missing:
|
|
138
|
+
|
|
139
|
+
- **Exit code**: `EXIT_PROTOCOL_MISSING` (60)
|
|
140
|
+
- **Fix command**: `cleo research inject`
|
|
141
|
+
- **Validation function**: `orchestrator_verify_protocol_injection()`
|
|
142
|
+
|
|
143
|
+
If validation fails, the spawn is **blocked** and you must fix the skill template or manually inject the protocol block.
|
|
144
|
+
|
|
145
|
+
### Return Value Structure
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"_meta": { "command": "orchestrator", "operation": "spawn_for_task" },
|
|
150
|
+
"success": true,
|
|
151
|
+
"result": {
|
|
152
|
+
"taskId": "T1234",
|
|
153
|
+
"skill": "ct-research-agent",
|
|
154
|
+
"topicSlug": "auth-implementation",
|
|
155
|
+
"date": "2026-01-20",
|
|
156
|
+
"epicId": "T1200",
|
|
157
|
+
"outputFile": "2026-01-20_auth-implementation.md",
|
|
158
|
+
"spawnTimestamp": "2026-01-20T15:30:00Z",
|
|
159
|
+
"targetModel": "auto",
|
|
160
|
+
"taskContext": {
|
|
161
|
+
"title": "Implement auth module",
|
|
162
|
+
"description": "Full task description..."
|
|
163
|
+
},
|
|
164
|
+
"instruction": "Use Task tool to spawn subagent with the following prompt:",
|
|
165
|
+
"prompt": "Complete injected prompt content..."
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Helper Functions
|
|
171
|
+
|
|
172
|
+
| Function | Purpose |
|
|
173
|
+
|----------|---------|
|
|
174
|
+
| `orchestrator_spawn_for_task()` | Main function - prepare single task spawn |
|
|
175
|
+
| `orchestrator_spawn_batch()` | Prepare prompts for multiple tasks |
|
|
176
|
+
| `orchestrator_spawn_preview()` | Preview skill selection without injection |
|
|
177
|
+
|
|
178
|
+
### Complete Workflow Example
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
#!/usr/bin/env bash
|
|
182
|
+
# Example: Spawn research subagent for task T1586
|
|
183
|
+
|
|
184
|
+
source lib/orchestrator-spawn.sh
|
|
185
|
+
|
|
186
|
+
# 1. Generate spawn result (includes all tokens and context)
|
|
187
|
+
spawn_result=$(orchestrator_spawn_for_task "T1586")
|
|
188
|
+
|
|
189
|
+
# 2. Check success
|
|
190
|
+
if [[ $(echo "$spawn_result" | jq -r '.success') != "true" ]]; then
|
|
191
|
+
echo "Spawn failed: $(echo "$spawn_result" | jq -r '.error.message')" >&2
|
|
192
|
+
exit 1
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
# 3. Extract prompt for Task tool
|
|
196
|
+
prompt=$(echo "$spawn_result" | jq -r '.result.prompt')
|
|
197
|
+
output_file=$(echo "$spawn_result" | jq -r '.result.outputFile')
|
|
198
|
+
skill=$(echo "$spawn_result" | jq -r '.result.skill')
|
|
199
|
+
|
|
200
|
+
# 4. Log spawn metadata
|
|
201
|
+
echo "Spawning $skill for task T1586"
|
|
202
|
+
echo "Expected output: $output_file"
|
|
203
|
+
|
|
204
|
+
# 5. Pass $prompt to Task tool (in orchestrator context)
|
|
205
|
+
# The Task tool invocation would include:
|
|
206
|
+
# - description: "Execute task T1586 with $skill"
|
|
207
|
+
# - prompt: $prompt
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Debug Mode
|
|
211
|
+
|
|
212
|
+
Enable debug output for troubleshooting:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
export ORCHESTRATOR_SPAWN_DEBUG=1
|
|
216
|
+
prompt=$(orchestrator_spawn_for_task "T1234")
|
|
217
|
+
# Logs to stderr: [orchestrator-spawn] DEBUG: ...
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### Manual Workflow
|
|
223
|
+
|
|
224
|
+
#### Step 1: Identify Task Type
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Check task details
|
|
228
|
+
cleo show T1234 | jq '{title, description, labels}'
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### Step 2: Select Skill
|
|
232
|
+
|
|
233
|
+
Match task keywords to skill selection matrix above.
|
|
234
|
+
|
|
235
|
+
#### Step 3: Prepare Context
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
source lib/token-inject.sh
|
|
239
|
+
|
|
240
|
+
# Set required tokens
|
|
241
|
+
ti_set_context "T1234" "$(date +%Y-%m-%d)" "auth-implementation"
|
|
242
|
+
|
|
243
|
+
# Set defaults and get task context
|
|
244
|
+
ti_set_defaults
|
|
245
|
+
task_json=$(cleo show T1234 --format json)
|
|
246
|
+
ti_set_task_context "$task_json"
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Step 4: Load Skill Template
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
template=$(ti_load_template "skills/ct-task-executor/SKILL.md")
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
#### Step 5: Spawn Subagent
|
|
256
|
+
|
|
257
|
+
Use Task tool with:
|
|
258
|
+
1. Injected skill template
|
|
259
|
+
2. Subagent protocol block
|
|
260
|
+
3. Context from previous agents (manifest `key_findings` ONLY)
|
|
261
|
+
4. Clear task definition and completion criteria
|
|
262
|
+
|
|
263
|
+
#### Step 6: Monitor Completion
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
# Check manifest for completion
|
|
267
|
+
{{RESEARCH_SHOW_CMD}} <research-id>
|
|
268
|
+
|
|
269
|
+
# Or use jq
|
|
270
|
+
jq -s '.[-1] | {id, status, key_findings}' {{MANIFEST_PATH}}
|
|
271
|
+
```
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Orchestrator: Token Injection System
|
|
2
|
+
|
|
3
|
+
> Referenced from: @skills/ct-orchestrator/SKILL.md
|
|
4
|
+
> Load when: Need details on token injection, placeholder values, manual token setup, or helper functions for template processing
|
|
5
|
+
|
|
6
|
+
## Token Injection System
|
|
7
|
+
|
|
8
|
+
The `spawn` command handles token injection automatically. For manual injection, use `lib/token-inject.sh`.
|
|
9
|
+
|
|
10
|
+
### Automatic (via spawn command)
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# The spawn command automatically:
|
|
14
|
+
# 1. Loads the skill template
|
|
15
|
+
# 2. Sets required context tokens
|
|
16
|
+
# 3. Gets task context from CLEO
|
|
17
|
+
# 4. Extracts manifest summaries
|
|
18
|
+
# 5. Injects all tokens
|
|
19
|
+
cleo orchestrator spawn T1586 --template ct-research-agent
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Manual Token Injection
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
source lib/token-inject.sh
|
|
26
|
+
|
|
27
|
+
# 1. Set required tokens
|
|
28
|
+
export TI_TASK_ID="T1234"
|
|
29
|
+
export TI_DATE="$(date +%Y-%m-%d)"
|
|
30
|
+
export TI_TOPIC_SLUG="my-research-topic"
|
|
31
|
+
|
|
32
|
+
# 2. Set CLEO defaults (task commands, output paths)
|
|
33
|
+
ti_set_defaults
|
|
34
|
+
|
|
35
|
+
# 3. Optional: Get task context from CLEO
|
|
36
|
+
task_json=$(cleo show T1234 --format json)
|
|
37
|
+
ti_set_task_context "$task_json"
|
|
38
|
+
|
|
39
|
+
# 4. Load and inject skill template
|
|
40
|
+
template=$(ti_load_template "skills/ct-research-agent/SKILL.md")
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Token Reference
|
|
46
|
+
|
|
47
|
+
**Source of Truth**: `skills/_shared/placeholders.json`
|
|
48
|
+
|
|
49
|
+
### Required Tokens
|
|
50
|
+
|
|
51
|
+
| Token | Description | Pattern | Example |
|
|
52
|
+
|-------|-------------|---------|---------|
|
|
53
|
+
| `{{TASK_ID}}` | CLEO task identifier | `^T[0-9]+$` | `T1234` |
|
|
54
|
+
| `{{DATE}}` | ISO date | `YYYY-MM-DD` | `2026-01-20` |
|
|
55
|
+
| `{{TOPIC_SLUG}}` | URL-safe topic name | `[a-zA-Z0-9_-]+` | `auth-research` |
|
|
56
|
+
|
|
57
|
+
### Task Command Tokens (CLEO defaults)
|
|
58
|
+
|
|
59
|
+
| Token | Default Value |
|
|
60
|
+
|-------|---------------|
|
|
61
|
+
| `{{TASK_SHOW_CMD}}` | `cleo show` |
|
|
62
|
+
| `{{TASK_START_CMD}}` | `cleo start` |
|
|
63
|
+
| `{{TASK_COMPLETE_CMD}}` | `cleo complete` |
|
|
64
|
+
| `{{TASK_LINK_CMD}}` | `cleo research link` |
|
|
65
|
+
| `{{TASK_LIST_CMD}}` | `cleo list` |
|
|
66
|
+
| `{{TASK_FIND_CMD}}` | `cleo find` |
|
|
67
|
+
| `{{TASK_ADD_CMD}}` | `cleo add` |
|
|
68
|
+
|
|
69
|
+
### Output Tokens (CLEO defaults)
|
|
70
|
+
|
|
71
|
+
| Token | Default Value |
|
|
72
|
+
|-------|---------------|
|
|
73
|
+
| `{{OUTPUT_DIR}}` | `claudedocs/agent-outputs` |
|
|
74
|
+
| `{{MANIFEST_PATH}}` | `claudedocs/agent-outputs/MANIFEST.jsonl` |
|
|
75
|
+
|
|
76
|
+
### Task Context Tokens (populated from CLEO task data)
|
|
77
|
+
|
|
78
|
+
| Token | Source | Description |
|
|
79
|
+
|-------|--------|-------------|
|
|
80
|
+
| `{{TASK_NAME}}` | `task.title` | Task title |
|
|
81
|
+
| `{{TASK_DESCRIPTION}}` | `task.description` | Full description |
|
|
82
|
+
| `{{TASK_INSTRUCTIONS}}` | `task.description` | Execution instructions |
|
|
83
|
+
| `{{DELIVERABLES_LIST}}` | `task.deliverables` | Expected outputs |
|
|
84
|
+
| `{{ACCEPTANCE_CRITERIA}}` | Extracted | Completion criteria |
|
|
85
|
+
| `{{DEPENDS_LIST}}` | `task.depends` | Completed dependencies |
|
|
86
|
+
| `{{MANIFEST_SUMMARIES}}` | MANIFEST.jsonl | Key findings from previous agents |
|
|
87
|
+
| `{{NEXT_TASK_IDS}}` | Dependency analysis | Tasks unblocked after completion |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Helper Functions
|
|
92
|
+
|
|
93
|
+
| Function | Purpose |
|
|
94
|
+
|----------|---------|
|
|
95
|
+
| `ti_set_defaults()` | Set CLEO defaults for unset tokens |
|
|
96
|
+
| `ti_validate_required()` | Verify required tokens are set |
|
|
97
|
+
| `ti_inject_tokens()` | Replace `{{TOKEN}}` patterns |
|
|
98
|
+
| `ti_load_template()` | Load file and inject tokens |
|
|
99
|
+
| `ti_set_context()` | Set TASK_ID, DATE, TOPIC_SLUG in one call |
|
|
100
|
+
| `ti_set_task_context()` | Populate task context tokens from CLEO JSON |
|
|
101
|
+
| `ti_extract_manifest_summaries()` | Get key_findings from recent manifest entries |
|
|
102
|
+
| `ti_list_tokens()` | Show all tokens with current values |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Token Injection with lib/token-inject.sh
|
|
107
|
+
|
|
108
|
+
For fine-grained control over token injection, use `lib/token-inject.sh` directly.
|
|
109
|
+
|
|
110
|
+
### Token Categories
|
|
111
|
+
|
|
112
|
+
| Category | Tokens | Source |
|
|
113
|
+
|----------|--------|--------|
|
|
114
|
+
| **Required** | `{{TASK_ID}}`, `{{DATE}}`, `{{TOPIC_SLUG}}` | Must be set before injection |
|
|
115
|
+
| **Task Commands** | `{{TASK_SHOW_CMD}}`, `{{TASK_START_CMD}}`, `{{TASK_COMPLETE_CMD}}`, etc. | CLEO defaults |
|
|
116
|
+
| **Output Paths** | `{{OUTPUT_DIR}}`, `{{MANIFEST_PATH}}` | CLEO defaults |
|
|
117
|
+
| **Task Context** | `{{TASK_TITLE}}`, `{{TASK_DESCRIPTION}}`, `{{DEPENDS_LIST}}`, etc. | From CLEO task data |
|
|
118
|
+
| **Manifest Context** | `{{MANIFEST_SUMMARIES}}` | From recent MANIFEST.jsonl entries |
|
|
119
|
+
|
|
120
|
+
### Manual Token Injection Example
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
source lib/token-inject.sh
|
|
124
|
+
|
|
125
|
+
# 1. Set required tokens
|
|
126
|
+
ti_set_context "T1234" "2026-01-20" "auth-research"
|
|
127
|
+
|
|
128
|
+
# 2. Set CLEO defaults for task commands and paths
|
|
129
|
+
ti_set_defaults
|
|
130
|
+
|
|
131
|
+
# 3. Get task context from CLEO
|
|
132
|
+
task_json=$(cleo show T1234 --format json)
|
|
133
|
+
ti_set_task_context "$task_json"
|
|
134
|
+
|
|
135
|
+
# 4. Load and inject skill template
|
|
136
|
+
template=$(ti_load_template "skills/ct-research-agent/SKILL.md")
|
|
137
|
+
|
|
138
|
+
# 5. Verify tokens were injected
|
|
139
|
+
echo "$template" | grep -c '{{' && echo "WARNING: Uninjected tokens remain"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Key Functions
|
|
143
|
+
|
|
144
|
+
| Function | Purpose | Example |
|
|
145
|
+
|----------|---------|---------|
|
|
146
|
+
| `ti_set_context()` | Set required tokens | `ti_set_context "T1234" "" "topic"` |
|
|
147
|
+
| `ti_set_defaults()` | Set CLEO command defaults | `ti_set_defaults` |
|
|
148
|
+
| `ti_set_task_context()` | Populate from CLEO JSON | `ti_set_task_context "$task_json"` |
|
|
149
|
+
| `ti_extract_manifest_summaries()` | Get recent findings | `ti_extract_manifest_summaries 5` |
|
|
150
|
+
| `ti_load_template()` | Load and inject file | `ti_load_template "path/to/SKILL.md"` |
|
|
151
|
+
| `ti_list_tokens()` | Debug token values | `ti_list_tokens` |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Subagent Protocol Tokens
|
|
156
|
+
|
|
157
|
+
Token defaults (from `skills/_shared/placeholders.json`):
|
|
158
|
+
- `{{OUTPUT_DIR}}` -> `claudedocs/agent-outputs`
|
|
159
|
+
- `{{MANIFEST_PATH}}` -> `claudedocs/agent-outputs/MANIFEST.jsonl`
|
|
160
|
+
|
|
161
|
+
### Inline Protocol Block (when CLI unavailable)
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
## SUBAGENT PROTOCOL (RFC 2119 - MANDATORY)
|
|
165
|
+
|
|
166
|
+
OUTPUT REQUIREMENTS:
|
|
167
|
+
1. MUST write findings to: {{OUTPUT_DIR}}/{{DATE}}_{{TOPIC_SLUG}}.md
|
|
168
|
+
2. MUST append ONE line to: {{MANIFEST_PATH}}
|
|
169
|
+
3. MUST return ONLY: "Research complete. See MANIFEST.jsonl for summary."
|
|
170
|
+
4. MUST NOT return research content in response.
|
|
171
|
+
|
|
172
|
+
CLEO INTEGRATION:
|
|
173
|
+
1. MUST read task details: `{{TASK_SHOW_CMD}} {{TASK_ID}}`
|
|
174
|
+
2. MUST start task: `{{TASK_START_CMD}} {{TASK_ID}}`
|
|
175
|
+
3. MUST complete task when done: `{{TASK_COMPLETE_CMD}} {{TASK_ID}}`
|
|
176
|
+
4. SHOULD link research: `{{TASK_LINK_CMD}} {{TASK_ID}} {{RESEARCH_ID}}` <- RECOMMENDED
|
|
177
|
+
|
|
178
|
+
**Research Linking Note**: If subagent fails to link research, orchestrator will link on verification.
|
|
179
|
+
This ensures bidirectional traceability between tasks and their research artifacts.
|
|
180
|
+
```
|