Skip to content

fix(cli): keep payload stdout pipe-safe - #165

Merged
ThePlenkov merged 3 commits into
mainfrom
fix/cli-payload-streams
Aug 11, 2026
Merged

fix(cli): keep payload stdout pipe-safe#165
ThePlenkov merged 3 commits into
mainfrom
fix/cli-payload-streams

Conversation

@ThePlenkov

@ThePlenkov ThePlenkov commented Aug 11, 2026

Copy link
Copy Markdown
Member

User description

Summary

  • send shared CLI progress to stderr
  • preserve stdout for pipeable source and structured payloads
  • add a regression test and agentic stream contract

Verification

  • bunx nx test adt-cli --args="--run src/lib/utils/progress-reporter.test.ts"
  • S0D read-only smoke test: ABAP source on stdout, progress on stderr

Summary by cubic

Route all CLI progress and diagnostics to stderr and keep stdout strictly for command payloads (source, JSON, XML) to make adt-cli outputs pipe-safe.

  • Bug Fixes
    • Write compact and non-compact progress to stderr in createProgressReporter, including persist and done(finalMessage).
    • Route diagnostics to stderr (consoleLogger uses console.error; pretty logger sets destination: 2).
    • Add regression tests to keep stdout clean and document the CLI stream contract.

Written for commit fa4a32d. Summary will update on new commits.

Review in cubic


CodeAnt-AI Description

Keep CLI payload output safe for piping

What Changed

  • CLI progress updates and completion messages now go to stderr instead of stdout
  • stdout remains reserved for source, JSON, XML, and other command payloads
  • Added a regression test to ensure compact progress never writes to stdout
  • Documented the stream contract for source-producing and write commands

Impact

✅ Safe piping of CLI payloads
✅ Clean machine-readable stdout
✅ Progress remains visible without corrupting output

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Bug Fixes

    • Improved command-line output so progress updates, diagnostics, and errors no longer interfere with command results.
    • Source-producing commands can now be reliably piped into corresponding write commands.
    • Updated logging behavior to keep formatted logs and diagnostic messages on the diagnostic stream.
  • Tests

    • Added coverage confirming progress reports are sent to the diagnostic stream while command output remains available for piping.

Route shared CLI progress to stderr so source and structured output can be safely piped into follow-up commands.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@codeant-ai

codeant-ai Bot commented Aug 11, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR ae6856f Aug 11, 2026 · 22:22 22:24

@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for adt-cli canceled.

Name Link
🔨 Latest commit fa4a32d
🔍 Latest deploy log https://app.netlify.com/projects/adt-cli/deploys/6a7ba3782ab5d80008359f09

@codeant-ai

codeant-ai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@baz-reviewer

baz-reviewer Bot commented Aug 11, 2026

Copy link
Copy Markdown

Merger

Waiting for CI and review to complete.

Commit ae6856f · Updated 2026-08-11 22:22 UTC

Review this PR on Baz | Customize your next review

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 208a174b-e339-4bbc-8e9e-aabcff52c18d

📥 Commits

Reviewing files that changed from the base of the PR and between ae6856f and fa4a32d.

📒 Files selected for processing (4)
  • packages/adt-cli/src/lib/shared/adt-client.ts
  • packages/adt-cli/src/lib/utils/logger-config.ts
  • packages/adt-cli/src/lib/utils/progress-reporter.test.ts
  • packages/adt-cli/src/lib/utils/progress-reporter.ts

📝 Walkthrough

Walkthrough

The CLI now reserves stdout for command payloads. Progress output, console diagnostics, and Pino pretty logs use stderr. Tests verify compact progress sequences do not write to stdout.

Changes

CLI stream contract

