claude-code-history 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +400 -0
  2. package/dist/cli/commands/export.d.ts +11 -0
  3. package/dist/cli/commands/export.d.ts.map +1 -0
  4. package/dist/cli/commands/export.js +119 -0
  5. package/dist/cli/commands/export.js.map +1 -0
  6. package/dist/cli/commands/list.d.ts +11 -0
  7. package/dist/cli/commands/list.d.ts.map +1 -0
  8. package/dist/cli/commands/list.js +79 -0
  9. package/dist/cli/commands/list.js.map +1 -0
  10. package/dist/cli/commands/migrate.d.ts +11 -0
  11. package/dist/cli/commands/migrate.d.ts.map +1 -0
  12. package/dist/cli/commands/migrate.js +144 -0
  13. package/dist/cli/commands/migrate.js.map +1 -0
  14. package/dist/cli/commands/search.d.ts +11 -0
  15. package/dist/cli/commands/search.d.ts.map +1 -0
  16. package/dist/cli/commands/search.js +94 -0
  17. package/dist/cli/commands/search.js.map +1 -0
  18. package/dist/cli/commands/view.d.ts +11 -0
  19. package/dist/cli/commands/view.d.ts.map +1 -0
  20. package/dist/cli/commands/view.js +67 -0
  21. package/dist/cli/commands/view.js.map +1 -0
  22. package/dist/cli/formatters/pager.d.ts +25 -0
  23. package/dist/cli/formatters/pager.d.ts.map +1 -0
  24. package/dist/cli/formatters/pager.js +119 -0
  25. package/dist/cli/formatters/pager.js.map +1 -0
  26. package/dist/cli/formatters/search.d.ts +38 -0
  27. package/dist/cli/formatters/search.d.ts.map +1 -0
  28. package/dist/cli/formatters/search.js +119 -0
  29. package/dist/cli/formatters/search.js.map +1 -0
  30. package/dist/cli/formatters/session.d.ts +24 -0
  31. package/dist/cli/formatters/session.d.ts.map +1 -0
  32. package/dist/cli/formatters/session.js +247 -0
  33. package/dist/cli/formatters/session.js.map +1 -0
  34. package/dist/cli/formatters/table.d.ts +25 -0
  35. package/dist/cli/formatters/table.d.ts.map +1 -0
  36. package/dist/cli/formatters/table.js +126 -0
  37. package/dist/cli/formatters/table.js.map +1 -0
  38. package/dist/cli/index.d.ts +14 -0
  39. package/dist/cli/index.d.ts.map +1 -0
  40. package/dist/cli/index.js +50 -0
  41. package/dist/cli/index.js.map +1 -0
  42. package/dist/cli/utils/config.d.ts +62 -0
  43. package/dist/cli/utils/config.d.ts.map +1 -0
  44. package/dist/cli/utils/config.js +65 -0
  45. package/dist/cli/utils/config.js.map +1 -0
  46. package/dist/cli/utils/errors.d.ts +86 -0
  47. package/dist/cli/utils/errors.d.ts.map +1 -0
  48. package/dist/cli/utils/errors.js +129 -0
  49. package/dist/cli/utils/errors.js.map +1 -0
  50. package/dist/cli/utils/output.d.ts +74 -0
  51. package/dist/cli/utils/output.d.ts.map +1 -0
  52. package/dist/cli/utils/output.js +113 -0
  53. package/dist/cli/utils/output.js.map +1 -0
  54. package/dist/lib/config.d.ts +44 -0
  55. package/dist/lib/config.d.ts.map +1 -0
  56. package/dist/lib/config.js +60 -0
  57. package/dist/lib/config.js.map +1 -0
  58. package/dist/lib/errors.d.ts +40 -0
  59. package/dist/lib/errors.d.ts.map +1 -0
  60. package/dist/lib/errors.js +61 -0
  61. package/dist/lib/errors.js.map +1 -0
  62. package/dist/lib/export.d.ts +70 -0
  63. package/dist/lib/export.d.ts.map +1 -0
  64. package/dist/lib/export.js +241 -0
  65. package/dist/lib/export.js.map +1 -0
  66. package/dist/lib/index.d.ts +16 -0
  67. package/dist/lib/index.d.ts.map +1 -0
  68. package/dist/lib/index.js +33 -0
  69. package/dist/lib/index.js.map +1 -0
  70. package/dist/lib/migrate.d.ts +50 -0
  71. package/dist/lib/migrate.d.ts.map +1 -0
  72. package/dist/lib/migrate.js +274 -0
  73. package/dist/lib/migrate.js.map +1 -0
  74. package/dist/lib/parser.d.ts +67 -0
  75. package/dist/lib/parser.d.ts.map +1 -0
  76. package/dist/lib/parser.js +321 -0
  77. package/dist/lib/parser.js.map +1 -0
  78. package/dist/lib/platform.d.ts +51 -0
  79. package/dist/lib/platform.d.ts.map +1 -0
  80. package/dist/lib/platform.js +94 -0
  81. package/dist/lib/platform.js.map +1 -0
  82. package/dist/lib/search.d.ts +39 -0
  83. package/dist/lib/search.d.ts.map +1 -0
  84. package/dist/lib/search.js +217 -0
  85. package/dist/lib/search.js.map +1 -0
  86. package/dist/lib/session.d.ts +59 -0
  87. package/dist/lib/session.d.ts.map +1 -0
  88. package/dist/lib/session.js +326 -0
  89. package/dist/lib/session.js.map +1 -0
  90. package/dist/lib/types.d.ts +280 -0
  91. package/dist/lib/types.d.ts.map +1 -0
  92. package/dist/lib/types.js +7 -0
  93. package/dist/lib/types.js.map +1 -0
  94. package/package.json +65 -0
