opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(opencode): add markdown output to export command

Open molloyzak13 opened this issue 5 months ago • 2 comments

Issue for this PR

Closes #9387

Type of change

  • [x] New feature

What does this PR do?

opencode export only emitted JSON. This adds -f/--format json|markdown and -o/--output <file>, so a session can be saved as a readable Markdown transcript instead of only JSON. The default stays json, so existing usage and scripts are unchanged. The markdown path walks the v1 part union (text, reasoning, tool) and writes a session-header table plus each turn. It also removes a MessageV2 import in the same file that was already unused.

How did you verify your code works?

Built the CLI (packages/opencode/script/build.ts --single) and ran the binary against a real session: export <id> -f markdown (stdout), -f markdown -o <file> (writes the file), and plain export <id> to confirm the JSON output is byte-for-byte unchanged. tsc --noEmit is clean.

Screenshots / recordings

Not a UI change (CLI output).

Checklist

  • [x] I have tested my changes locally
  • [x] I have not included unrelated changes in this PR

molloyzak13 avatar Jun 14 '26 03:06 molloyzak13

Thanks for updating your PR! It now meets our contributing guidelines. :+1:

github-actions[bot] avatar Jun 14 '26 04:06 github-actions[bot]

Small heads-up on the diff: I also dropped the MessageV2 import on line 3. It was already unused before this PR — once I edited the file the typecheck flagged it as dead, so I cleaned it up rather than leave it sitting there. It is a one-liner and unrelated to the markdown logic, so if you would rather this PR stay purely additive I am happy to pull it into a separate change.

molloyzak13 avatar Jun 14 '26 04:06 molloyzak13

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

github-actions[bot] avatar Jul 14 '26 22:07 github-actions[bot]