diff --git a/src/cli.ts b/src/cli.ts index 8b0dee2..3cce257 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1118,7 +1118,9 @@ function printSessionHistoryByFormat( format: OutputFormat, ): void { const history = record.turnHistory ?? []; - const visible = history.slice(Math.max(0, history.length - limit)); + // limit === 0 means show all entries + const visible = + limit === 0 ? history : history.slice(Math.max(0, history.length - limit)); if (format === "json") { process.stdout.write( @@ -1429,6 +1431,29 @@ function registerSessionsCommand( ) { await handleSessionsHistory(explicitAgentName, name, flags, this, config); }); + + sessionsCommand + .command("read") + .description("Read full session content (all history entries)") + .argument("[name]", "Session name", parseSessionName) + .option( + "--tail ", + "Show only the last N entries instead of all", + parseHistoryLimit, + ) + .action(async function ( + this: Command, + name: string | undefined, + flags: { tail?: number }, + ) { + await handleSessionsHistory( + explicitAgentName, + name, + { limit: flags.tail ?? 0 }, + this, + config, + ); + }); } type SharedSubcommandDescriptions = {