neuvikon 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. package/dist/index.mjs +25 -1
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -555,6 +555,25 @@ async function readStdin() {
555
555
  * while we read it will have a torn final line, and that is normal, not an
556
556
  * error worth failing a user's turn over.
557
557
  */
558
+ /**
559
+ * Where the transcript currently ends, so a session that starts mid-conversation
560
+ * can mark its starting point instead of counting what came before it.
561
+ */
562
+ function transcriptSize(path) {
563
+ let fd;
564
+ try {
565
+ fd = openSync(path, "r");
566
+ } catch {
567
+ return null;
568
+ }
569
+ try {
570
+ return fstatSync(fd).size;
571
+ } catch {
572
+ return null;
573
+ } finally {
574
+ closeSync(fd);
575
+ }
576
+ }
558
577
  function readUsageSince(path, offset) {
559
578
  let fd;
560
579
  try {
@@ -661,7 +680,12 @@ async function report(flags) {
661
680
  let nextOffset;
662
681
  const transcript = flags.get("transcript") || await transcriptFromHookPayload();
663
682
  if (transcript) {
664
- const usage = readUsageSince(transcript, session.transcriptOffset ?? 0);
683
+ const baseline = session.transcriptOffset ?? transcriptSize(transcript);
684
+ if (session.transcriptOffset === void 0 && baseline !== null) writeSession({
685
+ ...session,
686
+ transcriptOffset: baseline
687
+ });
688
+ const usage = baseline === null ? null : readUsageSince(transcript, baseline);
665
689
  if (usage) {
666
690
  tokensIn = (tokensIn ?? 0) + usage.tokensIn;
667
691
  tokensOut = (tokensOut ?? 0) + usage.tokensOut;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neuvikon",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Tell Neuvikon which ticket your coding agent is working on.",
5
5
  "keywords": [
6
6
  "neuvikon",