chore: collapse multi-line argument definitions into single lines across multiple modules
This commit is contained in:
+2
-6
@@ -39,9 +39,7 @@ def list_agents() -> Dict[str, Any]:
|
||||
return {"status": "error", "error": str(e)}
|
||||
|
||||
|
||||
def execute_agent_task(
|
||||
agent_id: str, task: str, context: Dict[str, Any] = None
|
||||
) -> Dict[str, Any]:
|
||||
def execute_agent_task(agent_id: str, task: str, context: Dict[str, Any] = None) -> Dict[str, Any]:
|
||||
"""Execute a task with the specified agent."""
|
||||
try:
|
||||
db_path = os.path.expanduser("~/.assistant_db.sqlite")
|
||||
@@ -63,9 +61,7 @@ def remove_agent(agent_id: str) -> Dict[str, Any]:
|
||||
return {"status": "error", "error": str(e)}
|
||||
|
||||
|
||||
def collaborate_agents(
|
||||
orchestrator_id: str, task: str, agent_roles: List[str]
|
||||
) -> Dict[str, Any]:
|
||||
def collaborate_agents(orchestrator_id: str, task: str, agent_roles: List[str]) -> Dict[str, Any]:
|
||||
"""Collaborate multiple agents on a task."""
|
||||
try:
|
||||
db_path = os.path.expanduser("~/.assistant_db.sqlite")
|
||||
|
||||
+4
-12
@@ -235,9 +235,7 @@ def get_tools_definition():
|
||||
"description": "Change the current working directory",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {"type": "string", "description": "Path to change to"}
|
||||
},
|
||||
"properties": {"path": {"type": "string", "description": "Path to change to"}},
|
||||
"required": ["path"],
|
||||
},
|
||||
},
|
||||
@@ -284,9 +282,7 @@ def get_tools_definition():
|
||||
"description": "Execute a database query",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"query": {"type": "string", "description": "SQL query"}
|
||||
},
|
||||
"properties": {"query": {"type": "string", "description": "SQL query"}},
|
||||
"required": ["query"],
|
||||
},
|
||||
},
|
||||
@@ -298,9 +294,7 @@ def get_tools_definition():
|
||||
"description": "Perform a web search",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"query": {"type": "string", "description": "Search query"}
|
||||
},
|
||||
"properties": {"query": {"type": "string", "description": "Search query"}},
|
||||
"required": ["query"],
|
||||
},
|
||||
},
|
||||
@@ -346,9 +340,7 @@ def get_tools_definition():
|
||||
"description": "Index directory recursively and read all source files.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {"type": "string", "description": "Path to index"}
|
||||
},
|
||||
"properties": {"path": {"type": "string", "description": "Path to index"}},
|
||||
"required": ["path"],
|
||||
},
|
||||
},
|
||||
|
||||
+1
-3
@@ -81,9 +81,7 @@ def tail_process(pid: int, timeout: int = 30):
|
||||
"pid": pid,
|
||||
}
|
||||
|
||||
ready, _, _ = select.select(
|
||||
[process.stdout, process.stderr], [], [], 0.1
|
||||
)
|
||||
ready, _, _ = select.select([process.stdout, process.stderr], [], [], 0.1)
|
||||
for pipe in ready:
|
||||
if pipe == process.stdout:
|
||||
line = process.stdout.readline()
|
||||
|
||||
@@ -44,9 +44,7 @@ def db_query(query, db_conn):
|
||||
|
||||
if query.strip().upper().startswith("SELECT"):
|
||||
results = cursor.fetchall()
|
||||
columns = (
|
||||
[desc[0] for desc in cursor.description] if cursor.description else []
|
||||
)
|
||||
columns = [desc[0] for desc in cursor.description] if cursor.description else []
|
||||
return {"status": "success", "columns": columns, "rows": results}
|
||||
else:
|
||||
db_conn.commit()
|
||||
|
||||
+2
-8
@@ -61,9 +61,7 @@ def editor_insert_text(filepath, text, line=None, col=None, show_diff=True):
|
||||
with open(path) as f:
|
||||
old_content = f.read()
|
||||
|
||||
position = (line if line is not None else 0) * 1000 + (
|
||||
col if col is not None else 0
|
||||
)
|
||||
position = (line if line is not None else 0) * 1000 + (col if col is not None else 0)
|
||||
operation = track_edit("INSERT", filepath, start_pos=position, content=text)
|
||||
tracker.mark_in_progress(operation)
|
||||
|
||||
@@ -76,11 +74,7 @@ def editor_insert_text(filepath, text, line=None, col=None, show_diff=True):
|
||||
mux_name = f"editor-{path}"
|
||||
mux = get_multiplexer(mux_name)
|
||||
if mux:
|
||||
location = (
|
||||
f" at line {line}, col {col}"
|
||||
if line is not None and col is not None
|
||||
else ""
|
||||
)
|
||||
location = f" at line {line}, col {col}" if line is not None and col is not None else ""
|
||||
preview = text[:50] + "..." if len(text) > 50 else text
|
||||
mux.write_stdout(f"Inserted text{location}: {repr(preview)}\n")
|
||||
|
||||
|
||||
+9
-33
@@ -41,10 +41,7 @@ def write_file(filepath, content, db_conn=None, show_diff=True):
|
||||
from pr.tools.database import db_get
|
||||
|
||||
read_status = db_get("read:" + path, db_conn)
|
||||
if (
|
||||
read_status.get("status") != "success"
|
||||
or read_status.get("value") != "true"
|
||||
):
|
||||
if read_status.get("status") != "success" or read_status.get("value") != "true":
|
||||
return {
|
||||
"status": "error",
|
||||
"error": "File must be read before writing. Please read the file first.",
|
||||
@@ -54,9 +51,7 @@ def write_file(filepath, content, db_conn=None, show_diff=True):
|
||||
with open(path) as f:
|
||||
old_content = f.read()
|
||||
|
||||
operation = track_edit(
|
||||
"WRITE", filepath, content=content, old_content=old_content
|
||||
)
|
||||
operation = track_edit("WRITE", filepath, content=content, old_content=old_content)
|
||||
tracker.mark_in_progress(operation)
|
||||
|
||||
if show_diff and not is_new_file:
|
||||
@@ -119,9 +114,7 @@ def list_directory(path=".", recursive=False):
|
||||
}
|
||||
)
|
||||
for name in dirs:
|
||||
items.append(
|
||||
{"path": os.path.join(root, name), "type": "directory"}
|
||||
)
|
||||
items.append({"path": os.path.join(root, name), "type": "directory"})
|
||||
else:
|
||||
for item in os.listdir(path):
|
||||
item_path = os.path.join(path, item)
|
||||
@@ -129,11 +122,7 @@ def list_directory(path=".", recursive=False):
|
||||
{
|
||||
"name": item,
|
||||
"type": "directory" if os.path.isdir(item_path) else "file",
|
||||
"size": (
|
||||
os.path.getsize(item_path)
|
||||
if os.path.isfile(item_path)
|
||||
else None
|
||||
),
|
||||
"size": (os.path.getsize(item_path) if os.path.isfile(item_path) else None),
|
||||
}
|
||||
)
|
||||
return {"status": "success", "items": items}
|
||||
@@ -209,10 +198,7 @@ def search_replace(filepath, old_string, new_string, db_conn=None):
|
||||
from pr.tools.database import db_get
|
||||
|
||||
read_status = db_get("read:" + path, db_conn)
|
||||
if (
|
||||
read_status.get("status") != "success"
|
||||
or read_status.get("value") != "true"
|
||||
):
|
||||
if read_status.get("status") != "success" or read_status.get("value") != "true":
|
||||
return {
|
||||
"status": "error",
|
||||
"error": "File must be read before writing. Please read the file first.",
|
||||
@@ -259,19 +245,14 @@ def open_editor(filepath):
|
||||
return {"status": "error", "error": str(e)}
|
||||
|
||||
|
||||
def editor_insert_text(
|
||||
filepath, text, line=None, col=None, show_diff=True, db_conn=None
|
||||
):
|
||||
def editor_insert_text(filepath, text, line=None, col=None, show_diff=True, db_conn=None):
|
||||
try:
|
||||
path = os.path.expanduser(filepath)
|
||||
if db_conn:
|
||||
from pr.tools.database import db_get
|
||||
|
||||
read_status = db_get("read:" + path, db_conn)
|
||||
if (
|
||||
read_status.get("status") != "success"
|
||||
or read_status.get("value") != "true"
|
||||
):
|
||||
if read_status.get("status") != "success" or read_status.get("value") != "true":
|
||||
return {
|
||||
"status": "error",
|
||||
"error": "File must be read before writing. Please read the file first.",
|
||||
@@ -282,9 +263,7 @@ def editor_insert_text(
|
||||
with open(path) as f:
|
||||
old_content = f.read()
|
||||
|
||||
position = (line if line is not None else 0) * 1000 + (
|
||||
col if col is not None else 0
|
||||
)
|
||||
position = (line if line is not None else 0) * 1000 + (col if col is not None else 0)
|
||||
operation = track_edit("INSERT", filepath, start_pos=position, content=text)
|
||||
tracker.mark_in_progress(operation)
|
||||
|
||||
@@ -325,10 +304,7 @@ def editor_replace_text(
|
||||
from pr.tools.database import db_get
|
||||
|
||||
read_status = db_get("read:" + path, db_conn)
|
||||
if (
|
||||
read_status.get("status") != "success"
|
||||
or read_status.get("value") != "true"
|
||||
):
|
||||
if read_status.get("status") != "success" or read_status.get("value") != "true":
|
||||
return {
|
||||
"status": "error",
|
||||
"error": "File must be read before writing. Please read the file first.",
|
||||
|
||||
+2
-6
@@ -47,9 +47,7 @@ def get_knowledge_entry(entry_id: str) -> Dict[str, Any]:
|
||||
return {"status": "error", "error": str(e)}
|
||||
|
||||
|
||||
def search_knowledge(
|
||||
query: str, category: str = None, top_k: int = 5
|
||||
) -> Dict[str, Any]:
|
||||
def search_knowledge(query: str, category: str = None, top_k: int = 5) -> Dict[str, Any]:
|
||||
"""Search the knowledge base semantically."""
|
||||
try:
|
||||
db_path = os.path.expanduser("~/.assistant_db.sqlite")
|
||||
@@ -75,9 +73,7 @@ def get_knowledge_by_category(category: str, limit: int = 20) -> Dict[str, Any]:
|
||||
return {"status": "error", "error": str(e)}
|
||||
|
||||
|
||||
def update_knowledge_importance(
|
||||
entry_id: str, importance_score: float
|
||||
) -> Dict[str, Any]:
|
||||
def update_knowledge_importance(entry_id: str, importance_score: float) -> Dict[str, Any]:
|
||||
"""Update the importance score of a knowledge entry."""
|
||||
try:
|
||||
db_path = os.path.expanduser("~/.assistant_db.sqlite")
|
||||
|
||||
+3
-10
@@ -13,10 +13,7 @@ def apply_patch(filepath, patch_content, db_conn=None):
|
||||
from pr.tools.database import db_get
|
||||
|
||||
read_status = db_get("read:" + path, db_conn)
|
||||
if (
|
||||
read_status.get("status") != "success"
|
||||
or read_status.get("value") != "true"
|
||||
):
|
||||
if read_status.get("status") != "success" or read_status.get("value") != "true":
|
||||
return {
|
||||
"status": "error",
|
||||
"error": "File must be read before writing. Please read the file first.",
|
||||
@@ -68,9 +65,7 @@ def create_diff(
|
||||
else:
|
||||
lines1 = content1.splitlines(keepends=True)
|
||||
lines2 = content2.splitlines(keepends=True)
|
||||
diff = list(
|
||||
difflib.unified_diff(lines1, lines2, fromfile=fromfile, tofile=tofile)
|
||||
)
|
||||
diff = list(difflib.unified_diff(lines1, lines2, fromfile=fromfile, tofile=tofile))
|
||||
return {"status": "success", "diff": "".join(diff)}
|
||||
except Exception as e:
|
||||
return {"status": "error", "error": str(e)}
|
||||
@@ -94,9 +89,7 @@ def display_file_diff(filepath1, filepath2, format_type="unified", context_lines
|
||||
return {"status": "error", "error": str(e)}
|
||||
|
||||
|
||||
def display_content_diff(
|
||||
old_content, new_content, filename="file", format_type="unified"
|
||||
):
|
||||
def display_content_diff(old_content, new_content, filename="file", format_type="unified"):
|
||||
try:
|
||||
visual_diff = display_diff(old_content, new_content, filename, format_type)
|
||||
stats = get_diff_stats(old_content, new_content)
|
||||
|
||||
@@ -187,9 +187,7 @@ class PromptDetector:
|
||||
|
||||
# Detect prompts and determine new state
|
||||
detections = self.detect_prompt(output, process_type)
|
||||
new_state = self._determine_state_from_detections(
|
||||
detections, process_type, old_state
|
||||
)
|
||||
new_state = self._determine_state_from_detections(detections, process_type, old_state)
|
||||
|
||||
if new_state != old_state:
|
||||
session_state["transitions"].append(
|
||||
|
||||
Reference in New Issue
Block a user