wendkeep 0.44.0 → 0.45.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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to **wendkeep** are documented here. Format based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project follows
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.45.0] — 2026-07-18
8
+
9
+ ### Fixed
10
+
11
+ - Observabilidade: o note de sessão deixa de ser reescrito com timestamp novo a cada Stop
12
+ quando o uso não muda. A preservação de `atualizado_em` (`token-usage.mjs`) comparava
13
+ `previous` (parseado do note) com `current` (recém-computado) via `JSON.stringify` —
14
+ sensível à ordem das chaves, que difere entre parse e build, então a comparação **sempre**
15
+ falhava e o timestamp era re-stampado toda vez. Novo `sameUsageData(a, b)` compara os campos
16
+ de uso de forma ordem-insensível (ignorando `atualizado_em`). Corrige o churn de reescrita e
17
+ o teste flaky "same sources produce byte-identical markdown".
18
+
7
19
  ## [0.44.0] — 2026-07-17
8
20
 
9
21
  ### Changed
@@ -604,6 +604,19 @@ function transcriptIdFromPath(transcriptPath) {
604
604
  return basename(String(transcriptPath || '')).replace(/\.jsonl?$/i, '') || 'desconhecido';
605
605
  }
606
606
 
607
+ // The usage fields that define whether a transcript's entry "changed" — everything except the
608
+ // key (transcript_id) and the timestamp (atualizado_em). Order-insensitive by design: a new
609
+ // field here is the single place to keep preservation correct.
610
+ const USAGE_FIELDS = ['provider', 'pensamento', 'input', 'cache_write', 'cache_read',
611
+ 'output', 'reasoning', 'total', 'custo_usd', 'prompts', 'tool_calls', 'chamadas_llm'];
612
+
613
+ export function sameUsageData(a, b) {
614
+ if (!a || !b) return false;
615
+ const listEqual = (x, y) => (x || []).join('') === (y || []).join('');
616
+ return USAGE_FIELDS.every((f) => (a[f] ?? null) === (b[f] ?? null))
617
+ && listEqual(a.modelos, b.modelos) && listEqual(a.tools, b.tools);
618
+ }
619
+
607
620
  function entryFromSummary(summary, transcriptId) {
608
621
  return {
609
622
  transcript_id: transcriptId,
@@ -931,10 +944,11 @@ export function collectSessionUsage({ sessionContent, transcriptPath }) {
931
944
  const transcriptId = transcriptIdFromPath(transcriptPath);
932
945
  const previous = existingEntries.find((entry) => entry.transcript_id === transcriptId);
933
946
  const current = entryFromSummary(summary, transcriptId);
934
- if (previous) {
935
- const comparable = (entry) => JSON.stringify({ ...entry, atualizado_em: undefined });
936
- if (comparable(previous) === comparable(current)) current.atualizado_em = previous.atualizado_em;
937
- }
947
+ // Preserve the old timestamp when the usage data is unchanged, so an unchanged session note
948
+ // stays byte-identical (no needless rewrite on every Stop). Compared semantically, NOT via
949
+ // JSON.stringify: the parsed-from-note entry and the freshly-built one have different key
950
+ // orders, which made the old stringify compare always mismatch — preservation never fired.
951
+ if (previous && sameUsageData(previous, current)) current.atualizado_em = previous.atualizado_em;
938
952
  let entries = existingEntries.filter((e) => e.transcript_id !== transcriptId);
939
953
 
940
954
  if (!existingEntries.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wendkeep",
3
- "version": "0.44.0",
3
+ "version": "0.45.0",
4
4
  "description": "A persistent-memory harness for AI coding agents on your Obsidian vault: turn-by-turn session capture plus a native, zero-dependency spec→change→verify→archive loop (sensor-gated, independent verdict, mutation discrimination). Local-first, agent-agnostic (Claude Code, Codex, Cursor…).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -46,6 +46,6 @@
46
46
  "url": "https://github.com/rogersialves/wendkeep/issues"
47
47
  },
48
48
  "devDependencies": {
49
- "wendkeep": "^0.39.0"
49
+ "wendkeep": "^0.44.0"
50
50
  }
51
51
  }