[Bug] Session Markdown export corrupts YAML frontmatter for workspace paths containing # or colon-space
Maintainer thường phản hồi trong vòng 1 ngày
@rishibalanagu0108 đang làm issue này rồi.
Từ ngày 2/11/2026.
- #4622 của @rishibalanagu0108 — đang mở
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript, yaml
- Lĩnh vực
- cli
Hướng nghiên cứu
Phép nội suy work_dir không được escape nằm trong bộ tạo frontmatter tại apps/vscode/src/utils/session-context.ts (buildExportMarkdown, khoảng dòng 34-41) và trong apps/kimi-code/src/tui/utils/export-markdown.ts (khoảng dòng 230-240). Bắt đầu với script tái hiện lỗi trong issue, script này sẽ cho thấy ba đường dẫn đều bị phân tích sai. Hoàn thành khi frontmatter của mỗi trình xuất, khi phân tích lại, cho đúng đường dẫn gốc với '/tmp/Project #1', '/tmp/Project: Demo' và một đường dẫn thông thường, và các trường hợp hồi quy được thêm vào apps/kimi-code/test/tui/export-markdown.test.ts.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What version of Kimi Code is running?
Source checkout at a2afdbc7d1fa0737d45d5780cc6c2bd38e477b55. Both affected files also match the upstream default-branch blobs fetched on 2026-11-01.
Verified by directly executing the VS Code Markdown formatter and parsing its output. This was not reproduced through an installed CLI release or a running VS Code extension.
Which open platform/subscription were you using?
N/A — local Markdown formatting; no authentication or model request is involved.
Which model were you using?
N/A.
What platform is your computer?
macOS, Darwin 24.6.0, arm64. Formatter check: Node.js 24.22.1. YAML parser: Ruby Psych 3.1.0.
The directory names below were successfully created on the local filesystem.
What issue are you seeing?
Session Markdown exports interpolate the workspace path into YAML frontmatter without quoting or escaping it. Certain valid directory names therefore corrupt the exported metadata:
| Workspace path (illustrative parent directory) | Parsed work_dir |
|---|---|
/tmp/Project |
/tmp/Project |
/tmp/Project #1 |
/tmp/Project — silently truncated |
/tmp/Project: Demo |
YAML syntax error |
For example:
---
work_dir: /tmp/Project #1
---
Here #1 becomes a YAML comment. With work_dir: /tmp/Project: Demo, Psych raises:
Psych::SyntaxError: mapping values are not allowed in this context
The Markdown file can still be written successfully. The failure affects downstream frontmatter consumers: they receive a wrong workspace path or cannot parse the metadata.
Both implementations contain the same unescaped interpolation:
Their export handlers pass the workspace path directly to these formatters.
What steps can reproduce the bug?
The following minimal check calls the actual VS Code formatter from the repository root, with Node.js 24.15+ and Ruby available. The resolution hook only supplies the .ts extension for the formatter's relative helper import.
node --input-type=module > /tmp/kimi-export-frontmatter.jsonl <<'JS'
import { registerHooks } from 'node:module';
registerHooks({
resolve(specifier, context, nextResolve) {
return nextResolve(
specifier === './hook-parts' ? './hook-parts.ts' : specifier,
context,
);
},
});
const { buildExportMarkdown } =
await import('./apps/vscode/src/utils/session-context.ts');
for (const workDir of ['/tmp/Project', '/tmp/Project #1', '/tmp/Project: Demo']) {
const markdown = buildExportMarkdown({
sessionId: '00000000-0000-4000-8000-000000000001',
workDir,
history: [
{ role: 'user', content: [{ type: 'text', text: 'Hello' }], toolCalls: [] },
],
tokenCount: 1,
now: new Date('2026-11-01T00:00:00.000Z'),
});
console.log(JSON.stringify({ workDir, yaml: markdown.split('---')[1] }));
}
JS
ruby -rjson -rpsych <<'RUBY'
File.foreach('/tmp/kimi-export-frontmatter.jsonl') do |line|
row = JSON.parse(line)
begin
parsed = Psych.safe_load(row.fetch('yaml'), permitted_classes: [Time])
puts "#{row.fetch('workDir').inspect} => #{parsed.fetch('work_dir').inspect}"
rescue Psych::SyntaxError => error
puts "#{row.fetch('workDir').inspect} => #{error.class}: #{error.problem}"
end
end
RUBY
Expected observed output:
"/tmp/Project" => "/tmp/Project"
"/tmp/Project #1" => "/tmp/Project"
"/tmp/Project: Demo" => Psych::SyntaxError: mapping values are not allowed in this context
Verification scope: the VS Code formatter was executed directly with a nonempty history, including a normal-path control. The CLI/TUI formatter and both callers were inspected. Full interactive CLI/TUI and VS Code integration checks have not been performed.
What is the expected behavior?
Parsing the exported frontmatter should recover the exact original workspace path, including legal filename characters such as # and : . Ordinary paths should continue to round-trip.
Additional information
A focused fix would serialize work_dir as a properly escaped YAML string in both exporters, with regression cases for ordinary paths and the two failing path forms.
Existing CLI coverage is in export-markdown.test.ts.
I searched open/closed issues and PRs for frontmatter, work_dir with export, and export YAML and did not find an equivalent report or fix. #4008 concerns parsing user-authored agent definitions, rather than generating session-export metadata.
- Ngôn ngữ chính
- TypeScript
- Star
- 8.1k
- Fork
- 1.3k
- Merge trung bình
- 16 giờ 21 phút
- Pull request đã merge (30 ngày)
- 227
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MoonshotAI/kimi-code
-
VS Code: Add quick chat actions to the editor title areaCó thể đã có người làm @rishibalanagu0108 đã nhận 5 ngày trước. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MoonshotAI/kimi-code#4591 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
VS Code: Use the Kimi icon for chat editor tabsCó thể đã có người làm @rishibalanagu0108 đã nhận 5 ngày trước. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MoonshotAI/kimi-code#4590 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ACP plan revision discards client feedback textCó thể đã có người làm @markankamaransheogarat-sys đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MoonshotAI/kimi-code#4548 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
VS Code extension: clickable file links in chat drop the :line suffix, never jump to the lineCó thể đã có người làm @2SinceJuly đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
MoonshotAI/kimi-code#4398 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] vis reports legacy tool-triggered swarm sessions as activeCó thể làm lại được @louisss1016 đã nhận 13 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
MoonshotAI/kimi-code#4395 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MoonshotAI/kimi-code
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/vscode-containers#655 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 bình luận ·
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepCó thể đã có người làm @albertteoh đã nhận hôm nay. Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
jaegertracing/jaeger-ui#4739 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Shop On TV SDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày