MCPcopy Create free account
hub / github.com/apache/maka / jsonArrayCount

Function jsonArrayCount

packages/cli/src/pi-transcript-tools.ts:338–345  ·  view source on GitHub ↗

* Row count for list-shaped json results (Grep `matches`, Glob `files`). * Returns a count only when the keyed field is genuinely an array; an * error-shaped result (e.g. `{ error: "..." }`) returns undefined so the * caller falls back to a generic first-line summary rather than reporting a * fa

(entry: MakaPiToolEntry, key: string)

Source from the content-addressed store, hash-verified

336 * fabricated "N matches" / "N files" from an unrelated line count.
337 */
338function jsonArrayCount(entry: MakaPiToolEntry, key: string): number | undefined {
339 const result = entry.result;
340 if (result?.kind === 'json' && result.value !== null && typeof result.value === 'object') {
341 const rows = (result.value as Record<string, unknown>)[key];
342 if (Array.isArray(rows)) return rows.length;
343 }
344 return undefined;
345}
346
347function renderToolText(text: string, width: number): string[] {
348 return renderIndented(limitText(text, 12_000), width, 2);

Callers 1

compactToolSummaryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected