@@ -182,8 +182,8 @@ func (a *PlanApp) defaultTaskEnricher(ctx context.Context, queries []string) (st
182182
183183 opts := knowledge .DefaultContextOptions ()
184184 opts .Query = query
185- opts .IncludeArchitectureMD = false // Too large for per-task context
186- opts .MaxNodes = 8 // Compact for task embedding
185+ opts .IncludeArchitectureMD = false // Included selectively for first task
186+ opts .MaxNodes = 20 // Richer context with batch embeddings
187187 opts .UseLLMQueries = false // Use queries directly for speed
188188
189189 memoryPath , _ := config .GetMemoryBasePath ()
@@ -679,7 +679,7 @@ func (a *PlanApp) Generate(ctx context.Context, opts GenerateOptions) (*Generate
679679 }
680680
681681 semanticResult := middleware .Validate (& planner.LLMPlanResponse {
682- GoalSummary : truncateString (opts .Goal , 100 ),
682+ GoalSummary : truncateString (opts .Goal , 500 ),
683683 Rationale : opts .EnrichedGoal ,
684684 Tasks : plannerTasks ,
685685 EstimatedComplexity : "medium" , // Default
@@ -863,165 +863,32 @@ func truncateString(s string, maxLen int) string {
863863 return s [:maxLen ]
864864}
865865
866- // Audit runs verification on a completed plan.
867- func (a * PlanApp ) Audit (ctx context.Context , opts AuditOptions ) (* AuditResult , error ) {
868- repo := a .Repo
869- llmCfg := a .ctx .LLMCfg
870-
871- // Determine which plan to audit
872- var plan * task.Plan
873- var err error
874-
875- if opts .PlanID != "" {
876- plan , err = repo .GetPlan (opts .PlanID )
877- if err != nil {
878- return & AuditResult {
879- Success : false ,
880- Message : fmt .Sprintf ("Failed to get plan: %v" , err ),
881- }, nil
882- }
883- } else {
884- plan , err = repo .GetActivePlan ()
885- if err != nil {
886- return & AuditResult {
887- Success : false ,
888- Message : fmt .Sprintf ("Failed to get active plan: %v" , err ),
889- }, nil
890- }
891- }
892-
893- if plan == nil {
894- return & AuditResult {
895- Success : false ,
896- Message : "No plan found. Create a plan first with plan action=clarify and then plan action=generate." ,
897- Hint : "Use plan action=clarify to start defining your development goal." ,
898- }, nil
899- }
900-
901- // Check if plan has completed tasks
902- completedCount := 0
903- for _ , t := range plan .Tasks {
904- if t .Status == task .StatusCompleted {
905- completedCount ++
906- }
907- }
908-
909- if completedCount == 0 {
910- return & AuditResult {
911- Success : false ,
912- PlanID : plan .ID ,
913- Message : "No completed tasks to impl. Complete tasks first." ,
914- Hint : "Use task action=next to get the next pending task." ,
915- }, nil
916- }
917-
918- // Get working directory
919- workDir , _ := os .Getwd ()
920-
921- // Create audit service
922- auditService := impl .NewService (workDir , llmCfg )
923-
924- if ! opts .AutoFix {
925- auditResult , err := auditService .Audit (ctx , plan )
926- if err != nil {
927- return & AuditResult {
928- Success : false ,
929- PlanID : plan .ID ,
930- Message : fmt .Sprintf ("Audit failed: %v" , err ),
931- }, nil
932- }
933-
934- result := & AuditResult {
935- Success : true ,
936- PlanID : plan .ID ,
937- RetryCount : 1 ,
938- BuildPassed : auditResult .BuildResult .Passed ,
939- TestsPassed : auditResult .TestResult .Passed ,
940- SemanticIssues : auditResult .SemanticResult .Issues ,
941- }
942-
943- // Update plan status in database
944- var newStatus task.PlanStatus
945- if auditResult .Status == "passed" {
946- result .Status = "verified"
947- newStatus = task .PlanStatusVerified
948- result .Message = "Plan verified successfully. All checks passed."
949- result .Hint = "The plan is complete and verified. You can create a PR or start a new plan."
950- } else {
951- result .Status = "needs_revision"
952- newStatus = task .PlanStatusNeedsRevision
953- result .Message = "Plan needs revision. One or more checks failed."
954- result .Hint = "Review the failed checks and fix them, then run audit again."
955- }
956- result .PlanStatus = newStatus
957-
958- // Store audit report
959- report := task.AuditReport {
960- Status : auditResult .Status ,
961- BuildOutput : auditResult .BuildResult .Output ,
962- TestOutput : auditResult .TestResult .Output ,
963- SemanticIssues : auditResult .SemanticResult .Issues ,
964- RetryCount : 1 ,
965- CompletedAt : time .Now ().UTC (),
966- }
967- if ! auditResult .BuildResult .Passed && auditResult .BuildResult .Error != "" {
968- report .ErrorMessage = "Build failed: " + auditResult .BuildResult .Error
969- } else if ! auditResult .TestResult .Passed && auditResult .TestResult .Error != "" {
970- report .ErrorMessage = "Tests failed: " + auditResult .TestResult .Error
971- }
972- reportJSON , marshalErr := json .Marshal (report )
973- if marshalErr == nil {
974- _ = repo .UpdatePlanAuditReport (plan .ID , newStatus , string (reportJSON ))
975- }
976-
977- return result , nil
866+ // loadArchitectureMD reads .taskwing/ARCHITECTURE.md for the current project.
867+ // Caps at 8000 chars to avoid blowing up the first task's context.
868+ func loadArchitectureMD () string {
869+ memoryPath , err := config .GetMemoryBasePath ()
870+ if err != nil || memoryPath == "" {
871+ return ""
978872 }
979-
980- // Run audit with auto-fix
981- autoFixResult , err := auditService .AuditWithAutoFix (ctx , plan )
873+ basePath := filepath .Dir (filepath .Dir (memoryPath ))
874+ content , err := os .ReadFile (filepath .Join (basePath , ".taskwing" , "ARCHITECTURE.md" ))
982875 if err != nil {
983- return & AuditResult {
984- Success : false ,
985- PlanID : plan .ID ,
986- Message : fmt .Sprintf ("Audit failed: %v" , err ),
987- }, nil
876+ return ""
988877 }
989-
990- result := & AuditResult {
991- Success : true ,
992- PlanID : plan .ID ,
993- Status : autoFixResult .FinalStatus ,
994- RetryCount : autoFixResult .Attempts ,
995- }
996- result .FixesApplied = autoFixResult .FixesApplied
997-
998- if autoFixResult .FinalAudit != nil {
999- result .BuildPassed = autoFixResult .FinalAudit .BuildResult .Passed
1000- result .TestsPassed = autoFixResult .FinalAudit .TestResult .Passed
1001- result .SemanticIssues = autoFixResult .FinalAudit .SemanticResult .Issues
1002- }
1003-
1004- // Update plan status in database
1005- var newStatus task.PlanStatus
1006- if autoFixResult .FinalStatus == "verified" {
1007- newStatus = task .PlanStatusVerified
1008- result .Message = "Plan verified successfully. All checks passed."
1009- result .Hint = "The plan is complete and verified. You can create a PR or start a new plan."
1010- } else {
1011- newStatus = task .PlanStatusNeedsRevision
1012- result .Message = fmt .Sprintf ("Plan needs revision after %d fix attempts." , autoFixResult .Attempts )
1013- result .Hint = "Review the semantic issues and fix them manually, then run audit again."
1014- }
1015- result .PlanStatus = newStatus
1016-
1017- // Store audit report
1018- auditReport := autoFixResult .ToAuditReportWithFixes ()
1019- reportJSON , marshalErr := json .Marshal (auditReport )
1020- if marshalErr == nil {
1021- _ = repo .UpdatePlanAuditReport (plan .ID , newStatus , string (reportJSON ))
878+ const maxArchLen = 8000
879+ if len (content ) > maxArchLen {
880+ content = append (content [:maxArchLen ], []byte ("\n ...[truncated]" )... )
1022881 }
882+ return string (content )
883+ }
1023884
1024- return result , nil
885+ // Audit runs verification on a completed plan.
886+ func (a * PlanApp ) Audit (_ context.Context , _ AuditOptions ) (* AuditResult , error ) {
887+ return & AuditResult {
888+ Success : false ,
889+ Message : "Audit service has been removed. Use your AI tool's built-in verification instead." ,
890+ Hint : "Run your project's build and test commands directly to verify plan completion." ,
891+ }, nil
1025892}
1026893
1027894// parseQuestionsFromMetadata extracts questions from agent metadata,
@@ -1141,6 +1008,13 @@ func (a *PlanApp) parseTasksFromMetadata(ctx context.Context, metadata map[strin
11411008 }
11421009 }
11431010
1011+ // First task gets ARCHITECTURE.md for full architectural context
1012+ if i == 0 {
1013+ if archContent := loadArchitectureMD (); archContent != "" {
1014+ t .ContextSummary = "## Architecture Overview\n " + archContent + "\n \n " + t .ContextSummary
1015+ }
1016+ }
1017+
11441018 tasks = append (tasks , t )
11451019 titleToID [pt .Title ] = id
11461020
@@ -1228,6 +1102,13 @@ func (a *PlanApp) parseTasksFromMetadata(ctx context.Context, metadata map[strin
12281102 }
12291103 }
12301104
1105+ // First task gets ARCHITECTURE.md for full architectural context
1106+ if i == 0 {
1107+ if archContent := loadArchitectureMD (); archContent != "" {
1108+ newTask .ContextSummary = "## Architecture Overview\n " + archContent + "\n \n " + newTask .ContextSummary
1109+ }
1110+ }
1111+
12311112 tasks = append (tasks , newTask )
12321113 titleToID [title ] = id
12331114
0 commit comments