@ebowwa/claudecodehistory 1.1.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 +266 -0
- package/dist/history-service.d.ts +107 -0
- package/dist/history-service.d.ts.map +1 -0
- package/dist/history-service.js +398 -0
- package/dist/history-service.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# @ebowwa/claudecodehistory
|
|
2
|
+
|
|
3
|
+
A TypeScript library for accessing and analyzing Claude Code conversation history with smart filtering and pagination.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
This library provides a `ClaudeCodeHistoryService` class that offers:
|
|
8
|
+
|
|
9
|
+
- **Conversation History Access** - Read Claude Code's `.jsonl` history files from `~/.claude/projects/`
|
|
10
|
+
- **Smart Filtering** - Filter by date range, project, session, and message types
|
|
11
|
+
- **Pagination Support** - Efficiently handle large datasets with limit/offset
|
|
12
|
+
- **Timezone Intelligence** - Automatic timezone detection with manual override support
|
|
13
|
+
- **Content Search** - Search conversation content across all projects
|
|
14
|
+
- **TypeScript Types** - Full TypeScript support with exported types
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @ebowwa/claudecodehistory
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { ClaudeCodeHistoryService } from '@ebowwa/claudecodehistory';
|
|
26
|
+
|
|
27
|
+
const service = new ClaudeCodeHistoryService();
|
|
28
|
+
|
|
29
|
+
// List all projects
|
|
30
|
+
const projects = await service.listProjects();
|
|
31
|
+
console.log(projects);
|
|
32
|
+
// [
|
|
33
|
+
// {
|
|
34
|
+
// projectPath: '/Users/username/code/my-project',
|
|
35
|
+
// sessionCount: 15,
|
|
36
|
+
// messageCount: 342,
|
|
37
|
+
// lastActivityTime: '2025-01-15T10:30:00.000Z'
|
|
38
|
+
// }
|
|
39
|
+
// ]
|
|
40
|
+
|
|
41
|
+
// Get conversation history with pagination
|
|
42
|
+
const history = await service.getConversationHistory({
|
|
43
|
+
limit: 20,
|
|
44
|
+
offset: 0,
|
|
45
|
+
messageTypes: ['user'], // Only user messages (default)
|
|
46
|
+
timezone: 'Asia/Tokyo'
|
|
47
|
+
});
|
|
48
|
+
console.log(history.entries);
|
|
49
|
+
console.log(history.pagination);
|
|
50
|
+
// {
|
|
51
|
+
// total_count: 150,
|
|
52
|
+
// limit: 20,
|
|
53
|
+
// offset: 0,
|
|
54
|
+
// has_more: true
|
|
55
|
+
// }
|
|
56
|
+
|
|
57
|
+
// Search conversations
|
|
58
|
+
const results = await service.searchConversations('API integration', {
|
|
59
|
+
limit: 30,
|
|
60
|
+
projectPath: '/Users/username/code/my-project',
|
|
61
|
+
startDate: '2025-01-01',
|
|
62
|
+
endDate: '2025-01-31'
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API
|
|
67
|
+
|
|
68
|
+
### `ClaudeCodeHistoryService`
|
|
69
|
+
|
|
70
|
+
Main service class for accessing Claude Code history.
|
|
71
|
+
|
|
72
|
+
#### Constructor
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const service = new ClaudeCodeHistoryService();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Automatically uses `~/.claude` as the data directory.
|
|
79
|
+
|
|
80
|
+
#### Methods
|
|
81
|
+
|
|
82
|
+
##### `getConversationHistory(options)`
|
|
83
|
+
|
|
84
|
+
Get paginated conversation history.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
const result = await service.getConversationHistory({
|
|
88
|
+
sessionId?: string, // Filter by specific session
|
|
89
|
+
startDate?: string, // Start date (e.g., "2025-01-01")
|
|
90
|
+
endDate?: string, // End date (e.g., "2025-01-31")
|
|
91
|
+
limit?: number, // Max entries (default: 20)
|
|
92
|
+
offset?: number, // Skip entries (default: 0)
|
|
93
|
+
messageTypes?: Array<'user' | 'assistant' | 'system' | 'result'>,
|
|
94
|
+
timezone?: string // Timezone (e.g., "Asia/Tokyo", "UTC")
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Returns: `PaginatedConversationResponse`
|
|
99
|
+
|
|
100
|
+
##### `searchConversations(query, options)`
|
|
101
|
+
|
|
102
|
+
Search conversation content.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const results = await service.searchConversations('search query', {
|
|
106
|
+
limit?: number,
|
|
107
|
+
projectPath?: string,
|
|
108
|
+
startDate?: string,
|
|
109
|
+
endDate?: string,
|
|
110
|
+
timezone?: string
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Returns: `ConversationEntry[]`
|
|
115
|
+
|
|
116
|
+
##### `listProjects()`
|
|
117
|
+
|
|
118
|
+
List all projects with conversation history.
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const projects = await service.listProjects();
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Returns: `ProjectInfo[]`
|
|
125
|
+
|
|
126
|
+
##### `listSessions(options)`
|
|
127
|
+
|
|
128
|
+
List conversation sessions.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const sessions = await service.listSessions({
|
|
132
|
+
projectPath?: string,
|
|
133
|
+
startDate?: string,
|
|
134
|
+
endDate?: string,
|
|
135
|
+
timezone?: string
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Returns: `SessionInfo[]`
|
|
140
|
+
|
|
141
|
+
## Types
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
interface ConversationEntry {
|
|
145
|
+
sessionId: string;
|
|
146
|
+
timestamp: string;
|
|
147
|
+
type: 'user' | 'assistant' | 'system' | 'result';
|
|
148
|
+
content: string;
|
|
149
|
+
projectPath: string;
|
|
150
|
+
uuid: string;
|
|
151
|
+
formattedTime?: string;
|
|
152
|
+
timeAgo?: string;
|
|
153
|
+
localDate?: string;
|
|
154
|
+
metadata?: {
|
|
155
|
+
usage?: any;
|
|
156
|
+
totalCostUsd?: number;
|
|
157
|
+
numTurns?: number;
|
|
158
|
+
durationMs?: number;
|
|
159
|
+
isError?: boolean;
|
|
160
|
+
errorType?: string;
|
|
161
|
+
model?: string;
|
|
162
|
+
requestId?: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface PaginatedConversationResponse {
|
|
167
|
+
entries: ConversationEntry[];
|
|
168
|
+
pagination: {
|
|
169
|
+
total_count: number;
|
|
170
|
+
limit: number;
|
|
171
|
+
offset: number;
|
|
172
|
+
has_more: boolean;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface ProjectInfo {
|
|
177
|
+
projectPath: string;
|
|
178
|
+
sessionCount: number;
|
|
179
|
+
messageCount: number;
|
|
180
|
+
lastActivityTime: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface SessionInfo {
|
|
184
|
+
sessionId: string;
|
|
185
|
+
projectPath: string;
|
|
186
|
+
startTime: string;
|
|
187
|
+
endTime: string;
|
|
188
|
+
messageCount: number;
|
|
189
|
+
userMessageCount: number;
|
|
190
|
+
assistantMessageCount: number;
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Smart Features
|
|
195
|
+
|
|
196
|
+
### Message Type Filtering
|
|
197
|
+
|
|
198
|
+
Default behavior only returns user messages to reduce data volume:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// Only user messages (default)
|
|
202
|
+
await service.getConversationHistory();
|
|
203
|
+
|
|
204
|
+
// User and assistant messages
|
|
205
|
+
await service.getConversationHistory({
|
|
206
|
+
messageTypes: ['user', 'assistant']
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// All message types
|
|
210
|
+
await service.getConversationHistory({
|
|
211
|
+
messageTypes: ['user', 'assistant', 'system', 'result']
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Timezone Support
|
|
216
|
+
|
|
217
|
+
Automatic timezone detection with manual override:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
// Auto-detect system timezone
|
|
221
|
+
await service.getConversationHistory();
|
|
222
|
+
|
|
223
|
+
// Explicit timezone
|
|
224
|
+
await service.getConversationHistory({
|
|
225
|
+
timezone: 'Asia/Tokyo'
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Date Filtering
|
|
230
|
+
|
|
231
|
+
Smart date normalization with timezone awareness:
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
await service.getConversationHistory({
|
|
235
|
+
startDate: '2025-01-01', // Automatically normalized to proper timezone bounds
|
|
236
|
+
endDate: '2025-01-31',
|
|
237
|
+
timezone: 'America/New_York'
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Example MCP Server
|
|
242
|
+
|
|
243
|
+
This repository includes an example MCP server in the `example/` directory that demonstrates how to use this library to build an MCP server.
|
|
244
|
+
|
|
245
|
+
See [example/README.md](./example/README.md) for details.
|
|
246
|
+
|
|
247
|
+
## Development
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Clone repository
|
|
251
|
+
git clone https://github.com/ebowwa/claude-code-history-mcp.git
|
|
252
|
+
cd claude-code-history-mcp
|
|
253
|
+
|
|
254
|
+
# Install dependencies
|
|
255
|
+
npm install
|
|
256
|
+
|
|
257
|
+
# Build
|
|
258
|
+
npm run build
|
|
259
|
+
|
|
260
|
+
# Run tests
|
|
261
|
+
npm test
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export interface ClaudeCodeMessage {
|
|
2
|
+
parentUuid: string | null;
|
|
3
|
+
isSidechain: boolean;
|
|
4
|
+
userType: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
version: string;
|
|
8
|
+
type: 'user' | 'assistant' | 'system' | 'result';
|
|
9
|
+
message?: {
|
|
10
|
+
role: string;
|
|
11
|
+
content: string | any[];
|
|
12
|
+
model?: string;
|
|
13
|
+
usage?: any;
|
|
14
|
+
};
|
|
15
|
+
uuid: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
requestId?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ConversationEntry {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
type: 'user' | 'assistant' | 'system' | 'result';
|
|
23
|
+
content: string;
|
|
24
|
+
projectPath: string;
|
|
25
|
+
uuid: string;
|
|
26
|
+
formattedTime?: string;
|
|
27
|
+
timeAgo?: string;
|
|
28
|
+
localDate?: string;
|
|
29
|
+
metadata?: {
|
|
30
|
+
usage?: any;
|
|
31
|
+
totalCostUsd?: number;
|
|
32
|
+
numTurns?: number;
|
|
33
|
+
durationMs?: number;
|
|
34
|
+
isError?: boolean;
|
|
35
|
+
errorType?: string;
|
|
36
|
+
model?: string;
|
|
37
|
+
requestId?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface PaginatedConversationResponse {
|
|
41
|
+
entries: ConversationEntry[];
|
|
42
|
+
pagination: {
|
|
43
|
+
total_count: number;
|
|
44
|
+
limit: number;
|
|
45
|
+
offset: number;
|
|
46
|
+
has_more: boolean;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface HistoryQueryOptions {
|
|
50
|
+
sessionId?: string;
|
|
51
|
+
startDate?: string;
|
|
52
|
+
endDate?: string;
|
|
53
|
+
limit?: number;
|
|
54
|
+
offset?: number;
|
|
55
|
+
timezone?: string;
|
|
56
|
+
messageTypes?: ('user' | 'assistant' | 'system' | 'result')[];
|
|
57
|
+
}
|
|
58
|
+
export interface SessionListOptions {
|
|
59
|
+
projectPath?: string;
|
|
60
|
+
startDate?: string;
|
|
61
|
+
endDate?: string;
|
|
62
|
+
timezone?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ProjectInfo {
|
|
65
|
+
projectPath: string;
|
|
66
|
+
sessionCount: number;
|
|
67
|
+
messageCount: number;
|
|
68
|
+
lastActivityTime: string;
|
|
69
|
+
}
|
|
70
|
+
export interface SessionInfo {
|
|
71
|
+
sessionId: string;
|
|
72
|
+
projectPath: string;
|
|
73
|
+
startTime: string;
|
|
74
|
+
endTime: string;
|
|
75
|
+
messageCount: number;
|
|
76
|
+
userMessageCount: number;
|
|
77
|
+
assistantMessageCount: number;
|
|
78
|
+
}
|
|
79
|
+
export interface SearchOptions {
|
|
80
|
+
limit?: number;
|
|
81
|
+
projectPath?: string;
|
|
82
|
+
startDate?: string;
|
|
83
|
+
endDate?: string;
|
|
84
|
+
timezone?: string;
|
|
85
|
+
}
|
|
86
|
+
export declare class ClaudeCodeHistoryService {
|
|
87
|
+
private claudeDir;
|
|
88
|
+
constructor(claudeDir?: string);
|
|
89
|
+
/**
|
|
90
|
+
* Normalize date string to ISO format for proper comparison with timezone support
|
|
91
|
+
*/
|
|
92
|
+
private normalizeDate;
|
|
93
|
+
getConversationHistory(options?: HistoryQueryOptions): Promise<PaginatedConversationResponse>;
|
|
94
|
+
searchConversations(searchQuery: string, options?: SearchOptions): Promise<ConversationEntry[]>;
|
|
95
|
+
listProjects(): Promise<ProjectInfo[]>;
|
|
96
|
+
listSessions(options?: SessionListOptions): Promise<SessionInfo[]>;
|
|
97
|
+
private loadClaudeHistoryEntries;
|
|
98
|
+
private parseJsonlFile;
|
|
99
|
+
private convertClaudeMessageToEntry;
|
|
100
|
+
private getTimeAgo;
|
|
101
|
+
private decodeProjectPath;
|
|
102
|
+
/**
|
|
103
|
+
* Determines whether to skip reading a file based on its modification time
|
|
104
|
+
*/
|
|
105
|
+
private shouldSkipFile;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=history-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-service.d.ts","sourceRoot":"","sources":["../src/history-service.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACjD,OAAO,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,GAAG,CAAC;KACb,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,C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CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,wBAAwB;IACnC,OAAO,CAAC,SAAS,CAAS;gBAEd,SAAS,CAAC,EAAE,MAAM;IAI9B;;OAEG;IACH,OAAO,CAAC,aAAa;IAmDf,sBAAsB,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IA0DjG,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAwCnG,YAAY,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IA6DtC,YAAY,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YAkE9D,wBAAwB;YAqCxB,cAAc;IAuC5B,OAAO,CAAC,2BAA2B;IAyDnC,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,iBAAiB;IAKzB;;OAEG;YACW,cAAc;CA8B7B"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import { createReadStream } from 'fs';
|
|
5
|
+
import { createInterface } from 'readline';
|
|
6
|
+
export class ClaudeCodeHistoryService {
|
|
7
|
+
claudeDir;
|
|
8
|
+
constructor(claudeDir) {
|
|
9
|
+
this.claudeDir = claudeDir || path.join(os.homedir(), '.claude');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Normalize date string to ISO format for proper comparison with timezone support
|
|
13
|
+
*/
|
|
14
|
+
normalizeDate(dateString, isEndDate = false, timezone) {
|
|
15
|
+
if (dateString.includes('T')) {
|
|
16
|
+
return dateString;
|
|
17
|
+
}
|
|
18
|
+
const tz = timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
19
|
+
try {
|
|
20
|
+
if (tz === 'UTC') {
|
|
21
|
+
const timeStr = isEndDate ? '23:59:59.999' : '00:00:00.000';
|
|
22
|
+
return `${dateString}T${timeStr}Z`;
|
|
23
|
+
}
|
|
24
|
+
// Correct approach: Create date in target timezone and convert to UTC
|
|
25
|
+
const [year, month, day] = dateString.split('-').map(Number);
|
|
26
|
+
const hour = isEndDate ? 23 : 0;
|
|
27
|
+
const minute = isEndDate ? 59 : 0;
|
|
28
|
+
const second = isEndDate ? 59 : 0;
|
|
29
|
+
const millisecond = isEndDate ? 999 : 0;
|
|
30
|
+
// Create a reference date to calculate offset
|
|
31
|
+
const referenceDate = new Date(year, month - 1, day, 12, 0, 0); // Use noon for stable offset
|
|
32
|
+
// Calculate timezone offset for this specific date (handles DST)
|
|
33
|
+
const offsetMs = referenceDate.getTimezoneOffset() * 60000;
|
|
34
|
+
// Create the target time in the specified timezone
|
|
35
|
+
const localTime = new Date(year, month - 1, day, hour, minute, second, millisecond);
|
|
36
|
+
// Get what this local time would be in the target timezone
|
|
37
|
+
const targetTzTime = new Date(localTime.toLocaleString('en-CA', { timeZone: tz }));
|
|
38
|
+
const utcTime = new Date(localTime.toLocaleString('en-CA', { timeZone: 'UTC' }));
|
|
39
|
+
// Calculate the difference between target timezone and UTC
|
|
40
|
+
const tzOffsetMs = targetTzTime.getTime() - utcTime.getTime();
|
|
41
|
+
// Adjust local time to get UTC equivalent
|
|
42
|
+
const utcResult = new Date(localTime.getTime() + offsetMs - tzOffsetMs);
|
|
43
|
+
const result = utcResult.toISOString();
|
|
44
|
+
console.log(`normalizeDate: ${dateString} (${isEndDate ? 'end' : 'start'}) in ${tz} -> ${result}`);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.warn(`Failed to process timezone ${tz}, falling back to simple conversion:`, error);
|
|
49
|
+
const fallback = `${dateString}T${isEndDate ? '23:59:59.999' : '00:00:00.000'}Z`;
|
|
50
|
+
console.log(`normalizeDate fallback: ${dateString} -> ${fallback}`);
|
|
51
|
+
return fallback;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async getConversationHistory(options = {}) {
|
|
55
|
+
const { sessionId, startDate, endDate, limit = 20, offset = 0, timezone, messageTypes } = options;
|
|
56
|
+
// Normalize date strings for proper comparison
|
|
57
|
+
const normalizedStartDate = startDate ? this.normalizeDate(startDate, false, timezone) : undefined;
|
|
58
|
+
const normalizedEndDate = endDate ? this.normalizeDate(endDate, true, timezone) : undefined;
|
|
59
|
+
// Determine which message types to include (default to user only to reduce data volume)
|
|
60
|
+
const allowedTypes = messageTypes && messageTypes.length > 0 ? messageTypes : ['user'];
|
|
61
|
+
// Load history from Claude Code's .jsonl files with pre-filtering
|
|
62
|
+
let allEntries = await this.loadClaudeHistoryEntries({
|
|
63
|
+
startDate: normalizedStartDate,
|
|
64
|
+
endDate: normalizedEndDate
|
|
65
|
+
});
|
|
66
|
+
// Filter by session ID if specified
|
|
67
|
+
if (sessionId) {
|
|
68
|
+
allEntries = allEntries.filter(entry => entry.sessionId === sessionId);
|
|
69
|
+
}
|
|
70
|
+
// Filter by message types (defaults to user only)
|
|
71
|
+
allEntries = allEntries.filter(entry => allowedTypes.includes(entry.type));
|
|
72
|
+
// Filter by date range if specified (additional in-memory filtering for precision)
|
|
73
|
+
if (normalizedStartDate) {
|
|
74
|
+
allEntries = allEntries.filter(entry => entry.timestamp >= normalizedStartDate);
|
|
75
|
+
}
|
|
76
|
+
if (normalizedEndDate) {
|
|
77
|
+
allEntries = allEntries.filter(entry => entry.timestamp <= normalizedEndDate);
|
|
78
|
+
}
|
|
79
|
+
// Sort by timestamp (newest first)
|
|
80
|
+
allEntries.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
81
|
+
// Calculate pagination
|
|
82
|
+
const totalCount = allEntries.length;
|
|
83
|
+
const paginatedEntries = allEntries.slice(offset, offset + limit);
|
|
84
|
+
const hasMore = offset + limit < totalCount;
|
|
85
|
+
return {
|
|
86
|
+
entries: paginatedEntries,
|
|
87
|
+
pagination: {
|
|
88
|
+
total_count: totalCount,
|
|
89
|
+
limit,
|
|
90
|
+
offset,
|
|
91
|
+
has_more: hasMore
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async searchConversations(searchQuery, options = {}) {
|
|
96
|
+
const { limit = 30, projectPath, startDate, endDate, timezone } = options;
|
|
97
|
+
// Normalize date strings for proper comparison
|
|
98
|
+
const normalizedStartDate = startDate ? this.normalizeDate(startDate, false, timezone) : undefined;
|
|
99
|
+
const normalizedEndDate = endDate ? this.normalizeDate(endDate, true, timezone) : undefined;
|
|
100
|
+
const allEntries = await this.loadClaudeHistoryEntries({
|
|
101
|
+
startDate: normalizedStartDate,
|
|
102
|
+
endDate: normalizedEndDate
|
|
103
|
+
});
|
|
104
|
+
const queryLower = searchQuery.toLowerCase();
|
|
105
|
+
let matchedEntries = allEntries.filter(entry => entry.content.toLowerCase().includes(queryLower));
|
|
106
|
+
// Filter by project path if specified
|
|
107
|
+
if (projectPath) {
|
|
108
|
+
matchedEntries = matchedEntries.filter(entry => entry.projectPath === projectPath);
|
|
109
|
+
}
|
|
110
|
+
// Filter by date range if specified (additional in-memory filtering for precision)
|
|
111
|
+
if (normalizedStartDate) {
|
|
112
|
+
matchedEntries = matchedEntries.filter(entry => entry.timestamp >= normalizedStartDate);
|
|
113
|
+
}
|
|
114
|
+
if (normalizedEndDate) {
|
|
115
|
+
matchedEntries = matchedEntries.filter(entry => entry.timestamp <= normalizedEndDate);
|
|
116
|
+
}
|
|
117
|
+
matchedEntries.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
118
|
+
return matchedEntries.slice(0, limit);
|
|
119
|
+
}
|
|
120
|
+
async listProjects() {
|
|
121
|
+
const projects = new Map();
|
|
122
|
+
try {
|
|
123
|
+
const projectsDir = path.join(this.claudeDir, 'projects');
|
|
124
|
+
const projectDirs = await fs.readdir(projectsDir);
|
|
125
|
+
for (const projectDir of projectDirs) {
|
|
126
|
+
const projectPath = path.join(projectsDir, projectDir);
|
|
127
|
+
const stats = await fs.stat(projectPath);
|
|
128
|
+
if (stats.isDirectory()) {
|
|
129
|
+
const files = await fs.readdir(projectPath);
|
|
130
|
+
const decodedPath = this.decodeProjectPath(projectDir);
|
|
131
|
+
if (!projects.has(decodedPath)) {
|
|
132
|
+
projects.set(decodedPath, {
|
|
133
|
+
sessionIds: new Set(),
|
|
134
|
+
messageCount: 0,
|
|
135
|
+
lastActivityTime: '1970-01-01T00:00:00.000Z'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const projectInfo = projects.get(decodedPath);
|
|
139
|
+
if (!projectInfo)
|
|
140
|
+
continue;
|
|
141
|
+
for (const file of files) {
|
|
142
|
+
if (file.endsWith('.jsonl')) {
|
|
143
|
+
const sessionId = file.replace('.jsonl', '');
|
|
144
|
+
projectInfo.sessionIds.add(sessionId);
|
|
145
|
+
const filePath = path.join(projectPath, file);
|
|
146
|
+
const fileStats = await fs.stat(filePath);
|
|
147
|
+
if (fileStats.mtime.toISOString() > projectInfo.lastActivityTime) {
|
|
148
|
+
projectInfo.lastActivityTime = fileStats.mtime.toISOString();
|
|
149
|
+
}
|
|
150
|
+
// Count messages in this session
|
|
151
|
+
const entries = await this.parseJsonlFile(filePath, projectDir);
|
|
152
|
+
projectInfo.messageCount += entries.length;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
console.error('Error listing projects:', error);
|
|
160
|
+
}
|
|
161
|
+
return Array.from(projects.entries()).map(([projectPath, info]) => ({
|
|
162
|
+
projectPath,
|
|
163
|
+
sessionCount: info.sessionIds.size,
|
|
164
|
+
messageCount: info.messageCount,
|
|
165
|
+
lastActivityTime: info.lastActivityTime
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
async listSessions(options = {}) {
|
|
169
|
+
const { projectPath, startDate, endDate, timezone } = options;
|
|
170
|
+
// Normalize date strings for proper comparison
|
|
171
|
+
const normalizedStartDate = startDate ? this.normalizeDate(startDate, false, timezone) : undefined;
|
|
172
|
+
const normalizedEndDate = endDate ? this.normalizeDate(endDate, true, timezone) : undefined;
|
|
173
|
+
const sessions = [];
|
|
174
|
+
try {
|
|
175
|
+
const projectsDir = path.join(this.claudeDir, 'projects');
|
|
176
|
+
const projectDirs = await fs.readdir(projectsDir);
|
|
177
|
+
for (const projectDir of projectDirs) {
|
|
178
|
+
const decodedPath = this.decodeProjectPath(projectDir);
|
|
179
|
+
// Filter by project path if specified
|
|
180
|
+
if (projectPath && decodedPath !== projectPath) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const projectDirPath = path.join(projectsDir, projectDir);
|
|
184
|
+
const stats = await fs.stat(projectDirPath);
|
|
185
|
+
if (stats.isDirectory()) {
|
|
186
|
+
const files = await fs.readdir(projectDirPath);
|
|
187
|
+
for (const file of files) {
|
|
188
|
+
if (file.endsWith('.jsonl')) {
|
|
189
|
+
const sessionId = file.replace('.jsonl', '');
|
|
190
|
+
const filePath = path.join(projectDirPath, file);
|
|
191
|
+
const entries = await this.parseJsonlFile(filePath, projectDir);
|
|
192
|
+
if (entries.length === 0)
|
|
193
|
+
continue;
|
|
194
|
+
const sessionStart = entries[entries.length - 1].timestamp;
|
|
195
|
+
const sessionEnd = entries[0].timestamp;
|
|
196
|
+
// Filter by date range if specified
|
|
197
|
+
if (normalizedStartDate && sessionEnd < normalizedStartDate)
|
|
198
|
+
continue;
|
|
199
|
+
if (normalizedEndDate && sessionStart > normalizedEndDate)
|
|
200
|
+
continue;
|
|
201
|
+
const userMessageCount = entries.filter(e => e.type === 'user').length;
|
|
202
|
+
const assistantMessageCount = entries.filter(e => e.type === 'assistant').length;
|
|
203
|
+
sessions.push({
|
|
204
|
+
sessionId,
|
|
205
|
+
projectPath: decodedPath,
|
|
206
|
+
startTime: sessionStart,
|
|
207
|
+
endTime: sessionEnd,
|
|
208
|
+
messageCount: entries.length,
|
|
209
|
+
userMessageCount,
|
|
210
|
+
assistantMessageCount
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
console.error('Error listing sessions:', error);
|
|
219
|
+
}
|
|
220
|
+
// Sort by start time (newest first)
|
|
221
|
+
sessions.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime());
|
|
222
|
+
return sessions;
|
|
223
|
+
}
|
|
224
|
+
async loadClaudeHistoryEntries(options = {}) {
|
|
225
|
+
const entries = [];
|
|
226
|
+
const { startDate, endDate } = options;
|
|
227
|
+
try {
|
|
228
|
+
const projectsDir = path.join(this.claudeDir, 'projects');
|
|
229
|
+
const projectDirs = await fs.readdir(projectsDir);
|
|
230
|
+
for (const projectDir of projectDirs) {
|
|
231
|
+
const projectPath = path.join(projectsDir, projectDir);
|
|
232
|
+
const stats = await fs.stat(projectPath);
|
|
233
|
+
if (stats.isDirectory()) {
|
|
234
|
+
const files = await fs.readdir(projectPath);
|
|
235
|
+
for (const file of files) {
|
|
236
|
+
if (file.endsWith('.jsonl')) {
|
|
237
|
+
const filePath = path.join(projectPath, file);
|
|
238
|
+
// Pre-filter files based on modification time
|
|
239
|
+
if (await this.shouldSkipFile(filePath, startDate, endDate)) {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const sessionEntries = await this.parseJsonlFile(filePath, projectDir, startDate, endDate);
|
|
243
|
+
entries.push(...sessionEntries);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
console.error('Error loading Claude history:', error);
|
|
251
|
+
}
|
|
252
|
+
return entries;
|
|
253
|
+
}
|
|
254
|
+
async parseJsonlFile(filePath, projectDir, startDate, endDate) {
|
|
255
|
+
const entries = [];
|
|
256
|
+
try {
|
|
257
|
+
const fileStream = createReadStream(filePath);
|
|
258
|
+
const rl = createInterface({
|
|
259
|
+
input: fileStream,
|
|
260
|
+
crlfDelay: Infinity
|
|
261
|
+
});
|
|
262
|
+
for await (const line of rl) {
|
|
263
|
+
if (line.trim()) {
|
|
264
|
+
try {
|
|
265
|
+
const claudeMessage = JSON.parse(line);
|
|
266
|
+
// Apply date filtering at message level for efficiency
|
|
267
|
+
if (startDate && claudeMessage.timestamp < startDate) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (endDate && claudeMessage.timestamp > endDate) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const entry = this.convertClaudeMessageToEntry(claudeMessage, projectDir);
|
|
274
|
+
if (entry) {
|
|
275
|
+
entries.push(entry);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch (parseError) {
|
|
279
|
+
console.error('Error parsing line:', parseError);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
console.error('Error reading file:', filePath, error);
|
|
286
|
+
}
|
|
287
|
+
return entries;
|
|
288
|
+
}
|
|
289
|
+
convertClaudeMessageToEntry(claudeMessage, projectDir) {
|
|
290
|
+
try {
|
|
291
|
+
let content = '';
|
|
292
|
+
if (claudeMessage.message?.content) {
|
|
293
|
+
if (typeof claudeMessage.message.content === 'string') {
|
|
294
|
+
content = claudeMessage.message.content;
|
|
295
|
+
}
|
|
296
|
+
else if (Array.isArray(claudeMessage.message.content)) {
|
|
297
|
+
// Handle array content (e.g., from assistant messages)
|
|
298
|
+
content = claudeMessage.message.content
|
|
299
|
+
.map(item => {
|
|
300
|
+
if (typeof item === 'string')
|
|
301
|
+
return item;
|
|
302
|
+
if (item?.type === 'text' && item?.text)
|
|
303
|
+
return item.text;
|
|
304
|
+
return JSON.stringify(item);
|
|
305
|
+
})
|
|
306
|
+
.join(' ');
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Decode project path from directory name
|
|
310
|
+
const projectPath = this.decodeProjectPath(projectDir);
|
|
311
|
+
// Add enhanced time information
|
|
312
|
+
const timestamp = claudeMessage.timestamp;
|
|
313
|
+
const messageDate = new Date(timestamp);
|
|
314
|
+
return {
|
|
315
|
+
sessionId: claudeMessage.sessionId,
|
|
316
|
+
timestamp,
|
|
317
|
+
type: claudeMessage.type,
|
|
318
|
+
content,
|
|
319
|
+
projectPath,
|
|
320
|
+
uuid: claudeMessage.uuid,
|
|
321
|
+
formattedTime: messageDate.toLocaleString('en-US', {
|
|
322
|
+
timeZone: 'Asia/Tokyo',
|
|
323
|
+
year: 'numeric',
|
|
324
|
+
month: '2-digit',
|
|
325
|
+
day: '2-digit',
|
|
326
|
+
hour: '2-digit',
|
|
327
|
+
minute: '2-digit',
|
|
328
|
+
second: '2-digit',
|
|
329
|
+
hour12: false
|
|
330
|
+
}),
|
|
331
|
+
timeAgo: this.getTimeAgo(messageDate),
|
|
332
|
+
localDate: messageDate.toLocaleDateString('sv-SE', { timeZone: 'Asia/Tokyo' }),
|
|
333
|
+
metadata: {
|
|
334
|
+
usage: claudeMessage.message?.usage,
|
|
335
|
+
model: claudeMessage.message?.model,
|
|
336
|
+
requestId: claudeMessage.requestId
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
console.error('Error converting Claude message:', error);
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
getTimeAgo(date) {
|
|
346
|
+
const now = new Date();
|
|
347
|
+
const diffMs = now.getTime() - date.getTime();
|
|
348
|
+
const diffMins = Math.floor(diffMs / (1000 * 60));
|
|
349
|
+
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
|
|
350
|
+
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
|
351
|
+
if (diffMins < 1)
|
|
352
|
+
return 'just now';
|
|
353
|
+
if (diffMins < 60)
|
|
354
|
+
return `${diffMins}m ago`;
|
|
355
|
+
if (diffHours < 24)
|
|
356
|
+
return `${diffHours}h ago`;
|
|
357
|
+
if (diffDays < 7)
|
|
358
|
+
return `${diffDays}d ago`;
|
|
359
|
+
if (diffDays < 30)
|
|
360
|
+
return `${Math.floor(diffDays / 7)}w ago`;
|
|
361
|
+
if (diffDays < 365)
|
|
362
|
+
return `${Math.floor(diffDays / 30)}mo ago`;
|
|
363
|
+
return `${Math.floor(diffDays / 365)}y ago`;
|
|
364
|
+
}
|
|
365
|
+
decodeProjectPath(projectDir) {
|
|
366
|
+
return projectDir.replace(/-/g, '/').replace(/^\//, '');
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Determines whether to skip reading a file based on its modification time
|
|
370
|
+
*/
|
|
371
|
+
async shouldSkipFile(filePath, startDate, endDate) {
|
|
372
|
+
if (!startDate && !endDate) {
|
|
373
|
+
return false; // Don't skip if no date filters are specified
|
|
374
|
+
}
|
|
375
|
+
try {
|
|
376
|
+
const fileStats = await fs.stat(filePath);
|
|
377
|
+
const fileModTime = fileStats.mtime.toISOString();
|
|
378
|
+
const fileCreateTime = fileStats.birthtime.toISOString();
|
|
379
|
+
// Get the earliest and latest possible times for file content
|
|
380
|
+
const oldestPossibleTime = fileCreateTime < fileModTime ? fileCreateTime : fileModTime;
|
|
381
|
+
const newestPossibleTime = fileModTime;
|
|
382
|
+
// If endDate is specified: skip if file's oldest time is after endDate
|
|
383
|
+
if (endDate && oldestPossibleTime > endDate) {
|
|
384
|
+
return true; // Skip
|
|
385
|
+
}
|
|
386
|
+
// If startDate is specified: skip if file's newest time is before startDate
|
|
387
|
+
if (startDate && newestPossibleTime < startDate) {
|
|
388
|
+
return true; // Skip
|
|
389
|
+
}
|
|
390
|
+
return false; // File might contain data in range, so read it
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
console.warn(`Failed to get file stats for ${filePath}:`, error);
|
|
394
|
+
return false; // Safe fallback: read the file if stat fails
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=history-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-service.js","sourceRoot":"","sources":["../src/history-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAgG3C,MAAM,OAAO,wBAAwB;IAC3B,SAAS,CAAS;IAE1B,YAAY,SAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,UAAkB,EAAE,YAAqB,KAAK,EAAE,QAAiB;QACrF,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,EAAE,GAAG,QAAQ,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;QAExE,IAAI,CAAC;YACH,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;gBACjB,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,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AK,CAAC,CAAC,6CAA6C;QAC7D,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ClaudeCodeHistoryService } from './history-service.js';
|
|
2
|
+
export type { ClaudeCodeMessage, ConversationEntry, PaginatedConversationResponse, HistoryQueryOptions, SessionListOptions, ProjectInfo, SessionInfo, SearchOptions, } from './history-service.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,6BAA6B,EAC7B,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ebowwa/claudecodehistory",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "TypeScript library for accessing and analyzing Claude Code conversation history",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^24.0.4",
|
|
26
|
+
"typescript": "^5.8.3"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"claude-code",
|
|
30
|
+
"history",
|
|
31
|
+
"conversation",
|
|
32
|
+
"ai",
|
|
33
|
+
"typescript",
|
|
34
|
+
"library",
|
|
35
|
+
"analytics"
|
|
36
|
+
],
|
|
37
|
+
"author": "ebowwa",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/ebowwa/claude-code-history-mcp.git"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/ebowwa/claude-code-history-mcp#readme",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/ebowwa/claude-code-history-mcp/issues"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"bun": ">=1.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|