Commit 176a063
fix(agent): use monorepo analyzer to detect ALL projects instead of flat analysis
BREAKING CHANGE: Agent now correctly identifies all projects in monorepos
## Problem
The agent's `analyze_project` tool was calling `analyze_project()` which
returns a flat `ProjectAnalysis` structure with only ~5 detected services.
Meanwhile, the CLI's `sync-ctl analyze .` was calling `analyze_monorepo()`
which correctly returns `MonorepoAnalysis` with all 42 projects.
This caused the agent to miss the vast majority of projects when analyzing
monorepo codebases, leading to incomplete and misleading analysis results.
## Solution
Changed `AnalyzeTool` to call `analyze_monorepo()` instead of `analyze_project()`.
This returns `MonorepoAnalysis` which includes:
- `is_monorepo`: Boolean flag for monorepo detection
- `projects`: Array of ALL detected projects with full analysis
- `technology_summary`: Aggregated languages, frameworks, databases
- `metadata`: Analysis timing and confidence scores
Each project in the array contains:
- `name`: Project name (from package.json, Cargo.toml, etc.)
- `path`: Relative path from monorepo root
- `project_category`: Frontend/Backend/Api/Service/Library/etc.
- `analysis`: Full `ProjectAnalysis` for that specific project
## Additional Improvements
### Smart Compression (compression.rs)
- Added `failures` field to `extract_issues()` for lint tools (kubelint,
hadolint, dclint, helmlint)
- Updated `compress_analysis_output()` to handle both output types:
- MonorepoAnalysis: Extracts project_names, languages, frameworks
- ProjectAnalysis: Extracts from flat structure (languages at top level)
- Added `services_detected` array with service names (not just count)
### Smart Retrieval (output_store.rs)
- Added `OutputType` enum for type detection:
- MonorepoAnalysis, ProjectAnalysis, LintResult, OptimizationResult, Generic
- Added `detect_output_type()` function for routing retrieval
- Added section-based queries for analyze_project outputs:
- `section:summary` - Project overview
- `section:projects` - List all projects with basic info
- `section:languages` - All detected languages
- `section:frameworks` - All detected frameworks
- `section:services` - All detected services
- `project:<name>` - Get specific project details
- `language:<name>` - Language details with file counts
- `framework:<name>` - Framework/technology details
- `compact:true` - Compacted output (default)
- File arrays are replaced with file_count to reduce context size
### Retrieval Tool (retrieve.rs)
- Updated tool description to document all query options
- Added examples for both lint tools and analyze_project outputs
### Error Display (streaming.rs)
- Fixed nested error message display (ToolCallError: ToolCallError: ...)
- Cleans up error messages for better readability
## Files Changed
- src/agent/tools/analyze.rs - Use analyze_monorepo() (1 line)
- src/agent/tools/compression.rs - Handle both output types
- src/agent/tools/output_store.rs - Smart retrieval with section queries
- src/agent/tools/retrieve.rs - Document query options
- src/agent/ui/streaming.rs - Clean error messages
## Testing
- All 884 tests pass
- Build succeeds with only minor warnings (unrelated dead code)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 6dd8e23 commit 176a063
5 files changed
Lines changed: 924 additions & 97 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
| |||
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
468 | 475 | | |
469 | 476 | | |
470 | 477 | | |
471 | 478 | | |
472 | 479 | | |
473 | 480 | | |
474 | | - | |
475 | | - | |
| 481 | + | |
| 482 | + | |
476 | 483 | | |
477 | | - | |
478 | | - | |
| 484 | + | |
| 485 | + | |
479 | 486 | | |
480 | | - | |
481 | | - | |
| 487 | + | |
| 488 | + | |
482 | 489 | | |
483 | 490 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 491 | + | |
499 | 492 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
521 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
522 | 512 | | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
530 | 535 | | |
531 | 536 | | |
532 | | - | |
533 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
534 | 553 | | |
535 | 554 | | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
551 | 583 | | |
552 | 584 | | |
553 | 585 | | |
554 | 586 | | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
574 | 616 | | |
575 | 617 | | |
576 | 618 | | |
577 | 619 | | |
578 | | - | |
579 | | - | |
| 620 | + | |
| 621 | + | |
580 | 622 | | |
581 | 623 | | |
582 | 624 | | |
583 | 625 | | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
589 | 633 | | |
590 | 634 | | |
591 | 635 | | |
| |||
0 commit comments