skrypt-ai 0.7.0 → 0.8.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 (110) hide show
  1. package/dist/auth/index.js +3 -3
  2. package/dist/cli.js +1 -1
  3. package/dist/commands/cron.js +0 -4
  4. package/dist/commands/generate/index.d.ts +3 -0
  5. package/dist/commands/generate/index.js +393 -0
  6. package/dist/commands/generate/scan.d.ts +41 -0
  7. package/dist/commands/generate/scan.js +256 -0
  8. package/dist/commands/generate/verify.d.ts +14 -0
  9. package/dist/commands/generate/verify.js +122 -0
  10. package/dist/commands/generate/write.d.ts +25 -0
  11. package/dist/commands/generate/write.js +120 -0
  12. package/dist/commands/import.js +4 -1
  13. package/dist/commands/llms-txt.js +6 -4
  14. package/dist/config/loader.d.ts +0 -1
  15. package/dist/config/loader.js +1 -1
  16. package/dist/generator/agents-md.d.ts +25 -0
  17. package/dist/generator/agents-md.js +122 -0
  18. package/dist/generator/index.d.ts +2 -0
  19. package/dist/generator/index.js +2 -0
  20. package/dist/generator/mdx-serializer.d.ts +11 -0
  21. package/dist/generator/mdx-serializer.js +135 -0
  22. package/dist/generator/organizer.d.ts +1 -16
  23. package/dist/generator/organizer.js +0 -38
  24. package/dist/generator/writer.js +5 -4
  25. package/dist/llm/proxy-client.d.ts +32 -0
  26. package/dist/llm/proxy-client.js +103 -0
  27. package/dist/scanner/csharp.d.ts +0 -4
  28. package/dist/scanner/csharp.js +9 -49
  29. package/dist/scanner/go.d.ts +0 -3
  30. package/dist/scanner/go.js +8 -35
  31. package/dist/scanner/java.d.ts +0 -4
  32. package/dist/scanner/java.js +9 -49
  33. package/dist/scanner/kotlin.d.ts +0 -3
  34. package/dist/scanner/kotlin.js +6 -33
  35. package/dist/scanner/php.d.ts +0 -10
  36. package/dist/scanner/php.js +11 -55
  37. package/dist/scanner/ruby.d.ts +0 -3
  38. package/dist/scanner/ruby.js +8 -38
  39. package/dist/scanner/rust.d.ts +0 -3
  40. package/dist/scanner/rust.js +10 -37
  41. package/dist/scanner/swift.d.ts +0 -3
  42. package/dist/scanner/swift.js +8 -35
  43. package/dist/scanner/utils.d.ts +41 -0
  44. package/dist/scanner/utils.js +97 -0
  45. package/dist/template/docs.json +5 -2
  46. package/dist/template/next.config.mjs +31 -0
  47. package/dist/template/package.json +5 -3
  48. package/dist/template/src/app/layout.tsx +13 -13
  49. package/dist/template/src/app/llms-full.md/route.ts +29 -0
  50. package/dist/template/src/app/llms.txt/route.ts +29 -0
  51. package/dist/template/src/app/md/[...slug]/route.ts +174 -0
  52. package/dist/template/src/app/reference/route.ts +22 -18
  53. package/dist/template/src/app/sitemap.ts +1 -1
  54. package/dist/template/src/components/ai-chat-impl.tsx +206 -0
  55. package/dist/template/src/components/ai-chat.tsx +20 -193
  56. package/dist/template/src/components/mdx/index.tsx +27 -4
  57. package/dist/template/src/lib/fonts.ts +135 -0
  58. package/dist/template/src/middleware.ts +101 -0
  59. package/dist/template/src/styles/globals.css +28 -20
  60. package/dist/utils/files.d.ts +0 -8
  61. package/dist/utils/files.js +0 -33
  62. package/package.json +1 -1
  63. package/dist/autofix/autofix.test.d.ts +0 -1
  64. package/dist/autofix/autofix.test.js +0 -487
  65. package/dist/commands/generate.d.ts +0 -9
  66. package/dist/commands/generate.js +0 -739
  67. package/dist/generator/generator.test.d.ts +0 -1
  68. package/dist/generator/generator.test.js +0 -259
  69. package/dist/generator/writer.test.d.ts +0 -1
  70. package/dist/generator/writer.test.js +0 -411
  71. package/dist/llm/llm.manual-test.d.ts +0 -1
  72. package/dist/llm/llm.manual-test.js +0 -112
  73. package/dist/llm/llm.mock-test.d.ts +0 -4
  74. package/dist/llm/llm.mock-test.js +0 -79
  75. package/dist/plugins/index.d.ts +0 -47
  76. package/dist/plugins/index.js +0 -181
  77. package/dist/scanner/content-type.test.d.ts +0 -1
  78. package/dist/scanner/content-type.test.js +0 -231
  79. package/dist/scanner/integration.test.d.ts +0 -4
  80. package/dist/scanner/integration.test.js +0 -180
  81. package/dist/scanner/scanner.test.d.ts +0 -1
  82. package/dist/scanner/scanner.test.js +0 -210
  83. package/dist/scanner/typescript.manual-test.d.ts +0 -1
  84. package/dist/scanner/typescript.manual-test.js +0 -112
  85. package/dist/template/src/app/docs/auth/page.mdx +0 -589
  86. package/dist/template/src/app/docs/autofix/page.mdx +0 -624
  87. package/dist/template/src/app/docs/cli/page.mdx +0 -217
  88. package/dist/template/src/app/docs/config/page.mdx +0 -428
  89. package/dist/template/src/app/docs/configuration/page.mdx +0 -86
  90. package/dist/template/src/app/docs/deployment/page.mdx +0 -112
  91. package/dist/template/src/app/docs/generator/generator.md +0 -504
  92. package/dist/template/src/app/docs/generator/organizer.md +0 -779
  93. package/dist/template/src/app/docs/generator/page.mdx +0 -613
  94. package/dist/template/src/app/docs/github/page.mdx +0 -502
  95. package/dist/template/src/app/docs/llm/anthropic-client.md +0 -549
  96. package/dist/template/src/app/docs/llm/index.md +0 -471
  97. package/dist/template/src/app/docs/llm/page.mdx +0 -428
  98. package/dist/template/src/app/docs/plugins/page.mdx +0 -1793
  99. package/dist/template/src/app/docs/pro/page.mdx +0 -121
  100. package/dist/template/src/app/docs/quickstart/page.mdx +0 -93
  101. package/dist/template/src/app/docs/scanner/content-type.md +0 -599
  102. package/dist/template/src/app/docs/scanner/index.md +0 -212
  103. package/dist/template/src/app/docs/scanner/page.mdx +0 -307
  104. package/dist/template/src/app/docs/scanner/python.md +0 -469
  105. package/dist/template/src/app/docs/scanner/python_parser.md +0 -1056
  106. package/dist/template/src/app/docs/scanner/rust.md +0 -325
  107. package/dist/template/src/app/docs/scanner/typescript.md +0 -201
  108. package/dist/template/src/app/icon.tsx +0 -29
  109. package/dist/utils/validation.d.ts +0 -1
  110. package/dist/utils/validation.js +0 -12
