-
Notifications
You must be signed in to change notification settings - Fork 14.9k
JSON output missing when using --command flag with opencode run --format json #2923
Copy link
Copy link
Closed
Description
Summary
I prepare a custom command inside the folder .opencode/command/custom-command.md, but when i try to execute and parse the command with json output there is no log.
custom-command.md
---
description: Create a new story
---
# Task Description
Write a new short story that blends **science fiction** with the world of **Middle-earth**. The setting should remain true to Tolkien’s landscapes, peoples, and cultures, but introduce a futuristic or extraterrestrial element that feels surprising yet coherent with the lore.
## Guidelines
- The story must feature at least one well-known location in Middle-earth (such as Rivendell, Mordor, or the Shire).
- Introduce a speculative sci-fi concept: for example, alien visitors, advanced technology hidden in ancient ruins, time travel, or parallel universes.
- Characters can include familiar figures from Tolkien’s world or original creations, but their actions and dialogue should remain consistent with the tone of Middle-earth.
- Maintain a balance between the mythic, magical tone of Tolkien’s work and the speculative edge of science fiction.
- Running
opencode run --format json "<prompt>"emits JSON-formatted output for each action as expected. - Adding the
--commandflag (e.g.,opencode run --format json --command <command> "<prompt>") removes the JSON output.
Steps to Reproduce
- Execute
opencode run --format json "<prompt>"and observe the JSON-formatted output. - Execute
opencode run --format json --command <command> "<prompt>"using any valid command value.
Expected Result
JSON output should be produced in both scenarios when --format json is specified, regardless of whether the --command flag is provided.
Actual Result
When --command is included, the JSON-formatted output is missing.
example with --format json:
$ opencode run --format json "hi"
# output
{"type":"step_start","timestamp":1759406013703,"sessionID":"ses_65b3acf58ffeLSa4dfj1RVoPpW","part":{"id":"prt_9a4c53d07001NQNfzkhqnUZlfh","messageID":"msg_9a4c53490001kBWON0m2jLIy4g","sessionID":"ses_65b3acf58ffeLSa4dfj1RVoPpW","type":"step-start"}}
{"type":"text","timestamp":1759406015783,"sessionID":"ses_65b3acf58ffeLSa4dfj1RVoPpW","part":{"id":"prt_9a4c543c6001n5L4mB2T3zc0g3","messageID":"msg_9a4c53490001kBWON0m2jLIy4g","sessionID":"ses_65b3acf58ffeLSa4dfj1RVoPpW","type":"text","text":"Hey there! How can I help you today?","time":{"start":1759406015783,"end":1759406015783},"metadata":{"openai":{"itemId":"msg_05be10b018de09130068de67b843b08195b8ae6e9913cfd9f3"}}}}
{"type":"step_finish","timestamp":1759406015885,"sessionID":"ses_65b3acf58ffeLSa4dfj1RVoPpW","part":{"id":"prt_9a4c5458d001YHrRrr76TONTWV","messageID":"msg_9a4c53490001kBWON0m2jLIy4g","sessionID":"ses_65b3acf58ffeLSa4dfj1RVoPpW","type":"step-finish","tokens":{"input":22144,"output":16,"reasoning":0,"cache":{"write":0,"read":22016}},"cost":0}}example with --format json and --command custom-command:
$ opencode run --format json --command "custom-command" "hi"
# output
# no jsonReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels