@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
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for Code Search tools
|
|
3
|
+
*/
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { stat } from 'node:fs/promises';
|
|
6
|
+
/**
|
|
7
|
+
* File extensions by language type (canonical source)
|
|
8
|
+
*/
|
|
9
|
+
export const FILE_TYPE_EXTENSIONS = {
|
|
10
|
+
ts: ['ts', 'tsx'],
|
|
11
|
+
js: ['js', 'jsx', 'mjs', 'cjs'],
|
|
12
|
+
py: ['py'],
|
|
13
|
+
rs: ['rs'],
|
|
14
|
+
go: ['go'],
|
|
15
|
+
java: ['java'],
|
|
16
|
+
kt: ['kt', 'kts'],
|
|
17
|
+
rb: ['rb'],
|
|
18
|
+
php: ['php'],
|
|
19
|
+
c: ['c', 'h'],
|
|
20
|
+
cpp: ['cpp', 'hpp', 'cc', 'cxx'],
|
|
21
|
+
cs: ['cs'],
|
|
22
|
+
md: ['md'],
|
|
23
|
+
yaml: ['yaml', 'yml'],
|
|
24
|
+
json: ['json'],
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* All source file extensions (for default glob patterns)
|
|
28
|
+
*/
|
|
29
|
+
export const ALL_SOURCE_EXTENSIONS = [
|
|
30
|
+
'ts',
|
|
31
|
+
'tsx',
|
|
32
|
+
'js',
|
|
33
|
+
'jsx',
|
|
34
|
+
'mjs',
|
|
35
|
+
'cjs',
|
|
36
|
+
'py',
|
|
37
|
+
'rs',
|
|
38
|
+
'go',
|
|
39
|
+
'java',
|
|
40
|
+
'kt',
|
|
41
|
+
'kts',
|
|
42
|
+
'rb',
|
|
43
|
+
'php',
|
|
44
|
+
'c',
|
|
45
|
+
'h',
|
|
46
|
+
'cpp',
|
|
47
|
+
'hpp',
|
|
48
|
+
'cc',
|
|
49
|
+
'cxx',
|
|
50
|
+
'cs',
|
|
51
|
+
'md',
|
|
52
|
+
'yaml',
|
|
53
|
+
'yml',
|
|
54
|
+
'json',
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Default timeout for search operations (30 seconds)
|
|
58
|
+
*/
|
|
59
|
+
export const SEARCH_TIMEOUT = 30000;
|
|
60
|
+
/**
|
|
61
|
+
* Escape special regex characters
|
|
62
|
+
*/
|
|
63
|
+
export function escapeRegex(str) {
|
|
64
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get glob pattern for file type filtering
|
|
68
|
+
*/
|
|
69
|
+
export function getGlobPattern(fileType, extensions) {
|
|
70
|
+
if (!fileType) {
|
|
71
|
+
const allExts = extensions ?? ALL_SOURCE_EXTENSIONS;
|
|
72
|
+
return `**/*.{${allExts.join(',')}}`;
|
|
73
|
+
}
|
|
74
|
+
const exts = FILE_TYPE_EXTENSIONS[fileType] ?? [fileType];
|
|
75
|
+
return exts.length === 1 ? `**/*.${exts[0]}` : `**/*.{${exts.join(',')}}`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check if path is a directory
|
|
79
|
+
*/
|
|
80
|
+
export async function isDirectory(path) {
|
|
81
|
+
try {
|
|
82
|
+
const stats = await stat(path);
|
|
83
|
+
return stats.isDirectory();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Run ripgrep and parse results
|
|
91
|
+
*
|
|
92
|
+
* @param args - ripgrep arguments (without the command itself)
|
|
93
|
+
* @param cwd - working directory
|
|
94
|
+
* @param limit - maximum results to return
|
|
95
|
+
* @param includeColumn - whether to parse column from output
|
|
96
|
+
*/
|
|
97
|
+
export function runGrep(args, cwd, limit, includeColumn = true) {
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
const results = [];
|
|
100
|
+
const proc = spawn('rg', args, { cwd });
|
|
101
|
+
let stdout = '';
|
|
102
|
+
let timedOut = false;
|
|
103
|
+
const timeout = setTimeout(() => {
|
|
104
|
+
timedOut = true;
|
|
105
|
+
proc.kill();
|
|
106
|
+
}, SEARCH_TIMEOUT);
|
|
107
|
+
proc.stdout.on('data', (data) => {
|
|
108
|
+
stdout += data.toString();
|
|
109
|
+
});
|
|
110
|
+
proc.on('close', () => {
|
|
111
|
+
clearTimeout(timeout);
|
|
112
|
+
if (timedOut) {
|
|
113
|
+
resolve(results);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// Parse ripgrep output
|
|
117
|
+
const lines = stdout.split('\n').filter(Boolean);
|
|
118
|
+
for (const line of lines) {
|
|
119
|
+
if (results.length >= limit)
|
|
120
|
+
break;
|
|
121
|
+
if (includeColumn) {
|
|
122
|
+
// Format: file:line:column:content
|
|
123
|
+
const match = line.match(/^([^:]+):(\d+):(\d+):(.*)$/);
|
|
124
|
+
if (match) {
|
|
125
|
+
results.push({
|
|
126
|
+
file: match[1],
|
|
127
|
+
line: parseInt(match[2], 10),
|
|
128
|
+
column: parseInt(match[3], 10),
|
|
129
|
+
context: match[4],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Format: file:line:content
|
|
135
|
+
const match = line.match(/^([^:]+):(\d+):(.*)$/);
|
|
136
|
+
if (match) {
|
|
137
|
+
results.push({
|
|
138
|
+
file: match[1],
|
|
139
|
+
line: parseInt(match[2], 10),
|
|
140
|
+
context: match[3],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
resolve(results);
|
|
146
|
+
});
|
|
147
|
+
proc.on('error', () => {
|
|
148
|
+
clearTimeout(timeout);
|
|
149
|
+
resolve(results);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@compilr-dev/agents-coding",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Coding-specific tools for @compilr-dev/agents - Git, project detection, smart runners, and code search",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./tools/git": {
|
|
14
|
+
"types": "./dist/tools/git/index.d.ts",
|
|
15
|
+
"import": "./dist/tools/git/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./tools/project": {
|
|
18
|
+
"types": "./dist/tools/project/index.d.ts",
|
|
19
|
+
"import": "./dist/tools/project/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./tools/runners": {
|
|
22
|
+
"types": "./dist/tools/runners/index.d.ts",
|
|
23
|
+
"import": "./dist/tools/runners/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./tools/search": {
|
|
26
|
+
"types": "./dist/tools/search/index.d.ts",
|
|
27
|
+
"import": "./dist/tools/search/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./skills": {
|
|
30
|
+
"types": "./dist/skills/index.d.ts",
|
|
31
|
+
"import": "./dist/skills/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc",
|
|
39
|
+
"clean": "rm -rf dist",
|
|
40
|
+
"lint": "eslint src/",
|
|
41
|
+
"lint:fix": "eslint src/ --fix",
|
|
42
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
43
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"test:coverage": "vitest run --coverage",
|
|
47
|
+
"prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build",
|
|
48
|
+
"typecheck": "tsc --noEmit"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/scozzola/compilr-dev-agents-coding.git"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"ai",
|
|
56
|
+
"agents",
|
|
57
|
+
"llm",
|
|
58
|
+
"coding",
|
|
59
|
+
"git",
|
|
60
|
+
"tools",
|
|
61
|
+
"cli",
|
|
62
|
+
"typescript"
|
|
63
|
+
],
|
|
64
|
+
"author": "Carmelo Scozzola",
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"bugs": {
|
|
67
|
+
"url": "https://github.com/scozzola/compilr-dev-agents-coding/issues"
|
|
68
|
+
},
|
|
69
|
+
"homepage": "https://github.com/scozzola/compilr-dev-agents-coding#readme",
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=18.0.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@compilr-dev/agents": "^0.0.1"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@anthropic-ai/sdk": "^0.30.1",
|
|
78
|
+
"@compilr-dev/agents": "^0.0.1",
|
|
79
|
+
"@eslint/js": "^9.39.1",
|
|
80
|
+
"@types/node": "^24.10.1",
|
|
81
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
82
|
+
"eslint": "^9.39.1",
|
|
83
|
+
"prettier": "^3.7.1",
|
|
84
|
+
"typescript": "^5.3.0",
|
|
85
|
+
"typescript-eslint": "^8.48.0",
|
|
86
|
+
"vitest": "^3.2.4"
|
|
87
|
+
}
|
|
88
|
+
}
|