braintracker 1.3.0 → 1.4.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.
|
@@ -10,25 +10,31 @@ process.stdin.on('end', () => {
|
|
|
10
10
|
try { payload = JSON.parse(raw); } catch { process.exit(0); }
|
|
11
11
|
|
|
12
12
|
const sessionId = payload.session_id;
|
|
13
|
+
if (!sessionId) process.exit(0);
|
|
14
|
+
|
|
13
15
|
const prj = path.basename(process.cwd());
|
|
14
16
|
const cacheDir = path.join(os.homedir(), '.claude', 'plugin', 'cache', 'braintracker', prj);
|
|
15
|
-
|
|
17
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
18
|
+
|
|
19
|
+
let messages = [];
|
|
20
|
+
try {
|
|
21
|
+
if (payload.transcript_path) {
|
|
22
|
+
messages = fs.readFileSync(payload.transcript_path, 'utf8')
|
|
23
|
+
.trim().split('\n').map(l => JSON.parse(l));
|
|
24
|
+
}
|
|
25
|
+
} catch { /* transcript unavailable */ }
|
|
16
26
|
|
|
27
|
+
const preFile = path.join(cacheDir, `${sessionId}.turn.pre.json`);
|
|
17
28
|
let preData;
|
|
18
29
|
try { preData = JSON.parse(fs.readFileSync(preFile, 'utf8')); } catch { process.exit(0); }
|
|
19
30
|
|
|
20
|
-
const transcript = payload.transcript || [];
|
|
21
|
-
|
|
22
|
-
// overwrite transcript file with full conversation on every turn
|
|
23
|
-
const transcriptFile = path.join(cacheDir, `${sessionId}.transcript.json`);
|
|
24
|
-
fs.writeFileSync(transcriptFile, JSON.stringify(transcript, null, 2));
|
|
25
|
-
|
|
26
31
|
const entry = {
|
|
27
32
|
type: 'conversation_turn',
|
|
28
33
|
session_id: sessionId,
|
|
29
34
|
user_prompt: preData.prompt,
|
|
30
35
|
started_at: new Date(preData.start_time).toISOString(),
|
|
31
36
|
duration_seconds: (Date.now() - preData.start_time) / 1000,
|
|
37
|
+
messages,
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
const logFile = path.join(cacheDir, `${sessionId}.jsonl`);
|