@@ -1,180 +0,0 @@
1
- /**
2
- * Integration tests for the full scanning pipeline
3
- */
4
- import { describe, it, expect, beforeAll, afterAll } from 'vitest';
5
- import { writeFileSync, mkdirSync, rmSync, existsSync } from 'fs';
6
- import { join } from 'path';
7
- import { scanDirectory, scanFile } from './index.js';
8
- const TEST_DIR = join(process.cwd(), 'test-fixtures');
9
- describe('Scanner Integration', () => {
10
- beforeAll(() => {
11
- // Create test fixtures
12
- mkdirSync(TEST_DIR, { recursive: true });
13
- // TypeScript file
14
- writeFileSync(join(TEST_DIR, 'sample.ts'), `
15
- /**
16
- * Add two numbers
17
- * @param a First number
18
- * @param b Second number
19
- */
20
- export function add(a: number, b: number): number {
21
- return a + b;
22
- }
23
-
24
- export class Calculator {
25
- value: number = 0;
26
-
27
- add(n: number): this {
28
- this.value += n;
29
- return this;
30
- }
31
- }
32
- `);
33
- // Python file
34
- writeFileSync(join(TEST_DIR, 'utils.py'), `
35
- """Utility functions."""
36
-
37
- def greet(name: str) -> str:
38
- """Greet someone by name."""
39
- return f"Hello, {name}!"
40
-
41
- class Helper:
42
- """Helper class."""
43
-
44
- def process(self, data: dict) -> dict:
45
- """Process data."""
46
- return data
47
- `);
48
- // Go file
49
- writeFileSync(join(TEST_DIR, 'handlers.go'), `
50
- package handlers
51
-
52
- // GetUser retrieves a user
53
- func GetUser(id string) string {
54
- return id
55
- }
56
-
57
- type Service struct {
58
- name string
59
- }
60
- `);
61
- // Rust file
62
- writeFileSync(join(TEST_DIR, 'lib.rs'), `
63
- /// Configuration struct
64
- pub struct Config {
65
- pub name: String,
66
- }
67
-
68
- impl Config {
69
- /// Create new config
70
- pub fn new() -> Self {
71
- Config { name: String::new() }
72
- }
73
- }
74
-
75
- /// Parse config from string
76
- pub fn parse_config(s: &str) -> Config {
77
- Config { name: s.to_string() }
78
- }
79
- `);
80
- });
81
- afterAll(() => {
82
- // Cleanup test fixtures
83
- if (existsSync(TEST_DIR)) {
84
- rmSync(TEST_DIR, { recursive: true });
85
- }
86
- });
87
- describe('scanDirectory', () => {
88
- it('scans all supported languages', async () => {
89
- const result = await scanDirectory(TEST_DIR);
90
- expect(result.errors).toHaveLength(0);
91
- expect(result.files.length).toBeGreaterThanOrEqual(4);
92
- expect(result.totalElements).toBeGreaterThanOrEqual(8);
93
- // Check we found elements from each language
94
- const languages = new Set(result.files.map(f => f.language));
95
- expect(languages.has('typescript')).toBe(true);
96
- expect(languages.has('python')).toBe(true);
97
- expect(languages.has('go')).toBe(true);
98
- expect(languages.has('rust')).toBe(true);
99
- });
100
- it('respects exclude patterns', async () => {
101
- const result = await scanDirectory(TEST_DIR, {
102
- exclude: ['**/utils.py']
103
- });
104
- // Should not find the utils.py file
105
- const fileNames = result.files.map(f => f.filePath);
106
- const hasPython = fileNames.some(f => f.includes('utils.py'));
107
- expect(hasPython).toBe(false);
108
- });
109
- it('respects include patterns', async () => {
110
- const result = await scanDirectory(TEST_DIR, {
111
- include: ['**/*.ts']
112
- });
113
- expect(result.files.length).toBe(1);
114
- expect(result.files[0].language).toBe('typescript');
115
- });
116
- it('calls progress callback', async () => {
117
- const progress = [];
118
- await scanDirectory(TEST_DIR, {
119
- onProgress: (current, total) => {
120
- progress.push({ current, total });
121
- }
122
- });
123
- expect(progress.length).toBeGreaterThan(0);
124
- expect(progress[0].current).toBe(1);
125
- });
126
- });
127
- describe('scanFile', () => {
128
- it('scans a single TypeScript file', async () => {
129
- const result = await scanFile(join(TEST_DIR, 'sample.ts'));
130
- expect(result.errors).toHaveLength(0);
131
- expect(result.language).toBe('typescript');
132
- expect(result.elements.length).toBeGreaterThanOrEqual(2);
133
- const functionNames = result.elements.map(e => e.name);
134
- expect(functionNames).toContain('add');
135
- expect(functionNames).toContain('Calculator');
136
- });
137
- it('scans a single Python file', async () => {
138
- const result = await scanFile(join(TEST_DIR, 'utils.py'));
139
- expect(result.errors).toHaveLength(0);
140
- expect(result.language).toBe('python');
141
- const names = result.elements.map(e => e.name);
142
- expect(names).toContain('greet');
143
- expect(names).toContain('Helper');
144
- });
145
- it('returns error for unsupported file type', async () => {
146
- const result = await scanFile(join(TEST_DIR, 'unknown.xyz'));
147
- expect(result.errors.length).toBeGreaterThan(0);
148
- expect(result.elements).toHaveLength(0);
149
- });
150
- });
151
- describe('single file via scanDirectory', () => {
152
- it('accepts a single file path', async () => {
153
- const result = await scanDirectory(join(TEST_DIR, 'sample.ts'));
154
- expect(result.errors).toHaveLength(0);
155
- expect(result.files.length).toBe(1);
156
- expect(result.files[0].language).toBe('typescript');
157
- });
158
- });
159
- describe('element extraction', () => {
160
- it('extracts function parameters', async () => {
161
- const result = await scanFile(join(TEST_DIR, 'sample.ts'));
162
- const addFn = result.elements.find(e => e.name === 'add');
163
- expect(addFn).toBeDefined();
164
- expect(addFn?.parameters).toHaveLength(2);
165
- expect(addFn?.parameters[0].name).toBe('a');
166
- expect(addFn?.parameters[0].type).toBe('number');
167
- });
168
- it('extracts docstrings', async () => {
169
- const result = await scanFile(join(TEST_DIR, 'sample.ts'));
170
- const addFn = result.elements.find(e => e.name === 'add');
171
- expect(addFn?.docstring).toContain('Add two numbers');
172
- });
173
- it('extracts class methods', async () => {
174
- const result = await scanFile(join(TEST_DIR, 'sample.ts'));
175
- const addMethod = result.elements.find(e => e.name === 'add' && e.kind === 'method');
176
- expect(addMethod).toBeDefined();
177
- expect(addMethod?.parentClass).toBe('Calculator');
178
- });
179
- });
180
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,210 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { scanFile, scanDirectory } from './index.js';
3
- import { join } from 'path';
4
- const TESTDATA = join(process.cwd(), 'testdata');
5
- describe('Scanner', () => {
6
- describe('scanFile', () => {
7
- describe('Python files', () => {
8
- it('should scan Python file and extract elements', async () => {
9
- const result = await scanFile(join(TESTDATA, 'sample.py'));
10
- expect(result.errors).toHaveLength(0);
11
- expect(result.language).toBe('python');
12
- expect(result.elements.length).toBeGreaterThan(0);
13
- });
14
- it('should find expected Python functions', async () => {
15
- const result = await scanFile(join(TESTDATA, 'sample.py'));
16
- const names = result.elements.map(e => e.name);
17
- expect(names).toContain('greet');
18
- expect(names).toContain('fetch_data');
19
- });
20
- it('should find Python class and methods', async () => {
21
- const result = await scanFile(join(TESTDATA, 'sample.py'));
22
- const names = result.elements.map(e => e.name);
23
- expect(names).toContain('Calculator');
24
- expect(names).toContain('add');
25
- expect(names).toContain('multiply');
26
- });
27
- it('should exclude private Python elements', async () => {
28
- const result = await scanFile(join(TESTDATA, 'sample.py'));
29
- const names = result.elements.map(e => e.name);
30
- expect(names).not.toContain('_private_method');
31
- expect(names).not.toContain('_private_function');
32
- expect(names).not.toContain('_PrivateClass');
33
- });
34
- it('should detect async Python functions', async () => {
35
- const result = await scanFile(join(TESTDATA, 'sample.py'));
36
- const fetchData = result.elements.find(e => e.name === 'fetch_data');
37
- expect(fetchData).toBeDefined();
38
- expect(fetchData?.isAsync).toBe(true);
39
- });
40
- it('should extract Python function parameters', async () => {
41
- const result = await scanFile(join(TESTDATA, 'sample.py'));
42
- const greet = result.elements.find(e => e.name === 'greet');
43
- expect(greet).toBeDefined();
44
- expect(greet?.parameters).toHaveLength(2);
45
- expect(greet?.parameters[0].name).toBe('name');
46
- expect(greet?.parameters[0].type).toBe('str');
47
- });
48
- it('should extract Python docstrings', async () => {
49
- const result = await scanFile(join(TESTDATA, 'sample.py'));
50
- const greet = result.elements.find(e => e.name === 'greet');
51
- expect(greet?.docstring).toContain('Generate a greeting');
52
- });
53
- });
54
- describe('TypeScript files', () => {
55
- it('should scan TypeScript file and extract elements', async () => {
56
- const result = await scanFile(join(TESTDATA, 'sample.ts'));
57
- expect(result.errors).toHaveLength(0);
58
- expect(result.language).toBe('typescript');
59
- expect(result.elements.length).toBeGreaterThan(0);
60
- });
61
- it('should find expected TypeScript functions', async () => {
62
- const result = await scanFile(join(TESTDATA, 'sample.ts'));
63
- const names = result.elements.map(e => e.name);
64
- expect(names).toContain('greet');
65
- expect(names).toContain('fetchData');
66
- expect(names).toContain('processItems');
67
- });
68
- it('should find TypeScript class and methods', async () => {
69
- const result = await scanFile(join(TESTDATA, 'sample.ts'));
70
- const names = result.elements.map(e => e.name);
71
- expect(names).toContain('Calculator');
72
- expect(names).toContain('add');
73
- expect(names).toContain('multiply');
74
- });
75
- it('should exclude non-exported TypeScript elements', async () => {
76
- const result = await scanFile(join(TESTDATA, 'sample.ts'));
77
- const names = result.elements.map(e => e.name);
78
- expect(names).not.toContain('internalHelper');
79
- expect(names).not.toContain('_privateFunction');
80
- });
81
- it('should detect async TypeScript functions', async () => {
82
- const result = await scanFile(join(TESTDATA, 'sample.ts'));
83
- const fetchData = result.elements.find(e => e.name === 'fetchData');
84
- const processItems = result.elements.find(e => e.name === 'processItems');
85
- expect(fetchData?.isAsync).toBe(true);
86
- expect(processItems?.isAsync).toBe(true);
87
- });
88
- it('should set parentClass for methods', async () => {
89
- const result = await scanFile(join(TESTDATA, 'sample.ts'));
90
- const addMethod = result.elements.find(e => e.name === 'add');
91
- expect(addMethod?.parentClass).toBe('Calculator');
92
- expect(addMethod?.kind).toBe('method');
93
- });
94
- });
95
- describe('Go files', () => {
96
- it('should scan Go file and extract elements', async () => {
97
- const result = await scanFile(join(TESTDATA, 'sample.go'));
98
- expect(result.errors).toHaveLength(0);
99
- expect(result.language).toBe('go');
100
- expect(result.elements.length).toBeGreaterThan(0);
101
- });
102
- it('should find exported Go functions', async () => {
103
- const result = await scanFile(join(TESTDATA, 'sample.go'));
104
- const names = result.elements.map(e => e.name);
105
- expect(names).toContain('Greet');
106
- expect(names).toContain('FetchData');
107
- expect(names).toContain('NewCalculator');
108
- expect(names).toContain('ProcessItems');
109
- });
110
- it('should find Go types', async () => {
111
- const result = await scanFile(join(TESTDATA, 'sample.go'));
112
- const names = result.elements.map(e => e.name);
113
- expect(names).toContain('Config');
114
- expect(names).toContain('Calculator');
115
- expect(names).toContain('Client');
116
- });
117
- it('should find Go methods', async () => {
118
- const result = await scanFile(join(TESTDATA, 'sample.go'));
119
- const names = result.elements.map(e => e.name);
120
- expect(names).toContain('Add');
121
- expect(names).toContain('Multiply');
122
- });
123
- it('should exclude non-exported Go functions', async () => {
124
- const result = await scanFile(join(TESTDATA, 'sample.go'));
125
- const names = result.elements.map(e => e.name);
126
- expect(names).not.toContain('privateFunction');
127
- expect(names).not.toContain('privateMethod');
128
- });
129
- it('should extract Go doc comments', async () => {
130
- const result = await scanFile(join(TESTDATA, 'sample.go'));
131
- const greet = result.elements.find(e => e.name === 'Greet');
132
- expect(greet?.docstring).toContain('generates a greeting');
133
- });
134
- });
135
- describe('Rust files', () => {
136
- it('should scan Rust file and extract elements', async () => {
137
- const result = await scanFile(join(TESTDATA, 'sample.rs'));
138
- expect(result.errors).toHaveLength(0);
139
- expect(result.language).toBe('rust');
140
- expect(result.elements.length).toBeGreaterThan(0);
141
- });
142
- it('should find pub Rust functions', async () => {
143
- const result = await scanFile(join(TESTDATA, 'sample.rs'));
144
- const names = result.elements.map(e => e.name);
145
- expect(names).toContain('greet');
146
- expect(names).toContain('fetch_data');
147
- expect(names).toContain('process_items');
148
- });
149
- it('should find pub Rust types', async () => {
150
- const result = await scanFile(join(TESTDATA, 'sample.rs'));
151
- const names = result.elements.map(e => e.name);
152
- expect(names).toContain('Config');
153
- expect(names).toContain('Calculator');
154
- expect(names).toContain('Client');
155
- });
156
- it('should find pub impl methods', async () => {
157
- const result = await scanFile(join(TESTDATA, 'sample.rs'));
158
- const names = result.elements.map(e => e.name);
159
- expect(names).toContain('new');
160
- expect(names).toContain('add');
161
- expect(names).toContain('multiply');
162
- });
163
- it('should exclude non-pub Rust functions', async () => {
164
- const result = await scanFile(join(TESTDATA, 'sample.rs'));
165
- const names = result.elements.map(e => e.name);
166
- expect(names).not.toContain('private_function');
167
- expect(names).not.toContain('private_method');
168
- });
169
- it('should detect async Rust functions', async () => {
170
- const result = await scanFile(join(TESTDATA, 'sample.rs'));
171
- const fetchData = result.elements.find(e => e.name === 'fetch_data');
172
- expect(fetchData?.isAsync).toBe(true);
173
- });
174
- it('should extract Rust doc comments', async () => {
175
- const result = await scanFile(join(TESTDATA, 'sample.rs'));
176
- const greet = result.elements.find(e => e.name === 'greet');
177
- expect(greet?.docstring).toContain('Generate a greeting');
178
- });
179
- });
180
- });
181
- describe('scanDirectory', () => {
182
- it('should scan multiple files in directory', async () => {
183
- const result = await scanDirectory(TESTDATA, {
184
- include: ['**/*.py', '**/*.ts', '**/*.go', '**/*.rs'],
185
- exclude: [],
186
- });
187
- expect(result.files.length).toBeGreaterThanOrEqual(4);
188
- expect(result.totalElements).toBeGreaterThan(0);
189
- expect(result.errors).toHaveLength(0);
190
- });
191
- it('should respect include patterns', async () => {
192
- const result = await scanDirectory(TESTDATA, {
193
- include: ['**/*.py'],
194
- exclude: [],
195
- });
196
- expect(result.files.every(f => f.language === 'python')).toBe(true);
197
- });
198
- it('should have files from all languages', async () => {
199
- const result = await scanDirectory(TESTDATA, {
200
- include: ['**/*.py', '**/*.ts', '**/*.go', '**/*.rs'],
201
- exclude: [],
202
- });
203
- const languages = new Set(result.files.map(f => f.language));
204
- expect(languages.has('python')).toBe(true);
205
- expect(languages.has('typescript')).toBe(true);
206
- expect(languages.has('go')).toBe(true);
207
- expect(languages.has('rust')).toBe(true);
208
- });
209
- });
210
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,112 +0,0 @@
1
- import { scanFile, scanDirectory } from './index.js';
2
- async function runTests() {
3
- console.log('=== TypeScript Scanner Tests ===\n');
4
- // Test 1: Scan single TypeScript file
5
- console.log('Test 1: Scan single TypeScript file');
6
- const result = await scanFile('testdata/sample.ts');
7
- if (result.errors.length > 0) {
8
- console.log(' ✗ errors:', result.errors);
9
- process.exit(1);
10
- }
11
- console.log(` found ${result.elements.length} elements`);
12
- console.log(` language: ${result.language}`);
13
- // Check we found expected elements
14
- const names = result.elements.map(e => e.name);
15
- const expected = ['greet', 'fetchData', 'processItems', 'Calculator', 'constructor', 'add', 'multiply'];
16
- for (const name of expected) {
17
- if (!names.includes(name)) {
18
- console.log(` ✗ missing expected element: ${name}`);
19
- console.log(' found:', names);
20
- process.exit(1);
21
- }
22
- }
23
- // Check private/non-exported elements are excluded
24
- const excluded = ['_privateMethod', '_privateFunction', 'internalHelper'];
25
- for (const name of excluded) {
26
- if (names.includes(name)) {
27
- console.log(` ✗ should have excluded: ${name}`);
28
- process.exit(1);
29
- }
30
- }
31
- console.log(' ✓ found all expected elements');
32
- console.log(' ✓ excluded private/non-exported elements\n');
33
- // Test 2: Check function details
34
- console.log('Test 2: Check function details');
35
- const greet = result.elements.find(e => e.name === 'greet');
36
- if (greet.kind !== 'function') {
37
- console.log(` ✗ greet.kind should be 'function', got '${greet.kind}'`);
38
- process.exit(1);
39
- }
40
- if (greet.parameters.length !== 2) {
41
- console.log(` ✗ greet should have 2 params, got ${greet.parameters.length}`);
42
- process.exit(1);
43
- }
44
- if (greet.returnType !== 'string') {
45
- console.log(` ✗ greet.returnType should be 'string', got '${greet.returnType}'`);
46
- process.exit(1);
47
- }
48
- console.log(' ✓ function details correct\n');
49
- // Test 3: Check async function
50
- console.log('Test 3: Check async function');
51
- const fetchData = result.elements.find(e => e.name === 'fetchData');
52
- if (!fetchData.isAsync) {
53
- console.log(' ✗ fetchData should be async');
54
- process.exit(1);
55
- }
56
- console.log(' ✓ async detected correctly\n');
57
- // Test 4: Check arrow function
58
- console.log('Test 4: Check arrow function');
59
- const processItems = result.elements.find(e => e.name === 'processItems');
60
- if (processItems.kind !== 'function') {
61
- console.log(` ✗ processItems.kind should be 'function', got '${processItems.kind}'`);
62
- process.exit(1);
63
- }
64
- if (!processItems.isAsync) {
65
- console.log(' ✗ processItems should be async');
66
- process.exit(1);
67
- }
68
- console.log(' ✓ arrow function detected correctly\n');
69
- // Test 5: Check class and methods
70
- console.log('Test 5: Check class and methods');
71
- const calculator = result.elements.find(e => e.name === 'Calculator');
72
- const addMethod = result.elements.find(e => e.name === 'add');
73
- if (calculator.kind !== 'class') {
74
- console.log(` ✗ Calculator.kind should be 'class', got '${calculator.kind}'`);
75
- process.exit(1);
76
- }
77
- if (addMethod.kind !== 'method') {
78
- console.log(` ✗ add.kind should be 'method', got '${addMethod.kind}'`);
79
- process.exit(1);
80
- }
81
- if (addMethod.parentClass !== 'Calculator') {
82
- console.log(` ✗ add.parentClass should be 'Calculator', got '${addMethod.parentClass}'`);
83
- process.exit(1);
84
- }
85
- console.log(' ✓ class and methods correct\n');
86
- // Test 6: Scan directory with both Python and TypeScript
87
- console.log('Test 6: Scan directory with multiple languages');
88
- const dirResult = await scanDirectory('testdata', {
89
- include: ['**/*.py', '**/*.ts'],
90
- exclude: []
91
- });
92
- console.log(` scanned ${dirResult.files.length} files`);
93
- console.log(` found ${dirResult.totalElements} total elements`);
94
- const languages = new Set(dirResult.files.map(f => f.language));
95
- if (!languages.has('python') || !languages.has('typescript')) {
96
- console.log(' ✗ should have found both Python and TypeScript');
97
- console.log(' languages:', [...languages]);
98
- process.exit(1);
99
- }
100
- console.log(' ✓ multi-language scan works\n');
101
- // Print summary of all elements
102
- console.log('=== Elements Found ===');
103
- for (const el of result.elements) {
104
- const prefix = el.parentClass ? `${el.parentClass}.` : '';
105
- console.log(` [${el.kind}] ${prefix}${el.name}`);
106
- }
107
- console.log('\n✓ All TypeScript scanner tests passed');
108
- }
109
- runTests().catch(err => {
110
- console.error('Test failed:', err);
111
- process.exit(1);
112
- });