wendkeep 0.72.0 → 0.73.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +66 -3
  2. package/README.en.md +28 -11
  3. package/README.md +28 -11
  4. package/docs/en/commands/changes-and-verification.md +10 -5
  5. package/docs/en/commands/maintenance-and-diagnostics.md +17 -9
  6. package/docs/en/commands/observer.md +18 -12
  7. package/docs/en/commands/operating-profiles.md +28 -3
  8. package/docs/en/commands/sessions-and-import.md +4 -4
  9. package/docs/pt-BR/commands/changes-and-verification.md +10 -5
  10. package/docs/pt-BR/commands/maintenance-and-diagnostics.md +12 -5
  11. package/docs/pt-BR/commands/observer.md +18 -12
  12. package/docs/pt-BR/commands/operating-profiles.md +28 -3
  13. package/docs/pt-BR/commands/sessions-and-import.md +4 -4
  14. package/hooks/brain-inject.mjs +6 -6
  15. package/hooks/change-context.mjs +11 -0
  16. package/hooks/change-core.mjs +53 -21
  17. package/hooks/change-warn.mjs +2 -0
  18. package/hooks/harness-doctor.mjs +13 -5
  19. package/hooks/understand-inject.mjs +1 -1
  20. package/hooks/vault-health.mjs +2 -2
  21. package/package.json +5 -4
  22. package/packages/cli/src/index.mjs +12 -2
  23. package/packages/integrations/src/host-hooks.mjs +1 -1
  24. package/packages/vault/src/memory-store.mjs +17 -4
  25. package/src/change.mjs +10 -4
  26. package/src/delivery.mjs +303 -0
  27. package/src/doctor.mjs +47 -10
  28. package/src/init.mjs +2 -2
  29. package/src/observer-auth.mjs +10 -0
  30. package/src/observer-memory-publish.mjs +13 -8
  31. package/src/observer-privacy.mjs +23 -0
  32. package/src/observer-publish.mjs +10 -7
  33. package/src/observer-server.mjs +51 -0
  34. package/src/observer-sql-publish.mjs +72 -31
  35. package/src/observer-sql-store.mjs +33 -2
  36. package/src/observer.mjs +10 -3
  37. package/src/release-changelog.mjs +1 -1
  38. package/src/release-provenance.mjs +115 -0
  39. package/src/skills-seed.mjs +25 -9
  40. package/src/sync-defs.mjs +5 -2
  41. package/src/sync.mjs +2 -2
  42. package/src/taxonomy.mjs +1 -1
  43. package/src/vault-readme.mjs +2 -2
  44. package/src/work-kind.mjs +62 -0
