wendkeep 0.58.0 → 0.58.3

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 (34) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.en.md +28 -36
  3. package/README.md +28 -36
  4. package/docs/en/commands/changes-and-verification.md +79 -0
  5. package/docs/en/commands/costs-and-observability.md +65 -0
  6. package/docs/en/commands/getting-started.md +82 -0
  7. package/docs/en/commands/maintenance-and-diagnostics.md +77 -0
  8. package/docs/en/commands/memory-migration.md +73 -0
  9. package/docs/en/commands/memory.md +84 -0
  10. package/docs/en/commands/notes-and-knowledge.md +70 -0
  11. package/docs/en/commands/retroactive-import.md +67 -0
  12. package/docs/en/commands/sessions-and-import.md +85 -0
  13. package/docs/en/commands/verify.md +86 -0
  14. package/docs/pt-BR/commands/changes-and-verification.md +80 -0
  15. package/docs/pt-BR/commands/costs-and-observability.md +65 -0
  16. package/docs/pt-BR/commands/getting-started.md +83 -0
  17. package/docs/pt-BR/commands/maintenance-and-diagnostics.md +77 -0
  18. package/docs/pt-BR/commands/memory-migration.md +73 -0
  19. package/docs/pt-BR/commands/memory.md +83 -0
  20. package/docs/pt-BR/commands/notes-and-knowledge.md +69 -0
  21. package/docs/pt-BR/commands/retroactive-import.md +67 -0
  22. package/docs/pt-BR/commands/sessions-and-import.md +85 -0
  23. package/docs/pt-BR/commands/verify.md +87 -0
  24. package/hooks/brain-inject.mjs +2 -1
  25. package/hooks/memory-mode.mjs +39 -0
  26. package/hooks/memory-schema.mjs +15 -0
  27. package/hooks/obsidian-common.mjs +80 -29
  28. package/hooks/session-ensure.mjs +15 -8
  29. package/hooks/session-memory-lifecycle.mjs +330 -0
  30. package/hooks/session-stop.mjs +122 -42
  31. package/hooks/vault-health.mjs +124 -5
  32. package/package.json +3 -1
  33. package/src/memory.mjs +32 -7
  34. package/src/taxonomy.mjs +1 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,67 @@ 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.58.3] — 2026-07-26
8
+
9
+ ### Fixed
10
+
11
+ - **O primeiro `SessionStop` elegível após a migração legacy → v2 volta a publicar o handoff.**
12
+ A activation passa a representar um epoch com múltiplos Stops, e `UserPromptSubmit` recupera
13
+ uma única activation ausente sob lock. Identidade nativa de sessão/turno e a ordem física do
14
+ transcript impedem que Stops duplicados, atrasados ou de uma activation anterior publiquem de
15
+ novo ou sobrescrevam checkpoints mais recentes.
16
+ - **A publicação de memória ficou durável e observável de ponta a ponta.** O evento é enfileirado
17
+ antes de registrar `enqueued`, a projeção ocorre fora do lock e retries reutilizam a tentativa
18
+ congelada. Falhas preservam a outbox como `degraded`, enquanto retornos ambíguos deixam evidência
19
+ diagnóstica em vez de encerrar silenciosamente.
20
+ - **`wendkeep doctor` agora detecta memória v2 realmente estagnada sem acusar uma migração nova.**
21
+ O diagnóstico correlaciona tentativa, ledger, outbox, revisão e checkpoint; revision 0 logo após
22
+ uma migração válida continua saudável, mas perda causal, ambiguidade e divergência bloqueiam.
23
+
24
+ ### Changed
25
+
26
+ - **Os guias bilíngues de memória, sessões, migração e diagnóstico descrevem o lifecycle real.**
27
+ A documentação cobre epochs multi-Stop, recuperação única, retries idempotentes, estados
28
+ `enqueued|projected|degraded|ambiguous` e como interpretar revision 0.
29
+
30
+ ### Security
31
+
32
+ - **Fixtures persistíveis de lifecycle são integralmente sintéticas.** Um gate de privacidade
33
+ verifica arquivos rastreados e novos e reporta somente arquivo, linha e categoria, evitando que
34
+ caminhos ou identificadores locais entrem em testes, commits e artefatos.
35
+
36
+ ## [0.58.2] — 2026-07-26
37
+
38
+ ### Added
39
+
40
+ - **Referência completa dos comandos agora é bilíngue e orientada por tarefa.** Sete guias por
41
+ domínio e três guias profundos cobrem instalação, changes, verificação, memória, sessões,
42
+ importação, notas, custos e manutenção em PT-BR e inglês, com sintaxe, exits, exemplos,
43
+ resultados esperados e diagnóstico.
44
+ - **Paridade documental virou gate automatizado.** O novo sensor `docs-bilingual` bloqueia pares
45
+ ausentes, comandos públicos sem cobertura, links quebrados, estrutura divergente, drift da regra
46
+ local e guias ausentes no tarball.
47
+
48
+ ### Changed
49
+
50
+ - **Os READMEs agora apresentam as funcionalidades por grupos.** A referência extensa deu lugar a
51
+ um mapa navegável que leva ao guia correto no GitHub e no npm. O fluxo de `verify` deixa explícito
52
+ que exit 2 por ausência de change é contexto ocioso, não falha de saúde do projeto.
53
+
54
+ ## [0.58.1] — 2026-07-26
55
+
56
+ ### Fixed
57
+
58
+ - **Vaults com `SHARED_MEMORY.md` legado voltam a atualizar sem bloquear o doctor.** `init` e
59
+ `sync` ainda preservam todos os bytes existentes e podem criar os sidecars v2 ausentes,
60
+ mas sidecars vazios não ativam a memória v2. `memory status --gate` reporta o estado
61
+ `legacy` como aviso não bloqueante e `brain-inject` mantém CORE+DIGEST durante a janela de
62
+ compatibilidade.
63
+ - **`SessionStop` não migra memória implicitamente.** Enquanto o vault permanecer legado, o
64
+ Stop não grava outbox, ledger, candidates nem reescreve SHARED. A transição acontece somente
65
+ com `wendkeep memory migrate --apply`; conteúdo com assinatura/evidência v2 corrompida continua
66
+ visível e bloqueante, sem fallback silencioso.
67
+
7
68
  ## [0.58.0] — 2026-07-26
