@tekmidian/pai 0.29.0 → 0.30.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/dist/cli/index.mjs +1 -1
- package/dist/cli/program.mjs +1 -1
- package/dist/daemon/index.mjs +2 -2
- package/dist/{daemon-DKBd1s59.mjs → daemon-mFGnPd8q.mjs} +4 -4
- package/dist/{daemon-DKBd1s59.mjs.map → daemon-mFGnPd8q.mjs.map} +1 -1
- package/dist/hooks/context-compression-hook.mjs +10 -7
- package/dist/hooks/context-compression-hook.mjs.map +3 -3
- package/dist/hooks/stop-hook.mjs +23 -6
- package/dist/hooks/stop-hook.mjs.map +3 -3
- package/dist/{pick-Dq_KmJS5.mjs → pick-BcmBBfOF.mjs} +2 -2
- package/dist/{pick-Dq_KmJS5.mjs.map → pick-BcmBBfOF.mjs.map} +1 -1
- package/dist/{work-queue-worker-BsdNuTM2.mjs → work-queue-worker-B8QUONlK.mjs} +22 -3
- package/dist/work-queue-worker-B8QUONlK.mjs.map +1 -0
- package/package.json +1 -1
- package/src/hooks/ts/lib/project-utils/index.ts +1 -0
- package/src/hooks/ts/lib/project-utils/todo.test.ts +60 -1
- package/src/hooks/ts/lib/project-utils/todo.ts +37 -2
- package/src/hooks/ts/lib/project-utils.ts +1 -0
- package/src/hooks/ts/stop/stop-hook.ts +11 -2
- package/dist/work-queue-worker-BsdNuTM2.mjs.map +0 -1
package/dist/hooks/stop-hook.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/hooks/ts/stop/stop-hook.ts
|
|
4
4
|
import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, existsSync as existsSync7, unlinkSync } from "fs";
|
|
5
|
-
import { join as join7, basename as
|
|
5
|
+
import { join as join7, basename as basename4, dirname } from "path";
|
|
6
6
|
import { connect } from "net";
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
8
8
|
|
|
@@ -388,7 +388,7 @@ ${summary || "Session completed."}`
|
|
|
388
388
|
|
|
389
389
|
// src/hooks/ts/lib/project-utils/todo.ts
|
|
390
390
|
import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
391
|
-
import { join as join6 } from "path";
|
|
391
|
+
import { join as join6, basename as basename3 } from "path";
|
|
392
392
|
|
|
393
393
|
// src/session/checkpoint-block.ts
|
|
394
394
|
import {
|
|
@@ -767,7 +767,12 @@ function ensureTodoMd(cwd) {
|
|
|
767
767
|
}
|
|
768
768
|
return todoPath;
|
|
769
769
|
}
|
|
770
|
-
function
|
|
770
|
+
function sessionIdFromTranscript(transcriptPath) {
|
|
771
|
+
if (!transcriptPath) return void 0;
|
|
772
|
+
const base = basename3(transcriptPath).replace(/\.jsonl$/, "");
|
|
773
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(base) ? base : void 0;
|
|
774
|
+
}
|
|
775
|
+
function updateTodoContinue(cwd, noteFilename, state, tokenDisplay, sessionId) {
|
|
771
776
|
ensureTodoMd(cwd);
|
|
772
777
|
const result = applyContinue({
|
|
773
778
|
rootPath: cwd,
|
|
@@ -778,6 +783,9 @@ function updateTodoContinue(cwd, noteFilename, state, tokenDisplay) {
|
|
|
778
783
|
// is the key that decides whether an authored checkpoint belongs to the
|
|
779
784
|
// current session and must be preserved.
|
|
780
785
|
sessionLine: noteFilename.replace(/\.md$/, ""),
|
|
786
|
+
// The UUID is authoritative when present; the line above is the fallback
|
|
787
|
+
// for callers that cannot supply one, and it is mutable by design.
|
|
788
|
+
sessionId,
|
|
781
789
|
cwd,
|
|
782
790
|
body: state?.trim() || void 0
|
|
783
791
|
});
|
|
@@ -1279,7 +1287,7 @@ async function executeDirectly(lines, transcriptPath, cwd, message, lastUserQuer
|
|
|
1279
1287
|
}
|
|
1280
1288
|
const summary = message || "Session completed.";
|
|
1281
1289
|
finalizeSessionNote(currentNotePath, summary);
|
|
1282
|
-
console.error(`Session note finalized: ${
|
|
1290
|
+
console.error(`Session note finalized: ${basename4(currentNotePath)}`);
|
|
1283
1291
|
if (workItems.length === 0 && !message) {
|
|
1284
1292
|
console.error("Nothing to hand over \u2014 leaving TODO.md ## Continue intact");
|
|
1285
1293
|
} else {
|
|
@@ -1295,7 +1303,16 @@ async function executeDirectly(lines, transcriptPath, cwd, message, lastUserQuer
|
|
|
1295
1303
|
if (message) {
|
|
1296
1304
|
stateLines.push("", `Last completed: ${message}`);
|
|
1297
1305
|
}
|
|
1298
|
-
updateTodoContinue(
|
|
1306
|
+
updateTodoContinue(
|
|
1307
|
+
cwd,
|
|
1308
|
+
basename4(currentNotePath),
|
|
1309
|
+
stateLines.join("\n"),
|
|
1310
|
+
"session-end",
|
|
1311
|
+
// Identity, not the note title. The note is renamed as the session
|
|
1312
|
+
// ends, so the title-based comparison stops recognising this very
|
|
1313
|
+
// session moments after it writes.
|
|
1314
|
+
sessionIdFromTranscript(transcriptPath)
|
|
1315
|
+
);
|
|
1299
1316
|
} catch (todoError) {
|
|
1300
1317
|
console.error(`Could not update TODO.md: ${todoError}`);
|
|
1301
1318
|
}
|
|
@@ -1348,7 +1365,7 @@ STOP-HOOK TRIGGERED AT ${timestamp}`);
|
|
|
1348
1365
|
transcriptPath = parsed.transcript_path;
|
|
1349
1366
|
cwd = parsed.cwd || process.cwd();
|
|
1350
1367
|
stopHookActive = parsed.stop_hook_active === true;
|
|
1351
|
-
sessionId = parsed.session_id ??
|
|
1368
|
+
sessionId = parsed.session_id ?? basename4(transcriptPath ?? "").replace(/\.jsonl$/, "");
|
|
1352
1369
|
debug(`Transcript path: ${transcriptPath}`);
|
|
1353
1370
|
debug(`Working directory: ${cwd}`);
|
|
1354
1371
|
debug(`stop_hook_active: ${stopHookActive}`);
|