Skip to content

fix(cli): expose pagination cursors and fetch complete inventories - #7590

Merged
TheodoreSpeaks merged 2 commits into
stagingfrom
fix/cli-json-malformed
Sep 8, 2026
Merged

fix(cli): expose pagination cursors and fetch complete inventories#7590
TheodoreSpeaks merged 2 commits into
stagingfrom
fix/cli-json-malformed

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Return paginated JSON/YAML as { data, nextCursor } and remove the pagination notice. Scripts now read items from .data instead of a bare array.
  • Fetch complete resource inventories by default, including resource directory ls. Keep table rows, logs, histories, documents, and chunks capped at 100 by default with --cursor to continue; --limit 0 still fetches all remaining results.
  • Size the final request to the remaining limit so continuation never skips unreturned items, fail fast on invalid or repeated cursors and oversized pages, and update command documentation and scripting examples.

Type of Change

  • Bug fix

Testing

  • CLI suite: 976 passed, 1 skipped; CLI type checking and all 283 repository script tests passed.
  • Full repository lint, all 46 audits, block registry validation, and docs manifest checks passed.
  • Regression coverage includes default inventory traversal, bounded collections, query/body cursor continuation, JSON/YAML envelopes, and malformed pagination responses including cursor cycles.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 8, 2026 8:19am UTC

Request Review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@TheodoreSpeaks I have started the AI code review. It will take a few minutes to complete.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR updates CLI pagination so structured output exposes continuation cursors, bounded requests preserve an accurate cursor, and inventory commands fetch complete datasets by default.

  • Returns paginated JSON and YAML as { data, nextCursor }.
  • Adds manual cursor continuation to bounded dataset and history commands.
  • Sizes each request to the remaining item limit and validates malformed, oversized, or cyclic pagination responses.
  • Makes resource inventories and directory listings unbounded by default while retaining 100-item defaults for larger datasets.
  • Updates CLI documentation and regression coverage for the new behavior.

Confidence Score: 5/5

The PR appears safe to merge; the previously identified repeated-cursor loop is addressed without introducing a new actionable failure.

Cursor history is now validated before additional pages are accumulated or rendered, including immediate repetition of a user-supplied continuation cursor. Remaining-limit request sizing preserves accurate continuation semantics, and the accompanying tests cover query- and body-based pagination, bounded and unbounded traversal, malformed pages, and cursor cycles.

Important Files Changed

Filename Overview
packages/sim-cli/src/runtime/execute.ts Implements bounded and unbounded pagination, cursor continuation, cycle detection, page-size validation, and structured page rendering.
packages/sim-cli/src/http/client.ts Consolidates complete-page traversal and rejects repeated pagination cursors.
packages/sim-cli/src/runtime/options.ts Separates request page size from command defaults and classifies inventory commands for complete traversal.
packages/sim-cli/src/runtime/result.ts Emits data and nextCursor envelopes for paginated JSON and YAML output.
packages/sim-cli/src/commands/protocol/resource-directory.ts Fetches complete paginated resource inventories for directory listings by default.
packages/sim-cli/src/runtime/build.test.ts Adds broad regression coverage for limits, continuation, cursor cycles, page sizing, and output envelopes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Invoke paginated CLI command] --> B{Explicit/default limit}
  B -->|0| C[Use unbounded total]
  B -->|N > 0| D[Use bounded total N]
  C --> E[Request up to 100 items]
  D --> F[Request min of 100 and remaining limit]
  E --> G[Validate page size and nextCursor]
  F --> G
  G -->|Repeated or invalid cursor| H[Fail without printing partial output]
  G -->|Valid page| I[Accumulate data]
  I --> J{Cursor remains and total limit not reached?}
  J -->|Yes| E
  J -->|No| K[Render data and nextCursor]
Loading

Reviews (2): Last reviewed commit: "fix(cli): reject pagination cursor cycle..." | Re-trigger Greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

Addressed the repeated-cursor finding in 1dd8165. Both pagination loops now use the same cursor-cycle check and throw before appending the offending page. Resumed commands seed the seen set with the supplied cursor, so a response that echoes it fails immediately. Regression tests cover repeated cursors, longer cycles, and query/body continuation without partial output.

Also corrected the example run ID flagged by the docs test. The CLI suite (976 passed, 1 skipped), repository script tests (283 passed), type checking, lint, and all 46 audits pass locally.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@TheodoreSpeaks I have started the AI code review. It will take a few minutes to complete.

@TheodoreSpeaks
TheodoreSpeaks merged commit ebf85f3 into staging Sep 8, 2026
33 of 34 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the fix/cli-json-malformed branch September 8, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant