-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
80 lines (72 loc) · 2.52 KB
/
Copy pathmain.py
File metadata and controls
80 lines (72 loc) · 2.52 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import argparse
import asyncio
from pathlib import Path
from qoder_agent_sdk import (
AgentDefinition,
AssistantMessage,
QoderAgentOptions,
ResultMessage,
TextBlock,
access_token_from_env,
query,
)
AGENTS = {
"architecture-explorer": AgentDefinition(
description="Maps the repository architecture and important boundaries.",
prompt=(
"Inspect the repository with read-only tools. Report the main modules, "
"their responsibilities, dependencies, and architectural risks. Do not "
"modify files."
),
tools=["Read", "Glob", "Grep"],
maxTurns=5,
),
"test-strategist": AgentDefinition(
description="Evaluates the test strategy for a proposed migration.",
prompt=(
"Inspect tests and production code with read-only tools. Identify "
"critical behaviors, coverage gaps, and a practical migration "
"verification plan. Do not modify files."
),
tools=["Read", "Glob", "Grep"],
maxTurns=5,
),
}
async def run(workspace: Path) -> None:
options = QoderAgentOptions(
auth=access_token_from_env(),
cwd=workspace,
model="auto",
agents=AGENTS,
tools=["Agent"],
allowed_tools=["Agent"],
max_turns=8,
)
prompt = (
"Ask architecture-explorer to map the repository, then ask test-strategist "
"to design verification for a major dependency upgrade. Synthesize their "
"findings into a concise migration plan with ordered steps and risks."
)
completed = False
async for message in query(prompt=prompt, options=options):
if isinstance(message, AssistantMessage):
for block in message.content:
if isinstance(block, TextBlock):
print(block.text, end="", flush=True)
elif isinstance(message, ResultMessage):
if message.subtype != "success":
raise RuntimeError("\n".join(message.errors or [message.subtype]))
completed = True
if not completed:
raise RuntimeError("The query ended without a success result.")
print()
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("workspace", nargs="?", type=Path, default=Path.cwd())
args = parser.parse_args()
asyncio.run(run(args.workspace.resolve()))
if __name__ == "__main__":
try:
main()
except (RuntimeError, OSError) as error:
raise SystemExit(str(error)) from error