agent-enderun 0.8.8 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.enderun/BRAIN_DASHBOARD.md +5 -5
  2. package/{ENDERUN.md → .enderun/ENDERUN.md} +4 -2
  3. package/.enderun/PROJECT_MEMORY.md +32 -43
  4. package/.enderun/STATUS.md +25 -28
  5. package/.enderun/agents/agent_army_schema.json +29 -7
  6. package/.enderun/agents/backend.md +48 -39
  7. package/.enderun/agents/database.md +55 -0
  8. package/.enderun/agents/devops.md +30 -17
  9. package/.enderun/agents/explorer.md +5 -5
  10. package/.enderun/agents/frontend.md +97 -76
  11. package/.enderun/agents/git.md +4 -4
  12. package/.enderun/agents/manager.md +68 -59
  13. package/.enderun/agents/mobile.md +4 -4
  14. package/.enderun/agents/native.md +106 -0
  15. package/.enderun/agents/quality.md +122 -0
  16. package/.enderun/agents/schema/agent-lifecycle-schema.json +29 -8
  17. package/.enderun/cli-commands.json +7 -3
  18. package/.enderun/config.json +8 -2
  19. package/.enderun/knowledge/SHIM_TEMPLATE.md +25 -0
  20. package/.enderun/knowledge/context_boundary_rules.md +57 -0
  21. package/.enderun/knowledge/corporate-governance/high-risk-action-approval-flow.md +29 -0
  22. package/.enderun/knowledge/documentation_ownership.md +53 -0
  23. package/.enderun/knowledge/eslint-standards.md +63 -0
  24. package/.enderun/knowledge/frontend_professionalization_guidelines.md +7 -7
  25. package/.enderun/knowledge/hermes_live_test_guidelines.md +5 -5
  26. package/.enderun/knowledge/hermes_protocol.md +1 -1
  27. package/.enderun/knowledge/lessons-learned.md +14 -0
  28. package/.enderun/knowledge/manager_authority_audit_enforcement.md +10 -10
  29. package/.enderun/knowledge/project_scaffold_guidelines.md +4 -4
  30. package/.enderun/knowledge/reference_application_guidelines.md +6 -6
  31. package/.enderun/mcp_config.json +9 -0
  32. package/.enderun/memory-graph/agent-contexts/backend.json +1 -1
  33. package/.enderun/memory-graph/agent-contexts/devops.json +1 -1
  34. package/.enderun/memory-graph/agent-contexts/explorer.json +1 -1
  35. package/.enderun/memory-graph/agent-contexts/frontend.json +1 -1
  36. package/.enderun/memory-graph/agent-contexts/git.json +1 -1
  37. package/.enderun/memory-graph/agent-contexts/manager.json +1 -1
  38. package/.enderun/memory-graph/agent-contexts/mobile.json +1 -1
  39. package/.enderun/memory-graph/agent-contexts/native.json +1 -0
  40. package/.enderun/memory-graph/agent-contexts/quality.json +1 -0
  41. package/.enderun/memory-graph/graph.json +123 -15
  42. package/.enderun/memory-graph/shared-facts.json +26 -31
  43. package/.enderun/queue/README.md +13 -13
  44. package/README.md +171 -393
  45. package/agent.md +25 -0
  46. package/bin/cli.js +10 -10
  47. package/bin/init-check.js +69 -0
  48. package/bin/update-contract.js +57 -38
  49. package/bin/validate-agent-army.js +38 -13
  50. package/claude.md +14 -8
  51. package/docs/README.md +24 -16
  52. package/docs/architecture/README.md +9 -0
  53. package/docs/architecture/standards/data-fetching-patterns.md +13 -0
  54. package/docs/architecture/standards/design-system.md +31 -0
  55. package/docs/architecture/standards/logging.md +7 -0
  56. package/docs/architecture/standards/tech-stack.md +9 -0
  57. package/docs/getting-started.md +9 -259
  58. package/docs/user/README.md +35 -0
  59. package/docs/user/action-plan-2026.md +9 -0
  60. package/docs/user/getting-started.md +13 -0
  61. package/docs/user/roadmap.md +13 -0
  62. package/eslint.config.js +68 -0
  63. package/framework-mcp/dist/index.js +178 -24
  64. package/framework-mcp/package.json +6 -33
  65. package/framework-mcp/tsconfig.json +3 -6
  66. package/gemini.md +12 -6
  67. package/grok.md +25 -0
  68. package/package.json +13 -5
  69. package/panda.config.ts +86 -86
  70. package/src/cli/adapters.ts +208 -0
  71. package/src/cli/commands/app.ts +38 -0
  72. package/src/cli/commands/check.ts +87 -0
  73. package/src/cli/commands/compliance.ts +55 -0
  74. package/src/cli/commands/contract.ts +45 -0
  75. package/src/cli/commands/explorer.ts +45 -0
  76. package/src/cli/commands/git.ts +39 -0
  77. package/src/cli/commands/init.ts +272 -0
  78. package/src/cli/commands/knowledge.ts +44 -0
  79. package/src/cli/commands/lint.ts +25 -0
  80. package/src/cli/commands/log.ts +37 -0
  81. package/src/cli/commands/memory.ts +78 -0
  82. package/src/cli/commands/orchestrate.ts +111 -0
  83. package/src/cli/commands/script.ts +20 -0
  84. package/src/cli/commands/security.ts +38 -0
  85. package/src/cli/commands/status.ts +59 -0
  86. package/src/cli/commands/trace.ts +46 -0
  87. package/src/cli/index.ts +74 -2155
  88. package/src/cli/utils/app.ts +764 -0
  89. package/src/cli/utils/claude.ts +56 -0
  90. package/src/cli/utils/fs.ts +139 -0
  91. package/src/cli/utils/memory.ts +141 -0
  92. package/src/cli/utils/pkg.ts +215 -0
  93. package/src/cli/utils/string.ts +48 -0
  94. package/src/cli/utils/time.ts +27 -0
  95. package/tsconfig.json +9 -0
  96. package/.enderun/agents/analyst.md +0 -238
  97. package/.enderun/agents/orchestrator.md +0 -172
  98. package/.enderun/agents/qa.md +0 -124
  99. package/.enderun/agents/security.md +0 -202
  100. package/.enderun/knowledge/api_design_rules.md +0 -6
  101. package/.enderun/knowledge/branded_types_pattern.md +0 -8
  102. package/.enderun/knowledge/code_review_checklist.md +0 -7
  103. package/.enderun/knowledge/contract_versioning.md +0 -7
  104. package/.enderun/knowledge/database_migration.md +0 -6
  105. package/.enderun/knowledge/deployment_checklist.md +0 -7
  106. package/.enderun/knowledge/git_commit_strategy.md +0 -10
  107. package/.enderun/knowledge/monitoring_setup.md +0 -5
  108. package/.enderun/knowledge/performance_guidelines.md +0 -11
  109. package/.enderun/knowledge/repository_patterns.md +0 -9
  110. package/.enderun/knowledge/security_scanning.md +0 -6
  111. package/.enderun/knowledge/testing_standards.md +0 -7
  112. package/.enderun/knowledge/troubleshooting_guide.md +0 -5
  113. package/.enderun/logs/analyst.json +0 -1
  114. package/.enderun/logs/backend.json +0 -1
  115. package/.enderun/logs/devops.json +0 -1
  116. package/.enderun/logs/explorer.json +0 -1
  117. package/.enderun/logs/frontend.json +0 -1
  118. package/.enderun/logs/git.json +0 -1
  119. package/.enderun/logs/manager.json +0 -1
  120. package/.enderun/logs/mobile.json +0 -1
  121. package/.enderun/logs/native.json +0 -1
  122. package/.enderun/logs/orchestrator.json +0 -1
  123. package/.enderun/logs/qa.json +0 -1
  124. package/.enderun/logs/security.json +0 -1
  125. package/.enderun/memory-graph/agent-contexts/analyst.json +0 -1
  126. package/.enderun/memory-graph/agent-contexts/orchestrator.json +0 -1
  127. package/.enderun/memory-graph/agent-contexts/qa.json +0 -1
  128. package/.enderun/memory-graph/agent-contexts/security.json +0 -1
  129. package/.env.example +0 -10
  130. package/cursor.md +0 -19
  131. package/docs/action-plan-2026.md +0 -119
  132. package/docs/roadmap.md +0 -142
  133. package/framework-mcp/README.md +0 -55
  134. package/framework-mcp/dist/schemas.js +0 -84
  135. package/framework-mcp/dist/tools/codebase.js +0 -294
  136. package/framework-mcp/dist/tools/contract.js +0 -197
  137. package/framework-mcp/dist/tools/framework.js +0 -225
  138. package/framework-mcp/dist/tools/git.js +0 -51
  139. package/framework-mcp/dist/tools/governance.js +0 -696
  140. package/framework-mcp/dist/tools/index.js +0 -47
  141. package/framework-mcp/dist/tools/knowledge.js +0 -133
  142. package/framework-mcp/dist/tools/memory.js +0 -217
  143. package/framework-mcp/dist/tools/messages.js +0 -193
  144. package/framework-mcp/dist/tools/monitoring.js +0 -294
  145. package/framework-mcp/dist/tools/orchestration.js +0 -369
  146. package/framework-mcp/dist/tools/pipeline.js +0 -267
  147. package/framework-mcp/dist/tools/security.js +0 -137
  148. package/framework-mcp/dist/utils.js +0 -121
  149. package/framework-mcp/src/index.ts +0 -49
  150. package/framework-mcp/src/schemas.ts +0 -106
  151. package/framework-mcp/src/tools/codebase.ts +0 -284
  152. package/framework-mcp/src/tools/contract.ts +0 -221
  153. package/framework-mcp/src/tools/framework.ts +0 -223
  154. package/framework-mcp/src/tools/git.ts +0 -42
  155. package/framework-mcp/src/tools/governance.ts +0 -891
  156. package/framework-mcp/src/tools/index.ts +0 -50
  157. package/framework-mcp/src/tools/knowledge.ts +0 -141
  158. package/framework-mcp/src/tools/memory.ts +0 -207
  159. package/framework-mcp/src/tools/messages.ts +0 -213
  160. package/framework-mcp/src/tools/monitoring.ts +0 -351
  161. package/framework-mcp/src/tools/orchestration.ts +0 -440
  162. package/framework-mcp/src/tools/pipeline.ts +0 -353
  163. package/framework-mcp/src/tools/security.ts +0 -143
  164. package/framework-mcp/src/utils.ts +0 -130
