Skip to content

feat(output): pm list csv/table + pm context --fields focus-row projection - #297

Merged
unbraind merged 2 commits into
mainfrom
feat/cli-output-formats-projection
Jun 19, 2026
Merged

unbraind merged 2 commits into
mainfrom
feat/cli-output-formats-projection

Conversation

@unbraind

Copy link
Copy Markdown
Owner

Summary

Combines two CLI output-shaping features under the CLI command surface & agent-ergonomics epic (pm-mpbb). Both give agents and humans control over the shape of pm output — directly serving the project philosophy that project management = context management (token-efficient projection) plus practical human export.

Closes pm-1lll (GH-154 remainder) and pm-hnjf (GH-156 follow-up).

pm list --format <csv|table|json|toon> (pm-1lll)

  • New shared renderer src/core/output/tabular.ts:
    • renderRowsAsCsv — RFC 4180 compliant (quotes values containing commas/quotes/newlines; array fields like tags join with ;).
    • renderRowsAsTable — fixed-width aligned columns with a dashed header rule.
  • csv/table are human export modes; json/toon reuse the existing resolveReadCommandOutputFormat override (honouring the --json + --format toon conflict).
  • Rendered columns follow the active projection, so --format composes with --fields/--brief/--compact.
  • Rejects --format csv|table + --stream. CLI-only (agents read --json), so added to LIST_FILTER_FLAG_CONTRACTS but not the MCP list option contracts.
pm list-open --format table
pm list-all --fields id,title,priority --format csv > backlog.csv

pm context --fields <a,b,c> (pm-hnjf)

  • Projects every focus-row section (high_level, low_level, blocked_fallback, recently_created, unparented) to a chosen field subset for low-token reads — the same shaping pm list --fields/pm get --fields provide.
  • New exported helpers parseContextFocusFields (validate + de-dupe) and projectContextFocusRows; ContextResult.focus_fields echoes the projection.
  • Applies across markdown (projected key:value lines; drops the recently-created date prefix), TOON, and JSON; exposed on the pm_context MCP tool via options.fields (wired through CONTEXT_FLAG_CONTRACTS + TOOL_CONTEXT_OPTION_CONTRACTS).
pm context --fields id,title,priority

Testing & quality

  • New tests/unit/core/output/tabular.spec.ts; extended register-list-query.spec.ts and context-command.spec.ts.
  • Full suite green: 4643 tests, 100/100/100/100 coverage.
  • contracts:check, quality:static, quality:docs-skills all pass; contracts snapshot + CHANGELOG regenerated.
  • Manually verified end-to-end in a sandbox tracker (CSV escaping, table alignment, field projection, json/toon override, error guidance).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WPY4oWVsYs2FjZ6shgUyrL

…cus-row projection

Combines two CLI output-shaping features under the CLI command surface &
agent-ergonomics epic (pm-mpbb): both let agents and humans control the shape
of pm output, serving token efficiency and human export.

pm list --format <csv|table|json|toon> (pm-1lll, GH-154 remainder):
- New shared renderer src/core/output/tabular.ts: renderRowsAsCsv (RFC 4180:
  quotes values containing commas/quotes/newlines, arrays join with ';') and
  renderRowsAsTable (fixed-width aligned columns with a dashed header rule).
- csv/table are human-export modes; json/toon reuse the existing
  resolveReadCommandOutputFormat override (honouring the --json + toon conflict).
- Rendered columns follow the active projection (--fields/--brief/--compact).
- Rejects --format csv|table + --stream; CLI-only (agents read --json), so it is
  added to LIST_FILTER_FLAG_CONTRACTS but not the MCP list option contracts.

pm context --fields <a,b,c> (pm-hnjf, GH-156 follow-up to --depth full):
- Projects every focus-row section (high_level, low_level, blocked_fallback,
  recently_created, unparented) to a chosen field subset for low-token reads.
- New exported helpers parseContextFocusFields (validate + de-dupe) and
  projectContextFocusRows; ContextResult.focus_fields echoes the projection.
- Applies across markdown (projected key:value lines, drops the recently-created
  date prefix), TOON, and JSON; exposed on the pm_context MCP tool via
  options.fields and wired through CONTEXT_FLAG_CONTRACTS + TOOL_CONTEXT_OPTION_CONTRACTS.

Tests: new tests/unit/core/output/tabular.spec.ts; extended
register-list-query.spec.ts and context-command.spec.ts. Full suite green at
100/100/100/100 coverage (4643 tests). Docs: COMMANDS.md (output render formats
+ context --fields). Contracts snapshot + changelog regenerated.

Closes pm-1lll, pm-hnjf.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPY4oWVsYs2FjZ6shgUyrL
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @unbraind, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@unbraind

Copy link
Copy Markdown
Owner Author

/gemini review

@unbraind

Copy link
Copy Markdown
Owner Author

@codex review

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@unbraind, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 42 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 00e48a79-6be1-4474-9af9-b74d919c9a94

📥 Commits

Reviewing files that changed from the base of the PR and between d7ac5ef and f9afa4d.

📒 Files selected for processing (2)
  • src/sdk/cli-contracts/tool-parameter-tables.ts
  • tests/fixtures/contracts/full.json
📝 Walkthrough

Walkthrough

Two output-shaping features are added to the CLI. pm list* gains a --format csv|table|json|toon option backed by a new src/core/output/tabular.ts renderer. pm context gains --fields <a,b,c> for per-row scalar field projection across markdown, TOON, JSON, and MCP outputs. Both features include contracts, CLI wiring, tests, documentation, and agent tracking closures.

Changes

pm list --format output formats

Layer / File(s) Summary
Tabular renderer (CSV + fixed-width table)
src/core/output/tabular.ts, tests/unit/core/output/tabular.spec.ts
Adds TabularRow, resolveColumns, renderCell, escapeCsvField, renderRowsAsCsv, and renderRowsAsTable; Vitest suite asserts RFC 4180 escaping, array/object serialization, column unioning, and padding behavior.
--format flag, parseListFormat, and output routing
src/cli/register-list-query.ts, src/sdk/cli-contracts.ts
Registers --format on list* commands, adds parseListFormat validating csv|table|json|toon, refactors the action output branch to route through tabular renderers or printListJsonStream, and rejects --format csv|table with --stream.
Contract fixture updates
tests/fixtures/contracts/full.json
Inserts --format into flag lists for all eight list* command surfaces.
list output format tests
tests/unit/cli/register-list-query.spec.ts
Mocks runList and adds a test suite asserting CSV/table output via writeStdout, quiet suppression, empty-result guard, JSON routing, streaming, and stream/format incompatibility rejection.
Docs, changelog, and agent tracking
docs/COMMANDS.md, CHANGELOG.md, .agents/pm/features/pm-1lll.toon, .agents/pm/history/pm-1lll.jsonl
Adds an "Output render formats" subsection, two changelog entries, and closes the pm-1lll feature record.

pm context --fields focus-row projection

Layer / File(s) Summary
ContextOptions/ContextResult types and SDK contracts
src/cli/commands/context.ts, src/sdk/cli-contracts.ts, src/sdk/cli-contracts/commander-types.ts, src/sdk/cli-contracts/tool-option-contracts.ts
Adds fields?: string to ContextOptions, focus_fields?: string[] to ContextResult, and --fields entries to all relevant contract tables.
parseContextFocusFields, projectContextFocusRows, and markdown rendering
src/cli/commands/context.ts
Adds field whitelist, comma-list parser with dedup/validation, row projector with null fill, formatProjectedFocusLine renderer, and routes all five markdown focus sections through a projection-aware renderFocus; runContext applies projection and sets result.focus_fields.
CLI option registration and normalizer wiring
src/cli/register-list-query.ts, src/cli/registration-helpers.ts
Registers --fields on the context command and reads it in normalizeContextOptions.
MCP tool description and fixture
src/mcp/tool-definitions.ts, tests/fixtures/contracts/full.json
Updates pm_context tool description to document options.fields, adds --fields to context/ctx flag surfaces, updates commander alias mapping, and extends JSON schemas with the fields parameter.
Tests, docs, and agent tracking
tests/unit/commands/context-command.spec.ts, docs/COMMANDS.md, .agents/pm/features/pm-hnjf.toon, .agents/pm/history/pm-hnjf.jsonl, .agents/pm/extensions/.managed-extensions.json
Adds --fields test block (parsing, errors, projection, markdown rendering, runContext integration), documents selectable fields, and closes the pm-hnjf feature record.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as register-list-query
  participant parseListFormat
  participant runList
  participant tabular as tabular.ts
  participant stdout as writeStdout

  User->>CLI: pm list --format csv
  CLI->>parseListFormat: "csv"
  parseListFormat-->>CLI: ListOutputFormat.CSV
  CLI->>runList: query options
  runList-->>CLI: { items, count }
  CLI->>tabular: renderRowsAsCsv(items)
  tabular-->>CLI: CSV string
  CLI->>stdout: write CSV string
