MCPcopy Create free account
hub / github.com/StepfenShawn/ShitCodify / generateFileStructureDescription

Function generateFileStructureDescription

src/utils/promptGenerator.ts:104–124  ·  view source on GitHub ↗
(files: FileNode[])

Source from the content-addressed store, hash-verified

102}
103
104function generateFileStructureDescription(files: FileNode[]): string {
105 let result = '';
106
107 function traverseFiles(nodes: FileNode[], depth: number = 0) {
108 for (const node of nodes) {
109 // 使用空格字符串拼接而不是 repeat 方法
110 let indent = '';
111 for (let i = 0; i < depth * 2; i++) {
112 indent += ' ';
113 }
114 result += `${indent}${node.isDirectory ? '📁' : '📄'} ${node.name}\n`;
115
116 if (node.isDirectory && node.children) {
117 traverseFiles(node.children, depth + 1);
118 }
119 }
120 }
121
122 traverseFiles(files);
123 return result;
124}
125
126// 辅助函数:将文件列表转换为树形结构
127export function filesToTree(files: File[]): FileNode[] {

Callers 1

generatePromptFunction · 0.85

Calls 1

traverseFilesFunction · 0.85

Tested by

no test coverage detected