aidex-mcp 1.4.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.
- package/CHANGELOG.md +128 -0
- package/LICENSE +21 -0
- package/MCP-API-REFERENCE.md +690 -0
- package/README.md +314 -0
- package/build/commands/files.d.ts +28 -0
- package/build/commands/files.js +124 -0
- package/build/commands/index.d.ts +14 -0
- package/build/commands/index.js +14 -0
- package/build/commands/init.d.ts +24 -0
- package/build/commands/init.js +396 -0
- package/build/commands/link.d.ts +45 -0
- package/build/commands/link.js +167 -0
- package/build/commands/note.d.ts +29 -0
- package/build/commands/note.js +105 -0
- package/build/commands/query.d.ts +36 -0
- package/build/commands/query.js +176 -0
- package/build/commands/scan.d.ts +25 -0
- package/build/commands/scan.js +104 -0
- package/build/commands/session.d.ts +52 -0
- package/build/commands/session.js +216 -0
- package/build/commands/signature.d.ts +52 -0
- package/build/commands/signature.js +171 -0
- package/build/commands/summary.d.ts +56 -0
- package/build/commands/summary.js +324 -0
- package/build/commands/update.d.ts +36 -0
- package/build/commands/update.js +273 -0
- package/build/constants.d.ts +10 -0
- package/build/constants.js +10 -0
- package/build/db/database.d.ts +69 -0
- package/build/db/database.js +126 -0
- package/build/db/index.d.ts +7 -0
- package/build/db/index.js +6 -0
- package/build/db/queries.d.ts +163 -0
- package/build/db/queries.js +273 -0
- package/build/db/schema.sql +136 -0
- package/build/index.d.ts +13 -0
- package/build/index.js +74 -0
- package/build/parser/extractor.d.ts +41 -0
- package/build/parser/extractor.js +249 -0
- package/build/parser/index.d.ts +7 -0
- package/build/parser/index.js +7 -0
- package/build/parser/languages/c.d.ts +28 -0
- package/build/parser/languages/c.js +70 -0
- package/build/parser/languages/cpp.d.ts +28 -0
- package/build/parser/languages/cpp.js +91 -0
- package/build/parser/languages/csharp.d.ts +32 -0
- package/build/parser/languages/csharp.js +97 -0
- package/build/parser/languages/go.d.ts +28 -0
- package/build/parser/languages/go.js +83 -0
- package/build/parser/languages/index.d.ts +21 -0
- package/build/parser/languages/index.js +107 -0
- package/build/parser/languages/java.d.ts +28 -0
- package/build/parser/languages/java.js +58 -0
- package/build/parser/languages/php.d.ts +28 -0
- package/build/parser/languages/php.js +75 -0
- package/build/parser/languages/python.d.ts +28 -0
- package/build/parser/languages/python.js +67 -0
- package/build/parser/languages/ruby.d.ts +28 -0
- package/build/parser/languages/ruby.js +68 -0
- package/build/parser/languages/rust.d.ts +28 -0
- package/build/parser/languages/rust.js +73 -0
- package/build/parser/languages/typescript.d.ts +28 -0
- package/build/parser/languages/typescript.js +82 -0
- package/build/parser/tree-sitter.d.ts +30 -0
- package/build/parser/tree-sitter.js +132 -0
- package/build/server/mcp-server.d.ts +7 -0
- package/build/server/mcp-server.js +36 -0
- package/build/server/tools.d.ts +18 -0
- package/build/server/tools.js +1245 -0
- package/build/viewer/git-status.d.ts +25 -0
- package/build/viewer/git-status.js +163 -0
- package/build/viewer/index.d.ts +5 -0
- package/build/viewer/index.js +5 -0
- package/build/viewer/server.d.ts +12 -0
- package/build/viewer/server.js +1122 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# AiDex
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
[](https://modelcontextprotocol.io/)
|
|
6
|
+
|
|
7
|
+
**Stop wasting 80% of your AI's context window on code searches.**
|
|
8
|
+
|
|
9
|
+
AiDex is an MCP server that gives AI coding assistants instant access to your entire codebase through a persistent, pre-built index. Works with any MCP-compatible AI assistant: Claude Code, Cursor, Windsurf, Continue.dev, and more.
|
|
10
|
+
|
|
11
|
+
<!-- TODO: Add demo GIF showing aidex_query vs grep -->
|
|
12
|
+
|
|
13
|
+
## The Problem
|
|
14
|
+
|
|
15
|
+
Every time your AI assistant searches for code, it:
|
|
16
|
+
- **Greps** through thousands of files → hundreds of results flood the context
|
|
17
|
+
- **Reads** file after file to understand the structure → more context consumed
|
|
18
|
+
- **Forgets** everything when the session ends → repeat from scratch
|
|
19
|
+
|
|
20
|
+
A single "Where is X defined?" question can eat 2,000+ tokens. Do that 10 times and you've burned half your context on navigation alone.
|
|
21
|
+
|
|
22
|
+
## The Solution
|
|
23
|
+
|
|
24
|
+
Index once, query forever:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
# Before: grep flooding your context
|
|
28
|
+
AI: grep "PlayerHealth" → 200 hits in 40 files
|
|
29
|
+
AI: read File1.cs, File2.cs, File3.cs...
|
|
30
|
+
→ 2000+ tokens consumed, 5+ tool calls
|
|
31
|
+
|
|
32
|
+
# After: precise results, minimal context
|
|
33
|
+
AI: aidex_query({ term: "PlayerHealth" })
|
|
34
|
+
→ Engine.cs:45, Player.cs:23, UI.cs:156
|
|
35
|
+
→ ~50 tokens, 1 tool call
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Result: 50-80% less context used for code navigation.**
|
|
39
|
+
|
|
40
|
+
## Why Not Just Grep?
|
|
41
|
+
|
|
42
|
+
| | Grep/Ripgrep | AiDex |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| **Context usage** | 2000+ tokens per search | ~50 tokens |
|
|
45
|
+
| **Results** | All text matches | Only identifiers |
|
|
46
|
+
| **Precision** | `log` matches `catalog`, `logarithm` | `log` finds only `log` |
|
|
47
|
+
| **Persistence** | Starts fresh every time | Index survives sessions |
|
|
48
|
+
| **Structure** | Flat text search | Knows methods, classes, types |
|
|
49
|
+
|
|
50
|
+
**The real cost of grep**: Every grep result includes surrounding context. Search for `User` in a large project and you'll get hundreds of hits - comments, strings, partial matches. Your AI reads through all of them, burning context tokens on noise.
|
|
51
|
+
|
|
52
|
+
**AiDex indexes identifiers**: It uses Tree-sitter to actually parse your code. When you search for `User`, you get the class definition, the method parameters, the variable declarations - not every comment that mentions "user".
|
|
53
|
+
|
|
54
|
+
## How It Works
|
|
55
|
+
|
|
56
|
+
1. **Index your project once** (~1 second per 1000 files)
|
|
57
|
+
```
|
|
58
|
+
aidex_init({ path: "/path/to/project" })
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. **AI searches the index instead of grepping**
|
|
62
|
+
```
|
|
63
|
+
aidex_query({ term: "Calculate", mode: "starts_with" })
|
|
64
|
+
→ All functions starting with "Calculate" + exact line numbers
|
|
65
|
+
|
|
66
|
+
aidex_query({ term: "Player", modified_since: "2h" })
|
|
67
|
+
→ Only matches changed in the last 2 hours
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
3. **Get file overviews without reading entire files**
|
|
71
|
+
```
|
|
72
|
+
aidex_signature({ file: "src/Engine.cs" })
|
|
73
|
+
→ All classes, methods, and their signatures
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The index lives in `.aidex/index.db` (SQLite) - fast, portable, no external dependencies.
|
|
77
|
+
|
|
78
|
+
## Features
|
|
79
|
+
|
|
80
|
+
- **Smart Extraction**: Uses Tree-sitter to parse code properly - indexes identifiers, not keywords
|
|
81
|
+
- **Method Signatures**: Get function prototypes without reading implementations
|
|
82
|
+
- **Project Summary**: Auto-detected entry points, main classes, language breakdown
|
|
83
|
+
- **Incremental Updates**: Re-index single files after changes
|
|
84
|
+
- **Cross-Project Links**: Query across multiple related projects
|
|
85
|
+
- **Time-based Filtering**: Find what changed in the last hour, day, or week
|
|
86
|
+
- **Project Structure**: Query all files (code, config, docs, assets) without filesystem access
|
|
87
|
+
- **Session Notes**: Leave reminders for the next session - persists in the database
|
|
88
|
+
- **Auto-Cleanup**: Excluded files (e.g., build outputs) are automatically removed from index
|
|
89
|
+
|
|
90
|
+
## Supported Languages
|
|
91
|
+
|
|
92
|
+
| Language | Extensions |
|
|
93
|
+
|----------|------------|
|
|
94
|
+
| C# | `.cs` |
|
|
95
|
+
| TypeScript | `.ts`, `.tsx` |
|
|
96
|
+
| JavaScript | `.js`, `.jsx`, `.mjs`, `.cjs` |
|
|
97
|
+
| Rust | `.rs` |
|
|
98
|
+
| Python | `.py`, `.pyw` |
|
|
99
|
+
| C | `.c`, `.h` |
|
|
100
|
+
| C++ | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.hxx` |
|
|
101
|
+
| Java | `.java` |
|
|
102
|
+
| Go | `.go` |
|
|
103
|
+
| PHP | `.php` |
|
|
104
|
+
| Ruby | `.rb`, `.rake` |
|
|
105
|
+
|
|
106
|
+
## Quick Start
|
|
107
|
+
|
|
108
|
+
### 1. Install
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
git clone https://github.com/CSCSoftware/AiDex.git
|
|
112
|
+
cd AiDex
|
|
113
|
+
npm install && npm run build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 2. Register with your AI assistant
|
|
117
|
+
|
|
118
|
+
**For Claude Code** (`~/.claude/settings.json` or `~/.claude.json`):
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"mcpServers": {
|
|
122
|
+
"aidex": {
|
|
123
|
+
"type": "stdio",
|
|
124
|
+
"command": "node",
|
|
125
|
+
"args": ["/path/to/AiDex/build/index.js"],
|
|
126
|
+
"env": {}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**For Claude Desktop** (`%APPDATA%/Claude/claude_desktop_config.json` on Windows):
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"mcpServers": {
|
|
136
|
+
"aidex": {
|
|
137
|
+
"command": "node",
|
|
138
|
+
"args": ["/path/to/AiDex/build/index.js"]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
> **Important:** The server name in your config determines the MCP tool prefix. Use `"aidex"` as shown above — this gives you tool names like `aidex_query`, `aidex_signature`, etc. Using a different name (e.g., `"codegraph"`) would change the prefix accordingly.
|
|
145
|
+
|
|
146
|
+
**For other MCP clients**: See your client's documentation for MCP server configuration.
|
|
147
|
+
|
|
148
|
+
### 3. Make your AI actually use it
|
|
149
|
+
|
|
150
|
+
Add to your AI's instructions (e.g., `~/.claude/CLAUDE.md` for Claude Code):
|
|
151
|
+
|
|
152
|
+
```markdown
|
|
153
|
+
## AiDex - Use for ALL code searches!
|
|
154
|
+
|
|
155
|
+
**Before using Grep/Glob, check if `.aidex/` exists in the project.**
|
|
156
|
+
|
|
157
|
+
If yes, use AiDex instead:
|
|
158
|
+
- `aidex_query` - Find functions, classes, variables by name
|
|
159
|
+
- `aidex_signature` - Get all methods in a file with line numbers
|
|
160
|
+
- `aidex_signatures` - Get methods from multiple files (glob pattern)
|
|
161
|
+
- `aidex_summary` - Project overview with entry points
|
|
162
|
+
|
|
163
|
+
If no `.aidex/` exists, offer to run `aidex_init` first.
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 4. Index your project
|
|
167
|
+
|
|
168
|
+
Ask your AI: *"Index this project with AiDex"*
|
|
169
|
+
|
|
170
|
+
Or manually in the AI chat:
|
|
171
|
+
```
|
|
172
|
+
aidex_init({ path: "/path/to/your/project" })
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Available Tools
|
|
176
|
+
|
|
177
|
+
| Tool | Description |
|
|
178
|
+
|------|-------------|
|
|
179
|
+
| `aidex_init` | Index a project (creates `.aidex/`) |
|
|
180
|
+
| `aidex_query` | Search by term (exact/contains/starts_with) |
|
|
181
|
+
| `aidex_signature` | Get one file's classes + methods |
|
|
182
|
+
| `aidex_signatures` | Get signatures for multiple files (glob) |
|
|
183
|
+
| `aidex_update` | Re-index a single changed file |
|
|
184
|
+
| `aidex_remove` | Remove a deleted file from index |
|
|
185
|
+
| `aidex_summary` | Project overview |
|
|
186
|
+
| `aidex_tree` | File tree with statistics |
|
|
187
|
+
| `aidex_describe` | Add documentation to summary |
|
|
188
|
+
| `aidex_link` | Link another indexed project |
|
|
189
|
+
| `aidex_unlink` | Remove linked project |
|
|
190
|
+
| `aidex_links` | List linked projects |
|
|
191
|
+
| `aidex_status` | Index statistics |
|
|
192
|
+
| `aidex_scan` | Find indexed projects in directory tree |
|
|
193
|
+
| `aidex_files` | List project files by type (code/config/doc/asset) |
|
|
194
|
+
| `aidex_note` | Read/write session notes (persists between sessions) |
|
|
195
|
+
| `aidex_session` | Start session, detect external changes, auto-reindex |
|
|
196
|
+
| `aidex_viewer` | Open interactive project tree in browser |
|
|
197
|
+
|
|
198
|
+
## Time-based Filtering
|
|
199
|
+
|
|
200
|
+
Track what changed recently with `modified_since` and `modified_before`:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
aidex_query({ term: "render", modified_since: "2h" }) # Last 2 hours
|
|
204
|
+
aidex_query({ term: "User", modified_since: "1d" }) # Last day
|
|
205
|
+
aidex_query({ term: "API", modified_since: "1w" }) # Last week
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Supported formats:
|
|
209
|
+
- **Relative**: `30m` (minutes), `2h` (hours), `1d` (days), `1w` (weeks)
|
|
210
|
+
- **ISO date**: `2026-01-27` or `2026-01-27T14:30:00`
|
|
211
|
+
|
|
212
|
+
Perfect for questions like *"What did I change in the last hour?"*
|
|
213
|
+
|
|
214
|
+
## Project Structure
|
|
215
|
+
|
|
216
|
+
AiDex indexes ALL files in your project (not just code), letting you query the structure:
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
aidex_files({ path: ".", type: "config" }) # All config files
|
|
220
|
+
aidex_files({ path: ".", type: "test" }) # All test files
|
|
221
|
+
aidex_files({ path: ".", pattern: "**/*.md" }) # All markdown files
|
|
222
|
+
aidex_files({ path: ".", modified_since: "30m" }) # Changed this session
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
File types: `code`, `config`, `doc`, `asset`, `test`, `other`, `dir`
|
|
226
|
+
|
|
227
|
+
Use `modified_since` to find files changed in this session - perfect for *"What did I edit?"*
|
|
228
|
+
|
|
229
|
+
## Session Notes
|
|
230
|
+
|
|
231
|
+
Leave reminders for the next session - no more losing context between chats:
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
aidex_note({ path: ".", note: "Test the glob fix after restart" }) # Write
|
|
235
|
+
aidex_note({ path: ".", note: "Also check edge cases", append: true }) # Append
|
|
236
|
+
aidex_note({ path: "." }) # Read
|
|
237
|
+
aidex_note({ path: ".", clear: true }) # Clear
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Use cases:**
|
|
241
|
+
- Before ending a session: *"Remember to test X next time"*
|
|
242
|
+
- AI auto-reminder: Save what to verify after a restart
|
|
243
|
+
- Handover notes: Context for the next session without editing config files
|
|
244
|
+
|
|
245
|
+
Notes are stored in the SQLite database (`.aidex/index.db`) and persist indefinitely.
|
|
246
|
+
|
|
247
|
+
## Interactive Viewer
|
|
248
|
+
|
|
249
|
+
Explore your indexed project visually in the browser:
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
aidex_viewer({ path: "." })
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Opens `http://localhost:3333` with:
|
|
256
|
+
- **Interactive file tree** - Click to expand directories
|
|
257
|
+
- **File signatures** - Click any file to see its types and methods
|
|
258
|
+
- **Live reload** - Changes detected automatically while you code
|
|
259
|
+
- **Git status icons** - See which files are modified, staged, or untracked
|
|
260
|
+
|
|
261
|
+
Close with `aidex_viewer({ path: ".", action: "close" })`
|
|
262
|
+
|
|
263
|
+
## CLI Usage
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
node build/index.js scan Q:/develop # Find all indexed projects
|
|
267
|
+
node build/index.js init ./myproject # Index a project from command line
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Performance
|
|
271
|
+
|
|
272
|
+
| Project | Files | Items | Index Time | Query Time |
|
|
273
|
+
|---------|-------|-------|------------|------------|
|
|
274
|
+
| Small (AiDex) | 19 | 1,200 | <1s | 1-5ms |
|
|
275
|
+
| Medium (RemoteDebug) | 10 | 1,900 | <1s | 1-5ms |
|
|
276
|
+
| Large (LibPyramid3D) | 18 | 3,000 | <1s | 1-5ms |
|
|
277
|
+
| XL (MeloTTS) | 56 | 4,100 | ~2s | 1-10ms |
|
|
278
|
+
|
|
279
|
+
## Technology
|
|
280
|
+
|
|
281
|
+
- **Parser**: [Tree-sitter](https://tree-sitter.github.io/) - Real parsing, not regex
|
|
282
|
+
- **Database**: SQLite with WAL mode - Fast, single file, zero config
|
|
283
|
+
- **Protocol**: [MCP](https://modelcontextprotocol.io/) - Works with any compatible AI
|
|
284
|
+
|
|
285
|
+
## Project Structure
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
.aidex/ ← Created in YOUR project
|
|
289
|
+
├── index.db ← SQLite database
|
|
290
|
+
└── summary.md ← Optional documentation
|
|
291
|
+
|
|
292
|
+
AiDex/ ← This repository
|
|
293
|
+
├── src/
|
|
294
|
+
│ ├── commands/ ← Tool implementations
|
|
295
|
+
│ ├── db/ ← SQLite wrapper
|
|
296
|
+
│ ├── parser/ ← Tree-sitter integration
|
|
297
|
+
│ └── server/ ← MCP protocol handler
|
|
298
|
+
└── build/ ← Compiled output
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Contributing
|
|
302
|
+
|
|
303
|
+
PRs welcome! Especially for:
|
|
304
|
+
- New language support
|
|
305
|
+
- Performance improvements
|
|
306
|
+
- Documentation
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
MIT License - see [LICENSE](LICENSE)
|
|
311
|
+
|
|
312
|
+
## Authors
|
|
313
|
+
|
|
314
|
+
Uwe Chalas & Claude
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* files command - List project files and directories
|
|
3
|
+
*
|
|
4
|
+
* Supports time-based filtering via modified_since parameter to find
|
|
5
|
+
* files that were recently indexed (useful for "what changed this session?")
|
|
6
|
+
*/
|
|
7
|
+
export interface FilesParams {
|
|
8
|
+
path: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
pattern?: string;
|
|
11
|
+
modifiedSince?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ProjectFile {
|
|
14
|
+
path: string;
|
|
15
|
+
type: string;
|
|
16
|
+
extension: string | null;
|
|
17
|
+
indexed: boolean;
|
|
18
|
+
lastIndexed?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface FilesResult {
|
|
21
|
+
success: boolean;
|
|
22
|
+
files: ProjectFile[];
|
|
23
|
+
totalFiles: number;
|
|
24
|
+
byType: Record<string, number>;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function files(params: FilesParams): FilesResult;
|
|
28
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* files command - List project files and directories
|
|
3
|
+
*
|
|
4
|
+
* Supports time-based filtering via modified_since parameter to find
|
|
5
|
+
* files that were recently indexed (useful for "what changed this session?")
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'fs';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
import { PRODUCT_NAME, INDEX_DIR, TOOL_PREFIX } from '../constants.js';
|
|
10
|
+
import { openDatabase, createQueries } from '../db/index.js';
|
|
11
|
+
import { parseTimeOffset } from './query.js';
|
|
12
|
+
// ============================================================
|
|
13
|
+
// Implementation
|
|
14
|
+
// ============================================================
|
|
15
|
+
export function files(params) {
|
|
16
|
+
const { path: projectPath, type, pattern, modifiedSince } = params;
|
|
17
|
+
// Validate project path
|
|
18
|
+
const dbPath = join(projectPath, INDEX_DIR, 'index.db');
|
|
19
|
+
if (!existsSync(dbPath)) {
|
|
20
|
+
return {
|
|
21
|
+
success: false,
|
|
22
|
+
files: [],
|
|
23
|
+
totalFiles: 0,
|
|
24
|
+
byType: {},
|
|
25
|
+
error: `No ${PRODUCT_NAME} index found at ${projectPath}. Run ${TOOL_PREFIX}init first.`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Open database
|
|
29
|
+
const db = openDatabase(dbPath, true);
|
|
30
|
+
const queries = createQueries(db);
|
|
31
|
+
try {
|
|
32
|
+
// Parse time filter
|
|
33
|
+
const modifiedSinceTs = modifiedSince ? parseTimeOffset(modifiedSince) : null;
|
|
34
|
+
// If time filter is specified, get recently indexed files from the files table
|
|
35
|
+
let recentlyIndexedPaths = null;
|
|
36
|
+
let indexedFilesMap = null;
|
|
37
|
+
if (modifiedSinceTs !== null) {
|
|
38
|
+
// Get all indexed files and filter by last_indexed
|
|
39
|
+
const allIndexedFiles = queries.getAllFiles();
|
|
40
|
+
recentlyIndexedPaths = new Set();
|
|
41
|
+
indexedFilesMap = new Map();
|
|
42
|
+
for (const file of allIndexedFiles) {
|
|
43
|
+
indexedFilesMap.set(file.path, file);
|
|
44
|
+
if (file.last_indexed >= modifiedSinceTs) {
|
|
45
|
+
recentlyIndexedPaths.add(file.path);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Get files, optionally filtered by type
|
|
50
|
+
let projectFiles;
|
|
51
|
+
if (type && isValidType(type)) {
|
|
52
|
+
projectFiles = queries.getProjectFilesByType(type);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
projectFiles = queries.getProjectFiles();
|
|
56
|
+
}
|
|
57
|
+
// Apply glob pattern filter if specified
|
|
58
|
+
if (pattern) {
|
|
59
|
+
const regex = globToRegex(pattern);
|
|
60
|
+
projectFiles = projectFiles.filter(f => regex.test(f.path));
|
|
61
|
+
}
|
|
62
|
+
// Apply time filter if specified (only show files indexed after the timestamp)
|
|
63
|
+
if (recentlyIndexedPaths !== null) {
|
|
64
|
+
projectFiles = projectFiles.filter(f => recentlyIndexedPaths.has(f.path));
|
|
65
|
+
}
|
|
66
|
+
// Build type statistics
|
|
67
|
+
const byType = {};
|
|
68
|
+
for (const file of projectFiles) {
|
|
69
|
+
byType[file.type] = (byType[file.type] || 0) + 1;
|
|
70
|
+
}
|
|
71
|
+
// Convert to output format
|
|
72
|
+
const result = projectFiles.map(f => {
|
|
73
|
+
const indexed = f.indexed === 1;
|
|
74
|
+
const indexedFile = indexedFilesMap?.get(f.path);
|
|
75
|
+
return {
|
|
76
|
+
path: f.path,
|
|
77
|
+
type: f.type,
|
|
78
|
+
extension: f.extension,
|
|
79
|
+
indexed,
|
|
80
|
+
lastIndexed: indexedFile?.last_indexed,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
db.close();
|
|
84
|
+
return {
|
|
85
|
+
success: true,
|
|
86
|
+
files: result,
|
|
87
|
+
totalFiles: result.length,
|
|
88
|
+
byType,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
db.close();
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
files: [],
|
|
96
|
+
totalFiles: 0,
|
|
97
|
+
byType: {},
|
|
98
|
+
error: error instanceof Error ? error.message : String(error),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// ============================================================
|
|
103
|
+
// Helper functions
|
|
104
|
+
// ============================================================
|
|
105
|
+
const VALID_TYPES = new Set(['dir', 'code', 'config', 'doc', 'asset', 'test', 'other']);
|
|
106
|
+
function isValidType(type) {
|
|
107
|
+
return VALID_TYPES.has(type);
|
|
108
|
+
}
|
|
109
|
+
function globToRegex(pattern) {
|
|
110
|
+
// Normalize to forward slashes
|
|
111
|
+
let regex = pattern.replace(/\\/g, '/');
|
|
112
|
+
// Escape special regex chars except * and ?
|
|
113
|
+
regex = regex.replace(/[.+^${}()|[\]]/g, '\\$&');
|
|
114
|
+
// Convert glob to regex - use placeholders to avoid double-replacement
|
|
115
|
+
regex = regex
|
|
116
|
+
.replace(/\*\*\//g, '\x00STARSTARSLASH\x00') // Placeholder for **/
|
|
117
|
+
.replace(/\*\*/g, '\x00STARSTAR\x00') // Placeholder for **
|
|
118
|
+
.replace(/\*/g, '[^/]*') // * matches anything except /
|
|
119
|
+
.replace(/\?/g, '.') // ? matches single char
|
|
120
|
+
.replace(/\x00STARSTARSLASH\x00/g, '(.*/)?') // **/ matches zero or more dirs
|
|
121
|
+
.replace(/\x00STARSTAR\x00/g, '.*'); // ** matches anything
|
|
122
|
+
return new RegExp('^' + regex + '$', 'i');
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands module exports
|
|
3
|
+
*/
|
|
4
|
+
export { init, type InitParams, type InitResult } from './init.js';
|
|
5
|
+
export { query, parseTimeOffset, type QueryParams, type QueryResult, type QueryMatch, type QueryMode } from './query.js';
|
|
6
|
+
export { signature, signatures, type SignatureParams, type SignatureResult, type SignaturesParams, type SignaturesResult } from './signature.js';
|
|
7
|
+
export { update, remove, type UpdateParams, type UpdateResult, type RemoveParams, type RemoveResult } from './update.js';
|
|
8
|
+
export { summary, tree, describe, type SummaryParams, type SummaryResult, type TreeParams, type TreeResult, type TreeEntry, type DescribeParams, type DescribeResult } from './summary.js';
|
|
9
|
+
export { link, unlink, listLinks, type LinkParams, type LinkResult, type UnlinkParams, type UnlinkResult, type ListLinksParams, type ListLinksResult, type LinkedProject } from './link.js';
|
|
10
|
+
export { scan, type ScanParams, type ScanResult, type IndexedProject } from './scan.js';
|
|
11
|
+
export { files, type FilesParams, type FilesResult, type ProjectFile } from './files.js';
|
|
12
|
+
export { note, getSessionNote, type NoteParams, type NoteResult } from './note.js';
|
|
13
|
+
export { session, updateSessionHeartbeat, getSessionInfo, formatSessionTime, formatDuration, type SessionParams, type SessionResult, type SessionInfo, type ChangedFile } from './session.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands module exports
|
|
3
|
+
*/
|
|
4
|
+
export { init } from './init.js';
|
|
5
|
+
export { query, parseTimeOffset } from './query.js';
|
|
6
|
+
export { signature, signatures } from './signature.js';
|
|
7
|
+
export { update, remove } from './update.js';
|
|
8
|
+
export { summary, tree, describe } from './summary.js';
|
|
9
|
+
export { link, unlink, listLinks } from './link.js';
|
|
10
|
+
export { scan } from './scan.js';
|
|
11
|
+
export { files } from './files.js';
|
|
12
|
+
export { note, getSessionNote } from './note.js';
|
|
13
|
+
export { session, updateSessionHeartbeat, getSessionInfo, formatSessionTime, formatDuration } from './session.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* init command - Initialize AiDex for a project
|
|
3
|
+
*/
|
|
4
|
+
export interface InitParams {
|
|
5
|
+
path: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
languages?: string[];
|
|
8
|
+
exclude?: string[];
|
|
9
|
+
fresh?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface InitResult {
|
|
12
|
+
success: boolean;
|
|
13
|
+
indexPath: string;
|
|
14
|
+
filesIndexed: number;
|
|
15
|
+
filesSkipped: number;
|
|
16
|
+
filesRemoved: number;
|
|
17
|
+
itemsFound: number;
|
|
18
|
+
methodsFound: number;
|
|
19
|
+
typesFound: number;
|
|
20
|
+
durationMs: number;
|
|
21
|
+
errors: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare function init(params: InitParams): Promise<InitResult>;
|
|
24
|
+
//# sourceMappingURL=init.d.ts.map
|