claude-code-types 0.1.0 → 0.3.0
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/LICENSE +21 -21
- package/README.md +62 -79
- package/index.d.ts +735 -535
- package/package.json +32 -30
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Pedro
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pedro Paulo Vezza Campos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,79 +1,62 @@
|
|
|
1
|
-
# claude-code-types
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
case '
|
|
30
|
-
console.log(entry.message.
|
|
31
|
-
break;
|
|
32
|
-
case '
|
|
33
|
-
console.log(entry.
|
|
34
|
-
break;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
| `
|
|
45
|
-
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
The `publish.yml` workflow triggers on `v*` tags, runs typecheck, and publishes with provenance.
|
|
65
|
-
|
|
66
|
-
### npm authentication
|
|
67
|
-
|
|
68
|
-
The GitHub Actions workflow uses OIDC-based trusted publishing. To set this up:
|
|
69
|
-
|
|
70
|
-
1. Go to [npmjs.com](https://www.npmjs.com) > **Access Tokens** > **Granular Access Token**
|
|
71
|
-
2. Create a token with publish access to `claude-code-types`
|
|
72
|
-
3. In your GitHub repo, go to **Settings** > **Environments** > create an environment called `npm`
|
|
73
|
-
4. Add a secret `NPM_TOKEN` with the token value
|
|
74
|
-
|
|
75
|
-
Alternatively, configure [npm trusted publishing](https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions) for keyless OIDC auth.
|
|
76
|
-
|
|
77
|
-
## License
|
|
78
|
-
|
|
79
|
-
MIT
|
|
1
|
+
# claude-code-types
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/claude-code-types)
|
|
4
|
+
|
|
5
|
+
TypeScript type definitions for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) chat history JSONL files.
|
|
6
|
+
|
|
7
|
+
Claude Code stores conversation history at `~/.claude/projects/<project-slug>/<session-id>.jsonl`. Each line is a JSON object. This package provides full type coverage for all entry types.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install claude-code-types
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { TranscriptEntry } from 'claude-code-types';
|
|
19
|
+
import { readFileSync } from 'fs';
|
|
20
|
+
|
|
21
|
+
const path = '~/.claude/projects/my-project/abc123.jsonl';
|
|
22
|
+
const entries: TranscriptEntry[] = readFileSync(path, 'utf-8')
|
|
23
|
+
.split('\n')
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.map(line => JSON.parse(line) as TranscriptEntry);
|
|
26
|
+
|
|
27
|
+
for (const entry of entries) {
|
|
28
|
+
switch (entry.type) {
|
|
29
|
+
case 'user':
|
|
30
|
+
console.log(entry.message.content);
|
|
31
|
+
break;
|
|
32
|
+
case 'assistant':
|
|
33
|
+
console.log(entry.message.model);
|
|
34
|
+
break;
|
|
35
|
+
case 'system':
|
|
36
|
+
console.log(entry.subtype);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Entry types
|
|
43
|
+
|
|
44
|
+
| `type` | Interface | Description |
|
|
45
|
+
|--------|-----------|-------------|
|
|
46
|
+
| `user` | `UserEntry` | Human messages, tool results |
|
|
47
|
+
| `assistant` | `AssistantEntry` | Model responses, tool calls |
|
|
48
|
+
| `system` | `SystemEntry` | API errors, compaction, durations |
|
|
49
|
+
| `file-history-snapshot` | `FileHistorySnapshotEntry` | Undo/restore tracking |
|
|
50
|
+
| `pr-link` | `PrLinkEntry` | Linked pull requests |
|
|
51
|
+
| `progress` | `ProgressEntry` | Streaming subagent updates |
|
|
52
|
+
| `queue-operation` | `QueueOperationEntry` | Queued user messages |
|
|
53
|
+
| `saved_hook_context` | `SavedHookContextEntry` | Hook execution context |
|
|
54
|
+
| `summary` | `SummaryEntry` | Conversation summaries |
|
|
55
|
+
|
|
56
|
+
## Contributing
|
|
57
|
+
|
|
58
|
+
See [AGENTS.md](AGENTS.md) for publishing instructions and project conventions.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|