package/README.md ADDED
@@ -0,0 +1,400 @@
1
+ # Claude Code History
2
+
3
+ A CLI tool and TypeScript library for browsing, searching, exporting, and managing your Claude Code conversation history.
4
+
5
+ ## Features
6
+
7
+ - **List Sessions** - View all your Claude Code sessions with summaries, timestamps, and message counts
8
+ - **View Conversations** - Read full session content with formatted messages and tool calls
9
+ - **Search** - Find specific content across all sessions or within a single session
10
+ - **Export** - Save sessions to JSON or Markdown format
11
+ - **Migrate** - Copy or move sessions between workspaces with automatic path rewriting
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ # Install globally
17
+ npm install -g claude-code-history
18
+
19
+ # Or use npx
20
+ npx claude-code-history list
21
+ ```
22
+
23
+ ## Requirements
24
+
25
+ - Node.js 20 or higher
26
+ - Claude Code installed and used at least once (creates `~/.claude/projects/`)
27
+
28
+ ## CLI Usage
29
+
30
+ ### List Sessions
31
+
32
+ View all your Claude Code sessions:
33
+
34
+ ```bash
35
+ # List all sessions (most recent first)
36
+ cch list
37
+
38
+ # Filter by workspace
39
+ cch list --workspace /path/to/project
40
+
41
+ # Paginate results
42
+ cch list --limit 10 --offset 20
43
+
44
+ # Output as JSON
45
+ cch list --json
46
+ ```
47
+
48
+ **Output:**
49
+ ```
50
+ ┌───────┬─────────────────────┬─────────────────────────────────┬─────────────────────────────────────────────┬──────────┐
51
+ │ Index │ Timestamp │ Project │ Summary │ Messages │
52
+ ├───────┼─────────────────────┼─────────────────────────────────┼─────────────────────────────────────────────┼──────────┤
53
+ │ 0 │ 2024-12-31 15:30:22 │ /Users/dev/my-project │ Implement user authentication │ 45 │
54
+ │ 1 │ 2024-12-31 14:15:10 │ /Users/dev/my-project │ Fix database connection issue │ 23 │
55
+ │ 2 │ 2024-12-30 09:45:33 │ /Users/dev/other-project │ Add unit tests for API endpoints │ 67 │
56
+ └───────┴─────────────────────┴─────────────────────────────────┴─────────────────────────────────────────────┴──────────┘
57
+ ```
58
+
59
+ ### View Session
60
+
61
+ Read the full content of a session:
62
+
63
+ ```bash
64
+ # View by index (0 = most recent)
65
+ cch view 0
66
+
67
+ # View by UUID
68
+ cch view abc123-def456-...
69
+
70
+ # Output as JSON
71
+ cch view 0 --json
72
+ ```
73
+
74
+ **Output:**
75
+ ```
76
+ # Session: Implement user authentication
77
+
78
+ | Property | Value |
79
+ |------------|------------------------------------------|
80
+ | Session ID | abc123-def456-... |
81
+ | Project | /Users/dev/my-project |
82
+ | Messages | 45 |
83
+ | Created | 2024-12-31T15:30:22Z |
84
+
85
+ ---
86
+
87
+ ## User
88
+ 2024-12-31 15:30:22
89
+
90
+ Help me implement user authentication with JWT tokens.
91
+
92
+ ---
93
+
94
+ ## Assistant
95
+ 2024-12-31 15:30:45
96
+
97
+ I'll help you implement JWT authentication. Let me start by...
98
+
99
+ ### Tool: Read
100
+ **Input:**
101
+ - file_path: `/Users/dev/my-project/src/auth/index.ts`
102
+
103
+ → Result:
104
+ ```typescript
105
+ export function authenticate() { ... }
106
+ ```
107
+ ```
108
+
109
+ ### Search Sessions
110
+
111
+ Find content across all sessions:
112
+
113
+ ```bash
114
+ # Search all sessions
115
+ cch search "authentication"
116
+
117
+ # Search with context lines
118
+ cch search "error" --context 3
119
+
120
+ # Search within a specific session
121
+ cch search "bug fix" --session 0
122
+
123
+ # Limit results
124
+ cch search "TODO" --limit 20
125
+
126
+ # Output as JSON
127
+ cch search "query" --json
128
+ ```
129
+
130
+ **Output:**
131
+ ```
132
+ Found 3 matches in 2 sessions
133
+
134
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
135
+
136
+ Session: abc123... | /Users/dev/my-project | 2024-12-31 15:30:22
137
+
138
+ [user] Help me implement user authentication with JWT tokens.
139
+ ^^^^^^^^^^^^^^
140
+
141
+ [assistant] I'll help you implement JWT authentication. Let me...
142
+ ^^^^^^^^^^^^^^
143
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
144
+ ```
145
+
146
+ ### Export Sessions
147
+
148
+ Save sessions to a file:
149
+
150
+ ```bash
151
+ # Export to JSON (stdout)
152
+ cch export 0
153
+
154
+ # Export to Markdown
155
+ cch export 0 --format markdown
156
+
157
+ # Export to file
158
+ cch export 0 --output session.json
159
+ cch export 0 --format markdown --output session.md
160
+
161
+ # Export all sessions
162
+ cch export --all --output all-sessions.json
163
+ cch export --all --format markdown --output all-sessions.md
164
+ ```
165
+
166
+ ### Migrate Sessions
167
+
168
+ Copy or move sessions between workspaces:
169
+
170
+ ```bash
171
+ # Copy session to new workspace
172
+ cch migrate 0 --destination /new/project/path
173
+
174
+ # Move session (removes from source)
175
+ cch migrate 0 --destination /new/project/path --mode move
176
+
177
+ # Migrate multiple sessions
178
+ cch migrate 0,1,2 --destination /new/project/path
179
+
180
+ # Migrate all sessions from a workspace
181
+ cch migrate --all --source /old/project --destination /new/project
182
+ ```
183
+
184
+ Migration automatically rewrites all absolute paths in the session (tool call inputs, cwd, file snapshots) to point to the new workspace location.
185
+
186
+ ### Global Options
187
+
188
+ ```bash
189
+ # Use custom Claude Code data directory
190
+ cch --data-path /custom/path list
191
+
192
+ # Output as JSON (for scripting)
193
+ cch --json list
194
+
195
+ # Disable pagination (full output)
196
+ cch --full view 0
197
+
198
+ # Short forms
199
+ cch -d /custom/path list
200
+ cch -j list
201
+ cch -f view 0
202
+ ```
203
+
204
+ ### Environment Variables
205
+
206
+ | Variable | Description |
207
+ |----------|-------------|
208
+ | `CCH_DATA_PATH` | Custom Claude Code data directory (overridden by `--data-path`) |
209
+ | `PAGER` | Custom pager command (default: `less` on Unix, `more` on Windows) |
210
+ | `NO_COLOR` | Disable colored output |
211
+
212
+ ## Library Usage
213
+
214
+ Use as a TypeScript/JavaScript library:
215
+
216
+ ```typescript
217
+ import {
218
+ listSessions,
219
+ getSession,
220
+ searchSessions,
221
+ exportSession,
222
+ migrateSession,
223
+ } from 'claude-code-history';
224
+
225
+ // List all sessions
226
+ const { data: sessions, pagination } = await listSessions({
227
+ limit: 10,
228
+ offset: 0,
229
+ workspace: '/path/to/project', // optional filter
230
+ });
231
+
232
+ console.log(sessions);
233
+ // [
234
+ // {
235
+ // id: 'abc123-...',
236
+ // projectPath: '/Users/dev/project',
237
+ // summary: 'Implement feature X',
238
+ // messageCount: 45,
239
+ // lastActivity: '2024-12-31T15:30:22Z',
240
+ // ...
241
+ // },
242
+ // ...
243
+ // ]
244
+
245
+ // Get full session content
246
+ const session = await getSession(0); // by index
247
+ const session = await getSession('abc123-...'); // by UUID
248
+
249
+ console.log(session.messages);
250
+ // [
251
+ // { type: 'user', content: 'Help me...', timestamp: '...' },
252
+ // { type: 'assistant', content: [...], timestamp: '...' },
253
+ // ...
254
+ // ]
255
+
256
+ // Search across sessions
257
+ const matches = await searchSessions('authentication', {
258
+ limit: 20,
259
+ contextLines: 2,
260
+ });
261
+
262
+ // Search within a session
263
+ const matches = await searchInSession(0, 'error');
264
+
265
+ // Export to JSON or Markdown
266
+ const json = await exportSession(0, 'json');
267
+ const markdown = await exportSession(0, 'markdown');
268
+
269
+ // Export all sessions
270
+ const allJson = await exportAllSessions('json');
271
+
272
+ // Migrate sessions
273
+ const result = await migrateSession({
274
+ sessions: [0, 1], // indices or UUIDs
275
+ destination: '/new/workspace',
276
+ mode: 'copy', // or 'move'
277
+ });
278
+
279
+ console.log(result);
280
+ // { successCount: 2, failedCount: 0, errors: [] }
281
+ ```
282
+
283
+ ### Custom Data Path
284
+
285
+ ```typescript
286
+ import { listSessions } from 'claude-code-history';
287
+
288
+ const sessions = await listSessions({
289
+ dataPath: '/custom/claude/data/path',
290
+ });
291
+ ```
292
+
293
+ ### Type Definitions
294
+
295
+ The library exports full TypeScript types:
296
+
297
+ ```typescript
298
+ import type {
299
+ Session,
300
+ SessionSummary,
301
+ Message,
302
+ UserMessage,
303
+ AssistantMessage,
304
+ SearchMatch,
305
+ MigrateResult,
306
+ LibraryConfig,
307
+ Pagination,
308
+ PaginatedResult,
309
+ } from 'claude-code-history';
310
+ ```
311
+
312
+ ## Project Structure
313
+
314
+ ```
315
+ claude-code-history/
316
+ ├── src/
317
+ │ ├── cli/ # CLI implementation
318
+ │ │ ├── commands/ # Command handlers (list, view, search, export, migrate)
319
+ │ │ ├── formatters/ # Output formatters (table, session, search)
320
+ │ │ └── utils/ # CLI utilities (config, errors, output)
321
+ │ └── lib/ # Core library
322
+ │ ├── index.ts # Public API exports
323
+ │ ├── session.ts # Session listing and retrieval
324
+ │ ├── search.ts # Search functionality
325
+ │ ├── export.ts # Export to JSON/Markdown
326
+ │ ├── migrate.ts # Session migration
327
+ │ └── types.ts # TypeScript type definitions
328
+ ├── tests/
329
+ │ ├── integration/ # Integration tests
330
+ │ │ └── cli/ # CLI integration tests
331
+ │ └── unit/ # Unit tests
332
+ └── dist/ # Compiled output
333
+ ```
334
+
335
+ ## Development
336
+
337
+ ```bash
338
+ # Clone the repository
339
+ git clone https://github.com/yourusername/claude-code-history.git
340
+ cd claude-code-history
341
+
342
+ # Install dependencies
343
+ npm install
344
+
345
+ # Build
346
+ npm run build
347
+
348
+ # Run tests
349
+ npm test
350
+
351
+ # Run tests in watch mode
352
+ npm run test:watch
353
+
354
+ # Run with coverage
355
+ npm run test:coverage
356
+
357
+ # Lint
358
+ npm run lint
359
+
360
+ # Format code
361
+ npm run format
362
+
363
+ # Type check
364
+ npm run typecheck
365
+ ```
366
+
367
+ ## How It Works
368
+
369
+ Claude Code stores conversation history in `~/.claude/projects/` as JSONL files. Each project directory contains session files named by UUID:
370
+
371
+ ```
372
+ ~/.claude/projects/
373
+ ├── -Users-dev-my-project/
374
+ │ ├── abc123-def456-....jsonl
375
+ │ └── def456-ghi789-....jsonl
376
+ └── -Users-dev-other-project/
377
+ └── xyz789-...jsonl
378
+ ```
379
+
380
+ Each session file contains JSON entries for:
381
+ - **Summary entries** - Session title/summary
382
+ - **User messages** - User inputs
383
+ - **Assistant messages** - Claude's responses with tool calls
384
+ - **File snapshots** - Backup snapshots of modified files
385
+
386
+ This tool reads these files to provide browsing, search, and export capabilities.
387
+
388
+ ## License
389
+
390
+ MIT
391
+
392
+ ## Contributing
393
+
394
+ Contributions are welcome! Please open an issue or submit a pull request.
395
+
396
+ 1. Fork the repository
397
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
398
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
399
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
400
+ 5. Open a Pull Request
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Export command implementation
3
+ *
4
+ * Exports sessions to JSON or Markdown format, to stdout or file.
5
+ */
6
+ import type { Command } from 'commander';
7
+ /**
8
+ * Register the export command
9
+ */
10
+ export declare function registerExportCommand(program: Command): void;
11
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/export.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0IzC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkB5D"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Export command implementation
3
+ *
4
+ * Exports sessions to JSON or Markdown format, to stdout or file.
5
+ */
6
+ import { writeFile } from 'fs/promises';
7
+ import { exportSession, exportAllSessions, isDataNotFoundError, isSessionNotFoundError, } from '../../lib/index.js';
8
+ import { resolveConfig, toLibraryConfig, parseSessionRef, } from '../utils/config.js';
9
+ import { ioError, notFoundError } from '../utils/errors.js';
10
+ import { successResult, output, handleError } from '../utils/output.js';
11
+ /**
12
+ * Validate and normalize format option
13
+ */
14
+ function normalizeFormat(format) {
15
+ const normalized = format.toLowerCase();
16
+ if (normalized === 'json' || normalized === 'markdown' || normalized === 'md') {
17
+ return normalized === 'md' ? 'markdown' : normalized;
18
+ }
19
+ throw new Error(`Invalid format: ${format}. Use 'json' or 'markdown'.`);
20
+ }
21
+ /**
22
+ * Execute the export command
23
+ */
24
+ async function executeExport(sessionArg, options) {
25
+ const config = resolveConfig(options);
26
+ const libConfig = toLibraryConfig(config);
27
+ let format;
28
+ try {
29
+ format = normalizeFormat(options.format);
30
+ }
31
+ catch (error) {
32
+ const exitCode = handleError(error, options.json);
33
+ process.exit(exitCode);
34
+ }
35
+ try {
36
+ let content;
37
+ if (options.all) {
38
+ // Export all sessions
39
+ content = await exportAllSessions(format, libConfig);
40
+ }
41
+ else if (sessionArg) {
42
+ // Export single session
43
+ const sessionRef = parseSessionRef(sessionArg);
44
+ content = await exportSession(sessionRef, format, libConfig);
45
+ }
46
+ else {
47
+ // No session specified and --all not set
48
+ const exitCode = handleError(new Error("Session identifier required. Provide a session index/UUID or use --all.\n\nUsage: cch export <session> [options]\n cch export --all [options]"), options.json);
49
+ process.exit(exitCode);
50
+ }
51
+ // Output to file or stdout
52
+ if (options.output) {
53
+ try {
54
+ await writeFile(options.output, content, 'utf-8');
55
+ if (options.json) {
56
+ const commandResult = successResult({
57
+ file: options.output,
58
+ format,
59
+ size: content.length,
60
+ });
61
+ output(commandResult, true);
62
+ }
63
+ else {
64
+ console.log(`Exported to ${options.output} (${content.length} bytes)`);
65
+ }
66
+ }
67
+ catch (error) {
68
+ const exitCode = handleError(ioError(`Failed to write to ${options.output}`, error instanceof Error ? error.message : 'Unknown error'), options.json);
69
+ process.exit(exitCode);
70
+ }
71
+ }
72
+ else {
73
+ // Output to stdout
74
+ if (options.json && format === 'json') {
75
+ // For JSON format with --json flag, wrap in command result
76
+ const commandResult = successResult(JSON.parse(content));
77
+ output(commandResult, true);
78
+ }
79
+ else {
80
+ // For markdown or raw output, just print the content
81
+ console.log(content);
82
+ }
83
+ }
84
+ }
85
+ catch (error) {
86
+ if (isSessionNotFoundError(error)) {
87
+ const exitCode = handleError(notFoundError(`Session not found: ${sessionArg}`, "Try 'cch list' to see available sessions."), options.json);
88
+ process.exit(exitCode);
89
+ }
90
+ if (isDataNotFoundError(error)) {
91
+ const exitCode = handleError(ioError('Claude Code data directory not found', 'Make sure Claude Code is installed and has been used at least once.'), options.json);
92
+ process.exit(exitCode);
93
+ }
94
+ throw error;
95
+ }
96
+ }
97
+ /**
98
+ * Register the export command
99
+ */
100
+ export function registerExportCommand(program) {
101
+ program
102
+ .command('export [session]')
103
+ .description('Export session(s) to JSON or Markdown format')
104
+ .option('-F, --format <format>', 'Export format: json or markdown', 'json')
105
+ .option('-o, --output <file>', 'Output file path (stdout if not specified)')
106
+ .option('-a, --all', 'Export all sessions', false)
107
+ .action(async (sessionArg, cmdOptions) => {
108
+ const globalOptions = program.opts();
109
+ const options = { ...globalOptions, ...cmdOptions };
110
+ try {
111
+ await executeExport(sessionArg, options);
112
+ }
113
+ catch (error) {
114
+ const exitCode = handleError(error, options.json);
115
+ process.exit(exitCode);
116
+ }
117
+ });
118
+ }
119
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.js","sourceRoot":"","sources":["../../../src/cli/commands/export.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GAEvB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E,UAAoD,EAAE,EAAE;QACrG,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,EAAmB,CAAC;QACtD,MAAM,OAAO,GAAkB,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,EAAE,CAAC;QAEnE,IAAI,CAAC;YACH,MAAM,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * List command implementation
3
+ *
4
+ * Lists all available Claude Code sessions with summary information.
5
+ */
6
+ import type { Command } from 'commander';
7
+ /**
8
+ * Register the list command
9
+ */
10
+ export declare function registerListCommand(program: Command): void;
11
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoFzC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkB1D"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * List command implementation
3
+ *
4
+ * Lists all available Claude Code sessions with summary information.
5
+ */
6
+ import { listSessions, isDataNotFoundError } from '../../lib/index.js';
7
+ import { resolveConfig, toLibraryConfig, } from '../utils/config.js';
8
+ import { ioError } from '../utils/errors.js';
9
+ import { successResult, output, handleError, formatPaginationHint, toPaginationInfo, } from '../utils/output.js';
10
+ import { formatSessionTable, formatSessionsForJson } from '../formatters/table.js';
11
+ import { outputWithPager } from '../formatters/pager.js';
12
+ /**
13
+ * Execute the list command
14
+ */
15
+ async function executeList(options) {
16
+ const config = resolveConfig(options);
17
+ const limit = parseInt(options.limit, 10);
18
+ const offset = parseInt(options.offset, 10);
19
+ const libConfig = toLibraryConfig(config, {
20
+ workspace: options.workspace,
21
+ limit,
22
+ offset,
23
+ });
24
+ try {
25
+ const result = await listSessions(libConfig);
26
+ if (options.json) {
27
+ // JSON output
28
+ const jsonData = formatSessionsForJson(result.data, offset);
29
+ const commandResult = successResult(jsonData, result.pagination);
30
+ output(commandResult, true);
31
+ }
32
+ else {
33
+ // Human-readable output
34
+ if (result.data.length === 0) {
35
+ if (options.workspace) {
36
+ console.log(`No sessions found for workspace: ${options.workspace}`);
37
+ }
38
+ else {
39
+ console.log('No sessions found.');
40
+ }
41
+ return;
42
+ }
43
+ const tableOutput = formatSessionTable(result.data, offset);
44
+ const paginationHint = formatPaginationHint(toPaginationInfo(result.pagination), 'sessions');
45
+ const fullOutput = tableOutput + paginationHint;
46
+ await outputWithPager(fullOutput, options.full);
47
+ }
48
+ }
49
+ catch (error) {
50
+ if (isDataNotFoundError(error)) {
51
+ const exitCode = handleError(ioError('Claude Code data directory not found', 'Make sure Claude Code is installed and has been used at least once.'), options.json);
52
+ process.exit(exitCode);
53
+ }
54
+ throw error;
55
+ }
56
+ }
57
+ /**
58
+ * Register the list command
59
+ */
60
+ export function registerListCommand(program) {
61
+ program
62
+ .command('list')
63
+ .description('List all sessions')
64
+ .option('-w, --workspace <path>', 'Filter by workspace/project path')
65
+ .option('-l, --limit <number>', 'Maximum number of sessions to display', '50')
66
+ .option('-o, --offset <number>', 'Number of sessions to skip', '0')
67
+ .action(async (cmdOptions) => {
68
+ const globalOptions = program.opts();
69
+ const options = { ...globalOptions, ...cmdOptions };
70
+ try {
71
+ await executeList(options);
72
+ }
73
+ catch (error) {
74
+ const exitCode = handleError(error, options.json);
75
+ process.exit(exitCode);
76
+ }
77
+ });
78
+ }
79
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot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AkD,EAAE,EAAE;QACnE,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,EAAmB,CAAC;QACtD,MAAM,OAAO,GAAgB,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,EAAE,CAAC;QAEjE,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Migrate command implementation
3
+ *
4
+ * Copies or moves sessions between workspaces.
5
+ */
6
+ import type { Command } from 'commander';
7
+ /**
8
+ * Register the migrate command
9
+ */
10
+ export declare function registerMigrateCommand(program: Command): void;
11
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/migrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiMzC;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmB7D"}