File size: 2,215 Bytes
896124d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Вспомогательные функции"""

import re
from typing import Dict, List, Tuple, Any
from .state import STATE

def build_skill_prompt(new_request: str, file_context: str = "") -> str:
    history = STATE.skill_history[-5:] if STATE.skill_history else []
    context = ""
    for entry in history:
        context += f"\n{entry['role']}: {entry['content'][:500]}"
    prompt = f"Previous context:{context}\n\nNew request: {new_request}"
    if file_context:
        prompt += f"\n\nFile context:\n{file_context}"
    return prompt

def parse_build_args(text: str) -> Tuple[Dict[str, Any], str]:
    params = {}
    # --agents=N
    agents_match = re.search(r'--agents=(\d+)', text)
    if agents_match:
        params["agents"] = int(agents_match.group(1))
        text = text.replace(agents_match.group(0), "")
    # --tier=tier1|tier2|...
    tier_match = re.search(r'--tier=(\w+)', text)
    if tier_match:
        params["tier"] = tier_match.group(1)
        text = text.replace(tier_match.group(0), "")
    # --interpreter=true|false
    interp_match = re.search(r'--interpreter=(true|false)', text, re.IGNORECASE)
    if interp_match:
        params["use_interpreter"] = interp_match.group(1).lower() == "true"
        text = text.replace(interp_match.group(0), "")
    return params, text.strip()

def parse_skill_args(text: str) -> Tuple[Dict[str, Any], str]:
    params = {}
    # --agents=role1,role2
    agents_match = re.search(r'--agents=([\w,]+)', text)
    if agents_match:
        params["agents"] = agents_match.group(1).split(",")
        text = text.replace(agents_match.group(0), "")
    # --internet
    if "--internet" in text:
        params["internet"] = True
        text = text.replace("--internet", "")
    return params, text.strip()

def parse_skill_agents(text: str) -> Tuple[List[str], str]:
    params, clean = parse_skill_args(text)
    return params.get("agents", []), clean

def get_current_mode_info() -> str:
    mode = STATE.current_mode
    role = STATE.current_role
    model = STATE.current_model
    conductor = STATE.current_conductor
    return f"🎛️ Режим: {mode} | Роль: {role} | Модель: {model} | Кондуктор: {conductor}"