MCPcopy Create free account
hub / github.com/driangle/taskmd / inlineContents

Function inlineContents

apps/cli/internal/taskcontext/resolve.go:260–286  ·  view source on GitHub ↗

inlineContents reads file contents and counts lines for each existing text file. Binary files and known generated files (lock files, etc.) are skipped.

(files []FileEntry, projectRoot string)

Source from the content-addressed store, hash-verified

258// inlineContents reads file contents and counts lines for each existing text file.
259// Binary files and known generated files (lock files, etc.) are skipped.
260func inlineContents(files []FileEntry, projectRoot string) {
261 for i := range files {
262 if !files[i].Exists {
263 continue
264 }
265 fullPath := filepath.Join(projectRoot, files[i].Path)
266 info, err := os.Stat(fullPath)
267 if err != nil || info.IsDir() {
268 continue
269 }
270 if generatedFiles[filepath.Base(files[i].Path)] {
271 files[i].Generated = true
272 continue
273 }
274 data, err := os.ReadFile(fullPath)
275 if err != nil {
276 continue
277 }
278 if isBinary(data) {
279 files[i].Binary = true
280 continue
281 }
282 content := string(data)
283 files[i].Content = content
284 files[i].Lines = countLines(content)
285 }
286}
287
288// isBinary reports whether data looks like binary content.
289// It checks for null bytes in the first 8KB, which is the same heuristic git uses.

Callers 1

ResolveFunction · 0.85

Calls 2

countLinesFunction · 0.85
isBinaryFunction · 0.70

Tested by

no test coverage detected