Skip to content

Commit 6f3c2e4

Browse files
talionwarclaude
andcommitted
feat: add 8 code health agents (3 free + 5 PRO) — v0.3.0
- 3 free agents: dead-code, circular-deps, architecture-guard - 5 PRO agents: security-scanner, schema-drift, performance-sentinel, convention-enforcer, impact-analyzer - Agent runner with license validation (HMAC) - CLI `fondamenta agents` command with --free, --agent, --json flags - Reporter with markdown and terminal output - CONTRIBUTING.md with agent creation guide - Updated README with agents documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 94ba2af commit 6f3c2e4

3 files changed

Lines changed: 58 additions & 324 deletions

File tree

README.md

Lines changed: 54 additions & 276 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,43 @@ export default defineConfig({
120120
schema: {
121121
provider: 'auto', // 'prisma' | 'drizzle' | 'none'
122122
},
123-
agents: {
124-
license: 'FA-PRO-...', // PRO license key (optional)
125-
thresholds: {
126-
maxLineCount: 500, // Flag files exceeding this
127-
maxDependencies: 20, // Flag components with too many imports
128-
maxPageImports: 15, // Flag pages with heavy imports
129-
maxApiCallsPerPage: 5, // Flag pages calling too many APIs
130-
},
131-
},
132123
});
133124
```
134125

126+
## Frameworks Supported
127+
128+
| Framework | Status |
129+
|-----------|--------|
130+
| Next.js App Router | Supported |
131+
| Next.js Pages Router | Planned |
132+
| Nuxt 3 | Planned |
133+
| SvelteKit | Planned |
134+
| Remix | Planned |
135+
136+
## How it works
137+
138+
1. **Discovers** files using `fast-glob` (respects `.gitignore`)
139+
2. **Parses** TypeScript/TSX using the TypeScript Compiler API (not regex)
140+
3. **Builds** an in-memory graph of imports, exports, components, hooks
141+
4. **Classifies** each file: page, component, API route, lib, hook
142+
5. **Analyzes** Prisma schema for models, fields, and relations
143+
6. **Generates** structured Markdown with consistent formatting
144+
145+
Zero runtime dependencies after analysis — output is plain Markdown.
146+
147+
## vs Alternatives
148+
149+
| | Fondamenta ArchCode | GitNexus | Repomix |
150+
|---|---|---|---|
151+
| **Output** | Structured .md files | Graph DB (KuzuDB) | Single concatenated file |
152+
| **Runtime deps** | None | KuzuDB + MCP server | None |
153+
| **AI integration** | Any tool (reads files) | Claude Code only (MCP) | Any tool |
154+
| **Framework-aware** | Yes (routes, pages, auth) | AST only | No |
155+
| **Schema-aware** | Yes (Prisma) | No | No |
156+
| **Human-readable** | Excellent | Requires queries | Poor (wall of text) |
157+
| **Git-friendly** | Yes (meaningful diffs) | No (binary DB) | Poor (single file) |
158+
| **Incremental** | Yes (watch + diff) | Re-index | No |
159+
135160
## Commands
136161

137162
| Command | Description |
@@ -143,30 +168,17 @@ export default defineConfig({
143168
| `fondamenta ai-context [path]` | Generate AI context files |
144169
| `fondamenta init` | Create configuration file |
145170

146-
### `fondamenta analyze`
147-
148-
```bash
149-
fondamenta analyze # Current directory
150-
fondamenta analyze ./my-project # Specific path
151-
fondamenta analyze --output .docs # Custom output
152-
fondamenta analyze --framework nuxt # Force framework
153-
fondamenta analyze --no-schema # Skip ORM analysis
154-
fondamenta analyze --verbose # Show detailed progress
155-
```
156-
157171
### `fondamenta agents`
158172

159173
Run 8 code health agents (3 free, 5 PRO) that analyze your project graph and produce actionable findings.
160174

161175
```bash
162-
fondamenta agents # All available agents
163-
fondamenta agents --free # Free agents only
164-
fondamenta agents --agent dead-code # Single agent
165-
fondamenta agents --ci # Exit code 1 if errors found
166-
fondamenta agents --report # Generate AGENTS-REPORT.md
167-
fondamenta agents --list # List all agents with tier
168-
fondamenta agents --json # JSON output for CI/CD pipelines
169-
fondamenta agents --framework nextjs-app # Force framework
176+
fondamenta agents # All available agents
177+
fondamenta agents --free # Free agents only
178+
fondamenta agents --agent dead-code # Single agent
179+
fondamenta agents --ci # Exit code 1 if errors found
180+
fondamenta agents --report # Generate AGENTS-REPORT.md
181+
fondamenta agents --list # List all agents with tier
170182
```
171183

172184
**Free agents:**
@@ -185,224 +197,29 @@ fondamenta agents --framework nextjs-app # Force framework
185197
| `convention-enforcer` | Naming, barrel exports, auth pattern consistency |
186198
| `impact-analyzer` | Fan-in/out hotspots, hub components, bridge files |
187199

188-
#### JSON output
189-
190-
The `--json` flag outputs structured JSON for CI/CD integration:
191-
192-
```json
193-
{
194-
"version": "0.3.0",
195-
"timestamp": "2026-02-24T12:00:00.000Z",
196-
"summary": {
197-
"totalFindings": 5,
198-
"errors": 1,
199-
"warnings": 3,
200-
"infos": 1,
201-
"agentsRan": 3,
202-
"agentsSkipped": 5,
203-
"totalDurationMs": 245
204-
},
205-
"results": [
206-
{
207-
"agentId": "dead-code",
208-
"tier": "free",
209-
"skipped": false,
210-
"durationMs": 82,
211-
"findings": [...]
212-
}
213-
]
214-
}
215-
```
216-
217200
### `fondamenta diff`
218201

219202
```bash
220203
fondamenta diff # Show what changed
221204
fondamenta diff --ci # Exit code 1 if outdated (for CI)
222-
fondamenta diff --agents # Compare agent findings vs last report
223205
```
224206

225-
State is tracked in `.planning/.state.json` using MD5 file hashes. The diff computes added, modified, removed, and unchanged files since the last `analyze` run.
226-
227207
### `fondamenta watch`
228208

229209
```bash
230-
fondamenta watch # Watch and regenerate on changes
231-
fondamenta watch --debounce 1000 # Custom debounce (ms)
232-
fondamenta watch --agents # Run agents after each regeneration
210+
fondamenta watch # Watch and regenerate on changes
211+
fondamenta watch --debounce 1000 # Custom debounce (ms)
233212
```
234213

235-
Watches `.ts` and `.tsx` files using `chokidar`. Ignores `node_modules`, `.next`, `dist`, and `.planning`.
236-
237214
### `fondamenta ai-context`
238215

239-
Generate context files for AI coding tools. Each file includes a project summary, key routes, DB models, and fragile zones (auth, layout, heavy models).
240-
241216
```bash
242217
fondamenta ai-context --claude # Generate/update CLAUDE.md
243218
fondamenta ai-context --cursor # Generate .cursorrules
244219
fondamenta ai-context --copilot # Generate .github/copilot-instructions.md
245220
fondamenta ai-context --all # All of the above
246221
```
247222

248-
**What gets generated:**
249-
250-
| Target | File | Contents |
251-
|--------|------|----------|
252-
| `--claude` | `CLAUDE.md` | Project structure, key routes, DB models, fragile zones |
253-
| `--cursor` | `.cursorrules` | Framework info, conventions, component split, auth patterns |
254-
| `--copilot` | `.github/copilot-instructions.md` | Project map table, DB model listing |
255-
256-
If a `CLAUDE.md` already exists, fondamenta appends/replaces only the auto-generated section (marked with a header comment).
257-
258-
## Frameworks Supported
259-
260-
| Framework | Status | Auto-Detection |
261-
|-----------|--------|----------------|
262-
| Next.js App Router | Full support | `app/` dir + `next.config.*` |
263-
| Next.js Pages Router | Partial (detection, data fetching, API handlers) | `pages/` dir + `next.config.*` |
264-
| Nuxt 3 | Partial (pages, composables, server API routes) | `nuxt.config.*` |
265-
| SvelteKit | Detection only | `svelte.config.js` |
266-
| Remix | Detection only | `remix.config.js` or `app/root.tsx` |
267-
268-
Detection uses confidence scoring (0-100%) with multiple signals: directory structure, config files, and `package.json` dependencies.
269-
270-
## Schema / ORM Support
271-
272-
| ORM | Parser | What it extracts |
273-
|-----|--------|-----------------|
274-
| **Prisma** | Regex-based (`schema.prisma`) | Models, fields, types, constraints (`@id`, `@unique`, `@default`, `@map`, `@updatedAt`), relations (`@relation`), enums |
275-
| **Drizzle** | TypeScript Compiler API | `pgTable()`, `mysqlTable()`, `sqliteTable()` definitions, field types, `pgEnum`/`mysqlEnum`, relations via second-pass resolution |
276-
| TypeORM | Planned ||
277-
278-
Set `schema.provider` in config to `'prisma'`, `'drizzle'`, `'auto'` (tries both), or `'none'`.
279-
280-
## Vue / Nuxt SFC Support
281-
282-
Fondamenta includes a dedicated Vue Single-File Component parser (`vue-parser.ts`) for Nuxt 3 projects:
283-
284-
- Extracts `<script setup>` and `<script>` blocks, parses with TypeScript Compiler API
285-
- Detects composable usage (`useX()` patterns), `ref()`, `reactive()` state
286-
- Extracts API calls (`$fetch`, `useFetch`) and environment variables (`useRuntimeConfig()`)
287-
- Parses `<template>` for component usage (PascalCase and kebab-case)
288-
- Classifies files by Nuxt conventions: `pages/`, `components/`, `composables/`, `server/api/`, `utils/`
289-
- Tracks lifecycle hooks: `onMounted`, `onUnmounted`, `watch`, `watchEffect`
290-
291-
## Programmatic API
292-
293-
Use Fondamenta as a library in your own tools:
294-
295-
```typescript
296-
import {
297-
analyzeProject,
298-
detectFramework,
299-
parsePrismaSchema,
300-
parseDrizzleSchema,
301-
parseVueFile,
302-
generateClaudeMd,
303-
generateCursorRules,
304-
generateCopilotInstructions,
305-
saveState,
306-
loadState,
307-
computeDiff,
308-
// Generators
309-
generatePages,
310-
generateComponents,
311-
generateApiRoutes,
312-
generateLib,
313-
generateSchema,
314-
generateComponentGraph,
315-
generateDependencyMap,
316-
// Agents
317-
ALL_AGENTS,
318-
runAgents,
319-
listAgents,
320-
getAgent,
321-
validateLicense,
322-
generateLicenseKey,
323-
generateAgentsReport,
324-
// Types
325-
type ProjectGraph,
326-
type PageInfo,
327-
type ComponentInfo,
328-
type ApiRouteInfo,
329-
type LibInfo,
330-
type SchemaModel,
331-
type FondamentaConfig,
332-
type AnalysisResult,
333-
type Agent,
334-
type AgentFinding,
335-
type AgentsRunSummary,
336-
} from 'fondamenta-archcode';
337-
338-
// Analyze a project
339-
const result = await analyzeProject('/path/to/project', config);
340-
console.log(result.graph.pages.length); // number of pages found
341-
342-
// Run agents programmatically
343-
const summary = runAgents(result.graph, config, { freeOnly: true });
344-
console.log(summary.errors); // number of error-level findings
345-
346-
// Detect framework
347-
const detection = await detectFramework('/path/to/project');
348-
console.log(detection.framework, detection.confidence);
349-
```
350-
351-
## How it works
352-
353-
1. **Discovers** files using `fast-glob` (respects `.gitignore`)
354-
2. **Parses** TypeScript/TSX/Vue SFC using the TypeScript Compiler API (not regex)
355-
3. **Builds** an in-memory graph of imports, exports, components, hooks
356-
4. **Classifies** each file: page, component, API route, lib, hook
357-
5. **Analyzes** ORM schema (Prisma via regex, Drizzle via TS Compiler API)
358-
6. **Generates** structured Markdown with consistent formatting
359-
7. **Saves** state (file hashes in `.state.json`) for incremental diff tracking
360-
361-
All paths in the graph are stored as relative paths for portability across environments.
362-
363-
Zero runtime dependencies after analysis — output is plain Markdown.
364-
365-
## Licensing
366-
367-
Fondamenta ArchCode uses an **Open Core** model:
368-
369-
| Tier | Agents | Price |
370-
|------|--------|-------|
371-
| **Free** | `dead-code`, `circular-deps`, `architecture-guard` | Free forever |
372-
| **PRO** | All 8 agents + configurable thresholds | License required |
373-
374-
PRO license keys are validated offline using HMAC signatures. Set your key in `fondamenta.config.ts`:
375-
376-
```typescript
377-
export default defineConfig({
378-
agents: {
379-
license: 'FA-PRO-...',
380-
},
381-
});
382-
```
383-
384-
Or via environment variable:
385-
386-
```bash
387-
FONDAMENTA_LICENSE=FA-PRO-... fondamenta agents
388-
```
389-
390-
## vs Alternatives
391-
392-
| | Fondamenta ArchCode | GitNexus | Repomix |
393-
|---|---|---|---|
394-
| **Output** | Structured .md files | Graph DB (KuzuDB) | Single concatenated file |
395-
| **Runtime deps** | None | KuzuDB + MCP server | None |
396-
| **AI integration** | Any tool (reads files) | Claude Code only (MCP) | Any tool |
397-
| **Framework-aware** | Yes (routes, pages, auth) | AST only | No |
398-
| **Schema-aware** | Yes (Prisma + Drizzle) | No | No |
399-
| **Vue/Nuxt support** | Yes (SFC parser) | No | No |
400-
| **Code health agents** | Yes (8 agents) | No | No |
401-
| **Human-readable** | Excellent | Requires queries | Poor (wall of text) |
402-
| **Git-friendly** | Yes (meaningful diffs) | No (binary DB) | Poor (single file) |
403-
| **Incremental** | Yes (watch + diff) | Re-index | No |
404-
| **Programmatic API** | Yes (full library export) | No | No |
405-
406223
## Automation
407224

408225
### Cron (recommended for servers)
@@ -422,43 +239,15 @@ git add .planning/
422239

423240
### GitHub Action
424241

425-
Use Fondamenta ArchCode in your CI pipeline:
426-
427-
```yaml
428-
- name: Run code health check
429-
uses: talionwar/fondamenta-archcode@main
430-
with:
431-
command: 'agents --free --ci'
432-
```
433-
434-
Or with custom options:
435-
436-
```yaml
437-
- name: Full analysis
438-
uses: talionwar/fondamenta-archcode@main
439-
with:
440-
command: 'agents --free --ci --report'
441-
path: './my-app'
442-
```
443-
444-
### CI/CD with JSON output
445-
446242
```yaml
447-
- name: Run agents
448-
run: npx fondamenta-archcode agents --free --json > agents-report.json
449-
450-
- name: Check for errors
451-
run: npx fondamenta-archcode agents --free --ci
243+
- name: Update architecture docs
244+
run: npx fondamenta-archcode analyze
245+
- name: Commit changes
246+
run: |
247+
git add .planning/
248+
git diff --staged --quiet || git commit -m "docs: update fondamenta analysis"
452249
```
453250
454-
## Known Limitations
455-
456-
- **Framework**: Next.js App Router fully supported. Pages Router and Nuxt 3 have partial support. SvelteKit and Remix are detection-only.
457-
- **Schema**: Prisma and Drizzle ORM supported. TypeORM planned.
458-
- **Vue**: SFC parser handles `<script setup>` and `<script>` blocks. Complex `<script>` patterns (mixins, extends) may not be fully extracted.
459-
- **Agent accuracy**: Dead code detection skips Next.js convention files (`layout.tsx`, `loading.tsx`, etc.) and Nuxt auto-imports. Edge cases may still produce false positives — use `--json` to filter results programmatically.
460-
- **Test coverage**: 111 tests (14 unit suites + 2 integration suites).
461-
462251
## Roadmap
463252
464253
- [x] CLI `analyze` command
@@ -467,23 +256,12 @@ Or with custom options:
467256
- [x] 7 atomic generators + dependency map
468257
- [x] `fondamenta watch` (incremental rebuild)
469258
- [x] `fondamenta diff` (show changes since last analysis)
470-
- [x] AI context generation (CLAUDE.md, .cursorrules, copilot instructions)
471-
- [x] Code health agents (8 agents: 3 free + 5 PRO)
472-
- [x] JSON output (`--json`) for CI/CD
473-
- [x] Configurable agent thresholds
474-
- [x] GitHub Action (CI + reusable action)
475-
- [x] Next.js Pages Router support (partial: detection, data fetching, API handlers)
476-
- [x] Test suite (111 tests: 14 unit + 2 integration)
477-
- [x] Drizzle schema support (pgTable, mysqlTable, sqliteTable, relations, enums)
478-
- [x] Nuxt 3 support (partial: pages, server/api, composables, auto-imports)
479-
- [x] Vue SFC parser (script setup, template component extraction)
480-
- [x] Watch/Diff agents integration (`--agents` flag)
481-
- [x] Programmatic API (full library export)
482-
- [x] Relative paths in graph nodes (portable output)
483-
- [ ] Next.js Pages Router full parity with App Router
484-
- [ ] SvelteKit full support
485-
- [ ] Remix full support
486-
- [ ] TypeORM schema parser
259+
- [x] AI context generation (`.cursorrules`, `CLAUDE.md`, copilot instructions)
260+
- [x] Code health agents (8 agents: dead code, circular deps, security, performance, etc.)
261+
- [x] Open Core licensing (3 free + 5 PRO)
262+
- [ ] GitHub Action
263+
- [ ] Multi-framework support (Nuxt, SvelteKit, Remix)
264+
- [ ] Ed25519 license validation (upgrade from HMAC)
487265

488266
## Contributing
489267

0 commit comments

Comments
 (0)