[PR #20] [MERGED] feat: add dump command for bulk session export #24

Closed
opened 2026-03-04 01:39:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/yigitkonur/cli-continues/pull/20
Author: @commandlinetips
Created: 2/28/2026
Status: Merged
Merged: 3/2/2026
Merged by: @yigitkonur

Base: mainHead: main


📝 Commits (4)

  • bb7e58c feat: add dump command for bulk session export
  • a2a51c2 docs: add dump command to README
  • f3ccafe fix: address code review feedback for dump command
  • 50948e1 fix: stop spinner on error + validate --limit input

📊 Changes

3 files changed (+195 additions, -0 deletions)

View changed files

📝 README.md (+25 -0)
📝 src/cli.ts (+13 -0)
src/commands/dump.ts (+157 -0)

📄 Description

Summary

Adds a new dump command to bulk export sessions to markdown or JSON files.

Usage

# Export all sessions to markdown (default)
continues dump all ./sessions

# Export specific tool's sessions
continues dump claude ./sessions/claude
continues dump gemini ./sessions/gemini

# Export as JSON instead of markdown
continues dump all ./sessions --json

# Control verbosity with presets
continues dump all ./sessions --preset full

# Limit number of sessions
continues dump all ./sessions --limit 50

Options

Flag Description
--preset <name> Verbosity: minimal, standard, verbose, full (default: standard)
--json Output raw session JSON instead of markdown
--limit <n> Limit number of sessions (default: no limit)
--rebuild Force rebuild session index before dumping

Implementation

  • New file: src/commands/dump.ts - dump command handler
  • Modified: src/cli.ts - register the command
  • Updated: README.md - documentation

File Naming

  • Markdown: {source}_{id}.md (e.g., claude_abc123def456.md)
  • JSON: {source}_{id}.json (e.g., gemini_def789ghi012.json)

Test plan

  • continues dump --help shows correct usage
  • continues dump all ./dir --limit 3 exports 3 markdown files
  • continues dump all ./dir --json exports JSON files
  • continues dump opencode ./dir filters by source
  • continues dump claude ./dir --preset full uses full verbosity

Review all of them with eye of John Carmack-like simplicity with elegeance approach and apply the one only if required

Greptile Summary

Adds bulk export command for sessions. Core feature is solid — reuses existing getAllSessions, getSessionsBySource, and adapter extractContext methods. Integrates naturally with the CLI's flag patterns and verbosity presets.

Critical bugs found:

  • Missing adapter null check causes crash on invalid session source
  • "By source" breakdown counts attempted exports, not successful ones — misleading when errors occur
  • No top-level try-catch, unlike other commands (see list.ts)
  • Unnecessary fs.existsSync check before mkdirSync with recursive flag

Feature itself fits well. Implementation needs tightening.

Confidence Score: 2/5

  • Not safe to merge — crashes on edge cases, misleading output
  • Two critical bugs that cause crashes or misleading output, plus inconsistent error handling. The missing adapter null check will crash the command if any session has corrupted metadata. The "by source" count bug makes error reporting confusing. Documentation and CLI integration are clean, but the core command needs fixes.
  • src/commands/dump.ts needs immediate fixes for crash bugs and error handling

Important Files Changed

Filename Overview
src/commands/dump.ts New bulk export command with critical bugs: missing adapter null check (crashes on invalid source), misleading source counts (includes failures), unnecessary existsSync check, no top-level error handling
src/cli.ts Clean command registration for dump - follows existing patterns, options match implementation
README.md Documentation accurately describes dump command usage, options, and examples

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Start([continues dump source dir --options]) --> ValidateSource{Valid source?}
    ValidateSource -->|No| ErrorExit1[Exit with error]
    ValidateSource -->|Yes| LoadSessions[Load sessions from index]
    LoadSessions --> CheckEmpty{Sessions found?}
    CheckEmpty -->|No| InfoExit[Print 'No sessions found' & exit]
    CheckEmpty -->|Yes| ApplyLimit[Apply --limit if specified]
    ApplyLimit --> CreateDir[Create target directory recursive]
    CreateDir --> GetPreset[Load verbosity preset]
    GetPreset --> LoopStart[Start export loop]
    LoopStart --> LoopNext{More sessions?}
    LoopNext -->|No| PrintSummary[Print summary: success/errors/time]
    LoopNext -->|Yes| CheckFormat{--json flag?}
    CheckFormat -->|Yes| ExportJSON[Write session as JSON]
    CheckFormat -->|No| GetAdapter[Get adapter for session.source]
    GetAdapter --> ExtractContext[adapter.extractContext with preset]
    ExtractContext --> ExportMD[Write markdown file]
    ExportJSON --> IncrSuccess[Increment successCount]
    ExportMD --> IncrSuccess
    IncrSuccess --> LoopNext
    PrintSummary --> CountBySource[Count sessions by source]
    CountBySource --> PrintBreakdown[Print source breakdown table]
    PrintBreakdown --> End([Exit with code 0 or 1])

Last reviewed commit: a2a51c2

(2/5) Greptile learns from your feedback when you react with thumbs up/down!


Open with Devin

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/yigitkonur/cli-continues/pull/20 **Author:** [@commandlinetips](https://github.com/commandlinetips) **Created:** 2/28/2026 **Status:** ✅ Merged **Merged:** 3/2/2026 **Merged by:** [@yigitkonur](https://github.com/yigitkonur) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (4) - [`bb7e58c`](https://github.com/yigitkonur/cli-continues/commit/bb7e58c3b3e9f3564126b1f8e038954b911fbc8a) feat: add dump command for bulk session export - [`a2a51c2`](https://github.com/yigitkonur/cli-continues/commit/a2a51c2f8134556dd90d5ae67292d3a12ace3d83) docs: add dump command to README - [`f3ccafe`](https://github.com/yigitkonur/cli-continues/commit/f3ccafea6211451bce18d4e05053cdc93235de60) fix: address code review feedback for dump command - [`50948e1`](https://github.com/yigitkonur/cli-continues/commit/50948e1ad2072b81d33def6766dc6ee5a4053072) fix: stop spinner on error + validate --limit input ### 📊 Changes **3 files changed** (+195 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+25 -0) 📝 `src/cli.ts` (+13 -0) ➕ `src/commands/dump.ts` (+157 -0) </details> ### 📄 Description ## Summary Adds a new `dump` command to bulk export sessions to markdown or JSON files. ## Usage ```bash # Export all sessions to markdown (default) continues dump all ./sessions # Export specific tool's sessions continues dump claude ./sessions/claude continues dump gemini ./sessions/gemini # Export as JSON instead of markdown continues dump all ./sessions --json # Control verbosity with presets continues dump all ./sessions --preset full # Limit number of sessions continues dump all ./sessions --limit 50 ``` ## Options | Flag | Description | |------|-------------| | `--preset <name>` | Verbosity: minimal, standard, verbose, full (default: standard) | | `--json` | Output raw session JSON instead of markdown | | `--limit <n>` | Limit number of sessions (default: no limit) | | `--rebuild` | Force rebuild session index before dumping | ## Implementation - New file: `src/commands/dump.ts` - dump command handler - Modified: `src/cli.ts` - register the command - Updated: `README.md` - documentation ## File Naming - Markdown: `{source}_{id}.md` (e.g., `claude_abc123def456.md`) - JSON: `{source}_{id}.json` (e.g., `gemini_def789ghi012.json`) ## Test plan - [x] `continues dump --help` shows correct usage - [x] `continues dump all ./dir --limit 3` exports 3 markdown files - [x] `continues dump all ./dir --json` exports JSON files - [x] `continues dump opencode ./dir` filters by source - [x] `continues dump claude ./dir --preset full` uses full verbosity <!-- greptile_comment --> # Review all of them with eye of John Carmack-like simplicity with elegeance approach and apply the one only if required <h3>Greptile Summary</h3> Adds bulk export command for sessions. Core feature is solid — reuses existing `getAllSessions`, `getSessionsBySource`, and adapter `extractContext` methods. Integrates naturally with the CLI's flag patterns and verbosity presets. **Critical bugs found:** - Missing adapter null check causes crash on invalid session source - "By source" breakdown counts attempted exports, not successful ones — misleading when errors occur - No top-level try-catch, unlike other commands (see `list.ts`) - Unnecessary `fs.existsSync` check before `mkdirSync` with recursive flag Feature itself fits well. Implementation needs tightening. <h3>Confidence Score: 2/5</h3> - Not safe to merge — crashes on edge cases, misleading output - Two critical bugs that cause crashes or misleading output, plus inconsistent error handling. The missing adapter null check will crash the command if any session has corrupted metadata. The "by source" count bug makes error reporting confusing. Documentation and CLI integration are clean, but the core command needs fixes. - `src/commands/dump.ts` needs immediate fixes for crash bugs and error handling <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | src/commands/dump.ts | New bulk export command with critical bugs: missing adapter null check (crashes on invalid source), misleading source counts (includes failures), unnecessary existsSync check, no top-level error handling | | src/cli.ts | Clean command registration for dump - follows existing patterns, options match implementation | | README.md | Documentation accurately describes dump command usage, options, and examples | </details> </details> <h3>Flowchart</h3> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD Start([continues dump source dir --options]) --> ValidateSource{Valid source?} ValidateSource -->|No| ErrorExit1[Exit with error] ValidateSource -->|Yes| LoadSessions[Load sessions from index] LoadSessions --> CheckEmpty{Sessions found?} CheckEmpty -->|No| InfoExit[Print 'No sessions found' & exit] CheckEmpty -->|Yes| ApplyLimit[Apply --limit if specified] ApplyLimit --> CreateDir[Create target directory recursive] CreateDir --> GetPreset[Load verbosity preset] GetPreset --> LoopStart[Start export loop] LoopStart --> LoopNext{More sessions?} LoopNext -->|No| PrintSummary[Print summary: success/errors/time] LoopNext -->|Yes| CheckFormat{--json flag?} CheckFormat -->|Yes| ExportJSON[Write session as JSON] CheckFormat -->|No| GetAdapter[Get adapter for session.source] GetAdapter --> ExtractContext[adapter.extractContext with preset] ExtractContext --> ExportMD[Write markdown file] ExportJSON --> IncrSuccess[Increment successCount] ExportMD --> IncrSuccess IncrSuccess --> LoopNext PrintSummary --> CountBySource[Count sessions by source] CountBySource --> PrintBreakdown[Print source breakdown table] PrintBreakdown --> End([Exit with code 0 or 1]) ``` <sub>Last reviewed commit: a2a51c2</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment --> <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/yigitkonur/cli-continues/pull/20" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:39:18 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cli-continues#24
No description provided.