MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / copy

Function copy

graph-ui/src/galaxy/selection-evidence.ts:186–213  ·  view source on GitHub ↗
(value: unknown, path: string, depth: number)

Source from the content-addressed store, hash-verified

184 const omissions: { path: string; kind: string; count: number }[] = [];
185 let budget = 16_000;
186 const copy = (value: unknown, path: string, depth: number): unknown => {
187 if (value === undefined) return undefined;
188 if (budget <= 0 || depth > 10) {
189 omissions.push({ path, kind: 'value', count: 1 }); return null;
190 }
191 if (typeof value === 'string') {
192 const limit = Math.max(0, Math.min(1200, budget));
193 budget -= Math.min(value.length, limit);
194 if (value.length > limit) omissions.push({ path, kind: 'characters', count: value.length - limit });
195 return value.slice(0, limit);
196 }
197 if (value === null || typeof value !== 'object') { budget -= 16; return value; }
198 if (Array.isArray(value)) {
199 const result: unknown[] = [];
200 for (let i = 0; i < Math.min(value.length, 24) && budget > 0; i++) result.push(copy(value[i], `${path}[${i}]`, depth + 1));
201 if (result.length < value.length) omissions.push({ path, kind: 'items', count: value.length - result.length });
202 return result;
203 }
204 const entries = Object.entries(value), result: Record<string, unknown> = {};
205 let processed = 0;
206 for (const [key, item] of entries) {
207 if (processed >= 48 || budget <= 0) break;
208 budget -= key.length + 6; processed++;
209 result[key] = copy(item, `${path}.${key}`, depth + 1);
210 }
211 if (processed < entries.length) omissions.push({ path, kind: 'fields', count: entries.length - processed });
212 return result;
213 };
214 // Keep provenance and limits ahead of potentially large member collections. In
215 // Architecture the connections of a part say more than the members listed with it.
216 const head = { kind: 'current-selection-evidence', project: evidence.project, view: evidence.view,

Callers 3

selectionEvidenceContextFunction · 0.70
fileSHA256Function · 0.50
SettingsPanelFunction · 0.50

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected