mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-12 03:48:38 +00:00
fix(cli): bound all context --limit array categories
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)
This commit is contained in:
parent
82c0cfe45f
commit
e4e442e1be
1 changed files with 15 additions and 6 deletions
|
|
@ -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<string, unknown> | 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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue