@tyroneross/bookmark 0.1.0 → 0.3.2
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/.claude-plugin/marketplace.json +29 -12
- package/.claude-plugin/plugin.json +12 -8
- package/.codex-plugin/plugin.json +31 -0
- package/.mcp.json +8 -0
- package/CLAUDE.md +83 -49
- package/LICENSE +202 -21
- package/README.md +150 -57
- package/agents/snapshot-analyst.md +1 -1
- package/commands/bookmark.md +29 -0
- package/commands/feedback.md +37 -0
- package/commands/restore.md +14 -4
- package/commands/snapshot.md +19 -7
- package/commands/status.md +1 -1
- package/dist/cli/index.js +627 -87
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/snapshot-resolution.d.ts +15 -0
- package/dist/cli/snapshot-resolution.d.ts.map +1 -0
- package/dist/cli/snapshot-resolution.js +21 -0
- package/dist/cli/snapshot-resolution.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +149 -23
- package/dist/config.js.map +1 -1
- package/dist/context/freshness.d.ts +3 -0
- package/dist/context/freshness.d.ts.map +1 -0
- package/dist/context/freshness.js +29 -0
- package/dist/context/freshness.js.map +1 -0
- package/dist/context/handoff-prompt.d.ts +12 -0
- package/dist/context/handoff-prompt.d.ts.map +1 -0
- package/dist/context/handoff-prompt.js +29 -0
- package/dist/context/handoff-prompt.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +9 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +85 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +97 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +304 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/registry.d.ts +40 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +134 -0
- package/dist/registry.js.map +1 -0
- package/dist/restore/index.d.ts +13 -1
- package/dist/restore/index.d.ts.map +1 -1
- package/dist/restore/index.js +163 -43
- package/dist/restore/index.js.map +1 -1
- package/dist/setup/auto-setup.d.ts +8 -2
- package/dist/setup/auto-setup.d.ts.map +1 -1
- package/dist/setup/auto-setup.js +287 -67
- package/dist/setup/auto-setup.js.map +1 -1
- package/dist/setup/configure-hooks.d.ts +14 -3
- package/dist/setup/configure-hooks.d.ts.map +1 -1
- package/dist/setup/configure-hooks.js +156 -24
- package/dist/setup/configure-hooks.js.map +1 -1
- package/dist/snapshot/capture.d.ts +13 -9
- package/dist/snapshot/capture.d.ts.map +1 -1
- package/dist/snapshot/capture.js +42 -105
- package/dist/snapshot/capture.js.map +1 -1
- package/dist/snapshot/compress.d.ts +3 -3
- package/dist/snapshot/compress.d.ts.map +1 -1
- package/dist/snapshot/compress.js +35 -67
- package/dist/snapshot/compress.js.map +1 -1
- package/dist/snapshot/storage.d.ts +7 -0
- package/dist/snapshot/storage.d.ts.map +1 -1
- package/dist/snapshot/storage.js +31 -6
- package/dist/snapshot/storage.js.map +1 -1
- package/dist/threshold/state.d.ts +5 -0
- package/dist/threshold/state.d.ts.map +1 -1
- package/dist/threshold/state.js +28 -2
- package/dist/threshold/state.js.map +1 -1
- package/dist/threshold/token-usage.d.ts +29 -0
- package/dist/threshold/token-usage.d.ts.map +1 -0
- package/dist/threshold/token-usage.js +128 -0
- package/dist/threshold/token-usage.js.map +1 -0
- package/dist/trails/identity.d.ts +76 -0
- package/dist/trails/identity.d.ts.map +1 -0
- package/dist/trails/identity.js +117 -0
- package/dist/trails/identity.js.map +1 -0
- package/dist/trails/reader.d.ts +7 -0
- package/dist/trails/reader.d.ts.map +1 -0
- package/dist/trails/reader.js +22 -0
- package/dist/trails/reader.js.map +1 -0
- package/dist/trails/writer.d.ts +9 -0
- package/dist/trails/writer.d.ts.map +1 -0
- package/dist/trails/writer.js +110 -0
- package/dist/trails/writer.js.map +1 -0
- package/dist/transcript/extractor.d.ts +17 -4
- package/dist/transcript/extractor.d.ts.map +1 -1
- package/dist/transcript/extractor.js +141 -174
- package/dist/transcript/extractor.js.map +1 -1
- package/dist/transcript/parser.d.ts.map +1 -1
- package/dist/transcript/parser.js +69 -7
- package/dist/transcript/parser.js.map +1 -1
- package/dist/types.d.ts +37 -38
- package/dist/types.d.ts.map +1 -1
- package/hooks/hooks.json +12 -14
- package/package.json +13 -10
- package/scripts/install-plugin.sh +48 -0
- package/skills/context-continuity/SKILL.md +43 -24
- package/commands/activate.md +0 -20
- package/dist/transcript/estimator.d.ts +0 -20
- package/dist/transcript/estimator.d.ts.map +0 -1
- package/dist/transcript/estimator.js +0 -95
- package/dist/transcript/estimator.js.map +0 -1
|
@@ -1,131 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { relative, isAbsolute } from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Convert an absolute file path to a project-relative one. Falls back to
|
|
4
|
+
* the original path when projectPath is missing or the file isn't under
|
|
5
|
+
* it (e.g. a tool call that touched something outside the repo, like a
|
|
6
|
+
* scratchpad in /tmp).
|
|
7
|
+
*
|
|
8
|
+
* Why: snapshots used to embed absolute paths
|
|
9
|
+
* (e.g. /Users/tyroneross/Desktop/git-folder/...). When the project moved
|
|
10
|
+
* to ~/dev/git-folder/... every old absolute path went stale, defeating
|
|
11
|
+
* the whole point of the snapshot. Going forward we store paths relative
|
|
12
|
+
* to project_path so a move only needs the project_path field updated
|
|
13
|
+
* (or — for git-tracked moves — nothing at all).
|
|
14
|
+
*/
|
|
15
|
+
function toProjectRelative(filePath, projectPath) {
|
|
16
|
+
if (!projectPath || !filePath)
|
|
17
|
+
return filePath;
|
|
18
|
+
if (!isAbsolute(filePath))
|
|
19
|
+
return filePath;
|
|
20
|
+
if (!filePath.startsWith(projectPath))
|
|
21
|
+
return filePath;
|
|
22
|
+
const rel = relative(projectPath, filePath);
|
|
23
|
+
// `relative` returns '' when paths match exactly; preserve a sentinel so
|
|
24
|
+
// downstream code knows it's the project root rather than the empty
|
|
25
|
+
// string (which can read as "missing data").
|
|
26
|
+
return rel === '' ? '.' : rel;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extractor v0.3 — file tracking + tool summary only.
|
|
30
|
+
*
|
|
31
|
+
* Removed: decision extraction, open items, unknowns, errors, sentiment, status.
|
|
32
|
+
* These produced noise (not signal) via regex. Claude writes semantic content
|
|
33
|
+
* when a lifecycle or token hook requests the handoff instead.
|
|
34
|
+
*
|
|
35
|
+
* Kept: file change tracking (accurate) and tool usage summary (accurate).
|
|
36
|
+
*/
|
|
20
37
|
const FILE_TOOL_NAMES = new Set(['Write', 'Edit', 'write', 'edit']);
|
|
21
38
|
const FILE_CREATING_BASH_PATTERNS = [
|
|
22
39
|
/\b(?:mkdir|touch|mv|cp|cat\s+>|echo\s+>|tee)\b/,
|
|
23
40
|
];
|
|
24
41
|
/**
|
|
25
|
-
* Extract
|
|
26
|
-
*
|
|
42
|
+
* Extract file changes and tool usage from transcript entries.
|
|
43
|
+
* These are the two extraction functions that actually produce accurate data.
|
|
27
44
|
*/
|
|
28
|
-
export function
|
|
29
|
-
const
|
|
30
|
-
const openItems = extractOpenItems(entries);
|
|
31
|
-
const unknowns = extractUnknowns(entries);
|
|
32
|
-
const filesChanged = extractFilesChanged(entries);
|
|
33
|
-
const errors = extractErrors(entries);
|
|
34
|
-
const toolsSummary = extractToolsSummary(entries);
|
|
35
|
-
const currentStatus = extractCurrentStatus(entries);
|
|
45
|
+
export function extractFilesAndTools(entries, options) {
|
|
46
|
+
const projectPath = options?.projectPath;
|
|
36
47
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
open_items: openItems,
|
|
40
|
-
unknowns,
|
|
41
|
-
files_changed: filesChanged,
|
|
42
|
-
errors_encountered: errors,
|
|
43
|
-
tools_summary: toolsSummary,
|
|
48
|
+
files_changed: extractFilesChanged(entries, projectPath),
|
|
49
|
+
tools_summary: extractToolsSummary(entries),
|
|
44
50
|
};
|
|
45
51
|
}
|
|
46
|
-
function
|
|
47
|
-
const decisions = [];
|
|
48
|
-
const seen = new Set();
|
|
49
|
-
for (const entry of entries) {
|
|
50
|
-
if (entry.type !== 'assistant')
|
|
51
|
-
continue;
|
|
52
|
-
const text = getEntryText(entry);
|
|
53
|
-
if (!text)
|
|
54
|
-
continue;
|
|
55
|
-
for (const pattern of DECISION_PATTERNS) {
|
|
56
|
-
if (pattern.test(text)) {
|
|
57
|
-
// Extract the sentence containing the decision
|
|
58
|
-
const sentences = text.split(/[.!?\n]/).filter(s => s.trim().length > 10);
|
|
59
|
-
for (const sentence of sentences) {
|
|
60
|
-
if (DECISION_PATTERNS.some(p => p.test(sentence))) {
|
|
61
|
-
const clean = sentence.trim().slice(0, 200);
|
|
62
|
-
const key = clean.toLowerCase().slice(0, 50);
|
|
63
|
-
if (!seen.has(key)) {
|
|
64
|
-
seen.add(key);
|
|
65
|
-
decisions.push({ description: clean });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return decisions.slice(0, 15); // maxDecisions
|
|
74
|
-
}
|
|
75
|
-
function extractOpenItems(entries) {
|
|
76
|
-
const items = [];
|
|
77
|
-
const seen = new Set();
|
|
78
|
-
// Process in reverse — more recent items are more relevant
|
|
79
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
80
|
-
const entry = entries[i];
|
|
81
|
-
if (entry.type !== 'assistant')
|
|
82
|
-
continue;
|
|
83
|
-
const text = getEntryText(entry);
|
|
84
|
-
if (!text)
|
|
85
|
-
continue;
|
|
86
|
-
const sentences = text.split(/[.!?\n]/).filter(s => s.trim().length > 10);
|
|
87
|
-
for (const sentence of sentences) {
|
|
88
|
-
if (OPEN_ITEM_PATTERNS.some(p => p.test(sentence))) {
|
|
89
|
-
const clean = sentence.trim().slice(0, 200);
|
|
90
|
-
const key = clean.toLowerCase().slice(0, 50);
|
|
91
|
-
if (!seen.has(key)) {
|
|
92
|
-
seen.add(key);
|
|
93
|
-
items.push({
|
|
94
|
-
description: clean,
|
|
95
|
-
priority: inferPriority(clean),
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return items.slice(0, 10); // maxOpenItems
|
|
102
|
-
}
|
|
103
|
-
function extractUnknowns(entries) {
|
|
104
|
-
const unknowns = [];
|
|
105
|
-
const seen = new Set();
|
|
106
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
107
|
-
const entry = entries[i];
|
|
108
|
-
if (entry.type !== 'assistant')
|
|
109
|
-
continue;
|
|
110
|
-
const text = getEntryText(entry);
|
|
111
|
-
if (!text)
|
|
112
|
-
continue;
|
|
113
|
-
const sentences = text.split(/[.!?\n]/).filter(s => s.trim().length > 10);
|
|
114
|
-
for (const sentence of sentences) {
|
|
115
|
-
if (UNKNOWN_PATTERNS.some(p => p.test(sentence))) {
|
|
116
|
-
const clean = sentence.trim().slice(0, 200);
|
|
117
|
-
const key = clean.toLowerCase().slice(0, 50);
|
|
118
|
-
if (!seen.has(key)) {
|
|
119
|
-
seen.add(key);
|
|
120
|
-
unknowns.push(clean);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return unknowns.slice(0, 10);
|
|
126
|
-
}
|
|
127
|
-
function extractFilesChanged(entries) {
|
|
52
|
+
function extractFilesChanged(entries, projectPath) {
|
|
128
53
|
const fileMap = new Map();
|
|
54
|
+
const fileLinesChanged = new Map();
|
|
55
|
+
const fileStructuralChanges = new Map();
|
|
129
56
|
for (const entry of entries) {
|
|
130
57
|
if (entry.type === 'tool_use') {
|
|
131
58
|
const toolName = entry.tool_name ?? '';
|
|
@@ -133,20 +60,33 @@ function extractFilesChanged(entries) {
|
|
|
133
60
|
if (FILE_TOOL_NAMES.has(toolName)) {
|
|
134
61
|
const filePath = input.file_path ?? input.path ?? '';
|
|
135
62
|
if (filePath) {
|
|
63
|
+
if (projectPath && !filePath.startsWith(projectPath))
|
|
64
|
+
continue;
|
|
136
65
|
const ops = fileMap.get(filePath) ?? new Set();
|
|
137
66
|
ops.add(toolName.toLowerCase());
|
|
138
67
|
fileMap.set(filePath, ops);
|
|
68
|
+
const newStr = input.new_string ?? input.content ?? '';
|
|
69
|
+
const oldStr = input.old_string ?? '';
|
|
70
|
+
const linesAdded = newStr ? newStr.split('\n').length : 0;
|
|
71
|
+
const linesRemoved = oldStr ? oldStr.split('\n').length : 0;
|
|
72
|
+
const delta = Math.abs(linesAdded - linesRemoved) + Math.min(linesAdded, linesRemoved);
|
|
73
|
+
fileLinesChanged.set(filePath, (fileLinesChanged.get(filePath) ?? 0) + delta);
|
|
74
|
+
const changes = fileStructuralChanges.get(filePath) ?? new Set();
|
|
75
|
+
extractStructuralHints(newStr, oldStr, changes);
|
|
76
|
+
if (changes.size > 0) {
|
|
77
|
+
fileStructuralChanges.set(filePath, changes);
|
|
78
|
+
}
|
|
139
79
|
}
|
|
140
80
|
}
|
|
141
|
-
// Detect file operations in Bash commands
|
|
142
81
|
if (toolName === 'Bash' || toolName === 'bash') {
|
|
143
82
|
const cmd = input.command ?? '';
|
|
144
83
|
for (const pattern of FILE_CREATING_BASH_PATTERNS) {
|
|
145
84
|
if (pattern.test(cmd)) {
|
|
146
|
-
// Try to extract file path from command
|
|
147
85
|
const parts = cmd.split(/\s+/);
|
|
148
86
|
const lastPart = parts[parts.length - 1];
|
|
149
87
|
if (lastPart && !lastPart.startsWith('-')) {
|
|
88
|
+
if (projectPath && !lastPart.startsWith(projectPath))
|
|
89
|
+
break;
|
|
150
90
|
const ops = fileMap.get(lastPart) ?? new Set();
|
|
151
91
|
ops.add('create');
|
|
152
92
|
fileMap.set(lastPart, ops);
|
|
@@ -159,43 +99,68 @@ function extractFilesChanged(entries) {
|
|
|
159
99
|
}
|
|
160
100
|
const result = [];
|
|
161
101
|
for (const [path, ops] of fileMap) {
|
|
162
|
-
|
|
102
|
+
const changes = fileStructuralChanges.get(path);
|
|
103
|
+
const summary = changes && changes.size > 0
|
|
104
|
+
? [...changes].slice(0, 4).join(', ')
|
|
105
|
+
: undefined;
|
|
106
|
+
result.push({
|
|
107
|
+
// Store relative to projectPath so snapshots survive a project move.
|
|
108
|
+
// The original absolute path is preserved in `absolute_path` for
|
|
109
|
+
// diagnostic use; consumers should prefer `path` joined to the
|
|
110
|
+
// current project_path.
|
|
111
|
+
path: toProjectRelative(path, projectPath),
|
|
112
|
+
operations: [...ops],
|
|
113
|
+
lines_changed: fileLinesChanged.get(path) ?? 0,
|
|
114
|
+
summary,
|
|
115
|
+
});
|
|
163
116
|
}
|
|
164
|
-
return result.slice(0, 20);
|
|
117
|
+
return result.slice(0, 20);
|
|
165
118
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
119
|
+
function extractStructuralHints(newStr, oldStr, changes) {
|
|
120
|
+
if (!newStr && !oldStr)
|
|
121
|
+
return;
|
|
122
|
+
const newLines = new Set(newStr.split('\n').map(l => l.trim()));
|
|
123
|
+
const oldLines = new Set(oldStr.split('\n').map(l => l.trim()));
|
|
124
|
+
const STRUCTURAL_PATTERNS = [
|
|
125
|
+
{ pattern: /^export\s+(?:async\s+)?function\s+(\w+)/, prefix: '+fn' },
|
|
126
|
+
{ pattern: /^(?:async\s+)?function\s+(\w+)/, prefix: '+fn' },
|
|
127
|
+
{ pattern: /^export\s+(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\(/, prefix: '+fn' },
|
|
128
|
+
{ pattern: /^(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\(/, prefix: '+fn' },
|
|
129
|
+
{ pattern: /^export\s+class\s+(\w+)/, prefix: '+class' },
|
|
130
|
+
{ pattern: /^class\s+(\w+)/, prefix: '+class' },
|
|
131
|
+
{ pattern: /^export\s+interface\s+(\w+)/, prefix: '+interface' },
|
|
132
|
+
{ pattern: /^interface\s+(\w+)/, prefix: '+interface' },
|
|
133
|
+
{ pattern: /^export\s+type\s+(\w+)/, prefix: '+type' },
|
|
134
|
+
{ pattern: /^type\s+(\w+)/, prefix: '+type' },
|
|
135
|
+
{ pattern: /^import\s+.*from\s+['"]([^'"]+)['"]/, prefix: '+import' },
|
|
136
|
+
];
|
|
137
|
+
for (const line of newLines) {
|
|
138
|
+
if (oldLines.has(line))
|
|
139
|
+
continue;
|
|
140
|
+
for (const { pattern, prefix } of STRUCTURAL_PATTERNS) {
|
|
141
|
+
const match = line.match(pattern);
|
|
142
|
+
if (match) {
|
|
143
|
+
changes.add(`${prefix} ${match[1]}`);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
176
146
|
}
|
|
177
147
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
message: firstLine,
|
|
192
|
-
tool: entry.tool_name,
|
|
193
|
-
resolved: false, // Will be updated below
|
|
194
|
-
});
|
|
148
|
+
if (oldStr) {
|
|
149
|
+
for (const line of oldLines) {
|
|
150
|
+
if (newLines.has(line))
|
|
151
|
+
continue;
|
|
152
|
+
for (const { pattern, prefix } of STRUCTURAL_PATTERNS) {
|
|
153
|
+
const match = line.match(pattern);
|
|
154
|
+
if (match) {
|
|
155
|
+
const removePrefix = prefix.replace('+', '-');
|
|
156
|
+
if (!changes.has(`${prefix} ${match[1]}`)) {
|
|
157
|
+
changes.add(`${removePrefix} ${match[1]}`);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
195
161
|
}
|
|
196
162
|
}
|
|
197
163
|
}
|
|
198
|
-
return errors.slice(0, 10); // maxErrorsTracked
|
|
199
164
|
}
|
|
200
165
|
function extractToolsSummary(entries) {
|
|
201
166
|
const summary = {};
|
|
@@ -206,32 +171,34 @@ function extractToolsSummary(entries) {
|
|
|
206
171
|
}
|
|
207
172
|
return summary;
|
|
208
173
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
174
|
+
export function extractCommitGap(entries) {
|
|
175
|
+
let lastCommitIdx = -1;
|
|
211
176
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
212
177
|
const entry = entries[i];
|
|
213
|
-
if (entry.type
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return sentences.join(' ').slice(0, 300);
|
|
178
|
+
if (entry.type === 'tool_use' && (entry.tool_name === 'Bash' || entry.tool_name === 'bash')) {
|
|
179
|
+
const cmd = entry.tool_input?.command ?? '';
|
|
180
|
+
if (/git\s+commit\b/.test(cmd)) {
|
|
181
|
+
lastCommitIdx = i;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
221
185
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
186
|
+
let editCount = 0;
|
|
187
|
+
const filesEdited = new Set();
|
|
188
|
+
const searchFrom = lastCommitIdx >= 0 ? lastCommitIdx + 1 : 0;
|
|
189
|
+
for (let i = searchFrom; i < entries.length; i++) {
|
|
190
|
+
const entry = entries[i];
|
|
191
|
+
if (entry.type === 'tool_use' && FILE_TOOL_NAMES.has(entry.tool_name ?? '')) {
|
|
192
|
+
editCount++;
|
|
193
|
+
const filePath = entry.tool_input?.file_path ?? '';
|
|
194
|
+
if (filePath)
|
|
195
|
+
filesEdited.add(filePath);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
edits_since_commit: editCount,
|
|
200
|
+
files_since_commit: filesEdited.size,
|
|
201
|
+
last_commit_index: lastCommitIdx,
|
|
202
|
+
};
|
|
236
203
|
}
|
|
237
204
|
//# sourceMappingURL=extractor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../src/transcript/extractor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../src/transcript/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGjD;;;;;;;;;;;;GAYG;AACH,SAAS,iBAAiB,CAAC,QAAgB,EAAE,WAAoB;IAC/D,IAAI,CAAC,WAAW,IAAI,CAAC,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC3C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvD,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC5C,yEAAyE;IACzE,oEAAoE;IACpE,6CAA6C;IAC7C,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAChC,CAAC;AAED;;;;;;;;GAQG;AAEH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,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C;QACjD,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;YAC5E,SAAS,EAAE,CAAC;YACZ,MAAM,QAAQ,GAAI,KAAK,CAAC,UAAU,EAAE,SAAoB,IAAI,EAAE,CAAC;YAC/D,IAAI,QAAQ;gBAAE,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO;QACL,kBAAkB,EAAE,SAAS;QAC7B,kBAAkB,EAAE,WAAW,CAAC,IAAI;QACpC,iBAAiB,EAAE,aAAa;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/transcript/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/transcript/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,CA8F3F"}
|
|
@@ -30,9 +30,53 @@ export function parseTranscript(transcriptPath, options) {
|
|
|
30
30
|
continue;
|
|
31
31
|
try {
|
|
32
32
|
const parsed = JSON.parse(trimmed);
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
entries.push(
|
|
33
|
+
const normalized = normalizeEntry(parsed);
|
|
34
|
+
if (normalized) {
|
|
35
|
+
entries.push(normalized);
|
|
36
|
+
}
|
|
37
|
+
// Also extract individual tool_use blocks from assistant messages
|
|
38
|
+
// Claude Code embeds tool calls inside message.content arrays
|
|
39
|
+
const message = parsed.message;
|
|
40
|
+
if (message?.content && Array.isArray(message.content)) {
|
|
41
|
+
// Build a tool_use_id → tool_name lookup for resolving tool_result entries
|
|
42
|
+
const toolIdToName = new Map();
|
|
43
|
+
for (const block of message.content) {
|
|
44
|
+
if (block.type === 'tool_use' && block.id && block.name) {
|
|
45
|
+
toolIdToName.set(block.id, block.name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (const block of message.content) {
|
|
49
|
+
if (block.type === 'tool_use' && block.name) {
|
|
50
|
+
entries.push({
|
|
51
|
+
type: 'tool_use',
|
|
52
|
+
timestamp: parsed.timestamp ?? undefined,
|
|
53
|
+
content: '',
|
|
54
|
+
tool_name: block.name,
|
|
55
|
+
tool_input: block.input,
|
|
56
|
+
session_id: parsed.sessionId ?? undefined,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (block.type === 'tool_result') {
|
|
60
|
+
const resultContent = typeof block.content === 'string'
|
|
61
|
+
? block.content
|
|
62
|
+
: Array.isArray(block.content)
|
|
63
|
+
? block.content
|
|
64
|
+
.map(c => c.text ?? '')
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.join('\n')
|
|
67
|
+
: '';
|
|
68
|
+
// Resolve tool_use_id to actual tool name
|
|
69
|
+
const toolUseId = block.tool_use_id;
|
|
70
|
+
const resolvedName = toolUseId ? toolIdToName.get(toolUseId) : undefined;
|
|
71
|
+
entries.push({
|
|
72
|
+
type: 'tool_result',
|
|
73
|
+
timestamp: parsed.timestamp ?? undefined,
|
|
74
|
+
content: resultContent,
|
|
75
|
+
tool_name: resolvedName ?? toolUseId,
|
|
76
|
+
session_id: parsed.sessionId ?? undefined,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
36
80
|
}
|
|
37
81
|
}
|
|
38
82
|
catch {
|
|
@@ -54,13 +98,27 @@ function normalizeEntry(raw) {
|
|
|
54
98
|
if (!type)
|
|
55
99
|
return null;
|
|
56
100
|
const content = extractTextContent(raw);
|
|
101
|
+
// Claude Code JSONL nests message fields
|
|
102
|
+
const message = raw.message;
|
|
103
|
+
// Extract tool_use blocks from assistant message content arrays
|
|
104
|
+
let toolName = raw.tool_name ?? raw.name ?? undefined;
|
|
105
|
+
let toolInput = raw.tool_input ?? raw.input ?? undefined;
|
|
106
|
+
if (!toolName && message?.content && Array.isArray(message.content)) {
|
|
107
|
+
for (const block of message.content) {
|
|
108
|
+
if (block.type === 'tool_use') {
|
|
109
|
+
toolName = block.name;
|
|
110
|
+
toolInput = block.input;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
57
115
|
return {
|
|
58
116
|
type,
|
|
59
117
|
timestamp: raw.timestamp ?? undefined,
|
|
60
118
|
content,
|
|
61
|
-
tool_name:
|
|
62
|
-
tool_input:
|
|
63
|
-
session_id: raw.session_id ?? undefined,
|
|
119
|
+
tool_name: toolName,
|
|
120
|
+
tool_input: toolInput,
|
|
121
|
+
session_id: raw.sessionId ?? raw.session_id ?? undefined,
|
|
64
122
|
};
|
|
65
123
|
}
|
|
66
124
|
function inferType(raw) {
|
|
@@ -98,7 +156,9 @@ function inferType(raw) {
|
|
|
98
156
|
* Extract text content from various message formats.
|
|
99
157
|
*/
|
|
100
158
|
function extractTextContent(raw) {
|
|
101
|
-
|
|
159
|
+
// Claude Code JSONL nests content under message.content
|
|
160
|
+
const message = raw.message;
|
|
161
|
+
const content = raw.content ?? message?.content ?? raw.text ?? '';
|
|
102
162
|
if (typeof content === 'string')
|
|
103
163
|
return content;
|
|
104
164
|
if (Array.isArray(content)) {
|
|
@@ -108,6 +168,8 @@ function extractTextContent(raw) {
|
|
|
108
168
|
return block;
|
|
109
169
|
if (block.text)
|
|
110
170
|
return block.text;
|
|
171
|
+
if (block.thinking)
|
|
172
|
+
return block.thinking;
|
|
111
173
|
if (block.content && typeof block.content === 'string')
|
|
112
174
|
return block.content;
|
|
113
175
|
return '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/transcript/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAa7D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,cAAsB,EAAE,OAAsB;IAC5E,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;IACtD,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;IAE7B,IAAI,WAAW,IAAI,UAAU,EAAE,CAAC;QAC9B,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;IAC5D,CAAC;IAED,MAAM,GAAG,GAAG,YAAY,CAAC,cAAc,EAA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