Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ skillspector scan ./my-skill/ --format markdown --output report.md
skillspector scan ./my-skill/ --format sarif --output report.sarif
```

Use repeatable `--report FORMAT=PATH` options to write additional file reports
from the same scan results. `--format` and `--output` still select the primary
report (stdout when `--output` is omitted). Each destination must be distinct;
additional reports do not support `PATH=-`.

```bash
skillspector scan ./my-skill/ --format json --output report.json \
--report markdown=report.md --report sarif=report.sarif
skillspector scan ./my-skills/ --recursive --no-llm \
--report json=collection.json --report markdown=collection.md
python -m contrib.batch_scan.batch_scan ./my-skills/ --no-llm \
--report json=batch.json --report markdown=batch.md
```

Batch reports support terminal, JSON, and Markdown; registry scans remain
JSON-only. Additional outputs do not rerun analyzers or change scan limits.

### Recursive Collection Scanning

`--recursive` scans immediate subdirectories containing `SKILL.md` as independent
Expand Down
32 changes: 31 additions & 1 deletion contrib/batch_scan/batch_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

from skillspector.file_output import require_secure_file_output, write_text_no_follow
from skillspector.logging_config import set_level
from skillspector.report_outputs import parse_reports

from .api_pool import create_api_key_pool_from_env
from .discovery import discover_skills
Expand Down Expand Up @@ -315,6 +316,12 @@ def _main_impl() -> None:
default=None,
help="Write report to FILE (default: stdout).",
)
parser.add_argument(
"--report",
action="append",
metavar="FORMAT=PATH",
help="Additional file report (repeatable): terminal, json, markdown.",
)
parser.add_argument(
"--no-llm",
action="store_true",
Expand Down Expand Up @@ -357,6 +364,10 @@ def _main_impl() -> None:
help="Allow non-English scans without LLM (results will be incomplete).",
)
args = parser.parse_args()
try:
reports = parse_reports(args.report, ("terminal", "json", "markdown"), args.output)
except ValueError as exc:
parser.error(str(exc))

# Structured reports must not share stdout with progress or diagnostics.
progress_file = sys.stdout if args.format == "terminal" else sys.stderr
Expand All @@ -375,7 +386,7 @@ def _print(*args: object, **kwargs: object) -> None:
else:
print(" ".join(str(a) for a in args), file=file) # type: ignore[arg-type]

if args.output:
if args.output or reports:
try:
require_secure_file_output()
except ValueError as exc:
Expand All @@ -391,6 +402,11 @@ def _print(*args: object, **kwargs: object) -> None:
_print(f"[red]Error:[/red] {display(root)} is not a directory", file=sys.stderr)
sys.exit(2)

for _, destination in reports:
if destination.exists() and destination.resolve().is_relative_to(root):
_print("Error: --report must not overwrite a batch input.", file=sys.stderr)
sys.exit(2)

skill_dirs = discover_skills(root)
if not skill_dirs:
_print(
Expand Down Expand Up @@ -547,6 +563,20 @@ def _print(*args: object, **kwargs: object) -> None:
else:
sys.stdout.write(report_body + "\n")

formatters = {
"terminal": format_terminal,
"json": format_json,
"markdown": format_markdown,
}
for report_format, destination in reports:
try:
body = report_body if report_format == fmt else formatters[report_format](results)
write_text_no_follow(destination, body)
except (OSError, ValueError) as exc:
_print(f"Error: {exc}", markup=False, file=sys.stderr)
sys.exit(2)
_print(f"Batch report saved to: {display(destination)}", file=sys.stderr)

# -- Exit codes ----------------------------------------------------------
if errors:
sys.exit(2)
Expand Down
Loading
Loading