fix(tools): render complete lists and never print a bare OK #11

Merged
dsh merged 1 commit from fix/tool-trust into master 2026-10-23 18:05:32 +00:00
Owner

One formatter patch for three coupled defects. All three live in lib/handlers/formatters.js (#7 also touches lib/handlers/common.js).

Fixes #2
Fixes #5
Fixes #7

What changed

  • #2 — silent truncation: the generic array formatter sliced every result to 20 rows. It now renders up to 100 rows and, beyond that, appends an explicit footer (… and N more — narrow the filter or page through.). The caller's limit/page is the only page-size control.
  • #5 — bare OK: removed every OK fallback. Empty arrays return a per-tool message (No issues., No labels., No pull requests., …, fallback No results.); unrecognised objects return identifying fields plus a ≤300-char JSON snippet; { ok: true } with no payload returns Done.
  • #7 — label ids: gitea_labels list now prints one line per label with name, numeric id, colour and description (type/bug (id: 39, #e11d48) — Defect…); create echoes Label "type/bug" created (id 39).; slimRecord keeps color and description on label-shaped records.

Tests

test/handlers-formatters.test.mjs (dependency-free; imports the formatter directly) covers 28 rows, 5 rows, >100 with footer, per-tool empty messages, unknown objects, Done., the no-OK source grep, label ids/colour/create, and the slimRecord passthrough.

npm test           # 25 pass
npm run test:leaks # clean
node --check lib/handlers/formatters.js lib/handlers/common.js

Live check (Forgejo 17; HMR picked up the change)

  • gitea_issue_list on pvlb-infra/vps-setup (state=all, limit=50) → 28 rows (was 20).
  • gitea_labels {action:"list"} on this repo → area/forgejo (id: 14, #0ea5e9) — … etc. (ids now visible).
  • gitea_pr_list on this repo → No pull requests. (was a bare OK).

Note: this PR targets master; the repository's default branch was renamed from main per operator direction.

One formatter patch for three coupled defects. All three live in `lib/handlers/formatters.js` (#7 also touches `lib/handlers/common.js`). Fixes #2 Fixes #5 Fixes #7 ## What changed - **#2 — silent truncation**: the generic array formatter sliced every result to 20 rows. It now renders up to 100 rows and, beyond that, appends an explicit footer (`… and N more — narrow the filter or page through.`). The caller's `limit`/`page` is the only page-size control. - **#5 — bare `OK`**: removed every `OK` fallback. Empty arrays return a per-tool message (`No issues.`, `No labels.`, `No pull requests.`, …, fallback `No results.`); unrecognised objects return identifying fields plus a ≤300-char JSON snippet; `{ ok: true }` with no payload returns `Done.` - **#7 — label ids**: `gitea_labels list` now prints one line per label with name, numeric id, colour and description (`type/bug (id: 39, #e11d48) — Defect…`); `create` echoes `Label "type/bug" created (id 39).`; `slimRecord` keeps `color` and `description` on label-shaped records. ## Tests `test/handlers-formatters.test.mjs` (dependency-free; imports the formatter directly) covers 28 rows, 5 rows, >100 with footer, per-tool empty messages, unknown objects, `Done.`, the no-`OK` source grep, label ids/colour/create, and the `slimRecord` passthrough. ``` npm test # 25 pass npm run test:leaks # clean node --check lib/handlers/formatters.js lib/handlers/common.js ``` ## Live check (Forgejo 17; HMR picked up the change) - `gitea_issue_list` on `pvlb-infra/vps-setup` (`state=all`, `limit=50`) → **28 rows** (was 20). - `gitea_labels {action:"list"}` on this repo → `area/forgejo (id: 14, #0ea5e9) — …` etc. (ids now visible). - `gitea_pr_list` on this repo → `No pull requests.` (was a bare `OK`). Note: this PR targets `master`; the repository's default branch was renamed from `main` per operator direction.
gitea_issue_list and every other array-returning tool truncated their
output at 20 rows inside the formatter, so the model never saw the rest
of the API page (#2). Empty and unrecognised results collapsed to a
single bare `OK`, hiding the difference between "nothing there", "done"
and "failed" (#5).

- render up to 100 rows, then an explicit "... and N more" footer
- per-tool empty messages; unknown objects get identifying fields plus a
  <=300-char JSON snippet; an empty success is `Done.`
- gitea_labels list shows numeric ids, colours and descriptions so
  `action: "set"` can consume its own output; create echoes the new id;
  slimRecord keeps colour/description on label objects (#7)

Adds test/handlers-formatters.test.mjs covering the acceptance lists.
Author
Owner

Gitea refuses self-approval (approve your own pull is not allowed), so the approval checkbox stays red; every other readiness gate is green (description, no conflicts, tests updated, no CI/migrations). Proceeding under the operator's delegated go-ahead for this patch. Local + live checks are recorded above.

Gitea refuses self-approval (`approve your own pull is not allowed`), so the approval checkbox stays red; every other readiness gate is green (description, no conflicts, tests updated, no CI/migrations). Proceeding under the operator's delegated go-ahead for this patch. Local + live checks are recorded above.
dsh merged commit 4d77e9f581 into master 2026-10-23 18:05:32 +00:00
Sign in to join this conversation.
No description provided.