Skip to content

fix(cli): write concatenated multi-skill report to --output for non-JSON formats#209

Open
rodboev wants to merge 2 commits into
NVIDIA:mainfrom
rodboev:fix/recursive-multiskill-output-203
Open

fix(cli): write concatenated multi-skill report to --output for non-JSON formats#209
rodboev wants to merge 2 commits into
NVIDIA:mainfrom
rodboev:fix/recursive-multiskill-output-203

Conversation

@rodboev

@rodboev rodboev commented Jun 25, 2026

Copy link
Copy Markdown

Summary

skillspector scan ./skills/ --recursive --format markdown --output report.md prints to stdout instead of writing report.md. The JSON recursive path and single-skill mode both write the file correctly; only the recursive + non-JSON combination silently ignores --output.

Closes #203

Root cause

_scan_multi_skill() (cli.py:434-437) passes None instead of output to _write_result(), so _write_result() routes to stdout unconditionally. A naive None → output substitution would also fail: _write_result calls Path(output).write_text(...) per skill, truncating the file on each call and leaving only the last skill's report.

Diff Notes

  • src/skillspector/cli.py: add private _result_body() helper (extracts report_body or SARIF fallback); refactor _write_result body resolution to use it (no behavior change); rewrite cli.py:434-437 to concatenate per-skill bodies with --- {skill.relative_path} --- separators and write once via Path(output).write_text(); file is always created when -o is given. JSON branch (lines 410-433) and single-skill path (line 321) untouched.
  • tests/unit/test_cli.py: two new tests — one asserts the file is created with both skills' content and stdout is not the destination; one locks the JSON branch behavior.

Scope

No change to the JSON multi-skill branch, single-skill path, _scan_multi_skill() signature, or summary-table stdout output. No new dependencies. Concatenated non-JSON output is not valid SARIF; this matches the issue's Option 1 scope.

Before / After

Invocation Before After
scan ./skills/ --recursive --format markdown --output report.md report.md not created; output to stdout report.md written with per-skill sections
scan ./skills/ --recursive --format json --output combined.json combined.json written (unchanged) combined.json written (unchanged)
scan ./skill --format markdown --output report.md report.md written (unchanged) report.md written (unchanged)

Verification

  • .\.venv\Scripts\python.exe -m pytest tests/unit/test_cli.py -v9 passed, 0 failed (7 pre-existing + 2 new)
  • uv run ruff check src/skillspector/cli.py tests/unit/test_cli.py — exit 0
  • uv run ruff format --check src/skillspector/cli.py tests/unit/test_cli.py — 2 files already formatted, exit 0
  • CI Lint & Test (Python 3.12), Lint & Test (Python 3.13), and DCO Check — pending maintainer approval if fork checks are gated

Notes

DCO sign-off required on every commit (git commit -s). Known existing failures (tests/nodes/test_meta_analyzer.py) are unrelated to this surface.

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.

[BUG] Recursive multi-skill scan ignores a non-JSON --output file and prints to stdout instead

1 participant