Skip to content

Commit 0f31f20

Browse files
committed
feat: add semantic analysis tools for finding references and symbols
- Implemented `find-references.tool.ts` to locate all references to a symbol across the codebase using TypeScript/JavaScript and Python analysis. - Created `find-symbol.tool.ts` to find symbol definitions (functions, classes, variables) across the codebase with support for filtering by symbol type. - Introduced `semantic-utils.ts` for managing project caching and Python code analysis, including a `PythonParser` for extracting symbols and calculating complexity. - Updated `index.ts` to export new tools and utilities for semantic analysis. - Developed `repo-ingestion-workflow.ts` to scan and ingest files from local or GitHub repositories, processing them into chunks for further analysis. - Created `spec-generation-workflow.ts` to generate project specifications, including planning, PRD, architecture, and task generation using a structured agent approach.
1 parent 17f128c commit 0f31f20

26 files changed

Lines changed: 2300 additions & 62 deletions

README.md

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,52 @@ graph TB
115115
style UI fill:#e8f5e9
116116
```
117117

118+
## 📊 **System Flowchart**
119+
120+
```mermaid
121+
flowchart TD
122+
A[app/chat] -->|components|< B[chat-header.tsx]
123+
A -->|components|< C[chat-messages.tsx]
124+
A -->|components|< D[chat-input.tsx]
125+
A -->|config|< E[agents.ts]
126+
A -->|providers|< F[chat-context.tsx]
127+
128+
G[app/networks] -->|components|< H[network-header.tsx]
129+
G -->|components|< I[network-messages.tsx]
130+
G -->|config|< J[networks.ts]
131+
G -->|providers|< K[network-context.tsx]
132+
133+
L[app/workflows] -->|components|< M[workflow-canvas.tsx]
134+
L -->|components|< N[workflow-header.tsx]
135+
L -->|config|< O[workflows.ts]
136+
L -->|providers|< P[workflow-context.tsx]
137+
138+
Q[app/dashboard] -->|components|< R[dashboard.tsx]
139+
Q -->|components|< S[agent-list.tsx]
140+
Q -->|providers|< T[dashboard-context.tsx]
141+
142+
U[lib] -->|hooks|< V[use-mastra.ts]
143+
U -->|hooks|< W[use-dashboard-queries.ts]
144+
U -->|utils|< X[utils.ts]
145+
U -->|client|< Y[mastra-client.ts]
146+
147+
Z[src/types] -->|api|< AA[mastra-api.ts]
148+
149+
AB[src/mastra/index.ts] -->|imports|< AC[agents/*]
150+
AB -->|imports|< AD[tools/*]
151+
AB -->|imports|< AE[workflows/*]
152+
AB -->|imports|< AF[networks/*]
153+
AB -->|imports|< AG[config/*]
154+
155+
style A fill:#e8f5e9,stroke:#81c784
156+
style G fill:#e8f5e9,stroke:#81c784
157+
style L fill:#e8f5e9,stroke:#81c784
158+
style Q fill:#e8f5e9,stroke:#81c784
159+
style U fill:#e3f2fd,stroke:#64b5f6
160+
style Z fill:#e3f2fd,stroke:#64b5f6
161+
style AB fill:#fff3e0,stroke:#ff9800
162+
```
163+
118164
## 🔄 **RAG Pipeline (Production-Grade)**
119165

120166
```mermaid
@@ -223,6 +269,77 @@ npm run build
223269
npm run start
224270
```
225271

272+
## 📊 **System Flowchart**
273+
274+
```mermaid
275+
flowchart TD
276+
A[app/chat] -->|components|< B[chat-header.tsx]
277+
A -->|components|< C[chat-messages.tsx]
278+
A -->|components|< D[chat-input.tsx]
279+
A -->|config|< E[agents.ts]
280+
A -->|providers|< F[chat-context.tsx]
281+
282+
G[app/networks] -->|components|< H[network-header.tsx]
283+
G -->|components|< I[network-messages.tsx]
284+
G -->|config|< J[networks.ts]
285+
G -->|providers|< K[network-context.tsx]
286+
287+
L[app/workflows] -->|components|< M[workflow-canvas.tsx]
288+
L -->|components|< N[workflow-header.tsx]
289+
L -->|config|< O[workflows.ts]
290+
L -->|providers|< P[workflow-context.tsx]
291+
292+
Q[app/dashboard] -->|components|< R[dashboard.tsx]
293+
Q -->|components|< S[agent-list.tsx]
294+
Q -->|providers|< T[dashboard-context.tsx]
295+
296+
U[lib] -->|hooks|< V[use-mastra.ts]
297+
U -->|hooks|< W[use-dashboard-queries.ts]
298+
U -->|utils|< X[utils.ts]
299+
U -->|client|< Y[mastra-client.ts]
300+
301+
Z[src/types] -->|api|< AA[mastra-api.ts]
302+
303+
AB[src/mastra/index.ts] -->|imports|< AC[agents/*]
304+
AB -->|imports|< AD[tools/*]
305+
AB -->|imports|< AE[workflows/*]
306+
AB -->|imports|< AF[networks/*]
307+
AB -->|imports|< AG[config/*]
308+
309+
style A fill:#e8f5e9,stroke:#81c784
310+
style G fill:#e8f5e9,stroke:#81c784
311+
style L fill:#e8f5e9,stroke:#81c784
312+
style Q fill:#e8f5e9,stroke:#81c784
313+
style U fill:#e3f2fd,stroke:#64b5f6
314+
style Z fill:#e3f2fd,stroke:#64b5f6
315+
style AB fill:#fff3e0,stroke:#ff9800
316+
```
317+
318+
## 🔄 **RAG Pipeline (Production-Grade)**
319+
320+
```mermaid
321+
flowchart TD
322+
A[Document Input] --> B[Chunking Strategy(recursive/character/token/markdown/etc.)]
323+
B --> C[Generate Chunks\n(document-chunking.tool.ts)]
324+
C --> D[Embed Each Chunk\nGemini text-embedding-001]
325+
D --> E[Store in PgVector\n(pg-storage.ts - indexed as memory_messages_3072)]
326+
F[User Query] --> G[Embed Query\nGemini text-embedding-001]
327+
G --> H[Vector Search PgVector\nHNSW/Flat Index]
328+
H --> I[Retrieve Top-K Chunks]
329+
I --> J[Generate Answer with Context\nAnswer Agent]
330+
331+
style A fill:#e8f5e9,stroke:#81c784
332+
style B fill:#fff3e0,stroke:#ff9800
333+
style C fill:#e3f2fd,stroke:#64b5f6
334+
style D fill:#e8f5e9,stroke:#81c784
335+
style E fill:#c8e6c9,stroke:#4caf50
336+
style F fill:#ffebee,stroke:#f44336
337+
style G fill:#e8f5e9,stroke:#81c784
338+
style H fill:#c8e6c9,stroke:#4caf50
339+
style I fill:#e3f2fd,stroke:#64b5f6
340+
style J fill:#fff3e0,stroke:#ff9800
341+
```
342+
226343
## 📁 **Structure**
227344

228345
```bash
@@ -380,9 +497,7 @@ npm run mcp-server
380497

381498
_Last updated: 2025-12-05 | v3.3.0_
382499

383-
## 📚 **Class Diagram**
384-
385-
- Latest class diagram for core AgentStack agents and tools:
500+
## 🧠 **Agent/Tool Relationships**
386501

387502
```mermaid
388503
classDiagram

llms.txt

Lines changed: 125 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
# AgentStack
22

3-
> A production-grade multi-agent framework built on Mastra, delivering enterprise tools, specialized agents, and A2A/MCP orchestration for scalable AI systems.
3+
> Production-grade multi-agent framework (Mastra) with a Next.js frontend. This repository contains the Mastra core (agents, tools, workflows, networks, MCP/A2A servers), frontend UI (Next.js app + shadcn/ui components), documentation, examples, and tests. Use the sections below to quickly find core docs, specs, examples, and configuration.
44

55
## Documentation
66

7-
- [Main README](README.md): Primary project documentation, architecture overview, and getting started guide
8-
- [Agents Documentation](src/mastra/agents/AGENTS.md): Detailed documentation for the agent framework, including development workflows and best practices
9-
- [Tools Documentation](src/mastra/tools/AGENTS.md): Comprehensive guide to available tools, including financial, search, and document processing capabilities
10-
- [Product Context](memory-bank/productContext.md): Detailed product goals, user problems, and core capabilities
11-
- [Technical Context](memory-bank/techContext.md): Technical constraints, dependencies, and development environment setup
12-
- [System Patterns](memory-bank/systemPatterns.md): Architecture patterns, key technical decisions, and design principles
13-
- [ADR: PgVector and Gemini Embeddings](docs/adr/0001-why-pgvector-and-gemini-embeddings.md): Architecture decision record for vector storage and embedding model choices
7+
- [Main README](README.md): Primary project documentation, architecture overview, running & development instructions
8+
- [Root AGENTS](AGENTS.md): Project-level overview and links to subdirectory AGENTS.md files
9+
- [Frontend (App) Docs](app/AGENTS.md): Next.js App Router layout, pages, and UX patterns for the frontend
10+
- [Mastra Core Docs](src/mastra/AGENTS.md): Top-level Mastra library overview (agents/tools/workflows/networks)
11+
- [Agents Documentation](src/mastra/agents/AGENTS.md): Agent development patterns, list of agents and change log
12+
- [Tools Documentation](src/mastra/tools/AGENTS.md): Tool catalogue (financial, RAG, scraping, PDF, utilities)
13+
- [Workflows Docs](src/mastra/workflows/AGENTS.md): Multi-step workflow patterns and examples
14+
- [Config & Provider Docs](src/mastra/config/AGENTS.md): Model provider, storage, and environment configuration guidance
15+
- [MCP Docs](src/mastra/mcp/AGENTS.md): Model Context Protocol server and client docs
16+
- [Data Directory Docs](src/mastra/data/AGENTS.md): Static data, examples and test-data descriptions
17+
- [A2A Coordination](src/mastra/a2a/AGENTS.md): Agent-to-Agent coordination and routing
18+
- [Scorers Documentation](src/mastra/scorers/AGENTS.md): Custom evaluation metrics and scoring guides
19+
- [Policy Documentation](src/mastra/policy/AGENTS.md): RBAC policies and access control definitions
20+
- [Vector Store Docs](src/mastra/config/vector/AGENTS.md): Vector store choices, configuration, and integration
21+
- [UI Components](ui/): shadcn/ui-based primitives and frontend components (see `ui/` folder)
22+
- [AI Elements (components)](src/components/ai-elements/): 30+ specialized UI components (artifact, chain-of-thought, reasoning, message, model-selector, canvas) used by chat/AI pages
23+
- [UI Primitives (shadcn)](ui/): shadcn/ui-based primitives and frontend components (see `ui/` folder)
24+
- [Memory Bank & Project Context](memory-bank/activeContext.md): active context, productContext.md, techContext.md, and usage notes
25+
- [Copilot & Project Rules](memory-bank/copilot-rules.md): Internal guidance for CI/automation/coding assistant usage
26+
- [API Reference & Developer Guides](docs/api.md, docs/api-small.md): API and developer-facing documentation
27+
- [Dashboard AGENTS](app/dashboard/AGENTS.md): Admin dashboard for monitoring and management
28+
- [Networks AGENTS](app/networks/AGENTS.md): Agent network management and visualization
29+
- [Chat AGENTS](app/chat/AGENTS.md): Client-side and streaming chat demos using @mastra/client-js
30+
- [Test AGENTS](app/test/AGENTS.md): Server action and runtime demos
31+
- [Workflows AGENTS](app/workflows/AGENTS.md): Workflow documentation and execution
32+
- [Tools AGENTS](app/tools/AGENTS.md): Tool documentation and execution
1433

1534
## Agents
1635

@@ -55,21 +74,11 @@
5574

5675
## Configuration
5776

58-
- [Configuration Guide](src/mastra/config/AGENTS.md): Guidelines for configuration, storage, and environment variables
77+
- [Configuration Guide](src/mastra/config/AGENTS.md): Guidelines for configuration, storage, providers and environment variables
5978
- [Config README](src/mastra/config/README.md): Model registry system and provider configuration overview
60-
- [Config Index](src/mastra/config/index.ts): Central export for project configuration
61-
- [OpenAI Config](src/mastra/config/openai.ts): OpenAI model provider client setup
62-
- [Google Config](src/mastra/config/google.ts): Google AI model provider client setup
63-
- [Anthropic Config](src/mastra/config/anthropic.ts): Anthropic model provider client setup
64-
- [OpenRouter Config](src/mastra/config/openrouter.ts): OpenRouter model provider client setup
65-
- [Vertex Config](src/mastra/config/vertex.ts): Google Vertex AI model provider setup
66-
- [Gemini CLI Config](src/mastra/config/gemini-cli.ts): Gemini CLI provider setup
67-
- [Postgres Storage](src/mastra/config/pg-storage.ts): PostgreSQL storage & vector client config with PgVector
68-
- [Logger Config](src/mastra/config/logger.ts): Structured logging (Pino) configuration
69-
- [Role Hierarchy](src/mastra/config/role-hierarchy.ts): RBAC inheritance model
70-
- [Upstash Memory](src/mastra/config/upstashMemory.ts): Upstash memory configuration
71-
- [Processors](src/mastra/config/processors.ts): Data processors configuration
72-
- [Vector Stores](src/mastra/config/vector/AGENTS.md): Vector store choices and configuration guide
79+
- [Example Provider Setup](src/mastra/config/google.ts, src/mastra/config/openai.ts, src/mastra/config/vertex.ts): Provider client examples and notes
80+
- [Postgres Vector Storage](src/mastra/config/pg-storage.ts): PostgreSQL + PgVector storage client and usage notes
81+
- [Logging & RBAC](src/mastra/config/logger.ts, src/mastra/config/role-hierarchy.ts): Observability and role model docs
7382

7483
## Workflows & MCP
7584

@@ -82,5 +91,97 @@
8291

8392
## Networks & Data
8493

85-
- [Networks Documentation](src/mastra/networks/AGENTS.md): Documentation for agent networks
86-
- [Data Directory](src/mastra/data/AGENTS.md): Documentation for data files and examples
94+
- [Networks Documentation](src/mastra/networks/AGENTS.md): Documentation for agent networks and routing
95+
- [Data Directory](src/mastra/data/AGENTS.md): Documentation for data files and example datasets
96+
97+
## Frontend (Next.js)
98+
99+
- [App Router (pages)](app/AGENTS.md): Next.js 16 App Router pages, layouts and examples
100+
- [Docs Pages](app/docs/): Developer-facing docs rendered in the Next.js app (getting-started, core-concepts, ai-sdk)
101+
- [Chat AGENTS](app/chat/AGENTS.md): Client-side and streaming chat demos using @mastra/client-js
102+
- [Example Pages](app/examples/page.tsx, app/blog/hello-world-agentstack/page.mdx): UI examples and tutorials
103+
- [Frontend shared components](app/components/): Reusable page components (navbar, footer, docs-layout, examples-list, chat components)
104+
- [Important API routes](app/api/): server routes used by the frontend and demos
105+
- [chat API routes](app/api/chat/route.ts, app/api/chat/r.ts): chat streaming and helper endpoints
106+
- [completion API](app/api/completion/route.ts): server-side completion demo
107+
- [contact API](app/api/contact/route.ts): contact form API route
108+
- [API Reference](app/api-reference/): API documentation pages (agents, tools, workflows)
109+
- [Blog](app/blog/): Blog posts and tutorials (e.g., hello-world-agentstack)
110+
- [Careers](app/careers/): Careers page and job listings
111+
- [Changelog](app/changelog/): Release notes and updates
112+
- [Dashboard AGENTS](app/dashboard/AGENTS.md): Admin dashboard for monitoring and management
113+
- [Login](app/login/): Authentication and login pages
114+
- [Networks AGENTS](app/networks/AGENTS.md): Agent network management and visualization
115+
- [Pricing](app/pricing/): Pricing tiers and subscription information
116+
- [Privacy](app/privacy/): Privacy policy and terms
117+
- [Test AGENTS](app/test/AGENTS.md): Server action and runtime demos
118+
- [Tools AGENTS](app/tools/AGENTS.md): Tool documentation and execution
119+
- [Workflows AGENTS](app/workflows/AGENTS.md): Workflow documentation and execution
120+
121+
## Configuration & Tooling (root)
122+
123+
- [package.json](package.json): Scripts, dependencies, and quick-start commands
124+
- [next.config.ts](next.config.ts): Next.js configuration including MDX and experimental features
125+
- [tsconfig.json](tsconfig.json): TypeScript config and path aliases
126+
- [vitest.config.ts](vitest.config.ts): Test runner configuration and test results output
127+
- [eslint.config.cjs](eslint.config.cjs): Linting configuration
128+
- [prettier.config.js](prettier.config.js): Formatting rules
129+
130+
## Tests & CI
131+
132+
- [Vitest config](vitest.config.ts): Local test runner and CI configuration
133+
- [tests/](tests/): Unit and integration test files
134+
- [test-results/](tests/test-results/): Test artifacts and coverage reports
135+
- [globalSetup.ts](globalSetup.ts), [testSetup.ts](testSetup.ts): Test initialization helpers
136+
137+
## Examples & Developer Guides
138+
139+
- [lib/mastra-client.ts](lib/mastra-client.ts): Example usage of the Mastra client SDK
140+
- [lib/utils.ts](lib/utils.ts): Shared utility functions used across frontend and SDK
141+
- [lib/client-stream-to-ai-sdk.ts](lib/client-stream-to-ai-sdk.ts): Streaming client integration with AI SDK
142+
- [lib/hooks/use-mastra.ts](lib/hooks/use-mastra.ts): Core hook for Mastra client integration
143+
- [lib/hooks/use-dashboard-queries.ts](lib/hooks/use-dashboard-queries.ts): Data-fetching hooks for dashboard
144+
- [app/chat/](app/chat/): Example streaming chat and client SDK patterns
145+
- [app/test/](app/test/): Example server action & runtime demos
146+
- [src/components/ai-elements/message.tsx](src/components/ai-elements/message.tsx): Chat message rendering with markdown/support
147+
- [src/components/ai-elements/plan.tsx](src/components/ai-elements/plan.tsx): Plan/strategy visualization component
148+
- [src/components/ai-elements/chain-of-thought.tsx](src/components/ai-elements/chain-of-thought.tsx): Reasoning step visualization
149+
- [src/components/ai-elements/model-selector.tsx](src/components/ai-elements/model-selector.tsx): Model/provider selection UI
150+
- [src/components/ai-elements/canvas.tsx](src/components/ai-elements/canvas.tsx): Visual canvas for Excalidraw integration
151+
- [src/components/ai-elements/artifact.tsx](src/components/ai-elements/artifact.tsx): Artifact display component
152+
- [src/components/ai-elements/code-block.tsx](src/components/ai-elements/code-block.tsx): Code display with syntax highlighting
153+
- [src/components/ai-elements/controls.tsx](src/components/ai-elements/controls.tsx): Conversation control buttons
154+
- [src/components/ai-elements/inline-citation.tsx](src/components/ai-elements/inline-citation.tsx): Inline citation rendering
155+
- [src/components/ai-elements/loader.tsx](src/components/ai-elements/loader.tsx): Loading state indicator
156+
- [src/components/ai-elements/node.tsx](src/components/ai-elements/node.tsx): Graph node visualization
157+
- [src/components/ai-elements/panel.tsx](src/components/ai-elements/panel.tsx): Collapsible panel container
158+
- [src/components/ai-elements/prompt-input.tsx](src/components/ai-elements/prompt-input.tsx): Prompt input field with enhancements
159+
- [src/components/ai-elements/queue.tsx](src/components/ai-elements/queue.tsx): Task queue visualization
160+
- [src/components/ai-elements/reasoning.tsx](src/components/ai-elements/reasoning.tsx): Reasoning step breakdown
161+
- [src/components/ai-elements/shimmer.tsx](src/components/ai-elements/shimmer.tsx): Shimmer loading animation
162+
- [src/components/ai-elements/sources.tsx](src/components/ai-elements/sources.tsx): Source citation display
163+
- [src/components/ai-elements/suggestion.tsx](src/components/ai-elements/suggestion.tsx): Suggestion rendering
164+
- [src/components/ai-elements/task.tsx](src/components/ai-elements/task.tsx): Task item display
165+
- [src/components/ai-elements/toolbar.tsx](src/components/ai-elements/toolbar.tsx): Conversation toolbar
166+
- [src/components/ai-elements/web-preview.tsx](src/components/ai-elements/web-preview.tsx): Web content preview
167+
- [ui/button.tsx](ui/button.tsx): Core button component with variants
168+
- [ui/input.tsx](ui/input.tsx): Form input component
169+
- [ui/card.tsx](ui/card.tsx): Card layout primitive
170+
- [ui/dialog.tsx](ui/dialog.tsx): Modal dialog component
171+
- [ui/popover.tsx](ui/popover.tsx): Context menu/popover primitive
172+
- [ui/tooltip.tsx](ui/tooltip.tsx): Hover tooltip component
173+
- [ui/layout.tsx](ui/layout.tsx): Page layout wrapper
174+
175+
## Memory Bank & Project Context (developer tooling)
176+
177+
- [memory-bank/activeContext.md](memory-bank/activeContext.md): Active context and project memory
178+
- [memory-bank/productContext.md](memory-bank/productContext.md): Product brief and goals
179+
- [memory-bank/techContext.md](memory-bank/techContext.md): Technical constraints and choices
180+
- [memory-bank/memory-bank-instructions.md](memory-bank/memory-bank-instructions.md): How the memory-bank is used in this repo
181+
182+
## Optional / Misc
183+
184+
- [docs/adr/0001-why-pgvector-and-gemini-embeddings.md](docs/adr/0001-why-pgvector-and-gemini-embeddings.md): ADR for vector/embedding choices
185+
- [.github/prompts/update-llms.prompt.md](.github/prompts/update-llms.prompt.md): Prompt used to guide updates to this file
186+
- [docs/runtimeContext.md](docs/runtimeContext.md): Runtime conventions and context documentation
187+
- [llms.txt](llms.txt): This file — machine-friendly navigation for LLMs and contributors

memory-bank/activeContext.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,28 @@ graph TB
135135
- Implementing and wiring real JWT verification for the `jwt-auth` tool and ensuring RBAC policies in `src/mastra/policy/acl.yaml` are enforced where appropriate.
136136
- **[Completed]** Implemented and verified data tools (`csv-to-json`, `json-to-csv`, `data-validator`) with `RuntimeContext` integration and comprehensive tests.
137137

138+
## Active Feature: Semantic Code Analysis Tools
139+
140+
**Status:** ✅ Implementation Complete
141+
**Location:** `/memory-bank/semantic-code-tools/`
142+
143+
**Objective:** Implement high-performance `find-references` and `find-symbol` tools using `ts-morph` and a `ProjectCache` singleton to enable intelligent agent navigation.
144+
145+
**Implemented Components:**
146+
147+
| Component | Path | Status |
148+
|-----------|------|--------|
149+
| ProjectCache | `src/mastra/tools/semantic-utils.ts` | ✅ Created |
150+
| PythonParser | `src/mastra/tools/semantic-utils.ts` | ✅ Created |
151+
| FindReferencesTool | `src/mastra/tools/find-references.tool.ts` | ✅ Created |
152+
| FindSymbolTool | `src/mastra/tools/find-symbol.tool.ts` | ✅ Created |
153+
| Tool Registration | `src/mastra/tools/index.ts` | ✅ Created |
154+
| Agent Integration | `src/mastra/agents/codingAgents.ts` | ✅ Updated |
155+
156+
**Next Steps:**
157+
1. Verify tools with manual testing (optional)
158+
2. Proceed to next feature
159+
138160
## Active Feature: CSV Agents & Data Pipeline Networks
139161

140162
**Status:** ✅ Implementation Complete

0 commit comments

Comments
 (0)