Skip to content

Session command with list subcommand added - #4558

Closed
opencode-agent[bot] wants to merge 1 commit into
devfrom
opencode/issue4557-20251120215033
Closed

opencode-agent[bot] wants to merge 1 commit into
devfrom
opencode/issue4557-20251120215033

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Perfect! Now let me create a final summary of what I've implemented:

Summary

I have successfully implemented a new session command with a list subcommand for the opencode CLI. Here's what was created:

Files Created/Modified:

  1. /src/cli/cmd/session.ts - New command file containing:

    • SessionListCommand - Handles the session list subcommand
    • SessionCommand - Main session command that registers the list subcommand
  2. /src/index.ts - Modified to register the new SessionCommand

  3. /test/cli/session.test.ts - Basic test file for the command structure

Features Implemented:

Command Structure:

  • opencode session list - Main command invocation

Output Formats:

  • Default format (--format default): Git log-style table with Session ID, Last Updated, and Title
  • JSON format (--format json): Full session data as JSON
  • IDs format (--format ids): Just session IDs, one per line (CI-friendly)

Options:

  • --format, -f: Output format choice (default, json, ids)
  • --limit, -l: Limit number of sessions shown

Key Features:

  • CI-friendly: The --format ids option outputs just session IDs for easy scripting
  • Git log-like: Default format shows a clean table similar to git log
  • Sortable: Sessions are sorted by most recently updated
  • Responsive: Terminal width detection for proper formatting
  • Comprehensive: JSON format provides full session data for advanced use cases

Usage Examples:

# List all sessions in default format
opencode session list

# Get just session IDs for CI scripting
opencode session list --format ids

# Get full session data as JSON
opencode session list --format json

# Show only 5 most recent sessions
opencode session list --limit 5

# Combine options
opencode session list --format ids --limit 3

Design Choices:

  1. CI-friendly focus: The --format ids option directly addresses the user's need for easily extractable session IDs
  2. Multiple formats: Provides flexibility for different use cases (human-readable, machine-readable, script-friendly)
  3. Git log inspiration: Familiar table format for developers
  4. Limit option: Helps with large numbers of sessions
  5. Consistent patterns: Follows the same structure as other CLI commands in the codebase

The implementation directly addresses the GitHub issue where users couldn't easily find session IDs to use with the --session flag, providing both human-friendly and CI-friendly ways to list and access session information.

Closes #4557

New%20session%20-%202025-11-20T21%3A50%3A32.854Z
opencode session  |  github run

@github-actions
github-actions Bot force-pushed the dev branch 3 times, most recently from f1dc981 to 3e15a39 Compare November 22, 2025 18:07
@github-actions
github-actions Bot force-pushed the dev branch 3 times, most recently from f8ee907 to 6a9856d Compare November 27, 2025 01:29
@thdxr
thdxr deleted the opencode/issue4557-20251120215033 branch February 7, 2026 06:24
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.

How do I find session ids for -s/--session?

1 participant