MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / packFiles

Function packFiles

src/context/trellis.ts:86–102  ·  view source on GitHub ↗

Concatenate files under a byte budget, marking truncation.

(
  files: Array<{ name: string; content: string }>,
  budget: number,
)

Source from the content-addressed store, hash-verified

84
85/** Concatenate files under a byte budget, marking truncation. */
86function packFiles(
87 files: Array<{ name: string; content: string }>,
88 budget: number,
89): string {
90 const parts: string[] = [];
91 let used = 0;
92 for (const f of files) {
93 if (used >= budget) { parts.push(`… (${files.length - parts.length} more file(s) omitted)`); break; }
94 const remaining = budget - used;
95 const body = f.content.length > remaining
96 ? f.content.slice(0, remaining) + '\n… (truncated)'
97 : f.content;
98 parts.push(`### ${f.name}\n${body}`);
99 used += body.length + f.name.length + 8;
100 }
101 return parts.join('\n\n');
102}
103
104/**
105 * Load and render the Trellis context block for `cwd`. Returns null when there's

Callers 1

loadTrellisContextFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected