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
@@ -0,0 +1,73 @@
1
+ # Legacy-to-v2 memory migration
2
+
3
+ **English** · [Português](../../pt-BR/commands/memory-migration.md)
4
+
5
+ ## Purpose
6
+
7
+ Convert a legacy `SHARED_MEMORY.md` into an auditable v2 bundle without overwriting CORE or
8
+ silently promoting old reports.
9
+
10
+ ## When to use
11
+
12
+ Use when `memory status` reports `legacy` and the team is ready to curate converted content.
13
+
14
+ ## When not to use
15
+
16
+ Do not migrate automatically during `init`, `sync`, SessionStop, or merely to silence a warning.
17
+ Do not apply until the backup and expected state are understood.
18
+
19
+ ## Prerequisites
20
+
21
+ - Valid CORE and preserved legacy bytes.
22
+ - No partially corrupt v2 bundle.
23
+ - Human review of the candidates that will be created.
24
+
25
+ ## Syntax
26
+
27
+ ```bash
28
+ npx wendkeep memory status --gate --vault <vault>
29
+ npx wendkeep memory migrate --vault <vault>
30
+ npx wendkeep memory migrate --apply --vault <vault>
31
+ ```
32
+
33
+ ## Options and exit codes
34
+
35
+ - Without `--apply`, `wendkeep memory migrate` is a zero-write dry run.
36
+ - `--apply` creates a backup, converts legacy content into candidates, and publishes valid v2.
37
+ - A newly migrated bundle may start healthy at `revision: 0`: no v2 attempt or eligible event has
38
+ happened yet, so zero does not mean the lifecycle is stalled.
39
+ - Exit `0` means a consistent preview/application; non-zero preserves original state and reports
40
+ the failure.
41
+
42
+ ## Examples
43
+
44
+ ```bash
45
+ npx wendkeep memory migrate --vault .MyApp-vault
46
+ # review the preview
47
+ npx wendkeep memory migrate --apply --vault .MyApp-vault
48
+ npx wendkeep memory status --gate --vault .MyApp-vault
49
+ ```
50
+
51
+ ## Expected result
52
+
53
+ The vault receives a coherent v2 ledger/projection, a backup of legacy SHARED, and candidates for
54
+ unsupported facts. CORE is untouched and unverified content is not activated automatically.
55
+ After migration, the next `UserPromptSubmit` opens exactly one recovery activation when the
56
+ legacy registry was closed; the first transcript-proven `Stop` publishes once and advances SHARED
57
+ to revision 1. Replaying that prompt or Stop does not duplicate the event/revision.
58
+
59
+ ## Common errors and diagnosis
60
+
61
+ - Dry run says already v2: do not apply again.
62
+ - `revision: 0` immediately after a valid apply: this is healthy; wait for an eligible prompt and
63
+ Stop instead of repairing or repeating migration.
64
+ - Partial/corrupt v2 bundle: use status and repair; migration is not a corruption tool.
65
+ - First post-migration Stop is `ambiguous`: verify that its `turn_id` belongs to the transcript and
66
+ that `UserPromptSubmit` opened/advanced the recovery activation.
67
+ - Many candidates: curate gradually with `memory promote`/`memory reject`.
68
+ - Legacy warning remains after apply: verify the selected vault and project binding.
69
+
70
+ ## Next steps
71
+
72
+ Return to [memory and curation](memory.md) and run
73
+ [maintenance and diagnostics](maintenance-and-diagnostics.md).
@@ -0,0 +1,84 @@
1
+ # Shared memory and curation
2
+
3
+ **English** · [Português](../../pt-BR/commands/memory.md)
4
+
5
+ ## Purpose
6
+
7
+ Inspect and curate CORE, SHARED, ledger, outbox, attempts, and candidates without confusing
8
+ canonical authorship with generated operational state.
9
+
10
+ ## When to use
11
+
12
+ Use in CI, before verify/archive, after doctor warnings, or when deciding candidates.
13
+
14
+ ## When not to use
15
+
16
+ Do not hand-edit `SHARED_MEMORY.md` or `MEMORY_EVENTS.jsonl`. Do not repair a healthy legacy vault
17
+ that merely awaits migration.
18
+
19
+ ## Prerequisites
20
+
21
+ Pass the vault explicitly in automation. Preserve backups and evidence before repair.
22
+
23
+ ## Syntax
24
+
25
+ ```bash
26
+ npx wendkeep memory status [--gate] --vault <vault>
27
+ npx wendkeep memory repair --vault <vault>
28
+ npx wendkeep memory promote <candidate> --vault <vault>
29
+ npx wendkeep memory reject <candidate> --vault <vault>
30
+ npx wendkeep validate-memory [CORE-path]
31
+ npx wendkeep validate-memory --vault <v2-vault>
32
+ ```
33
+
34
+ ## Options and exit codes
35
+
36
+ - `memory status` is read-only; `--gate` exits `1` only for blocking state.
37
+ - `Stop` writes events to the outbox before acknowledging `last_memory_attempt: enqueued`, then the
38
+ projector runs outside the registry lock. Retrying the same attempt reuses its frozen event IDs
39
+ and can project them at most once.
40
+ - A busy/failed projector persists `degraded`, preserves the outbox, and reports replay. A later
41
+ Stop/retry reuses that attempt instead of rebuilding its handoff from new transient data.
42
+ - The outcome updates `memory_status`/checkpoint only while activation, epoch, turn, and attempt
43
+ still match exactly. A stale/superseded result cannot clear or overwrite a newer checkpoint.
44
+ - A valid legacy vault warns and exits `0`. For v2, status correlates `last_memory_attempt`,
45
+ disposition, outbox, ledger, SHARED, and checkpoint: an ambiguous attempt, lost publication, or
46
+ mismatched checkpoint blocks; `degraded` with an intact outbox is a warning.
47
+ - `memory repair` locks, writes a `.bak`, retains valid events, and reprojects state.
48
+ - `promote`/`reject` append auditable decisions and never rewrite the ledger in place.
49
+ - `validate-memory <CORE.md>` checks the 25-line cap, required sections, and secrets.
50
+ - `validate-memory --vault` requires a complete v2 bundle and is not the legacy-vault gate.
51
+
52
+ ## Examples
53
+
54
+ ```bash
55
+ npx wendkeep memory status --gate --vault .MyApp-vault
56
+ npx wendkeep validate-memory .MyApp-vault/.brain/CORE.md
57
+ npx wendkeep memory promote candidate-123 --vault .MyApp-vault
58
+ ```
59
+
60
+ ## Expected result
61
+
62
+ Status prints schema, revision, cursor, hash, events, outbox, candidates, conflicts, and the causal
63
+ state of the last attempt. CORE stays hand-curated and canonical; SHARED stays a verifiable
64
+ operational projection. After successful projection, an attempt checkpoint may be a valid prefix
65
+ of a global projection that has already advanced with concurrent events.
66
+
67
+ ## Common errors and diagnosis
68
+
69
+ - `legacy`: follow the migration guide; this is not corruption.
70
+ - `revision: 0` immediately after a valid migration, with no v2 attempt, is healthy; do not run
71
+ repair merely to manufacture the first event.
72
+ - `degraded` with every event ID present in either the ledger or an intact outbox is recoverable;
73
+ let idempotent replay finish. An event ID absent from both locations means lost publication.
74
+ - An `ambiguous` attempt, an `applied` attempt without event IDs, a `projected` event found only in
75
+ the outbox, or a mismatched checkpoint is blocking: preserve the artifacts and investigate
76
+ before repair.
77
+ - Ordinary pending candidate: recoverable warning, requiring human choice when appropriate.
78
+ - Missing `event_cursor` or mismatched v2 hash: preserve the bundle and assess `memory repair`.
79
+ - `validate-memory --vault` fails on legacy: validate CORE only or migrate first.
80
+
81
+ ## Next steps
82
+
83
+ Read [memory migration](memory-migration.md), [maintenance](maintenance-and-diagnostics.md), and
84
+ [verify](verify.md).
@@ -0,0 +1,70 @@
1
+ # Derived notes and knowledge graph
2
+
3
+ **English** · [Português](../../pt-BR/commands/notes-and-knowledge.md)
4
+
5
+ ## Purpose
6
+
7
+ Create, repair, number, and navigate decisions, bugs, and learnings while preserving provenance
8
+ and wikilinks.
9
+
10
+ ## When to use
11
+
12
+ Use to record durable knowledge or repair historical notes diagnosed by doctor.
13
+
14
+ ## When not to use
15
+
16
+ Do not hand-edit numbering or wikilinks in bulk. Do not use `--apply` before reviewing the preview.
17
+
18
+ ## Prerequisites
19
+
20
+ A bound vault, identifiable source session, and backup before broad renumbering.
21
+
22
+ ## Syntax
23
+
24
+ ```bash
25
+ npx wendkeep dashboard [--force]
26
+ npx wendkeep note new --type bug|learning "<title>"
27
+ npx wendkeep note relink [--apply]
28
+ npx wendkeep note repair-frontmatter [--apply]
29
+ npx wendkeep note repair-sections [--apply]
30
+ npx wendkeep renumber-decisions [--apply]
31
+ npx wendkeep renumber-bugs [--apply]
32
+ npx wendkeep renumber-learnings [--apply]
33
+ npx wendkeep lesson add "<title>" "<lesson>"
34
+ ```
35
+
36
+ ## Options and exit codes
37
+
38
+ - `note new` creates a monthly `BUG-NNNN` or `APR-NNNN` and accepts `--date`.
39
+ - `note relink`, `repair-frontmatter`, `repair-sections`, and `renumber-*` default to dry-run;
40
+ `--apply` writes and `--json` supports audit.
41
+ - `dashboard --force` regenerates Bases/MOC when required.
42
+ - `lesson add` accepts `--change <slug>` and `--vault` to bind local learning.
43
+ - Exit `0` means a consistent preview/application; non-zero makes incomplete repair explicit.
44
+
45
+ ## Examples
46
+
47
+ ```bash
48
+ npx wendkeep note new --type bug "refresh expires during upload"
49
+ npx wendkeep note relink --json
50
+ npx wendkeep renumber-decisions --json
51
+ # review before repeating with --apply
52
+ npx wendkeep dashboard --force
53
+ ```
54
+
55
+ ## Expected result
56
+
57
+ Derived notes live in the month folder, use global per-type numbering, and link back to the source
58
+ session. Repairs preserve valid frontmatter and rewrite wikilinks when files move.
59
+
60
+ ## Common errors and diagnosis
61
+
62
+ - Orphan note without a modal source: `note relink` reports it and does not invent provenance.
63
+ - Stacked frontmatter: repair under the same lock used by hooks.
64
+ - Grey links after renumber/archive: preview relink and inspect ambiguities.
65
+ - Sensitive title: remove secrets/PII before persistence.
66
+
67
+ ## Next steps
68
+
69
+ See [sessions and import](sessions-and-import.md), [costs and observability](costs-and-observability.md),
70
+ and [maintenance](maintenance-and-diagnostics.md).
@@ -0,0 +1,67 @@
1
+ # Safe retroactive import
2
+
3
+ **English** · [Português](../../pt-BR/commands/retroactive-import.md)
4
+
5
+ ## Purpose
6
+
7
+ Import historical Claude and Codex sessions with bounded scope, stable identity, and review before
8
+ writes.
9
+
10
+ ## When to use
11
+
12
+ Use when installing WendKeep in an existing project, recovering a date range, or rescanning
13
+ decisions without importing every transcript on the machine.
14
+
15
+ ## When not to use
16
+
17
+ Do not use `--source all` without dry-run on machines with many projects, forks, or subagent
18
+ rollouts. Do not treat imported conversation history as current implementation evidence.
19
+
20
+ ## Prerequisites
21
+
22
+ Confirm project, vault, provider, source directory, and date window. Back up the registry if it
23
+ already contains manual repairs.
24
+
25
+ ## Syntax
26
+
27
+ ```bash
28
+ npx wendkeep import --dry-run --json
29
+ npx wendkeep import --source claude|codex|all [--since <date>] [--limit <n>]
30
+ npx wendkeep import --from <claude-dir> --codex-from <codex-dir>
31
+ npx wendkeep import --stamp-ids | --rescan-decisions
32
+ ```
33
+
34
+ ## Options and exit codes
35
+
36
+ - `--source` bounds provider; `--since` and `--limit` bound volume.
37
+ - `--from`/`--codex-from` override discovered directories.
38
+ - `--dry-run` performs zero writes; `--json` emits an auditable report.
39
+ - `--stamp-ids` fills IDs in existing notes; `--rescan-decisions` reruns prose extraction.
40
+ - Exit `0` means a consistent scan/import; non-zero requires fixing source, parsing, or identity
41
+ before retrying.
42
+
43
+ ## Examples
44
+
45
+ ```bash
46
+ npx wendkeep import --source codex --since 2026-07-20 --limit 20 --dry-run --json
47
+ # inspect accepted/skipped/forks
48
+ npx wendkeep import --source codex --since 2026-07-20 --limit 20
49
+ ```
50
+
51
+ ## Expected result
52
+
53
+ Accepted sessions enter once per `session_id` with matching provider/transcript. Canonical
54
+ duplicates are skipped; forks/subagents retain origin relationships instead of copying inherited
55
+ history into another full independent conversation.
56
+
57
+ ## Common errors and diagnosis
58
+
59
+ - Cross-project contamination: stop and verify cwd, binding, and filters before cleaning notes.
60
+ - Ordinary fork imported as full session: inspect `forked_from_id` and source payload.
61
+ - Note without `session_id`: use `--stamp-ids` only after dry-run.
62
+ - Missing decisions in an imported note: prefer `--rescan-decisions` over duplicating the session.
63
+
64
+ ## Next steps
65
+
66
+ Return to [sessions and hooks](sessions-and-import.md), generate [costs](costs-and-observability.md),
67
+ and review [derived notes](notes-and-knowledge.md).
@@ -0,0 +1,85 @@
1
+ # Sessions, hooks, and import
2
+
3
+ **English** · [Português](../../pt-BR/commands/sessions-and-import.md)
4
+
5
+ ## Purpose
6
+
7
+ Understand how hooks capture live sessions, how activation/turn state preserves causality in the
8
+ registry, and when to use retroactive import.
9
+
10
+ ## When to use
11
+
12
+ Use `session` to inspect/focus a conversation and `import` to recover sessions from before setup or
13
+ outside the current registry.
14
+
15
+ ## When not to use
16
+
17
+ Do not invoke hooks manually without their expected JSON envelope. Do not run broad imports before
18
+ a preview when forks/subagents may duplicate history.
19
+
20
+ ## Prerequisites
21
+
22
+ Installed hooks for live capture; for imports, local access to Claude/Codex transcript directories
23
+ and a vault bound to the correct project.
24
+
25
+ ## Syntax
26
+
27
+ ```bash
28
+ npx wendkeep hook <name>
29
+ npx wendkeep session list
30
+ npx wendkeep session show <id>
31
+ npx wendkeep session use <id>
32
+ npx wendkeep import [options]
33
+ ```
34
+
35
+ ## Options and exit codes
36
+
37
+ - `wendkeep hook <name>` reads the agent payload from stdin; valid names are listed by `--help`.
38
+ - `SessionStart` opens an activation: an epoch that remains active across multiple `Stop` events;
39
+ only a new `SessionStart` supersedes the previous epoch.
40
+ - `UserPromptSubmit` advances the active activation's native turn. If it finds a legacy registry
41
+ with a closed epoch, it opens exactly one recovery activation; replaying the same prompt does
42
+ not open another one.
43
+ - On Codex, `session_id`, the native `turn_id`, and observed transcript order are enough to resolve
44
+ the turn. Hook payloads do not need invented `activation_id` or `turn_sequence` fields.
45
+ - `Stop` accepts only a transcript-proven turn from the compatible active activation. Duplicates
46
+ are no-ops; stale/superseded Stops neither publish memory nor overwrite a newer epoch's
47
+ checkpoint.
48
+ - `session list` reads `SESSION_REGISTRY`; `show` displays one session and `use` only changes human
49
+ focus in `CURRENT_SESSION.md`.
50
+ - `import --source all|claude|codex`, `--since`, `--limit`, `--from`, and `--codex-from` bound scope.
51
+ - `--dry-run`/`--json` support audit before writes; `--stamp-ids` and `--rescan-decisions` address
52
+ specific historical gaps.
53
+ - Exit `0` means consistent processing; non-zero reports invalid source/config/write instead of
54
+ presenting silent partial success.
55
+
56
+ ## Examples
57
+
58
+ ```bash
59
+ npx wendkeep session list
60
+ npx wendkeep session show 019abc-session-id
61
+ npx wendkeep import --source codex --since 2026-07-01 --dry-run --json
62
+ ```
63
+
64
+ ## Expected result
65
+
66
+ Each canonical session points to the matching provider, transcript, note file, and costs. The
67
+ registry keeps one `SessionStart` epoch per activation plus the latest native turn; multiple
68
+ `Stop` events may acknowledge turns in that epoch without closing it. Repeated imports of the
69
+ same `session_id` deduplicate; human focus does not close or re-identify live hooks.
70
+
71
+ ## Common errors and diagnosis
72
+
73
+ - Missing session: verify provider, transcript path, and registry before importing again.
74
+ - `Stop ambiguous`: the transcript did not prove the `turn_id`, or no compatible active activation
75
+ was found; the attempt remains observable but does not publish memory.
76
+ - A late Stop reports `stale_turn`/`superseded`: the newer epoch and checkpoint are preserved; do
77
+ not force the old payload to apply.
78
+ - Fork duplicates: bound source/date and inspect `forked_from_id`/`source.subagent`.
79
+ - Codex does not capture: approve hooks and start a new session after `sync`.
80
+ - Contaminated cost: validate `session_id → session_file → transcript_path → provider`.
81
+
82
+ ## Next steps
83
+
84
+ Read [retroactive import](retroactive-import.md), [costs and observability](costs-and-observability.md),
85
+ and [notes](notes-and-knowledge.md).
@@ -0,0 +1,86 @@
1
+ # Verify and independent verification
2
+
3
+ **English** · [Português](../../pt-BR/commands/verify.md)
4
+
5
+ ## Purpose
6
+
7
+ Run the sensors required by a change's tasks, persist fresh evidence, and assemble the
8
+ self-contained package consumed by the independent `wk-verify` pass.
9
+
10
+ ## When to use
11
+
12
+ Run after implementing tasks and again whenever tasks, specs, or tests change.
13
+
14
+ ## When not to use
15
+
16
+ Do not use it as a post-install health check or when no change exists. Run `wendkeep doctor` and
17
+ `wendkeep memory status --gate` instead.
18
+
19
+ ## Prerequisites
20
+
21
+ - An open change selected through `CURRENT_CHANGE.md` or `--change <slug>`.
22
+ - A placeholder-free `tarefas.md` with `[req:]` and `[sensor:]` tags on checkbox lines.
23
+ - Sensors declared in `wendkeep.sensors.json`.
24
+
25
+ ## Syntax
26
+
27
+ ```bash
28
+ npx wendkeep verify [--change <slug>] [--project <root>] [--vault <vault>]
29
+ npx wendkeep verify --deep [--change <slug>]
30
+ npx wendkeep change use <slug>
31
+ ```
32
+
33
+ ## Options and exit codes
34
+
35
+ - `--change <slug>` targets a change without changing the active pointer.
36
+ - `change use <slug>` persists focus for following commands.
37
+ - `--project <root>` selects the sensor cwd; `--vault` selects where proof is stored.
38
+ - **Exit 0:** all required sensors passed and evidence was written.
39
+ - **Exit 1:** the gate ran, but at least one critical sensor was red or a mutant survived.
40
+ - **Exit 2:** invalid usage/context, including `no change (--change or active)`, missing vault,
41
+ unknown change, or invalid `wendkeep.sensors.json`.
42
+
43
+ `verify --deep` writes `verificacao.json`; it does not replace the reviewer. The `wk-verify` skill
44
+ must be run by a different author and writes `verdict.json`.
45
+
46
+ ## Examples
47
+
48
+ Active change:
49
+
50
+ ```bash
51
+ npx wendkeep verify
52
+ npx wendkeep verify --deep
53
+ ```
54
+
55
+ Explicit change:
56
+
57
+ ```bash
58
+ npx wendkeep verify --change tenant-login
59
+ npx wendkeep verify --deep --change tenant-login
60
+ ```
61
+
62
+ Project with no open change:
63
+
64
+ ```bash
65
+ npx wendkeep doctor --vault .MyApp-vault
66
+ npx wendkeep memory status --gate --vault .MyApp-vault
67
+ ```
68
+
69
+ ## Expected result
70
+
71
+ `evidencia.json` contains sensor results and a seal binds proof to the current `tarefas.md` hash.
72
+ Deep mode packages requirements, tasks, and evidence for read-only review; the verdict covers every
73
+ `[req:]` before archive.
74
+
75
+ ## Common errors and diagnosis
76
+
77
+ - `no change`: this is exit 2 and a valid idle state; create/use a change or skip verify.
78
+ - Zero sensors: inspect same-line tags and `sensors list`.
79
+ - Red gate: fix the cause and rerun; never choose `archive --force` on your own.
80
+ - Missing/stale verdict: regenerate `--deep` and request a fresh independent pass.
81
+ - Surviving mutants: strengthen the discriminating test; after three rounds, review manually.
82
+
83
+ ## Next steps
84
+
85
+ Return to the [change lifecycle](changes-and-verification.md) for archive, or use
86
+ [maintenance](maintenance-and-diagnostics.md) when no change exists.
@@ -0,0 +1,80 @@
1
+ # Changes, specs, sensores e archive
2
+
3
+ **PT-BR** · [English](../../en/commands/changes-and-verification.md)
4
+
5
+ ## Objetivo
6
+
7
+ Conduzir uma mudança desde a intenção registrada até uma decisão arquivada, ligando requisitos,
8
+ tarefas, sensores, evidência e verdict no grafo do cofre.
9
+
10
+ ## Quando usar
11
+
12
+ Use para qualquer implementação não trivial ou correção que precise deixar prova auditável.
13
+
14
+ ## Quando não usar
15
+
16
+ Não crie uma change para consultar saúde, importar sessões ou executar manutenção read-only.
17
+
18
+ ## Pré-requisitos
19
+
20
+ Tenha o projeto inicializado, um vault saudável e `wendkeep.sensors.json` válido na raiz.
21
+
22
+ ## Sintaxe
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
+ ## Opções e códigos de saída
34
+
35
+ - `wendkeep change new <slug> [--simple]` cria proposta, design, tarefas e ponteiro ativo.
36
+ - `change use`, `list`, `show`, `status`, `diff`, `done` e `undone` inspecionam ou atualizam o
37
+ trabalho sem arquivar.
38
+ - `change continue <arquivada> <nova>` abre continuação sem herdar evidência antiga.
39
+ - `change bind <slug> --session <id>` liga uma sessão existente.
40
+ - `change relink [--apply]` e `change backlink [--apply]` reparam o grafo; dry-run é o padrão.
41
+ - `change abandon <slug>` descarta sem ADR; `archive --force` exige decisão humana explícita.
42
+ - `wendkeep spec list|show|effective|migrate|rebase` administra contratos vivos e deltas.
43
+ - `wendkeep sensors list|add` administra provas executáveis.
44
+ - Exit `0` indica comando concluído; os gates usam exit `1` para prova vermelha e exit `2` para
45
+ contexto/uso inválido.
46
+
47
+ ## Exemplos
48
+
49
+ ```bash
50
+ npx wendkeep change new login-tenant
51
+ npx wendkeep spec effective --change login-tenant
52
+ npx wendkeep change done 1.1 --change login-tenant
53
+ npx wendkeep verify --change login-tenant
54
+ npx wendkeep verify --deep --change login-tenant
55
+ npx wendkeep change archive login-tenant
56
+ ```
57
+
58
+ Para adicionar um sensor:
59
+
60
+ ```bash
61
+ npx wendkeep sensors add api-contracts "npm run test:contracts" --severity critical
62
+ ```
63
+
64
+ ## Resultado esperado
65
+
66
+ A change arquivada move seu delta para o spec vivo, preserva proposta/design/tarefas/evidência e
67
+ gera um ADR. O archive só passa com tarefas fechadas, sensores exigidos verdes e verdict atual.
68
+
69
+ ## Erros comuns e diagnóstico
70
+
71
+ - `no change`: selecione com `change use <slug>` ou informe `--change`.
72
+ - `spec_impact: pending`: defina `required` com delta ou `none` com justificativa real.
73
+ - Sensor não executado: mantenha `[sensor:id]` na mesma linha do checkbox da tarefa.
74
+ - Evidência stale: rode novamente `verify` e `verify --deep` depois de alterar tarefas/spec.
75
+ - Rebase em conflito: resolva o delta ou use `--accept-current` apenas quando isso for a decisão.
76
+
77
+ ## Próximos passos
78
+
79
+ Leia o guia profundo de [verify](verify.md) e a referência de
80
+ [manutenção e diagnóstico](maintenance-and-diagnostics.md).
@@ -0,0 +1,65 @@
1
+ # Custos e observabilidade
2
+
3
+ **PT-BR** · [English](../../en/commands/costs-and-observability.md)
4
+
5
+ ## Objetivo
6
+
7
+ Medir sessões, prompts, modelos e custo de IA, além de reconstruir históricos a partir dos
8
+ transcripts canônicos quando necessário.
9
+
10
+ ## Quando usar
11
+
12
+ Use `stats` para visão rápida, `cost` para análise e `cost rebuild` quando notas antigas não têm
13
+ custos confiáveis.
14
+
15
+ ## Quando não usar
16
+
17
+ Não aplique rebuild antes de validar provider e transcript de cada sessão. Não compare custos de
18
+ projetos com registries misturados.
19
+
20
+ ## Pré-requisitos
21
+
22
+ Registry consistente, tabela de preços completa e acesso aos transcripts das sessões reconstruídas.
23
+
24
+ ## Sintaxe
25
+
26
+ ```bash
27
+ npx wendkeep stats [--vault <cofre>] [--json]
28
+ npx wendkeep cost [--since <data>] [--top [N]] [--trend day|week|month] [--write] [--json]
29
+ npx wendkeep cost rebuild [--session <id|arquivo>] [--limit N] [--apply] [--json]
30
+ ```
31
+
32
+ ## Opções e códigos de saída
33
+
34
+ - `wendkeep stats` gera uma linha compartilhável ou JSON.
35
+ - `wendkeep cost` agrega total/modelo/dia; `--trend` inclui projeção e `--write` atualiza
36
+ `00-Custo.md`.
37
+ - `wendkeep cost rebuild` é dry-run por padrão; `--apply` grava notas e
38
+ `.brain/COST_REBUILD.json`.
39
+ - Exit `0` indica cálculo consistente; não zero indica registry, preço, transcript ou parsing
40
+ insuficiente.
41
+
42
+ ## Exemplos
43
+
44
+ ```bash
45
+ npx wendkeep stats --vault .MeuApp-vault
46
+ npx wendkeep cost --since 2026-07-01 --top 10 --trend week
47
+ npx wendkeep cost rebuild --session 019abc --json
48
+ ```
49
+
50
+ ## Resultado esperado
51
+
52
+ Totais preservam dimensões de input/output/cache/reasoning por modelo e período. Rebuild mostra a
53
+ prévia antes de alterar notas e deixa um relatório reproduzível quando aplicado.
54
+
55
+ ## Erros comuns e diagnóstico
56
+
57
+ - Modelo sem preço: atualize a tabela antes de aceitar o total.
58
+ - Custos de provider errado: valide a cadeia de identidade da sessão.
59
+ - Transcript ausente: não estime silenciosamente; mantenha a lacuna visível.
60
+ - Total duplicado por subagent/fork: confirme relação pai/subagent e deduplicação do registry.
61
+
62
+ ## Próximos passos
63
+
64
+ Veja [sessões e importação](sessions-and-import.md), [importação retroativa](retroactive-import.md)
65
+ e [manutenção](maintenance-and-diagnostics.md).