@compilr-dev/agents-coding-go 0.1.0
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/LICENSE +21 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/parser/go-parser.d.ts +104 -0
- package/dist/parser/go-parser.d.ts.map +1 -0
- package/dist/parser/go-parser.js +492 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +5 -0
- package/dist/parser/node-types.d.ts +130 -0
- package/dist/parser/node-types.d.ts.map +1 -0
- package/dist/parser/node-types.js +4 -0
- package/dist/skills/go-best-practices.d.ts +7 -0
- package/dist/skills/go-best-practices.d.ts.map +1 -0
- package/dist/skills/go-best-practices.js +78 -0
- package/dist/skills/go-code-health.d.ts +7 -0
- package/dist/skills/go-code-health.d.ts.map +1 -0
- package/dist/skills/go-code-health.js +209 -0
- package/dist/skills/go-code-structure.d.ts +7 -0
- package/dist/skills/go-code-structure.d.ts.map +1 -0
- package/dist/skills/go-code-structure.js +155 -0
- package/dist/skills/go-dependency-audit.d.ts +7 -0
- package/dist/skills/go-dependency-audit.d.ts.map +1 -0
- package/dist/skills/go-dependency-audit.js +246 -0
- package/dist/skills/go-refactor-impact.d.ts +7 -0
- package/dist/skills/go-refactor-impact.d.ts.map +1 -0
- package/dist/skills/go-refactor-impact.js +232 -0
- package/dist/skills/index.d.ts +26 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +36 -0
- package/dist/tools/extract-docstrings.d.ts +51 -0
- package/dist/tools/extract-docstrings.d.ts.map +1 -0
- package/dist/tools/extract-docstrings.js +292 -0
- package/dist/tools/find-dead-code.d.ts +62 -0
- package/dist/tools/find-dead-code.d.ts.map +1 -0
- package/dist/tools/find-dead-code.js +422 -0
- package/dist/tools/find-duplicates.d.ts +65 -0
- package/dist/tools/find-duplicates.d.ts.map +1 -0
- package/dist/tools/find-duplicates.js +289 -0
- package/dist/tools/find-implementations.d.ts +71 -0
- package/dist/tools/find-implementations.d.ts.map +1 -0
- package/dist/tools/find-implementations.js +342 -0
- package/dist/tools/find-patterns.d.ts +71 -0
- package/dist/tools/find-patterns.d.ts.map +1 -0
- package/dist/tools/find-patterns.js +477 -0
- package/dist/tools/find-references.d.ts +66 -0
- package/dist/tools/find-references.d.ts.map +1 -0
- package/dist/tools/find-references.js +306 -0
- package/dist/tools/find-symbol.d.ts +86 -0
- package/dist/tools/find-symbol.d.ts.map +1 -0
- package/dist/tools/find-symbol.js +380 -0
- package/dist/tools/get-call-graph.d.ts +89 -0
- package/dist/tools/get-call-graph.d.ts.map +1 -0
- package/dist/tools/get-call-graph.js +431 -0
- package/dist/tools/get-class-hierarchy.d.ts +34 -0
- package/dist/tools/get-class-hierarchy.d.ts.map +1 -0
- package/dist/tools/get-class-hierarchy.js +250 -0
- package/dist/tools/get-complexity.d.ts +53 -0
- package/dist/tools/get-complexity.d.ts.map +1 -0
- package/dist/tools/get-complexity.js +357 -0
- package/dist/tools/get-dependency-graph.d.ts +85 -0
- package/dist/tools/get-dependency-graph.d.ts.map +1 -0
- package/dist/tools/get-dependency-graph.js +389 -0
- package/dist/tools/get-exports.d.ts +78 -0
- package/dist/tools/get-exports.d.ts.map +1 -0
- package/dist/tools/get-exports.js +437 -0
- package/dist/tools/get-file-structure.d.ts +28 -0
- package/dist/tools/get-file-structure.d.ts.map +1 -0
- package/dist/tools/get-file-structure.js +172 -0
- package/dist/tools/get-imports.d.ts +30 -0
- package/dist/tools/get-imports.d.ts.map +1 -0
- package/dist/tools/get-imports.js +420 -0
- package/dist/tools/get-signature.d.ts +100 -0
- package/dist/tools/get-signature.d.ts.map +1 -0
- package/dist/tools/get-signature.js +800 -0
- package/dist/tools/index.d.ts +55 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +75 -0
- package/dist/tools/types.d.ts +408 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +4 -0
- package/package.json +86 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getImports Tool
|
|
3
|
+
*
|
|
4
|
+
* Analyzes imports in Go files.
|
|
5
|
+
* Categorizes imports into stdlib, third-party, and local.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "node:fs/promises";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { defineTool, createSuccessResult, createErrorResult, } from "@compilr-dev/agents";
|
|
10
|
+
import { parseFile, parseImport, walkTree } from "../parser/go-parser.js";
|
|
11
|
+
// Go standard library packages (Go 1.21+)
|
|
12
|
+
const STDLIB_PACKAGES = new Set([
|
|
13
|
+
// Core packages
|
|
14
|
+
"archive/tar",
|
|
15
|
+
"archive/zip",
|
|
16
|
+
"bufio",
|
|
17
|
+
"bytes",
|
|
18
|
+
"cmp",
|
|
19
|
+
"compress/bzip2",
|
|
20
|
+
"compress/flate",
|
|
21
|
+
"compress/gzip",
|
|
22
|
+
"compress/lzw",
|
|
23
|
+
"compress/zlib",
|
|
24
|
+
"container/heap",
|
|
25
|
+
"container/list",
|
|
26
|
+
"container/ring",
|
|
27
|
+
"context",
|
|
28
|
+
"crypto",
|
|
29
|
+
"crypto/aes",
|
|
30
|
+
"crypto/cipher",
|
|
31
|
+
"crypto/des",
|
|
32
|
+
"crypto/dsa",
|
|
33
|
+
"crypto/ecdh",
|
|
34
|
+
"crypto/ecdsa",
|
|
35
|
+
"crypto/ed25519",
|
|
36
|
+
"crypto/elliptic",
|
|
37
|
+
"crypto/hmac",
|
|
38
|
+
"crypto/md5",
|
|
39
|
+
"crypto/rand",
|
|
40
|
+
"crypto/rc4",
|
|
41
|
+
"crypto/rsa",
|
|
42
|
+
"crypto/sha1",
|
|
43
|
+
"crypto/sha256",
|
|
44
|
+
"crypto/sha512",
|
|
45
|
+
"crypto/subtle",
|
|
46
|
+
"crypto/tls",
|
|
47
|
+
"crypto/x509",
|
|
48
|
+
"crypto/x509/pkix",
|
|
49
|
+
"database/sql",
|
|
50
|
+
"database/sql/driver",
|
|
51
|
+
"debug/buildinfo",
|
|
52
|
+
"debug/dwarf",
|
|
53
|
+
"debug/elf",
|
|
54
|
+
"debug/gosym",
|
|
55
|
+
"debug/macho",
|
|
56
|
+
"debug/pe",
|
|
57
|
+
"debug/plan9obj",
|
|
58
|
+
"embed",
|
|
59
|
+
"encoding",
|
|
60
|
+
"encoding/ascii85",
|
|
61
|
+
"encoding/asn1",
|
|
62
|
+
"encoding/base32",
|
|
63
|
+
"encoding/base64",
|
|
64
|
+
"encoding/binary",
|
|
65
|
+
"encoding/csv",
|
|
66
|
+
"encoding/gob",
|
|
67
|
+
"encoding/hex",
|
|
68
|
+
"encoding/json",
|
|
69
|
+
"encoding/pem",
|
|
70
|
+
"encoding/xml",
|
|
71
|
+
"errors",
|
|
72
|
+
"expvar",
|
|
73
|
+
"flag",
|
|
74
|
+
"fmt",
|
|
75
|
+
"go/ast",
|
|
76
|
+
"go/build",
|
|
77
|
+
"go/build/constraint",
|
|
78
|
+
"go/constant",
|
|
79
|
+
"go/doc",
|
|
80
|
+
"go/doc/comment",
|
|
81
|
+
"go/format",
|
|
82
|
+
"go/importer",
|
|
83
|
+
"go/parser",
|
|
84
|
+
"go/printer",
|
|
85
|
+
"go/scanner",
|
|
86
|
+
"go/token",
|
|
87
|
+
"go/types",
|
|
88
|
+
"hash",
|
|
89
|
+
"hash/adler32",
|
|
90
|
+
"hash/crc32",
|
|
91
|
+
"hash/crc64",
|
|
92
|
+
"hash/fnv",
|
|
93
|
+
"hash/maphash",
|
|
94
|
+
"html",
|
|
95
|
+
"html/template",
|
|
96
|
+
"image",
|
|
97
|
+
"image/color",
|
|
98
|
+
"image/color/palette",
|
|
99
|
+
"image/draw",
|
|
100
|
+
"image/gif",
|
|
101
|
+
"image/jpeg",
|
|
102
|
+
"image/png",
|
|
103
|
+
"index/suffixarray",
|
|
104
|
+
"io",
|
|
105
|
+
"io/fs",
|
|
106
|
+
"io/ioutil",
|
|
107
|
+
"iter",
|
|
108
|
+
"log",
|
|
109
|
+
"log/slog",
|
|
110
|
+
"log/syslog",
|
|
111
|
+
"maps",
|
|
112
|
+
"math",
|
|
113
|
+
"math/big",
|
|
114
|
+
"math/bits",
|
|
115
|
+
"math/cmplx",
|
|
116
|
+
"math/rand",
|
|
117
|
+
"math/rand/v2",
|
|
118
|
+
"mime",
|
|
119
|
+
"mime/multipart",
|
|
120
|
+
"mime/quotedprintable",
|
|
121
|
+
"net",
|
|
122
|
+
"net/http",
|
|
123
|
+
"net/http/cgi",
|
|
124
|
+
"net/http/cookiejar",
|
|
125
|
+
"net/http/fcgi",
|
|
126
|
+
"net/http/httptest",
|
|
127
|
+
"net/http/httptrace",
|
|
128
|
+
"net/http/httputil",
|
|
129
|
+
"net/http/pprof",
|
|
130
|
+
"net/mail",
|
|
131
|
+
"net/netip",
|
|
132
|
+
"net/rpc",
|
|
133
|
+
"net/rpc/jsonrpc",
|
|
134
|
+
"net/smtp",
|
|
135
|
+
"net/textproto",
|
|
136
|
+
"net/url",
|
|
137
|
+
"os",
|
|
138
|
+
"os/exec",
|
|
139
|
+
"os/signal",
|
|
140
|
+
"os/user",
|
|
141
|
+
"path",
|
|
142
|
+
"path/filepath",
|
|
143
|
+
"plugin",
|
|
144
|
+
"reflect",
|
|
145
|
+
"regexp",
|
|
146
|
+
"regexp/syntax",
|
|
147
|
+
"runtime",
|
|
148
|
+
"runtime/cgo",
|
|
149
|
+
"runtime/coverage",
|
|
150
|
+
"runtime/debug",
|
|
151
|
+
"runtime/metrics",
|
|
152
|
+
"runtime/pprof",
|
|
153
|
+
"runtime/race",
|
|
154
|
+
"runtime/trace",
|
|
155
|
+
"slices",
|
|
156
|
+
"sort",
|
|
157
|
+
"strconv",
|
|
158
|
+
"strings",
|
|
159
|
+
"structs",
|
|
160
|
+
"sync",
|
|
161
|
+
"sync/atomic",
|
|
162
|
+
"syscall",
|
|
163
|
+
"testing",
|
|
164
|
+
"testing/fstest",
|
|
165
|
+
"testing/iotest",
|
|
166
|
+
"testing/quick",
|
|
167
|
+
"testing/slogtest",
|
|
168
|
+
"text/scanner",
|
|
169
|
+
"text/tabwriter",
|
|
170
|
+
"text/template",
|
|
171
|
+
"text/template/parse",
|
|
172
|
+
"time",
|
|
173
|
+
"time/tzdata",
|
|
174
|
+
"unicode",
|
|
175
|
+
"unicode/utf16",
|
|
176
|
+
"unicode/utf8",
|
|
177
|
+
"unique",
|
|
178
|
+
"unsafe",
|
|
179
|
+
]);
|
|
180
|
+
// Tool description
|
|
181
|
+
const TOOL_DESCRIPTION = `Analyze imports in Go files.
|
|
182
|
+
Returns categorized imports (stdlib, third_party, local) with statistics.
|
|
183
|
+
Helps understand dependencies and import organization.`;
|
|
184
|
+
// Tool input schema
|
|
185
|
+
const TOOL_INPUT_SCHEMA = {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: {
|
|
188
|
+
path: {
|
|
189
|
+
type: "string",
|
|
190
|
+
description: "Path to Go file or directory",
|
|
191
|
+
},
|
|
192
|
+
filterModule: {
|
|
193
|
+
type: "string",
|
|
194
|
+
description: "Filter to show only imports matching this prefix",
|
|
195
|
+
},
|
|
196
|
+
recursive: {
|
|
197
|
+
type: "boolean",
|
|
198
|
+
description: "Recursively scan directories (default: false)",
|
|
199
|
+
default: false,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
required: ["path"],
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* getImports tool - Analyze Go imports
|
|
206
|
+
*/
|
|
207
|
+
export const getImportsTool = defineTool({
|
|
208
|
+
name: "get_imports_go",
|
|
209
|
+
description: TOOL_DESCRIPTION,
|
|
210
|
+
inputSchema: TOOL_INPUT_SCHEMA,
|
|
211
|
+
execute: executeGetImports,
|
|
212
|
+
});
|
|
213
|
+
/**
|
|
214
|
+
* Execute the getImports tool
|
|
215
|
+
*/
|
|
216
|
+
async function executeGetImports(input) {
|
|
217
|
+
const { path: inputPath, filterModule, recursive = false } = input;
|
|
218
|
+
// Validate input
|
|
219
|
+
if (!inputPath) {
|
|
220
|
+
return createErrorResult("Path is required");
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
// Check if path exists
|
|
224
|
+
const stats = await fs.stat(inputPath);
|
|
225
|
+
if (stats.isFile()) {
|
|
226
|
+
// Analyze single file
|
|
227
|
+
const result = await analyzeFileImports(inputPath, filterModule);
|
|
228
|
+
return createSuccessResult(result);
|
|
229
|
+
}
|
|
230
|
+
else if (stats.isDirectory()) {
|
|
231
|
+
// Analyze directory
|
|
232
|
+
if (recursive) {
|
|
233
|
+
const results = await analyzeDirectoryImports(inputPath, filterModule);
|
|
234
|
+
return createSuccessResult(results);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// Just analyze .go files in this directory
|
|
238
|
+
const entries = await fs.readdir(inputPath, { withFileTypes: true });
|
|
239
|
+
const goFiles = entries
|
|
240
|
+
.filter((e) => e.isFile() && e.name.endsWith(".go"))
|
|
241
|
+
.map((e) => path.join(inputPath, e.name));
|
|
242
|
+
if (goFiles.length === 0) {
|
|
243
|
+
return createErrorResult(`No Go files found in: ${inputPath}`);
|
|
244
|
+
}
|
|
245
|
+
// Combine results from all files
|
|
246
|
+
const allImports = [];
|
|
247
|
+
let stdlibCount = 0;
|
|
248
|
+
let thirdPartyCount = 0;
|
|
249
|
+
let localCount = 0;
|
|
250
|
+
for (const filePath of goFiles) {
|
|
251
|
+
const result = await analyzeFileImports(filePath, filterModule);
|
|
252
|
+
allImports.push(...result.imports);
|
|
253
|
+
stdlibCount += result.stats.stdlib;
|
|
254
|
+
thirdPartyCount += result.stats.thirdParty;
|
|
255
|
+
localCount += result.stats.local;
|
|
256
|
+
}
|
|
257
|
+
// Deduplicate imports
|
|
258
|
+
const uniqueImports = deduplicateImports(allImports);
|
|
259
|
+
return createSuccessResult({
|
|
260
|
+
path: inputPath,
|
|
261
|
+
imports: uniqueImports,
|
|
262
|
+
stats: {
|
|
263
|
+
total: uniqueImports.length,
|
|
264
|
+
stdlib: stdlibCount,
|
|
265
|
+
thirdParty: thirdPartyCount,
|
|
266
|
+
local: localCount,
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
return createErrorResult(`Path is neither a file nor directory: ${inputPath}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
277
|
+
return createErrorResult(`Failed to analyze imports: ${message}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Analyze imports in a single Go file
|
|
282
|
+
*/
|
|
283
|
+
async function analyzeFileImports(filePath, filterModule) {
|
|
284
|
+
const parseResult = await parseFile(filePath);
|
|
285
|
+
const { tree, source } = parseResult;
|
|
286
|
+
const rootNode = tree.rootNode;
|
|
287
|
+
const imports = [];
|
|
288
|
+
let stdlibCount = 0;
|
|
289
|
+
let thirdPartyCount = 0;
|
|
290
|
+
let localCount = 0;
|
|
291
|
+
// Look for import declarations
|
|
292
|
+
for (const node of walkTree(rootNode, ["import_declaration"])) {
|
|
293
|
+
const importInfos = parseImport(node, source);
|
|
294
|
+
for (const importInfo of importInfos) {
|
|
295
|
+
const category = categorizeImport(importInfo.module);
|
|
296
|
+
// Apply filter if specified
|
|
297
|
+
if (filterModule && !importInfo.module.startsWith(filterModule)) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const categorizedImport = {
|
|
301
|
+
...importInfo,
|
|
302
|
+
category,
|
|
303
|
+
};
|
|
304
|
+
imports.push(categorizedImport);
|
|
305
|
+
switch (category) {
|
|
306
|
+
case "stdlib":
|
|
307
|
+
stdlibCount++;
|
|
308
|
+
break;
|
|
309
|
+
case "third_party":
|
|
310
|
+
thirdPartyCount++;
|
|
311
|
+
break;
|
|
312
|
+
case "local":
|
|
313
|
+
localCount++;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
path: filePath,
|
|
320
|
+
imports,
|
|
321
|
+
stats: {
|
|
322
|
+
total: imports.length,
|
|
323
|
+
stdlib: stdlibCount,
|
|
324
|
+
thirdParty: thirdPartyCount,
|
|
325
|
+
local: localCount,
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Analyze imports in a directory recursively
|
|
331
|
+
*/
|
|
332
|
+
async function analyzeDirectoryImports(dir, filterModule) {
|
|
333
|
+
const allImports = [];
|
|
334
|
+
let stdlibCount = 0;
|
|
335
|
+
let thirdPartyCount = 0;
|
|
336
|
+
let localCount = 0;
|
|
337
|
+
async function walk(currentDir) {
|
|
338
|
+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
339
|
+
for (const entry of entries) {
|
|
340
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
341
|
+
if (entry.isDirectory()) {
|
|
342
|
+
// Skip vendor, testdata, and hidden directories
|
|
343
|
+
if (entry.name === "vendor" ||
|
|
344
|
+
entry.name === "testdata" ||
|
|
345
|
+
entry.name.startsWith(".")) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
await walk(fullPath);
|
|
349
|
+
}
|
|
350
|
+
else if (entry.isFile() && entry.name.endsWith(".go")) {
|
|
351
|
+
const result = await analyzeFileImports(fullPath, filterModule);
|
|
352
|
+
allImports.push(...result.imports);
|
|
353
|
+
stdlibCount += result.stats.stdlib;
|
|
354
|
+
thirdPartyCount += result.stats.thirdParty;
|
|
355
|
+
localCount += result.stats.local;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
await walk(dir);
|
|
360
|
+
// Deduplicate imports
|
|
361
|
+
const uniqueImports = deduplicateImports(allImports);
|
|
362
|
+
return {
|
|
363
|
+
path: dir,
|
|
364
|
+
imports: uniqueImports,
|
|
365
|
+
stats: {
|
|
366
|
+
total: uniqueImports.length,
|
|
367
|
+
stdlib: stdlibCount,
|
|
368
|
+
thirdParty: thirdPartyCount,
|
|
369
|
+
local: localCount,
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Categorize an import path
|
|
375
|
+
*/
|
|
376
|
+
function categorizeImport(importPath) {
|
|
377
|
+
// Standard library doesn't have dots in the first segment
|
|
378
|
+
const firstSegment = importPath.split("/")[0];
|
|
379
|
+
// Check if it's a known stdlib package
|
|
380
|
+
if (STDLIB_PACKAGES.has(importPath)) {
|
|
381
|
+
return "stdlib";
|
|
382
|
+
}
|
|
383
|
+
// Standard library packages don't have dots (no domain)
|
|
384
|
+
if (!firstSegment.includes(".")) {
|
|
385
|
+
return "stdlib";
|
|
386
|
+
}
|
|
387
|
+
// If it starts with the current module path, it's local
|
|
388
|
+
// (This would require parsing go.mod, simplified here)
|
|
389
|
+
// Everything else is third-party
|
|
390
|
+
return "third_party";
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Deduplicate imports by module path
|
|
394
|
+
*/
|
|
395
|
+
function deduplicateImports(imports) {
|
|
396
|
+
const seen = new Map();
|
|
397
|
+
for (const imp of imports) {
|
|
398
|
+
if (!seen.has(imp.module)) {
|
|
399
|
+
seen.set(imp.module, imp);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return Array.from(seen.values());
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Factory function to create a customized getImports tool
|
|
406
|
+
*/
|
|
407
|
+
export function createGetImportsTool(options) {
|
|
408
|
+
const { defaultRecursive = false } = options ?? {};
|
|
409
|
+
return defineTool({
|
|
410
|
+
name: "get_imports_go",
|
|
411
|
+
description: TOOL_DESCRIPTION,
|
|
412
|
+
inputSchema: TOOL_INPUT_SCHEMA,
|
|
413
|
+
execute: async (input) => {
|
|
414
|
+
return executeGetImports({
|
|
415
|
+
...input,
|
|
416
|
+
recursive: input.recursive ?? defaultRecursive,
|
|
417
|
+
});
|
|
418
|
+
},
|
|
419
|
+
});
|
|
420
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getSignature Tool
|
|
3
|
+
*
|
|
4
|
+
* Get detailed signature information for a function, method, or class in Go code.
|
|
5
|
+
* Includes parameters, type hints, decorators, and docstrings.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tool } from "@compilr-dev/agents";
|
|
8
|
+
/**
|
|
9
|
+
* Python symbol kinds
|
|
10
|
+
*/
|
|
11
|
+
export type PythonSymbolKind = "function" | "async_function" | "method" | "class" | "variable";
|
|
12
|
+
/**
|
|
13
|
+
* Parameter detail
|
|
14
|
+
*/
|
|
15
|
+
export interface ParameterDetail {
|
|
16
|
+
name: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
optional: boolean;
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
isKwOnly?: boolean;
|
|
22
|
+
isPosOnly?: boolean;
|
|
23
|
+
isVarArgs?: boolean;
|
|
24
|
+
isKwArgs?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Return type detail
|
|
28
|
+
*/
|
|
29
|
+
export interface ReturnTypeDetail {
|
|
30
|
+
type: string;
|
|
31
|
+
isCoroutine?: boolean;
|
|
32
|
+
nullable?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Member signature (for class members)
|
|
36
|
+
*/
|
|
37
|
+
export interface MemberSignature {
|
|
38
|
+
name: string;
|
|
39
|
+
kind: "method" | "property" | "class_variable";
|
|
40
|
+
signature: string;
|
|
41
|
+
async?: boolean;
|
|
42
|
+
static?: boolean;
|
|
43
|
+
classmethod?: boolean;
|
|
44
|
+
decorators?: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Documentation extracted from docstrings
|
|
48
|
+
*/
|
|
49
|
+
export interface Documentation {
|
|
50
|
+
summary: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
params?: Record<string, string>;
|
|
53
|
+
returns?: string;
|
|
54
|
+
raises?: string[];
|
|
55
|
+
examples?: string[];
|
|
56
|
+
notes?: string;
|
|
57
|
+
deprecated?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Input for getSignature tool
|
|
61
|
+
*/
|
|
62
|
+
export interface GetSignatureInput {
|
|
63
|
+
/** File containing the symbol */
|
|
64
|
+
path: string;
|
|
65
|
+
/** Symbol name to get signature for */
|
|
66
|
+
name: string;
|
|
67
|
+
/** Line number for disambiguation (optional) */
|
|
68
|
+
line?: number;
|
|
69
|
+
/** Include full documentation (default: true) */
|
|
70
|
+
includeDoc?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Result of getSignature
|
|
74
|
+
*/
|
|
75
|
+
export interface GetSignatureResult {
|
|
76
|
+
name: string;
|
|
77
|
+
path: string;
|
|
78
|
+
kind: PythonSymbolKind;
|
|
79
|
+
line: number;
|
|
80
|
+
signature: string;
|
|
81
|
+
formattedSignature: string;
|
|
82
|
+
parameters?: ParameterDetail[];
|
|
83
|
+
returnType?: ReturnTypeDetail;
|
|
84
|
+
decorators?: string[];
|
|
85
|
+
documentation?: Documentation;
|
|
86
|
+
bases?: string[];
|
|
87
|
+
members?: MemberSignature[];
|
|
88
|
+
async?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* getSignature tool
|
|
92
|
+
*/
|
|
93
|
+
export declare const getSignatureTool: Tool<GetSignatureInput>;
|
|
94
|
+
/**
|
|
95
|
+
* Factory function to create a customized getSignature tool
|
|
96
|
+
*/
|
|
97
|
+
export declare function createGetSignatureTool(options?: {
|
|
98
|
+
defaultIncludeDoc?: boolean;
|
|
99
|
+
}): Tool<GetSignatureInput>;
|
|
100
|
+
//# sourceMappingURL=get-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-signature.d.ts","sourceRoot":"","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