@compilr-dev/agents-coding-ts 0.1.2 → 0.1.4

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 (49) hide show
  1. package/dist/index.d.ts +8 -5
  2. package/dist/index.js +14 -4
  3. package/dist/parser/index.d.ts +2 -2
  4. package/dist/parser/index.js +1 -1
  5. package/dist/parser/typescript-parser.d.ts +2 -2
  6. package/dist/parser/typescript-parser.js +77 -54
  7. package/dist/skills/code-health.js +18 -5
  8. package/dist/skills/code-structure.js +15 -5
  9. package/dist/skills/dependency-audit.js +16 -5
  10. package/dist/skills/index.d.ts +7 -7
  11. package/dist/skills/index.js +11 -11
  12. package/dist/skills/refactor-impact.js +16 -5
  13. package/dist/skills/type-analysis.js +16 -5
  14. package/dist/tools/find-dead-code.d.ts +2 -2
  15. package/dist/tools/find-dead-code.js +82 -58
  16. package/dist/tools/find-duplicates.d.ts +2 -2
  17. package/dist/tools/find-duplicates.js +41 -38
  18. package/dist/tools/find-implementations.d.ts +2 -2
  19. package/dist/tools/find-implementations.js +44 -36
  20. package/dist/tools/find-patterns.d.ts +2 -2
  21. package/dist/tools/find-patterns.js +154 -148
  22. package/dist/tools/find-references.d.ts +2 -2
  23. package/dist/tools/find-references.js +76 -72
  24. package/dist/tools/find-symbol.d.ts +2 -2
  25. package/dist/tools/find-symbol.js +106 -96
  26. package/dist/tools/get-call-graph.d.ts +2 -2
  27. package/dist/tools/get-call-graph.js +52 -47
  28. package/dist/tools/get-complexity.d.ts +2 -2
  29. package/dist/tools/get-complexity.js +94 -46
  30. package/dist/tools/get-dependency-graph.d.ts +2 -2
  31. package/dist/tools/get-dependency-graph.js +66 -52
  32. package/dist/tools/get-documentation.d.ts +2 -2
  33. package/dist/tools/get-documentation.js +154 -122
  34. package/dist/tools/get-exports.d.ts +2 -2
  35. package/dist/tools/get-exports.js +73 -61
  36. package/dist/tools/get-file-structure.d.ts +2 -2
  37. package/dist/tools/get-file-structure.js +16 -16
  38. package/dist/tools/get-imports.d.ts +2 -2
  39. package/dist/tools/get-imports.js +46 -46
  40. package/dist/tools/get-signature.d.ts +2 -2
  41. package/dist/tools/get-signature.js +168 -124
  42. package/dist/tools/get-type-hierarchy.d.ts +2 -2
  43. package/dist/tools/get-type-hierarchy.js +53 -44
  44. package/dist/tools/index.d.ts +18 -16
  45. package/dist/tools/index.js +17 -15
  46. package/dist/tools/read-symbol.d.ts +62 -0
  47. package/dist/tools/read-symbol.js +464 -0
  48. package/dist/tools/types.d.ts +27 -27
  49. package/package.json +3 -3
@@ -4,8 +4,8 @@
4
4
  * Analyze the inheritance hierarchy of a class or interface.
5
5
  * Shows ancestors (parents) and descendants (children) in the type tree.
6
6
  */
7
- import type { Tool } from '@compilr-dev/agents';
8
- import type { GetTypeHierarchyInput, HierarchyDirection } from './types.js';
7
+ import type { Tool } from "@compilr-dev/agents";
8
+ import type { GetTypeHierarchyInput, HierarchyDirection } from "./types.js";
9
9
  /**
10
10
  * getTypeHierarchy tool - Analyze type inheritance
11
11
  */
@@ -4,53 +4,58 @@
4
4
  * Analyze the inheritance hierarchy of a class or interface.
5
5
  * Shows ancestors (parents) and descendants (children) in the type tree.
6
6
  */
