From e4e442e1be362c91a43dacddf5082e4fddd8729a Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Tue, 30 Jun 2026 12:10:09 +0000 Subject: [PATCH] fix(cli): bound all context --limit array categories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit context --limit sliced only incoming.calls / outgoing.calls / outgoing.accesses / processes, leaving the other relType buckets unbounded — notably incoming.accesses (bounded on outgoing but not incoming) plus imports/extends/ uses/… and typed_properties. Replace the hardcoded slices with a generic loop over every array-valued bucket under incoming/outgoing, plus typed_properties and processes, so --limit caps the whole context payload. (#2310) --- gitnexus/src/cli/tool.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gitnexus/src/cli/tool.ts b/gitnexus/src/cli/tool.ts index 7c2accc46..d5debdfea 100644 --- a/gitnexus/src/cli/tool.ts +++ b/gitnexus/src/cli/tool.ts @@ -138,12 +138,21 @@ export async function contextCommand( branch: options?.branch, }); if (limit !== undefined) { - if (result.incoming?.calls && Array.isArray(result.incoming.calls)) - result.incoming.calls = result.incoming.calls.slice(0, limit); - if (result.outgoing?.calls && Array.isArray(result.outgoing.calls)) - result.outgoing.calls = result.outgoing.calls.slice(0, limit); - if (result.outgoing?.accesses && Array.isArray(result.outgoing.accesses)) - result.outgoing.accesses = result.outgoing.accesses.slice(0, limit); + // Bound every array-valued category under incoming/outgoing (calls, accesses, + // imports, extends, uses, …) — categorize() buckets by relType, so the prior + // hardcoded calls/accesses missed the rest (e.g. incoming.accesses) — plus + // typed_properties and processes, so --limit caps the whole context payload. + for (const dir of [result.incoming, result.outgoing] as Array< + Record | undefined + >) { + if (!dir) continue; + for (const key of Object.keys(dir)) { + const bucket = dir[key]; + if (Array.isArray(bucket)) dir[key] = bucket.slice(0, limit); + } + } + if (Array.isArray(result.typed_properties)) + result.typed_properties = result.typed_properties.slice(0, limit); if (Array.isArray(result.processes)) result.processes = result.processes.slice(0, limit); } output(result);