ai-first-cli 1.1.1 → 1.1.2
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.
- package/CHANGELOG.md +78 -0
- package/README.es.md +137 -1
- package/README.md +136 -4
- package/ai/ai_context.md +2 -2
- package/ai/architecture.md +3 -3
- package/ai/cache.json +85 -57
- package/ai/ccp/jira-123/context.json +7 -0
- package/ai/context/repo.json +56 -0
- package/ai/context/utils.json +7 -0
- package/ai/dependencies.json +51 -1026
- package/ai/files.json +195 -3
- package/ai/git/commit-activity.json +8646 -0
- package/ai/git/recent-features.json +1 -0
- package/ai/git/recent-files.json +52 -0
- package/ai/git/recent-flows.json +1 -0
- package/ai/graph/knowledge-graph.json +43643 -0
- package/ai/graph/module-graph.json +4 -0
- package/ai/graph/symbol-graph.json +3307 -879
- package/ai/graph/symbol-references.json +119 -32
- package/ai/index-state.json +843 -188
- package/ai/index.db +0 -0
- package/ai/modules.json +4 -0
- package/ai/repo-map.json +81 -17
- package/ai/repo_map.json +81 -17
- package/ai/repo_map.md +21 -7
- package/ai/summary.md +5 -5
- package/ai/symbols.json +1 -20287
- package/dist/analyzers/androidResources.d.ts +23 -0
- package/dist/analyzers/androidResources.d.ts.map +1 -0
- package/dist/analyzers/androidResources.js +93 -0
- package/dist/analyzers/androidResources.js.map +1 -0
- package/dist/analyzers/dependencies.d.ts.map +1 -1
- package/dist/analyzers/dependencies.js +37 -0
- package/dist/analyzers/dependencies.js.map +1 -1
- package/dist/analyzers/entrypoints.d.ts.map +1 -1
- package/dist/analyzers/entrypoints.js +71 -1
- package/dist/analyzers/entrypoints.js.map +1 -1
- package/dist/analyzers/gradleModules.d.ts +22 -0
- package/dist/analyzers/gradleModules.d.ts.map +1 -0
- package/dist/analyzers/gradleModules.js +75 -0
- package/dist/analyzers/gradleModules.js.map +1 -0
- package/dist/analyzers/techStack.d.ts +7 -0
- package/dist/analyzers/techStack.d.ts.map +1 -1
- package/dist/analyzers/techStack.js +44 -1
- package/dist/analyzers/techStack.js.map +1 -1
- package/dist/commands/ai-first.d.ts.map +1 -1
- package/dist/commands/ai-first.js +311 -1
- package/dist/commands/ai-first.js.map +1 -1
- package/dist/core/adapters/adapterRegistry.d.ts +39 -0
- package/dist/core/adapters/adapterRegistry.d.ts.map +1 -0
- package/dist/core/adapters/adapterRegistry.js +155 -0
- package/dist/core/adapters/adapterRegistry.js.map +1 -0
- package/dist/core/adapters/baseAdapter.d.ts +49 -0
- package/dist/core/adapters/baseAdapter.d.ts.map +1 -0
- package/dist/core/adapters/baseAdapter.js +28 -0
- package/dist/core/adapters/baseAdapter.js.map +1 -0
- package/dist/core/adapters/community/fastapiAdapter.d.ts +7 -0
- package/dist/core/adapters/community/fastapiAdapter.d.ts.map +1 -0
- package/dist/core/adapters/community/fastapiAdapter.js +40 -0
- package/dist/core/adapters/community/fastapiAdapter.js.map +1 -0
- package/dist/core/adapters/community/index.d.ts +11 -0
- package/dist/core/adapters/community/index.d.ts.map +1 -0
- package/dist/core/adapters/community/index.js +11 -0
- package/dist/core/adapters/community/index.js.map +1 -0
- package/dist/core/adapters/community/laravelAdapter.d.ts +7 -0
- package/dist/core/adapters/community/laravelAdapter.d.ts.map +1 -0
- package/dist/core/adapters/community/laravelAdapter.js +47 -0
- package/dist/core/adapters/community/laravelAdapter.js.map +1 -0
- package/dist/core/adapters/community/nestjsAdapter.d.ts +7 -0
- package/dist/core/adapters/community/nestjsAdapter.d.ts.map +1 -0
- package/dist/core/adapters/community/nestjsAdapter.js +48 -0
- package/dist/core/adapters/community/nestjsAdapter.js.map +1 -0
- package/dist/core/adapters/community/phoenixAdapter.d.ts +7 -0
- package/dist/core/adapters/community/phoenixAdapter.d.ts.map +1 -0
- package/dist/core/adapters/community/phoenixAdapter.js +45 -0
- package/dist/core/adapters/community/phoenixAdapter.js.map +1 -0
- package/dist/core/adapters/community/springBootAdapter.d.ts +7 -0
- package/dist/core/adapters/community/springBootAdapter.d.ts.map +1 -0
- package/dist/core/adapters/community/springBootAdapter.js +44 -0
- package/dist/core/adapters/community/springBootAdapter.js.map +1 -0
- package/dist/core/adapters/dotnetAdapter.d.ts +20 -0
- package/dist/core/adapters/dotnetAdapter.d.ts.map +1 -0
- package/dist/core/adapters/dotnetAdapter.js +86 -0
- package/dist/core/adapters/dotnetAdapter.js.map +1 -0
- package/dist/core/adapters/index.d.ts +18 -0
- package/dist/core/adapters/index.d.ts.map +1 -0
- package/dist/core/adapters/index.js +19 -0
- package/dist/core/adapters/index.js.map +1 -0
- package/dist/core/adapters/javascriptAdapter.d.ts +11 -0
- package/dist/core/adapters/javascriptAdapter.d.ts.map +1 -0
- package/dist/core/adapters/javascriptAdapter.js +47 -0
- package/dist/core/adapters/javascriptAdapter.js.map +1 -0
- package/dist/core/adapters/pythonAdapter.d.ts +20 -0
- package/dist/core/adapters/pythonAdapter.d.ts.map +1 -0
- package/dist/core/adapters/pythonAdapter.js +99 -0
- package/dist/core/adapters/pythonAdapter.js.map +1 -0
- package/dist/core/adapters/railsAdapter.d.ts +10 -0
- package/dist/core/adapters/railsAdapter.d.ts.map +1 -0
- package/dist/core/adapters/railsAdapter.js +52 -0
- package/dist/core/adapters/railsAdapter.js.map +1 -0
- package/dist/core/adapters/salesforceAdapter.d.ts +16 -0
- package/dist/core/adapters/salesforceAdapter.d.ts.map +1 -0
- package/dist/core/adapters/salesforceAdapter.js +64 -0
- package/dist/core/adapters/salesforceAdapter.js.map +1 -0
- package/dist/core/adapters/sdk.d.ts +83 -0
- package/dist/core/adapters/sdk.d.ts.map +1 -0
- package/dist/core/adapters/sdk.js +114 -0
- package/dist/core/adapters/sdk.js.map +1 -0
- package/dist/core/ccp.d.ts +37 -0
- package/dist/core/ccp.d.ts.map +1 -0
- package/dist/core/ccp.js +184 -0
- package/dist/core/ccp.js.map +1 -0
- package/dist/core/gitAnalyzer.d.ts +74 -0
- package/dist/core/gitAnalyzer.d.ts.map +1 -0
- package/dist/core/gitAnalyzer.js +298 -0
- package/dist/core/gitAnalyzer.js.map +1 -0
- package/dist/core/incrementalAnalyzer.d.ts +28 -0
- package/dist/core/incrementalAnalyzer.d.ts.map +1 -0
- package/dist/core/incrementalAnalyzer.js +343 -0
- package/dist/core/incrementalAnalyzer.js.map +1 -0
- package/dist/core/knowledgeGraphBuilder.d.ts +31 -0
- package/dist/core/knowledgeGraphBuilder.d.ts.map +1 -0
- package/dist/core/knowledgeGraphBuilder.js +197 -0
- package/dist/core/knowledgeGraphBuilder.js.map +1 -0
- package/dist/core/lazyAnalyzer.d.ts +57 -0
- package/dist/core/lazyAnalyzer.d.ts.map +1 -0
- package/dist/core/lazyAnalyzer.js +204 -0
- package/dist/core/lazyAnalyzer.js.map +1 -0
- package/dist/core/schema.d.ts +57 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +131 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/semanticContexts.d.ts +40 -0
- package/dist/core/semanticContexts.d.ts.map +1 -0
- package/dist/core/semanticContexts.js +454 -0
- package/dist/core/semanticContexts.js.map +1 -0
- package/docs/es/guide/adapters.md +143 -0
- package/docs/es/guide/ai-repository-schema.md +119 -0
- package/docs/es/guide/features.md +67 -0
- package/docs/es/guide/flows.md +134 -0
- package/docs/es/guide/git-intelligence.md +170 -0
- package/docs/es/guide/incremental-analysis.md +131 -0
- package/docs/es/guide/knowledge-graph.md +135 -0
- package/docs/es/guide/lazy-indexing.md +144 -0
- package/docs/es/guide/performance.md +125 -0
- package/docs/guide/adapters.md +225 -0
- package/docs/guide/ai-repository-schema.md +119 -0
- package/docs/guide/architecture.md +69 -1
- package/docs/guide/flows.md +134 -0
- package/docs/guide/git-intelligence.md +170 -0
- package/docs/guide/incremental-analysis.md +131 -0
- package/docs/guide/knowledge-graph.md +135 -0
- package/docs/guide/lazy-indexing.md +144 -0
- package/docs/guide/performance.md +125 -0
- package/package.json +5 -2
- package/src/analyzers/androidResources.ts +113 -0
- package/src/analyzers/dependencies.ts +41 -0
- package/src/analyzers/entrypoints.ts +80 -1
- package/src/analyzers/gradleModules.ts +100 -0
- package/src/analyzers/techStack.ts +56 -0
- package/src/commands/ai-first.ts +342 -1
- package/src/core/adapters/adapterRegistry.ts +187 -0
- package/src/core/adapters/baseAdapter.ts +82 -0
- package/src/core/adapters/community/fastapiAdapter.ts +50 -0
- package/src/core/adapters/community/index.ts +11 -0
- package/src/core/adapters/community/laravelAdapter.ts +56 -0
- package/src/core/adapters/community/nestjsAdapter.ts +57 -0
- package/src/core/adapters/community/phoenixAdapter.ts +54 -0
- package/src/core/adapters/community/springBootAdapter.ts +53 -0
- package/src/core/adapters/dotnetAdapter.ts +104 -0
- package/src/core/adapters/index.ts +24 -0
- package/src/core/adapters/javascriptAdapter.ts +56 -0
- package/src/core/adapters/pythonAdapter.ts +118 -0
- package/src/core/adapters/railsAdapter.ts +65 -0
- package/src/core/adapters/salesforceAdapter.ts +76 -0
- package/src/core/adapters/sdk.ts +172 -0
- package/src/core/ccp.ts +240 -0
- package/src/core/gitAnalyzer.ts +391 -0
- package/src/core/incrementalAnalyzer.ts +382 -0
- package/src/core/knowledgeGraphBuilder.ts +181 -0
- package/src/core/lazyAnalyzer.ts +261 -0
- package/src/core/schema.ts +157 -0
- package/src/core/semanticContexts.ts +575 -0
- package/tests/adapters.test.ts +159 -0
- package/tests/gitAnalyzer.test.ts +133 -0
- package/tests/incrementalAnalyzer.test.ts +83 -0
- package/tests/knowledgeGraph.test.ts +146 -0
- package/tests/lazyAnalyzer.test.ts +230 -0
- package/tests/schema.test.ts +203 -0
- package/tests/semanticContexts.test.ts +435 -0
- package/ai/context/analyzers.Symbol.json +0 -19
- package/ai/context/analyzers.extractSymbols.json +0 -19
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Analysis Adapters
|
|
2
|
+
|
|
3
|
+
AI-First uses an adapter system to support multiple languages and frameworks without modifying the core analysis engine.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Adapters customize how AI-First detects:
|
|
8
|
+
- **Feature roots**: Where to look for business features
|
|
9
|
+
- **Entrypoints**: Files that represent entry points
|
|
10
|
+
- **Layers**: Architectural layers in the codebase
|
|
11
|
+
- **Ignored folders**: Technical directories to skip
|
|
12
|
+
|
|
13
|
+
## Supported Adapters
|
|
14
|
+
|
|
15
|
+
| Adapter | Detection Signals |
|
|
16
|
+
|---------|-------------------|
|
|
17
|
+
| JavaScript/TypeScript | `package.json`, `tsconfig.json`, `vite.config.ts` |
|
|
18
|
+
| NestJS | `nest-cli.json`, `main.ts` |
|
|
19
|
+
| Django | `manage.py`, `settings.py` |
|
|
20
|
+
| Flask/FastAPI | `app.py`, `main.py`, `requirements.txt` |
|
|
21
|
+
| FastAPI | `main.py`, `app.py` |
|
|
22
|
+
| Ruby on Rails | `Gemfile`, `config.ru` |
|
|
23
|
+
| Laravel | `artisan`, `composer.json` |
|
|
24
|
+
| Elixir Phoenix | `mix.exs`, `phoenix` |
|
|
25
|
+
| Spring Boot | `pom.xml`, `build.gradle`, `application.java` |
|
|
26
|
+
| Salesforce | `sfdx-project.json`, `force-app/` |
|
|
27
|
+
| .NET | `*.csproj`, `Program.cs` |
|
|
28
|
+
| ASP.NET Core | `Startup.cs`, `Program.cs` |
|
|
29
|
+
| Blazor | `_Imports.razor`, `@page` |
|
|
30
|
+
|
|
31
|
+
| Adapter | Detection Signals |
|
|
32
|
+
|---------|------------------|
|
|
33
|
+
| JavaScript/TypeScript | `package.json`, `tsconfig.json`, `vite.config.ts` |
|
|
34
|
+
| Django | `manage.py`, `settings.py` |
|
|
35
|
+
| Flask/FastAPI | `app.py`, `main.py` |
|
|
36
|
+
| Ruby on Rails | `Gemfile`, `config.ru` |
|
|
37
|
+
| Salesforce | `sfdx-project.json`, `force-app/` |
|
|
38
|
+
| .NET | `*.csproj`, `Program.cs` |
|
|
39
|
+
| ASP.NET Core | `Startup.cs`, `Program.cs` |
|
|
40
|
+
| Blazor | `_Imports.razor`, `@page` |
|
|
41
|
+
|
|
42
|
+
## Architecture
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
analysis/
|
|
46
|
+
adapters/
|
|
47
|
+
baseAdapter.ts # Interface definition
|
|
48
|
+
javascriptAdapter.ts
|
|
49
|
+
pythonAdapter.ts
|
|
50
|
+
railsAdapter.ts
|
|
51
|
+
salesforceAdapter.ts
|
|
52
|
+
dotnetAdapter.ts
|
|
53
|
+
adapterRegistry.ts # Detection logic
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Adapter Interface
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface AnalysisAdapter {
|
|
60
|
+
name: string;
|
|
61
|
+
displayName: string;
|
|
62
|
+
detectionSignals: DetectionSignal[];
|
|
63
|
+
featureRoots: string[];
|
|
64
|
+
ignoredFolders: string[];
|
|
65
|
+
entrypointPatterns: string[];
|
|
66
|
+
layerRules: LayerRule[];
|
|
67
|
+
supportedExtensions: string[];
|
|
68
|
+
flowEntrypointPatterns: string[];
|
|
69
|
+
flowExcludePatterns: string[];
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Detection Signals
|
|
74
|
+
|
|
75
|
+
Adapters are detected using signals:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
interface DetectionSignal {
|
|
79
|
+
type: 'file' | 'directory' | 'content';
|
|
80
|
+
pattern: string;
|
|
81
|
+
contentPattern?: string;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Example:
|
|
86
|
+
```typescript
|
|
87
|
+
detectionSignals: [
|
|
88
|
+
{ type: 'file', pattern: 'package.json' },
|
|
89
|
+
{ type: 'file', pattern: 'tsconfig.json' },
|
|
90
|
+
{ type: 'directory', pattern: 'src' }
|
|
91
|
+
]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Layer Rules
|
|
95
|
+
|
|
96
|
+
Each adapter defines architectural layers:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
layerRules: [
|
|
100
|
+
{ name: 'api', priority: 1, patterns: ['controller', 'handler', 'route'] },
|
|
101
|
+
{ name: 'service', priority: 2, patterns: ['service', 'usecase'] },
|
|
102
|
+
{ name: 'data', priority: 3, patterns: ['repository', 'model'] }
|
|
103
|
+
]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Usage
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { detectAdapter, getAdapter } from './core/adapters/index.js';
|
|
110
|
+
|
|
111
|
+
// Auto-detect project type
|
|
112
|
+
const adapter = detectAdapter('/path/to/project');
|
|
113
|
+
console.log(adapter.name); // 'javascript', 'django', etc.
|
|
114
|
+
|
|
115
|
+
// Get specific adapter
|
|
116
|
+
const jsAdapter = getAdapter('javascript');
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Creating Custom Adapters
|
|
120
|
+
|
|
121
|
+
1. Create a new file in `src/core/adapters/`
|
|
122
|
+
2. Define your adapter:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { AnalysisAdapter } from './baseAdapter.js';
|
|
126
|
+
|
|
127
|
+
export const myAdapter: AnalysisAdapter = {
|
|
128
|
+
name: 'myframework',
|
|
129
|
+
displayName: 'My Framework',
|
|
130
|
+
detectionSignals: [
|
|
131
|
+
{ type: 'file', pattern: 'my-framework.config.js' }
|
|
132
|
+
],
|
|
133
|
+
featureRoots: ['src', 'lib'],
|
|
134
|
+
ignoredFolders: ['node_modules', 'dist'],
|
|
135
|
+
entrypointPatterns: ['controller', 'service'],
|
|
136
|
+
layerRules: [
|
|
137
|
+
{ name: 'api', priority: 1, patterns: ['controller'] },
|
|
138
|
+
{ name: 'service', priority: 2, patterns: ['service'] },
|
|
139
|
+
{ name: 'data', priority: 3, patterns: ['model'] }
|
|
140
|
+
],
|
|
141
|
+
supportedExtensions: ['.ts', '.js'],
|
|
142
|
+
flowEntrypointPatterns: ['controller'],
|
|
143
|
+
flowExcludePatterns: ['test', 'spec']
|
|
144
|
+
};
|
|
145
|
+
3. Register in `adapterRegistry.ts`
|
|
146
|
+
4. Add tests
|
|
147
|
+
|
|
148
|
+
## Using the Adapter SDK
|
|
149
|
+
|
|
150
|
+
AI-First provides a developer-friendly SDK for creating custom adapters:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { createAdapter, validateAdapter, fileSignal, directorySignal } from './core/adapters/sdk.js';
|
|
154
|
+
|
|
155
|
+
// Create adapter with sensible defaults
|
|
156
|
+
export const myAdapter = createAdapter({
|
|
157
|
+
name: 'myframework',
|
|
158
|
+
displayName: 'My Framework',
|
|
159
|
+
detectionSignals: [
|
|
160
|
+
fileSignal('my-framework.config.js'),
|
|
161
|
+
directorySignal('src')
|
|
162
|
+
],
|
|
163
|
+
featureRoots: ['src', 'lib', 'app'],
|
|
164
|
+
entrypointPatterns: ['Controller', 'Service', 'Handler']
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Validate your adapter
|
|
168
|
+
const result = validateAdapter(myAdapter);
|
|
169
|
+
if (!result.valid) {
|
|
170
|
+
console.error('Adapter errors:', result.errors);
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### SDK Functions
|
|
175
|
+
|
|
176
|
+
- `createAdapter(config)` - Create adapter with defaults
|
|
177
|
+
- `validateAdapter(adapter)` - Validate adapter configuration
|
|
178
|
+
- `fileSignal(pattern)` - Create file detection signal
|
|
179
|
+
- `directorySignal(pattern)` - Create directory detection signal
|
|
180
|
+
- `contentSignal(pattern, contentPattern?)` - Create content-based signal
|
|
181
|
+
- `layerRule(name, priority, patterns)` - Create layer rule
|
|
182
|
+
|
|
183
|
+
## Community Adapters
|
|
184
|
+
|
|
185
|
+
Community adapters are located in `src/core/adapters/community/`:
|
|
186
|
+
|
|
187
|
+
- **Laravel** - PHP Laravel framework
|
|
188
|
+
- **NestJS** - Node.js progressive framework
|
|
189
|
+
- **Spring Boot** - Java/Kotlin framework
|
|
190
|
+
- **Phoenix** - Elixir web framework
|
|
191
|
+
- **FastAPI** - Python modern framework
|
|
192
|
+
|
|
193
|
+
### Listing Available Adapters
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
ai-first adapters
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Output:
|
|
200
|
+
```
|
|
201
|
+
📦 Available adapters:
|
|
202
|
+
|
|
203
|
+
Name | Display Name
|
|
204
|
+
--------------------|---
|
|
205
|
+
javascript | JavaScript / TypeScript
|
|
206
|
+
nestjs | NestJS
|
|
207
|
+
django | Django
|
|
208
|
+
...
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Integration
|
|
212
|
+
|
|
213
|
+
3. Register in `adapterRegistry.ts`
|
|
214
|
+
4. Add tests
|
|
215
|
+
|
|
216
|
+
## Integration
|
|
217
|
+
|
|
218
|
+
Adapters integrate with feature and flow detection:
|
|
219
|
+
|
|
220
|
+
- `featureRoots` → where to find features
|
|
221
|
+
- `ignoredFolders` → what to skip
|
|
222
|
+
- `entrypointPatterns` → business logic entry points
|
|
223
|
+
- `layerRules` → flow chain layers
|
|
224
|
+
|
|
225
|
+
This allows AI-First to understand any codebase structure.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# AI Repository Schema
|
|
2
|
+
|
|
3
|
+
The AI Repository Schema standardizes how AI-First stores and manages repository metadata, enabling AI agents to understand project structure and maintain compatibility across versions.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
AI-First generates three core schema files that define the project structure:
|
|
8
|
+
|
|
9
|
+
- `schema.json` - Schema version and metadata
|
|
10
|
+
- `project.json` - Project information (features, flows, languages, frameworks)
|
|
11
|
+
- `tools.json` - Compatible AI tools and agents
|
|
12
|
+
|
|
13
|
+
## Schema Files
|
|
14
|
+
|
|
15
|
+
### schema.json
|
|
16
|
+
|
|
17
|
+
Contains schema version and generation metadata:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"schemaVersion": "1.0",
|
|
22
|
+
"generatedBy": "ai-first",
|
|
23
|
+
"generatedAt": "2024-01-15T10:30:00.000Z"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### project.json
|
|
28
|
+
|
|
29
|
+
Contains project-specific information:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"name": "my-project",
|
|
34
|
+
"rootDir": "/path/to/project",
|
|
35
|
+
"features": ["auth", "users", "payments"],
|
|
36
|
+
"flows": ["login", "checkout", "registration"],
|
|
37
|
+
"languages": ["TypeScript", "Python"],
|
|
38
|
+
"frameworks": ["Express", "React"],
|
|
39
|
+
"generatedAt": "2024-01-15T10:30:00.000Z"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### tools.json
|
|
44
|
+
|
|
45
|
+
Defines compatible AI agents:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"compatibleAgents": ["ai-first-bridge", "opencode", "cursor", "windsurf", "cline"],
|
|
50
|
+
"schemaVersion": "1.0"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Auto-Detection
|
|
55
|
+
|
|
56
|
+
AI-First automatically detects:
|
|
57
|
+
|
|
58
|
+
- **Features**: From `ai/context/features/*.json` files
|
|
59
|
+
- **Flows**: From `ai/context/flows/*.json` files
|
|
60
|
+
- **Languages**: From `ai/tech_stack.md` (Languages section)
|
|
61
|
+
- **Frameworks**: From `ai/tech_stack.md` (Frameworks section)
|
|
62
|
+
|
|
63
|
+
## Version Compatibility
|
|
64
|
+
|
|
65
|
+
The schema uses semantic versioning. AI-First validates compatibility:
|
|
66
|
+
|
|
67
|
+
- Same major version = compatible
|
|
68
|
+
- Different major version = incompatible
|
|
69
|
+
|
|
70
|
+
## CLI Commands
|
|
71
|
+
|
|
72
|
+
### Generate Schema
|
|
73
|
+
|
|
74
|
+
Schema is automatically generated with `ai-first init`:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
ai-first init
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Validate Schema
|
|
81
|
+
|
|
82
|
+
Check if your repository has a valid schema:
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
import { validateSchema } from 'ai-first';
|
|
86
|
+
|
|
87
|
+
const result = validateSchema('./ai');
|
|
88
|
+
console.log(result.valid); // true/false
|
|
89
|
+
console.log(result.errors); // []
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Load Schema
|
|
93
|
+
|
|
94
|
+
Load schema programmatically:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
import { loadFullSchema } from 'ai-first';
|
|
98
|
+
|
|
99
|
+
const schema = loadFullSchema('./ai');
|
|
100
|
+
if (schema) {
|
|
101
|
+
console.log(schema.project.name);
|
|
102
|
+
console.log(schema.schema.schemaVersion);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Integration
|
|
107
|
+
|
|
108
|
+
The schema is integrated into the AI-First CLI:
|
|
109
|
+
|
|
110
|
+
1. `ai-first init` - Generates schema files
|
|
111
|
+
2. `ai-first validate` - Validates schema (coming soon)
|
|
112
|
+
3. `ai-first doctor` - Checks schema health
|
|
113
|
+
|
|
114
|
+
## Benefits
|
|
115
|
+
|
|
116
|
+
- **Version Safety**: AI agents know which schema version to expect
|
|
117
|
+
- **Project Discovery**: Features and flows are automatically detected
|
|
118
|
+
- **Agent Compatibility**: Clear list of supported AI tools
|
|
119
|
+
- **Extensibility**: Schema can be extended for custom agents
|
|
@@ -209,4 +209,72 @@ AI-First is designed to be extensible:
|
|
|
209
209
|
|
|
210
210
|
- Add new analyzers in `src/analyzers/`
|
|
211
211
|
- Custom rules in `ai_rules.md`
|
|
212
|
-
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Feature Detection (`src/core/semanticContexts.ts`)
|
|
215
|
+
|
|
216
|
+
AI-First automatically detects business features and flows from your codebase structure.
|
|
217
|
+
|
|
218
|
+
### Feature Detection Rules
|
|
219
|
+
|
|
220
|
+
**1. Candidate Roots**
|
|
221
|
+
|
|
222
|
+
Features are scanned inside:
|
|
223
|
+
- `src/*`
|
|
224
|
+
- `app/*`
|
|
225
|
+
- `packages/*`
|
|
226
|
+
- `services/*`
|
|
227
|
+
- `modules/*`
|
|
228
|
+
- `features/*`
|
|
229
|
+
|
|
230
|
+
**2. Ignored Folders**
|
|
231
|
+
|
|
232
|
+
Technical folders are excluded:
|
|
233
|
+
- `utils`, `helpers`, `types`, `interfaces`, `constants`
|
|
234
|
+
- `config`, `dto`, `models`, `common`, `shared`
|
|
235
|
+
|
|
236
|
+
**3. Feature Requirements**
|
|
237
|
+
|
|
238
|
+
A valid feature must:
|
|
239
|
+
- Contain at least 3 source files
|
|
240
|
+
- Contain at least one entrypoint (Controller, Route, Handler, Command, Service)
|
|
241
|
+
- Exist at depth 1 or 2: `src/auth`, `src/modules/auth`
|
|
242
|
+
|
|
243
|
+
### Feature Output Format
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"name": "auth",
|
|
248
|
+
"path": "src/auth",
|
|
249
|
+
"files": [
|
|
250
|
+
"src/auth/authController.ts",
|
|
251
|
+
"src/auth/authService.ts",
|
|
252
|
+
"src/auth/authRepository.ts"
|
|
253
|
+
],
|
|
254
|
+
"entrypoints": [
|
|
255
|
+
"src/auth/authController.ts"
|
|
256
|
+
],
|
|
257
|
+
"dependencies": ["users", "payments"]
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Flow Detection
|
|
262
|
+
|
|
263
|
+
Flows represent business execution chains starting from entrypoints:
|
|
264
|
+
|
|
265
|
+
- **Minimum 3 files** per flow
|
|
266
|
+
- **Minimum 2 architectural layers** (api → service → data)
|
|
267
|
+
- Entry points: Controller, Route, Handler, Command
|
|
268
|
+
|
|
269
|
+
Flows are generated using three fallback methods:
|
|
270
|
+
1. **Symbol Graph** - Uses call/import relationships
|
|
271
|
+
2. **Folder Structure** - Groups by feature prefix
|
|
272
|
+
3. **Import Analysis** - Follows dependency chains
|
|
273
|
+
|
|
274
|
+
### Output Location
|
|
275
|
+
|
|
276
|
+
Features and flows are written to:
|
|
277
|
+
```
|
|
278
|
+
ai/context/features/<feature>.json
|
|
279
|
+
ai/context/flows/<flow>.json
|
|
280
|
+
```
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Flow Detection
|
|
2
|
+
|
|
3
|
+
Flows represent business execution chains that traverse multiple architectural layers in your codebase.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Flow detection identifies how data flows through your application from entrypoints to data access layers.
|
|
8
|
+
|
|
9
|
+
### Example Flow
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
LoginController → AuthService → UserRepository
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This represents the typical three-tier architecture:
|
|
16
|
+
1. **API Layer**: LoginController (entrypoint)
|
|
17
|
+
2. **Service Layer**: AuthService (business logic)
|
|
18
|
+
3. **Data Layer**: UserRepository (persistence)
|
|
19
|
+
|
|
20
|
+
## Detection Methods
|
|
21
|
+
|
|
22
|
+
AI-First uses multiple fallback methods to detect flows:
|
|
23
|
+
|
|
24
|
+
### 1. Symbol Graph (Primary)
|
|
25
|
+
|
|
26
|
+
When symbol relationships are strong, flows are detected by analyzing:
|
|
27
|
+
- Function calls (`calls`)
|
|
28
|
+
- Module imports (`imports`)
|
|
29
|
+
- Symbol references (`references`)
|
|
30
|
+
|
|
31
|
+
**Requirements:**
|
|
32
|
+
- Symbol graph density ≥ 0.5
|
|
33
|
+
- At least 10 relationships
|
|
34
|
+
|
|
35
|
+
### 2. Folder Structure (Fallback)
|
|
36
|
+
|
|
37
|
+
When symbol graph is weak, flows are inferred from:
|
|
38
|
+
- File naming conventions (e.g., `authController.ts`, `authService.ts`)
|
|
39
|
+
- Grouping by feature prefix
|
|
40
|
+
|
|
41
|
+
**Example:**
|
|
42
|
+
- `authController.ts` → feature: `auth`
|
|
43
|
+
- `authService.ts` → belongs to `auth` flow
|
|
44
|
+
- `authRepository.ts` → belongs to `auth` flow
|
|
45
|
+
|
|
46
|
+
### 3. Import Analysis (Fallback)
|
|
47
|
+
|
|
48
|
+
Uses dependency analysis to trace execution paths:
|
|
49
|
+
1. Start from entrypoint files
|
|
50
|
+
2. Follow import statements
|
|
51
|
+
3. Build chain up to MAX_FLOW_DEPTH
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
### Limits
|
|
56
|
+
|
|
57
|
+
| Parameter | Value | Description |
|
|
58
|
+
|-----------|-------|-------------|
|
|
59
|
+
| `MAX_FLOW_DEPTH` | 5 | Maximum traversal depth |
|
|
60
|
+
| `MAX_FLOW_FILES` | 30 | Maximum files per flow |
|
|
61
|
+
|
|
62
|
+
### Entrypoints
|
|
63
|
+
|
|
64
|
+
Flows must start from one of these file types:
|
|
65
|
+
- Controller
|
|
66
|
+
- Route
|
|
67
|
+
- Handler
|
|
68
|
+
- Command
|
|
69
|
+
|
|
70
|
+
### Layers
|
|
71
|
+
|
|
72
|
+
Supported architectural layers:
|
|
73
|
+
| Layer | Patterns |
|
|
74
|
+
|-------|----------|
|
|
75
|
+
| api | controller, handler, route, router, endpoint |
|
|
76
|
+
| service | service, services, usecase, interactor |
|
|
77
|
+
| data | repository, repo, dal, dao, data, persistence |
|
|
78
|
+
| domain | model, entity, schema, domain |
|
|
79
|
+
|
|
80
|
+
## Requirements
|
|
81
|
+
|
|
82
|
+
A valid flow must have:
|
|
83
|
+
- **Minimum 3 files**
|
|
84
|
+
- **Minimum 2 architectural layers**
|
|
85
|
+
|
|
86
|
+
## Output Format
|
|
87
|
+
|
|
88
|
+
Flows are written to: `ai/context/flows/<flow-name>.json`
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"name": "auth",
|
|
93
|
+
"entrypoint": "api/authController.js",
|
|
94
|
+
"files": [
|
|
95
|
+
"api/authController.js",
|
|
96
|
+
"services/authService.js",
|
|
97
|
+
"data/authRepository.js"
|
|
98
|
+
],
|
|
99
|
+
"depth": 3,
|
|
100
|
+
"layers": ["api", "service", "data"]
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Output Fields
|
|
105
|
+
|
|
106
|
+
| Field | Description |
|
|
107
|
+
|-------|-------------|
|
|
108
|
+
| `name` | Flow identifier (derived from entrypoint) |
|
|
109
|
+
| `entrypoint` | Starting file (Controller/Route/Handler/Command) |
|
|
110
|
+
| `files` | All files in the flow chain |
|
|
111
|
+
| `depth` | Actual traversal depth |
|
|
112
|
+
| `layers` | Unique layers traversed |
|
|
113
|
+
|
|
114
|
+
## Usage
|
|
115
|
+
|
|
116
|
+
Flows are automatically generated when running:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
ai-first map
|
|
120
|
+
# or
|
|
121
|
+
ai-first init
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Integration
|
|
125
|
+
|
|
126
|
+
Flows work with Features to provide complete context:
|
|
127
|
+
|
|
128
|
+
- **Features**: Identify business modules (auth, users, payments)
|
|
129
|
+
- **Flows**: Identify how code executes within features
|
|
130
|
+
|
|
131
|
+
Together they enable AI agents to:
|
|
132
|
+
1. Understand business domain structure
|
|
133
|
+
2. Trace execution paths
|
|
134
|
+
3. Locate relevant code for modifications
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Git Intelligence
|
|
2
|
+
|
|
3
|
+
AI-First can analyze your git repository to provide AI agents with context about recent activity, helping them prioritize relevant files and understand what's been recently changed.
|
|
4
|
+
|
|
5
|
+
## Why Git Intelligence?
|
|
6
|
+
|
|
7
|
+
When working with AI coding assistants, knowing which files have been recently modified helps the AI:
|
|
8
|
+
|
|
9
|
+
- **Prioritize review** - Focus on recently changed files when suggesting modifications
|
|
10
|
+
- **Understand context** - Know which features/flows are actively being developed
|
|
11
|
+
- **Avoid conflicts** - Identify files that were recently modified to prevent overwrite
|
|
12
|
+
- **Trace changes** - See commit patterns and activity frequency
|
|
13
|
+
|
|
14
|
+
## How It Works
|
|
15
|
+
|
|
16
|
+
Git Intelligence analyzes your git history to generate metadata about recent repository activity:
|
|
17
|
+
|
|
18
|
+
1. **Detects git repository** - Checks if the project is a git repository
|
|
19
|
+
2. **Analyzes recent commits** - Extracts commit data (default: last 50 commits, last 30 days)
|
|
20
|
+
3. **Maps to features/flows** - Correlates changed files with detected features and flows
|
|
21
|
+
4. **Generates metadata** - Outputs JSON files for AI consumption
|
|
22
|
+
|
|
23
|
+
## Generated Files
|
|
24
|
+
|
|
25
|
+
When you run `ai-first git`, the following files are created in `ai/git/`:
|
|
26
|
+
|
|
27
|
+
### recent-files.json
|
|
28
|
+
|
|
29
|
+
List of recently changed files:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
[
|
|
33
|
+
"src/auth/loginController.ts",
|
|
34
|
+
"src/auth/sessionService.ts",
|
|
35
|
+
"src/payments/checkoutFlow.ts"
|
|
36
|
+
]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### recent-features.json
|
|
40
|
+
|
|
41
|
+
Features that have been recently modified:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
["auth", "payments"]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### recent-flows.json
|
|
48
|
+
|
|
49
|
+
Flows that have been recently modified:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
["login", "checkout"]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### commit-activity.json
|
|
56
|
+
|
|
57
|
+
Detailed commit frequency data:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"totalCommits": 50,
|
|
62
|
+
"dateRange": {
|
|
63
|
+
"start": "2026-02-01",
|
|
64
|
+
"end": "2026-03-10"
|
|
65
|
+
},
|
|
66
|
+
"files": {
|
|
67
|
+
"src/auth/loginController.ts": 5,
|
|
68
|
+
"src/auth/sessionService.ts": 3
|
|
69
|
+
},
|
|
70
|
+
"features": {
|
|
71
|
+
"auth": 8,
|
|
72
|
+
"payments": 12
|
|
73
|
+
},
|
|
74
|
+
"flows": {
|
|
75
|
+
"login": 4,
|
|
76
|
+
"checkout": 7
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
### CLI Command
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Analyze git activity
|
|
87
|
+
ai-first git
|
|
88
|
+
|
|
89
|
+
# Analyze with more commits
|
|
90
|
+
ai-first git --limit 100
|
|
91
|
+
|
|
92
|
+
# Show detailed activity
|
|
93
|
+
ai-first git --activity
|
|
94
|
+
|
|
95
|
+
# Output as JSON
|
|
96
|
+
ai-first git --json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Options
|
|
100
|
+
|
|
101
|
+
| Option | Alias | Description |
|
|
102
|
+
|--------|-------|-------------|
|
|
103
|
+
| `--root` | `-r` | Root directory (default: current) |
|
|
104
|
+
| `--limit` | `-n` | Number of commits (default: 50) |
|
|
105
|
+
| `--activity` | `-a` | Show detailed activity |
|
|
106
|
+
| `--json` | | Output as JSON |
|
|
107
|
+
| `--help` | `-h` | Show help |
|
|
108
|
+
|
|
109
|
+
### Programmatic Usage
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import {
|
|
113
|
+
detectGitRepository,
|
|
114
|
+
getRecentCommits,
|
|
115
|
+
analyzeGitActivity,
|
|
116
|
+
generateGitContext
|
|
117
|
+
} from 'ai-first';
|
|
118
|
+
|
|
119
|
+
// Check if git repo
|
|
120
|
+
if (detectGitRepository('/path/to/project')) {
|
|
121
|
+
// Get recent commits
|
|
122
|
+
const commits = getRecentCommits('/path/to/project');
|
|
123
|
+
|
|
124
|
+
// Analyze activity
|
|
125
|
+
const activity = analyzeGitActivity('/path/to/project');
|
|
126
|
+
|
|
127
|
+
// Generate context files
|
|
128
|
+
const context = generateGitContext('/path/to/project');
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## API Reference
|
|
133
|
+
|
|
134
|
+
### detectGitRepository(rootDir: string): boolean
|
|
135
|
+
|
|
136
|
+
Checks if a directory is a git repository.
|
|
137
|
+
|
|
138
|
+
### getRecentCommits(rootDir: string, limit?: number): GitCommit[]
|
|
139
|
+
|
|
140
|
+
Returns recent commits with file changes.
|
|
141
|
+
|
|
142
|
+
### extractChangedFiles(commits: GitCommit[]): RecentFile[]
|
|
143
|
+
|
|
144
|
+
Extracts and counts changed files from commits.
|
|
145
|
+
|
|
146
|
+
### mapFilesToFeatures(rootDir: string, files: string[]): string[]
|
|
147
|
+
|
|
148
|
+
Maps changed files to detected features.
|
|
149
|
+
|
|
150
|
+
### mapFilesToFlows(rootDir: string, files: string[]): string[]
|
|
151
|
+
|
|
152
|
+
Maps changed files to detected flows.
|
|
153
|
+
|
|
154
|
+
### analyzeGitActivity(rootDir: string): GitActivity | null
|
|
155
|
+
|
|
156
|
+
Analyzes git activity and returns aggregated data.
|
|
157
|
+
|
|
158
|
+
### generateGitContext(rootDir: string, aiDir?: string): GitContext
|
|
159
|
+
|
|
160
|
+
Generates all git context files in `ai/git/`.
|
|
161
|
+
|
|
162
|
+
## Integration with AI Context
|
|
163
|
+
|
|
164
|
+
Git intelligence integrates with the AI context system:
|
|
165
|
+
|
|
166
|
+
1. Run `ai-first init` to generate features and flows
|
|
167
|
+
2. Run `ai-first git` to analyze git activity
|
|
168
|
+
3. AI agents can read `ai/git/` files to understand recent changes
|
|
169
|
+
|
|
170
|
+
This provides a complete picture of both your codebase structure and its development activity.
|