@hunyed15/codecgc 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import asyncio
|
|
6
|
+
import functools
|
|
5
7
|
import json
|
|
6
8
|
import os
|
|
7
9
|
import queue
|
|
@@ -134,12 +136,11 @@ def _validate_backend_target_paths(target_paths: List[Path]) -> tuple[bool, List
|
|
|
134
136
|
return True, policy_checks, ""
|
|
135
137
|
|
|
136
138
|
|
|
137
|
-
def run_shell_command(cmd: list[str]
|
|
139
|
+
def run_shell_command(cmd: list[str]) -> Generator[str, None, None]:
|
|
138
140
|
"""Execute a command and stream its output line-by-line.
|
|
139
141
|
|
|
140
142
|
Args:
|
|
141
143
|
cmd: Command and arguments as a list (e.g., ["codex", "exec", "prompt"])
|
|
142
|
-
cwd: Optional working directory for the command
|
|
143
144
|
|
|
144
145
|
Yields:
|
|
145
146
|
Output lines from the command
|
|
@@ -158,7 +159,6 @@ def run_shell_command(cmd: list[str], cwd: Optional[Path] = None) -> Generator[s
|
|
|
158
159
|
stderr=subprocess.STDOUT,
|
|
159
160
|
universal_newlines=True,
|
|
160
161
|
encoding='utf-8',
|
|
161
|
-
cwd=str(cwd) if cwd else None, # 添加 cwd 参数,确保在正确的工作目录中运行
|
|
162
162
|
)
|
|
163
163
|
|
|
164
164
|
output_queue: queue.Queue[str | None] = queue.Queue()
|
|
@@ -265,7 +265,7 @@ def _execute_codex_session(
|
|
|
265
265
|
err_message = ""
|
|
266
266
|
thread_id: Optional[str] = None
|
|
267
267
|
|
|
268
|
-
for line in run_shell_command(cmd
|
|
268
|
+
for line in run_shell_command(cmd):
|
|
269
269
|
try:
|
|
270
270
|
line_dict = json.loads(line.strip())
|
|
271
271
|
all_messages.append(line_dict)
|
|
@@ -409,17 +409,20 @@ async def codex(
|
|
|
409
409
|
] = "",
|
|
410
410
|
) -> Dict[str, Any]:
|
|
411
411
|
"""Execute a Codex CLI session and return the results."""
|
|
412
|
-
return
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
412
|
+
return await asyncio.to_thread(
|
|
413
|
+
functools.partial(
|
|
414
|
+
_execute_codex_session,
|
|
415
|
+
prompt=PROMPT,
|
|
416
|
+
cd=cd,
|
|
417
|
+
sandbox=sandbox,
|
|
418
|
+
session_id=SESSION_ID,
|
|
419
|
+
skip_git_repo_check=skip_git_repo_check,
|
|
420
|
+
return_all_messages=return_all_messages,
|
|
421
|
+
image=image,
|
|
422
|
+
model=model,
|
|
423
|
+
yolo=yolo,
|
|
424
|
+
profile=profile,
|
|
425
|
+
)
|
|
423
426
|
)
|
|
424
427
|
|
|
425
428
|
|
|
@@ -495,17 +498,20 @@ async def implement_backend_task(
|
|
|
495
498
|
constraints=constraints,
|
|
496
499
|
acceptance_criteria=acceptance_criteria,
|
|
497
500
|
)
|
|
498
|
-
result =
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
501
|
+
result = await asyncio.to_thread(
|
|
502
|
+
functools.partial(
|
|
503
|
+
_execute_codex_session,
|
|
504
|
+
prompt=prompt,
|
|
505
|
+
cd=cd,
|
|
506
|
+
sandbox=sandbox,
|
|
507
|
+
session_id=SESSION_ID,
|
|
508
|
+
skip_git_repo_check=True,
|
|
509
|
+
return_all_messages=return_all_messages,
|
|
510
|
+
image=[],
|
|
511
|
+
model=model,
|
|
512
|
+
yolo=False,
|
|
513
|
+
profile=profile,
|
|
514
|
+
)
|
|
509
515
|
)
|
|
510
516
|
|
|
511
517
|
if not result.get("success"):
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import asyncio
|
|
6
|
+
import functools
|
|
5
7
|
import json
|
|
6
8
|
import os
|
|
7
9
|
import queue
|
|
@@ -359,13 +361,16 @@ async def gemini(
|
|
|
359
361
|
] = "",
|
|
360
362
|
) -> Dict[str, Any]:
|
|
361
363
|
"""Execute a gemini CLI session and return the results."""
|
|
362
|
-
return
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
364
|
+
return await asyncio.to_thread(
|
|
365
|
+
functools.partial(
|
|
366
|
+
_execute_gemini_session,
|
|
367
|
+
prompt=PROMPT,
|
|
368
|
+
cd=cd,
|
|
369
|
+
sandbox=sandbox,
|
|
370
|
+
session_id=SESSION_ID,
|
|
371
|
+
return_all_messages=return_all_messages,
|
|
372
|
+
model=model,
|
|
373
|
+
)
|
|
369
374
|
)
|
|
370
375
|
|
|
371
376
|
|
|
@@ -433,13 +438,16 @@ async def implement_frontend_task(
|
|
|
433
438
|
constraints=constraints,
|
|
434
439
|
acceptance_criteria=acceptance_criteria,
|
|
435
440
|
)
|
|
436
|
-
result =
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
result = await asyncio.to_thread(
|
|
442
|
+
functools.partial(
|
|
443
|
+
_execute_gemini_session,
|
|
444
|
+
prompt=prompt,
|
|
445
|
+
cd=cd,
|
|
446
|
+
sandbox=sandbox,
|
|
447
|
+
session_id=SESSION_ID,
|
|
448
|
+
return_all_messages=return_all_messages,
|
|
449
|
+
model=model,
|
|
450
|
+
)
|
|
443
451
|
)
|
|
444
452
|
|
|
445
453
|
if not result.get("success"):
|