7
- import * as fs from 'node:fs/promises';
8
- import * as path from 'node:path';
9
- import * as ts from 'typescript';
10
- import { defineTool, createSuccessResult, createErrorResult } from '@compilr-dev/agents';
11
- import { detectLanguage, isLanguageSupported } from '../parser/typescript-parser.js';
7
+ import * as fs from "node:fs/promises";
8
+ import * as path from "node:path";
9
+ import * as ts from "typescript";
10
+ import { defineTool, createSuccessResult, createErrorResult, } from "@compilr-dev/agents";
11
+ import { detectLanguage, isLanguageSupported, } from "../parser/typescript-parser.js";
12
12
  // Tool description
13
13
  const TOOL_DESCRIPTION = `Analyze the inheritance hierarchy of a class or interface.
14
14
  Returns the type's ancestors (what it extends/implements) and descendants (what extends/implements it).
15
15
  Useful for understanding class hierarchies and interface relationships.`;
16
16
  // Tool input schema
17
17
  const TOOL_INPUT_SCHEMA = {
18
- type: 'object',
18
+ type: "object",
19
19
  properties: {
20
20
  name: {
21
- type: 'string',
22
- description: 'Class or interface name to analyze',
21
+ type: "string",
22
+ description: "Class or interface name to analyze",
23
23
  },
24
24
  file: {
25
- type: 'string',
26
- description: 'File where the type is defined (improves accuracy)',
25
+ type: "string",
26
+ description: "File where the type is defined (improves accuracy)",
27
27
  },
28
28
  direction: {
29
- type: 'string',
30
- enum: ['ancestors', 'descendants', 'both'],
29
+ type: "string",
30
+ enum: ["ancestors", "descendants", "both"],
31
31
  description: 'Direction: "ancestors" | "descendants" | "both" (default: "both")',
32
- default: 'both',
32
+ default: "both",
33
33
  },
34
34
  maxDepth: {
35
- type: 'number',
36
- description: 'Maximum depth to traverse (default: 5)',
35
+ type: "number",
36
+ description: "Maximum depth to traverse (default: 5)",
37
37
  default: 5,
38
38
  },
39
39
  scope: {
40
- type: 'string',
41
- description: 'Scope directory for searching descendants (default: current directory)',
40
+ type: "string",
41
+ description: "Scope directory for searching descendants (default: current directory)",
42
42
  },
43
43
  },
44
- required: ['name'],
44
+ required: ["name"],
45
45
  };
46
46
  // Default file patterns
47
- const DEFAULT_INCLUDE = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'];
48
- const DEFAULT_EXCLUDE = ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.git/**'];
47
+ const DEFAULT_INCLUDE = ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"];
48
+ const DEFAULT_EXCLUDE = [
49
+ "**/node_modules/**",
50
+ "**/dist/**",
51
+ "**/build/**",
52
+ "**/.git/**",
53
+ ];
49
54
  /**
50
55
  * getTypeHierarchy tool - Analyze type inheritance
51
56
  */
