Skip to content

feat: add --format=md and --format=llm to mr:files and mr:diff#316

Merged
mglaman merged 2 commits intomainfrom
feat/mr-files-diff-llm-md-format
Mar 10, 2026
Merged

feat: add --format=md and --format=llm to mr:files and mr:diff#316
mglaman merged 2 commits intomainfrom
feat/mr-files-diff-llm-md-format

Conversation

@mglaman
Copy link
Owner

@mglaman mglaman commented Mar 10, 2026

Summary

  • Registers MergeRequestFilesResult and MergeRequestDiffResult in AbstractFormatter::format() so the formatter dispatch covers these types
  • Implements formatMergeRequestFiles() and formatMergeRequestDiff() in LlmFormatter (XML with CDATA diff) and MarkdownFormatter (bullet list + fenced diff block)
  • Replaces the manual json_encode branches in GetFiles and GetDiff with $this->writeFormatted(), so all four formats (text, json, md, llm) are handled uniformly
  • Updates --format option descriptions to list all supported values

JsonFormatter required no changes — it serializes any ResultInterface via json_encode.

Closes #312.

Test plan

  • vendor/bin/phpstan analyse src — no errors
  • vendor/bin/phpcs src — no errors
  • vendor/bin/phpunit — all 122 tests pass
  • bin/drupalorg mr:files --format=llm <nid> — emits <drupal_context> XML
  • bin/drupalorg mr:diff --format=llm <nid> — emits <drupal_context> XML with CDATA diff
  • bin/drupalorg mr:files --format=md <nid> — emits Markdown bullet list
  • bin/drupalorg mr:diff --format=md <nid> — emits Markdown with fenced diff block
  • bin/drupalorg mr:files --format=json <nid> — still works
  • bin/drupalorg mr:diff --format=json <nid> — still works

🤖 Generated with Claude Code

mglaman and others added 2 commits March 10, 2026 15:34
Wire MergeRequestFilesResult and MergeRequestDiffResult into the
formatter architecture so mr:files and mr:diff benefit from
LlmFormatter (XML/CDATA output) and MarkdownFormatter alongside the
existing json and text formats.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r:files and mr:diff

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mglaman mglaman merged commit 0a98393 into main Mar 10, 2026
9 checks passed
@mglaman mglaman deleted the feat/mr-files-diff-llm-md-format branch March 10, 2026 20:49
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.

Add --format=llm to MR diff/files

1 participant