@compilr-dev/agents-coding 0.0.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/README.md +788 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +75 -0
- package/dist/skills/index.d.ts +39 -0
- package/dist/skills/index.js +322 -0
- package/dist/tools/git/branch.d.ts +17 -0
- package/dist/tools/git/branch.js +264 -0
- package/dist/tools/git/commit.d.ts +23 -0
- package/dist/tools/git/commit.js +280 -0
- package/dist/tools/git/diff.d.ts +19 -0
- package/dist/tools/git/diff.js +221 -0
- package/dist/tools/git/index.d.ts +10 -0
- package/dist/tools/git/index.js +11 -0
- package/dist/tools/git/log.d.ts +19 -0
- package/dist/tools/git/log.js +235 -0
- package/dist/tools/git/stash.d.ts +17 -0
- package/dist/tools/git/stash.js +294 -0
- package/dist/tools/git/status.d.ts +19 -0
- package/dist/tools/git/status.js +160 -0
- package/dist/tools/git/types.d.ts +293 -0
- package/dist/tools/git/types.js +4 -0
- package/dist/tools/git/utils.d.ts +58 -0
- package/dist/tools/git/utils.js +197 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.js +5 -0
- package/dist/tools/project/detect.d.ts +19 -0
- package/dist/tools/project/detect.js +341 -0
- package/dist/tools/project/find-root.d.ts +21 -0
- package/dist/tools/project/find-root.js +239 -0
- package/dist/tools/project/index.d.ts +6 -0
- package/dist/tools/project/index.js +5 -0
- package/dist/tools/project/types.d.ts +83 -0
- package/dist/tools/project/types.js +4 -0
- package/dist/tools/runners/build.d.ts +19 -0
- package/dist/tools/runners/build.js +306 -0
- package/dist/tools/runners/format.d.ts +19 -0
- package/dist/tools/runners/format.js +376 -0
- package/dist/tools/runners/index.d.ts +9 -0
- package/dist/tools/runners/index.js +9 -0
- package/dist/tools/runners/lint.d.ts +19 -0
- package/dist/tools/runners/lint.js +356 -0
- package/dist/tools/runners/test.d.ts +19 -0
- package/dist/tools/runners/test.js +386 -0
- package/dist/tools/runners/types.d.ts +97 -0
- package/dist/tools/runners/types.js +4 -0
- package/dist/tools/runners/utils.d.ts +69 -0
- package/dist/tools/runners/utils.js +179 -0
- package/dist/tools/search/definition.d.ts +19 -0
- package/dist/tools/search/definition.js +305 -0
- package/dist/tools/search/index.d.ts +8 -0
- package/dist/tools/search/index.js +8 -0
- package/dist/tools/search/references.d.ts +19 -0
- package/dist/tools/search/references.js +179 -0
- package/dist/tools/search/todos.d.ts +19 -0
- package/dist/tools/search/todos.js +269 -0
- package/dist/tools/search/types.d.ts +132 -0
- package/dist/tools/search/types.js +4 -0
- package/dist/tools/search/utils.d.ts +45 -0
- package/dist/tools/search/utils.js +152 -0
- package/package.json +88 -0
package/README.md
ADDED
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
# @compilr-dev/agents-coding
|
|
2
|
+
|
|
3
|
+
Coding-specific tools for [@compilr-dev/agents](https://github.com/scozzola/compilr-dev-agents) - Git operations, project detection, smart runners, and code search.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This extension package provides tools specifically designed for building AI coding assistants. It complements the core `@compilr-dev/agents` library with:
|
|
8
|
+
|
|
9
|
+
- **Git Tools** - Structured git operations with parsed output
|
|
10
|
+
- **Project Detection** - Auto-detect project type, package manager, and tooling
|
|
11
|
+
- **Smart Runners** - Auto-detect and run tests, lint, build, format
|
|
12
|
+
- **Code Search** - Find definitions, references, and TODO comments
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @compilr-dev/agents-coding @compilr-dev/agents
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { Agent } from '@compilr-dev/agents';
|
|
24
|
+
import { allCodingTools } from '@compilr-dev/agents-coding';
|
|
25
|
+
|
|
26
|
+
// Create an agent with coding tools
|
|
27
|
+
const agent = new Agent({
|
|
28
|
+
provider: yourProvider,
|
|
29
|
+
tools: allCodingTools,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Or register specific tools
|
|
33
|
+
import {
|
|
34
|
+
gitStatusTool,
|
|
35
|
+
gitCommitTool,
|
|
36
|
+
gitBranchTool,
|
|
37
|
+
detectProjectTool,
|
|
38
|
+
runTestsTool,
|
|
39
|
+
runLintTool,
|
|
40
|
+
findDefinitionTool,
|
|
41
|
+
findReferencesTool,
|
|
42
|
+
findTodosTool,
|
|
43
|
+
} from '@compilr-dev/agents-coding';
|
|
44
|
+
|
|
45
|
+
const agent = new Agent({
|
|
46
|
+
provider: yourProvider,
|
|
47
|
+
tools: [gitStatusTool, detectProjectTool],
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Available Tools
|
|
52
|
+
|
|
53
|
+
### Project Detection
|
|
54
|
+
|
|
55
|
+
#### `detectProjectTool`
|
|
56
|
+
|
|
57
|
+
Detect project type and available tooling in a directory.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const result = await detectProjectTool.execute({ path: '/path/to/project' });
|
|
61
|
+
// Returns:
|
|
62
|
+
// {
|
|
63
|
+
// type: 'node',
|
|
64
|
+
// types: ['node'],
|
|
65
|
+
// packageManager: 'pnpm',
|
|
66
|
+
// testFramework: 'vitest',
|
|
67
|
+
// linter: 'eslint',
|
|
68
|
+
// formatter: 'prettier',
|
|
69
|
+
// buildTool: 'vite',
|
|
70
|
+
// configFiles: ['package.json', 'tsconfig.json'],
|
|
71
|
+
// name: 'my-project'
|
|
72
|
+
// }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Supported Project Types:**
|
|
76
|
+
- `node` - package.json
|
|
77
|
+
- `python` - pyproject.toml, setup.py, requirements.txt
|
|
78
|
+
- `rust` - Cargo.toml
|
|
79
|
+
- `go` - go.mod
|
|
80
|
+
- `java` - pom.xml, build.gradle
|
|
81
|
+
- `ruby` - Gemfile
|
|
82
|
+
- `php` - composer.json
|
|
83
|
+
- `dotnet` - *.csproj, *.sln
|
|
84
|
+
|
|
85
|
+
#### `findProjectRootTool`
|
|
86
|
+
|
|
87
|
+
Find the root directory of a project by looking for marker files.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const result = await findProjectRootTool.execute({
|
|
91
|
+
path: '/path/to/project/src/components',
|
|
92
|
+
markers: ['.git', 'package.json'] // optional, uses defaults
|
|
93
|
+
});
|
|
94
|
+
// Returns:
|
|
95
|
+
// {
|
|
96
|
+
// root: '/path/to/project',
|
|
97
|
+
// foundMarker: 'package.json',
|
|
98
|
+
// depth: 2
|
|
99
|
+
// }
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Git Tools
|
|
103
|
+
|
|
104
|
+
#### `gitStatusTool`
|
|
105
|
+
|
|
106
|
+
Get structured git working tree status.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const result = await gitStatusTool.execute({ path: '/path/to/repo' });
|
|
110
|
+
// Returns:
|
|
111
|
+
// {
|
|
112
|
+
// branch: 'main',
|
|
113
|
+
// tracking: { remote: 'origin/main', ahead: 2, behind: 0 },
|
|
114
|
+
// staged: [{ path: 'src/index.ts', status: 'modified' }],
|
|
115
|
+
// modified: [{ path: 'README.md', status: 'modified' }],
|
|
116
|
+
// untracked: ['temp.txt'],
|
|
117
|
+
// isClean: false
|
|
118
|
+
// }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Options:**
|
|
122
|
+
- `includeUntracked` - Include untracked files (default: true)
|
|
123
|
+
- `short` - Also return short format status string
|
|
124
|
+
|
|
125
|
+
#### `gitDiffTool`
|
|
126
|
+
|
|
127
|
+
Show changes between commits, working tree, etc.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// Unstaged changes
|
|
131
|
+
const result = await gitDiffTool.execute({ path: '/path/to/repo' });
|
|
132
|
+
|
|
133
|
+
// Staged changes
|
|
134
|
+
const result = await gitDiffTool.execute({ path: '/path/to/repo', staged: true });
|
|
135
|
+
|
|
136
|
+
// Compare with a ref
|
|
137
|
+
const result = await gitDiffTool.execute({ path: '/path/to/repo', ref: 'HEAD~3' });
|
|
138
|
+
|
|
139
|
+
// Compare two refs
|
|
140
|
+
const result = await gitDiffTool.execute({
|
|
141
|
+
path: '/path/to/repo',
|
|
142
|
+
refA: 'main',
|
|
143
|
+
refB: 'feature-branch'
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Returns:
|
|
147
|
+
// {
|
|
148
|
+
// diff: '--- a/file.txt\n+++ b/file.txt\n...',
|
|
149
|
+
// files: [{ path: 'file.txt', additions: 10, deletions: 3 }],
|
|
150
|
+
// stats: { filesChanged: 1, insertions: 10, deletions: 3 }
|
|
151
|
+
// }
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Options:**
|
|
155
|
+
- `staged` - Show staged changes instead of unstaged
|
|
156
|
+
- `file` - Diff a specific file
|
|
157
|
+
- `ref` - Compare with a commit/branch
|
|
158
|
+
- `refA`, `refB` - Compare two refs
|
|
159
|
+
- `context` - Number of context lines (default: 3)
|
|
160
|
+
- `statOnly` - Show only statistics, no diff content
|
|
161
|
+
- `nameOnly` - Show only names of changed files
|
|
162
|
+
|
|
163
|
+
#### `gitLogTool`
|
|
164
|
+
|
|
165
|
+
Show commit history with filtering options.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
const result = await gitLogTool.execute({
|
|
169
|
+
path: '/path/to/repo',
|
|
170
|
+
limit: 10,
|
|
171
|
+
author: 'john',
|
|
172
|
+
since: '2 weeks ago',
|
|
173
|
+
grep: 'feat:'
|
|
174
|
+
});
|
|
175
|
+
// Returns:
|
|
176
|
+
// {
|
|
177
|
+
// commits: [
|
|
178
|
+
// {
|
|
179
|
+
// hash: 'abc123...',
|
|
180
|
+
// shortHash: 'abc123',
|
|
181
|
+
// author: 'John Doe',
|
|
182
|
+
// email: 'john@example.com',
|
|
183
|
+
// date: '2024-01-15T10:30:00Z',
|
|
184
|
+
// message: 'feat: add new feature',
|
|
185
|
+
// body: 'Detailed description...'
|
|
186
|
+
// }
|
|
187
|
+
// ]
|
|
188
|
+
// }
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Options:**
|
|
192
|
+
- `limit` - Number of commits (default: 10)
|
|
193
|
+
- `file` - Filter by file path
|
|
194
|
+
- `author` - Filter by author name/email
|
|
195
|
+
- `since`, `until` - Date range filters
|
|
196
|
+
- `grep` - Filter by message pattern
|
|
197
|
+
- `ref` - Branch/ref to show log for
|
|
198
|
+
- `stat` - Include diff statistics
|
|
199
|
+
|
|
200
|
+
#### `gitCommitTool`
|
|
201
|
+
|
|
202
|
+
Create a git commit with safety features.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
const result = await gitCommitTool.execute({
|
|
206
|
+
path: '/path/to/repo',
|
|
207
|
+
message: 'feat: add new feature',
|
|
208
|
+
files: ['src/index.ts', 'src/utils.ts'], // specific files to stage
|
|
209
|
+
// OR
|
|
210
|
+
addAll: true, // stage all including untracked
|
|
211
|
+
// OR
|
|
212
|
+
addModified: true, // stage only modified tracked files
|
|
213
|
+
});
|
|
214
|
+
// Returns:
|
|
215
|
+
// {
|
|
216
|
+
// hash: 'abc123def456...',
|
|
217
|
+
// shortHash: 'abc123d',
|
|
218
|
+
// branch: 'main',
|
|
219
|
+
// filesCommitted: 2,
|
|
220
|
+
// insertions: 45,
|
|
221
|
+
// deletions: 12,
|
|
222
|
+
// message: 'feat: add new feature'
|
|
223
|
+
// }
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Safety Features:**
|
|
227
|
+
- Automatically blocks commits containing potential secrets (`.env`, `credentials.json`, `.pem`, etc.)
|
|
228
|
+
- Warns about large files (>1MB)
|
|
229
|
+
- Requires explicit confirmation for `amend` and `noVerify` options
|
|
230
|
+
|
|
231
|
+
**Options:**
|
|
232
|
+
- `message` (required) - Commit message
|
|
233
|
+
- `files` - Specific files to stage before committing
|
|
234
|
+
- `addAll` - Stage all files including untracked (`git add -A`)
|
|
235
|
+
- `addModified` - Stage modified/deleted tracked files only (`git add -u`)
|
|
236
|
+
- `allowEmpty` - Allow creating an empty commit
|
|
237
|
+
- `amend` - Amend the previous commit (dangerous)
|
|
238
|
+
- `noVerify` - Skip pre-commit hooks (dangerous)
|
|
239
|
+
|
|
240
|
+
#### `gitBranchTool`
|
|
241
|
+
|
|
242
|
+
Manage git branches.
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
// List all branches
|
|
246
|
+
const result = await gitBranchTool.execute({
|
|
247
|
+
path: '/path/to/repo',
|
|
248
|
+
action: 'list',
|
|
249
|
+
remotes: true, // include remote branches
|
|
250
|
+
});
|
|
251
|
+
// Returns:
|
|
252
|
+
// {
|
|
253
|
+
// current: 'main',
|
|
254
|
+
// branches: [
|
|
255
|
+
// { name: 'main', isCurrent: true, tracking: 'origin/main', lastCommit: 'abc123' },
|
|
256
|
+
// { name: 'feature-x', isCurrent: false, tracking: 'origin/feature-x' }
|
|
257
|
+
// ],
|
|
258
|
+
// message: 'Found 2 branch(es)'
|
|
259
|
+
// }
|
|
260
|
+
|
|
261
|
+
// Create a new branch
|
|
262
|
+
await gitBranchTool.execute({
|
|
263
|
+
path: '/path/to/repo',
|
|
264
|
+
action: 'create',
|
|
265
|
+
name: 'feature-y',
|
|
266
|
+
startPoint: 'main', // optional base
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Switch branches
|
|
270
|
+
await gitBranchTool.execute({
|
|
271
|
+
path: '/path/to/repo',
|
|
272
|
+
action: 'switch',
|
|
273
|
+
name: 'feature-y',
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Delete a branch
|
|
277
|
+
await gitBranchTool.execute({
|
|
278
|
+
path: '/path/to/repo',
|
|
279
|
+
action: 'delete',
|
|
280
|
+
name: 'feature-y',
|
|
281
|
+
force: true, // delete even if not merged
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// Rename a branch
|
|
285
|
+
await gitBranchTool.execute({
|
|
286
|
+
path: '/path/to/repo',
|
|
287
|
+
action: 'rename',
|
|
288
|
+
name: 'old-name',
|
|
289
|
+
newName: 'new-name',
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Actions:**
|
|
294
|
+
- `list` - Show all branches
|
|
295
|
+
- `create` - Create a new branch
|
|
296
|
+
- `delete` - Delete a branch (protects current branch)
|
|
297
|
+
- `switch` - Switch to a branch
|
|
298
|
+
- `rename` - Rename a branch
|
|
299
|
+
|
|
300
|
+
#### `gitStashTool`
|
|
301
|
+
|
|
302
|
+
Manage git stashes.
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
// Stash current changes
|
|
306
|
+
const result = await gitStashTool.execute({
|
|
307
|
+
path: '/path/to/repo',
|
|
308
|
+
action: 'push',
|
|
309
|
+
message: 'WIP: feature work',
|
|
310
|
+
includeUntracked: true,
|
|
311
|
+
});
|
|
312
|
+
// Returns:
|
|
313
|
+
// { message: 'Stashed changes: WIP: feature work' }
|
|
314
|
+
|
|
315
|
+
// List all stashes
|
|
316
|
+
const result = await gitStashTool.execute({
|
|
317
|
+
path: '/path/to/repo',
|
|
318
|
+
action: 'list',
|
|
319
|
+
});
|
|
320
|
+
// Returns:
|
|
321
|
+
// {
|
|
322
|
+
// stashes: [
|
|
323
|
+
// { ref: 'stash@{0}', index: 0, branch: 'main', message: 'WIP: feature work' },
|
|
324
|
+
// { ref: 'stash@{1}', index: 1, branch: 'main', message: 'backup' }
|
|
325
|
+
// ],
|
|
326
|
+
// message: 'Found 2 stash(es)'
|
|
327
|
+
// }
|
|
328
|
+
|
|
329
|
+
// Pop stash (apply and remove)
|
|
330
|
+
await gitStashTool.execute({
|
|
331
|
+
path: '/path/to/repo',
|
|
332
|
+
action: 'pop',
|
|
333
|
+
index: 0, // optional, defaults to 0
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// Apply stash (keep in stash list)
|
|
337
|
+
await gitStashTool.execute({
|
|
338
|
+
path: '/path/to/repo',
|
|
339
|
+
action: 'apply',
|
|
340
|
+
index: 0,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Show stash contents
|
|
344
|
+
const result = await gitStashTool.execute({
|
|
345
|
+
path: '/path/to/repo',
|
|
346
|
+
action: 'show',
|
|
347
|
+
index: 0,
|
|
348
|
+
});
|
|
349
|
+
// Returns:
|
|
350
|
+
// { diff: '--- a/file.txt\n...', message: ' file.txt | 5 ++---\n 1 file changed...' }
|
|
351
|
+
|
|
352
|
+
// Drop a specific stash
|
|
353
|
+
await gitStashTool.execute({
|
|
354
|
+
path: '/path/to/repo',
|
|
355
|
+
action: 'drop',
|
|
356
|
+
index: 1,
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
// Clear all stashes
|
|
360
|
+
await gitStashTool.execute({
|
|
361
|
+
path: '/path/to/repo',
|
|
362
|
+
action: 'clear',
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Actions:**
|
|
367
|
+
- `push` - Save changes to stash
|
|
368
|
+
- `pop` - Apply and remove stash
|
|
369
|
+
- `apply` - Apply stash without removing
|
|
370
|
+
- `list` - Show all stashes
|
|
371
|
+
- `drop` - Remove a specific stash
|
|
372
|
+
- `clear` - Remove all stashes
|
|
373
|
+
- `show` - Display stash contents
|
|
374
|
+
|
|
375
|
+
### Smart Runner Tools
|
|
376
|
+
|
|
377
|
+
All runner tools support a `dryRun` option to detect the tool/framework and return the command without actually executing it. This is useful for:
|
|
378
|
+
- Previewing what command would run
|
|
379
|
+
- Testing detection logic without side effects
|
|
380
|
+
- Implementing "rehearsal" patterns for safety
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
// Dry run - just detect, don't execute
|
|
384
|
+
const result = await runBuildTool.execute({
|
|
385
|
+
path: '/path/to/project',
|
|
386
|
+
dryRun: true,
|
|
387
|
+
});
|
|
388
|
+
// Returns detected tool and command without running it:
|
|
389
|
+
// { buildTool: 'vite', command: 'npx vite build', output: '(dry run - command not executed)' }
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### `runTestsTool`
|
|
393
|
+
|
|
394
|
+
Auto-detect and run tests using the appropriate test framework.
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
const result = await runTestsTool.execute({
|
|
398
|
+
path: '/path/to/project',
|
|
399
|
+
pattern: 'src/**/*.test.ts', // optional filter
|
|
400
|
+
coverage: true,
|
|
401
|
+
verbose: true,
|
|
402
|
+
});
|
|
403
|
+
// Returns:
|
|
404
|
+
// {
|
|
405
|
+
// command: 'npx vitest run --coverage',
|
|
406
|
+
// output: '...',
|
|
407
|
+
// exitCode: 0,
|
|
408
|
+
// duration: 5230,
|
|
409
|
+
// success: true,
|
|
410
|
+
// framework: 'vitest',
|
|
411
|
+
// passed: 42,
|
|
412
|
+
// failed: 0,
|
|
413
|
+
// total: 42
|
|
414
|
+
// }
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**Supported Frameworks:**
|
|
418
|
+
- `vitest` - vitest.config.ts/js or dependency
|
|
419
|
+
- `jest` - jest.config.ts/js/json or dependency
|
|
420
|
+
- `mocha` - .mocharc.json/js/yaml or dependency
|
|
421
|
+
- `ava` - ava.config.js/cjs or dependency
|
|
422
|
+
- `npm test` - package.json scripts.test
|
|
423
|
+
- `pytest` - pytest.ini, pyproject.toml, conftest.py
|
|
424
|
+
- `unittest` - setup.py, setup.cfg
|
|
425
|
+
- `cargo test` - Cargo.toml
|
|
426
|
+
- `go test` - go.mod
|
|
427
|
+
|
|
428
|
+
**Options:**
|
|
429
|
+
- `pattern` - Test file pattern or name filter
|
|
430
|
+
- `watch` - Run in watch mode
|
|
431
|
+
- `coverage` - Generate coverage report
|
|
432
|
+
- `verbose` - Verbose output
|
|
433
|
+
- `updateSnapshots` - Update test snapshots (jest/vitest)
|
|
434
|
+
- `timeout` - Command timeout in milliseconds
|
|
435
|
+
|
|
436
|
+
#### `runLintTool`
|
|
437
|
+
|
|
438
|
+
Auto-detect and run linter.
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
const result = await runLintTool.execute({
|
|
442
|
+
path: '/path/to/project',
|
|
443
|
+
fix: true,
|
|
444
|
+
files: ['src/index.ts'],
|
|
445
|
+
});
|
|
446
|
+
// Returns:
|
|
447
|
+
// {
|
|
448
|
+
// command: 'npx eslint src/index.ts --fix',
|
|
449
|
+
// output: '...',
|
|
450
|
+
// exitCode: 0,
|
|
451
|
+
// duration: 1230,
|
|
452
|
+
// success: true,
|
|
453
|
+
// linter: 'eslint',
|
|
454
|
+
// errors: 0,
|
|
455
|
+
// warnings: 2
|
|
456
|
+
// }
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**Supported Linters:**
|
|
460
|
+
- `eslint` - eslint.config.js/mjs/cjs, .eslintrc.* or dependency
|
|
461
|
+
- `biome` - biome.json/jsonc or dependency
|
|
462
|
+
- `npm lint` - package.json scripts.lint
|
|
463
|
+
- `ruff` - ruff.toml, .ruff.toml
|
|
464
|
+
- `pylint` - .pylintrc, pylintrc
|
|
465
|
+
- `flake8` - .flake8, setup.cfg
|
|
466
|
+
- `clippy` - Cargo.toml
|
|
467
|
+
- `golangci-lint` - .golangci.yml/yaml/json or go.mod
|
|
468
|
+
|
|
469
|
+
**Options:**
|
|
470
|
+
- `files` - Specific files to lint
|
|
471
|
+
- `fix` - Auto-fix issues
|
|
472
|
+
- `format` - Output format (json, stylish, etc.)
|
|
473
|
+
- `timeout` - Command timeout
|
|
474
|
+
|
|
475
|
+
#### `runBuildTool`
|
|
476
|
+
|
|
477
|
+
Auto-detect and run build.
|
|
478
|
+
|
|
479
|
+
```typescript
|
|
480
|
+
const result = await runBuildTool.execute({
|
|
481
|
+
path: '/path/to/project',
|
|
482
|
+
production: true,
|
|
483
|
+
});
|
|
484
|
+
// Returns:
|
|
485
|
+
// {
|
|
486
|
+
// command: 'npx vite build --mode production',
|
|
487
|
+
// output: '...',
|
|
488
|
+
// exitCode: 0,
|
|
489
|
+
// duration: 8500,
|
|
490
|
+
// success: true,
|
|
491
|
+
// buildTool: 'vite'
|
|
492
|
+
// }
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**Supported Build Tools:**
|
|
496
|
+
- `vite` - vite.config.ts/js/mjs or dependency
|
|
497
|
+
- `next` - next.config.js/mjs/ts or dependency
|
|
498
|
+
- `tsc` - tsconfig.json with typescript dependency
|
|
499
|
+
- `webpack` - webpack.config.js/ts or dependency
|
|
500
|
+
- `rollup` - rollup.config.js/mjs or dependency
|
|
501
|
+
- `esbuild` - esbuild.config.js/mjs or dependency
|
|
502
|
+
- `turbo` - turbo.json or dependency
|
|
503
|
+
- `npm build` - package.json scripts.build
|
|
504
|
+
- `cargo build` - Cargo.toml
|
|
505
|
+
- `go build` - go.mod
|
|
506
|
+
- `python build` - setup.py, pyproject.toml
|
|
507
|
+
- `maven` - pom.xml
|
|
508
|
+
- `gradle` - build.gradle, build.gradle.kts
|
|
509
|
+
|
|
510
|
+
**Options:**
|
|
511
|
+
- `production` - Build for production
|
|
512
|
+
- `clean` - Clean before build
|
|
513
|
+
- `timeout` - Command timeout
|
|
514
|
+
|
|
515
|
+
#### `runFormatTool`
|
|
516
|
+
|
|
517
|
+
Auto-detect and run formatter.
|
|
518
|
+
|
|
519
|
+
```typescript
|
|
520
|
+
const result = await runFormatTool.execute({
|
|
521
|
+
path: '/path/to/project',
|
|
522
|
+
check: true, // check only, don't write
|
|
523
|
+
});
|
|
524
|
+
// Returns:
|
|
525
|
+
// {
|
|
526
|
+
// command: 'npx prettier --check .',
|
|
527
|
+
// output: '...',
|
|
528
|
+
// exitCode: 0,
|
|
529
|
+
// duration: 2100,
|
|
530
|
+
// success: true,
|
|
531
|
+
// formatter: 'prettier',
|
|
532
|
+
// filesProcessed: 45
|
|
533
|
+
// }
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
**Supported Formatters:**
|
|
537
|
+
- `prettier` - .prettierrc.* or prettier.config.* or dependency
|
|
538
|
+
- `biome` - biome.json/jsonc or dependency
|
|
539
|
+
- `dprint` - dprint.json, .dprint.json or dependency
|
|
540
|
+
- `npm format` - package.json scripts.format
|
|
541
|
+
- `black` - pyproject.toml, .black
|
|
542
|
+
- `ruff format` - ruff.toml, .ruff.toml
|
|
543
|
+
- `autopep8` - .pep8, setup.cfg
|
|
544
|
+
- `rustfmt` - Cargo.toml
|
|
545
|
+
- `gofmt` - go.mod
|
|
546
|
+
- `goimports` - go.mod
|
|
547
|
+
|
|
548
|
+
**Options:**
|
|
549
|
+
- `files` - Specific files to format
|
|
550
|
+
- `check` - Check only, don't write changes
|
|
551
|
+
- `timeout` - Command timeout
|
|
552
|
+
|
|
553
|
+
### Code Search Tools
|
|
554
|
+
|
|
555
|
+
#### `findDefinitionTool`
|
|
556
|
+
|
|
557
|
+
Find where a symbol is defined in the codebase.
|
|
558
|
+
|
|
559
|
+
```typescript
|
|
560
|
+
const result = await findDefinitionTool.execute({
|
|
561
|
+
path: '/path/to/project',
|
|
562
|
+
symbol: 'calculateSum',
|
|
563
|
+
fileType: 'ts', // optional filter
|
|
564
|
+
});
|
|
565
|
+
// Returns:
|
|
566
|
+
// {
|
|
567
|
+
// definitions: [
|
|
568
|
+
// {
|
|
569
|
+
// file: 'src/utils.ts',
|
|
570
|
+
// line: 8,
|
|
571
|
+
// column: 17,
|
|
572
|
+
// context: 'export function calculateSum(a: number, b: number): number {',
|
|
573
|
+
// type: 'function',
|
|
574
|
+
// isExported: true
|
|
575
|
+
// }
|
|
576
|
+
// ],
|
|
577
|
+
// totalFound: 1,
|
|
578
|
+
// symbol: 'calculateSum'
|
|
579
|
+
// }
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
**Supported Languages:**
|
|
583
|
+
- TypeScript/JavaScript - functions, classes, interfaces, types, const, enums
|
|
584
|
+
- Python - functions, classes, async functions
|
|
585
|
+
- Rust - fn, struct, enum, trait, type
|
|
586
|
+
- Go - func, type, const, var
|
|
587
|
+
- Java/Kotlin - classes, interfaces, methods
|
|
588
|
+
|
|
589
|
+
**Options:**
|
|
590
|
+
- `symbol` (required) - Symbol name to find
|
|
591
|
+
- `path` - Working directory
|
|
592
|
+
- `fileType` - File type filter (ts, py, rs, go, java, etc.)
|
|
593
|
+
- `limit` - Maximum results (default: 20)
|
|
594
|
+
|
|
595
|
+
#### `findReferencesTool`
|
|
596
|
+
|
|
597
|
+
Find all usages of a symbol in the codebase.
|
|
598
|
+
|
|
599
|
+
```typescript
|
|
600
|
+
const result = await findReferencesTool.execute({
|
|
601
|
+
path: '/path/to/project',
|
|
602
|
+
symbol: 'calculateSum',
|
|
603
|
+
excludeDefinitions: true,
|
|
604
|
+
});
|
|
605
|
+
// Returns:
|
|
606
|
+
// {
|
|
607
|
+
// references: [
|
|
608
|
+
// { file: 'src/main.ts', line: 5, column: 18, context: ' const sum = calculateSum(1, 2);' },
|
|
609
|
+
// { file: 'src/calc.ts', line: 12, column: 10, context: ' return calculateSum(a, b);' }
|
|
610
|
+
// ],
|
|
611
|
+
// totalFound: 2,
|
|
612
|
+
// symbol: 'calculateSum'
|
|
613
|
+
// }
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
**Options:**
|
|
617
|
+
- `symbol` (required) - Symbol name to find
|
|
618
|
+
- `path` - Working directory
|
|
619
|
+
- `fileType` - File type filter
|
|
620
|
+
- `excludeDefinitions` - Exclude definition lines, show only usages (default: false)
|
|
621
|
+
- `limit` - Maximum results (default: 50)
|
|
622
|
+
|
|
623
|
+
#### `findTodosTool`
|
|
624
|
+
|
|
625
|
+
Find TODO, FIXME, HACK, and other comment markers in code.
|
|
626
|
+
|
|
627
|
+
```typescript
|
|
628
|
+
const result = await findTodosTool.execute({
|
|
629
|
+
path: '/path/to/project',
|
|
630
|
+
types: ['TODO', 'FIXME'],
|
|
631
|
+
includeAuthor: true,
|
|
632
|
+
});
|
|
633
|
+
// Returns:
|
|
634
|
+
// {
|
|
635
|
+
// todos: [
|
|
636
|
+
// {
|
|
637
|
+
// type: 'TODO',
|
|
638
|
+
// file: 'src/utils.ts',
|
|
639
|
+
// line: 5,
|
|
640
|
+
// text: 'Add error handling',
|
|
641
|
+
// author: 'John Doe' // if includeAuthor: true
|
|
642
|
+
// },
|
|
643
|
+
// {
|
|
644
|
+
// type: 'FIXME',
|
|
645
|
+
// file: 'src/api.ts',
|
|
646
|
+
// line: 42,
|
|
647
|
+
// text: 'This needs optimization'
|
|
648
|
+
// }
|
|
649
|
+
// ],
|
|
650
|
+
// summary: { TODO: 1, FIXME: 1 },
|
|
651
|
+
// totalFound: 2
|
|
652
|
+
// }
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
**Supported Comment Types:**
|
|
656
|
+
- `TODO` - Tasks to be done
|
|
657
|
+
- `FIXME` - Bugs to fix
|
|
658
|
+
- `HACK` - Workarounds
|
|
659
|
+
- `XXX` - Critical issues
|
|
660
|
+
- `NOTE` - Important notes
|
|
661
|
+
- `BUG` - Known bugs
|
|
662
|
+
- `WARN` - Warnings
|
|
663
|
+
|
|
664
|
+
**Options:**
|
|
665
|
+
- `path` - Working directory
|
|
666
|
+
- `types` - Comment types to find (default: all)
|
|
667
|
+
- `fileType` - File type filter (ts, py, rs, go, etc.)
|
|
668
|
+
- `includeAuthor` - Include git blame author info (slower, limited to first 20 results)
|
|
669
|
+
- `limit` - Maximum results (default: 100)
|
|
670
|
+
|
|
671
|
+
## Factory Functions
|
|
672
|
+
|
|
673
|
+
Each tool has a factory function for customization:
|
|
674
|
+
|
|
675
|
+
```typescript
|
|
676
|
+
import { createGitStatusTool, createDetectProjectTool } from '@compilr-dev/agents-coding';
|
|
677
|
+
|
|
678
|
+
// Custom base directory
|
|
679
|
+
const customGitStatus = createGitStatusTool({
|
|
680
|
+
baseDir: '/workspace',
|
|
681
|
+
defaultIncludeUntracked: false,
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
const customDetectProject = createDetectProjectTool({
|
|
685
|
+
baseDir: '/workspace',
|
|
686
|
+
});
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
## Design Principles
|
|
690
|
+
|
|
691
|
+
1. **Zero Dependencies** - Only peer dependency on `@compilr-dev/agents`
|
|
692
|
+
2. **Structured Output** - All tools return parsed, typed data (not raw strings)
|
|
693
|
+
3. **CLI-First** - Uses git CLI directly for predictable behavior
|
|
694
|
+
4. **Safety First** - Git tools include protections against dangerous operations
|
|
695
|
+
5. **TypeScript Native** - Full type safety throughout
|
|
696
|
+
|
|
697
|
+
## Roadmap
|
|
698
|
+
|
|
699
|
+
### Phase 1: Foundation ✅
|
|
700
|
+
- [x] detectProjectTool
|
|
701
|
+
- [x] findProjectRootTool
|
|
702
|
+
- [x] gitStatusTool
|
|
703
|
+
- [x] gitDiffTool
|
|
704
|
+
- [x] gitLogTool
|
|
705
|
+
|
|
706
|
+
### Phase 2: Core Git ✅
|
|
707
|
+
- [x] gitCommitTool - Create commits with safety features
|
|
708
|
+
- [x] gitBranchTool - Branch management
|
|
709
|
+
- [x] gitStashTool - Stash operations
|
|
710
|
+
|
|
711
|
+
### Phase 3: Smart Runners ✅
|
|
712
|
+
- [x] runTestsTool - Auto-detect and run tests
|
|
713
|
+
- [x] runLintTool - Auto-detect and run linter
|
|
714
|
+
- [x] runBuildTool - Auto-detect and run build
|
|
715
|
+
- [x] runFormatTool - Auto-detect and run formatter
|
|
716
|
+
|
|
717
|
+
### Phase 4: Code Search ✅
|
|
718
|
+
- [x] findDefinitionTool - Find symbol definitions
|
|
719
|
+
- [x] findReferencesTool - Find symbol usages
|
|
720
|
+
- [x] findTodosTool - Find TODO/FIXME comments
|
|
721
|
+
|
|
722
|
+
### Phase 5: Skills & Polish ✅
|
|
723
|
+
- [x] Coding-specific skills (6 skills)
|
|
724
|
+
- [x] Comprehensive documentation
|
|
725
|
+
|
|
726
|
+
## Skills
|
|
727
|
+
|
|
728
|
+
Coding-specific skills for specialized workflows. Use with `SkillRegistry` from `@compilr-dev/agents`.
|
|
729
|
+
|
|
730
|
+
```typescript
|
|
731
|
+
import { SkillRegistry } from '@compilr-dev/agents';
|
|
732
|
+
import { codingSkills } from '@compilr-dev/agents-coding';
|
|
733
|
+
|
|
734
|
+
const registry = new SkillRegistry();
|
|
735
|
+
registry.registerAll(codingSkills);
|
|
736
|
+
|
|
737
|
+
// Invoke a skill
|
|
738
|
+
const result = registry.invoke('git-workflow');
|
|
739
|
+
console.log(result.prompt); // Expanded skill prompt
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
### Available Skills
|
|
743
|
+
|
|
744
|
+
| Skill | Description |
|
|
745
|
+
|-------|-------------|
|
|
746
|
+
| `git-workflow` | Best practices for git operations with safety checks |
|
|
747
|
+
| `test-driven` | Test-driven development workflow with smart runners |
|
|
748
|
+
| `code-navigation` | Effectively navigate and understand codebases |
|
|
749
|
+
| `pr-workflow` | Pull request creation and review workflow |
|
|
750
|
+
| `project-onboarding` | Quickly understand and navigate a new project |
|
|
751
|
+
| `code-optimization` | Performance optimization workflow |
|
|
752
|
+
|
|
753
|
+
### Skill Details
|
|
754
|
+
|
|
755
|
+
#### `git-workflow`
|
|
756
|
+
Safe git operations including verification before destructive actions, commit workflow, and recovery strategies.
|
|
757
|
+
|
|
758
|
+
#### `test-driven`
|
|
759
|
+
Red-Green-Refactor cycle with integration of `runTests`, `runLint`, `runBuild`, and `runFormat` tools.
|
|
760
|
+
|
|
761
|
+
#### `code-navigation`
|
|
762
|
+
Using `findDefinition`, `findReferences`, and `findTodos` to understand and navigate code.
|
|
763
|
+
|
|
764
|
+
#### `pr-workflow`
|
|
765
|
+
Complete PR workflow from branch preparation through review and merge, with pre-flight checks.
|
|
766
|
+
|
|
767
|
+
#### `project-onboarding`
|
|
768
|
+
Systematic approach to understanding new codebases using `detectProject` and search tools.
|
|
769
|
+
|
|
770
|
+
#### `code-optimization`
|
|
771
|
+
Performance optimization with measurement-first approach and common optimization patterns.
|
|
772
|
+
|
|
773
|
+
## Runtime Dependencies
|
|
774
|
+
|
|
775
|
+
Some tools require external programs to be installed:
|
|
776
|
+
|
|
777
|
+
| Tool | Dependency | Installation |
|
|
778
|
+
|------|------------|--------------|
|
|
779
|
+
| Code Search tools | `ripgrep` (rg) | `apt install ripgrep` or `brew install ripgrep` |
|
|
780
|
+
| Git tools | `git` | Usually pre-installed |
|
|
781
|
+
|
|
782
|
+
## License
|
|
783
|
+
|
|
784
|
+
MIT
|
|
785
|
+
|
|
786
|
+
## Related
|
|
787
|
+
|
|
788
|
+
- [@compilr-dev/agents](https://github.com/scozzola/compilr-dev-agents) - Core agent library
|