@@ -27,10 +27,15 @@ pode persistir \`profile use OFF\` explicitamente.
27
27
 
28
28
  - **FLOW:** ajuste local, reversível e de escopo fechado, sem contrato/spec, segurança,
29
29
  dependência, CI/release ou policy.
30
- - **GUIDE:** mudança compacta de comportamento que precisa de change/spec, sem revisão formal.
30
+ - **GUIDE:** implementação compacta com change, sem spec/design/ADR automáticos quando contract_impact é none.
31
31
  - **GOVERN:** escolha conservadora em caso de dúvida ou risco e para superfícies sensíveis.
32
32
  - **ASSURE:** GOVERN quando confirmação explícita e handoff fazem parte do contrato.
33
33
 
34
+ Classifique também o work kind: inspection, maintenance, implementation, delivery ou recovery.
35
+ Risco operacional e impacto de contrato são independentes. Merge, push, tag e publish de código
36
+ já aprovado usam delivery + ASSURE sem criar outra change; registre com delivery start e conclua
37
+ com delivery finish para gerar receipt.
38
+
34
39
  O harness da LLM faz essa classificação semântica; o Wend Runtime valida e aplica a lease.
35
40
  Se não houver uma sessão causal identificada ou o comando falhar, não fabrique estado: use o
36
41
  perfil efetivo já injetado e trate \`GOVERN\` como fallback conservador quando ele for o padrão.
@@ -39,6 +44,7 @@ perfil efetivo já injetado e trate \`GOVERN\` como fallback conservador quando
39
44
  Antes de editar, leia o **perfil efetivo** injetado pelo WendKeep e siga somente sua rota:
40
45
  - \`OFF\`: não imponha processo Wend; a governança pertence ao **harness nativo da LLM**.
41
46
  - \`FLOW\`: inicie o microcontrato com \`wendkeep flow start\` antes de editar os paths permitidos.
47
+ - \`delivery\`: inicie \`wendkeep delivery start\` antes das operações autorizadas; não crie change.
42
48
  - \`GUIDE\`, \`GOVERN\` ou \`ASSURE\`: não edite código antes de Propose / \`wendkeep change new\`.
43
49
  Este gate nunca transforma \`OFF\` ou \`FLOW\` silenciosamente em \`GOVERN\`.
44
50
  </HARD-GATE>
@@ -47,14 +53,16 @@ Este gate nunca transforma \`OFF\` ou \`FLOW\` silenciosamente em \`GOVERN\`.
47
53
 
48
54
  - **OFF — LLM nativa:** Wend Runtime desligado; esta skill devolve a execução ao harness nativo.
49
55
  - **FLOW — E → V:** \`flow start\` → implementar com wk-tdd → \`flow finish\`; sem change/ADR/verdict.
50
- - **GUIDE — P → E → V:** change compacta, sem revisão formal obrigatória.
56
+ - **GUIDE — P → E → V:** change new --guide, sem design/spec/ADR automáticos quando não há impacto de contrato.
51
57
  - **GOVERN — P → R → E → V:** loop a2 atual, com design/revisão; é o padrão conservador.
52
58
  - **ASSURE — P → R → E → V → C:** GOVERN acrescido de confirmação e handoff explícitos.
53
59
 
54
60
  ## Passos para GUIDE, GOVERN e ASSURE
55
61
 
56
62
  1. **Explore** — entenda o problema antes de propor. Leia o código/contexto relevante.
57
- 2. **Propose** — \`wendkeep change new <slug>\`. Isso cria \`08-Mudanças/<slug>/\` com:
63
+ 2. **Propose** — GUIDE usa \`wendkeep change new <slug> --guide\`; GOVERN/ASSURE usam
64
+ \`wendkeep change new <slug>\`. O GUIDE compacto exige objetivo, critérios de aceite, áreas
65
+ afetadas, testes e resultado. GOVERN/ASSURE criam \`08-Mudanças/<slug>/\` com:
58
66
  - \`proposta.md\` — *por quê* e *o que muda* (o WHAT).
59
67
  - \`design.md\` — a abordagem técnica.
60
68
  - \`tarefas.md\` — a lista de tarefas \`- [ ] N.N descrição\`.
@@ -83,7 +91,7 @@ Este gate nunca transforma \`OFF\` ou \`FLOW\` silenciosamente em \`GOVERN\`.
83
91
  \`[req:]\`) recebe verdict automático — pula este passe.
84
92
  6. **Archive** — \`wendkeep change archive <slug>\`. O *gate* exige sensores verdes **E**
85
93
  \`verdict.json\` cobrindo os \`[req:]\`. Passando, promove os deltas pro \`07-Specs\`,
86
- move a change pro \`_arquivo\` e gera um ADR em \`04-Decisões/\`.
94
+ move a change pro \`_arquivo\`; GUIDE com contract_impact none não gera ADR automático.
87
95
 
88
96
  ## Regras
89
97
 
@@ -296,10 +304,15 @@ persist it explicitly through \`profile use OFF\`.
296
304
 
297
305
  - **FLOW:** a local, reversible, bounded adjustment with no contract/spec, security, dependency,
298
306
  CI/release, or policy impact.
299
- - **GUIDE:** a compact behavior change that needs a change/spec but no formal review.
307
+ - **GUIDE:** compact implementation with a change, but no automatic spec/design/ADR when contract impact is none.
300
308
  - **GOVERN:** the conservative choice when uncertain or risky, and for sensitive surfaces.
301
309
  - **ASSURE:** GOVERN when explicit confirmation and handoff are part of the contract.
302
310
 
311
+ Also classify work kind as inspection, maintenance, implementation, delivery, or recovery.
312
+ Operational risk and contract impact are independent. Merge, push, tag, and publish for
313
+ already-approved code use delivery + ASSURE without another change; use delivery start and
314
+ delivery finish to produce a receipt.
315
+
303
316
  The LLM harness owns semantic classification; Wend Runtime validates and applies the lease. If
304
317
  there is no causally identified session or the command fails, do not fabricate state: use the
305
318
  already injected effective profile, with \`GOVERN\` as the conservative configured fallback.
@@ -308,6 +321,7 @@ already injected effective profile, with \`GOVERN\` as the conservative configur
308
321
  Before editing, read the injected **effective profile** and follow only its route:
309
322
  - \`OFF\`: impose no Wend process; governance belongs to the **native LLM harness**.
310
323
  - \`FLOW\`: start the microcontract with \`wendkeep flow start\` before editing allowed paths.
324
+ - \`delivery\`: run \`wendkeep delivery start\` before authorized operations; do not create a change.
311
325
  - \`GUIDE\`, \`GOVERN\`, or \`ASSURE\`: do not edit code before Propose / \`wendkeep change new\`.
312
326
  This gate never silently turns \`OFF\` or \`FLOW\` into \`GOVERN\`.
313
327
  </HARD-GATE>
@@ -316,15 +330,16 @@ This gate never silently turns \`OFF\` or \`FLOW\` into \`GOVERN\`.
316
330
 
317
331
  - **OFF — native LLM:** Wend Runtime is disabled; this skill returns execution to the native harness.
318
332
  - **FLOW — E → V:** \`flow start\` → implement with wk-tdd → \`flow finish\`; no change/ADR/verdict.
319
- - **GUIDE — P → E → V:** a compact change with no mandatory formal review.
333
+ - **GUIDE — P → E → V:** change new --guide, with no automatic design/spec/ADR when contract impact is none.
320
334
  - **GOVERN — P → R → E → V:** the current a2 loop with design/review; the conservative default.
321
335
  - **ASSURE — P → R → E → V → C:** GOVERN plus explicit confirmation and handoff.
322
336
 
323
337
  ## Steps for GUIDE, GOVERN, and ASSURE
324
338
 
325
339
  1. **Explore** — understand the problem before proposing.
326
- 2. **Propose** — \`wendkeep change new <slug>\` scaffolds \`08-Changes/<slug>/\`
327
- (proposta/design/tarefas + a \`specs/\` delta). The change becomes *current* through global
340
+ 2. **Propose** — GUIDE uses \`wendkeep change new <slug> --guide\`; GOVERN/ASSURE use
341
+ \`wendkeep change new <slug>\`. Compact GUIDE requires objective, acceptance criteria,
342
+ affected areas, tests, and result. The change becomes *current* through global
328
343
  \`.brain/CURRENT_CHANGE.md\`. Multiple changes may stay open; hooks and \`change list/status\`
329
344
  show every pending task, while commands without \`--change\` use only the current change.
330
345
  Before implementation, resolve \`spec_impact\`: \`required\` needs the capability listed in
@@ -341,7 +356,8 @@ This gate never silently turns \`OFF\` or \`FLOW\` into \`GOVERN\`.
341
356
  5. **Verify deep** — the **wk-verify** skill (fresh, author≠verifier) writes \`verdict.json\`.
342
357
  A trivial change (no \`[req:]\`) gets an auto verdict.
343
358
  6. **Archive** — \`wendkeep change archive <slug>\`. The gate needs green sensors AND a
344
- verdict AND no open tasks. It promotes the delta into \`07-Specs\` and mints an ADR.
359
+ verdict AND no open tasks. It promotes the delta into \`07-Specs\`; compact GUIDE does not
360
+ mint an automatic ADR.
345
361
 
346
362
  ## Rules
347
363
  - Multiple changes may stay open. \`CURRENT_CHANGE.md\` marks one current change without hiding
package/src/sync-defs.mjs CHANGED
@@ -66,7 +66,7 @@ The persistent profile is selected explicitly; missing or invalid configuration
66
66
 
67
67
  Before every implementation, the native LLM harness **MUST run the routing gate**:
68
68
  1. Inspect \`wendkeep profile status\`.
69
- 2. Classify the request and choose FLOW, GUIDE, GOVERN, or ASSURE from its scope and risk.
69
+ 2. Classify work kind, contract impact, and operation risk independently; then choose the profile.
70
70
  3. Register the choice with
71
71
  \`wendkeep profile route <FLOW|GUIDE|GOVERN|ASSURE> --session <id> --reason <text>\`.
72
72
  4. Re-check \`wendkeep profile status\` and follow the effective profile before editing.
@@ -82,12 +82,15 @@ fallback when configuration is missing or invalid. The lease expires when the re
82
82
  Route work by the effective profile:
83
83
  - **OFF** — Wend Runtime is disabled and governance belongs to the native LLM harness; Keep Core stays active.
84
84
  - **FLOW** — Execute → Validate through \`wendkeep flow start/finish\`, without creating a change.
85
- - **GUIDE** — Plan → Execute → Validate through a compact change.
85
+ - **GUIDE** — Plan → Execute → Validate through \`change new --guide\`; no automatic spec/design/ADR for contract_impact none.
86
86
  - **GOVERN** — the default a2 loop: \`wendkeep change new <slug>\` → review → implement tasks test-first
87
87
  (tag proof \`[sensor:id]\` and requirement \`[req:ID]\`) → \`wendkeep verify\` →
88
88
  \`wendkeep verify --deep\` + independent read-only verdict → \`wendkeep change archive\`.
89
89
  - **ASSURE** — GOVERN plus explicit confirmation and handoff.
90
90
 
91
+ Delivery of already-approved behavior uses \`wendkeep delivery start/status/finish/abandon\` with
92
+ ASSURE authorization and an append-only receipt. It does not create a new change, spec, or ADR.
93
+
91
94
  Inspect with \`wendkeep profile status\` / \`wendkeep change status\` /
92
95
  \`spec effective --change <slug>\` / \`sensors list\`. Author specs only in
93
96
  \`08-Mudanças/<slug>/specs/\`; \`07-Specs\` is generated and must not be edited directly.
package/src/sync.mjs CHANGED
@@ -81,11 +81,11 @@ export async function runSync(argv) {
81
81
  // código é propagado sem ser tratado como falha da cadeia.
82
82
  step(3, 'doctor');
83
83
  const { runDoctor } = await import('./doctor.mjs');
84
- const doctorCode = runDoctor(['--vault', vaultBase, '--project', projectPath]);
84
+ const doctorCode = runDoctor(['--vault', vaultBase, '--project', projectPath, '--scope', 'core']);
85
85
 
86
86
  // Nunca afirmar "tudo em dia": o doctor sai 0 mesmo tendo listado órfãos, seções
87
87
  // desatualizadas ou modelos sem preço — essas checagens não são fatais. Uma linha final
88
88
  // otimista contradiria o relatório logo acima dela.
89
- process.stdout.write(`\nwendkeep sync: 3 passo(s) concluído(s)${doctorCode ? ' — doctor reportou erros' : ' — veja o relatório do doctor acima'}\n`);
89
+ process.stdout.write(`\nwendkeep sync: ${doctorCode ? 'falhouKeep Core comprometido' : 'concluídoKeep Core saudável'}\n`);
90
90
  return doctorCode;
91
91
  }
package/src/taxonomy.mjs CHANGED
@@ -131,7 +131,7 @@ export const RUNNABLE_HOOKS = [
131
131
  // the MOST agent-agnostic mechanism it supports; the Claude Code plugin entry
132
132
  // (extraKnownMarketplaces + enabledPlugins) is an additive bonus, never the base.
133
133
  // - mcp: .mcp.json server entry (works on any MCP-capable agent)
134
- // - wendkeepHook: a wendkeep-authored hook (runs via `npx wendkeep hook`, any agent)
134
+ // - wendkeepHook: a wendkeep-authored hook (runs via `npx --no-install wendkeep hook`, any agent)
135
135
  // - installer: cross-agent install script (used on non-Claude agents)
136
136
  // marketplace/plugin shapes are verified against a real ~/.claude/settings.json.
137
137
  export const COMPANIONS = [
@@ -52,7 +52,7 @@ export function renderVaultReadme({ projectName, vaultPath, withMcp = true, loca
52
52
  const mcpIntro = withMcp ? ', and read/written by the **MCPVault** MCP server' : '';
53
53
  const access = [`- **Obsidian:** open this folder with "Open folder as vault" → \`${vaultPath}\``];
