Skip to content

Conversation

@stdrc
Copy link
Collaborator

@stdrc stdrc commented Jan 21, 2026

Summary

SVG files are XML-based text files that can be directly read and understood by the agent. Previously, they were classified as image type, which prevented the agent from reading their content as text.

Changes

  • Move .svg from _IMAGE_MIME_BY_SUFFIX to a new _TEXT_MIME_BY_SUFFIX dictionary
  • Update detect_file_type() to check text MIME types first
  • Add test case for SVG file type detection

Why

Since SVG is a text-based vector graphics format, treating it as text allows the agent to:

  • Read and analyze SVG content directly
  • Make modifications to SVG files
  • Understand the structure and elements within SVG files

Open with Devin

stdrc added 3 commits January 21, 2026 22:11
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Copilot AI review requested due to automatic review settings January 21, 2026 14:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes how SVG files are classified by the file type detection system, treating them as text instead of images to enable the agent to read and modify their XML-based content directly.

Changes:

  • Moved .svg extension from _IMAGE_MIME_BY_SUFFIX to a new _TEXT_MIME_BY_SUFFIX dictionary
  • Updated detect_file_type() to prioritize text MIME type checks before image checks
  • Added test coverage for SVG text classification

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/kimi_cli/tools/file/utils.py Introduces _TEXT_MIME_BY_SUFFIX dictionary with .svg entry and updates detection logic to check text types first
tests/test_file_utils.py Adds test case to verify .svg files are classified as text type
CHANGELOG.md Documents the SVG classification change
docs/en/release-notes/changelog.md Documents the SVG classification change (English)
docs/zh/release-notes/changelog.md Documents the SVG classification change (Chinese)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +55 to +57
_TEXT_MIME_BY_SUFFIX = {
".svg": "image/svg+xml",
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with how other media types are handled in this codebase (e.g., .avif, .heic, .mkv are both in _EXTRA_MIME_TYPES and their respective suffix dictionaries), consider also adding .svg to _EXTRA_MIME_TYPES. This ensures the MIME type is registered globally with the mimetypes module, matching the pattern used for other formats.

Copilot uses AI. Check for mistakes.
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional flags.

Open in Devin Review

@stdrc stdrc merged commit 228a418 into main Jan 22, 2026
19 checks passed
@stdrc stdrc deleted the rc/svg-as-text branch January 22, 2026 09:14
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.

2 participants