Loading
sequenceDiagram
  participant User
  participant CLI as register-list-query
  participant normalizeContextOptions
  participant runContext
  participant parseContextFocusFields
  participant projectContextFocusRows
  participant renderContextMarkdown

  User->>CLI: pm context --fields id,title,priority
  CLI->>normalizeContextOptions: options
  normalizeContextOptions-->>CLI: ContextOptions { fields: "id,title,priority" }
  CLI->>runContext: ContextOptions
  runContext->>parseContextFocusFields: "id,title,priority"
  parseContextFocusFields-->>runContext: ["id","title","priority"]
  runContext->>projectContextFocusRows: focus arrays + fields
  projectContextFocusRows-->>runContext: projected ContextFocusItem[]
  runContext->>renderContextMarkdown: result with focus_fields set
  renderContextMarkdown-->>CLI: field:value token lines
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • unbraind/pm-cli#234: Modifies src/cli/commands/context.ts and runContext option/type surfaces (--parent, --depth full) in the same file and function that this PR extends with --fields focus-row projection.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely summarizes the two main changes: pm list CSV/table format support and pm context --fields focus-row projection, which are the primary features of this changeset.
Description check ✅ Passed The description comprehensively relates to the changeset, detailing both features (pm list --format and pm context --fields), implementation approach, testing strategy, and closure of associated issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/fixtures/contracts/full.json`:
- Around line 16720-16727: The schema examples in the "fields" property contain
search-specific fields (score and matched_fields) that are invalid for context
focus-row projection. Remove these invalid fields from the examples array and
update only those entries to use valid context projection fields such as id,
title, type, status, priority, order, deadline, assignee, tags, updated_at,
parent, children_total, children_closed, completion_pct, and created_at.
Additionally, update the description text to clarify that this projection is
context-specific rather than claiming it applies to get, search, or list-family
outputs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: e4d38447-4cad-49ad-97eb-656e474ebbac

📥 Commits

Reviewing files that changed from the base of the PR and between 96dcc79 and d7ac5ef.

📒 Files selected for processing (19)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/features/pm-1lll.toon
  • .agents/pm/features/pm-hnjf.toon
  • .agents/pm/history/pm-1lll.jsonl
  • .agents/pm/history/pm-hnjf.jsonl
  • CHANGELOG.md
  • docs/COMMANDS.md
  • src/cli/commands/context.ts
  • src/cli/register-list-query.ts
  • src/cli/registration-helpers.ts
  • src/core/output/tabular.ts
  • src/mcp/tool-definitions.ts
  • src/sdk/cli-contracts.ts
  • src/sdk/cli-contracts/commander-types.ts
  • src/sdk/cli-contracts/tool-option-contracts.ts
  • tests/fixtures/contracts/full.json
  • tests/unit/cli/register-list-query.spec.ts
  • tests/unit/commands/context-command.spec.ts
  • tests/unit/core/output/tabular.spec.ts

Comment thread tests/fixtures/contracts/full.json Resolved
…tion

Addresses CodeRabbit review on PR #297: adding `fields` to the pm_context tool
extended the shared `fields` parameter description, which previously named only
get/search/list and carried search-specific example fields (score/matched_fields)
that are not valid for context focus-row projection.

Clarify that valid field names are command-specific, name context explicitly, and
add a context-shaped example (id,title,priority,deadline). Contracts snapshot
regenerated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPY4oWVsYs2FjZ6shgUyrL
@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@unbraind

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@unbraind
unbraind merged commit 4c32fe5 into main Jun 19, 2026
15 checks passed
@unbraind
unbraind deleted the feat/cli-output-formats-projection branch June 19, 2026 05:50
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