54
54
  if (withMcp) access.push('- **Agent (MCP):** the `wendkeep-vault` server (MCPVault) points at this vault (set in `.mcp.json`), giving the agent read/write on the notes.');
55
- access.push('- **Hooks:** Codex and Claude Code call `npx wendkeep hook <name>`; the vault is discovered from the project-local `.wendkeep.json` binding and checked against `.brain/PROJECT.json`.');
55
+ access.push('- **Hooks:** Codex and Claude Code call `npx --no-install wendkeep hook <name>`; the vault is discovered from the project-local `.wendkeep.json` binding and checked against `.brain/PROJECT.json`.');
56
56
  return `# Obsidian vault — ${name}
57
57
 
58
58
  > Knowledge base of **${name}**, captured automatically by wendkeep from AI coding-agent
@@ -84,7 +84,7 @@ ${access.join('\n')}
84
84
  const mcpIntro = withMcp ? ', e lida/escrita pelo MCP server **MCPVault**' : '';
85
85
  const access = [`- **Obsidian:** abra esta pasta com "Open folder as vault" → \`${vaultPath}\``];
86
86
  if (withMcp) access.push('- **Agente (MCP):** o servidor `wendkeep-vault` (MCPVault) é apontado para este vault pelo `wendkeep init` (em `.mcp.json`), dando ao agente leitura/escrita das notas.');
