协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
andruia-consultant【开发与工程】Implements intelligent andruia consultant with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: andruia-consultant compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for andruia consultant 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 evaluate_andruia_consultant_request(
request: Dict[str, Any],
consultant_pool: List[Dict[str, Any]],
compliance_threshold: float = 0.85
) -> Optional[Dict[str, Any]]:
"""Evaluate and route an Andruia consultant request to the optimal specialist.
Applies the 5 Laws of Elegant Defense:
- Law 1: Early exit on malformed requests
- Law 2: Parse request into structured domains before scoring
- Law 3: Return immutable routing decision
- Law 4: Fail immediately if compliance checks fail
"""
if not request.get("domain") or not request.get("priority"):
raise ValueError("Request must include 'domain' and 'priority' fields")
parsed_request = {
"domain": request["domain"].lower(),
"priority": request["priority"],
"risk_level": _assess_risk(request.get("context", "")),
"compliance_flags": _extract_compliance_flags(request)
}
best_match = None
best_score = 0.0
for consultant in consultant_pool:
if not _is_compliant(consultant, parsed_request["compliance_flags"]):
continue
domain_match = _calculate_domain_alignment(parsed_request["domain"], consultant["expertise"])
priority_weight = 1.2 if parsed_request["priority"] == "critical" else 1.0
score = domain_match * priority_weight * consultant["resolution_rate"]
if score > best_score and score >= compliance_threshold:
best_score = score
best_match = consultant
if best_match is None:
return None
return {
"assigned_consultant": best_match["id"],
"routing_score": best_score,
"estimated_resolution": _estimate_timeline(best_match, parsed_request["priority"]),
"immutable_decision": True
}
def execute_consultant_workflow(
consultant: Dict[str, Any],
workflow_context: Dict[str, Any],
escalation_path: List[str] = None
) -> Dict[str, Any]:
"""Execute an Andruia consultant workflow with domain-specific fallbacks.
Implements Fail Fast, Fail Loud (Law 4) and Atomic Predictability (Law 3).
Fallback chain: 1. Retry with adjusted scope -> 2. Escalate to senior specialist -> 3. Defer to compliance board
"""
if not _validate_consultant_credentials(consultant):
raise ConsultantError(f"Invalid credentials for consultant {consultant['id']}")
validated_context = _normalize_workflow_inputs(workflow_context)
attempts = 0
max_attempts = 2
while attempts <= max_attempts:
try:
result = _run_consultant_analysis(consultant, validated_context)
return {
"status": "resolved",
"consultant_id": consultant["id"],
"output": result,
"attempts": attempts + 1,
"audit_trail": _log_execution(consultant, result)
}
except ComplianceViolationError as e:
raise ConsultantError(f"Compliance violation in {consultant['id']}: {e}") from e
except ScopeLimitError as e:
attempts += 1
if attempts > max_attempts:
return _escalate_to_senior(consultant, validated_context, escalation_path)
validated_context = _adjust_scope_for_retry(validated_context, e)
return _defer_to_compliance_board(workflow_context)
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose |
|---|---|
andruia-skill-smith | Agent skill creation and design patterns |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.