Skip to content

feat(tui): add /export-md slash command - #113

Merged
liruifengv merged 4 commits into
mainfrom
add-export-md
May 27, 2026
Merged

feat(tui): add /export-md slash command#113
liruifengv merged 4 commits into
mainfrom
add-export-md

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — new feature to complement the existing /export-debug-zip command.

Problem

Users have no way to export their session conversation as a readable document. The existing /export-debug-zip outputs raw wire protocol data in a ZIP archive, which is useful for debugging but not for reviewing or sharing conversations.

What changed

Added a new /export-md (alias: /export) slash command that exports the current session as a human-readable Markdown file.

TUI layer (apps/kimi-code):

  • Registered the /export-md command in the slash command registry
  • Implemented handleExportMdCommand which fetches context via session.getContext(), formats it, and writes to disk
  • Added export-markdown.ts with pure formatting functions (message filtering, turn grouping, Markdown rendering)
  • 33 unit tests covering all formatting functions

SDK layer (packages/node-sdk):

  • Exposed Session.getContext() and SDKRpcClient.getContext() to allow TUI-layer access to the agent's conversation history

Export format (aligned with Python kimi-cli /export):

  • YAML frontmatter with session metadata
  • Overview section (topic, turn count, tool call count)
  • Turn-by-turn dialogue with ### User / ### Assistant headings
  • Collapsible <details> blocks for thinking and tool results
  • Tool call hints extracted from arguments (path, command, etc.)
  • Internal messages (injections, system triggers, compaction summaries) are filtered out

Usage:

  • /export-md — saves to working directory with auto-generated filename
  • /export-md path/to/file.md — saves to specified path

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Add a new /export-md (alias: /export) command that exports the current
session conversation as a human-readable Markdown file. The export
includes YAML frontmatter metadata, an overview section, and
turn-by-turn dialogue with collapsible thinking blocks and tool
call/result details.

Also exposes Session.getContext() on the SDK to allow TUI-layer access
to the agent's conversation history.
@changeset-bot

changeset-bot Bot commented May 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bd4c348

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kimi-code Minor
@moonshot-ai/kimi-code-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented May 27, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@bd4c348
npx https://pkg.pr.new/@moonshot-ai/kimi-code@bd4c348

commit: bd4c348

@liruifengv
liruifengv merged commit 028d069 into main May 27, 2026
6 checks passed
@liruifengv
liruifengv deleted the add-export-md branch May 27, 2026 10:51
@github-actions github-actions Bot mentioned this pull request May 27, 2026
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.

1 participant