@pdpp/local-collector 0.1.0-beta.6 → 0.1.0-beta.7
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.
|
@@ -148,6 +148,17 @@ export function observeJsonlFields(obj, obs, forcedSessionId) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
+
function updateSessionAccumulatorFromCurrentLine(sessionAccumulators, projectDir, obs, obj, messageCountDelta) {
|
|
152
|
+
if (!obs.sessionId) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
updateSessionAccumulator(sessionAccumulators, projectDir, {
|
|
156
|
+
...obs,
|
|
157
|
+
firstTimestamp: obj.timestamp ?? null,
|
|
158
|
+
lastTimestamp: obj.timestamp ?? null,
|
|
159
|
+
messageCount: messageCountDelta,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
151
162
|
export function isMessageType(type) {
|
|
152
163
|
return type === "user" || type === "assistant";
|
|
153
164
|
}
|
|
@@ -357,11 +368,12 @@ async function parseJsonlFile(args) {
|
|
|
357
368
|
message: ` ${path}: ${lineCount} lines parsed`,
|
|
358
369
|
});
|
|
359
370
|
}
|
|
371
|
+
const messageCountBeforeLine = obs.messageCount;
|
|
360
372
|
observeJsonlFields(obj, obs, forcedSessionId);
|
|
361
373
|
await processJsonlLine({ buildOnly, deps: { emitRecord, requested }, obj, obs });
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
374
|
+
if (buildOnly) {
|
|
375
|
+
updateSessionAccumulatorFromCurrentLine(sessionAccumulators, projectDir, obs, obj, obs.messageCount - messageCountBeforeLine);
|
|
376
|
+
}
|
|
365
377
|
}
|
|
366
378
|
return obs.sessionId;
|
|
367
379
|
}
|
|
@@ -732,7 +744,8 @@ if (isMainModule(import.meta.url)) {
|
|
|
732
744
|
const baseDir = process.env.CLAUDE_CODE_PROJECTS_DIR || join(claudeHome, "projects");
|
|
733
745
|
await assertRequestedClaudeSources({ baseDir, claudeHome, requested });
|
|
734
746
|
const typedState = state;
|
|
735
|
-
const
|
|
747
|
+
const messageFileMtimes = streamFileMtimes(typedState, "messages") ?? typedState.file_mtimes ?? {};
|
|
748
|
+
const sessionFileMtimes = streamFileMtimes(typedState, "sessions") ?? {};
|
|
736
749
|
const skillsMtimes = streamFileMtimes(typedState, "skills") ?? {};
|
|
737
750
|
const slashCommandMtimes = streamFileMtimes(typedState, "slash_commands") ?? {};
|
|
738
751
|
const memoryNoteMtimes = streamFileMtimes(typedState, "memory_notes") ?? {};
|
|
@@ -753,15 +766,16 @@ if (isMainModule(import.meta.url)) {
|
|
|
753
766
|
if (!needsProjects) {
|
|
754
767
|
return;
|
|
755
768
|
}
|
|
756
|
-
const
|
|
769
|
+
const newMessageFileMtimes = { ...messageFileMtimes };
|
|
770
|
+
const newSessionFileMtimes = { ...sessionFileMtimes };
|
|
757
771
|
const sessionAccumulators = new Map();
|
|
758
772
|
await scanProjectDirs({
|
|
759
773
|
baseDir,
|
|
760
774
|
buildOnly: true,
|
|
761
775
|
emit,
|
|
762
776
|
emitRecord,
|
|
763
|
-
fileMtimes,
|
|
764
|
-
newMtimes,
|
|
777
|
+
fileMtimes: sessionFileMtimes,
|
|
778
|
+
newMtimes: newSessionFileMtimes,
|
|
765
779
|
memoryNoteMtimes,
|
|
766
780
|
newMemoryNoteMtimes,
|
|
767
781
|
requested,
|
|
@@ -772,7 +786,7 @@ if (isMainModule(import.meta.url)) {
|
|
|
772
786
|
await emit({
|
|
773
787
|
type: "STATE",
|
|
774
788
|
stream: "sessions",
|
|
775
|
-
cursor: { fetched_at: nowIso() },
|
|
789
|
+
cursor: { file_mtimes: newSessionFileMtimes, fetched_at: nowIso() },
|
|
776
790
|
});
|
|
777
791
|
}
|
|
778
792
|
if (requested.has("memory_notes")) {
|
|
@@ -788,8 +802,8 @@ if (isMainModule(import.meta.url)) {
|
|
|
788
802
|
buildOnly: false,
|
|
789
803
|
emit,
|
|
790
804
|
emitRecord,
|
|
791
|
-
fileMtimes,
|
|
792
|
-
newMtimes,
|
|
805
|
+
fileMtimes: messageFileMtimes,
|
|
806
|
+
newMtimes: newMessageFileMtimes,
|
|
793
807
|
requested,
|
|
794
808
|
sessionAccumulators,
|
|
795
809
|
});
|
|
@@ -798,7 +812,7 @@ if (isMainModule(import.meta.url)) {
|
|
|
798
812
|
await emit({
|
|
799
813
|
type: "STATE",
|
|
800
814
|
stream: "messages",
|
|
801
|
-
cursor: { file_mtimes:
|
|
815
|
+
cursor: { file_mtimes: newMessageFileMtimes, fetched_at: nowIso() },
|
|
802
816
|
});
|
|
803
817
|
}
|
|
804
818
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdpp/local-collector",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.7",
|
|
4
4
|
"description": "Publishable local collector runtime for PDPP: filesystem-class connectors (Claude Code, Codex) plus the device-exporter ingest client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|