Skip to content

Commit 4f67871

Browse files
xiaoju111astdrc
andauthored
fix(tool): prevent TypeScript files from being misidentified as video (#602)
Signed-off-by: Richard Chien <stdrc@outlook.com> Co-authored-by: xiaoju111a <xiaoju111a@users.noreply.github.com> Co-authored-by: Richard Chien <stdrc@outlook.com>
1 parent ce23c36 commit 4f67871

5 files changed

Lines changed: 13 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Only write entries that are worth mentioning to users.
1212
## Unreleased
1313

1414
- Tool: Make `ReadFile` tool description reflect model capabilities for image/video support
15+
- Tool: Fix TypeScript files (`.ts`, `.tsx`, `.mts`, `.cts`) being misidentified as video files
1516
- Shell: Allow slash commands (`/help`, `/exit`, `/version`, `/changelog`, `/feedback`) in shell mode
1617
- Shell: Improve `/help` with fullscreen pager, showing slash commands, skills, and keyboard shortcuts
1718
- Shell: Improve `/changelog` and `/mcp` display with consistent bullet-style formatting

docs/en/release-notes/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This page documents the changes in each Kimi CLI release.
55
## Unreleased
66

77
- Tool: Make `ReadFile` tool description reflect model capabilities for image/video support
8+
- Tool: Fix TypeScript files (`.ts`, `.tsx`, `.mts`, `.cts`) being misidentified as video files
89
- Shell: Allow slash commands (`/help`, `/exit`, `/version`, `/changelog`, `/feedback`) in shell mode
910
- Shell: Improve `/help` with fullscreen pager, showing slash commands, skills, and keyboard shortcuts
1011
- Shell: Improve `/changelog` and `/mcp` display with consistent bullet-style formatting

docs/zh/release-notes/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## 未发布
66

77
- Tool:让 `ReadFile` 工具描述根据模型能力动态反映图片/视频支持情况
8+
- Tool:修复 TypeScript 文件(`.ts``.tsx``.mts``.cts`)被误识别为视频文件的问题
89
- Shell:允许在 Shell 模式下使用部分斜杠命令(`/help``/exit``/version``/changelog``/feedback`
910
- Shell:改进 `/help` 显示,使用全屏分页器,展示斜杠命令、Skills 和键盘快捷键
1011
- Shell:改进 `/changelog``/mcp` 显示,采用一致的项目符号格式

src/kimi_cli/tools/file/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
".m4v": "video/x-m4v",
1919
".3gp": "video/3gpp",
2020
".3g2": "video/3gpp2",
21+
# TypeScript files: override mimetypes default (video/mp2t for MPEG Transport Stream)
22+
".ts": "text/typescript",
23+
".tsx": "text/typescript",
24+
".mts": "text/typescript",
25+
".cts": "text/typescript",
2126
}
2227

2328
for suffix, mime_type in _EXTRA_MIME_TYPES.items():

tests/test_file_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def test_detect_file_type_suffixes():
1111
assert detect_file_type(".env").kind == "text"
1212
assert detect_file_type("archive.tar.gz").kind == "unknown"
1313
assert detect_file_type("my file.pdf").kind == "unknown"
14+
# TypeScript files should not be misidentified as MPEG Transport Stream (video/mp2t)
15+
assert detect_file_type("app.ts").kind == "text"
16+
assert detect_file_type("component.tsx").kind == "text"
17+
assert detect_file_type("module.mts").kind == "text"
18+
assert detect_file_type("common.cts").kind == "text"
1419

1520

1621
def test_detect_file_type_header_overrides():

0 commit comments

Comments
 (0)