@side-quest/kit 0.0.0 → 0.2.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.
Files changed (127) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +54 -352
  3. package/dist/cli.d.ts +14 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +156 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/index.d.ts +8 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +8 -2509
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/ast/index.d.ts +11 -0
  12. package/dist/lib/ast/index.d.ts.map +1 -0
  13. package/dist/lib/ast/index.js +15 -0
  14. package/dist/lib/ast/index.js.map +1 -0
  15. package/dist/lib/ast/languages.d.ts +55 -0
  16. package/dist/lib/ast/languages.d.ts.map +1 -0
  17. package/dist/lib/ast/languages.js +146 -0
  18. package/dist/lib/ast/languages.js.map +1 -0
  19. package/dist/lib/ast/pattern.d.ts +84 -0
  20. package/dist/lib/ast/pattern.d.ts.map +1 -0
  21. package/dist/lib/ast/pattern.js +268 -0
  22. package/dist/lib/ast/pattern.js.map +1 -0
  23. package/dist/lib/ast/searcher.d.ts +89 -0
  24. package/dist/lib/ast/searcher.d.ts.map +1 -0
  25. package/dist/lib/ast/searcher.js +316 -0
  26. package/dist/lib/ast/searcher.js.map +1 -0
  27. package/dist/lib/ast/types.d.ts +93 -0
  28. package/dist/lib/ast/types.d.ts.map +1 -0
  29. package/dist/lib/ast/types.js +23 -0
  30. package/dist/lib/ast/types.js.map +1 -0
  31. package/dist/lib/commands/callers.d.ts +20 -0
  32. package/dist/lib/commands/callers.d.ts.map +1 -0
  33. package/dist/lib/commands/callers.js +162 -0
  34. package/dist/lib/commands/callers.js.map +1 -0
  35. package/dist/lib/commands/find.d.ts +15 -0
  36. package/dist/lib/commands/find.d.ts.map +1 -0
  37. package/dist/lib/commands/find.js +113 -0
  38. package/dist/lib/commands/find.js.map +1 -0
  39. package/dist/lib/commands/overview.d.ts +6 -0
  40. package/dist/lib/commands/overview.d.ts.map +1 -0
  41. package/dist/lib/commands/overview.js +52 -0
  42. package/dist/lib/commands/overview.js.map +1 -0
  43. package/dist/lib/commands/prime.d.ts +16 -0
  44. package/dist/lib/commands/prime.d.ts.map +1 -0
  45. package/dist/lib/commands/prime.js +168 -0
  46. package/dist/lib/commands/prime.js.map +1 -0
  47. package/dist/lib/commands/search.d.ts +20 -0
  48. package/dist/lib/commands/search.d.ts.map +1 -0
  49. package/dist/lib/commands/search.js +111 -0
  50. package/dist/lib/commands/search.js.map +1 -0
  51. package/dist/lib/errors.d.ts +80 -0
  52. package/dist/lib/errors.d.ts.map +1 -0
  53. package/dist/lib/errors.js +189 -0
  54. package/dist/lib/errors.js.map +1 -0
  55. package/dist/lib/formatters/output.d.ts +5 -0
  56. package/dist/lib/formatters/output.d.ts.map +1 -0
  57. package/dist/lib/formatters/output.js +5 -0
  58. package/dist/lib/formatters/output.js.map +1 -0
  59. package/dist/lib/formatters.d.ts +29 -0
  60. package/dist/lib/formatters.d.ts.map +1 -0
  61. package/dist/lib/formatters.js +141 -0
  62. package/dist/lib/formatters.js.map +1 -0
  63. package/dist/lib/index-tools.d.ts +108 -0
  64. package/dist/lib/index-tools.d.ts.map +1 -0
  65. package/dist/lib/index-tools.js +311 -0
  66. package/dist/lib/index-tools.js.map +1 -0
  67. package/dist/lib/index.d.ts +21 -0
  68. package/dist/lib/index.d.ts.map +1 -0
  69. package/dist/lib/index.js +42 -0
  70. package/dist/lib/index.js.map +1 -0
  71. package/dist/lib/kit-wrapper.d.ts +70 -0
  72. package/dist/lib/kit-wrapper.d.ts.map +1 -0
  73. package/dist/lib/kit-wrapper.js +462 -0
  74. package/dist/lib/kit-wrapper.js.map +1 -0
  75. package/dist/lib/logger.d.ts +28 -0
  76. package/dist/lib/logger.d.ts.map +1 -0
  77. package/dist/lib/logger.js +39 -0
  78. package/dist/lib/logger.js.map +1 -0
  79. package/dist/lib/types.d.ts +179 -0
  80. package/dist/lib/types.d.ts.map +1 -0
  81. package/dist/lib/types.js +48 -0
  82. package/dist/lib/types.js.map +1 -0
  83. package/dist/lib/utils/args.d.ts +40 -0
  84. package/dist/lib/utils/args.d.ts.map +1 -0
  85. package/dist/lib/utils/args.js +58 -0
  86. package/dist/lib/utils/args.js.map +1 -0
  87. package/dist/lib/utils/git.d.ts +23 -0
  88. package/dist/lib/utils/git.d.ts.map +1 -0
  89. package/dist/lib/utils/git.js +50 -0
  90. package/dist/lib/utils/git.js.map +1 -0
  91. package/dist/lib/utils/index-parser.d.ts +155 -0
  92. package/dist/lib/utils/index-parser.d.ts.map +1 -0
  93. package/dist/lib/utils/index-parser.js +252 -0
  94. package/dist/lib/utils/index-parser.js.map +1 -0
  95. package/dist/lib/validators.d.ts +138 -0
  96. package/dist/lib/validators.d.ts.map +1 -0
  97. package/dist/lib/validators.js +302 -0
  98. package/dist/lib/validators.js.map +1 -0
  99. package/dist/mcp/index.d.ts +19 -0
  100. package/dist/mcp/index.d.ts.map +1 -0
  101. package/dist/mcp/index.js +769 -0
  102. package/dist/mcp/index.js.map +1 -0
  103. package/package.json +5 -2
  104. package/src/cli.ts +170 -0
  105. package/src/lib/ast/index.ts +32 -0
  106. package/src/lib/ast/languages.ts +172 -0
  107. package/src/lib/ast/pattern.ts +299 -0
  108. package/src/lib/ast/searcher.ts +381 -0
  109. package/src/lib/ast/types.ts +99 -0
  110. package/src/lib/commands/callers.ts +226 -0
  111. package/src/lib/commands/find.ts +159 -0
  112. package/src/lib/commands/overview.ts +73 -0
  113. package/src/lib/commands/prime.ts +271 -0
  114. package/src/lib/commands/search.ts +146 -0
  115. package/src/lib/errors.ts +221 -0
  116. package/src/lib/formatters/output.ts +9 -0
  117. package/src/lib/formatters.ts +189 -0
  118. package/src/lib/index-tools.ts +471 -0
  119. package/src/lib/index.ts +122 -0
  120. package/src/lib/kit-wrapper.ts +675 -0
  121. package/src/lib/logger.ts +57 -0
  122. package/src/lib/types.ts +228 -0
  123. package/src/lib/utils/args.ts +72 -0
  124. package/src/lib/utils/git.ts +65 -0
  125. package/src/lib/utils/index-parser.ts +350 -0
  126. package/src/lib/validators.ts +437 -0
  127. package/src/mcp/index.ts +144 -79
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * AST Module
3
+ *
4
+ * Tree-sitter powered AST search for code analysis.
5
+ * Provides pattern-based search across TypeScript, JavaScript, and Python files.
6
+ */
7
+ export { detectLanguage, getParser, getSupportedGlob, initParser, isSupported, LANGUAGES, SUPPORTED_LANGUAGES, type SupportedLanguage, } from './languages.js';
8
+ export { ASTPattern } from './pattern.js';
9
+ export { ASTSearcher } from './searcher.js';
10
+ export { AST_SEARCH_TIMEOUT, type ASTMatch, type ASTMatchContext, type ASTSearchOptions, type ASTSearchResult, type PatternCriteria, SearchMode, } from './types.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACN,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,KAAK,iBAAiB,GACtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EACN,kBAAkB,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,UAAU,GACV,MAAM,YAAY,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * AST Module
3
+ *
4
+ * Tree-sitter powered AST search for code analysis.
5
+ * Provides pattern-based search across TypeScript, JavaScript, and Python files.
6
+ */
7
+ // Language utilities
8
+ export { detectLanguage, getParser, getSupportedGlob, initParser, isSupported, LANGUAGES, SUPPORTED_LANGUAGES, } from './languages.js';
9
+ // Pattern matching
10
+ export { ASTPattern } from './pattern.js';
11
+ // Search engine
12
+ export { ASTSearcher } from './searcher.js';
13
+ // Types
14
+ export { AST_SEARCH_TIMEOUT, SearchMode, } from './types.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/ast/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAqB;AACrB,OAAO,EACN,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,SAAS,EACT,mBAAmB,GAEnB,MAAM,gBAAgB,CAAA;AACvB,mBAAmB;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,QAAQ;AACR,OAAO,EACN,kBAAkB,EAMlB,UAAU,GACV,MAAM,YAAY,CAAA"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Language Registry
3
+ *
4
+ * Maps file extensions to tree-sitter languages and provides
5
+ * lazy-loaded parser instances using WASM grammars.
6
+ */
7
+ import { type Node, Parser } from 'web-tree-sitter';
8
+ /**
9
+ * File extension to tree-sitter language mapping.
10
+ * Ported from Kit's LANGUAGES dict in tree_sitter_symbol_extractor.py
11
+ */
12
+ export declare const LANGUAGES: Record<string, string>;
13
+ /**
14
+ * Languages we support for AST search.
15
+ */
16
+ export declare const SUPPORTED_LANGUAGES: readonly ["typescript", "tsx", "javascript", "python"];
17
+ export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
18
+ /**
19
+ * Initialize the tree-sitter parser.
20
+ * Must be called before any parsing operations.
21
+ */
22
+ export declare function initParser(): Promise<void>;
23
+ /**
24
+ * Get a parser configured for a specific language.
25
+ *
26
+ * Each language gets its own dedicated parser instance to avoid race conditions
27
+ * when concurrent requests for different languages would otherwise swap the
28
+ * language on a shared parser mid-parse.
29
+ *
30
+ * @param language - The language name (e.g., "typescript")
31
+ * @returns Configured parser instance for this language
32
+ */
33
+ export declare function getParser(language: SupportedLanguage): Promise<Parser>;
34
+ /**
35
+ * Detect language from file path by extension.
36
+ *
37
+ * @param filePath - Path to the file
38
+ * @returns Language name or null if unsupported
39
+ */
40
+ export declare function detectLanguage(filePath: string): SupportedLanguage | null;
41
+ /**
42
+ * Check if a file is supported for AST parsing.
43
+ *
44
+ * @param filePath - Path to the file
45
+ * @returns True if the file can be parsed
46
+ */
47
+ export declare function isSupported(filePath: string): boolean;
48
+ /**
49
+ * Get all supported file extensions as a glob pattern.
50
+ *
51
+ * @returns Glob pattern matching all supported files
52
+ */
53
+ export declare function getSupportedGlob(): string;
54
+ export type { Node as SyntaxNode };
55
+ //# sourceMappingURL=languages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/languages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAM7D;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAU5C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,wDAKtB,CAAA;AAEV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;AAQpE;;;GAGG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBhD;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAc5E;AAkCD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAYzE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAGzC;AAID,YAAY,EAAE,IAAI,IAAI,UAAU,EAAE,CAAA"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Language Registry
3
+ *
4
+ * Maps file extensions to tree-sitter languages and provides
5
+ * lazy-loaded parser instances using WASM grammars.
6
+ */
7
+ import { createRequire } from 'node:module';
8
+ import { ResourcePool } from '@side-quest/core/concurrency';
9
+ import { Language, Parser } from 'web-tree-sitter';
10
+ import { getAstLogger } from '../logger.js';
11
+ // Create require for resolving WASM paths
12
+ const require = createRequire(import.meta.url);
13
+ /**
14
+ * File extension to tree-sitter language mapping.
15
+ * Ported from Kit's LANGUAGES dict in tree_sitter_symbol_extractor.py
16
+ */
17
+ export const LANGUAGES = {
18
+ '.ts': 'typescript',
19
+ '.tsx': 'tsx',
20
+ '.mts': 'typescript',
21
+ '.cts': 'typescript',
22
+ '.js': 'javascript',
23
+ '.jsx': 'javascript',
24
+ '.mjs': 'javascript',
25
+ '.cjs': 'javascript',
26
+ '.py': 'python',
27
+ };
28
+ /**
29
+ * Languages we support for AST search.
30
+ */
31
+ export const SUPPORTED_LANGUAGES = [
32
+ 'typescript',
33
+ 'tsx',
34
+ 'javascript',
35
+ 'python',
36
+ ];
37
+ // Resource pools for cached instances
38
+ const languagePool = new ResourcePool();
39
+ const parserPool = new ResourcePool();
40
+ let initialized = false;
41
+ /**
42
+ * Initialize the tree-sitter parser.
43
+ * Must be called before any parsing operations.
44
+ */
45
+ export async function initParser() {
46
+ if (initialized)
47
+ return;
48
+ const logger = getAstLogger();
49
+ logger.debug('Initializing tree-sitter parser');
50
+ try {
51
+ await Parser.init();
52
+ initialized = true;
53
+ logger.debug('Tree-sitter parser initialized successfully');
54
+ }
55
+ catch (error) {
56
+ logger.error('Failed to initialize tree-sitter parser', {
57
+ error: error instanceof Error ? error.message : String(error),
58
+ });
59
+ throw error;
60
+ }
61
+ }
62
+ /**
63
+ * Get a parser configured for a specific language.
64
+ *
65
+ * Each language gets its own dedicated parser instance to avoid race conditions
66
+ * when concurrent requests for different languages would otherwise swap the
67
+ * language on a shared parser mid-parse.
68
+ *
69
+ * @param language - The language name (e.g., "typescript")
70
+ * @returns Configured parser instance for this language
71
+ */
72
+ export async function getParser(language) {
73
+ await initParser();
74
+ const logger = getAstLogger();
75
+ return parserPool.getOrCreate(language, async (lang) => {
76
+ logger.debug('Creating new parser for language', { language: lang });
77
+ const parser = new Parser();
78
+ const grammar = await loadLanguage(lang);
79
+ parser.setLanguage(grammar);
80
+ return parser;
81
+ });
82
+ }
83
+ /**
84
+ * Load a language grammar from WASM.
85
+ *
86
+ * @param language - The language name
87
+ * @returns Loaded language instance
88
+ */
89
+ async function loadLanguage(language) {
90
+ const logger = getAstLogger();
91
+ return languagePool.getOrCreate(language, async (lang) => {
92
+ logger.debug('Loading language grammar from WASM', { language: lang });
93
+ try {
94
+ const wasmPath = require.resolve(`tree-sitter-wasms/out/tree-sitter-${lang}.wasm`);
95
+ const grammar = await Language.load(wasmPath);
96
+ logger.debug('Language grammar loaded successfully', {
97
+ language: lang,
98
+ wasmPath,
99
+ });
100
+ return grammar;
101
+ }
102
+ catch (error) {
103
+ logger.error('Failed to load language grammar', {
104
+ language: lang,
105
+ error: error instanceof Error ? error.message : String(error),
106
+ });
107
+ throw error;
108
+ }
109
+ });
110
+ }
111
+ /**
112
+ * Detect language from file path by extension.
113
+ *
114
+ * @param filePath - Path to the file
115
+ * @returns Language name or null if unsupported
116
+ */
117
+ export function detectLanguage(filePath) {
118
+ const lastDot = filePath.lastIndexOf('.');
119
+ if (lastDot === -1)
120
+ return null;
121
+ const ext = filePath.substring(lastDot).toLowerCase();
122
+ const language = LANGUAGES[ext];
123
+ if (language && SUPPORTED_LANGUAGES.includes(language)) {
124
+ return language;
125
+ }
126
+ return null;
127
+ }
128
+ /**
129
+ * Check if a file is supported for AST parsing.
130
+ *
131
+ * @param filePath - Path to the file
132
+ * @returns True if the file can be parsed
133
+ */
134
+ export function isSupported(filePath) {
135
+ return detectLanguage(filePath) !== null;
136
+ }
137
+ /**
138
+ * Get all supported file extensions as a glob pattern.
139
+ *
140
+ * @returns Glob pattern matching all supported files
141
+ */
142
+ export function getSupportedGlob() {
143
+ const extensions = Object.keys(LANGUAGES).map((ext) => ext.slice(1));
144
+ return `**/*.{${extensions.join(',')}}`;
145
+ }
146
+ //# sourceMappingURL=languages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.js","sourceRoot":"","sources":["../../../src/lib/ast/languages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAa,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,0CAA0C;AAC1C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAA2B;IAChD,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,QAAQ;CACf,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,YAAY;IACZ,KAAK;IACL,YAAY;IACZ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,GAAG,CAAC,CAAA;IAE/B,IAAI,QAAQ,IAAI,mBAAmB,CAAC,QAAQ,CAAC,QAA6B,CAAC,EAAE,CAAC;QAC7E,OAAO,QAA6B,CAAA;IACrC,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC3C,OAAO,cAAc,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACpE,OAAO,SAAS,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;AACxC,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * AST Pattern
3
+ *
4
+ * Compiles and matches AST search patterns against tree-sitter nodes.
5
+ * Ported from Kit's ASTPattern class in ast_search.py.
6
+ */
7
+ import type { SyntaxNode } from './languages.js';
8
+ import { SearchMode } from './types.js';
9
+ /**
10
+ * ASTPattern compiles search patterns and matches them against AST nodes.
11
+ *
12
+ * Supports two modes:
13
+ * - `simple`: Natural language patterns like "async function", "class"
14
+ * - `pattern`: JSON object criteria like {"type": "function_declaration"}
15
+ */
16
+ export declare class ASTPattern {
17
+ readonly pattern: string;
18
+ readonly mode: SearchMode;
19
+ private isAsync;
20
+ private isDef;
21
+ private isClass;
22
+ private isTry;
23
+ private isImport;
24
+ private isExport;
25
+ private criteria;
26
+ /**
27
+ * Create a new AST pattern.
28
+ *
29
+ * @param pattern - The search pattern string
30
+ * @param mode - The search mode (simple or pattern)
31
+ */
32
+ constructor(pattern: string, mode?: SearchMode);
33
+ /**
34
+ * Compile the pattern based on mode.
35
+ */
36
+ private compile;
37
+ /**
38
+ * Compile simple mode pattern from natural language.
39
+ * Parses keywords like "async", "function", "class", etc.
40
+ */
41
+ private compileSimple;
42
+ /**
43
+ * Compile pattern mode from JSON criteria.
44
+ */
45
+ private compilePattern;
46
+ /**
47
+ * Check if a node matches this pattern.
48
+ *
49
+ * @param node - The tree-sitter syntax node
50
+ * @param source - The source code string
51
+ * @returns True if the node matches
52
+ */
53
+ matches(node: SyntaxNode, source: string): boolean;
54
+ /**
55
+ * Match a node against simple mode pattern.
56
+ */
57
+ private matchesSimple;
58
+ /**
59
+ * Match a node against pattern mode criteria.
60
+ */
61
+ private matchesPattern;
62
+ /**
63
+ * Check if a node type is a function node.
64
+ */
65
+ private isFunctionNode;
66
+ /**
67
+ * Check if a node type is a class node.
68
+ */
69
+ private isClassNode;
70
+ /**
71
+ * Check if a node has an async modifier.
72
+ * Works for both direct 'async' child and keyword in text.
73
+ */
74
+ private hasAsyncModifier;
75
+ /**
76
+ * Get the name of a named node (function, class, etc.)
77
+ */
78
+ private getNodeName;
79
+ /**
80
+ * Get the text content of a node.
81
+ */
82
+ private getNodeText;
83
+ }
84
+ //# sourceMappingURL=pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/pattern.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAwB,UAAU,EAAE,MAAM,YAAY,CAAA;AAkC7D;;;;;;GAMG;AACH,qBAAa,UAAU;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IAGzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAQ;IAGxB,OAAO,CAAC,QAAQ,CAAsB;IAEtC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,UAA8B;IAMjE;;OAEG;IACH,OAAO,CAAC,OAAO;IAQf;;;OAGG;IACH,OAAO,CAAC,aAAa;IA4BrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAetB;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IASlD;;OAEG;IACH,OAAO,CAAC,aAAa;IAmCrB;;OAEG;IACH,OAAO,CAAC,cAAc;IA0CtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAsBnB;;OAEG;IACH,OAAO,CAAC,WAAW;CAGnB"}
@@ -0,0 +1,268 @@
1
+ /**
2
+ * AST Pattern
3
+ *
4
+ * Compiles and matches AST search patterns against tree-sitter nodes.
5
+ * Ported from Kit's ASTPattern class in ast_search.py.
6
+ */
7
+ import { getAstLogger } from '../logger.js';
8
+ import { SearchMode } from './types.js';
9
+ /**
10
+ * Node types that represent function definitions across languages.
11
+ */
12
+ const FUNCTION_NODE_TYPES = [
13
+ // TypeScript/JavaScript
14
+ 'function_declaration',
15
+ 'function_expression',
16
+ 'arrow_function',
17
+ 'method_definition',
18
+ 'generator_function_declaration',
19
+ // Python
20
+ 'function_definition',
21
+ ];
22
+ /**
23
+ * Node types that represent class definitions across languages.
24
+ */
25
+ const CLASS_NODE_TYPES = [
26
+ // TypeScript/JavaScript
27
+ 'class_declaration',
28
+ 'class_expression',
29
+ // Python
30
+ 'class_definition',
31
+ ];
32
+ /**
33
+ * Node types that represent try/catch statements.
34
+ */
35
+ const TRY_NODE_TYPES = [
36
+ 'try_statement', // TypeScript/JavaScript and Python
37
+ ];
38
+ /**
39
+ * ASTPattern compiles search patterns and matches them against AST nodes.
40
+ *
41
+ * Supports two modes:
42
+ * - `simple`: Natural language patterns like "async function", "class"
43
+ * - `pattern`: JSON object criteria like {"type": "function_declaration"}
44
+ */
45
+ export class ASTPattern {
46
+ pattern;
47
+ mode;
48
+ // Simple mode flags (parsed from natural language)
49
+ isAsync = false;
50
+ isDef = false;
51
+ isClass = false;
52
+ isTry = false;
53
+ isImport = false;
54
+ isExport = false;
55
+ // Pattern mode criteria (parsed from JSON)
56
+ criteria = {};
57
+ /**
58
+ * Create a new AST pattern.
59
+ *
60
+ * @param pattern - The search pattern string
61
+ * @param mode - The search mode (simple or pattern)
62
+ */
63
+ constructor(pattern, mode = SearchMode.SIMPLE) {
64
+ this.pattern = pattern;
65
+ this.mode = mode;
66
+ this.compile();
67
+ }
68
+ /**
69
+ * Compile the pattern based on mode.
70
+ */
71
+ compile() {
72
+ if (this.mode === SearchMode.SIMPLE) {
73
+ this.compileSimple();
74
+ }
75
+ else if (this.mode === SearchMode.PATTERN) {
76
+ this.compilePattern();
77
+ }
78
+ }
79
+ /**
80
+ * Compile simple mode pattern from natural language.
81
+ * Parses keywords like "async", "function", "class", etc.
82
+ */
83
+ compileSimple() {
84
+ const lower = this.pattern.toLowerCase();
85
+ // Check for keywords
86
+ this.isAsync = lower.includes('async');
87
+ this.isDef =
88
+ lower.includes('function') ||
89
+ lower.includes('def') ||
90
+ lower.includes('method');
91
+ this.isClass = lower.includes('class');
92
+ this.isTry = lower.includes('try') || lower.includes('catch');
93
+ this.isImport = lower.includes('import');
94
+ this.isExport = lower.includes('export');
95
+ // If no specific keywords matched, treat as text search
96
+ if (!this.isAsync &&
97
+ !this.isDef &&
98
+ !this.isClass &&
99
+ !this.isTry &&
100
+ !this.isImport &&
101
+ !this.isExport) {
102
+ // Fall back to text matching mode
103
+ this.criteria = { textMatch: this.pattern };
104
+ }
105
+ }
106
+ /**
107
+ * Compile pattern mode from JSON criteria.
108
+ */
109
+ compilePattern() {
110
+ try {
111
+ this.criteria = JSON.parse(this.pattern);
112
+ }
113
+ catch (error) {
114
+ // If JSON parsing fails, treat as text match
115
+ // Log at debug level since this is often intentional (user typed plain text)
116
+ const logger = getAstLogger();
117
+ logger.debug('Pattern JSON parse failed, using text match fallback', {
118
+ pattern: this.pattern,
119
+ error: error instanceof Error ? error.message : String(error),
120
+ });
121
+ this.criteria = { textMatch: this.pattern };
122
+ }
123
+ }
124
+ /**
125
+ * Check if a node matches this pattern.
126
+ *
127
+ * @param node - The tree-sitter syntax node
128
+ * @param source - The source code string
129
+ * @returns True if the node matches
130
+ */
131
+ matches(node, source) {
132
+ if (this.mode === SearchMode.SIMPLE) {
133
+ return this.matchesSimple(node, source);
134
+ }
135
+ else if (this.mode === SearchMode.PATTERN) {
136
+ return this.matchesPattern(node, source);
137
+ }
138
+ return false;
139
+ }
140
+ /**
141
+ * Match a node against simple mode pattern.
142
+ */
143
+ matchesSimple(node, source) {
144
+ const nodeType = node.type;
145
+ // If we're looking for specific constructs
146
+ if (this.isDef ||
147
+ this.isClass ||
148
+ this.isTry ||
149
+ this.isImport ||
150
+ this.isExport) {
151
+ // Check construct type
152
+ if (this.isDef && !this.isFunctionNode(nodeType))
153
+ return false;
154
+ if (this.isClass && !this.isClassNode(nodeType))
155
+ return false;
156
+ if (this.isTry && !TRY_NODE_TYPES.includes(nodeType))
157
+ return false;
158
+ if (this.isImport && !nodeType.includes('import'))
159
+ return false;
160
+ if (this.isExport && !nodeType.includes('export'))
161
+ return false;
162
+ // Check async modifier (only for functions)
163
+ if (this.isAsync && this.isDef) {
164
+ if (!this.hasAsyncModifier(node))
165
+ return false;
166
+ }
167
+ return true;
168
+ }
169
+ // Text match fallback
170
+ if (this.criteria.textMatch) {
171
+ const text = this.getNodeText(node, source);
172
+ return text.includes(this.criteria.textMatch);
173
+ }
174
+ return false;
175
+ }
176
+ /**
177
+ * Match a node against pattern mode criteria.
178
+ */
179
+ matchesPattern(node, source) {
180
+ // Match node type
181
+ if (this.criteria.type && node.type !== this.criteria.type) {
182
+ return false;
183
+ }
184
+ // Match async modifier
185
+ if (this.criteria.async !== undefined) {
186
+ if (this.hasAsyncModifier(node) !== this.criteria.async) {
187
+ return false;
188
+ }
189
+ }
190
+ // Match symbol name
191
+ if (this.criteria.name) {
192
+ const name = this.getNodeName(node, source);
193
+ if (name !== this.criteria.name) {
194
+ return false;
195
+ }
196
+ }
197
+ // Match text content
198
+ if (this.criteria.textMatch) {
199
+ const text = this.getNodeText(node, source);
200
+ if (!text.includes(this.criteria.textMatch)) {
201
+ return false;
202
+ }
203
+ }
204
+ // If no criteria specified, don't match anything
205
+ if (!this.criteria.type &&
206
+ !this.criteria.async &&
207
+ !this.criteria.name &&
208
+ !this.criteria.textMatch) {
209
+ return false;
210
+ }
211
+ return true;
212
+ }
213
+ /**
214
+ * Check if a node type is a function node.
215
+ */
216
+ isFunctionNode(type) {
217
+ return FUNCTION_NODE_TYPES.includes(type);
218
+ }
219
+ /**
220
+ * Check if a node type is a class node.
221
+ */
222
+ isClassNode(type) {
223
+ return CLASS_NODE_TYPES.includes(type);
224
+ }
225
+ /**
226
+ * Check if a node has an async modifier.
227
+ * Works for both direct 'async' child and keyword in text.
228
+ */
229
+ hasAsyncModifier(node) {
230
+ // Check for 'async' child node (TypeScript/JavaScript)
231
+ for (const child of node.children) {
232
+ if (child && child.type === 'async')
233
+ return true;
234
+ }
235
+ // Check for async keyword in first few characters
236
+ // This handles cases where async is part of the node text
237
+ const firstPart = node.text?.slice(0, 10) ?? '';
238
+ return firstPart.includes('async');
239
+ }
240
+ /**
241
+ * Get the name of a named node (function, class, etc.)
242
+ */
243
+ getNodeName(node, source) {
244
+ // Look for identifier or name child
245
+ for (const child of node.children) {
246
+ if (!child)
247
+ continue;
248
+ if (child.type === 'identifier' ||
249
+ child.type === 'type_identifier' ||
250
+ child.type === 'property_identifier') {
251
+ return source.substring(child.startIndex, child.endIndex);
252
+ }
253
+ }
254
+ // Check named children
255
+ const nameChild = node.childForFieldName('name');
256
+ if (nameChild) {
257
+ return source.substring(nameChild.startIndex, nameChild.endIndex);
258
+ }
259
+ return undefined;
260
+ }
261
+ /**
262
+ * Get the text content of a node.
263
+ */
264
+ getNodeText(node, source) {
265
+ return source.substring(node.startIndex, node.endIndex);
266
+ }
267
+ }
268
+ //# sourceMappingURL=pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../../src/lib/ast/pattern.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAwB,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7D;;GAEG;AACH,MAAM,mBAAmB,GAAG;IAC3B,wBAAwB;IACxB,sBAAsB;IACtB,qBAAqB;IACrB,gBAAgB;IAChB,mBAAmB;IACnB,gCAAgC;IAChC,SAAS;IACT,qBAAqB;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACxB,wBAAwB;IACxB,mBAAmB;IACnB,kBAAkB;IAClB,SAAS;IACT,kBAAkB;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,cAAc,GAAG;IACtB,eAAe,EAAE,mCAAmC;CACpD,CAAA;AAED;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IACb,OAAO,CAAQ;IACf,IAAI,CAAY;IAEzB,mDAAmD;IAC3C,OAAO,GAAG,KAAK,CAAA;IACf,KAAK,GAAG,KAAK,CAAA;IACb,OAAO,GAAG,KAAK,CAAA;IACf,KAAK,GAAG,KAAK,CAAA;IACb,QAAQ,GAAG,KAAK,CAAA;IAChB,QAAQ,GAAG,KAAK,CAAA;IAExB,2CAA2C;IACnC,QAAQ,GAAoB,EAAE,CAAA;IAEtC;;;;;OAKG;IACH,YAAY,OAAe,EAAE,OAAmB,UAAU,CAAC,MAAM;QAChE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CA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