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.
Files changed (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +62 -79
  3. package/index.d.ts +735 -535
  4. package/package.json +32 -30
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Pedro Carvalho
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
- TypeScript type definitions for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) chat history JSONL files.
4
-
5
- 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.
6
-
7
- ## Install
8
-
9
- ```bash
10
- npm install claude-code-types
11
- ```
12
-
13
- ## Usage
14
-
15
- ```ts
16
- import type { TranscriptEntry } from 'claude-code-types';
17
- import { readFileSync } from 'fs';
18
-
19
- const entries: TranscriptEntry[] = readFileSync(path, 'utf-8')
20
- .split('\n')
21
- .filter(Boolean)
22
- .map(line => JSON.parse(line) as TranscriptEntry);
23
-
24
- for (const entry of entries) {
25
- switch (entry.type) {
26
- case 'user':
27
- console.log(entry.message.content);
28
- break;
29
- case 'assistant':
30
- console.log(entry.message.model);
31
- break;
32
- case 'system':
33
- console.log(entry.subtype);
34
- break;
35
- }
36
- }
37
- ```
38
-
39
- ## Entry types
40
-
41
- | `type` | Interface | Description |
42
- |--------|-----------|-------------|
43
- | `user` | `UserEntry` | Human messages, tool results |
44
- | `assistant` | `AssistantEntry` | Model responses, tool calls |
45
- | `system` | `SystemEntry` | API errors, compaction, durations |
46
- | `file-history-snapshot` | `FileHistorySnapshotEntry` | Undo/restore tracking |
47
- | `pr-link` | `PrLinkEntry` | Linked pull requests |
48
- | `progress` | `ProgressEntry` | Streaming subagent updates |
49
- | `queue-operation` | `QueueOperationEntry` | Queued user messages |
50
- | `saved_hook_context` | `SavedHookContextEntry` | Hook execution context |
51
- | `summary` | `SummaryEntry` | Conversation summaries |
52
-
53
- ## Publishing
54
-
55
- This package is published to npm automatically via GitHub Actions when a version tag is pushed.
56
-
57
- ### Releasing a new version
58
-
59
- ```bash
60
- npm version patch # or minor / major
61
- git push --follow-tags
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
+ [![npm](https://img.shields.io/npm/v/claude-code-types)](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