Show implementation plan before generated code
Browse files- Display plan section after result table, before code
- Plan is shown for both new tasks and resume flows
- Helps users understand what was planned before seeing code
- Dockerfile +1 -1
- chainlit_app.py +25 -8
Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# HuggingFace Spaces Dockerfile for CodePilot
|
| 2 |
-
# BUILD_VERSION:
|
| 3 |
FROM python:3.11-slim
|
| 4 |
|
| 5 |
# Set working directory
|
|
|
|
| 1 |
# HuggingFace Spaces Dockerfile for CodePilot
|
| 2 |
+
# BUILD_VERSION: 18 (v3.4.1 show-plan - display implementation plan before code)
|
| 3 |
FROM python:3.11-slim
|
| 4 |
|
| 5 |
# Set working directory
|
chainlit_app.py
CHANGED
|
@@ -22,8 +22,8 @@ from concurrent.futures import ThreadPoolExecutor
|
|
| 22 |
# ============================================================
|
| 23 |
# STARTUP VERSION CHECK - Change this to detect if rebuild worked
|
| 24 |
# ============================================================
|
| 25 |
-
APP_VERSION = "3.4.
|
| 26 |
-
BUILD_ID = "2024-12-20-
|
| 27 |
print("=" * 60)
|
| 28 |
print(f"[STARTUP] CodePilot Chainlit App")
|
| 29 |
print(f"[STARTUP] APP_VERSION: {APP_VERSION}")
|
|
@@ -106,6 +106,7 @@ def parse_agent_status(logs: str) -> dict:
|
|
| 106 |
'reviewer_done': False,
|
| 107 |
'approved': None,
|
| 108 |
'tools_called': [],
|
|
|
|
| 109 |
}
|
| 110 |
|
| 111 |
for line in logs.split('\n'):
|
|
@@ -224,6 +225,18 @@ def format_final_result(result: dict, total_cost: float) -> str:
|
|
| 224 |
return "\n".join(lines)
|
| 225 |
|
| 226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
@cl.on_chat_start
|
| 228 |
async def start():
|
| 229 |
"""Initialize the agent system when chat starts."""
|
|
@@ -372,7 +385,11 @@ async def main(message: cl.Message):
|
|
| 372 |
# Show final result
|
| 373 |
await cl.Message(content=format_final_result(result, total_cost)).send()
|
| 374 |
|
| 375 |
-
# Show
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
if result.get('code_changes'):
|
| 377 |
await cl.Message(content="## Generated Code\n\n" + format_code_output(result['code_changes'])).send()
|
| 378 |
return
|
|
@@ -467,14 +484,14 @@ AVAILABLE TOOLS:
|
|
| 467 |
# Show final result
|
| 468 |
await cl.Message(content=format_final_result(result, total_cost)).send()
|
| 469 |
|
| 470 |
-
# Show
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
if result.get('code_changes'):
|
| 472 |
await cl.Message(content="## Generated Code\n\n" + format_code_output(result['code_changes'])).send()
|
| 473 |
|
| 474 |
-
# Show plan if available
|
| 475 |
-
if result.get('plan') and not result.get('code_changes'):
|
| 476 |
-
await cl.Message(content=f"## Plan\n\n{result['plan']}").send()
|
| 477 |
-
|
| 478 |
|
| 479 |
if __name__ == "__main__":
|
| 480 |
sys.exit("Run with: chainlit run chainlit_app.py")
|
|
|
|
| 22 |
# ============================================================
|
| 23 |
# STARTUP VERSION CHECK - Change this to detect if rebuild worked
|
| 24 |
# ============================================================
|
| 25 |
+
APP_VERSION = "3.4.1-show-plan"
|
| 26 |
+
BUILD_ID = "2024-12-20-v2"
|
| 27 |
print("=" * 60)
|
| 28 |
print(f"[STARTUP] CodePilot Chainlit App")
|
| 29 |
print(f"[STARTUP] APP_VERSION: {APP_VERSION}")
|
|
|
|
| 106 |
'reviewer_done': False,
|
| 107 |
'approved': None,
|
| 108 |
'tools_called': [],
|
| 109 |
+
'plan_preview': None,
|
| 110 |
}
|
| 111 |
|
| 112 |
for line in logs.split('\n'):
|
|
|
|
| 225 |
return "\n".join(lines)
|
| 226 |
|
| 227 |
|
| 228 |
+
def format_plan_display(plan: str) -> str:
|
| 229 |
+
"""Format the implementation plan for display."""
|
| 230 |
+
if not plan:
|
| 231 |
+
return ""
|
| 232 |
+
|
| 233 |
+
lines = ["## Implementation Plan\n"]
|
| 234 |
+
lines.append(plan)
|
| 235 |
+
lines.append("")
|
| 236 |
+
|
| 237 |
+
return "\n".join(lines)
|
| 238 |
+
|
| 239 |
+
|
| 240 |
@cl.on_chat_start
|
| 241 |
async def start():
|
| 242 |
"""Initialize the agent system when chat starts."""
|
|
|
|
| 385 |
# Show final result
|
| 386 |
await cl.Message(content=format_final_result(result, total_cost)).send()
|
| 387 |
|
| 388 |
+
# Show plan first
|
| 389 |
+
if result.get('plan'):
|
| 390 |
+
await cl.Message(content=format_plan_display(result['plan'])).send()
|
| 391 |
+
|
| 392 |
+
# Then show code
|
| 393 |
if result.get('code_changes'):
|
| 394 |
await cl.Message(content="## Generated Code\n\n" + format_code_output(result['code_changes'])).send()
|
| 395 |
return
|
|
|
|
| 484 |
# Show final result
|
| 485 |
await cl.Message(content=format_final_result(result, total_cost)).send()
|
| 486 |
|
| 487 |
+
# Show plan first
|
| 488 |
+
if result.get('plan'):
|
| 489 |
+
await cl.Message(content=format_plan_display(result['plan'])).send()
|
| 490 |
+
|
| 491 |
+
# Then show generated code
|
| 492 |
if result.get('code_changes'):
|
| 493 |
await cl.Message(content="## Generated Code\n\n" + format_code_output(result['code_changes'])).send()
|
| 494 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
|
| 496 |
if __name__ == "__main__":
|
| 497 |
sys.exit("Run with: chainlit run chainlit_app.py")
|