Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@PeterDaveHello
Copy link
Contributor

Context

Add session export/import commands to the CLI, enabling users to backup and share their session data as portable JSON files.

Implementation

  • New kilocode export <sessionId> subcommand that exports session data to JSON
  • New kilocode import <file> subcommand that previews exported session files
  • Uses lightweight SessionClient + TrpcClient directly instead of full SessionManager initialization, allowing export to work as a standalone subcommand without starting the full CLI
  • Token retrieval uses getKiloToken() with applyEnvOverrides() to support both config file and environment variable authentication
  • Blob download failures are reported as warnings to stderr (export continues with partial data)

Exported data includes:

  • Session metadata (title, mode, model, timestamps, git URL)
  • API conversation history
  • UI messages
  • Task metadata
  • Git state

How to Test

# Build the CLI
pnpm cli:bundle

# Export a session (get session ID from /session list in CLI)
cd cli && pnpm start export <session-id>

# Export to specific file
cd cli && pnpm start export <session-id> -o my-session.json

# Preview an exported session
cd cli && pnpm start import my-session.json

# Test error handling - invalid session ID
cd cli && pnpm start export invalid-id

# Test without token configured (should show helpful error)
KILOCODE_TOKEN= pnpm start export <session-id>

GitHub Copilot summary

This pull request adds new session export and import functionality to the CLI, enabling users to export session data to a JSON file and preview imports from such files. The changes introduce a new command implementation and integrate these commands into the CLI's command routing and help system.

Session export/import feature:

  • Added a new module session-export.ts implementing session export to JSON, reading and validating exported sessions, and previewing imports. This includes fetching all relevant session data, handling blob URLs, and providing user warnings on errors.

CLI command integration:

  • Registered new export and import commands in the CLI using Commander.js, with appropriate argument parsing, error handling, and user-facing messages.
  • Updated the CLI's subcommand routing logic to recognize the new export and import commands, ensuring correct command dispatch.

Get in Touch

@PeterDaveHello

Add 'kilocode export' and 'kilocode import' subcommands for session
portability.

Export:
  kilocode export [sessionId] [-o output.json]
  - Exports session metadata and conversation history to JSON
  - Fetches data from cloud blob storage

Import:
  kilocode import <file>
  - Reads and validates exported session JSON
  - Shows preview of session contents
  - Provides guidance for full restore via /session fork

Exported data includes:
- Session metadata (title, mode, model, timestamps)
- API conversation history
- UI messages
- Task metadata
@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

πŸ¦‹ Changeset detected

Latest commit: 087e2f3

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

This PR includes changesets to release 1 package
Name Type
@kilocode/cli 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

@PeterDaveHello PeterDaveHello changed the title Add CLI Commands for Session Export and Import feat(cli): add session export/import commands Jan 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