[Bug] Session Markdown export corrupts YAML frontmatter for workspace paths containing # or colon-space
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript, yaml
- 領域
- cli
調査の方向性
work_dir のエスケープされていない埋め込みは、apps/vscode/src/utils/session-context.ts の frontmatter 生成部分(buildExportMarkdown、34〜41行目付近)と、apps/kimi-code/src/tui/utils/export-markdown.ts(230〜240行目付近)にあります。まず issue に含まれる再現スクリプトから始めてください。3 つのパスすべてが誤って解析されることが示されるはずです。完了の条件は、'/tmp/Project #1'、'/tmp/Project: Demo'、通常のパスのそれぞれについて、両エクスポーターの frontmatter が元のパスに正確に戻ることを確認し、apps/kimi-code/test/tui/export-markdown.test.ts に回帰テストケースを追加することです。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 8.1k
- フォーク
- 1.3k
- 平均マージ
- 18時間 41分
- マージ済み PR(30日)
- 186
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MoonshotAI/kimi-code のほかの issue
-
VS Code: Add quick chat actions to the editor title area対応中かも @rishibalanagu0108 が今日担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MoonshotAI/kimi-code#4591 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
VS Code: Use the Kimi icon for chat editor tabs対応中かも @rishibalanagu0108 が今日担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MoonshotAI/kimi-code#4590 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ACP plan revision discards client feedback text対応中かも @markankamaransheogarat-sys が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MoonshotAI/kimi-code#4548 ·
メンテナーはふだん 1 日以内に返信
-
VS Code extension: clickable file links in chat drop the :line suffix, never jump to the line対応中かも @2SinceJuly が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
MoonshotAI/kimi-code#4398 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] vis reports legacy tool-triggered swarm sessions as active再び着手できるかも @louisss1016 が 8 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
MoonshotAI/kimi-code#4395 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
MoonshotAI/kimi-code の issue をすべて見る
似ている issue
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
vfarcic/dot-agent-deck#2079 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
status:in-linear
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
🔊 a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
betagouv/mon-entreprise#4726 ·
メンテナーはふだん 9 日以内に返信