aicp-tracker 1.2.8 → 1.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/package.json +1 -1
- package/src/log-parser.js +13 -7
package/package.json
CHANGED
package/src/log-parser.js
CHANGED
|
@@ -158,12 +158,14 @@ function parseNewLines(filePath) {
|
|
|
158
158
|
|
|
159
159
|
// groupOrder preserves insertion order so records are emitted chronologically.
|
|
160
160
|
const groupOrder = [];
|
|
161
|
-
const groupTurns = new Map(); // promptId → assistant entries[]
|
|
161
|
+
const groupTurns = new Map(); // promptId → assistant entries with usage[]
|
|
162
|
+
const groupAllEntries = new Map(); // promptId → ALL entries in this turn (for file extraction)
|
|
162
163
|
const groupRef = new Map(); // promptId → reference entry (user msg or first asst turn)
|
|
163
164
|
|
|
164
165
|
function ensureGroup(pid, refEntry) {
|
|
165
166
|
if (!groupTurns.has(pid)) {
|
|
166
167
|
groupTurns.set(pid, []);
|
|
168
|
+
groupAllEntries.set(pid, []);
|
|
167
169
|
groupRef.set(pid, refEntry);
|
|
168
170
|
groupOrder.push(pid);
|
|
169
171
|
}
|
|
@@ -178,9 +180,11 @@ function parseNewLines(filePath) {
|
|
|
178
180
|
currentPromptId = entry.promptId;
|
|
179
181
|
latestPromptId = entry.promptId;
|
|
180
182
|
ensureGroup(currentPromptId, entry);
|
|
181
|
-
} else if (isAssistant &&
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
} else if (isAssistant && currentPromptId) {
|
|
184
|
+
// Track ALL assistant entries for file extraction, but only add ones with usage for token counting
|
|
185
|
+
ensureGroup(currentPromptId, entry);
|
|
186
|
+
groupAllEntries.get(currentPromptId).push(entry);
|
|
187
|
+
if (entry.message?.usage) {
|
|
184
188
|
groupTurns.get(currentPromptId).push(entry);
|
|
185
189
|
}
|
|
186
190
|
}
|
|
@@ -193,6 +197,7 @@ function parseNewLines(filePath) {
|
|
|
193
197
|
|
|
194
198
|
for (const promptId of groupOrder) {
|
|
195
199
|
const turns = groupTurns.get(promptId);
|
|
200
|
+
const allEntries = groupAllEntries.get(promptId);
|
|
196
201
|
if (!turns.length) continue;
|
|
197
202
|
|
|
198
203
|
const ref = groupRef.get(promptId);
|
|
@@ -203,11 +208,12 @@ function parseNewLines(filePath) {
|
|
|
203
208
|
const isCarryOver = promptId === carryOverPromptId && !carryOverSeenInBatch;
|
|
204
209
|
const baseUuid = isCarryOver ? `${promptId}:carry` : promptId;
|
|
205
210
|
|
|
206
|
-
// Collect ALL file paths from
|
|
211
|
+
// Collect ALL file paths from ALL entries (including ones without usage),
|
|
212
|
+
// not just from entries with usage
|
|
207
213
|
const allFiles = new Set();
|
|
208
214
|
const turnFiles = turns.map(extractFilePath);
|
|
209
|
-
for (const
|
|
210
|
-
for (const fp of extractAllFilePaths(
|
|
215
|
+
for (const entry of allEntries) {
|
|
216
|
+
for (const fp of extractAllFilePaths(entry)) {
|
|
211
217
|
allFiles.add(fp);
|
|
212
218
|
}
|
|
213
219
|
}
|