Layer / File(s) Summary
Define and route CLI streams
.agents/rules/development/coding-conventions.md, packages/adt-cli/src/lib/utils/progress-reporter.ts, packages/adt-cli/src/lib/shared/adt-client.ts, packages/adt-cli/src/lib/utils/logger-config.ts
The CLI documents payload-only stdout. Progress output, console logs, and Pino pretty logs now use stderr.
Verify progress stream separation
packages/adt-cli/src/lib/utils/progress-reporter.test.ts
Vitest spies verify compact step/done, step/persist, and final-message sequences write expected output to stderr without using stdout.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving stdout for pipe-safe CLI payloads.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-payload-streams

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.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes correctly implement the CLI stream contract by routing all progress output to stderr while preserving stdout for command payloads. The implementation is complete across all 5 write locations in the progress reporter, properly tested with an appropriate regression test, and documented with a clear coding convention rule. No blocking issues found.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@codacy-production

codacy-production Bot commented Aug 11, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 7 complexity · 4 duplication

Metric Results
Complexity 7
Duplication 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Comment thread packages/adt-cli/src/lib/utils/progress-reporter.ts
@nx-cloud

nx-cloud Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit ae6856f

Command Status Duration Result
nx affected -t lint test build e2e-ci --verbose... ✅ Succeeded 43s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-11 22:35:58 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/adt-cli/src/lib/utils/progress-reporter.test.ts (1)

17-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the other changed write paths.

This test covers compact step() and done() without a final message. It does not cover persist() or done(finalMessage), which changed in progress-reporter.ts at Lines 80 and 96-99. Add these calls and assert their exact stderr writes.

As per coding guidelines, enforce this contract with a regression test at the shared output/progress abstraction.

Suggested coverage
     reporter.step('Reading source...');
     reporter.done();
+    reporter.persist('Persisted source');
+    reporter.done('Finished');

-    expect(stderr).toHaveBeenCalled();
+    expect(stderr).toHaveBeenCalledWith('Reading source...');
+    expect(stderr).toHaveBeenCalledWith('Persisted source\n');
+    expect(stderr).toHaveBeenCalledWith('Finished\n');
🤖 Prompt for 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.

In `@packages/adt-cli/src/lib/utils/progress-reporter.test.ts` around lines 17 -
25, Add coverage in the compact progress test for the changed persist() and
done(finalMessage) paths on the reporter, asserting the exact stderr writes
produced by each call while retaining the stdout-clean assertion. Use the
existing createProgressReporter setup and verify the shared output contract
without expanding scope beyond these two write paths.

Source: Coding guidelines

🤖 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 `@packages/adt-cli/src/lib/utils/progress-reporter.ts`:
- Around line 80-82: Update persist() so the non-compact path with logger
configured routes progress through a Pino destination bound to stderr rather
than stdout, while preserving the existing compact behavior. Add coverage
verifying that this logger mode writes progress to stderr without mixing it into
command payload output.

---

Nitpick comments:
In `@packages/adt-cli/src/lib/utils/progress-reporter.test.ts`:
- Around line 17-25: Add coverage in the compact progress test for the changed
persist() and done(finalMessage) paths on the reporter, asserting the exact
stderr writes produced by each call while retaining the stdout-clean assertion.
Use the existing createProgressReporter setup and verify the shared output
contract without expanding scope beyond these two write paths.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b7115c21-89b7-434b-b6e7-e95a7ff76335

📥 Commits

Reviewing files that changed from the base of the PR and between f0b9125 and ae6856f.

📒 Files selected for processing (3)
  • .agents/rules/development/coding-conventions.md
  • packages/adt-cli/src/lib/utils/progress-reporter.test.ts
  • packages/adt-cli/src/lib/utils/progress-reporter.ts

Comment thread packages/adt-cli/src/lib/utils/progress-reporter.ts
@devin-ai-integration
devin-ai-integration Bot marked this pull request as draft August 11, 2026 22:29
devin-ai-integration Bot and others added 2 commits August 11, 2026 22:34
Co-Authored-By: Petr Plenkov <petr.plenkov@gmail.com>
Co-Authored-By: Petr Plenkov <petr.plenkov@gmail.com>
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review August 11, 2026 22:37
@ThePlenkov
ThePlenkov merged commit 14114eb into main Aug 11, 2026
26 of 27 checks passed
@ThePlenkov
ThePlenkov deleted the fix/cli-payload-streams branch August 11, 2026 22:38
@gitar-bot

gitar-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

baz: pending size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant