Skip to content

feat: community polish — examples, badges, discussions#72

Merged
kienbui1995 merged 1 commit intomainfrom
feat/community-polish
Apr 15, 2026
Merged

feat: community polish — examples, badges, discussions#72
kienbui1995 merged 1 commit intomainfrom
feat/community-polish

Conversation

@kienbui1995
Copy link
Copy Markdown
Owner

@kienbui1995 kienbui1995 commented Apr 15, 2026

Community & Adoption

  • ✅ GitHub Discussions enabled
  • ✅ 4 example scripts (CI fix, batch review, NDJSON streaming, self-hosted config)
  • ✅ README badges (CI, Security, License, Release)
  • ✅ Repo topics for discoverability

Summary by CodeRabbit

  • Documentation

    • Updated README with CI, security, license, and release badges
    • Added "Self-hostable" to project tagline
    • Added a "Via cargo" install instruction (cargo install)
    • Added a self-hosted configuration example
  • New Features

    • Added example scripts for batch review, CI test-fix automation, event streaming, and a demo walkthrough
  • Chores

    • Added package keywords and categories metadata for publication

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

Adds README badges and "Self-hostable" tagline, introduces multiple example scripts and a self-hosted config template, and augments package metadata in mc/Cargo.toml. No library/public API changes.

Changes

Cohort / File(s) Summary
Documentation
README.md
Prepended CI/security/license/release/crates.io badges and appended "Self-hostable" to the introductory tagline; added "Via cargo" install instruction.
Example Scripts
examples/batch-review.sh, examples/ci-fix.sh, examples/stream-events.sh, examples/demo.sh
Added four executable Bash examples: batch prompt batching, CI-driven test/fix flow, NDJSON event streaming parser, and a demo script showing common CLI usages.
Example Configuration
examples/config-selfhosted.toml
New self-hosted example profile using qwen3.5-9b via litellm at http://localhost:4000, with token/memory/managed_agents settings.
Package Metadata
mc/Cargo.toml
Added keywords and categories fields to workspace package metadata (publishing descriptors only).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • release: v1.4.0 #29 — touches mc/Cargo.toml workspace package metadata (version/metadata related).

Poem

🐇 I nibble badges, tidy the readme bright,

I script the tests that wake the night,
Self-hosted dreams on localhost grown,
Batch and stream — small seeds I've sown,
Hop, fix, and ship — a rabbit's delight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It omits required template sections: 'What', 'Why', 'How', and the validation checklist are all missing. Fill in all required sections from the template: add detailed 'What' (summary), 'Why' (motivation), 'How' (implementation details), and complete the checklist with test/lint results.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the main change: community-focused polish including examples, badges, and discussions support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ 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 feat/community-polish

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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several example scripts and a self-hosted configuration file to demonstrate the capabilities of magic-code, alongside updating the README with project status badges. The review feedback highlights several opportunities to improve the robustness of these examples, such as using trap for temporary file cleanup, avoiding brittle output parsing with tail, and ensuring correct flag usage for headless CI environments. Additionally, there are suggestions to resolve a conflict between set -e and manual exit status checks and to fix a documentation mismatch in the streaming example.

set -e

echo "Running tests..."
if cargo test --workspace 2>&1 | tail -5 | grep -q "FAILED"; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Restricting the failure check to the last 5 lines of output using tail -5 is brittle. If the "FAILED" indicator is pushed further up by other output, grep will fail, and the script will incorrectly report "All tests pass." despite the actual failure. This could lead to false positives in CI.

Suggested change
if cargo test --workspace 2>&1 | tail -5 | grep -q "FAILED"; then
if cargo test --workspace 2>&1 | grep -q "FAILED"; then

# Batch code review: review multiple files
# Usage: ./batch-review.sh src/*.rs

TMPFILE=$(mktemp)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The temporary file created with mktemp is not cleaned up if the script is interrupted (e.g., via Ctrl+C) or fails before reaching the explicit rm command. It is safer to use a trap to ensure the file is removed upon exit.