package/docs/roadmap.md DELETED
@@ -1,142 +0,0 @@
1
- # Agent Enderun — Development Roadmap (v0.6.6+) / Geliştirme Yol Haritası
2
-
3
- **Last Updated / Son Güncelleme:** 23 May 2026 / 23 May 2026
4
- **Owner / Sorumlu:** @manager
5
-
6
- [English](#english) | [Türkçe](#türkçe)
7
-
8
- ---
9
-
10
- # English
11
-
12
- This document outlines the development roadmap for the Agent Enderun framework **v0.6.6 and beyond**. All items are prioritized logically based on actual project needs and corporate governance principles.
13
-
14
- ## Current Status (24 May 2026)
15
-
16
- - **Version:** v0.6.6 (ready for npm release)
17
- - **System Health:** 🟢 GREEN
18
- - **Key Accomplishments:**
19
- - Only Gemini adapter supported (installs to .enderun/)
20
- - Antigravity adapter and all related code fully removed
21
- - Lint technical debt resolved (reduced from 43 to 0 issues)
22
- - Published `docs/getting-started.md` guide
23
- - Updated memory structures and workspace hygiene
24
-
25
- - **Active Challenge:** Memory and task tracking need reinforcement (ACTIVE TASKS section is empty)
26
-
27
- ---
28
-
29
- ## Agent Maturity & Professionalization Program (Highest Strategic Initiative)
30
-
31
- To make Agent Enderun truly production-grade for enterprise use, agents must be professionalized to meet the standards of senior software engineers.
32
-
33
- This program systematically audits current agent maturity levels and runs structured improvements to elevate each agent to enterprise readiness.
34
-
35
- ### Agent Maturity Targets
36
-
37
- | Agent Persona | Current Level | Target Level | Priority / Risk Status |
38
- | :--- | :--- | :--- | :--- |
39
- | **@manager** | 8.0 | 9.5 | High / Stable. Leadership and project management capabilities are excellent. |
40
- | **@backend** | 7.5 | 9.0 | High / Stable. Deeply understands Kysely and Fastify patterns; testing discipline needs reinforcement. |
41
- | **@frontend** | 6.5 | 9.0 | **Critical / High Risk**. Needs major reinforcement in component slots, composition patterns, WCAG 2.2 accessibility, and performance engineering. |
42
- | **@explorer** | 6.5 | 8.5 | High / Stable. Highly capable in dependency analysis and codebase intelligence. |
43
- | **@analyst** | 6.5 | 8.5 | Medium / Stable. Handles system health metrics and compliance audits. |
44
- | **@git** | 6.0 | 8.0 | Medium / Stable. Coordinates PRs, semantic commits, and version compliance. |
45
- | **@mobile** | 2.0 | 7.5 | Low / Dormant. Foundational blueprints and Hermes safety rules added. |
46
-
47
- > **Note:** `@frontend` is currently the highest risk to enterprise onboarding and is the top priority.
48
-
49
- ---
50
-
51
- ## Roadmap Overview
52
-
53
- | Phase | Timeline | Focus | Priority |
54
- | :--- | :--- | :--- | :--- |
55
- | **Agent Maturity Program** | 1–4 Months | Elevate all agents to professional enterprise-grade | **Highest** |
56
- | **Phase 1** | 1–6 Weeks | Usability, automated configurations, and CLI tooling | High |
57
- | **Phase 2** | 1–3 Months | Hermes messaging stability & multi-agent intelligence | High |
58
- | **Phase 3** | 3+ Months | Scalability, performance benchmarks, and Reference Application | Medium |
59
-
60
- ---
61
-
62
- ## Agent Maturity Program — Phase 1 (Weeks 1–8)
63
-
64
- ### 1. Professionalize @frontend Agent (Critical)
65
- - Component Architecture (Compound Components, Slots, Composition Patterns)
66
- - Accessibility (WCAG 2.2 AA compliance standards)
67
- - Performance Engineering (Core Web Vitals, virtualization, code splitting)
68
- - Testing Strategy (Hook + Component + Integration testing)
69
- - Error Boundaries & Resilience
70
- - Design System Governance
71
-
72
- ### 2. Reinforce @backend Agent
73
- - Production Testing Culture (Unit + Integration + Contract + E2E)
74
- - Observability (Structured Logging + Metrics + Tracing)
75
- - Resilience Patterns (Idempotency, Retry, Circuit Breaker)
76
- - Query Optimization and Caching Strategy
77
-
78
- ### 3. Elevate @manager Leadership
79
- - Technical Debt Auditing & Escalation Register
80
- - Risk Assessment Framework
81
- - Capacity Planning & Sustainable Delivery
82
- - Architecture Decision Records (ADR) Discipline
83
-
84
- ---
85
-
86
- ## Phase 1 — Short-Term (Weeks 1–6)
87
-
88
- ### 1. Fully Automate Claude Configuration
89
- - **Description:** Remove the manual `claude config add` step after running `init claude`. Automatically patch the Claude Desktop configuration file.
90
- - **Complexity:** Medium
91
- - **Status:** Pending
92
-
93
- ### 2. Frontend Blueprint System
94
- - **Description:** Carry the blueprint generator power of the backend over to the frontend. Establish structured React components, pages, and UI pattern blueprints.
95
- - **Complexity:** Medium-High
96
- - **Status:** Pending
97
-
98
- ### 3. Expand Getting Started Documentation
99
- - **Description:** Enrich the new guide based on developer feedback. Add more real-world scenarios, troubleshooting tips, and best practices.
100
- - **Complexity:** Low-Medium
101
- - **Status:** In Progress (Getting started guide updated to v0.6.6)
102
-
103
- ---
104
-
105
- ## Phase 2 — Mid-Term (Months 1–3)
106
-
107
- ### 4. Fully Implement Hermes Messaging Protocol
108
- - **Description:** Move inter-agent categorized, prioritized, and persistent messaging protocol from "defined on paper" to active code implementation.
109
- - **Complexity:** High
110
- - **Status:** Draft defined; implementation pending
111
-
112
- ### 5. Reinforce Academy & Performance System
113
- - **Description:** Aggregate success metrics, failure tracking, and structured feedback for all agents to report via dashboard.
114
- - **Complexity:** Medium-High
115
- - **Status:** Basic tools available; scaling required
116
-
117
- ---
118
-
119
- ## Phase 3 — Long-Term (Months 3+)
120
-
121
- ### 6. Production-Grade Reference Application
122
- - **Description:** Build a complete end-to-end reference application demonstrating normal CRUD + High-Risk Admin actions + Hermes messaging under Agent Enderun's governance.
123
- - **Complexity:** Very High
124
- - **Status:** Planned
125
-
126
- ---
127
-
128
- # Türkçe
129
-
130
- Bu belge, Agent Enderun framework’ünün **v0.6.6 sonrası** geliştirme yol haritasını içerir.
131
-
132
- ## Mevcut Durum (May 2026)
133
-
134
- - **Versiyon:** v0.6.6
135
- - **Sistem Sağlığı:** 🟢 GREEN (build ve test altyapısı onarım altında)
136
- - **v0.6.6 Odak:** Tüm framework’ün profesyonel İngilizceye dönüştürülmesi ve yönetişim boşluklarının dürüstçe analiz edilmesi.
137
-
138
- ## Özet
139
-
140
- Ajan Olgunluk Programı devam etmektedir. @frontend en yüksek riskli ajan olmaya devam ediyor. Hermes protokolünün canlı test edilmesi ve referans uygulamanın üretilmesi önümüzdeki ana hedeflerdir.
141
-
142
- Detaylı plan ve risk takibi İngilizce bölümde yer almaktadır.
@@ -1,55 +0,0 @@
1
- # AI-Enderun MCP Server (v0.8.3)
2
-
3
- English | [Türkçe](#türkçe)
4
-
5
- The `ai-enderun-mcp` package is the core intelligence engine of the Agent Enderun framework, implementing the Model Context Protocol (MCP).
6
-
7
- ## English
8
-
9
- ### 🛠️ Categorized Tools
10
-
11
- #### 🛡️ Security & Compliance
12
- - `security_audit_scan`: Scans for secrets, raw SQL, and unsafe patterns using AST.
13
- - `analyze_constitution_compliance`: Verifies adherence to `ENDERUN.md` rules.
14
-
15
- #### 🧠 Framework & Memory
16
- - `get_framework_status`: Retrieves active phase and status.
17
- - `update_project_memory`: Atomic updates to project brain sections.
18
- - `bootstrap_legacy_memory`: Auto-generates memory for existing projects.
19
- - `read_project_memory`: Safe read access to the project brain.
20
-
21
- #### 🔍 Codebase Intelligence
22
- - `search_codebase`: Regex-powered semantic search.
23
- - `analyze_dependencies`: Deep import tracking and dependency mapping.
24
- - `analyze_codebase_intelligence`: Detects complexity spikes and dead code.
25
- - `generate_dependency_graph`: Creates Mermaid architecture maps.
26
-
27
- #### 📜 Contract Management
28
- - `verify_api_contract`: Checks shared-types integrity via hashing.
29
- - `update_contract_hash`: Synchronizes the contract versioning.
30
- - `verify_contract_integrity`: Ensures API docs and types are in sync.
31
-
32
- #### 🎓 Academy & Orchestration
33
- - `log_agent_action`: Records traceable agent activities.
34
- - `send_agent_message`: Facilitates inter-agent collaboration.
35
- - `read_agent_messages`: Inbox management for specialized agents.
36
-
37
- #### 📦 Repository & Git
38
- - `generate_semantic_commit_message`: Automated commit messages based on diffs.
39
-
40
- ---
41
-
42
- ## Türkçe
43
-
44
- ### 🛠️ Kategorize Edilmiş Araçlar
45
-
46
- - **Güvenlik:** `security_audit_scan`, `analyze_constitution_compliance`.
47
- - **Hafıza:** `get_framework_status`, `update_project_memory`, `bootstrap_legacy_memory`.
48
- - **Zeka:** `search_codebase`, `analyze_dependencies`, `generate_dependency_graph`.
49
- - **Kontrat:** `verify_api_contract`, `update_contract_hash`, `verify_contract_integrity`.
50
- - **Orkestrasyon:** `send_agent_message`, `log_agent_action`.
51
- - **Repo:** `generate_semantic_commit_message`.
52
-
53
- ## License
54
-
55
- MIT
@@ -1,84 +0,0 @@
1
- import { z } from "zod";
2
- export const SECURITY_AUDIT_ARGS_SCHEMA = z.object({
3
- path: z.string().default("."),
4
- });
5
- export const SEARCH_CODEBASE_ARGS_SCHEMA = z.object({
6
- query: z.string().min(1).max(300),
7
- extension: z
8
- .string()
9
- .default("ts")
10
- .refine((s) => /^[a-z0-9]+$/i.test(s), { message: "extension must be alphanumeric" }),
11
- });
12
- export const UPDATE_MEMORY_ARGS_SCHEMA = z.object({
13
- section: z.enum(["CURRENT STATUS", "HISTORY", "ACTIVE TASKS"]),
14
- content: z.string().min(1),
15
- });
16
- export const ANALYZE_DEPENDENCIES_ARGS_SCHEMA = z.object({
17
- path: z.string().min(1),
18
- });
19
- export const LOG_AGENT_ACTION_ARGS_SCHEMA = z.object({
20
- agent: z.string().min(1),
21
- action: z.string().min(1),
22
- requestId: z.string().min(1),
23
- files: z.array(z.string()).default([]),
24
- status: z.enum(["SUCCESS", "FAILURE"]),
25
- summary: z.string().min(1),
26
- details: z.record(z.string(), z.any()).default({}),
27
- });
28
- export const SEND_AGENT_MESSAGE_ARGS_SCHEMA = z.object({
29
- from: z.string().min(1),
30
- to: z.string().min(1),
31
- message: z.string().min(1),
32
- traceId: z.string().min(1),
33
- category: z.enum(["ACTION", "DELEGATION", "INFO", "ALERT"]).default("INFO"),
34
- priority: z.enum(["LOW", "MEDIUM", "HIGH", "URGENT"]).default("MEDIUM"),
35
- });
36
- export const UPDATE_AGENT_MESSAGE_STATUS_ARGS_SCHEMA = z.object({
37
- agent: z.string().min(1),
38
- traceId: z.string().min(1),
39
- newStatus: z.enum(["ACKNOWLEDGED", "COMPLETED", "REJECTED"]),
40
- });
41
- export const SEARCH_KNOWLEDGE_BASE_ARGS_SCHEMA = z.object({
42
- query: z.string().min(1),
43
- });
44
- export const UPDATE_KNOWLEDGE_BASE_ARGS_SCHEMA = z.object({
45
- topic: z.string().min(1),
46
- content: z.string().min(1),
47
- tags: z.array(z.string().min(1)).default([]),
48
- });
49
- export const ANALYZE_CONSTITUTION_COMPLIANCE_ARGS_SCHEMA = z.object({
50
- path: z.string().min(1),
51
- });
52
- export const GENERATE_DEPENDENCY_GRAPH_ARGS_SCHEMA = z.object({
53
- path: z.string().default("src"),
54
- format: z.enum(["mermaid", "json"]).default("mermaid"),
55
- });
56
- export const READ_AGENT_MESSAGES_ARGS_SCHEMA = z.object({
57
- agent: z.string().min(1),
58
- traceId: z.string().min(1).optional(),
59
- });
60
- export const VERIFY_CONTRACT_INTEGRITY_ARGS_SCHEMA = z.object({
61
- domain: z.string().min(1),
62
- });
63
- export const GENERATE_SEMANTIC_COMMIT_MESSAGE_ARGS_SCHEMA = z.object({
64
- traceId: z.string().min(1),
65
- });
66
- export const ANALYZE_CODEBASE_INTELLIGENCE_ARGS_SCHEMA = z.object({
67
- path: z.string().default("."),
68
- });
69
- export const ANALYZE_PROCEDURAL_CONTINUITY_ARGS_SCHEMA = z.object({
70
- targetPath: z.string().min(1),
71
- referencePath: z.string().min(1),
72
- });
73
- export const GET_AGENT_INBOX_STATS_ARGS_SCHEMA = z.object({
74
- agent: z.string().min(1),
75
- });
76
- export const GET_KNOWLEDGE_GRAPH_ARGS_SCHEMA = z.object({
77
- tag: z.string().optional(),
78
- });
79
- export const SYNC_CONTRACT_HASH_ARGS_SCHEMA = z.object({
80
- force: z.boolean().default(false),
81
- });
82
- export const VERIFY_FRAMEWORK_HEALTH_ARGS_SCHEMA = z.object({
83
- detailed: z.boolean().default(false),
84
- });
@@ -1,294 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { Project } from "ts-morph";
4
- import { collectFilesRecursively, resolveSafePath } from "../utils.js";
5
- import { SEARCH_CODEBASE_ARGS_SCHEMA, ANALYZE_DEPENDENCIES_ARGS_SCHEMA, ANALYZE_CODEBASE_INTELLIGENCE_ARGS_SCHEMA, ANALYZE_PROCEDURAL_CONTINUITY_ARGS_SCHEMA, GENERATE_DEPENDENCY_GRAPH_ARGS_SCHEMA } from "../schemas.js";
6
- export const codebaseTools = [
7
- {
8
- name: "search_codebase",
9
- description: "Semantic search across the codebase using grep for exact matches and context. Ideal for finding logic and patterns.",
10
- inputSchema: {
11
- type: "object",
12
- properties: {
13
- query: {
14
- type: "string",
15
- description: "Search query or regex pattern",
16
- },
17
- extension: {
18
- type: "string",
19
- description: "File extension filter (e.g., ts, md)",
20
- default: "ts",
21
- },
22
- },
23
- required: ["query"],
24
- },
25
- },
26
- {
27
- name: "codebase_search",
28
- description: "Compatibility alias for search_codebase. Use when older agent prompts still reference codebase_search.",
29
- inputSchema: {
30
- type: "object",
31
- properties: {
32
- query: {
33
- type: "string",
34
- description: "Search query or regex pattern",
35
- },
36
- extension: {
37
- type: "string",
38
- description: "File extension filter (e.g., ts, md)",
39
- default: "ts",
40
- },
41
- },
42
- required: ["query"],
43
- },
44
- },
45
- {
46
- name: "analyze_dependencies",
47
- description: "Analyze code dependencies for a specific file or folder using import tracking.",
48
- inputSchema: {
49
- type: "object",
50
- properties: {
51
- path: {
52
- type: "string",
53
- description: "Path to analyze (relative to project root)",
54
- },
55
- },
56
- required: ["path"],
57
- },
58
- },
59
- {
60
- name: "codebase_graph_query",
61
- description: "Compatibility alias for analyze_dependencies. Returns import-level dependency information for a file or folder.",
62
- inputSchema: {
63
- type: "object",
64
- properties: {
65
- path: {
66
- type: "string",
67
- description: "Path to analyze (relative to project root)",
68
- },
69
- },
70
- required: ["path"],
71
- },
72
- },
73
- {
74
- name: "analyze_codebase_intelligence",
75
- description: "Scans the codebase for complexity spikes and potential dead code (exported but unused symbols).",
76
- inputSchema: {
77
- type: "object",
78
- properties: {
79
- path: {
80
- type: "string",
81
- description: "Path to scan (relative to project root)",
82
- default: ".",
83
- },
84
- },
85
- },
86
- },
87
- {
88
- name: "analyze_procedural_continuity",
89
- description: "Compares a target file with a reference file to identify stylistic or structural deviations. Ensures agents follow existing patterns.",
90
- inputSchema: {
91
- type: "object",
92
- properties: {
93
- targetPath: {
94
- type: "string",
95
- description: "Path to the newly created/modified file",
96
- },
97
- referencePath: {
98
- type: "string",
99
- description: "Path to an existing 'gold standard' file for comparison",
100
- },
101
- },
102
- required: ["targetPath", "referencePath"],
103
- },
104
- },
105
- {
106
- name: "generate_dependency_graph",
107
- description: "Generates a Mermaid-compatible dependency graph of the codebase or a specific directory.",
108
- inputSchema: {
109
- type: "object",
110
- properties: {
111
- path: {
112
- type: "string",
113
- description: "Path to scan (relative to project root)",
114
- default: "src",
115
- },
116
- format: {
117
- type: "string",
118
- enum: ["mermaid", "json"],
119
- default: "mermaid",
120
- },
121
- },
122
- },
123
- },
124
- ];
125
- export const codebaseHandlers = {
126
- search_codebase: async (args, projectRoot) => {
127
- const parsed = SEARCH_CODEBASE_ARGS_SCHEMA.safeParse(args);
128
- if (!parsed.success) {
129
- return { content: [{ type: "text", text: "Invalid query/extension argument." }] };
130
- }
131
- const { query, extension } = parsed.data;
132
- try {
133
- const files = collectFilesRecursively(projectRoot, new Set([extension]));
134
- let queryRegex;
135
- try {
136
- queryRegex = new RegExp(query, "i");
137
- }
138
- catch {
139
- return { content: [{ type: "text", text: "Invalid regex pattern in query." }] };
140
- }
141
- const matches = [];
142
- const MAX_RESULTS = 30;
143
- for (const filePath of files) {
144
- if (matches.length >= MAX_RESULTS)
145
- break;
146
- const content = fs.readFileSync(filePath, "utf-8");
147
- const lines = content.split("\n");
148
- for (let i = 0; i < lines.length; i++) {
149
- if (matches.length >= MAX_RESULTS)
150
- break;
151
- const line = lines[i];
152
- if (queryRegex.test(line)) {
153
- const relativePath = path.relative(projectRoot, filePath);
154
- matches.push(`- ${relativePath}:${i + 1}: ${line.trim()}`);
155
- }
156
- }
157
- }
158
- return { content: [{ type: "text", text: matches.join("\n") || "No matches found." }] };
159
- }
160
- catch {
161
- return { content: [{ type: "text", text: "Search failed." }] };
162
- }
163
- },
164
- analyze_dependencies: async (args, projectRoot) => {
165
- const parsed = ANALYZE_DEPENDENCIES_ARGS_SCHEMA.safeParse(args);
166
- if (!parsed.success) {
167
- return { content: [{ type: "text", text: "Invalid path argument." }] };
168
- }
169
- const targetPath = parsed.data.path;
170
- try {
171
- const fullPath = resolveSafePath(projectRoot, targetPath);
172
- if (!fs.existsSync(fullPath))
173
- return { content: [{ type: "text", text: `Path not found: ${targetPath}` }] };
174
- const stats = fs.statSync(fullPath);
175
- const tsProject = new Project({ compilerOptions: { allowJs: true } });
176
- if (stats.isDirectory()) {
177
- tsProject.addSourceFilesAtPaths(path.join(fullPath, "**/*.{ts,tsx,js,jsx}"));
178
- const sourceFiles = tsProject.getSourceFiles();
179
- return { content: [{ type: "text", text: `Directory contains ${sourceFiles.length} source files. Use a specific file path for deep dependency analysis.` }] };
180
- }
181
- else {
182
- const sourceFile = tsProject.addSourceFileAtPath(fullPath);
183
- const imports = sourceFile.getImportDeclarations();
184
- const importDetails = imports.map((imp) => {
185
- const moduleSpecifier = imp.getModuleSpecifierValue();
186
- const source = imp.getModuleSpecifierSourceFile();
187
- const resolvedPath = source ? path.relative(projectRoot, source.getFilePath()) : "unresolved/external";
188
- return `- ${moduleSpecifier} (${resolvedPath})`;
189
- });
190
- return { content: [{ type: "text", text: `Dependencies for ${targetPath}:\n${importDetails.length > 0 ? importDetails.join("\n") : "No imports found."}` }] };
191
- }
192
- }
193
- catch (error) {
194
- return { content: [{ type: "text", text: "Analysis failed: " + (error instanceof Error ? error.message : String(error)) }] };
195
- }
196
- },
197
- analyze_codebase_intelligence: async (args, projectRoot) => {
198
- const parsed = ANALYZE_CODEBASE_INTELLIGENCE_ARGS_SCHEMA.safeParse(args);
199
- const targetPath = parsed.success ? parsed.data.path : ".";
200
- try {
201
- const safeTargetPath = resolveSafePath(projectRoot, targetPath);
202
- if (!fs.existsSync(safeTargetPath))
203
- return { content: [{ type: "text", text: "Target path not found." }] };
204
- const tsProject = new Project({ compilerOptions: { allowJs: true } });
205
- tsProject.addSourceFilesAtPaths(path.join(safeTargetPath, "**/*.{ts,tsx}"));
206
- const complexitySpikes = [];
207
- const potentialDeadCode = [];
208
- for (const sourceFile of tsProject.getSourceFiles()) {
209
- const relativePath = path.relative(projectRoot, sourceFile.getFilePath());
210
- const lineCount = sourceFile.getEndLineNumber();
211
- if (lineCount > 300)
212
- complexitySpikes.push(`${relativePath} (${lineCount} lines)`);
213
- sourceFile.getExportedDeclarations().forEach((declarations, name) => {
214
- const isUsed = tsProject.getSourceFiles().some(sf => {
215
- if (sf === sourceFile)
216
- return false;
217
- return sf.getImportDeclarations().some(i => i.getModuleSpecifierValue().includes(sourceFile.getBaseNameWithoutExtension()) && i.getNamedImports().some(ni => ni.getName() === name));
218
- });
219
- if (!isUsed && !sourceFile.getFilePath().includes("index.ts") && !sourceFile.getFilePath().includes("shared-types")) {
220
- potentialDeadCode.push(`${relativePath} -> ${name}`);
221
- }
222
- });
223
- }
224
- return { content: [{ type: "text", text: `### CODEBASE INTELLIGENCE REPORT\n\n**Complexity Spikes (>300 lines):**\n${complexitySpikes.length > 0 ? complexitySpikes.map(s => `- ${s}`).join("\n") : "- None detected"}\n\n**Potential Dead Code (Unused Exports):**\n${potentialDeadCode.length > 0 ? potentialDeadCode.map(d => `- ${d}`).join("\n") : "- None detected (within scanned scope)"}` }] };
225
- }
226
- catch {
227
- return { content: [{ type: "text", text: "Intelligence scan failed." }] };
228
- }
229
- },
230
- analyze_procedural_continuity: async (args, projectRoot) => {
231
- const parsed = ANALYZE_PROCEDURAL_CONTINUITY_ARGS_SCHEMA.safeParse(args);
232
- if (!parsed.success)
233
- return { content: [{ type: "text", text: "Invalid targetPath or referencePath." }] };
234
- try {
235
- const targetFull = resolveSafePath(projectRoot, parsed.data.targetPath);
236
- const referenceFull = resolveSafePath(projectRoot, parsed.data.referencePath);
237
- if (!fs.existsSync(targetFull) || !fs.existsSync(referenceFull))
238
- return { content: [{ type: "text", text: "One or both files not found." }] };
239
- const tsProject = new Project({ compilerOptions: { allowJs: true } });
240
- const targetFile = tsProject.addSourceFileAtPath(targetFull);
241
- const referenceFile = tsProject.addSourceFileAtPath(referenceFull);
242
- const deviations = [];
243
- const targetImports = targetFile.getImportDeclarations().map(i => i.getModuleSpecifierValue());
244
- const referenceImports = referenceFile.getImportDeclarations().map(i => i.getModuleSpecifierValue());
245
- const missingImports = referenceImports.filter(i => !targetImports.includes(i) && !i.startsWith("."));
246
- if (missingImports.length > 0)
247
- deviations.push(`Missing standard imports found in reference: ${missingImports.join(", ")}`);
248
- if (referenceFile.getClasses().length > 0 && targetFile.getClasses().length === 0)
249
- deviations.push("Reference uses classes, but target does not.");
250
- const targetFunctions = targetFile.getFunctions().map(f => f.getName());
251
- const referenceFunctions = referenceFile.getFunctions().map(f => f.getName());
252
- if (referenceFunctions.some(f => f?.startsWith("get")) && !targetFunctions.some(f => f?.startsWith("get")))
253
- deviations.push("Reference uses 'get' prefix for functions, target does not.");
254
- return { content: [{ type: "text", text: deviations.length > 0 ? `### PROCEDURAL CONTINUITY DEVIATIONS\n\n${deviations.map(d => `- ${d}`).join("\n")}` : "No major structural or stylistic deviations detected based on reference." }] };
255
- }
256
- catch {
257
- return { content: [{ type: "text", text: "Dependency analysis failed." }] };
258
- }
259
- },
260
- generate_dependency_graph: async (args, projectRoot) => {
261
- const parsed = GENERATE_DEPENDENCY_GRAPH_ARGS_SCHEMA.safeParse(args);
262
- const targetPath = parsed.success ? parsed.data.path : "src";
263
- const format = parsed.success ? parsed.data.format : "mermaid";
264
- try {
265
- const safeTargetPath = resolveSafePath(projectRoot, targetPath);
266
- if (!fs.existsSync(safeTargetPath))
267
- return { content: [{ type: "text", text: "Target path not found." }] };
268
- const tsProject = new Project({ compilerOptions: { allowJs: true } });
269
- tsProject.addSourceFilesAtPaths(path.join(safeTargetPath, "**/*.{ts,tsx}"));
270
- const edges = [];
271
- for (const sourceFile of tsProject.getSourceFiles()) {
272
- const from = sourceFile.getBaseNameWithoutExtension();
273
- sourceFile.getImportDeclarations().forEach(imp => {
274
- const moduleSpecifier = imp.getModuleSpecifierValue();
275
- if (moduleSpecifier.startsWith(".")) {
276
- const to = path.basename(moduleSpecifier, path.extname(moduleSpecifier));
277
- edges.push({ from, to });
278
- }
279
- });
280
- }
281
- if (format === "json")
282
- return { content: [{ type: "text", text: JSON.stringify(edges, null, 2) }] };
283
- let mermaid = "graph TD\n";
284
- const uniqueEdges = Array.from(new Set(edges.map(e => `${e.from} --> ${e.to}`)));
285
- if (uniqueEdges.length === 0)
286
- return { content: [{ type: "text", text: "No internal dependencies found in the scanned path." }] };
287
- mermaid += uniqueEdges.join("\n");
288
- return { content: [{ type: "text", text: `### VISUAL ARCHITECTURE MAP: ${targetPath}\n\n\`\`\`mermaid\n${mermaid}\n\`\`\`\n\n**Total Nodes:** ${new Set(edges.flatMap(e => [e.from, e.to])).size} | **Total Edges:** ${uniqueEdges.length}` }] };
289
- }
290
- catch {
291
- return { content: [{ type: "text", text: "Dependency graph generation failed." }] };
292
- }
293
- },
294
- };