8
69
 
9
70
  ### Added
package/README.en.md CHANGED
@@ -156,41 +156,23 @@ stop reporting `defs stale` without a single skill having been updated. If you h
156
156
  `wk-*`, that edit is overwritten; your own customisation belongs in a skill of your own,
157
157
  which the reseed never touches.
158
158
 
159
- ## Commands
159
+ ## Features by group
160
160
 
161
- | Command | What it does |
162
- |---|---|
163
- | `wendkeep init` | Set up wendkeep in a project (vault taxonomy + settings + MCP + skills). |
164
- | `wendkeep sync [--project P]` | **One-command update**: runs `init` → `sync-defs` → `doctor` on the current project, stopping at the first failing step. Install the package first (a running process cannot replace itself). `--vault P` · `--yes` to skip the companions picker. |
165
- | `wendkeep hook <name>` | Run a session hook; invoked by `settings.json` (reads agent JSON on stdin). |
166
- | `wendkeep change <sub>` | Change lifecycle: `new <slug> [--simple]` / `use <slug>` (switch focus) / `continue <archived> <new> [--simple]` / `bind <slug> --session <id>` / `list` (global backlog) / `show <slug>` / `status [slug]` / `done <id> [--change slug]` / `undone <id> [--change slug]` / `relink [--apply] [--json]` (repair change wikilinks; preview by default) / `diff [slug]` / `archive [slug] [--force]` / `abandon [slug]` (drop it, no ADR) / `backlink [--apply]` (inject the proposal backlink into orphan design/tasks/spec files). `diff`, `archive` and `abandon` fall back to the active change when you omit the slug; bare `status` lists every open one. |
167
- | `wendkeep verify [--deep] [--change s]` | Run the change's task sensors; `--deep` assembles the independent-verification package. `--change` targets a change other than the active one; `--project <root>` runs it from outside the root. |
168
- | `wendkeep spec <sub>` | `list` / `show <capability>` generated contracts; `effective [--change <slug>] [--json]` (living contract + delta; defaults to the active change); `migrate`; `rebase [--accept-current]` (stops on conflicts unless you accept the living spec's side). |
169
- | `wendkeep sensors <sub>` | `list` / `add <id> "<command>"` with `--severity` / `--type` / `--report` / `--name` / `--description` / `--project` — view/edit `wendkeep.sensors.json` (JSON Schema shipped). |
170
- | `wendkeep cost [opts]` | Aggregate AI-coding spend across the vault's sessions — total, by model, by day. `--since <date>` / `--top [N]` (priciest) / `--trend [day\|week\|month]` (+ run-rate projection) / `--write` (generate `00-Custo.md`) / `--json`. |
171
- | `wendkeep cost rebuild [opts]` | Recalculate historical parent + subagent costs from `SESSION_REGISTRY`. Dry-run by default; `--apply` updates the notes and writes `.brain/COST_REBUILD.json`. Also `--session <id\|file>` / `--limit n` / `--json`. |
172
- | `wendkeep stats [--vault P]` | One shareable line: sessions · prompts · spend · span · models (`--json`). |
173
- | `wendkeep import [opts]` | **Retroactive memory** backfill past **Claude + Codex** sessions into the vault (deduped by `session_id`). `--source all\|claude\|codex` / `--stamp-ids` / `--rescan-decisions` / `--from <dir>` / `--codex-from <dir>` / `--since d` / `--limit n` / `--dry-run` / `--json`. |
174
- | `wendkeep session list\|show\|use` | List the multi-session registry, show one conversation, or move only the human focus in `CURRENT_SESSION.md`. |
175
- | `wendkeep dashboard [--force]` | (Re)generate the vault's folder-filtered Bases + the `00-Dashboard` MOC. |
176
- | `wendkeep note new --type bug\|learning "<title>"` | Create a **numbered** derived note (`BUG-`/`APR-NNNN`) in the month folder and print its vault path. `--date YYYY-MM-DD`. |
177
- | `wendkeep note relink [--apply]` | Backfill provenance on orphan derived notes (BUG/APR with no source session), inheriting the modal session of their type/month cohort. Preview by default. |
178
- | `wendkeep note repair-frontmatter [--apply]` | Merge stacked frontmatter blocks in a session note — damage from the concurrent writes of pre-0.50 versions. Base keys from the original block, values from the newest; preview by default · `--json`. |
179
- | `wendkeep note repair-sections [--apply]` | Rebuild the `## Decisions/Bugs/Learnings generated in this session` sections from the linked derived notes — the body used to lag behind the closing block. Preview by default · `--json`. |
180
- | `wendkeep renumber-decisions` | Renumber `04-Decisões` to `ADR-NNNN-<slug>` chronologically, move notes out of legacy `DIA N` subfolders into the month folder, and rewrite wikilinks. Preview by default; `--apply` / `--json`. |
181
- | `wendkeep renumber-bugs` | Same for `05-Bugs` → `BUG-NNNN-<slug>`. |
182
- | `wendkeep renumber-learnings` | Same for `06-Aprendizados`/`06-Learnings` → `APR-NNNN-<slug>`. |
183
- | `wendkeep lesson add "t" "l"` | Record a project-local lesson (injected at the next SessionStart). `--change <slug>` ties the lesson to a change; `--vault P`. |
184
- | `wendkeep sync-defs` | Copy `.brain/agents\|skills` into `.codex/agents`, `.claude/skills`, `.agents/skills`; `--check` detects drift, `--reseed` refreshes the `wk-*` skills from the installed version's seeds. |
185
- | `wendkeep memory status [--gate] --vault P` | Inspect the v2 bundle without mutating it. `--gate` exits 1 only for a blocking state; warnings keep exit code 0. |
186
- | `wendkeep memory migrate [--apply] --vault P` | Convert a legacy `SHARED_MEMORY.md`. Dry-run by default; `--apply` creates a backup, turns legacy content into candidates, and publishes a valid v2 projection without editing CORE. |
187
- | `wendkeep memory repair --vault P` | Repair a partial/corrupt ledger under lock, preserving the original bytes in a `.bak`, retaining valid events, and re-projecting state. |
188
- | `wendkeep memory promote <candidate> --vault P` | Promote a candidate by ID by appending an auditable event; never edits the ledger in place. |
189
- | `wendkeep memory reject <candidate> --vault P` | Reject a candidate by ID by appending the decision to the audit history. |
190
- | `wendkeep validate-memory [path]` | Compatibility mode: validate `.brain/CORE.md` only (cap 25, 3 sections, no secrets/PII). Use `--vault <path>` to validate CORE + ledger + SHARED as a v2 bundle. |
191
- | `wendkeep theme sync [--vault P]` | Re-apply the colour system (CSS snippet + graph groups) to an existing vault — recovers a grey graph without re-running `init`. |
192
- | `wendkeep doctor [--vault P]` | Read-only vault health check. Beyond sessions/registry, links, notes, prices, and derived sections, it checks the v2 bundle and points to `memory status --gate` or `memory repair`; doctor never projects or repairs by itself. |
193
- | `wendkeep --version` / `--help` | Version / usage. |
161
+ The README is the map; the guides provide syntax, options, exit codes, examples, and diagnosis.
162
+
163
+ | Group | Use it for | Detailed guide |
164
+ |---|---|---|
165
+ | **Installation and updates** | `init`, `sync`, companions, and the first project↔vault binding | [Installation and first use](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/getting-started.md) |
166
+ | **Changes and verification** | `change`, specs, sensors, TDD, evidence, and archive | [Changes and verification](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/changes-and-verification.md) |
167
+ | **Shared memory** | CORE, SHARED, status, validation, repair, and curation | [Memory](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory.md) |
168
+ | **Sessions and import** | hooks, registry, session focus, and Claude/Codex backfill | [Sessions and import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/sessions-and-import.md) |
169
+ | **Notes and knowledge** | BUG/APR/ADR, repairs, renumbering, lessons, and dashboard | [Notes and knowledge](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/notes-and-knowledge.md) |
170
+ | **Costs and observability** | stats, aggregation, trends, and historical rebuild | [Costs and observability](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/costs-and-observability.md) |
171
+ | **Maintenance and diagnostics** | doctor, definition drift, theme, version, and help | [Maintenance and diagnostics](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/maintenance-and-diagnostics.md) |
172
+
173
+ Operations that deserve step-by-step guidance: [verify and exits 0/1/2](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/verify.md),
174
+ [legacy-memory migration](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory-migration.md), and
175
+ [safe retroactive import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/retroactive-import.md).
194
176
 
195
177
  ## Shared Project Memory v2
196
178
 
@@ -198,11 +180,17 @@ Hot memory now separates human authorship, operational state, and evidence:
198
180
 
199
181
  - **`CORE.md` is canonical.** It is the short, hand-curated nucleus for durable preferences, active patterns, and open issues; no projector may infer or overwrite it.
200
182
  - **`SHARED_MEMORY.md` is generated operational state.** The `Stop` hook turns the session handoff into sanitized events; the projector deterministically reduces the ledger and publishes a verifiable revision, cursor, and hash. Facts are `verified` only with local evidence; unsupported reports remain `reported`, and disagreements become candidates for human judgment.
201
- - **`MEMORY_EVENTS.jsonl` is the append-only authority.** Producers publish to the outbox with exclusive creation, then the projector serializes append + projection under a lock. Repeating an identical `event_id`/payload is a no-op; reusing the ID with different bytes is observable corruption.
183
+ - **`MEMORY_EVENTS.jsonl` is the append-only authority.** `Stop` makes events durable in the outbox before acknowledging the attempt; the projector runs outside the registry lock and retries reuse the same IDs. Repeating an identical `event_id`/payload is a no-op; reusing the ID with different bytes is observable corruption.
202
184
  - **`MEMORY_CANDIDATES.jsonl` is the curation queue.** Conflicts and legacy content are never silently promoted. `promote` and `reject` record the decision as a new event.
203
185
 
204
186
  Artifacts stay under `.brain/` only. Sanitization strips secrets, tokens, local paths, transcripts, and harness payloads both before persistence and before injection. Events carry a `project_id`, and one vault never accepts another project's events.
205
187
 
188
+ Lifecycle in brief: each `SessionStart` opens an epoch that spans multiple `Stop` events;
189
+ `UserPromptSubmit` advances the native turn and recovers exactly one closed legacy activation.
190
+ Codex uses `session_id`/`turn_id` plus transcript order, with no artificial causal fields. See
191
+ [sessions and hooks](docs/en/commands/sessions-and-import.md) and
192
+ [memory](docs/en/commands/memory.md).
193
+
206
194
  ### Injection and budgets
207
195
 
208
196
  `brain-inject` delivers the same revision/hash on `startup`, `/clear`, and `/compact` `SessionStart` events, always placing CORE and SHARED before change context. The full envelope is capped at 24 KiB; CORE reserves up to 4 KiB, SHARED up to 6 KiB, and each line is capped at 320 characters. Under pressure, lessons are removed first, then non-current changes. CORE and SHARED are never prefix-sliced: a missing, invalid, or over-budget layer becomes a visible, repairable `<wk_memory_error>`.
@@ -217,7 +205,11 @@ wendkeep memory migrate --apply --vault .MyApp-vault # backup + candidates + v2
217
205
 
218
206
  ### Health and recovery
219
207
 
220
- Use `wendkeep memory status --gate --vault <vault>` in CI and before `verify`/`archive`. The critical `memory-health` sensor blocks ledger/outbox/bundle corruption, revision/cursor/hash lag, and active conflicts. A valid pending outbox or ordinary candidate is recoverable and remains a warning rather than blocking.
208
+ Use `wendkeep memory status --gate --vault <vault>` in CI and before `verify`/`archive`. Revision 0
209
+ immediately after valid migration is healthy. The gate correlates `last_memory_attempt`, outbox,
210
+ ledger, SHARED, and checkpoint: `degraded` with a durable outbox is a warning; an ambiguous attempt,
211
+ lost publication, or mismatched checkpoint blocks. See [migration](docs/en/commands/memory-migration.md)
212
+ and [diagnostics](docs/en/commands/maintenance-and-diagnostics.md).
221
213
 
222
214
  If status blocks, preserve the evidence and run `wendkeep memory repair --vault <vault>` to save a backup of the corrupt ledger, retain valid lines, and re-project. Then run `status --gate` again. Conflicts require explicit curation with `memory promote <id>` or `memory reject <id>`; doctor only diagnoses.
223
215
 
package/README.md CHANGED
@@ -156,41 +156,23 @@ stop reporting `defs stale` without a single skill having been updated. If you h
156
156
  `wk-*`, that edit is overwritten; your own customisation belongs in a skill of your own,
157
157
  which the reseed never touches.
158
158
 
159
- ## Commands
159
+ ## Features by group
160
160
 
161
- | Command | What it does |
162
- |---|---|
163
- | `wendkeep init` | Set up wendkeep in a project (vault taxonomy + settings + MCP + skills). |
164
- | `wendkeep sync [--project P]` | **One-command update**: runs `init` → `sync-defs` → `doctor` on the current project, stopping at the first failing step. Install the package first (a running process cannot replace itself). `--vault P` · `--yes` to skip the companions picker. |
165
- | `wendkeep hook <name>` | Run a session hook; invoked by `settings.json` (reads agent JSON on stdin). |
166
- | `wendkeep change <sub>` | Change lifecycle: `new <slug> [--simple]` / `use <slug>` (switch focus) / `continue <archived> <new> [--simple]` / `bind <slug> --session <id>` / `list` (global backlog) / `show <slug>` / `status [slug]` / `done <id> [--change slug]` / `undone <id> [--change slug]` / `relink [--apply] [--json]` (repair change wikilinks; preview by default) / `diff [slug]` / `archive [slug] [--force]` / `abandon [slug]` (drop it, no ADR) / `backlink [--apply]` (inject the proposal backlink into orphan design/tasks/spec files). `diff`, `archive` and `abandon` fall back to the active change when you omit the slug; bare `status` lists every open one. |
167
- | `wendkeep verify [--deep] [--change s]` | Run the change's task sensors; `--deep` assembles the independent-verification package. `--change` targets a change other than the active one; `--project <root>` runs it from outside the root. |
168
- | `wendkeep spec <sub>` | `list` / `show <capability>` generated contracts; `effective [--change <slug>] [--json]` (living contract + delta; defaults to the active change); `migrate`; `rebase [--accept-current]` (stops on conflicts unless you accept the living spec's side). |
169
- | `wendkeep sensors <sub>` | `list` / `add <id> "<command>"` with `--severity` / `--type` / `--report` / `--name` / `--description` / `--project` — view/edit `wendkeep.sensors.json` (JSON Schema shipped). |
170
- | `wendkeep cost [opts]` | Aggregate AI-coding spend across the vault's sessions — total, by model, by day. `--since <date>` / `--top [N]` (priciest) / `--trend [day\|week\|month]` (+ run-rate projection) / `--write` (generate `00-Custo.md`) / `--json`. |
171
- | `wendkeep cost rebuild [opts]` | Recalculate historical parent + subagent costs from `SESSION_REGISTRY`. Dry-run by default; `--apply` updates the notes and writes `.brain/COST_REBUILD.json`. Also `--session <id\|file>` / `--limit n` / `--json`. |
172
- | `wendkeep stats [--vault P]` | One shareable line: sessions · prompts · spend · span · models (`--json`). |
173
- | `wendkeep import [opts]` | **Retroactive memory** backfill past **Claude + Codex** sessions into the vault (deduped by `session_id`). `--source all\|claude\|codex` / `--stamp-ids` / `--rescan-decisions` / `--from <dir>` / `--codex-from <dir>` / `--since d` / `--limit n` / `--dry-run` / `--json`. |
174
- | `wendkeep session list\|show\|use` | List the multi-session registry, show one conversation, or move only the human focus in `CURRENT_SESSION.md`. |
175
- | `wendkeep dashboard [--force]` | (Re)generate the vault's folder-filtered Bases + the `00-Dashboard` MOC. |
176
- | `wendkeep note new --type bug\|learning "<title>"` | Create a **numbered** derived note (`BUG-`/`APR-NNNN`) in the month folder and print its vault path. `--date YYYY-MM-DD`. |
177
- | `wendkeep note relink [--apply]` | Backfill provenance on orphan derived notes (BUG/APR with no source session), inheriting the modal session of their type/month cohort. Preview by default. |
178
- | `wendkeep note repair-frontmatter [--apply]` | Merge stacked frontmatter blocks in a session note — damage from the concurrent writes of pre-0.50 versions. Base keys from the original block, values from the newest; preview by default · `--json`. |
179
- | `wendkeep note repair-sections [--apply]` | Rebuild the `## Decisions/Bugs/Learnings generated in this session` sections from the linked derived notes — the body used to lag behind the closing block. Preview by default · `--json`. |
180
- | `wendkeep renumber-decisions` | Renumber `04-Decisões` to `ADR-NNNN-<slug>` chronologically, move notes out of legacy `DIA N` subfolders into the month folder, and rewrite wikilinks. Preview by default; `--apply` / `--json`. |
181
- | `wendkeep renumber-bugs` | Same for `05-Bugs` → `BUG-NNNN-<slug>`. |
182
- | `wendkeep renumber-learnings` | Same for `06-Aprendizados`/`06-Learnings` → `APR-NNNN-<slug>`. |
183
- | `wendkeep lesson add "t" "l"` | Record a project-local lesson (injected at the next SessionStart). `--change <slug>` ties the lesson to a change; `--vault P`. |
184
- | `wendkeep sync-defs` | Copy `.brain/agents\|skills` into `.codex/agents`, `.claude/skills`, `.agents/skills`; `--check` detects drift, `--reseed` refreshes the `wk-*` skills from the installed version's seeds. |
185
- | `wendkeep memory status [--gate] --vault P` | Inspect the v2 bundle without mutating it. `--gate` exits 1 only for a blocking state; warnings keep exit code 0. |
186
- | `wendkeep memory migrate [--apply] --vault P` | Convert a legacy `SHARED_MEMORY.md`. Dry-run by default; `--apply` creates a backup, turns legacy content into candidates, and publishes a valid v2 projection without editing CORE. |
187
- | `wendkeep memory repair --vault P` | Repair a partial/corrupt ledger under lock, preserving the original bytes in a `.bak`, retaining valid events, and re-projecting state. |
188
- | `wendkeep memory promote <candidate> --vault P` | Promote a candidate by ID by appending an auditable event; never edits the ledger in place. |
189
- | `wendkeep memory reject <candidate> --vault P` | Reject a candidate by ID by appending the decision to the audit history. |
190
- | `wendkeep validate-memory [path]` | Compatibility mode: validate `.brain/CORE.md` only (cap 25, 3 sections, no secrets/PII). Use `--vault <path>` to validate CORE + ledger + SHARED as a v2 bundle. |
191
- | `wendkeep theme sync [--vault P]` | Re-apply the colour system (CSS snippet + graph groups) to an existing vault — recovers a grey graph without re-running `init`. |
192
- | `wendkeep doctor [--vault P]` | Read-only vault health check. Beyond sessions/registry, links, notes, prices, and derived sections, it checks the v2 bundle and points to `memory status --gate` or `memory repair`; doctor never projects or repairs by itself. |
193
- | `wendkeep --version` / `--help` | Version / usage. |
161
+ The README is the map; the guides provide syntax, options, exit codes, examples, and diagnosis.
162
+
163
+ | Group | Use it for | Detailed guide |
164
+ |---|---|---|
165
+ | **Installation and updates** | `init`, `sync`, companions, and the first project↔vault binding | [Installation and first use](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/getting-started.md) |
166
+ | **Changes and verification** | `change`, specs, sensors, TDD, evidence, and archive | [Changes and verification](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/changes-and-verification.md) |
167
+ | **Shared memory** | CORE, SHARED, status, validation, repair, and curation | [Memory](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory.md) |
168
+ | **Sessions and import** | hooks, registry, session focus, and Claude/Codex backfill | [Sessions and import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/sessions-and-import.md) |
169
+ | **Notes and knowledge** | BUG/APR/ADR, repairs, renumbering, lessons, and dashboard | [Notes and knowledge](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/notes-and-knowledge.md) |
170
+ | **Costs and observability** | stats, aggregation, trends, and historical rebuild | [Costs and observability](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/costs-and-observability.md) |
171
+ | **Maintenance and diagnostics** | doctor, definition drift, theme, version, and help | [Maintenance and diagnostics](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/maintenance-and-diagnostics.md) |
172
+
173
+ Operations that deserve step-by-step guidance: [verify and exits 0/1/2](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/verify.md),
174
+ [legacy-memory migration](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory-migration.md), and
175
+ [safe retroactive import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/retroactive-import.md).
194
176
 
195
177
  ## Shared Project Memory v2
196
178
 
@@ -198,11 +180,17 @@ Hot memory now separates human authorship, operational state, and evidence:
198
180
 
199
181
  - **`CORE.md` is canonical.** It is the short, hand-curated nucleus for durable preferences, active patterns, and open issues; no projector may infer or overwrite it.
200
182
  - **`SHARED_MEMORY.md` is generated operational state.** The `Stop` hook turns the session handoff into sanitized events; the projector deterministically reduces the ledger and publishes a verifiable revision, cursor, and hash. Facts are `verified` only with local evidence; unsupported reports remain `reported`, and disagreements become candidates for human judgment.
201
- - **`MEMORY_EVENTS.jsonl` is the append-only authority.** Producers publish to the outbox with exclusive creation, then the projector serializes append + projection under a lock. Repeating an identical `event_id`/payload is a no-op; reusing the ID with different bytes is observable corruption.
183
+ - **`MEMORY_EVENTS.jsonl` is the append-only authority.** `Stop` makes events durable in the outbox before acknowledging the attempt; the projector runs outside the registry lock and retries reuse the same IDs. Repeating an identical `event_id`/payload is a no-op; reusing the ID with different bytes is observable corruption.
202
184
  - **`MEMORY_CANDIDATES.jsonl` is the curation queue.** Conflicts and legacy content are never silently promoted. `promote` and `reject` record the decision as a new event.
203
185
 
204
186
  Artifacts stay under `.brain/` only. Sanitization strips secrets, tokens, local paths, transcripts, and harness payloads both before persistence and before injection. Events carry a `project_id`, and one vault never accepts another project's events.
205
187
 
188
+ Lifecycle in brief: each `SessionStart` opens an epoch that spans multiple `Stop` events;
189
+ `UserPromptSubmit` advances the native turn and recovers exactly one closed legacy activation.
190
+ Codex uses `session_id`/`turn_id` plus transcript order, with no artificial causal fields. See
191
+ [sessions and hooks](docs/en/commands/sessions-and-import.md) and
192
+ [memory](docs/en/commands/memory.md).
193
+
206
194
  ### Injection and budgets
207
195
 
208
196
  `brain-inject` delivers the same revision/hash on `startup`, `/clear`, and `/compact` `SessionStart` events, always placing CORE and SHARED before change context. The full envelope is capped at 24 KiB; CORE reserves up to 4 KiB, SHARED up to 6 KiB, and each line is capped at 320 characters. Under pressure, lessons are removed first, then non-current changes. CORE and SHARED are never prefix-sliced: a missing, invalid, or over-budget layer becomes a visible, repairable `<wk_memory_error>`.
@@ -217,7 +205,11 @@ wendkeep memory migrate --apply --vault .MyApp-vault # backup + candidates + v2
217
205
 
218
206
  ### Health and recovery
219
207
 
220
- Use `wendkeep memory status --gate --vault <vault>` in CI and before `verify`/`archive`. The critical `memory-health` sensor blocks ledger/outbox/bundle corruption, revision/cursor/hash lag, and active conflicts. A valid pending outbox or ordinary candidate is recoverable and remains a warning rather than blocking.
208
+ Use `wendkeep memory status --gate --vault <vault>` in CI and before `verify`/`archive`. Revision 0
209
+ immediately after valid migration is healthy. The gate correlates `last_memory_attempt`, outbox,
210
+ ledger, SHARED, and checkpoint: `degraded` with a durable outbox is a warning; an ambiguous attempt,
211
+ lost publication, or mismatched checkpoint blocks. See [migration](docs/en/commands/memory-migration.md)
212
+ and [diagnostics](docs/en/commands/maintenance-and-diagnostics.md).
221
213
 
222
214
  If status blocks, preserve the evidence and run `wendkeep memory repair --vault <vault>` to save a backup of the corrupt ledger, retain valid lines, and re-project. Then run `status --gate` again. Conflicts require explicit curation with `memory promote <id>` or `memory reject <id>`; doctor only diagnoses.
223
215
 
@@ -0,0 +1,79 @@
1
+ # Changes, specs, sensors, and archive
2
+
3
+ **English** · [Português](../../pt-BR/commands/changes-and-verification.md)
4
+
5
+ ## Purpose
6
+
7
+ Carry a change from recorded intent to an archived decision, linking requirements, tasks,
8
+ sensors, evidence, and verdict in the vault graph.
9
+
10
+ ## When to use
11
+
12
+ Use for any non-trivial implementation or fix that must leave auditable proof.
13
+
14
+ ## When not to use
15
+
16
+ Do not create a change merely to inspect health, import sessions, or run read-only maintenance.
17
+
18
+ ## Prerequisites
19
+
20
+ Initialize the project, keep the vault healthy, and provide a valid `wendkeep.sensors.json`.
21
+
22
+ ## Syntax
23
+
24
+ ```bash
25
+ npx wendkeep change new <slug>
26
+ npx wendkeep change status [slug]
27
+ npx wendkeep spec effective --change <slug>
28
+ npx wendkeep sensors list
29
+ npx wendkeep verify [--deep] [--change <slug>]
30
+ npx wendkeep change archive <slug>
31
+ ```
32
+
33
+ ## Options and exit codes
34
+
35
+ - `wendkeep change new <slug> [--simple]` creates proposal, design, tasks, and active pointer.
36
+ - `change use`, `list`, `show`, `status`, `diff`, `done`, and `undone` inspect or update work
37
+ without archiving it.
38
+ - `change continue <archived> <new>` starts follow-up work without inheriting stale proof.
39
+ - `change bind <slug> --session <id>` attaches an existing session.
40
+ - `change relink [--apply]` and `change backlink [--apply]` repair graph links; preview is default.
41
+ - `change abandon <slug>` drops work without an ADR; `archive --force` needs explicit human choice.
42
+ - `wendkeep spec list|show|effective|migrate|rebase` manages living contracts and deltas.
43
+ - `wendkeep sensors list|add` manages executable proof.
44
+ - Exit `0` means completion; gates use exit `1` for red proof and exit `2` for invalid
45
+ context/usage.
46
+
47
+ ## Examples
48
+
49
+ ```bash
50
+ npx wendkeep change new tenant-login
51
+ npx wendkeep spec effective --change tenant-login
52
+ npx wendkeep change done 1.1 --change tenant-login
53
+ npx wendkeep verify --change tenant-login
54
+ npx wendkeep verify --deep --change tenant-login
55
+ npx wendkeep change archive tenant-login
56
+ ```
57
+
58
+ Add a sensor:
59
+
60
+ ```bash
61
+ npx wendkeep sensors add api-contracts "npm run test:contracts" --severity critical
62
+ ```
63
+
64
+ ## Expected result
65
+
66
+ An archived change promotes its delta into the living spec, preserves proposal/design/tasks/proof,
67
+ and mints an ADR. Archive passes only with closed tasks, green required sensors, and a fresh verdict.
68
+
69
+ ## Common errors and diagnosis
70
+
71
+ - `no change`: select one with `change use <slug>` or pass `--change`.
72
+ - `spec_impact: pending`: choose `required` with a delta or `none` with a real reason.
73
+ - Sensor not executed: keep `[sensor:id]` on the same checkbox line as the task.
74
+ - Stale evidence: rerun `verify` and `verify --deep` after task/spec edits.
75
+ - Rebase conflict: resolve the delta or use `--accept-current` only when that is the decision.
76
+
77
+ ## Next steps
78
+
79
+ Read the deep [verify guide](verify.md) and [maintenance and diagnostics](maintenance-and-diagnostics.md).
@@ -0,0 +1,65 @@
1
+ # Costs and observability
2
+
3
+ **English** · [Português](../../pt-BR/commands/costs-and-observability.md)
4
+
5
+ ## Purpose
6
+
7
+ Measure sessions, prompts, models, and AI spend, and rebuild historical costs from canonical
8
+ transcripts when required.
9
+
10
+ ## When to use
11
+
12
+ Use `stats` for a quick view, `cost` for analysis, and `cost rebuild` when older notes lack
13
+ trustworthy costs.
14
+
15
+ ## When not to use
16
+
17
+ Do not apply rebuild before validating each session's provider and transcript. Do not compare
18
+ projects whose registries are mixed.
19
+
20
+ ## Prerequisites
21
+
22
+ A consistent registry, complete price table, and transcript access for rebuilt sessions.
23
+
24
+ ## Syntax
25
+
26
+ ```bash
27
+ npx wendkeep stats [--vault <vault>] [--json]
28
+ npx wendkeep cost [--since <date>] [--top [N]] [--trend day|week|month] [--write] [--json]
29
+ npx wendkeep cost rebuild [--session <id|file>] [--limit N] [--apply] [--json]
30
+ ```
31
+
32
+ ## Options and exit codes
33
+
34
+ - `wendkeep stats` emits one shareable line or JSON.
35
+ - `wendkeep cost` aggregates total/model/day; `--trend` adds projection and `--write` refreshes
36
+ `00-Custo.md`.
37
+ - `wendkeep cost rebuild` is dry-run by default; `--apply` writes notes and
38
+ `.brain/COST_REBUILD.json`.
39
+ - Exit `0` means a consistent calculation; non-zero reports insufficient registry, price,
40
+ transcript, or parsing state.
41
+
42
+ ## Examples
43
+
44
+ ```bash
45
+ npx wendkeep stats --vault .MyApp-vault
46
+ npx wendkeep cost --since 2026-07-01 --top 10 --trend week
47
+ npx wendkeep cost rebuild --session 019abc --json
48
+ ```
49
+
50
+ ## Expected result
51
+
52
+ Totals retain input/output/cache/reasoning dimensions by model and period. Rebuild shows a preview
53
+ before changing notes and leaves a reproducible report when applied.
54
+
55
+ ## Common errors and diagnosis
56
+
57
+ - Model without a price: update the table before accepting totals.
58
+ - Wrong-provider costs: validate the session identity chain.
59
+ - Missing transcript: do not estimate silently; keep the gap visible.
60
+ - Duplicated parent/subagent/fork totals: verify registry relationships and deduplication.
61
+
62
+ ## Next steps
63
+
64
+ See [sessions and import](sessions-and-import.md), [retroactive import](retroactive-import.md), and
65
+ [maintenance](maintenance-and-diagnostics.md).
@@ -0,0 +1,82 @@
1
+ # Installation and first use
2
+
3
+ **English** · [Português](../../pt-BR/commands/getting-started.md)
4
+
5
+ ## Purpose
6
+
7
+ Install WendKeep, bind the project to the correct vault, and enable capture, memory, and skills
8
+ without overwriting existing configuration.
9
+
10
+ ## When to use
11
+
12
+ Use `wendkeep init` for the first installation and `wendkeep sync` after updating the package.
13
+
14
+ ## When not to use
15
+
16
+ Do not run `init --force` as a generic repair for memory or unreadable configuration. Run
17
+ `wendkeep doctor` first and follow the repair command it reports.
18
+
19
+ ## Prerequisites
20
+
21
+ - Node.js 18 or newer.
22
+ - A local project and write access to the vault.
23
+ - Claude Code or Codex; Obsidian is optional at runtime and recommended for graph navigation.
24
+
25
+ ## Syntax
26
+
27
+ ```bash
28
+ npm install --save-dev wendkeep
29
+ npx wendkeep init [options]
30
+ npx wendkeep sync [--project <root>] [--vault <vault>] [--yes]
31
+ ```
32
+
33
+ ## Options and exit codes
34
+
35
+ - `--vault <path>` selects the vault; otherwise the local `.wendkeep.json` binding wins.
36
+ - `--project <path>` selects the project root.
37
+ - `--no-mcp`, `--no-colors`, and `--no-companions` disable optional integrations.
38
+ - `--companions <csv>` explicitly enables companion integrations.
39
+ - `--yes` accepts non-interactive defaults; `--force` refreshes managed blocks only.
40
+ - Exit `0` means setup/sync completed. Any other exit identifies the failed stage. `sync` stops at
41
+ `init`, `sync-defs`, or `doctor` instead of hiding the error.
42
+
43
+ ## Examples
44
+
45
+ First installation in the current project:
46
+
47
+ ```bash
48
+ npm install --save-dev wendkeep
49
+ npx wendkeep init --no-companions
50
+ ```
51
+
52
+ Later update:
53
+
54
+ ```bash
55
+ npm install --save-dev wendkeep@latest
56
+ npx wendkeep sync --yes
57
+ ```
58
+
59
+ With pnpm, pin a concrete version because minimum-release-age policies may keep `latest` silently
60
+ behind:
61
+
62
+ ```bash
63
+ pnpm add -D wendkeep@0.58.2
64
+ pnpm exec wendkeep sync --yes
65
+ ```
66
+
67
+ ## Expected result
68
+
69
+ The project receives `.wendkeep.json`, managed Claude/Codex hooks, skill definitions, and an
70
+ initialized vault. Existing files are merged or preserved, and the selected vault is printed.
71
+
72
+ ## Common errors and diagnosis
73
+
74
+ - Wrong vault: inspect `.wendkeep.json` and run `wendkeep doctor --vault <path>`.
75
+ - Codex hooks do not run: approve **Hooks need review** on the next startup.
76
+ - `defs stale`: run `wendkeep sync-defs --reseed`, then restart the agents.
77
+ - `sync` stops at doctor: read the failing section; do not retry with `--force` blindly.
78
+
79
+ ## Next steps
80
+
81
+ Continue with [maintenance and diagnostics](maintenance-and-diagnostics.md),
82
+ [sessions and import](sessions-and-import.md), and [shared memory](memory.md).
@@ -0,0 +1,77 @@
1
+ # Maintenance and diagnostics
2
+
3
+ **English** · [Português](../../pt-BR/commands/maintenance-and-diagnostics.md)
4
+
5
+ ## Purpose
6
+
7
+ Inspect vault health and keep definitions, theme, and package version aligned without treating
8
+ change commands as global checks.
9
+
10
+ ## When to use
11
+
12
+ Use after install/update, when hooks emit warnings, or before starting a change.
13
+
14
+ ## When not to use
15
+
16
+ Do not run `wendkeep verify` when no change is active. It proves a change's tasks; it is not a
17
+ replacement for doctor.
18
+
19
+ ## Prerequisites
20
+
21
+ Run from the project root or provide `--project` and `--vault` explicitly.
22
+
23
+ ## Syntax
24
+
25
+ ```bash
26
+ npx wendkeep doctor [--vault <vault>]
27
+ npx wendkeep sync-defs [--check|--reseed] --vault <vault> --project <root>
28
+ npx wendkeep theme sync --vault <vault>
29
+ npx wendkeep --version
30
+ npx wendkeep --help
31
+ ```
32
+
33
+ ## Options and exit codes
34
+
35
+ - `doctor` is read-only; exit `0` accepts recoverable warnings, while non-zero means failure.
36
+ - In v2, `doctor`/`memory status --gate` correlate `last_memory_attempt` (mode, disposition, event
37
+ IDs, and checkpoint) with outbox, ledger, and SHARED; they do not infer health from revision alone.
38
+ - `revision: 0` after a valid migration, with no v2 attempt, is healthy. A `degraded` attempt whose
39
+ events remain durable in the outbox/ledger is a recoverable warning.
40
+ - An ambiguous attempt, a lost event ID (absent from ledger and outbox), `projected` state found
41
+ only in the outbox, or a mismatched checkpoint is blocking.
42
+ - `sync-defs --check` detects drift without writes; `--reseed` restores packaged `wk-*` skills.
43
+ - `theme sync` reapplies the CSS snippet and graph groups without recreating the vault.
44
+ - `wendkeep --version` prints the running version; `wendkeep --help` lists the public interface.
45
+
46
+ ## Examples
47
+
48
+ Post-update checklist:
49
+
50
+ ```bash
51
+ npx wendkeep --version
52
+ npx wendkeep sync-defs --check --vault .MyApp-vault --project .
53
+ npx wendkeep doctor --vault .MyApp-vault
54
+ npx wendkeep memory status --gate --vault .MyApp-vault
55
+ ```
56
+
57
+ ## Expected result
58
+
59
+ Doctor names sessions, registry, links, notes, prices, derived sections, and memory as healthy or
60
+ provides a specific diagnostic/repair command. For memory, it distinguishes a valid initial empty
61
+ state, recoverable pending replay, and lost/divergent lifecycle state. It never repairs implicitly
62
+ or echoes private projector-error content into its report.
63
+
64
+ ## Common errors and diagnosis
65
+
66
+ - `no vault`: run from the bound root or pass `--vault`.
67
+ - `defs stale`: confirm the version and run `sync-defs --reseed`.
68
+ - Legacy vault: this is a non-blocking warning; plan `memory migrate --apply` separately.
69
+ - `degraded` plus an intact outbox: warning; preserve the outbox and allow idempotent replay.
70
+ - `ambiguous`, lost publication, or a mismatched checkpoint: blocking; preserve registry, ledger,
71
+ outbox, and SHARED so `last_memory_attempt` can be correlated before repair.
72
+ - Corrupt bundle: preserve evidence and run `memory status --gate` before `memory repair`.
73
+
74
+ ## Next steps
75
+
76
+ See [installation and first use](getting-started.md), [memory](memory.md), and
77
+ [change verification](verify.md).