Suggested change
TMPFILE=$(mktemp)
TMPFILE=$(mktemp)
trap 'rm -f "$TMPFILE"' EXIT

#!/bin/bash
# CI/CD: Auto-fix failing tests with magic-code
# Usage: ./ci-fix.sh
set -e
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using set -e in combination with manual exit status checks (like if [ $? -eq 0 ] on line 13) can lead to unexpected behavior. If magic-code fails, the script will terminate immediately at line 11, making the else block on line 16 unreachable. It is generally better to avoid set -e when you intend to handle errors manually.

echo "Running tests..."
if cargo test --workspace 2>&1 | tail -5 | grep -q "FAILED"; then
echo "Tests failed. Asking magic-code to fix..."
magic-code --yes --json \
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

In an automated CI/CD context, the bash tool will still prompt for user confirmation unless the --dangerously-allow-bash flag is provided, even if --yes is used. To ensure the script runs headlessly as intended, you should include this flag.

Suggested change
magic-code --yes --json \
magic-code --yes --dangerously-allow-bash --json \

@@ -0,0 +1,15 @@
#!/bin/bash
# NDJSON streaming: pipe magic-code events to a web app
# Usage: ./stream-to-webapp.sh "your prompt"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The usage example in the comment refers to a different filename (stream-to-webapp.sh) than the actual file (stream-events.sh).

Suggested change
# Usage: ./stream-to-webapp.sh "your prompt"
# Usage: ./stream-events.sh "your prompt"

1. GitHub Discussions enabled
2. Examples directory:
   - ci-fix.sh: auto-fix failing tests in CI
   - batch-review.sh: review multiple files
   - stream-events.sh: NDJSON streaming to web app
   - config-selfhosted.toml: Qwen 3.5 via LiteLLM config
3. README badges: CI, Security, License, Release
4. Repo topics: ai, coding-agent, rust, tui, self-hosted, etc.
@kienbui1995 kienbui1995 force-pushed the feat/community-polish branch from 134276c to 1ba8252 Compare April 15, 2026 04:22
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
examples/ci-fix.sh (1)

6-22: Consider adding clippy to mirror the project’s pre-commit quality gate.

This example validates tests only; adding cargo clippy --workspace --all-targets would catch additional CI failures earlier.

Based on learnings, "Run cargo test --workspace && cargo clippy --workspace --all-targets before committing".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/ci-fix.sh` around lines 6 - 22, Add a cargo clippy check to the CI
script so linting mirrors the project's pre-commit gate: run "cargo test
--workspace && cargo clippy --workspace --all-targets" (or run clippy
immediately after the initial cargo test) before invoking magic-code; update the
conditional logic around the existing cargo test invocation (the block using
"cargo test --workspace 2>&1 | tail -5 | grep -q 'FAILED'" and the subsequent
magic-code call) to consider clippy failures the same as test failures (capture
clippy's exit status and treat non-zero as a failure to trigger the fix flow or
to fail CI).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/batch-review.sh`:
- Around line 5-11: The script currently creates TMPFILE with mktemp and writes
to it without ensuring cleanup on failure or interruption and allows running
with zero args; add a strict shell header (set -euo pipefail) and an early
argument guard that exits with a usage message if "$#" is zero, replace echo
with printf for portability when writing the per-file review prompts to TMPFILE,
and register a trap 'trap "rm -f \"$TMPFILE\"" EXIT' immediately after creating
TMPFILE so the temp file is removed on any exit; update references to TMPFILE
and the magic-code --yes --json --batch "$TMPFILE" invocation accordingly.

In `@examples/ci-fix.sh`:
- Around line 7-19: Capture cargo test's exit status and output instead of
relying on tail+grep and make magic-code failure reachable by not letting set -e
short-circuit; specifically, run cargo test --workspace with its stdout/stderr
redirected into a variable/file (e.g., test_output="$(cargo test --workspace
2>&1)" and test_exit=$?), then inspect test_exit (and optionally grep
"$test_output" for "FAILED") to decide whether to invoke magic-code; likewise
run magic-code in a way that preserves its exit code (e.g., magic-code ... -o
fix-result.json; magic_exit=$?) and branch on magic_exit to either re-run cargo
test or print the failure message and exit non-zero, updating the script's cargo
test / magic-code checks instead of relying on tail/grep and unsettable set -e
behavior.

