@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.
Files changed (60) hide show
  1. package/README.md +788 -0
  2. package/dist/index.d.ts +39 -0
  3. package/dist/index.js +75 -0
  4. package/dist/skills/index.d.ts +39 -0
  5. package/dist/skills/index.js +322 -0
  6. package/dist/tools/git/branch.d.ts +17 -0
  7. package/dist/tools/git/branch.js +264 -0
  8. package/dist/tools/git/commit.d.ts +23 -0
  9. package/dist/tools/git/commit.js +280 -0
  10. package/dist/tools/git/diff.d.ts +19 -0
  11. package/dist/tools/git/diff.js +221 -0
  12. package/dist/tools/git/index.d.ts +10 -0
  13. package/dist/tools/git/index.js +11 -0
  14. package/dist/tools/git/log.d.ts +19 -0
  15. package/dist/tools/git/log.js +235 -0
  16. package/dist/tools/git/stash.d.ts +17 -0
  17. package/dist/tools/git/stash.js +294 -0
  18. package/dist/tools/git/status.d.ts +19 -0
  19. package/dist/tools/git/status.js +160 -0
  20. package/dist/tools/git/types.d.ts +293 -0
  21. package/dist/tools/git/types.js +4 -0
  22. package/dist/tools/git/utils.d.ts +58 -0
  23. package/dist/tools/git/utils.js +197 -0
  24. package/dist/tools/index.d.ts +5 -0
  25. package/dist/tools/index.js +5 -0
  26. package/dist/tools/project/detect.d.ts +19 -0
  27. package/dist/tools/project/detect.js +341 -0
  28. package/dist/tools/project/find-root.d.ts +21 -0
  29. package/dist/tools/project/find-root.js +239 -0
  30. package/dist/tools/project/index.d.ts +6 -0
  31. package/dist/tools/project/index.js +5 -0
  32. package/dist/tools/project/types.d.ts +83 -0
  33. package/dist/tools/project/types.js +4 -0
  34. package/dist/tools/runners/build.d.ts +19 -0
  35. package/dist/tools/runners/build.js +306 -0
  36. package/dist/tools/runners/format.d.ts +19 -0
  37. package/dist/tools/runners/format.js +376 -0
  38. package/dist/tools/runners/index.d.ts +9 -0
  39. package/dist/tools/runners/index.js +9 -0
  40. package/dist/tools/runners/lint.d.ts +19 -0
  41. package/dist/tools/runners/lint.js +356 -0
  42. package/dist/tools/runners/test.d.ts +19 -0
  43. package/dist/tools/runners/test.js +386 -0
  44. package/dist/tools/runners/types.d.ts +97 -0
  45. package/dist/tools/runners/types.js +4 -0
  46. package/dist/tools/runners/utils.d.ts +69 -0
  47. package/dist/tools/runners/utils.js +179 -0
  48. package/dist/tools/search/definition.d.ts +19 -0
  49. package/dist/tools/search/definition.js +305 -0
  50. package/dist/tools/search/index.d.ts +8 -0
  51. package/dist/tools/search/index.js +8 -0
  52. package/dist/tools/search/references.d.ts +19 -0
  53. package/dist/tools/search/references.js +179 -0
  54. package/dist/tools/search/todos.d.ts +19 -0
  55. package/dist/tools/search/todos.js +269 -0
  56. package/dist/tools/search/types.d.ts +132 -0
  57. package/dist/tools/search/types.js +4 -0
  58. package/dist/tools/search/utils.d.ts +45 -0
  59. package/dist/tools/search/utils.js +152 -0
  60. package/package.json +88 -0
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Types for project detection tools
3
+ */
4
+ /**
5
+ * Detected project types
6
+ */
7
+ export type ProjectType = 'node' | 'python' | 'rust' | 'go' | 'java' | 'ruby' | 'php' | 'dotnet' | 'unknown';
8
+ /**
9
+ * Package managers by project type
10
+ */
11
+ export type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'pip' | 'poetry' | 'cargo' | 'go' | 'maven' | 'gradle' | 'bundler' | 'composer' | 'dotnet';
12
+ /**
13
+ * Input for detectProject tool
14
+ */
15
+ export interface DetectProjectInput {
16
+ /** Directory to analyze (default: current directory) */
17
+ path?: string;
18
+ }
19
+ /**
20
+ * Result of project detection
21
+ */
22
+ export interface DetectProjectResult {
23
+ /** Primary project type */
24
+ type: ProjectType;
25
+ /** All detected types (for monorepos or multi-language projects) */
26
+ types: ProjectType[];
27
+ /** Package manager detected */
28
+ packageManager?: PackageManager;
29
+ /** Test framework detected */
30
+ testFramework?: string;
31
+ /** Linter detected */
32
+ linter?: string;
33
+ /** Formatter detected */
34
+ formatter?: string;
35
+ /** Build tool detected */
36
+ buildTool?: string;
37
+ /** Config files found */
38
+ configFiles: string[];
39
+ /** Project name (if detectable) */
40
+ name?: string;
41
+ }
42
+ /**
43
+ * Input for findProjectRoot tool
44
+ */
45
+ export interface FindProjectRootInput {
46
+ /** Starting directory (default: current directory) */
47
+ path?: string;
48
+ /** Marker files to look for */
49
+ markers?: string[];
50
+ }
51
+ /**
52
+ * Result of finding project root
53
+ */
54
+ export interface FindProjectRootResult {
55
+ /** Project root path */
56
+ root: string;
57
+ /** Marker file that was found */
58
+ foundMarker: string;
59
+ /** Distance from starting path (0 = same directory) */
60
+ depth: number;
61
+ }
62
+ /**
63
+ * Project detection rule
64
+ */
65
+ export interface ProjectDetectionRule {
66
+ type: ProjectType;
67
+ files: string[];
68
+ packageManager?: PackageManager;
69
+ priority: number;
70
+ }
71
+ /**
72
+ * Tool detection rule
73
+ */
74
+ export interface ToolDetectionRule {
75
+ /** Files that indicate this tool */
76
+ files: string[];
77
+ /** Package.json dependencies that indicate this tool */
78
+ dependencies?: string[];
79
+ /** Package.json scripts that indicate this tool */
80
+ scripts?: string[];
81
+ /** Name to return when detected */
82
+ name: string;
83
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Types for project detection tools
3
+ */
4
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Run Build Tool
3
+ * Auto-detect and run build using the appropriate tool
4
+ */
5
+ import type { Tool } from '@compilr-dev/agents';
6
+ import type { RunBuildInput } from './types.js';
7
+ /**
8
+ * Run Build Tool
9
+ */
10
+ export declare const runBuildTool: Tool<RunBuildInput>;
11
+ /**
12
+ * Factory function to create run build tool with custom options
13
+ */
14
+ export declare function createRunBuildTool(options?: {
15
+ /** Base directory for relative paths */
16
+ baseDir?: string;
17
+ /** Default timeout */
18
+ defaultTimeout?: number;
19
+ }): Tool<RunBuildInput>;
@@ -0,0 +1,306 @@
1
+ /**
2
+ * Run Build Tool
3
+ * Auto-detect and run build using the appropriate tool
4
+ */
5
+ import { defineTool, createSuccessResult, createErrorResult } from '@compilr-dev/agents';
6
+ import { isDirectory, readPackageJson, listDirectory, hasFile, hasDependency, hasScript, runCommand, buildCommand, formatCommand, DEFAULT_TIMEOUT, } from './utils.js';
7
+ const BUILD_TOOLS = [
8
+ // Vite (Node.js)
9
+ {
10
+ name: 'vite',
11
+ detect: (entries, pkg) => hasFile(entries, 'vite.config.ts') ||
12
+ hasFile(entries, 'vite.config.js') ||
13
+ hasFile(entries, 'vite.config.mjs') ||
14
+ hasDependency(pkg, 'vite'),
15
+ getCommand: (input) => {
16
+ const args = ['vite', 'build'];
17
+ if (input.production)
18
+ args.push('--mode', 'production');
19
+ return { command: 'npx', args, useNpx: false };
20
+ },
21
+ },
22
+ // Next.js
23
+ {
24
+ name: 'next',
25
+ detect: (entries, pkg) => hasFile(entries, 'next.config.js') ||
26
+ hasFile(entries, 'next.config.mjs') ||
27
+ hasFile(entries, 'next.config.ts') ||
28
+ hasDependency(pkg, 'next'),
29
+ getCommand: () => ({
30
+ command: 'npx',
31
+ args: ['next', 'build'],
32
+ useNpx: false,
33
+ }),
34
+ },
35
+ // TypeScript Compiler
36
+ {
37
+ name: 'tsc',
38
+ detect: (entries, pkg) => hasFile(entries, 'tsconfig.json') &&
39
+ (hasDependency(pkg, 'typescript') || hasScript(pkg, 'build')),
40
+ getCommand: (input) => {
41
+ const args = ['tsc'];
42
+ if (input.clean)
43
+ args.push('--build', '--clean');
44
+ return { command: 'npx', args, useNpx: false };
45
+ },
46
+ },
47
+ // Webpack
48
+ {
49
+ name: 'webpack',
50
+ detect: (entries, pkg) => hasFile(entries, 'webpack.config.js') ||
51
+ hasFile(entries, 'webpack.config.ts') ||
52
+ hasDependency(pkg, 'webpack'),
53
+ getCommand: (input) => {
54
+ const args = ['webpack'];
55
+ if (input.production)
56
+ args.push('--mode', 'production');
57
+ return { command: 'npx', args, useNpx: false };
58
+ },
59
+ },
60
+ // Rollup
61
+ {
62
+ name: 'rollup',
63
+ detect: (entries, pkg) => hasFile(entries, 'rollup.config.js') ||
64
+ hasFile(entries, 'rollup.config.mjs') ||
65
+ hasDependency(pkg, 'rollup'),
66
+ getCommand: () => ({
67
+ command: 'npx',
68
+ args: ['rollup', '-c'],
69
+ useNpx: false,
70
+ }),
71
+ },
72
+ // esbuild
73
+ {
74
+ name: 'esbuild',
75
+ detect: (entries, pkg) => hasFile(entries, 'esbuild.config.js') ||
76
+ hasFile(entries, 'esbuild.config.mjs') ||
77
+ hasDependency(pkg, 'esbuild'),
78
+ getCommand: () => ({
79
+ command: 'npx',
80
+ args: ['esbuild'],
81
+ useNpx: false,
82
+ }),
83
+ },
84
+ // Turbo (monorepo)
85
+ {
86
+ name: 'turbo',
87
+ detect: (entries, pkg) => hasFile(entries, 'turbo.json') || hasDependency(pkg, 'turbo'),
88
+ getCommand: () => ({
89
+ command: 'npx',
90
+ args: ['turbo', 'run', 'build'],
91
+ useNpx: false,
92
+ }),
93
+ },
94
+ // npm build script fallback (Node.js)
95
+ {
96
+ name: 'npm build',
97
+ detect: (_entries, pkg) => hasScript(pkg, 'build'),
98
+ getCommand: () => ({
99
+ command: 'npm',
100
+ args: ['run', 'build'],
101
+ useScript: true,
102
+ scriptName: 'build',
103
+ }),
104
+ },
105
+ // Cargo build (Rust)
106
+ {
107
+ name: 'cargo build',
108
+ detect: (entries) => hasFile(entries, 'Cargo.toml'),
109
+ getCommand: (input) => {
110
+ const args = ['build'];
111
+ if (input.production)
112
+ args.push('--release');
113
+ return { command: 'cargo', args };
114
+ },
115
+ },
116
+ // Go build
117
+ {
118
+ name: 'go build',
119
+ detect: (entries) => hasFile(entries, 'go.mod'),
120
+ getCommand: () => ({
121
+ command: 'go',
122
+ args: ['build', './...'],
123
+ }),
124
+ },
125
+ // Python setuptools
126
+ {
127
+ name: 'python build',
128
+ detect: (entries) => hasFile(entries, 'setup.py') || hasFile(entries, 'pyproject.toml'),
129
+ getCommand: () => ({
130
+ command: 'python',
131
+ args: ['-m', 'build'],
132
+ }),
133
+ },
134
+ // Maven (Java)
135
+ {
136
+ name: 'maven',
137
+ detect: (entries) => hasFile(entries, 'pom.xml'),
138
+ getCommand: (input) => {
139
+ const args = [];
140
+ if (input.clean)
141
+ args.push('clean');
142
+ args.push('package');
143
+ if (input.production)
144
+ args.push('-DskipTests');
145
+ return { command: 'mvn', args };
146
+ },
147
+ },
148
+ // Gradle (Java)
149
+ {
150
+ name: 'gradle',
151
+ detect: (entries) => hasFile(entries, 'build.gradle') || hasFile(entries, 'build.gradle.kts'),
152
+ getCommand: (input) => {
153
+ const args = [];
154
+ if (input.clean)
155
+ args.push('clean');
156
+ args.push('build');
157
+ return { command: './gradlew', args };
158
+ },
159
+ },
160
+ ];
161
+ /**
162
+ * Run Build Tool
163
+ */
164
+ export const runBuildTool = defineTool({
165
+ name: 'run_build',
166
+ description: 'Run build using the auto-detected build tool. ' +
167
+ 'Supports Vite, Next.js, TypeScript, Webpack, Rollup, esbuild, Turbo, Cargo, Go, Python, Maven, Gradle, and npm build scripts. ' +
168
+ 'Options: production (optimized build), clean (clean before build).',
169
+ inputSchema: {
170
+ type: 'object',
171
+ properties: {
172
+ path: {
173
+ type: 'string',
174
+ description: 'Working directory (default: current directory)',
175
+ },
176
+ production: {
177
+ type: 'boolean',
178
+ description: 'Build for production (optimized)',
179
+ },
180
+ clean: {
181
+ type: 'boolean',
182
+ description: 'Clean before build',
183
+ },
184
+ timeout: {
185
+ type: 'number',
186
+ description: 'Timeout in milliseconds (default: 300000)',
187
+ },
188
+ dryRun: {
189
+ type: 'boolean',
190
+ description: 'Detect build tool and return command without executing (default: false)',
191
+ },
192
+ },
193
+ required: [],
194
+ },
195
+ execute: executeRunBuild,
196
+ });
197
+ /**
198
+ * Execute run build
199
+ */
200
+ async function executeRunBuild(input) {
201
+ const targetPath = input.path ?? process.cwd();
202
+ const timeout = input.timeout ?? DEFAULT_TIMEOUT;
203
+ // Check if directory exists
204
+ if (!(await isDirectory(targetPath))) {
205
+ return createErrorResult(`Directory not found: ${targetPath}`);
206
+ }
207
+ try {
208
+ // Read directory and package.json
209
+ const entries = await listDirectory(targetPath);
210
+ const packageJson = await readPackageJson(targetPath);
211
+ // Detect build tool
212
+ let buildTool;
213
+ for (const b of BUILD_TOOLS) {
214
+ if (b.detect(entries, packageJson)) {
215
+ buildTool = b;
216
+ break;
217
+ }
218
+ }
219
+ if (!buildTool) {
220
+ return createErrorResult('No build tool detected. Supported: Vite, Next.js, TypeScript, Webpack, Rollup, esbuild, Turbo, Cargo, Go, Maven, Gradle, npm build script.');
221
+ }
222
+ // Build command
223
+ const template = buildTool.getCommand(input);
224
+ const { command, args } = buildCommand(template);
225
+ const commandString = formatCommand(command, args);
226
+ // Dry run - return detected info without executing
227
+ if (input.dryRun) {
228
+ const buildResult = {
229
+ command: commandString,
230
+ output: '(dry run - command not executed)',
231
+ exitCode: 0,
232
+ duration: 0,
233
+ success: true,
234
+ buildTool: buildTool.name,
235
+ };
236
+ return createSuccessResult(buildResult);
237
+ }
238
+ // Run build
239
+ const result = await runCommand(command, args, {
240
+ cwd: targetPath,
241
+ timeout,
242
+ env: {
243
+ NODE_ENV: input.production ? 'production' : 'development',
244
+ },
245
+ });
246
+ // Combine output
247
+ const output = [result.stdout, result.stderr].filter(Boolean).join('\n');
248
+ const buildResult = {
249
+ command: commandString,
250
+ output,
251
+ exitCode: result.exitCode,
252
+ duration: result.duration,
253
+ success: result.exitCode === 0,
254
+ buildTool: buildTool.name,
255
+ };
256
+ return createSuccessResult(buildResult);
257
+ }
258
+ catch (error) {
259
+ return createErrorResult(error instanceof Error ? error.message : String(error));
260
+ }
261
+ }
262
+ /**
263
+ * Factory function to create run build tool with custom options
264
+ */
265
+ export function createRunBuildTool(options) {
266
+ return defineTool({
267
+ name: 'run_build',
268
+ description: 'Run build using the auto-detected build tool. ' +
269
+ 'Supports Vite, Next.js, TypeScript, Webpack, Rollup, esbuild, Turbo, Cargo, Go, Maven, Gradle.',
270
+ inputSchema: {
271
+ type: 'object',
272
+ properties: {
273
+ path: {
274
+ type: 'string',
275
+ description: 'Working directory (default: current directory)',
276
+ },
277
+ production: {
278
+ type: 'boolean',
279
+ description: 'Build for production',
280
+ },
281
+ clean: {
282
+ type: 'boolean',
283
+ description: 'Clean before build',
284
+ },
285
+ timeout: {
286
+ type: 'number',
287
+ description: 'Timeout in milliseconds',
288
+ },
289
+ },
290
+ required: [],
291
+ },
292
+ execute: async (input) => {
293
+ let targetPath = input.path ?? '.';
294
+ // Resolve relative paths
295
+ if (options?.baseDir && !targetPath.startsWith('/')) {
296
+ const nodePath = await import('node:path');
297
+ targetPath = nodePath.join(options.baseDir, targetPath);
298
+ }
299
+ return executeRunBuild({
300
+ ...input,
301
+ path: targetPath,
302
+ timeout: input.timeout ?? options?.defaultTimeout,
303
+ });
304
+ },
305
+ });
306
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Run Format Tool
3
+ * Auto-detect and run formatter using the appropriate tool
4
+ */
5
+ import type { Tool } from '@compilr-dev/agents';
6
+ import type { RunFormatInput } from './types.js';
7
+ /**
8
+ * Run Format Tool
9
+ */
10
+ export declare const runFormatTool: Tool<RunFormatInput>;
11
+ /**
12
+ * Factory function to create run format tool with custom options
13
+ */
14
+ export declare function createRunFormatTool(options?: {
15
+ /** Base directory for relative paths */
16
+ baseDir?: string;
17
+ /** Default timeout */
18
+ defaultTimeout?: number;
19
+ }): Tool<RunFormatInput>;