52
57
  export const getTypeHierarchyTool = defineTool({
53
- name: 'get_type_hierarchy',
58
+ name: "get_type_hierarchy",
54
59
  description: TOOL_DESCRIPTION,
55
60
  inputSchema: TOOL_INPUT_SCHEMA,
56
61
  execute: executeGetTypeHierarchy,
@@ -59,10 +64,10 @@ export const getTypeHierarchyTool = defineTool({
59
64
  * Execute the getTypeHierarchy tool
60
65
  */
61
66
  async function executeGetTypeHierarchy(input) {
62
- const { name, file, direction = 'both', maxDepth = 5, scope = '.' } = input;
67
+ const { name, file, direction = "both", maxDepth = 5, scope = "." } = input;
63
68
  // Validate input
64
69
  if (!name || name.trim().length === 0) {
65
- return createErrorResult('Type name is required');
70
+ return createErrorResult("Type name is required");
66
71
  }
67
72
  try {
68
73
  // Resolve scope path
@@ -116,9 +121,9 @@ async function executeGetTypeHierarchy(input) {
116
121
  // Return empty result if type not found
117
122
  const emptyRoot = {
118
123
  name,
119
- path: '',
124
+ path: "",
120
125
  line: 0,
121
- kind: 'class',
126
+ kind: "class",
122
127
  exported: false,
123
128
  };
124
129
  const result = {
@@ -136,13 +141,13 @@ async function executeGetTypeHierarchy(input) {
136
141
  const allTypes = [];
137
142
  let maxDepthReached = 0;
138
143
  const rootNode = createTypeNode(targetType);
139
- if (direction === 'ancestors' || direction === 'both') {
144
+ if (direction === "ancestors" || direction === "both") {
140
145
  const { ancestors, depth } = buildAncestors(targetType, typeMap, maxDepth, 0);
141
146
  rootNode.parents = ancestors;
142
147
  if (depth > maxDepthReached)
143
148
  maxDepthReached = depth;
144
149
  }
145
- if (direction === 'descendants' || direction === 'both') {
150
+ if (direction === "descendants" || direction === "both") {
146
151
  const { descendants, depth } = buildDescendants(targetType, typeMap, maxDepth, 0);
147
152
  rootNode.children = descendants;
148
153
  if (depth > maxDepthReached)
@@ -213,9 +218,9 @@ function buildAncestors(type, typeMap, maxDepth, currentDepth) {
213
218
  // External type (not found in codebase)
214
219
  ancestors.push({
215
220
  name: parentName,
216
- path: '',
221
+ path: "",
217
222
  line: 0,
218
- kind: 'interface', // Assume interface for unknown types
223
+ kind: "interface", // Assume interface for unknown types
219
224
  exported: true,
220
225
  });
221
226
  }
@@ -285,7 +290,7 @@ function collectAllTypes(node, allTypes) {
285
290
  */
286
291
  async function extractTypeInfo(filePath) {
287
292
  try {
288
- const content = await fs.readFile(filePath, 'utf-8');
293
+ const content = await fs.readFile(filePath, "utf-8");
289
294
  const detection = detectLanguage(filePath);
290
295
  if (!detection.language) {
291
296
  return [];
@@ -293,7 +298,7 @@ async function extractTypeInfo(filePath) {
293
298
  if (!isLanguageSupported(detection.language)) {
294
299
  return [];
295
300
  }
296
- const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, filePath.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
301
+ const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
297
302
  const types = [];
298
303
  const visit = (node) => {
299
304
  // Class declarations
@@ -330,8 +335,10 @@ function extractClassInfo(node, sourceFile, filePath) {
330
335
  if (!node.name)
331
336
  return null;
332
337
  const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
333
- const isExported = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
334
- const isAbstract = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.AbstractKeyword) ?? false;
338
+ const isExported = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ??
339
+ false;
340
+ const isAbstract = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.AbstractKeyword) ??
341
+ false;
335
342
  const extendsTypes = [];
336
343
  const implementsTypes = [];
337
344
  if (node.heritageClauses) {
@@ -352,7 +359,7 @@ function extractClassInfo(node, sourceFile, filePath) {
352
359
  name: node.name.text,
353
360
  path: filePath,
354
361
  line: line + 1,
355
- kind: 'class',
362
+ kind: "class",
356
363
  isAbstract,
357
364
  exported: isExported,
358
365
  extends: extendsTypes.length > 0 ? extendsTypes : undefined,
@@ -364,7 +371,8 @@ function extractClassInfo(node, sourceFile, filePath) {
364
371
  */
365
372
  function extractInterfaceInfo(node, sourceFile, filePath) {
366
373
  const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
367
- const isExported = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
374
+ const isExported = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ??
375
+ false;
368
376
  const extendsTypes = [];
369
377
  if (node.heritageClauses) {
370
378
  for (const clause of node.heritageClauses) {
@@ -379,7 +387,7 @@ function extractInterfaceInfo(node, sourceFile, filePath) {
379
387
  name: node.name.text,
380
388
  path: filePath,
381
389
  line: line + 1,
382
- kind: 'interface',
390
+ kind: "interface",
383
391
  exported: isExported,
384
392
  extends: extendsTypes.length > 0 ? extendsTypes : undefined,
385
393
  };
@@ -389,7 +397,8 @@ function extractInterfaceInfo(node, sourceFile, filePath) {
389
397
  */
390
398
  function extractTypeAliasInfo(node, sourceFile, filePath) {
391
399
  const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
392
- const isExported = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
400
+ const isExported = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ??
401
+ false;
393
402
  // Extract types from intersection type
394
403
  const extendsTypes = [];
395
404
  if (ts.isIntersectionTypeNode(node.type)) {
@@ -411,7 +420,7 @@ function extractTypeAliasInfo(node, sourceFile, filePath) {
411
420
  name: node.name.text,
412
421
  path: filePath,
413
422
  line: line + 1,
414
- kind: 'type',
423
+ kind: "type",
415
424
  exported: isExported,
416
425
  extends: extendsTypes,
417
426
  };
@@ -432,9 +441,9 @@ async function collectFiles(dirPath, include, exclude, maxDepth, maxFiles, curre
432
441
  const relativePath = fullPath;
433
442
  // Check exclusions
434
443
  const isExcluded = exclude.some((pattern) => {
435
- if (pattern.includes('**')) {
436
- const simplePattern = pattern.replace(/\*\*/g, '');
437
- return relativePath.includes(simplePattern.replace(/\*/g, ''));
444
+ if (pattern.includes("**")) {
445
+ const simplePattern = pattern.replace(/\*\*/g, "");
446
+ return relativePath.includes(simplePattern.replace(/\*/g, ""));
438
447
  }
439
448
  return entry.name === pattern || relativePath.includes(pattern);
440
449
  });
@@ -447,8 +456,8 @@ async function collectFiles(dirPath, include, exclude, maxDepth, maxFiles, curre
447
456
  else if (entry.isFile()) {
448
457
  // Check if file matches include patterns
449
458
  const isIncluded = include.some((pattern) => {
450
- if (pattern.includes('*')) {
451
- const ext = pattern.replace('**/', '').replace('*', '');
459
+ if (pattern.includes("*")) {
460
+ const ext = pattern.replace("**/", "").replace("*", "");
452
461
  return entry.name.endsWith(ext);
453
462
  }
454
463
  return entry.name === pattern;
@@ -469,7 +478,7 @@ async function collectFiles(dirPath, include, exclude, maxDepth, maxFiles, curre
469
478
  */
470
479
  export function createGetTypeHierarchyTool(options) {
471
480
  return defineTool({
472
- name: options?.name ?? 'get_type_hierarchy',
481
+ name: options?.name ?? "get_type_hierarchy",
473
482
  description: options?.description ?? TOOL_DESCRIPTION,
474
483
  inputSchema: TOOL_INPUT_SCHEMA,
475
484
  execute: async (input) => {
@@ -5,19 +5,21 @@
5
5
  * These tools reduce token usage by returning structured JSON
6
6
  * instead of requiring the agent to read and reason through raw code.
7
7
  */
8
- export { getFileStructureTool, createGetFileStructureTool } from './get-file-structure.js';
9
- export { findSymbolTool, createFindSymbolTool } from './find-symbol.js';
10
- export { findReferencesTool, createFindReferencesTool } from './find-references.js';
11
- export { getImportsTool, createGetImportsTool } from './get-imports.js';
12
- export { getExportsTool, createGetExportsTool } from './get-exports.js';
13
- export { getCallGraphTool, createGetCallGraphTool } from './get-call-graph.js';
14
- export { getDependencyGraphTool, createGetDependencyGraphTool } from './get-dependency-graph.js';
15
- export { findImplementationsTool, createFindImplementationsTool } from './find-implementations.js';
16
- export { getTypeHierarchyTool, createGetTypeHierarchyTool } from './get-type-hierarchy.js';
17
- export { getComplexityTool, createGetComplexityTool } from './get-complexity.js';
18
- export { findDeadCodeTool, createFindDeadCodeTool } from './find-dead-code.js';
19
- export { findDuplicatesTool, createFindDuplicatesTool } from './find-duplicates.js';
20
- export { findPatternsTool, createFindPatternsTool } from './find-patterns.js';
21
- export { getSignatureTool, createGetSignatureTool } from './get-signature.js';
22
- export { getDocumentationTool, createGetDocumentationTool } from './get-documentation.js';
23
- export type { SupportedLanguage, ParameterInfo, GetFileStructureInput, FileStructure, ImportInfo, ExportInfo, ClassInfo, FunctionInfo, MethodInfo, PropertyInfo, VariableInfo, TypeDefinitionInfo, FileStats, SymbolKind, SymbolKindFilter, FindSymbolInput, FindSymbolResult, SymbolDefinition, SearchStats, ReferenceType, FindReferencesInput, FindReferencesResult, Reference, FileReferences, GetImportsInput, GetImportsResult, DetailedImport, ImportedSymbol, TransitiveImport, ImportStats, GetExportsInput, GetExportsResult, ExportedSymbol, ExportKind, ReExport, ExportStats, CallGraphDirection, CallType, GetCallGraphInput, GetCallGraphResult, FunctionNode, CallInfo, CallGraphNode, CallGraphStats, GetDependencyGraphInput, GetDependencyGraphResult, ModuleNode, DependencyEdge, CircularDependency, DependencyGraphStats, FindImplementationsInput, FindImplementationsResult, ImplementationInfo, HierarchyDirection, GetTypeHierarchyInput, GetTypeHierarchyResult, TypeHierarchyNode, GetComplexityInput, GetComplexityResult, FileComplexity, FunctionComplexity, ComplexityContributor, ComplexityContributorType, FindDeadCodeInput, FindDeadCodeResult, DeadCodeItem, FindDuplicatesInput, FindDuplicatesResult, DuplicateGroup, CodeLocation, FindPatternsInput, FindPatternsResult, PatternMatch, CodePattern, GetSignatureInput, GetSignatureResult, ParameterDetail, TypeDetail, GenericDetail, Documentation, MemberSignature, SignatureSymbolKind, GetDocumentationInput, GetDocumentationResult, FileDocumentation, DocumentedSymbol, DocumentationSymbolKind, ExtractorOptions, } from './types.js';
8
+ export { getFileStructureTool, createGetFileStructureTool, } from "./get-file-structure.js";
9
+ export { findSymbolTool, createFindSymbolTool } from "./find-symbol.js";
10
+ export { findReferencesTool, createFindReferencesTool, } from "./find-references.js";
11
+ export { getImportsTool, createGetImportsTool } from "./get-imports.js";
12
+ export { getExportsTool, createGetExportsTool } from "./get-exports.js";
13
+ export { getCallGraphTool, createGetCallGraphTool } from "./get-call-graph.js";
14
+ export { getDependencyGraphTool, createGetDependencyGraphTool, } from "./get-dependency-graph.js";
15
+ export { findImplementationsTool, createFindImplementationsTool, } from "./find-implementations.js";
16
+ export { getTypeHierarchyTool, createGetTypeHierarchyTool, } from "./get-type-hierarchy.js";
17
+ export { getComplexityTool, createGetComplexityTool, } from "./get-complexity.js";
18
+ export { findDeadCodeTool, createFindDeadCodeTool } from "./find-dead-code.js";
19
+ export { findDuplicatesTool, createFindDuplicatesTool, } from "./find-duplicates.js";
20
+ export { findPatternsTool, createFindPatternsTool } from "./find-patterns.js";
21
+ export { getSignatureTool, createGetSignatureTool } from "./get-signature.js";
22
+ export { getDocumentationTool, createGetDocumentationTool, } from "./get-documentation.js";
23
+ export { readFunctionTool, readClassTool, readTypeTool, createReadFunctionTool, createReadClassTool, createReadTypeTool, } from "./read-symbol.js";
24
+ export type { SupportedLanguage, ParameterInfo, GetFileStructureInput, FileStructure, ImportInfo, ExportInfo, ClassInfo, FunctionInfo, MethodInfo, PropertyInfo, VariableInfo, TypeDefinitionInfo, FileStats, SymbolKind, SymbolKindFilter, FindSymbolInput, FindSymbolResult, SymbolDefinition, SearchStats, ReferenceType, FindReferencesInput, FindReferencesResult, Reference, FileReferences, GetImportsInput, GetImportsResult, DetailedImport, ImportedSymbol, TransitiveImport, ImportStats, GetExportsInput, GetExportsResult, ExportedSymbol, ExportKind, ReExport, ExportStats, CallGraphDirection, CallType, GetCallGraphInput, GetCallGraphResult, FunctionNode, CallInfo, CallGraphNode, CallGraphStats, GetDependencyGraphInput, GetDependencyGraphResult, ModuleNode, DependencyEdge, CircularDependency, DependencyGraphStats, FindImplementationsInput, FindImplementationsResult, ImplementationInfo, HierarchyDirection, GetTypeHierarchyInput, GetTypeHierarchyResult, TypeHierarchyNode, GetComplexityInput, GetComplexityResult, FileComplexity, FunctionComplexity, ComplexityContributor, ComplexityContributorType, FindDeadCodeInput, FindDeadCodeResult, DeadCodeItem, FindDuplicatesInput, FindDuplicatesResult, DuplicateGroup, CodeLocation, FindPatternsInput, FindPatternsResult, PatternMatch, CodePattern, GetSignatureInput, GetSignatureResult, ParameterDetail, TypeDetail, GenericDetail, Documentation, MemberSignature, SignatureSymbolKind, GetDocumentationInput, GetDocumentationResult, FileDocumentation, DocumentedSymbol, DocumentationSymbolKind, ExtractorOptions, } from "./types.js";
25
+ export type { ReadFunctionInput, ReadClassInput, ReadTypeInput, ReadSymbolResult, } from "./read-symbol.js";
@@ -6,20 +6,22 @@
6
6
  * instead of requiring the agent to read and reason through raw code.
7
7
  */
8
8
  // Tier 1 & 2 Tools
9
- export { getFileStructureTool, createGetFileStructureTool } from './get-file-structure.js';
10
- export { findSymbolTool, createFindSymbolTool } from './find-symbol.js';
11
- export { findReferencesTool, createFindReferencesTool } from './find-references.js';
12
- export { getImportsTool, createGetImportsTool } from './get-imports.js';
13
- export { getExportsTool, createGetExportsTool } from './get-exports.js';
14
- export { getCallGraphTool, createGetCallGraphTool } from './get-call-graph.js';
15
- export { getDependencyGraphTool, createGetDependencyGraphTool } from './get-dependency-graph.js';
16
- export { findImplementationsTool, createFindImplementationsTool } from './find-implementations.js';
17
- export { getTypeHierarchyTool, createGetTypeHierarchyTool } from './get-type-hierarchy.js';
9
+ export { getFileStructureTool, createGetFileStructureTool, } from "./get-file-structure.js";
10
+ export { findSymbolTool, createFindSymbolTool } from "./find-symbol.js";
11
+ export { findReferencesTool, createFindReferencesTool, } from "./find-references.js";
12
+ export { getImportsTool, createGetImportsTool } from "./get-imports.js";
13
+ export { getExportsTool, createGetExportsTool } from "./get-exports.js";
14
+ export { getCallGraphTool, createGetCallGraphTool } from "./get-call-graph.js";
15
+ export { getDependencyGraphTool, createGetDependencyGraphTool, } from "./get-dependency-graph.js";
16
+ export { findImplementationsTool, createFindImplementationsTool, } from "./find-implementations.js";
17
+ export { getTypeHierarchyTool, createGetTypeHierarchyTool, } from "./get-type-hierarchy.js";
18
18
  // Tier 3 Tools
19
- export { getComplexityTool, createGetComplexityTool } from './get-complexity.js';
20
- export { findDeadCodeTool, createFindDeadCodeTool } from './find-dead-code.js';
21
- export { findDuplicatesTool, createFindDuplicatesTool } from './find-duplicates.js';
22
- export { findPatternsTool, createFindPatternsTool } from './find-patterns.js';
19
+ export { getComplexityTool, createGetComplexityTool, } from "./get-complexity.js";
20
+ export { findDeadCodeTool, createFindDeadCodeTool } from "./find-dead-code.js";
21
+ export { findDuplicatesTool, createFindDuplicatesTool, } from "./find-duplicates.js";
22
+ export { findPatternsTool, createFindPatternsTool } from "./find-patterns.js";
23
23
  // Tier 4 Utility Tools
24
- export { getSignatureTool, createGetSignatureTool } from './get-signature.js';
25
- export { getDocumentationTool, createGetDocumentationTool } from './get-documentation.js';
24
+ export { getSignatureTool, createGetSignatureTool } from "./get-signature.js";
25
+ export { getDocumentationTool, createGetDocumentationTool, } from "./get-documentation.js";
26
+ // Smart File Reading Tools (token-efficient code extraction)
27
+ export { readFunctionTool, readClassTool, readTypeTool, createReadFunctionTool, createReadClassTool, createReadTypeTool, } from "./read-symbol.js";
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Smart File Reading Tools
3
+ *
4
+ * AST-aware tools that extract specific code elements by name,
5
+ * returning exact source code without guessing line numbers.
6
+ *
7
+ * Tools:
8
+ * - read_function: Read a function/method by name
9
+ * - read_class: Read a class by name
10
+ * - read_type: Read a type/interface by name
11
+ */
12
+ import type { Tool } from "@compilr-dev/agents";
13
+ export interface ReadFunctionInput {
14
+ /** Absolute path to the file */
15
+ path: string;
16
+ /** Function or method name to read */
17
+ name: string;
18
+ /** Class name if reading a method (optional) */
19
+ className?: string;
20
+ /** Include JSDoc comment (default: true) */
21
+ includeJsDoc?: boolean;
22
+ }
23
+ export interface ReadClassInput {
24
+ /** Absolute path to the file */
25
+ path: string;
26
+ /** Class name to read */
27
+ name: string;
28
+ /** What to include: 'full' | 'signature' | 'methods-only' | 'properties-only' */
29
+ include?: "full" | "signature" | "methods-only" | "properties-only";
30
+ /** Include JSDoc comment (default: true) */
31
+ includeJsDoc?: boolean;
32
+ }
33
+ export interface ReadTypeInput {
34
+ /** Absolute path to the file */
35
+ path: string;
36
+ /** Type or interface name to read */
37
+ name: string;
38
+ /** Include JSDoc comment (default: true) */
39
+ includeJsDoc?: boolean;
40
+ }
41
+ export interface ReadSymbolResult {
42
+ /** Symbol name */
43
+ name: string;
44
+ /** Symbol kind */
45
+ kind: "function" | "method" | "class" | "interface" | "type" | "enum";
46
+ /** Start line (1-based) */
47
+ startLine: number;
48
+ /** End line (1-based) */
49
+ endLine: number;
50
+ /** Source code content */
51
+ content: string;
52
+ /** Signature (for functions/methods/classes) */
53
+ signature?: string;
54
+ /** Containing class (for methods) */
55
+ container?: string;
56
+ }
57
+ export declare const readFunctionTool: Tool<ReadFunctionInput>;
58
+ export declare const readClassTool: Tool<ReadClassInput>;
59
+ export declare const readTypeTool: Tool<ReadTypeInput>;
60
+ export declare function createReadFunctionTool(): Tool<ReadFunctionInput>;
61
+ export declare function createReadClassTool(): Tool<ReadClassInput>;
62
+ export declare function createReadTypeTool(): Tool<ReadTypeInput>;