In `@examples/config-selfhosted.toml`:
- Around line 4-9: The TOML example places provider-level key "base_url" and
runtime-level key "notifications" under the [default] section, but DefaultLayer
(mc/crates/mc-config/src/types.rs) does not accept those keys so they will be
ignored; move "provider" and "base_url" into the provider-specific section
(e.g., [providers.litellm] or whatever provider block your config uses) and move
"notifications" into the runtime or top-level section that the config expects
(e.g., [runtime] or the top-level flags) so the self-hosted example actually
applies to localhost:4000 and enables/disables notifications correctly. Ensure
keys remain named exactly "base_url" and "notifications" and reference the same
provider name "litellm" used in the [default] model mapping.

In `@examples/stream-events.sh`:
- Around line 3-5: Update the usage message in examples/stream-events.sh to
reference the correct script name "stream-events.sh" and add a check for the
prompt argument ($1) before calling magic-code; if $1 is empty or missing, print
the corrected usage string and exit with a non-zero status. Specifically, adjust
the header line that currently mentions "stream-to-webapp.sh" to
"stream-events.sh", validate $1 (the prompt) at the top of the script, and only
run the pipeline magic-code --yes --ndjson "$1" | while IFS= read -r line; do
when the argument is present.

---

Nitpick comments:
In `@examples/ci-fix.sh`:
- Around line 6-22: Add a cargo clippy check to the CI script so linting mirrors
the project's pre-commit gate: run "cargo test --workspace && cargo clippy
--workspace --all-targets" (or run clippy immediately after the initial cargo
test) before invoking magic-code; update the conditional logic around the
existing cargo test invocation (the block using "cargo test --workspace 2>&1 |
tail -5 | grep -q 'FAILED'" and the subsequent magic-code call) to consider
clippy failures the same as test failures (capture clippy's exit status and
treat non-zero as a failure to trigger the fix flow or to fail CI).
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b1a11d7-73b8-4b1e-9b48-108810892429

📥 Commits

Reviewing files that changed from the base of the PR and between aed3d81 and 134276c.

📒 Files selected for processing (5)
  • README.md
  • examples/batch-review.sh
  • examples/ci-fix.sh
  • examples/config-selfhosted.toml
  • examples/stream-events.sh

Comment on lines +5 to +11
TMPFILE=$(mktemp)
for file in "$@"; do
echo "Review $file for bugs, security issues, and improvements. Be specific about line numbers." >> "$TMPFILE"
done

magic-code --yes --json --batch "$TMPFILE"
rm "$TMPFILE"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if the file exists and examine its full contents
find . -name "batch-review.sh" -type f

Repository: kienbui1995/mc-code

Length of output: 89


🏁 Script executed:

# If file exists, read its full contents
cat examples/batch-review.sh 2>/dev/null || echo "File not found"

Repository: kienbui1995/mc-code

Length of output: 371


🏁 Script executed:

# Verify the script's current state matches the snippet
wc -l examples/batch-review.sh 2>/dev/null || echo "Cannot determine line count"

Repository: kienbui1995/mc-code

Length of output: 90


Harden temp-file lifecycle and empty-args behavior.

The script creates a temp file without cleanup on failure or interruption, and silently accepts zero arguments, creating an empty batch file. Add an EXIT trap for cleanup, set -euo pipefail for safety, an argument guard, and use printf for portability.

Suggested patch
 #!/bin/bash
 # Batch code review: review multiple files
 # Usage: ./batch-review.sh src/*.rs
+set -euo pipefail
+
+if [ "$#" -eq 0 ]; then
+    echo "Usage: ./batch-review.sh <files...>" >&2
+    exit 2
+fi
 
 TMPFILE=$(mktemp)
+trap 'rm -f "$TMPFILE"' EXIT
 for file in "$@"; do
-    echo "Review $file for bugs, security issues, and improvements. Be specific about line numbers." >> "$TMPFILE"
+    printf 'Review %s for bugs, security issues, and improvements. Be specific about line numbers.\n' "$file" >> "$TMPFILE"
 done
 
 magic-code --yes --json --batch "$TMPFILE"
-rm "$TMPFILE"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/batch-review.sh` around lines 5 - 11, The script currently creates
TMPFILE with mktemp and writes to it without ensuring cleanup on failure or
interruption and allows running with zero args; add a strict shell header (set
-euo pipefail) and an early argument guard that exits with a usage message if
"$#" is zero, replace echo with printf for portability when writing the per-file
review prompts to TMPFILE, and register a trap 'trap "rm -f \"$TMPFILE\"" EXIT'
immediately after creating TMPFILE so the temp file is removed on any exit;
update references to TMPFILE and the magic-code --yes --json --batch "$TMPFILE"
invocation accordingly.

Comment on lines +7 to +19
if cargo test --workspace 2>&1 | tail -5 | grep -q "FAILED"; then
echo "Tests failed. Asking magic-code to fix..."
magic-code --yes --json \
"The tests are failing. Read the test output, find the bug, and fix it. Run tests again to verify." \
-o fix-result.json

if [ $? -eq 0 ]; then
echo "Fix applied. Re-running tests..."
cargo test --workspace
else
echo "magic-code could not fix the issue."
exit 1
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n examples/ci-fix.sh

Repository: kienbui1995/mc-code

Length of output: 842


Failure detection via pipeline loses cargo test exit code; $? check is dead code due to set -e.

The pipeline on line 7 loses the cargo test exit code. If tests fail without "FAILED" appearing in the last 5 lines, the condition evaluates false and the else block incorrectly reports success. Additionally, with set -e active, the else block (lines 16–18) is unreachable—if magic-code fails, the script exits immediately rather than executing that branch.

Suggested patch
 echo "Running tests..."
-if cargo test --workspace 2>&1 | tail -5 | grep -q "FAILED"; then
+TEST_LOG=$(mktemp)
+trap 'rm -f "$TEST_LOG"' EXIT
+
+if ! cargo test --workspace >"$TEST_LOG" 2>&1; then
     echo "Tests failed. Asking magic-code to fix..."
-    magic-code --yes --json \
-        "The tests are failing. Read the test output, find the bug, and fix it. Run tests again to verify." \
-        -o fix-result.json
-    
-    if [ $? -eq 0 ]; then
+    if magic-code --yes --json \
+        "The tests are failing. Use this test output to find and fix the bug:
+$(tail -n 200 "$TEST_LOG")
+Run tests again to verify." \
+        -o fix-result.json; then
         echo "Fix applied. Re-running tests..."
         cargo test --workspace
     else
         echo "magic-code could not fix the issue."
         exit 1
     fi
 else
     echo "All tests pass."
 fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[style] 13-13: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

(SC2181)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/ci-fix.sh` around lines 7 - 19, Capture cargo test's exit status and
output instead of relying on tail+grep and make magic-code failure reachable by
not letting set -e short-circuit; specifically, run cargo test --workspace with
its stdout/stderr redirected into a variable/file (e.g., test_output="$(cargo
test --workspace 2>&1)" and test_exit=$?), then inspect test_exit (and
optionally grep "$test_output" for "FAILED") to decide whether to invoke
magic-code; likewise run magic-code in a way that preserves its exit code (e.g.,
magic-code ... -o fix-result.json; magic_exit=$?) and branch on magic_exit to
either re-run cargo test or print the failure message and exit non-zero,
updating the script's cargo test / magic-code checks instead of relying on
tail/grep and unsettable set -e behavior.

