brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
task-intelligenceImplements intelligent task intelligence with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
Independent GitHub snapshot · Automated classification · Original documentation governs
name: task-intelligence compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for task intelligence workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability.
┌───────────────────────────────────────────────────────────────────────────────┐ │ Orchestration Flow │ └───────────────────────────────────────────────────────────────────────────────┘
User Request ↓ ┌─────────────────┐ │ Parse Request │ │ & Extract │ │ Features │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Evaluate Available Skills │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Skill A │ │ Skill B │ │ Skill C │ │ │ │ - Match Score│ │ - Match Score│ │ - Match Score│ │ │ │ - Confidence │ │ - Confidence │ │ - Confidence │ │ │ │ - History │ │ - History │ │ - History │ │ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ │ │ │ │ └─────────────────┴─────────────────┘ │ │ ↓ │ │ Select Best Skill │ └─────────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────┐ │ Execute Skill │ └────────┬────────┘ ↓ ┌─────────────────┐ │ Handle Result │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Error Handling & Fallback │ │ │ │ Success? ────────► Return Result │ │ │ │ Fail? ────────┐ │ │ ↓ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ Fallback Chain │ │ │ │ │ │ │ │ 1. Retry with adjusted parameters │ │ │ │ 2. Try Alternative Skill (if available) │ │ │ │ 3. Defer to Human Operator (if critical) │ │ │ │ 4. Log & Return Error │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Use this skill when:
Avoid this skill for:
Parse and Analyze Request - Extract intent, entities, and constraints from user input. Checkpoint: All required parameters must be present and in valid format before proceeding.
Score Available Skills - Calculate match scores using multi-factor algorithm:
Checkpoint: Skip to fallback if no skill scores above threshold.
Select Optimal Skill - Choose skill with highest score that meets minimum confidence. Checkpoint: Verify skill has not been disabled or deprecated.
Execute with Fallback - Run skill execution wrapped in retry and fallback logic. Checkpoint: Log all execution attempts for audit trail.
Return or Fallback - Either return successful result or apply fallback chain:
related-skillsCheckpoint: Record outcome with timing and confidence metadata.
def route_task_intelligence(
raw_request: str,
skill_registry: List[Dict],
confidence_threshold: float = 0.75
) -> Dict:
"""Route a task through multi-factor intelligence scoring.
Implements Law 2 (Parse at boundary) by extracting intent and entities
before scoring. Uses weighted scoring for text match, historical success,
and system health.
"""
# Law 1: Early exit on malformed input
if not raw_request or len(raw_request.strip()) < 3:
return {"status": "rejected", "reason": "insufficient_input"}
# Law 2: Parse and extract features at boundary
parsed_intent = _extract_intent_entities(raw_request)
if not parsed_intent.get("primary_entity"):
return {"status": "rejected", "reason": "unrecognized_domain"}
scored_candidates = []
for skill in skill_registry:
# Multi-factor scoring: text similarity (40%), history (40%), health (20%)
text_match = _cosine_similarity(parsed_intent["query"], skill["triggers"])
hist_success = skill.get("success_rate", 0.0)
health_score = 1.0 if skill.get("is_healthy", True) else 0.3
weighted_score = (text_match * 0.4) + (hist_success * 0.4) + (health_score * 0.2)
if weighted_score >= confidence_threshold:
scored_candidates.append({
"skill_id": skill["id"],
"score": round(weighted_score, 3),
"fallback_chain": skill.get("fallback_ids", [])
})
# Law 3: Return new structure, never mutate registry
if not scored_candidates:
return {"status": "no_match", "fallback_to": "human_operator"}
scored_candidates.sort(key=lambda x: x["score"], reverse=True)
return {
"selected_skill": scored_candidates[0],
"alternatives": scored_candidates[1:],
"routing_metadata": {
"intent": parsed_intent["primary_entity"],
"timestamp": time.time(),
"confidence": scored_candidates[0]["score"]
}
}
def execute_task_with_adaptive_fallback(
routing_result: Dict,
task_context: Dict,
max_retries: int = 2
) -> Dict:
"""Execute routed task with intelligent fallback chain.
Implements Law 4 (Fail Fast/Loud) by validating state before execution
and escalating through a predefined fallback hierarchy.
"""
selected = routing_result["selected_skill"]
current_skill_id = selected["skill_id"]
fallback_chain = selected.get("fallback_chain", [])
for attempt in range(max_retries + 1):
try:
# Validate context matches skill requirements
_validate_context_compatibility(task_context, current_skill_id)
# Execute primary skill
raw_output = _invoke_skill_api(current_skill_id, task_context)
# Law 3: Atomic predictability - return fresh result
return {
"status": "success",
"skill_used": current_skill_id,
"output": raw_output,
"attempts": attempt + 1,
"latency_ms": _measure_duration()
}
except CriticalValidationError as e:
# Law 4: Fail immediately on invalid state
return {"status": "hard_fail", "error": str(e), "escalate": True}
except TransientAPIError as e:
if attempt < max_retries:
_log_retry(current_skill_id, attempt, str(e))
continue
# Exhausted retries -> traverse fallback chain
if fallback_chain:
next_skill_id = fallback_chain[0]
_log_fallback_triggered(current_skill_id, next_skill_id)
return execute_task_with_adaptive_fallback(
{"selected_skill": {"skill_id": next_skill_id, "fallback_chain": fallback_chain[1:]}, "alternatives": []},
task_context,
max_retries=0
)
# Final fallback: human escalation
return {
"status": "escalated",
"original_skill": current_skill_id,
"error_context": task_context,
"message": "All automated fallbacks exhausted. Routing to human operator."
}
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose |
|---|---|
task-decomposition-engine | Uses intelligence analysis to inform how tasks should be decomposed into sub-tasks |
skill-router-system | Applies task intelligence scores to improve skill routing accuracy |
Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.