-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcollect_codebase.py
More file actions
71 lines (62 loc) · 2.58 KB
/
collect_codebase.py
File metadata and controls
71 lines (62 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
def write_file_contents_to_txt(root_dir, output_file):
# Specific files to capture
specific_files = [
'src/analyzer/parsers/function-parser.ts',
'src/analyzer/parsers/class-parser.ts',
'src/analyzer/parsers/interface-parser.ts',
'src/analyzer/parsers/type-alias-parser.ts',
'src/analyzer/parsers/variable-parser.ts',
'src/analyzer/parsers/module-parser.ts',
'src/cli/analyze.ts',
'src/config/index.ts',
'src/database/schema.ts',
'src/database/neo4j-client.ts',
'src/scanner/file-scanner.ts',
'src/utils/errors.ts',
'src/utils/logger.ts',
'src/utils/ts-helpers.ts',
'src/vector/vector-service.ts',
'src/analyzer/analysis/assignment-analyzer.ts',
'src/analyzer/analysis/call-analyzer.ts',
'src/analyzer/analysis/control-flow-analyzer.ts',
'src/analyzer/analysis/usage-analyzer.ts',
'src/analyzer/analyzer-service.ts',
'src/analyzer/domain-analyzer.ts',
'src/analyzer/parser.ts',
'src/analyzer/relationship-resolver.ts',
'src/analyzer/semantic-analyzer.ts',
'src/analyzer/storage-manager.ts',
'src/index.ts',
'package.json',
'tsconfig.json'
]
with open(output_file, 'w', encoding='utf-8') as outfile:
def write_separator():
outfile.write('\n' + '='*80 + '\n\n')
for file_path in specific_files:
full_path = os.path.join(root_dir, file_path)
if os.path.exists(full_path):
# Write file header
outfile.write(f'File: {os.path.basename(file_path)}\n')
outfile.write(f'Path: {file_path}\n')
outfile.write('-'*40 + '\n\n')
# Read and write file contents
try:
with open(full_path, 'r', encoding='utf-8') as infile:
outfile.write(infile.read())
except Exception as e:
outfile.write(f'Error reading file: {str(e)}\n')
write_separator()
else:
print(f'Warning: File not found: {file_path}')
def main():
# Get the root directory (assuming this script is in the root)
root_dir = os.getcwd()
# Output file name
output_file = 'codebase_contents.txt'
print(f"Starting to collect file contents from {root_dir}")
write_file_contents_to_txt(root_dir, output_file)
print(f"Finished! All contents have been written to {output_file}")
if __name__ == "__main__":
main()