Comment on lines +4 to +9
[default]
model = "qwen3.5-9b"
provider = "litellm"
base_url = "http://localhost:4000"
max_tokens = 4096
notifications = false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

base_url and notifications look scoped to the wrong section.

DefaultLayer (from mc/crates/mc-config/src/types.rs) does not define these keys, so placing them under [default] risks silently ignoring them. Please move provider-level and runtime-level keys to their supported sections so this self-hosted example actually targets localhost:4000.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/config-selfhosted.toml` around lines 4 - 9, The TOML example places
provider-level key "base_url" and runtime-level key "notifications" under the
[default] section, but DefaultLayer (mc/crates/mc-config/src/types.rs) does not
accept those keys so they will be ignored; move "provider" and "base_url" into
the provider-specific section (e.g., [providers.litellm] or whatever provider
block your config uses) and move "notifications" into the runtime or top-level
section that the config expects (e.g., [runtime] or the top-level flags) so the
self-hosted example actually applies to localhost:4000 and enables/disables
notifications correctly. Ensure keys remain named exactly "base_url" and
"notifications" and reference the same provider name "litellm" used in the
[default] model mapping.

Comment on lines +3 to +5
# Usage: ./stream-to-webapp.sh "your prompt"

magic-code --yes --ndjson "$1" | while IFS= read -r line; do
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, check if examples/stream-events.sh exists and read its content
cat -n examples/stream-events.sh

Repository: kienbui1995/mc-code

Length of output: 676


🏁 Script executed:

# Check if stream-to-webapp.sh exists
fd -a "stream-to-webapp" examples/

Repository: kienbui1995/mc-code

Length of output: 45


🏁 Script executed:

# List all files in examples directory to understand the structure
ls -la examples/

Repository: kienbui1995/mc-code

Length of output: 430


Fix usage string and validate prompt input.

The usage line references a non-existent script name stream-to-webapp.sh instead of the actual script name stream-events.sh, and $1 is used without an argument check. Users calling this script without arguments will pass an empty string to magic-code.

Suggested patch
 #!/bin/bash
 # NDJSON streaming: pipe magic-code events to a web app
-# Usage: ./stream-to-webapp.sh "your prompt"
+# Usage: ./stream-events.sh "your prompt"
+set -euo pipefail
+
+if [ "$#" -lt 1 ]; then
+    echo 'Usage: ./stream-events.sh "your prompt"' >&2
+    exit 2
+fi
 
 magic-code --yes --ndjson "$1" | while IFS= read -r line; do
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/stream-events.sh` around lines 3 - 5, Update the usage message in
examples/stream-events.sh to reference the correct script name
"stream-events.sh" and add a check for the prompt argument ($1) before calling
magic-code; if $1 is empty or missing, print the corrected usage string and exit
with a non-zero status. Specifically, adjust the header line that currently
mentions "stream-to-webapp.sh" to "stream-events.sh", validate $1 (the prompt)
at the top of the script, and only run the pipeline magic-code --yes --ndjson
"$1" | while IFS= read -r line; do when the argument is present.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
examples/ci-fix.sh (1)

7-19: ⚠️ Potential issue | 🟠 Major

Fix test-failure detection and unreachable magic-code failure branch.

Current control flow can miss failing tests and incorrectly print “All tests pass.” Also, with set -e, a failing magic-code exits before the $? branch runs, so Lines 16–18 won’t execute as intended.

Suggested patch
 echo "Running tests..."
-if cargo test --workspace 2>&1 | tail -5 | grep -q "FAILED"; then
+TEST_LOG="$(mktemp)"
+trap 'rm -f "$TEST_LOG"' EXIT
+
+if ! cargo test --workspace >"$TEST_LOG" 2>&1; then
     echo "Tests failed. Asking magic-code to fix..."
-    magic-code --yes --json \
-        "The tests are failing. Read the test output, find the bug, and fix it. Run tests again to verify." \
-        -o fix-result.json
-    
-    if [ $? -eq 0 ]; then
+    if magic-code --yes --json \
+        "The tests are failing. Use this output to find and fix the bug:
+$(tail -n 200 "$TEST_LOG")
+Run tests again to verify."; then
         echo "Fix applied. Re-running tests..."
         cargo test --workspace
     else
         echo "magic-code could not fix the issue."
         exit 1
     fi
 else
     echo "All tests pass."
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/ci-fix.sh` around lines 7 - 19, Detect failing tests reliably by
avoiding losing exit status through pipes and by handling magic-code failures
when set -e is enabled: run cargo test --workspace 2>&1 | tee test-output and
then check grep -q "FAILED" test-output (or enable set -o pipefail before the
pipe) instead of relying on piped exit status, and invoke magic-code in a safe
way that captures its exit code (e.g., temporarily disable errexit with set +e;
run magic-code --yes --json ... -o fix-result.json; rc=$?; set -e; then test rc
with if [ $rc -eq 0 ]; then ...) so the "magic-code could not fix" branch
executes correctly when magic-code fails; refer to the cargo test invocation,
the magic-code call, and usage of $?/rc in the script to locate where to change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/ci-fix.sh`:
- Around line 9-11: The CLI currently prints JSON and returns early when the
--json flag is set, which prevents the -o output-file logic from running; update
the command handling so that when both --json and -o are provided the JSON is
written to the specified file instead of (or in addition to) only printing to
stdout. Change the handler that prints JSON to either: a) write the JSON string
to the path from the -o option before returning, or b) skip the early return and
funnel the same JSON payload into the existing file-write routine used by the -o
branch; ensure you reference the --json flag handling and the -o output-file
logic so both paths produce the artifact.