87
- access.push('- **Hooks:** Codex e Claude Code chamam `npx wendkeep hook <name>`; o vault é descoberto pelo vínculo local `.wendkeep.json` e validado contra `.brain/PROJECT.json`.');
87
+ access.push('- **Hooks:** Codex e Claude Code chamam `npx --no-install wendkeep hook <name>`; o vault é descoberto pelo vínculo local `.wendkeep.json` e validado contra `.brain/PROJECT.json`.');
88
88
  return `# Vault Obsidian — ${name}
89
89
 
90
90
  > Base de conhecimento de **${name}**, capturada automaticamente pelo wendkeep a
@@ -0,0 +1,62 @@
1
+ export const WORK_KINDS = Object.freeze([
2
+ 'inspection',
3
+ 'maintenance',
4
+ 'implementation',
5
+ 'delivery',
6
+ 'recovery',
7
+ ]);
8
+
9
+ export const CONTRACT_IMPACTS = Object.freeze(['none', 'internal', 'public']);
10
+
11
+ function normalize(value, values, code, label) {
12
+ const normalized = String(value || '').trim().toLowerCase();
13
+ if (values.includes(normalized)) return normalized;
14
+ const error = new Error(`${label} inválido: ${String(value || '(vazio)')}. Use ${values.join(', ')}.`);
15
+ error.code = code;
16
+ throw error;
17
+ }
18
+
19
+ export function normalizeWorkKind(value) {
20
+ return normalize(value, WORK_KINDS, 'WENDKEEP_WORK_KIND_INVALID', 'work kind');
21
+ }
22
+
23
+ export function normalizeContractImpact(value) {
24
+ return normalize(value, CONTRACT_IMPACTS, 'WENDKEEP_CONTRACT_IMPACT_INVALID', 'contract impact');
25
+ }
26
+
27
+ export function createWorkRoute({
28
+ workKind,
29
+ profile = '',
30
+ contractImpact = 'none',
31
+ operationRisk = [],
32
+ sourceChange = '',
33
+ sourceCommit = '',
34
+ } = {}) {
35
+ const kind = normalizeWorkKind(workKind);
36
+ const impact = normalizeContractImpact(contractImpact);
37
+ const risks = [...new Set((Array.isArray(operationRisk) ? operationRisk : [operationRisk])
38
+ .map((item) => String(item || '').trim()).filter(Boolean))];
39
+ if (kind === 'delivery' && impact !== 'none') {
40
+ const error = new Error('delivery só aceita contract_impact none; alteração de contrato exige implementation.');
41
+ error.code = 'WENDKEEP_DELIVERY_CONTRACT_IMPACT';
42
+ throw error;
43
+ }
44
+ return {
45
+ work_kind: kind,
46
+ profile: String(profile || (kind === 'delivery' ? 'ASSURE' : '')).trim().toUpperCase(),
47
+ contract_impact: impact,
48
+ operation_risk: risks,
49
+ ...(sourceChange ? { source_change: String(sourceChange) } : {}),
50
+ ...(sourceCommit ? { source_commit: String(sourceCommit) } : {}),
51
+ };
52
+ }
53
+
54
+ export function classifyWorkRequest(prompt) {
55
+ const text = String(prompt || '').toLowerCase();
56
+ if (/acompanhar|acompanhe|status|actions|diff|inspecion/.test(text)) return 'inspection';
57
+ if (/token\s+(?:expir|venc)|credencial.*(?:expir|venc)/.test(text)) return 'recovery';
58
+ if (/corrig|corrij|alter|implementar|package\.json.*errad|workflow.*(?:errad|falh)/.test(text)) return 'implementation';
59
+ if (/merge|push|public|publish|tag|release/.test(text)) return 'delivery';
60
+ if (/texto|formata|manuten/.test(text)) return 'maintenance';
61
+ return 'implementation';
62
+ }