fix(planning-agent): relax task parser regex and inject Prior Analysis into CLI context

1. extractStructuredTasks regex: /### (TASK-\d+|T\d+):/ was too strict,
   failing when Gemini outputs fewer #'s or omits colon. Relaxed to
   /#{1,3}\s*(TASK-\d+|T\d+):?\s*/ to tolerate format variations.

2. CLI Command Template CONTEXT field: added explicit instruction to use
   Prior Analysis from task description as primary planning context when
   exploration files are absent.
This commit is contained in:
catlog22
2026-03-02 16:28:10 +08:00
parent 4f3ef5cba8
commit a4cb1e7eb2

View File

@@ -174,7 +174,7 @@ TASK:
• Identify dependencies and execution phases • Identify dependencies and execution phases
• Generate complexity-appropriate fields (rationale, verification, risks, code_skeleton, data_flow) • Generate complexity-appropriate fields (rationale, verification, risks, code_skeleton, data_flow)
MODE: analysis MODE: analysis
CONTEXT: @**/* | Memory: {context_summary} CONTEXT: @**/* | Memory: {context_summary}. If task description contains '## Prior Analysis', treat it as primary planning context with pre-analyzed files, findings, and recommendations.
EXPECTED: EXPECTED:
## Summary ## Summary
[overview] [overview]
@@ -257,8 +257,8 @@ function extractSection(cliOutput, header) {
// Parse structured tasks from CLI output // Parse structured tasks from CLI output
function extractStructuredTasks(cliOutput, complexity) { function extractStructuredTasks(cliOutput, complexity) {
const tasks = [] const tasks = []
// Split by task headers (supports both TASK-NNN and T\d+ formats) // Split by task headers (flexible: 1-3 #, optional colon, supports TASK-NNN and T\d+)
const taskBlocks = cliOutput.split(/### (TASK-\d+|T\d+):/).slice(1) const taskBlocks = cliOutput.split(/#{1,3}\s*(TASK-\d+|T\d+):?\s*/).slice(1)
for (let i = 0; i < taskBlocks.length; i += 2) { for (let i = 0; i < taskBlocks.length; i += 2) {
const rawId = taskBlocks[i].trim() const rawId = taskBlocks[i].trim()