---

Duplicate comments:
In `@examples/ci-fix.sh`:
- Around line 7-19: Detect failing tests reliably by avoiding losing exit status
through pipes and by handling magic-code failures when set -e is enabled: run
cargo test --workspace 2>&1 | tee test-output and then check grep -q "FAILED"
test-output (or enable set -o pipefail before the pipe) instead of relying on
piped exit status, and invoke magic-code in a safe way that captures its exit
code (e.g., temporarily disable errexit with set +e; run magic-code --yes --json
... -o fix-result.json; rc=$?; set -e; then test rc with if [ $rc -eq 0 ]; then
...) so the "magic-code could not fix" branch executes correctly when magic-code
fails; refer to the cargo test invocation, the magic-code call, and usage of
$?/rc in the script to locate where to change.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: b6138c32-cdbc-4750-92bd-8467aa24af5c

📥 Commits

Reviewing files that changed from the base of the PR and between 134276c and 1ba8252.

📒 Files selected for processing (7)
  • README.md
  • examples/batch-review.sh
  • examples/ci-fix.sh
  • examples/config-selfhosted.toml
  • examples/demo.sh
  • examples/stream-events.sh
  • mc/Cargo.toml
✅ Files skipped from review due to trivial changes (5)
  • README.md
  • mc/Cargo.toml
  • examples/config-selfhosted.toml
  • examples/demo.sh
  • examples/stream-events.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/batch-review.sh

Comment on lines +9 to +11
magic-code --yes --json \
"The tests are failing. Read the test output, find the bug, and fix it. Run tests again to verify." \
-o fix-result.json
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify `--json` return path occurs before `-o` output write handling.
rg -n -C4 'if json_output|if let Some\(path\) = output_path|return Ok\(\);' mc/crates/mc-cli/src/main.rs

Repository: kienbui1995/mc-code

Length of output: 726


--json bypasses -o output file creation due to early return.

The function returns at line 1722 after printing JSON output, before reaching the -o file-write logic at lines 1724-1726. Using both --json and -o together will silently ignore the output file flag. Redirect stdout or drop --json if an artifact is required.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/ci-fix.sh` around lines 9 - 11, The CLI currently prints JSON and
returns early when the --json flag is set, which prevents the -o output-file
logic from running; update the command handling so that when both --json and -o
are provided the JSON is written to the specified file instead of (or in
addition to) only printing to stdout. Change the handler that prints JSON to
either: a) write the JSON string to the path from the -o option before
returning, or b) skip the early return and funnel the same JSON payload into the
existing file-write routine used by the -o branch; ensure you reference the
--json flag handling and the -o output-file logic so both paths produce the
artifact.

@kienbui1995 kienbui1995 merged commit c3b9e9f into main Apr 15, 2026
16 checks passed
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