getappmap / appmap-js

Client libraries for AppMap
48 stars 17 forks source link

feat: Diagram agent #1873

Closed kgilpin closed 2 months ago

kgilpin commented 2 months ago

Adds @diagram agent mode, with built-in prompts for entity-relationship, flowchart, and class map diagrams.

  1. [ ] Diagram Generation Mode: Introduced a new AgentMode called Diagram for generating software diagrams (flowcharts, ER diagrams, UML class diagrams).
  2. [ ] DiagramAgent: Created a new DiagramAgent class for handling diagram generation requests.
  3. [ ] Agent Selection for Diagrams: Updated AgentSelectionService to handle @diagram mode requests.
  4. [ ] Mermaid Library Integration: Added mermaid library dependency for diagram rendering.
  5. [ ] MermaidValidator: Added MermaidValidator to validate Mermaid diagram syntax.
  6. [ ] MermaidFilter: Implemented MermaidFilter to parse and validate Mermaid diagram syntax. Tokens are withheld from the LLM until a complete diagram is received, then the diagram is validated and potentially fixed.
  7. [ ] Mermaid Fixer Service: Added MermaidFixerService for repairing Mermaid diagrams.
  8. [ ] Filter Interface and NopFilter: Defined a Filter interface and a NopFilter class. These exist to support MermaidFilter.
  9. [ ] Agent Filters: Enabled agents to return filters for processing output through the newFilter method.
  10. [ ] Command Warning Enhancements: Added color-coded warnings for questions and classifications in ExplainCommand.
  11. [ ] Explain Agent Updates: Modified the ExplainAgent to include diagram prompt checking and added capability to generate diagrams.
  12. [ ] Classification Service Update: Modified ClassificationService to handle the new classification label, and distinguish between modes and scopes.
  13. [ ] Context Label Update: Updated ContextV2.ContextLabelName and ContextV2.ContextLabelWeight to handle new diagram generation labels.

Example of diagram output

Class map of deferred tax
classDiagram
  direction LR

  class DeferredTax {
      +pricing_policy(product: Product, stockrecord: StockRecord) : Price
      +parent_pricing_policy(product: Product, children_stock: List~StockRecord~) : Price
  }
  class Product {
  }
  class StockRecord {
  }
  class Price {
  }

  class FixedPrice {
      +currency: str
      +excl_tax: Decimal
  }
  FixedPrice --> Price

  class UnavailablePrice {
  }
  UnavailablePrice --> Price

  DeferredTax --> Product
  DeferredTax --> StockRecord
  DeferredTax --> Price
appland-release commented 2 months ago

:tada: This PR is included in version @appland/navie-v1.19.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

appland-release commented 2 months ago

:tada: This PR is included in version @appland/appmap-v3.152.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: