singularity-forge/src/help-text.ts
sgodoy90 72cef21876 feat: add gsd sessions subcommand for session picker
Add a new `gsd sessions` subcommand that lists all saved sessions for
the current directory and lets the user interactively pick one to resume.

Currently `gsd --continue` only resumes the most recent session, with no
way to access older conversations. This change adds:

- `gsd sessions` subcommand that calls SessionManager.list() to enumerate
  all sessions for the current working directory
- Interactive numbered list showing date, message count, session name (if
  set), and a preview of the first message
- Selection by number to resume any past session via SessionManager.open()
- Subcommand help text (`gsd sessions --help`)
- Help text entry in the main `gsd --help` output

The implementation uses only existing SessionManager APIs (list, open) -
no SDK changes required.
2026-03-16 15:27:10 -06:00

63 lines
2.8 KiB
TypeScript

const SUBCOMMAND_HELP: Record<string, string> = {
config: [
'Usage: gsd config',
'',
'Re-run the interactive setup wizard to configure:',
' - LLM provider (Anthropic, OpenAI, Google, etc.)',
' - Web search provider (Brave, Tavily, built-in)',
' - Remote questions (Discord, Slack, Telegram)',
' - Tool API keys (Context7, Jina, Groq)',
'',
'All steps are skippable and can be changed later with /login or /search-provider.',
].join('\n'),
update: [
'Usage: gsd update',
'',
'Update GSD to the latest version.',
'',
'Equivalent to: npm install -g gsd-pi@latest',
].join('\n'),
sessions: [
'Usage: gsd sessions',
'',
'List all saved sessions for the current directory and interactively',
'pick one to resume. Shows date, message count, and a preview of the',
'first message for each session.',
'',
'Sessions are stored per-directory, so you only see sessions that were',
'started from the current working directory.',
'',
'Compare with --continue (-c) which always resumes the most recent session.',
].join('\n'),
}
export function printHelp(version: string): void {
process.stdout.write(`GSD v${version} — Get Shit Done\n\n`)
process.stdout.write('Usage: gsd [options] [message...]\n\n')
process.stdout.write('Options:\n')
process.stdout.write(' --mode <text|json|rpc|mcp> Output mode (default: interactive)\n')
process.stdout.write(' --print, -p Single-shot print mode\n')
process.stdout.write(' --continue, -c Resume the most recent session\n')
process.stdout.write(' --model <id> Override model (e.g. claude-opus-4-6)\n')
process.stdout.write(' --no-session Disable session persistence\n')
process.stdout.write(' --extension <path> Load additional extension\n')
process.stdout.write(' --tools <a,b,c> Restrict available tools\n')
process.stdout.write(' --list-models [search] List available models and exit\n')
process.stdout.write(' --version, -v Print version and exit\n')
process.stdout.write(' --help, -h Print this help and exit\n')
process.stdout.write('\nSubcommands:\n')
process.stdout.write(' config Re-run the setup wizard\n')
process.stdout.write(' update Update GSD to the latest version\n')
process.stdout.write(' sessions List and resume a past session\n')
process.stdout.write('\nRun gsd <subcommand> --help for subcommand-specific help.\n')
}
export function printSubcommandHelp(subcommand: string, version: string): boolean {
const help = SUBCOMMAND_HELP[subcommand]
if (!help) return false
process.stdout.write(`GSD v${version} — Get Shit Done\n\n`)
process.stdout.write(help + '\n')
return true
}