import { hashProjectPath } from '../storage/base-store.js';
import * as sessionStore from '../storage/session-store.js';
import { t, ti } from '../i18n/index.js';
export async function handleListSessions(params) {
    const projectId = hashProjectPath(params.projectPath);
    const limit = params.limit ?? 10;
    try {
        const items = await sessionStore.listItems(projectId, limit);
        const lines = [];
        lines.push(t('tools.response.sessionsTitle'));
        lines.push('');
        if (items.length === 0) {
            lines.push(t('tools.response.noSessions'));
        }
        else {
            lines.push(ti('tools.response.sessionsFound', { count: items.length }));
            lines.push('');
            for (const session of items) {
                lines.push(`- **${session.id}** | created: ${session.startedAt} | saved: ${session.lastSavedAt}`);
            }
        }
        lines.push('');
        lines.push('🚀 **Next Steps**');
        lines.push('1. Use `restore_session` to resume a session');
        lines.push('2. Use `export_session` to save session data');
        const sessionTips = {
            naming: 'Name sessions at start: claude -n auth-refactor  |  Or rename during: /rename auth-refactor',
            resume: 'Resume by name: claude --resume auth-refactor  |  Most recent: claude --continue',
            fromPr: 'Resume PR session: claude --from-pr 123 (auto-linked when PR created inside Claude Code)',
            pickerShortcuts: 'In /resume picker: P=preview, R=rename, B=filter by branch, /=search',
            btw: 'Use /btw for quick side questions — answer appears in overlay, never enters conversation history',
        };
        return {
            content: [{ type: 'text', text: lines.join('\n') }],
            sessionTips,
        };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        return {
            content: [{ type: 'text', text: `Error listing sessions: ${message}` }],
            isError: true,
        };
    }
}
//# sourceMappingURL=list-sessions.js.map