cursor-history 0.5.1
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.
- package/README.md +225 -0
- package/dist/cli/commands/export.d.ts +9 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +126 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/list.d.ts +9 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +77 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/search.d.ts +9 -0
- package/dist/cli/commands/search.d.ts.map +1 -0
- package/dist/cli/commands/search.js +47 -0
- package/dist/cli/commands/search.js.map +1 -0
- package/dist/cli/commands/show.d.ts +9 -0
- package/dist/cli/commands/show.d.ts.map +1 -0
- package/dist/cli/commands/show.js +51 -0
- package/dist/cli/commands/show.js.map +1 -0
- package/dist/cli/formatters/index.d.ts +6 -0
- package/dist/cli/formatters/index.d.ts.map +1 -0
- package/dist/cli/formatters/index.js +6 -0
- package/dist/cli/formatters/index.js.map +1 -0
- package/dist/cli/formatters/json.d.ts +28 -0
- package/dist/cli/formatters/json.d.ts.map +1 -0
- package/dist/cli/formatters/json.js +98 -0
- package/dist/cli/formatters/json.js.map +1 -0
- package/dist/cli/formatters/table.d.ts +45 -0
- package/dist/cli/formatters/table.d.ts.map +1 -0
- package/dist/cli/formatters/table.js +439 -0
- package/dist/cli/formatters/table.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +51 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/parser.d.ts +38 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/parser.js +324 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/storage.d.ts +45 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/core/storage.js +869 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/core/types.d.ts +113 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/lib/errors.d.ts +56 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +90 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/platform.d.ts +25 -0
- package/dist/lib/platform.d.ts.map +1 -0
- package/dist/lib/platform.js +66 -0
- package/dist/lib/platform.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# cursor-history
|
|
2
|
+
|
|
3
|
+
CLI tool to browse, search, and export your Cursor AI chat history.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **List sessions** - View all chat sessions across workspaces
|
|
8
|
+
- **View full conversations** - See complete chat history with:
|
|
9
|
+
- AI responses with natural language explanations
|
|
10
|
+
- **Full diff display** for file edits and writes with syntax highlighting
|
|
11
|
+
- **Detailed tool calls** showing all parameters (file paths, search patterns, commands, etc.)
|
|
12
|
+
- AI reasoning and thinking blocks
|
|
13
|
+
- Message timestamps
|
|
14
|
+
- **Search** - Find conversations by keyword with highlighted matches
|
|
15
|
+
- **Export** - Save sessions as Markdown or JSON files
|
|
16
|
+
- **Cross-platform** - Works on macOS, Windows, and Linux
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### From NPM (Recommended)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Install globally
|
|
24
|
+
npm install -g cursor-history
|
|
25
|
+
|
|
26
|
+
# Use the CLI
|
|
27
|
+
cursor-history list
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### From Source
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Clone and build
|
|
34
|
+
git clone https://github.com/S2thend/cursor_chat_history.git
|
|
35
|
+
cd cursor_chat_history
|
|
36
|
+
npm install
|
|
37
|
+
npm run build
|
|
38
|
+
|
|
39
|
+
# Run directly
|
|
40
|
+
node dist/cli/index.js list
|
|
41
|
+
|
|
42
|
+
# Or link globally
|
|
43
|
+
npm link
|
|
44
|
+
cursor-history list
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Requirements
|
|
48
|
+
|
|
49
|
+
- Node.js 20+
|
|
50
|
+
- Cursor IDE (with existing chat history)
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### List Sessions
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# List recent sessions (default: 20)
|
|
58
|
+
cursor-history list
|
|
59
|
+
|
|
60
|
+
# List all sessions
|
|
61
|
+
cursor-history list --all
|
|
62
|
+
|
|
63
|
+
# List with composer IDs (for external tools)
|
|
64
|
+
cursor-history list --ids
|
|
65
|
+
|
|
66
|
+
# Limit results
|
|
67
|
+
cursor-history list -n 10
|
|
68
|
+
|
|
69
|
+
# List workspaces only
|
|
70
|
+
cursor-history list --workspaces
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### View a Session
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Show session by index number
|
|
77
|
+
cursor-history show 1
|
|
78
|
+
|
|
79
|
+
# Show with truncated messages (for quick overview)
|
|
80
|
+
cursor-history show 1 --short
|
|
81
|
+
|
|
82
|
+
# Show full AI thinking/reasoning text
|
|
83
|
+
cursor-history show 1 --think
|
|
84
|
+
|
|
85
|
+
# Show full file read content (not truncated)
|
|
86
|
+
cursor-history show 1 --fullread
|
|
87
|
+
|
|
88
|
+
# Show full error messages (not truncated to 300 chars)
|
|
89
|
+
cursor-history show 1 --error
|
|
90
|
+
|
|
91
|
+
# Combine options
|
|
92
|
+
cursor-history show 1 --short --think --fullread --error
|
|
93
|
+
|
|
94
|
+
# Output as JSON
|
|
95
|
+
cursor-history show 1 --json
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Search
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Search for keyword
|
|
102
|
+
cursor-history search "react hooks"
|
|
103
|
+
|
|
104
|
+
# Limit results
|
|
105
|
+
cursor-history search "api" -n 5
|
|
106
|
+
|
|
107
|
+
# Adjust context around matches
|
|
108
|
+
cursor-history search "error" --context 100
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Export
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Export single session to Markdown
|
|
115
|
+
cursor-history export 1
|
|
116
|
+
|
|
117
|
+
# Export to specific file
|
|
118
|
+
cursor-history export 1 -o ./my-chat.md
|
|
119
|
+
|
|
120
|
+
# Export as JSON
|
|
121
|
+
cursor-history export 1 --format json
|
|
122
|
+
|
|
123
|
+
# Export all sessions to directory
|
|
124
|
+
cursor-history export --all -o ./exports/
|
|
125
|
+
|
|
126
|
+
# Overwrite existing files
|
|
127
|
+
cursor-history export 1 --force
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Global Options
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Output as JSON (works with all commands)
|
|
134
|
+
cursor-history --json list
|
|
135
|
+
|
|
136
|
+
# Use custom Cursor data path
|
|
137
|
+
cursor-history --data-path ~/.cursor-alt list
|
|
138
|
+
|
|
139
|
+
# Filter by workspace
|
|
140
|
+
cursor-history --workspace /path/to/project list
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## What You Can View
|
|
144
|
+
|
|
145
|
+
When browsing your chat history, you'll see:
|
|
146
|
+
|
|
147
|
+
- **Complete conversations** - All messages exchanged with Cursor AI
|
|
148
|
+
- **Duplicate message folding** - Consecutive identical messages are folded into one display with multiple timestamps and repeat count (e.g., "02:48:01 PM, 02:48:04 PM, 02:48:54 PM (×3)")
|
|
149
|
+
- **Timestamps** - Exact time each message was sent (HH:MM:SS format)
|
|
150
|
+
- **AI tool actions** - Detailed view of what Cursor AI did:
|
|
151
|
+
- **File edits/writes** - Full diff display with syntax highlighting showing exactly what changed
|
|
152
|
+
- **File reads** - File paths and content previews (use `--fullread` for complete content)
|
|
153
|
+
- **Search operations** - Patterns, paths, and search queries used
|
|
154
|
+
- **Terminal commands** - Complete command text
|
|
155
|
+
- **Directory listings** - Paths explored
|
|
156
|
+
- **Tool errors** - Failed/cancelled operations shown with ❌ status indicator and parameters
|
|
157
|
+
- **User decisions** - Shows if you accepted (✓), rejected (✗), or pending (⏳) on tool operations
|
|
158
|
+
- **Errors** - Error messages with ❌ emoji highlighting (extracted from `toolFormerData.additionalData.status`)
|
|
159
|
+
- **AI reasoning** - See the AI's thinking process behind decisions (use `--think` for full text)
|
|
160
|
+
- **Code artifacts** - Mermaid diagrams, code blocks, with syntax highlighting
|
|
161
|
+
- **Natural language explanations** - AI explanations combined with code for full context
|
|
162
|
+
|
|
163
|
+
### Display Options
|
|
164
|
+
|
|
165
|
+
- **Default view** - Full messages with truncated thinking (200 chars), file reads (100 chars), and errors (300 chars)
|
|
166
|
+
- **`--short` mode** - Truncates user and assistant messages to 300 chars for quick scanning
|
|
167
|
+
- **`--think` flag** - Shows complete AI reasoning/thinking text (not truncated)
|
|
168
|
+
- **`--fullread` flag** - Shows full file read content instead of previews
|
|
169
|
+
- **`--error` flag** - Shows full error messages instead of 300-char preview
|
|
170
|
+
|
|
171
|
+
## Where Cursor Stores Data
|
|
172
|
+
|
|
173
|
+
| Platform | Path |
|
|
174
|
+
|----------|------|
|
|
175
|
+
| macOS | `~/Library/Application Support/Cursor/User/` |
|
|
176
|
+
| Windows | `%APPDATA%/Cursor/User/` |
|
|
177
|
+
| Linux | `~/.config/Cursor/User/` |
|
|
178
|
+
|
|
179
|
+
The tool automatically finds and reads your Cursor chat history from these locations.
|
|
180
|
+
|
|
181
|
+
## Development
|
|
182
|
+
|
|
183
|
+
### Building from Source
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm install
|
|
187
|
+
npm run build
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Running Tests
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm test # Run all tests
|
|
194
|
+
npm run test:watch # Watch mode
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Releasing to NPM
|
|
198
|
+
|
|
199
|
+
This project uses GitHub Actions for automatic NPM publishing. To release a new version:
|
|
200
|
+
|
|
201
|
+
1. Update version in `package.json`:
|
|
202
|
+
```bash
|
|
203
|
+
npm version patch # For bug fixes (0.1.0 -> 0.1.1)
|
|
204
|
+
npm version minor # For new features (0.1.0 -> 0.2.0)
|
|
205
|
+
npm version major # For breaking changes (0.1.0 -> 1.0.0)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
2. Push the version tag to trigger automatic publishing:
|
|
209
|
+
```bash
|
|
210
|
+
git push origin main --tags
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
3. The GitHub workflow will automatically:
|
|
214
|
+
- Run type checks, linting, and tests
|
|
215
|
+
- Build the project
|
|
216
|
+
- Publish to NPM with provenance
|
|
217
|
+
|
|
218
|
+
**First-time setup**: Add your NPM access token as a GitHub secret named `NPM_TOKEN`:
|
|
219
|
+
1. Create an NPM access token at https://www.npmjs.com/settings/YOUR_USERNAME/tokens
|
|
220
|
+
2. Go to your GitHub repository settings → Secrets and variables → Actions
|
|
221
|
+
3. Add a new repository secret named `NPM_TOKEN` with your NPM token
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/export.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBzC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoJ5D"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export command - export chat sessions to files
|
|
3
|
+
*/
|
|
4
|
+
import { writeFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { getSession, listSessions, findWorkspaces } from '../../core/storage.js';
|
|
7
|
+
import { exportToMarkdown, exportToJson } from '../../core/parser.js';
|
|
8
|
+
import { formatExportSuccess, formatExportResultJson } from '../formatters/index.js';
|
|
9
|
+
import { SessionNotFoundError, FileExistsError, handleError, CliError, ExitCode, } from '../../lib/errors.js';
|
|
10
|
+
import { expandPath, contractPath } from '../../lib/platform.js';
|
|
11
|
+
/**
|
|
12
|
+
* Register the export command
|
|
13
|
+
*/
|
|
14
|
+
export function registerExportCommand(program) {
|
|
15
|
+
program
|
|
16
|
+
.command('export [index]')
|
|
17
|
+
.description('Export chat session(s) to file')
|
|
18
|
+
.option('-o, --output <path>', 'Output file or directory')
|
|
19
|
+
.option('-f, --format <format>', 'Output format: md or json', 'md')
|
|
20
|
+
.option('--force', 'Overwrite existing files')
|
|
21
|
+
.option('-a, --all', 'Export all sessions')
|
|
22
|
+
.action(async (indexArg, options, command) => {
|
|
23
|
+
const globalOptions = command.parent?.opts();
|
|
24
|
+
const useJson = options.json ?? globalOptions?.json ?? false;
|
|
25
|
+
const customPath = options.dataPath ?? globalOptions?.dataPath;
|
|
26
|
+
const format = options.format === 'json' ? 'json' : 'md';
|
|
27
|
+
try {
|
|
28
|
+
// Validate arguments
|
|
29
|
+
if (!options.all && !indexArg) {
|
|
30
|
+
throw new CliError('Please specify a session index or use --all to export all sessions.', ExitCode.USAGE_ERROR);
|
|
31
|
+
}
|
|
32
|
+
const exported = [];
|
|
33
|
+
if (options.all) {
|
|
34
|
+
// Export all sessions
|
|
35
|
+
const sessions = listSessions({ limit: 0, all: true }, customPath ? expandPath(customPath) : undefined);
|
|
36
|
+
if (sessions.length === 0) {
|
|
37
|
+
throw new CliError('No sessions to export.', ExitCode.NOT_FOUND);
|
|
38
|
+
}
|
|
39
|
+
// Determine output directory
|
|
40
|
+
const outputDir = options.output ? expandPath(options.output) : process.cwd();
|
|
41
|
+
// Create directory if needed
|
|
42
|
+
if (!existsSync(outputDir)) {
|
|
43
|
+
mkdirSync(outputDir, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
const workspaces = findWorkspaces(customPath ? expandPath(customPath) : undefined);
|
|
46
|
+
for (const summary of sessions) {
|
|
47
|
+
const session = getSession(summary.index, customPath ? expandPath(customPath) : undefined);
|
|
48
|
+
if (!session)
|
|
49
|
+
continue;
|
|
50
|
+
const workspace = workspaces.find((w) => w.id === session.workspaceId);
|
|
51
|
+
const workspacePath = workspace?.path;
|
|
52
|
+
// Generate filename
|
|
53
|
+
const dateStr = session.createdAt.toISOString().split('T')[0];
|
|
54
|
+
const safeTitle = (session.title ?? 'untitled')
|
|
55
|
+
.replace(/[^a-zA-Z0-9-_]/g, '_')
|
|
56
|
+
.slice(0, 30);
|
|
57
|
+
const filename = `${dateStr}-${session.index}-${safeTitle}.${format}`;
|
|
58
|
+
const filePath = join(outputDir, filename);
|
|
59
|
+
// Check if file exists
|
|
60
|
+
if (existsSync(filePath) && !options.force) {
|
|
61
|
+
throw new FileExistsError(filePath);
|
|
62
|
+
}
|
|
63
|
+
// Export
|
|
64
|
+
const content = format === 'json'
|
|
65
|
+
? exportToJson(session, workspacePath)
|
|
66
|
+
: exportToMarkdown(session, workspacePath);
|
|
67
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
68
|
+
exported.push({ index: session.index, path: contractPath(filePath) });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Export single session
|
|
73
|
+
const index = parseInt(indexArg, 10);
|
|
74
|
+
if (isNaN(index) || index < 1) {
|
|
75
|
+
throw new CliError(`Invalid index: ${indexArg}. Must be a positive number.`, ExitCode.USAGE_ERROR);
|
|
76
|
+
}
|
|
77
|
+
const session = getSession(index, customPath ? expandPath(customPath) : undefined);
|
|
78
|
+
if (!session) {
|
|
79
|
+
const sessions = listSessions({ limit: 0, all: true }, customPath ? expandPath(customPath) : undefined);
|
|
80
|
+
throw new SessionNotFoundError(index, sessions.length);
|
|
81
|
+
}
|
|
82
|
+
const workspaces = findWorkspaces(customPath ? expandPath(customPath) : undefined);
|
|
83
|
+
const workspace = workspaces.find((w) => w.id === session.workspaceId);
|
|
84
|
+
const workspacePath = workspace?.path;
|
|
85
|
+
// Determine output path
|
|
86
|
+
let outputPath;
|
|
87
|
+
if (options.output) {
|
|
88
|
+
outputPath = expandPath(options.output);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const dateStr = session.createdAt.toISOString().split('T')[0];
|
|
92
|
+
const safeTitle = (session.title ?? 'untitled')
|
|
93
|
+
.replace(/[^a-zA-Z0-9-_]/g, '_')
|
|
94
|
+
.slice(0, 30);
|
|
95
|
+
outputPath = `${dateStr}-${index}-${safeTitle}.${format}`;
|
|
96
|
+
}
|
|
97
|
+
// Check if file exists
|
|
98
|
+
if (existsSync(outputPath) && !options.force) {
|
|
99
|
+
throw new FileExistsError(outputPath);
|
|
100
|
+
}
|
|
101
|
+
// Create directory if needed
|
|
102
|
+
const dir = dirname(outputPath);
|
|
103
|
+
if (dir !== '.' && !existsSync(dir)) {
|
|
104
|
+
mkdirSync(dir, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
// Export
|
|
107
|
+
const content = format === 'json'
|
|
108
|
+
? exportToJson(session, workspacePath)
|
|
109
|
+
: exportToMarkdown(session, workspacePath);
|
|
110
|
+
writeFileSync(outputPath, content, 'utf-8');
|
|
111
|
+
exported.push({ index, path: contractPath(outputPath) });
|
|
112
|
+
}
|
|
113
|
+
// Output result
|
|
114
|
+
if (useJson) {
|
|
115
|
+
console.log(formatExportResultJson(exported));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.log(formatExportSuccess(exported));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
handleError(error);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../../src/cli/commands/export.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAWjE;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,gBAAgB,CAAC;SACzB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,qBAAqB,EAAE,0BAA0B,CAAC;SACzD,MAAM,CAAC,uBAAuB,EAAE,2BAA2B,EAAE,IAAI,CAAC;SAClE,MAAM,CAAC,SAAS,EAAE,0BAA0B,CAAC;SAC7C,MAAM,CAAC,WAAW,EAAE,qBAAqB,CAAC;SAC1C,MAAM,CACL,KAAK,EAAE,QAA4B,EAAE,OAA6B,EAAE,OAAgB,EAAE,EAAE;QACtF,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAA2C,CAAC;QACtF,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,aAAa,EAAE,IAAI,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C,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAC3D,CAAC;YAED,gBAAgB;YAChB,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChD,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CACF,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBzC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuE1D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List command - display chat sessions and workspaces
|
|
3
|
+
*/
|
|
4
|
+
import { listSessions, listWorkspaces } from '../../core/storage.js';
|
|
5
|
+
import { formatSessionsTable, formatSessionsJson, formatWorkspacesTable, formatWorkspacesJson, formatNoHistory, formatCursorNotFound, } from '../formatters/index.js';
|
|
6
|
+
import { getCursorDataPath, expandPath } from '../../lib/platform.js';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
/**
|
|
9
|
+
* Register the list command
|
|
10
|
+
*/
|
|
11
|
+
export function registerListCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('list')
|
|
14
|
+
.alias('ls')
|
|
15
|
+
.description('List chat sessions')
|
|
16
|
+
.option('-n, --limit <number>', 'Maximum sessions to show', '20')
|
|
17
|
+
.option('-a, --all', 'Show all sessions (ignore limit)')
|
|
18
|
+
.option('--workspaces', 'List workspaces instead of sessions')
|
|
19
|
+
.option('--ids', 'Show composer IDs (for external export tools)')
|
|
20
|
+
.action(async (options, command) => {
|
|
21
|
+
const globalOptions = command.parent?.opts();
|
|
22
|
+
const useJson = options.json ?? globalOptions?.json ?? false;
|
|
23
|
+
const customPath = options.dataPath ?? globalOptions?.dataPath;
|
|
24
|
+
const workspaceFilter = options.workspace ?? globalOptions?.workspace;
|
|
25
|
+
if (options.workspaces) {
|
|
26
|
+
// Verify Cursor data exists for workspaces listing
|
|
27
|
+
const dataPath = getCursorDataPath(customPath ? expandPath(customPath) : undefined);
|
|
28
|
+
if (!existsSync(dataPath)) {
|
|
29
|
+
if (useJson) {
|
|
30
|
+
console.log(JSON.stringify({ error: 'Cursor data not found', path: dataPath }));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.log(formatCursorNotFound(dataPath));
|
|
34
|
+
}
|
|
35
|
+
process.exit(3);
|
|
36
|
+
}
|
|
37
|
+
// List workspaces
|
|
38
|
+
const workspaces = listWorkspaces(customPath ? expandPath(customPath) : undefined);
|
|
39
|
+
if (workspaces.length === 0) {
|
|
40
|
+
if (useJson) {
|
|
41
|
+
console.log(JSON.stringify({ count: 0, workspaces: [] }));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log(formatNoHistory());
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (useJson) {
|
|
49
|
+
console.log(formatWorkspacesJson(workspaces));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(formatWorkspacesTable(workspaces));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// List sessions
|
|
57
|
+
const limit = options.all ? 0 : parseInt(options.limit ?? '20', 10);
|
|
58
|
+
const sessions = listSessions({ limit, all: options.all ?? false, workspacePath: workspaceFilter }, customPath ? expandPath(customPath) : undefined);
|
|
59
|
+
if (sessions.length === 0) {
|
|
60
|
+
if (useJson) {
|
|
61
|
+
console.log(JSON.stringify({ count: 0, sessions: [] }));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.log(formatNoHistory());
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (useJson) {
|
|
69
|
+
console.log(formatSessionsJson(sessions));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log(formatSessionsTable(sessions, options.ids ?? false));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAYrC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,KAAK,CAAC,IAAI,CAAC;SACX,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CAAC,sBAAsB,EAAE,0BAA0B,EAAE,IAAI,CAAC;SAChE,MAAM,CAAC,WAAW,EAAE,kCAAkC,CAAC;SACvD,MAAM,CAAC,cAAc,EAAE,qCAAqC,CAAC;SAC7D,MAAM,CAAC,OAAO,EAAE,+CAA+C,CAAC;SAChE,MAAM,CAAC,KAAK,EAAE,OAA2B,EAAE,OAA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,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/search.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAczC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4C5D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search command - search across chat sessions
|
|
3
|
+
*/
|
|
4
|
+
import { searchSessions } from '../../core/storage.js';
|
|
5
|
+
import { formatSearchResultsTable, formatSearchResultsJson } from '../formatters/index.js';
|
|
6
|
+
import { NoSearchResultsError, handleError } from '../../lib/errors.js';
|
|
7
|
+
import { expandPath } from '../../lib/platform.js';
|
|
8
|
+
/**
|
|
9
|
+
* Register the search command
|
|
10
|
+
*/
|
|
11
|
+
export function registerSearchCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('search <query>')
|
|
14
|
+
.description('Search chat history for a keyword')
|
|
15
|
+
.option('-n, --limit <number>', 'Maximum results to show', '10')
|
|
16
|
+
.option('-c, --context <chars>', 'Context characters around match', '50')
|
|
17
|
+
.action(async (query, options, command) => {
|
|
18
|
+
const globalOptions = command.parent?.opts();
|
|
19
|
+
const useJson = options.json ?? globalOptions?.json ?? false;
|
|
20
|
+
const customPath = options.dataPath ?? globalOptions?.dataPath;
|
|
21
|
+
const workspaceFilter = options.workspace ?? globalOptions?.workspace;
|
|
22
|
+
const limit = parseInt(options.limit ?? '10', 10);
|
|
23
|
+
const contextChars = parseInt(options.context ?? '50', 10);
|
|
24
|
+
try {
|
|
25
|
+
const results = searchSessions(query, { limit, contextChars, workspacePath: workspaceFilter }, customPath ? expandPath(customPath) : undefined);
|
|
26
|
+
if (results.length === 0) {
|
|
27
|
+
if (useJson) {
|
|
28
|
+
console.log(JSON.stringify({ query, count: 0, totalMatches: 0, results: [] }));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new NoSearchResultsError(query);
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (useJson) {
|
|
36
|
+
console.log(formatSearchResultsJson(results, query));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log(formatSearchResultsTable(results, query));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
handleError(error);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/cli/commands/search.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAUnD;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,gBAAgB,CAAC;SACzB,WAAW,CAAC,mCAAmC,CAAC;SAChD,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,EAAE,IAAI,CAAC;SAC/D,MAAM,CAAC,uBAAuB,EAAE,iCAAiC,EAAE,IAAI,CAAC;SACxE,MAAM,CAAC,KAAK,EAAE,KAAa,EAAE,OAA6B,EAAE,OAAgB,EAAE,EAAE;QAC/E,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAIzC,C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;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/show.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAezC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+C1D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Show command - display a single chat session in detail
|
|
3
|
+
*/
|
|
4
|
+
import { getSession, listSessions } from '../../core/storage.js';
|
|
5
|
+
import { formatSessionDetail, formatSessionJson } from '../formatters/index.js';
|
|
6
|
+
import { SessionNotFoundError, handleError } from '../../lib/errors.js';
|
|
7
|
+
import { expandPath } from '../../lib/platform.js';
|
|
8
|
+
/**
|
|
9
|
+
* Register the show command
|
|
10
|
+
*/
|
|
11
|
+
export function registerShowCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('show <index>')
|
|
14
|
+
.description('Show a chat session by index')
|
|
15
|
+
.option('-s, --short', 'Truncate user and assistant messages')
|
|
16
|
+
.option('-t, --think', 'Show full thinking/reasoning text')
|
|
17
|
+
.option('--tool', 'Show full tool call details (commands, content, results)')
|
|
18
|
+
.option('-e, --error', 'Show full error messages (default: truncated)')
|
|
19
|
+
.action(async (indexArg, options, command) => {
|
|
20
|
+
const globalOptions = command.parent?.opts();
|
|
21
|
+
const useJson = options.json ?? globalOptions?.json ?? false;
|
|
22
|
+
const customPath = options.dataPath ?? globalOptions?.dataPath;
|
|
23
|
+
const index = parseInt(indexArg, 10);
|
|
24
|
+
if (isNaN(index) || index < 1) {
|
|
25
|
+
handleError(new Error(`Invalid index: ${indexArg}. Must be a positive number.`));
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const session = getSession(index, customPath ? expandPath(customPath) : undefined);
|
|
29
|
+
if (!session) {
|
|
30
|
+
// Get max index for error message
|
|
31
|
+
const sessions = listSessions({ limit: 0, all: true }, customPath ? expandPath(customPath) : undefined);
|
|
32
|
+
throw new SessionNotFoundError(index, sessions.length);
|
|
33
|
+
}
|
|
34
|
+
if (useJson) {
|
|
35
|
+
console.log(formatSessionJson(session, session.workspacePath));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.log(formatSessionDetail(session, session.workspacePath, {
|
|
39
|
+
short: options.short ?? false,
|
|
40
|
+
fullThinking: options.think ?? false,
|
|
41
|
+
fullTool: options.tool ?? false,
|
|
42
|
+
fullError: options.error ?? false,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
handleError(error);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/cli/commands/show.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAWnD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,8BAA8B,CAAC;SAC3C,MAAM,CAAC,aAAa,EAAE,sCAAsC,CAAC;SAC7D,MAAM,CAAC,aAAa,EAAE,mCAAmC,CAAC;SAC1D,MAAM,CAAC,QAAQ,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O,CAAC,GAAG,CACT,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;oBAClD,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;oBAC7B,YAAY,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;oBACpC,QAAQ,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;oBAC/B,SAAS,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;iBAClC,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/formatters/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/formatters/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|