sessionlog 0.0.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.
Files changed (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +388 -0
  3. package/dist/agent/agents/claude-code.d.ts +76 -0
  4. package/dist/agent/agents/claude-code.d.ts.map +1 -0
  5. package/dist/agent/agents/claude-code.js +769 -0
  6. package/dist/agent/agents/claude-code.js.map +1 -0
  7. package/dist/agent/agents/cursor.d.ts +35 -0
  8. package/dist/agent/agents/cursor.d.ts.map +1 -0
  9. package/dist/agent/agents/cursor.js +294 -0
  10. package/dist/agent/agents/cursor.js.map +1 -0
  11. package/dist/agent/agents/gemini-cli.d.ts +62 -0
  12. package/dist/agent/agents/gemini-cli.d.ts.map +1 -0
  13. package/dist/agent/agents/gemini-cli.js +474 -0
  14. package/dist/agent/agents/gemini-cli.js.map +1 -0
  15. package/dist/agent/agents/opencode.d.ts +100 -0
  16. package/dist/agent/agents/opencode.d.ts.map +1 -0
  17. package/dist/agent/agents/opencode.js +423 -0
  18. package/dist/agent/agents/opencode.js.map +1 -0
  19. package/dist/agent/registry.d.ts +54 -0
  20. package/dist/agent/registry.d.ts.map +1 -0
  21. package/dist/agent/registry.js +123 -0
  22. package/dist/agent/registry.js.map +1 -0
  23. package/dist/agent/session-types.d.ts +45 -0
  24. package/dist/agent/session-types.d.ts.map +1 -0
  25. package/dist/agent/session-types.js +48 -0
  26. package/dist/agent/session-types.js.map +1 -0
  27. package/dist/agent/types.d.ts +126 -0
  28. package/dist/agent/types.d.ts.map +1 -0
  29. package/dist/agent/types.js +40 -0
  30. package/dist/agent/types.js.map +1 -0
  31. package/dist/cli.d.ts +12 -0
  32. package/dist/cli.d.ts.map +1 -0
  33. package/dist/cli.js +425 -0
  34. package/dist/cli.js.map +1 -0
  35. package/dist/commands/clean.d.ts +30 -0
  36. package/dist/commands/clean.d.ts.map +1 -0
  37. package/dist/commands/clean.js +98 -0
  38. package/dist/commands/clean.js.map +1 -0
  39. package/dist/commands/disable.d.ts +23 -0
  40. package/dist/commands/disable.d.ts.map +1 -0
  41. package/dist/commands/disable.js +57 -0
  42. package/dist/commands/disable.js.map +1 -0
  43. package/dist/commands/doctor.d.ts +43 -0
  44. package/dist/commands/doctor.d.ts.map +1 -0
  45. package/dist/commands/doctor.js +97 -0
  46. package/dist/commands/doctor.js.map +1 -0
  47. package/dist/commands/enable.d.ts +37 -0
  48. package/dist/commands/enable.d.ts.map +1 -0
  49. package/dist/commands/enable.js +133 -0
  50. package/dist/commands/enable.js.map +1 -0
  51. package/dist/commands/explain.d.ts +68 -0
  52. package/dist/commands/explain.d.ts.map +1 -0
  53. package/dist/commands/explain.js +182 -0
  54. package/dist/commands/explain.js.map +1 -0
  55. package/dist/commands/reset.d.ts +23 -0
  56. package/dist/commands/reset.d.ts.map +1 -0
  57. package/dist/commands/reset.js +68 -0
  58. package/dist/commands/reset.js.map +1 -0
  59. package/dist/commands/resume.d.ts +42 -0
  60. package/dist/commands/resume.d.ts.map +1 -0
  61. package/dist/commands/resume.js +133 -0
  62. package/dist/commands/resume.js.map +1 -0
  63. package/dist/commands/rewind.d.ts +34 -0
  64. package/dist/commands/rewind.d.ts.map +1 -0
  65. package/dist/commands/rewind.js +155 -0
  66. package/dist/commands/rewind.js.map +1 -0
  67. package/dist/commands/status.d.ts +51 -0
  68. package/dist/commands/status.d.ts.map +1 -0
  69. package/dist/commands/status.js +112 -0
  70. package/dist/commands/status.js.map +1 -0
  71. package/dist/config.d.ts +40 -0
  72. package/dist/config.d.ts.map +1 -0
  73. package/dist/config.js +127 -0
  74. package/dist/config.js.map +1 -0
  75. package/dist/git-operations.d.ts +191 -0
  76. package/dist/git-operations.d.ts.map +1 -0
  77. package/dist/git-operations.js +462 -0
  78. package/dist/git-operations.js.map +1 -0
  79. package/dist/hooks/git-hooks.d.ts +22 -0
  80. package/dist/hooks/git-hooks.d.ts.map +1 -0
  81. package/dist/hooks/git-hooks.js +139 -0
  82. package/dist/hooks/git-hooks.js.map +1 -0
  83. package/dist/hooks/lifecycle.d.ts +21 -0
  84. package/dist/hooks/lifecycle.d.ts.map +1 -0
  85. package/dist/hooks/lifecycle.js +179 -0
  86. package/dist/hooks/lifecycle.js.map +1 -0
  87. package/dist/index.d.ts +76 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +166 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/security/redaction.d.ts +35 -0
  92. package/dist/security/redaction.d.ts.map +1 -0
  93. package/dist/security/redaction.js +239 -0
  94. package/dist/security/redaction.js.map +1 -0
  95. package/dist/session/state-machine.d.ts +90 -0
  96. package/dist/session/state-machine.d.ts.map +1 -0
  97. package/dist/session/state-machine.js +345 -0
  98. package/dist/session/state-machine.js.map +1 -0
  99. package/dist/store/checkpoint-store.d.ts +59 -0
  100. package/dist/store/checkpoint-store.d.ts.map +1 -0
  101. package/dist/store/checkpoint-store.js +321 -0
  102. package/dist/store/checkpoint-store.js.map +1 -0
  103. package/dist/store/native-store.d.ts +14 -0
  104. package/dist/store/native-store.d.ts.map +1 -0
  105. package/dist/store/native-store.js +159 -0
  106. package/dist/store/native-store.js.map +1 -0
  107. package/dist/store/provider-types.d.ts +78 -0
  108. package/dist/store/provider-types.d.ts.map +1 -0
  109. package/dist/store/provider-types.js +12 -0
  110. package/dist/store/provider-types.js.map +1 -0
  111. package/dist/store/session-store.d.ts +36 -0
  112. package/dist/store/session-store.d.ts.map +1 -0
  113. package/dist/store/session-store.js +193 -0
  114. package/dist/store/session-store.js.map +1 -0
  115. package/dist/strategy/attribution.d.ts +39 -0
  116. package/dist/strategy/attribution.d.ts.map +1 -0
  117. package/dist/strategy/attribution.js +225 -0
  118. package/dist/strategy/attribution.js.map +1 -0
  119. package/dist/strategy/common.d.ts +57 -0
  120. package/dist/strategy/common.d.ts.map +1 -0
  121. package/dist/strategy/common.js +156 -0
  122. package/dist/strategy/common.js.map +1 -0
  123. package/dist/strategy/content-overlap.d.ts +33 -0
  124. package/dist/strategy/content-overlap.d.ts.map +1 -0
  125. package/dist/strategy/content-overlap.js +176 -0
  126. package/dist/strategy/content-overlap.js.map +1 -0
  127. package/dist/strategy/manual-commit.d.ts +36 -0
  128. package/dist/strategy/manual-commit.d.ts.map +1 -0
  129. package/dist/strategy/manual-commit.js +717 -0
  130. package/dist/strategy/manual-commit.js.map +1 -0
  131. package/dist/strategy/types.d.ts +163 -0
  132. package/dist/strategy/types.d.ts.map +1 -0
  133. package/dist/strategy/types.js +48 -0
  134. package/dist/strategy/types.js.map +1 -0
  135. package/dist/summarize/claude-generator.d.ts +25 -0
  136. package/dist/summarize/claude-generator.d.ts.map +1 -0
  137. package/dist/summarize/claude-generator.js +87 -0
  138. package/dist/summarize/claude-generator.js.map +1 -0
  139. package/dist/summarize/summarize.d.ts +52 -0
  140. package/dist/summarize/summarize.d.ts.map +1 -0
  141. package/dist/summarize/summarize.js +335 -0
  142. package/dist/summarize/summarize.js.map +1 -0
  143. package/dist/types.d.ts +293 -0
  144. package/dist/types.d.ts.map +1 -0
  145. package/dist/types.js +94 -0
  146. package/dist/types.js.map +1 -0
  147. package/dist/utils/chunk-files.d.ts +25 -0
  148. package/dist/utils/chunk-files.d.ts.map +1 -0
  149. package/dist/utils/chunk-files.js +47 -0
  150. package/dist/utils/chunk-files.js.map +1 -0
  151. package/dist/utils/commit-message.d.ts +11 -0
  152. package/dist/utils/commit-message.d.ts.map +1 -0
  153. package/dist/utils/commit-message.js +54 -0
  154. package/dist/utils/commit-message.js.map +1 -0
  155. package/dist/utils/detect-agent.d.ts +19 -0
  156. package/dist/utils/detect-agent.d.ts.map +1 -0
  157. package/dist/utils/detect-agent.js +34 -0
  158. package/dist/utils/detect-agent.js.map +1 -0
  159. package/dist/utils/hook-managers.d.ts +24 -0
  160. package/dist/utils/hook-managers.d.ts.map +1 -0
  161. package/dist/utils/hook-managers.js +96 -0
  162. package/dist/utils/hook-managers.js.map +1 -0
  163. package/dist/utils/ide-tags.d.ts +12 -0
  164. package/dist/utils/ide-tags.d.ts.map +1 -0
  165. package/dist/utils/ide-tags.js +30 -0
  166. package/dist/utils/ide-tags.js.map +1 -0
  167. package/dist/utils/paths.d.ts +32 -0
  168. package/dist/utils/paths.d.ts.map +1 -0
  169. package/dist/utils/paths.js +55 -0
  170. package/dist/utils/paths.js.map +1 -0
  171. package/dist/utils/preview-rewind.d.ts +23 -0
  172. package/dist/utils/preview-rewind.d.ts.map +1 -0
  173. package/dist/utils/preview-rewind.js +63 -0
  174. package/dist/utils/preview-rewind.js.map +1 -0
  175. package/dist/utils/rewind-conflict.d.ts +52 -0
  176. package/dist/utils/rewind-conflict.d.ts.map +1 -0
  177. package/dist/utils/rewind-conflict.js +79 -0
  178. package/dist/utils/rewind-conflict.js.map +1 -0
  179. package/dist/utils/shadow-branch.d.ts +44 -0
  180. package/dist/utils/shadow-branch.d.ts.map +1 -0
  181. package/dist/utils/shadow-branch.js +93 -0
  182. package/dist/utils/shadow-branch.js.map +1 -0
  183. package/dist/utils/string-utils.d.ts +24 -0
  184. package/dist/utils/string-utils.d.ts.map +1 -0
  185. package/dist/utils/string-utils.js +47 -0
  186. package/dist/utils/string-utils.js.map +1 -0
  187. package/dist/utils/todo-extract.d.ts +52 -0
  188. package/dist/utils/todo-extract.d.ts.map +1 -0
  189. package/dist/utils/todo-extract.js +167 -0
  190. package/dist/utils/todo-extract.js.map +1 -0
  191. package/dist/utils/trailers.d.ts +36 -0
  192. package/dist/utils/trailers.d.ts.map +1 -0
  193. package/dist/utils/trailers.js +148 -0
  194. package/dist/utils/trailers.js.map +1 -0
  195. package/dist/utils/transcript-parse.d.ts +57 -0
  196. package/dist/utils/transcript-parse.d.ts.map +1 -0
  197. package/dist/utils/transcript-parse.js +126 -0
  198. package/dist/utils/transcript-parse.js.map +1 -0
  199. package/dist/utils/transcript-timestamp.d.ts +22 -0
  200. package/dist/utils/transcript-timestamp.d.ts.map +1 -0
  201. package/dist/utils/transcript-timestamp.js +56 -0
  202. package/dist/utils/transcript-timestamp.js.map +1 -0
  203. package/dist/utils/tree-ops.d.ts +47 -0
  204. package/dist/utils/tree-ops.d.ts.map +1 -0
  205. package/dist/utils/tree-ops.js +145 -0
  206. package/dist/utils/tree-ops.js.map +1 -0
  207. package/dist/utils/tty.d.ts +25 -0
  208. package/dist/utils/tty.d.ts.map +1 -0
  209. package/dist/utils/tty.js +70 -0
  210. package/dist/utils/tty.js.map +1 -0
  211. package/dist/utils/validation.d.ts +31 -0
  212. package/dist/utils/validation.d.ts.map +1 -0
  213. package/dist/utils/validation.js +59 -0
  214. package/dist/utils/validation.js.map +1 -0
  215. package/dist/utils/worktree.d.ts +16 -0
  216. package/dist/utils/worktree.d.ts.map +1 -0
  217. package/dist/utils/worktree.js +50 -0
  218. package/dist/utils/worktree.js.map +1 -0
  219. package/package.json +64 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alex Ngai
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 ADDED
@@ -0,0 +1,388 @@
1
+ # entire-cli
2
+
3
+ TypeScript implementation of the [Entire CLI](https://github.com/entireio/cli) — a Git-integrated tool that captures AI agent sessions as searchable records within your repository.
4
+
5
+ This package provides the core library used to build session tracking, checkpoint management, and agent integrations for AI coding tools.
6
+
7
+ ## Features
8
+
9
+ - **Multi-agent support** — Claude Code, Cursor, Gemini CLI, and OpenCode
10
+ - **Session lifecycle tracking** — automatic capture of prompts, responses, files modified, and token usage
11
+ - **Git-native checkpoints** — temporary snapshots on shadow branches, permanent records on `entire/checkpoints/v1`
12
+ - **Rewind** — restore code to any previous checkpoint
13
+ - **Resume** — pick up agent sessions from any branch
14
+ - **Secret redaction** — multi-layer detection (entropy analysis + 30+ patterns) before storing transcripts
15
+ - **AI summarization** — generate structured summaries of agent sessions
16
+ - **Zero production dependencies** — only Node.js and Git required
17
+
18
+ ## Installation
19
+
20
+ **Global CLI (recommended for standalone use):**
21
+
22
+ ```bash
23
+ npm install -g entire-cli
24
+ ```
25
+
26
+ Then use the `entire` command directly:
27
+
28
+ ```bash
29
+ cd your-project
30
+ entire enable
31
+ entire status
32
+ ```
33
+
34
+ **As a project dependency:**
35
+
36
+ ```bash
37
+ npm install entire-cli
38
+ ```
39
+
40
+ **As a dev dependency (for tools/plugins that integrate with Entire):**
41
+
42
+ ```bash
43
+ npm install --save-dev entire-cli
44
+ ```
45
+
46
+ Requires Node.js >= 18 and Git.
47
+
48
+ ## Quick Start
49
+
50
+ ```typescript
51
+ import {
52
+ enable,
53
+ disable,
54
+ status,
55
+ listRewindPoints,
56
+ rewindTo,
57
+ } from 'entire-cli';
58
+
59
+ // Enable Entire in a repository
60
+ const result = await enable({ cwd: '/path/to/repo' });
61
+ console.log(result.enabled); // true
62
+
63
+ // Check status
64
+ const info = await status('/path/to/repo');
65
+ console.log(info.sessions); // active sessions
66
+ console.log(info.agents); // installed agents
67
+
68
+ // List rewind points
69
+ const points = await listRewindPoints({ cwd: '/path/to/repo' });
70
+
71
+ // Rewind to a checkpoint
72
+ await rewindTo(points[0].id, { cwd: '/path/to/repo' });
73
+
74
+ // Disable
75
+ await disable({ cwd: '/path/to/repo' });
76
+ ```
77
+
78
+ ## Architecture
79
+
80
+ ```
81
+ Your Branch entire/checkpoints/v1
82
+ │ │
83
+ ▼ │
84
+ [Base Commit] │
85
+ │ │
86
+ │ ┌─── Agent works ───┐ │
87
+ │ │ Step 1 │ │
88
+ │ │ Step 2 │ │
89
+ │ │ Step 3 │ │
90
+ │ └───────────────────┘ │
91
+ │ │
92
+ ▼ ▼
93
+ [Your Commit] ─────────────────► [Session Metadata]
94
+ │ (transcript, prompts,
95
+ │ files touched)
96
+
97
+ ```
98
+
99
+ Your active branch stays clean — all metadata is stored on the separate `entire/checkpoints/v1` branch.
100
+
101
+ ## Key Concepts
102
+
103
+ **Sessions** represent complete AI agent interactions, capturing all prompts, responses, modified files, and timestamps. Session identifiers follow the format: `YYYY-MM-DD-<UUID>`.
104
+
105
+ **Checkpoints** are save points within sessions — snapshots you can rewind to when commits occur. Checkpoint identifiers are 12-character hexadecimal strings.
106
+
107
+ ## Commands
108
+
109
+ All commands are exposed as async functions that return structured results:
110
+
111
+ | Function | Purpose |
112
+ |----------|---------|
113
+ | `enable(options)` | Activate Entire in a repository |
114
+ | `disable(options)` | Deactivate Entire hooks |
115
+ | `status(cwd)` | Get current session information |
116
+ | `listRewindPoints(options)` | List available checkpoints |
117
+ | `rewindTo(pointID, options)` | Restore to a previous checkpoint |
118
+ | `doctor(options)` | Diagnose and fix stuck sessions |
119
+ | `clean(options)` | Remove orphaned data artifacts |
120
+ | `reset(options)` | Clear shadow branch and session state |
121
+ | `explainCommit(ref, options)` | Get session details for a commit |
122
+ | `discoverResumeInfo(branch)` | Find resumable sessions on a branch |
123
+
124
+ ### Enable
125
+
126
+ ```typescript
127
+ import { enable } from 'entire-cli';
128
+
129
+ const result = await enable({
130
+ cwd: '/path/to/repo',
131
+ agent: 'claude-code', // or auto-detect
132
+ force: true, // reinstall hooks
133
+ local: false, // save to project settings
134
+ });
135
+ // result: { enabled, agent, agentHooksInstalled, gitHooksInstalled, errors }
136
+ ```
137
+
138
+ ### Status
139
+
140
+ ```typescript
141
+ import { status, formatTokens } from 'entire-cli';
142
+
143
+ const info = await status('/path/to/repo');
144
+ console.log(`Strategy: ${info.strategy}`);
145
+ console.log(`Sessions: ${info.sessions.length}`);
146
+ for (const s of info.sessions) {
147
+ console.log(` ${s.sessionID} (${s.agentType}) - ${s.phase}`);
148
+ if (s.tokenUsage) {
149
+ console.log(` Tokens: ${formatTokens(s.tokenUsage.input)} in / ${formatTokens(s.tokenUsage.output)} out`);
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### Rewind
155
+
156
+ ```typescript
157
+ import { listRewindPoints, rewindTo } from 'entire-cli';
158
+
159
+ const points = await listRewindPoints({ cwd: '.', limit: 10 });
160
+ for (const p of points) {
161
+ console.log(`${p.id} - ${p.message} (${p.date})`);
162
+ }
163
+
164
+ const result = await rewindTo(points[0].id);
165
+ // result: { success, message, rewindPoint }
166
+ ```
167
+
168
+ ### Explain
169
+
170
+ ```typescript
171
+ import { explainCommit, getCheckpointDetail } from 'entire-cli';
172
+
173
+ // Explain a specific commit
174
+ const info = await explainCommit('HEAD');
175
+ if (info?.detail) {
176
+ console.log(`Checkpoint: ${info.detail.checkpointID}`);
177
+ console.log(`Agent: ${info.detail.agent}`);
178
+ console.log(`Files: ${info.detail.filesTouched.join(', ')}`);
179
+ }
180
+
181
+ // Get checkpoint details by ID
182
+ const detail = await getCheckpointDetail('a3b2c4d5e6f7');
183
+ ```
184
+
185
+ ### Resume
186
+
187
+ ```typescript
188
+ import { discoverResumeInfo, listResumableBranches } from 'entire-cli';
189
+
190
+ // List branches with resumable sessions
191
+ const branches = await listResumableBranches();
192
+ for (const b of branches) {
193
+ console.log(`${b.branch}: session ${b.sessionID}`);
194
+ }
195
+
196
+ // Get resume info for a specific branch
197
+ const info = await discoverResumeInfo('feature/my-branch');
198
+ if (info.success && info.info) {
199
+ console.log(`Resume command: ${info.info.resumeCommand}`);
200
+ }
201
+ ```
202
+
203
+ ## Agent System
204
+
205
+ Register and use AI agent integrations:
206
+
207
+ ```typescript
208
+ import {
209
+ registerAgent,
210
+ getAgent,
211
+ detectAgents,
212
+ createClaudeCodeAgent,
213
+ } from 'entire-cli';
214
+
215
+ // Agents auto-register on import. Detect installed agents:
216
+ const agents = await detectAgents('/path/to/repo');
217
+
218
+ // Or get a specific agent:
219
+ const claude = getAgent('claude-code');
220
+ if (claude) {
221
+ const present = await claude.detectPresence('/path/to/repo');
222
+ const transcript = await claude.readTranscript(sessionRef);
223
+ }
224
+ ```
225
+
226
+ ### Supported Agents
227
+
228
+ | Agent | Name | Hook Location |
229
+ |-------|------|---------------|
230
+ | Claude Code | `claude-code` | `.claude/settings.json` |
231
+ | Cursor | `cursor` | `.cursor/hooks.json` |
232
+ | Gemini CLI | `gemini` | `.gemini/settings.json` |
233
+ | OpenCode | `opencode` | `.opencode/plugins/entire.ts` |
234
+
235
+ ## Strategy Engine
236
+
237
+ The manual-commit strategy orchestrates the full checkpoint lifecycle:
238
+
239
+ ```typescript
240
+ import {
241
+ createManualCommitStrategy,
242
+ createSessionStore,
243
+ createCheckpointStore,
244
+ } from 'entire-cli';
245
+
246
+ const strategy = createManualCommitStrategy({
247
+ sessionStore: createSessionStore('/path/to/repo'),
248
+ checkpointStore: createCheckpointStore('/path/to/repo'),
249
+ cwd: '/path/to/repo',
250
+ });
251
+
252
+ // Git hook integration
253
+ await strategy.prepareCommitMsg(msgFile, source, sha);
254
+ await strategy.commitMsg(msgFile);
255
+ await strategy.postCommit();
256
+ await strategy.prePush('origin');
257
+
258
+ // Session management
259
+ await strategy.saveStep(stepContext);
260
+ await strategy.saveTaskStep(taskStepContext);
261
+ ```
262
+
263
+ ## Lifecycle Handler
264
+
265
+ Process agent events through the session state machine:
266
+
267
+ ```typescript
268
+ import {
269
+ createLifecycleHandler,
270
+ createSessionStore,
271
+ createCheckpointStore,
272
+ } from 'entire-cli';
273
+
274
+ const handler = createLifecycleHandler({
275
+ sessionStore: createSessionStore(),
276
+ checkpointStore: createCheckpointStore(),
277
+ });
278
+
279
+ // Dispatch events from agent hooks
280
+ await handler.dispatch(agent, event);
281
+ ```
282
+
283
+ ## Security
284
+
285
+ Redact secrets before storing transcripts:
286
+
287
+ ```typescript
288
+ import { redactJSONL, detectSecrets, shannonEntropy } from 'entire-cli';
289
+
290
+ // Redact a JSONL transcript buffer
291
+ const safe = redactJSONL(transcriptBuffer);
292
+
293
+ // Detect secrets in text
294
+ const secrets = detectSecrets(content);
295
+
296
+ // Check entropy of a string
297
+ const entropy = shannonEntropy('AKIAIOSFODNN7EXAMPLE');
298
+ ```
299
+
300
+ ## Configuration
301
+
302
+ Settings stored in `.entire/`:
303
+
304
+ | File | Purpose |
305
+ |------|---------|
306
+ | `.entire/settings.json` | Team-shared, version-controlled |
307
+ | `.entire/settings.local.json` | Personal overrides, gitignored |
308
+
309
+ ```typescript
310
+ import { loadSettings, saveProjectSettings, isEnabled } from 'entire-cli';
311
+
312
+ const settings = await loadSettings('/path/to/repo');
313
+ // { enabled, strategy, logLevel, skipPushSessions, telemetryEnabled, summarizationEnabled }
314
+
315
+ await saveProjectSettings({ enabled: true, strategy: 'manual-commit' });
316
+
317
+ const enabled = await isEnabled('/path/to/repo');
318
+ ```
319
+
320
+ ### Configuration Options
321
+
322
+ | Option | Type | Default | Purpose |
323
+ |--------|------|---------|---------|
324
+ | `enabled` | boolean | `false` | Toggle Entire functionality |
325
+ | `strategy` | string | `'manual-commit'` | Checkpoint strategy |
326
+ | `logLevel` | string | `'warn'` | Log verbosity (debug/info/warn/error) |
327
+ | `skipPushSessions` | boolean | `false` | Disable auto-push of checkpoints branch |
328
+ | `telemetryEnabled` | boolean | `false` | Anonymous usage analytics |
329
+ | `summarizationEnabled` | boolean | `false` | AI-generated summaries on commit |
330
+
331
+ ## Summarization
332
+
333
+ Generate AI-powered session summaries:
334
+
335
+ ```typescript
336
+ import {
337
+ buildCondensedTranscript,
338
+ buildSummarizationPrompt,
339
+ createClaudeGenerator,
340
+ } from 'entire-cli';
341
+
342
+ // Build a condensed transcript from raw agent output
343
+ const condensed = buildCondensedTranscript(entries);
344
+
345
+ // Generate a summary using Claude
346
+ const generator = createClaudeGenerator({ model: 'claude-sonnet-4-6' });
347
+ const summary = await generator.generate({ condensed, prompt: 'Summarize this session' });
348
+ // { intent, outcome, learnings, friction, openItems }
349
+ ```
350
+
351
+ ## Git Worktrees
352
+
353
+ Entire integrates with git worktrees, providing independent session tracking per worktree without conflicts.
354
+
355
+ ## Development
356
+
357
+ ```bash
358
+ # Install dependencies
359
+ npm install
360
+
361
+ # Build
362
+ npm run build
363
+
364
+ # Run tests
365
+ npm test
366
+
367
+ # Watch mode
368
+ npm run test:watch
369
+
370
+ # Lint
371
+ npm run lint
372
+
373
+ # Format
374
+ npm run format
375
+ ```
376
+
377
+ ## Troubleshooting
378
+
379
+ | Problem | Fix |
380
+ |---------|-----|
381
+ | "Not a git repository" | Navigate to a Git repository first |
382
+ | "Entire is disabled" | Run `enable()` |
383
+ | "No rewind points found" | Work with your agent and commit changes |
384
+ | "shadow branch conflict" | Run `reset({ force: true })` |
385
+
386
+ ## License
387
+
388
+ MIT
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Claude Code Agent
3
+ *
4
+ * Implementation of the Entire agent interface for Anthropic's Claude Code.
5
+ * Handles JSONL transcript format, Claude-specific hook installation,
6
+ * and session lifecycle management.
7
+ */
8
+ import { type HookInput, type Event, type TokenUsage } from '../../types.js';
9
+ import type { Agent, HookSupport, TranscriptAnalyzer, TokenCalculator, TranscriptChunker, TranscriptPreparer, SubagentAwareExtractor } from '../types.js';
10
+ export interface TranscriptLine {
11
+ type: 'user' | 'assistant';
12
+ uuid?: string;
13
+ message: unknown;
14
+ }
15
+ export interface AssistantContent {
16
+ type: string;
17
+ text?: string;
18
+ name?: string;
19
+ input?: Record<string, unknown>;
20
+ id?: string;
21
+ }
22
+ declare class ClaudeCodeAgent implements Agent, HookSupport, TranscriptAnalyzer, TokenCalculator, TranscriptChunker, TranscriptPreparer, SubagentAwareExtractor {
23
+ readonly name: string;
24
+ readonly type: string;
25
+ readonly description = "Anthropic Claude Code CLI";
26
+ readonly isPreview = false;
27
+ readonly protectedDirs: string[];
28
+ detectPresence(cwd?: string): Promise<boolean>;
29
+ getSessionDir(repoPath: string): Promise<string>;
30
+ getSessionID(input: HookInput): string;
31
+ resolveSessionFile(sessionDir: string, agentSessionID: string): string;
32
+ readTranscript(sessionRef: string): Promise<Buffer>;
33
+ formatResumeCommand(sessionID: string): string;
34
+ hookNames(): string[];
35
+ parseHookEvent(hookName: string, stdin: string): Event | null;
36
+ installHooks(repoPath: string, force?: boolean): Promise<number>;
37
+ uninstallHooks(repoPath: string): Promise<void>;
38
+ areHooksInstalled(repoPath: string): Promise<boolean>;
39
+ prepareTranscript(sessionRef: string): Promise<void>;
40
+ getTranscriptPosition(transcriptPath: string): Promise<number>;
41
+ extractModifiedFilesFromOffset(transcriptPath: string, startOffset: number): Promise<{
42
+ files: string[];
43
+ currentPosition: number;
44
+ }>;
45
+ extractPrompts(sessionRef: string, fromOffset: number): Promise<string[]>;
46
+ extractSummary(sessionRef: string): Promise<string>;
47
+ calculateTokenUsage(transcriptData: Buffer, fromOffset: number): Promise<TokenUsage>;
48
+ extractAllModifiedFiles(transcriptData: Buffer, fromOffset: number, subagentsDir: string): Promise<string[]>;
49
+ calculateTotalTokenUsage(transcriptData: Buffer, fromOffset: number, subagentsDir: string): Promise<TokenUsage>;
50
+ chunkTranscript(content: Buffer, maxSize: number): Promise<Buffer[]>;
51
+ reassembleTranscript(chunks: Buffer[]): Promise<Buffer>;
52
+ }
53
+ /**
54
+ * Parse a JSONL transcript into structured lines
55
+ */
56
+ export declare function parseTranscript(content: string): TranscriptLine[];
57
+ /**
58
+ * Extract all modified files from transcript lines
59
+ */
60
+ export declare function extractModifiedFiles(lines: TranscriptLine[]): string[];
61
+ /**
62
+ * Extract the last user prompt from transcript lines
63
+ */
64
+ export declare function extractLastUserPrompt(lines: TranscriptLine[]): string;
65
+ /**
66
+ * Extract spawned agent IDs from Task tool results in a transcript.
67
+ * When a Task tool completes, the tool_result contains "agentId: <id>".
68
+ * Returns a map of agentID → toolUseID.
69
+ */
70
+ export declare function extractSpawnedAgentIDs(lines: TranscriptLine[]): Map<string, string>;
71
+ /**
72
+ * Create and return a new Claude Code agent instance
73
+ */
74
+ export declare function createClaudeCodeAgent(): ClaudeCodeAgent;
75
+ export {};
76
+ //# sourceMappingURL=claude-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../../src/agent/agents/claude-code.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,UAAU,EAGhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAoCrB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AA0CD,cAAM,eACJ,YACE,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB;IAExB,QAAQ,CAAC,IAAI,SAA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