Skip to content

fix(tool): prevent TypeScript files from being misidentified as video#602

Merged
stdrc merged 4 commits into
MoonshotAI:mainfrom
xiaoju111a:fix/ts-file-type-detection
Jan 12, 2026
Merged

fix(tool): prevent TypeScript files from being misidentified as video#602
stdrc merged 4 commits into
MoonshotAI:mainfrom
xiaoju111a:fix/ts-file-type-detection

Conversation

@xiaoju111a

Copy link
Copy Markdown
Contributor

Summary

Fix TypeScript files (.ts, .tsx, .mts, .cts) being misidentified as MPEG Transport Stream video files, which caused ReadFile to return VideoURLPart and trigger video_in capability check failure.

Resolves #601

Problem

Python's mimetypes.guess_type() maps .ts extension to video/mp2t (MPEG Transport Stream), not TypeScript. This caused:

  1. detect_file_type("app.ts") returns kind="video"
  2. ReadFile wraps content as VideoURLPart
  3. Model capability check fails if video_in is not enabled

Solution

Override the default mimetypes mapping by registering TypeScript extensions with text/typescript MIME type in _EXTRA_MIME_TYPES.

Changes

  • src/kimi_cli/tools/file/utils.py: Add .ts, .tsx, .mts, .cts to _EXTRA_MIME_TYPES
  • tests/test_file_utils.py: Add test cases for TypeScript file detection

@xiaoju111a xiaoju111a closed this Jan 12, 2026
Signed-off-by: Richard Chien <stdrc@outlook.com>
@stdrc stdrc reopened this Jan 12, 2026
@stdrc
stdrc merged commit 4f67871 into MoonshotAI:main Jan 12, 2026
8 checks passed
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