2import { existsSync } from 'fs' 3import { execSync } from 'child_process' 7const textFileExts = new Set(ptTextFileExtA) 8export const isTextFile = (filePath: string) => { 9 const ext = filePath.split('.').pop()?.toLowerCase() 10 const basename = path.basename(filePath) 11 return textFileExts.has(ext!) || basename.startsWith('.') || !filePath.includes('.') 14export const getTrackedFiles = async (trackedPaths: string[]) => { 15 const files: string[] = [] 16 for (const tp of trackedPaths) { 17 if (tp.endsWith('/')) { 18 const abs = path.join(ptDir, tp) 19 if (!existsSync(abs)) continue 22 result = execSync(`git ls-files --full-name "${tp}"`, {cwd: ptDir, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe']}).trim() 24 if (result) files.push(...result.split('\n').filter(Boolean)) 26 if (!existsSync(path.join(ptDir, tp))) continue 30 return [...new Set(files)]