协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
finishing-a-development-branch【开发与工程】Implements intelligent finishing a development branch with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: finishing-a-development-branch compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for finishing a development branch 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 select_branch_finishing_strategy(
branch_metadata: Dict,
project_config: Dict,
available_tools: List[Dict]
) -> Dict:
"""Select the optimal finishing strategy based on branch type and project rules.
Evaluates branch characteristics (feature, hotfix, release) against
project-specific merge policies, required checks, and team conventions.
"""
if not branch_metadata.get("name"):
raise ValueError("Branch name is required for strategy selection")
branch_type = branch_metadata.get("type", "feature")
target_ref = project_config.get("default_target", "main")
strategy = {
"type": branch_type,
"target": target_ref,
"required_checks": [],
"merge_method": "squash",
"fallback_actions": []
}
# Apply project-specific merge policies
policies = project_config.get("merge_policies", {})
if branch_type in policies:
policy = policies[branch_type]
strategy["required_checks"] = policy.get("checks", [])
strategy["merge_method"] = policy.get("method", "merge")
# Select appropriate toolchain from available tools
for tool in available_tools:
if tool.get("supports_type") == branch_type:
strategy["toolchain"] = tool["name"]
break
# Validate strategy against branch constraints
if branch_metadata.get("is_hotfix") and strategy["merge_method"] == "squash":
strategy["merge_method"] = "fast-forward"
strategy["fallback_actions"].append("notify_team_lead")
return strategy
def execute_branch_finishing_pipeline(
strategy: Dict,
branch_state: Dict,
ci_client: object,
notifier: object
) -> Dict:
"""Execute the complete branch finishing workflow with domain-specific fallbacks.
Pipeline: Validate -> Run Checks -> Merge -> Cleanup -> Notify
Implements graceful degradation when non-critical checks fail.
"""
branch_name = branch_state["name"]
target = strategy["target"]
required_checks = strategy.get("required_checks", [])
# Phase 1: Pre-flight Validation
if not _validate_branch_up_to_date(branch_state, target):
raise BranchStaleError(f"{branch_name} is behind {target}. Rebase required.")
# Phase 2: Execute Required Checks
check_results = []
for check in required_checks:
try:
result = ci_client.run_check(check, branch_name)
check_results.append(result)
if not result["passed"]:
strategy["fallback_actions"].append(f"skip_{check}")
except CheckTimeoutError:
strategy["fallback_actions"].append(f"retry_{check}")
# Phase 3: Merge Execution with Fallback
merge_result = None
for attempt in range(2):
try:
merge_result = _perform_merge(branch_name, target, strategy["merge_method"])
break
except MergeConflictError as e:
if attempt == 0:
strategy["fallback_actions"].append("auto_resolve_conflicts")
continue
raise MergeFailedError(f"Merge failed after conflict resolution: {e}")
# Phase 4: Cleanup & Notification
if merge_result and merge_result["success"]:
_cleanup_remote_branch(branch_name)
notifier.send_update(target, merge_result["commit_hash"])
return {"status": "finished", "merge": merge_result}
# Fallback execution
for action in strategy["fallback_actions"]:
_execute_fallback_action(action, branch_name, target)
return {"status": "completed_with_fallbacks", "actions_taken": strategy["fallback_actions"]}
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose | |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.