fix: inline --json-schema file paths so structured output works on CLI 2.1.160 (closes #3)
The docs recommend the file-path form (`--json-schema /path/to/schema.json`) as primary, but the default-pinned Claude CLI 2.1.160 only accepts an inline JSON string. Passing a path makes the CLI exit 0 with empty output, so the action's fail-loud branch trips on every run. Resolve the value before spawning the CLI: a file-path schema is read in-process and passed inline (validated + compacted), while an already-inline schema is left untouched. Because the value is handed to spawn() as an argv element (never through a shell), a schema with `$ref`/`$defs` round-trips intact. Unreadable files and invalid JSON now fail with a clear error instead of the CLI's silent empty output. Docs (README, example workflow, action.yml) are corrected to explain that the file-path form is auto-inlined and works on the default CLI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
#
|
||||
# Instead of having the agent write its verdict to a file, this asks Claude for a
|
||||
# result that conforms to a JSON Schema and reads it back from the action output.
|
||||
# Requires a Claude CLI new enough to support `--json-schema` (see README →
|
||||
# "Structured output"). If you consume this action through a pre-baked runner
|
||||
# image (path_to_claude_code_executable), that image's CLI must be bumped too.
|
||||
# The default-installed Claude CLI (2.1.160) supports `--json-schema`; the
|
||||
# action reads the schema file below and passes it to the CLI inline, so the
|
||||
# file-path form works out of the box (see README → "Structured output"). If
|
||||
# you consume this action through a pre-baked runner image
|
||||
# (path_to_claude_code_executable), that image's CLI must still support the
|
||||
# `--json-schema` flag.
|
||||
|
||||
name: Claude PR Review (structured output)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user