wrxn-reversa 1.5.0 → 1.6.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 (124) hide show
  1. package/agents/reversa/SKILL.md +30 -10
  2. package/agents/reversa/references/checkpoint-guide.md +7 -7
  3. package/agents/reversa/references/modo-de-execucao.md +89 -0
  4. package/agents/reversa/references/stack-record.md +81 -0
  5. package/agents/reversa/references/state-schema.md +7 -2
  6. package/agents/reversa/references/step-01-first-run.md +3 -3
  7. package/agents/reversa/references/step-02-resume.md +4 -2
  8. package/agents/reversa/references/step-03-specs-organization.md +1 -1
  9. package/agents/reversa/scripts/session-state.mjs +476 -0
  10. package/agents/reversa-add/SKILL.md +15 -1
  11. package/agents/reversa-arbiter/SKILL.md +12 -2
  12. package/agents/reversa-archaeologist/SKILL.md +5 -1
  13. package/agents/reversa-archaeologist/references/modules-schema.md +1 -1
  14. package/agents/reversa-architect/SKILL.md +13 -1
  15. package/agents/reversa-arquitetura-3d/SKILL.md +2 -2
  16. package/agents/reversa-audit/SKILL.md +10 -0
  17. package/agents/reversa-autonomous/SKILL.md +13 -9
  18. package/agents/reversa-brainstorm/SKILL.md +13 -2
  19. package/agents/reversa-challenger/SKILL.md +11 -1
  20. package/agents/reversa-clarify/SKILL.md +12 -0
  21. package/agents/reversa-code-express/SKILL.md +38 -22
  22. package/agents/reversa-coding/SKILL.md +30 -11
  23. package/agents/reversa-curator/SKILL.md +6 -3
  24. package/agents/reversa-data-master/SKILL.md +4 -0
  25. package/agents/reversa-debugger/SKILL.md +13 -2
  26. package/agents/reversa-debugger-debate/SKILL.md +12 -2
  27. package/agents/reversa-debugger-fix/SKILL.md +12 -2
  28. package/agents/reversa-debugger-graph/SKILL.md +10 -0
  29. package/agents/reversa-decouple/SKILL.md +12 -0
  30. package/agents/reversa-depth-inspection/SKILL.md +12 -0
  31. package/agents/reversa-design-system/SKILL.md +4 -0
  32. package/agents/reversa-designer/SKILL.md +7 -0
  33. package/agents/reversa-designer/references/templates/target_architecture.md +2 -0
  34. package/agents/reversa-detective/SKILL.md +5 -1
  35. package/agents/reversa-docs/SKILL.md +25 -16
  36. package/agents/reversa-docs/references/expected_sources.yaml +3 -4
  37. package/agents/reversa-docs-analyst/SKILL.md +13 -1
  38. package/agents/reversa-docs-mapper/SKILL.md +12 -0
  39. package/agents/reversa-docs-publisher/SKILL.md +20 -3
  40. package/agents/reversa-docs-storyteller/SKILL.md +21 -7
  41. package/{templates/documentation → agents/reversa-docs-storyteller}/scripts/convert_soul.py +3 -3
  42. package/agents/reversa-drafter/SKILL.md +15 -0
  43. package/agents/reversa-explorer/SKILL.md +11 -1
  44. package/agents/reversa-extract-soul/SKILL.md +10 -0
  45. package/agents/reversa-forward/SKILL.md +21 -7
  46. package/agents/reversa-forward-autonomous/SKILL.md +21 -8
  47. package/agents/reversa-framer/SKILL.md +11 -1
  48. package/agents/reversa-ideator/SKILL.md +10 -0
  49. package/agents/reversa-image-prompt-json/SKILL.md +1 -1
  50. package/agents/reversa-inspector/SKILL.md +4 -0
  51. package/agents/reversa-migrate/SKILL.md +33 -12
  52. package/agents/reversa-migrate/references/expected_legacy_artifacts.yaml +1 -1
  53. package/agents/reversa-migrate/references/templates/handoff.md +3 -2
  54. package/agents/reversa-migrate/references/templates/migration_brief.md +4 -6
  55. package/agents/reversa-modularize/SKILL.md +12 -0
  56. package/agents/reversa-n8n/SKILL.md +31 -21
  57. package/agents/reversa-new/SKILL.md +47 -24
  58. package/agents/reversa-optimize/SKILL.md +12 -0
  59. package/agents/reversa-paradigm-advisor/SKILL.md +4 -0
  60. package/agents/reversa-plan/SKILL.md +22 -3
  61. package/agents/reversa-pre-spec/SKILL.md +11 -1
  62. package/agents/reversa-pricing/SKILL.md +22 -18
  63. package/agents/reversa-pricing-advisor/SKILL.md +12 -2
  64. package/agents/reversa-pricing-estimate/SKILL.md +16 -6
  65. package/agents/reversa-pricing-estimate/references/example-estimate.json +1 -1
  66. package/agents/reversa-pricing-estimate/references/example-estimate.md +1 -1
  67. package/agents/reversa-pricing-product/SKILL.md +22 -6
  68. package/agents/reversa-pricing-profile/SKILL.md +23 -6
  69. package/agents/reversa-pricing-research/SKILL.md +19 -3
  70. package/agents/reversa-pricing-size/SKILL.md +21 -11
  71. package/agents/reversa-pricing-size/references/example-size.json +1 -1
  72. package/agents/reversa-pricing-size/references/sizing-formula.md +2 -2
  73. package/agents/reversa-principles/SKILL.md +5 -0
  74. package/agents/reversa-prune/SKILL.md +12 -0
  75. package/agents/reversa-quality/SKILL.md +10 -0
  76. package/agents/reversa-reconstructor/SKILL.md +36 -13
  77. package/agents/reversa-reconstructor/references/reconstruction-plan-migration-template.md +4 -1
  78. package/agents/reversa-reconstructor/references/reconstruction-plan-template.md +9 -2
  79. package/agents/reversa-refactor/SKILL.md +12 -1
  80. package/agents/reversa-requirements/SKILL.md +21 -4
  81. package/agents/reversa-researcher/SKILL.md +10 -0
  82. package/agents/reversa-restructure/SKILL.md +12 -0
  83. package/agents/reversa-resume/SKILL.md +12 -2
  84. package/agents/reversa-reviewer/SKILL.md +21 -30
  85. package/agents/reversa-router/SKILL.md +7 -3
  86. package/agents/reversa-scout/SKILL.md +4 -0
  87. package/agents/reversa-screen-translator/SKILL.md +20 -4
  88. package/agents/reversa-screen-translator/references/adapter-pairs.md +2 -1
  89. package/agents/reversa-screen-translator/references/templates/screen_modernization_decision.md +1 -0
  90. package/agents/reversa-selo-generativo/SKILL.md +3 -3
  91. package/agents/reversa-selo-generativo/references/PALETTE_BY_STYLE.md +1 -1
  92. package/agents/reversa-simplify/SKILL.md +12 -0
  93. package/agents/reversa-spec-sdd/SKILL.md +10 -0
  94. package/agents/reversa-standardize/SKILL.md +12 -0
  95. package/agents/reversa-strategist/SKILL.md +4 -0
  96. package/agents/reversa-sync/SKILL.md +10 -0
  97. package/agents/reversa-to-do/SKILL.md +11 -1
  98. package/agents/reversa-visor/SKILL.md +4 -0
  99. package/agents/reversa-writer/SKILL.md +12 -2
  100. package/lib/commands/add-engine.js +39 -34
  101. package/lib/commands/install.js +68 -58
  102. package/lib/commands/uninstall.js +95 -58
  103. package/lib/commands/update.js +45 -38
  104. package/lib/installer/checkout-guard.js +42 -0
  105. package/lib/installer/detector.js +2 -4
  106. package/lib/installer/reconcile.js +3 -2
  107. package/lib/installer/skill-layout.js +228 -0
  108. package/lib/installer/writer.js +20 -7
  109. package/package.json +2 -2
  110. package/templates/config.toml +1 -1
  111. package/templates/documentation/assets/css/style.css +1 -1
  112. package/templates/documentation/pages/glossario.html.tpl +1 -1
  113. package/templates/engines/card.md +2 -2
  114. package/templates/forward/body/quality-template.md +1 -1
  115. package/templates/forward/body/requirements-template.md +1 -0
  116. package/templates/forward/body/roadmap-template.md +3 -0
  117. package/templates/hooks/README.md +52 -0
  118. package/templates/hooks/reanchor-omp.mjs +36 -0
  119. package/templates/hooks/reanchor.mjs +92 -0
  120. package/templates/migration/artifacts/handoff.md +2 -1
  121. package/templates/migration/artifacts/migration_brief.md +4 -6
  122. package/templates/migration/expected_legacy_artifacts.yaml +1 -1
  123. package/templates/plan.md +0 -1
  124. package/templates/state.json +4 -1
@@ -10,6 +10,11 @@ metadata:
10
10
  role: orchestrator
11
11
  ---
12
12
 
13
+ ## Modo de execução
14
+
15
+ Use execução inline, uma etapa por vez, no fluxo `discovery`. Antes de agir ou retomar, leia `reversa/references/modo-de-execucao.md` no mesmo diretório de skills e aplique o contrato de posse. Inspeção pura não adquire posse; antes de iniciar trabalho ativo ou gravar, confirme a posse pelo helper.
16
+ Mostre a posição no início de cada resposta. Grave o progresso verificado e atualize a posição com `checkpoint` antes de aguardar. Libere a posse ao concluir ou mediante pausa com liberação explícita. A gravação de posse e checkpoint pelo helper é a única exceção adicional ao escopo de escrita abaixo. Delegue apenas com autorização explícita do usuário para aquele destino e escopo.
17
+
13
18
  Você é o Reversa, orquestrador central do framework Reversa.
14
19
 
15
20
  ## Ao ser ativado
@@ -35,13 +40,26 @@ Na opção 1, leia `reversa-sync/SKILL.md` (pasta irmã, no mesmo diretório de
35
40
  Execute as tarefas do plano **sequencialmente, uma por vez**:
36
41
 
37
42
  1. Informe o usuário: "Iniciando o **[Nome do Agente]** — [o que ele fará]."
38
- 2. Leia `reversa-[agente]/SKILL.md` correspondente (pasta irmã, no mesmo diretório de skills) na íntegra e execute as instruções no contexto atual.
39
- 3. Após conclusão: salve checkpoint em `.reversa/state.json` seguindo `references/checkpoint-guide.md` e marque a tarefa com ✅ em `.reversa/plan.md`.
43
+ 2. Resolva o nome literal do agente pela tabela. Leia o `SKILL.md` inteiro da pasta irmã e execute as instruções no contexto atual. Se faltar, informe o caminho esperado e pare. Para nome desconhecido, pergunte antes de avançar.
44
+ 3. Após conclusão, verifique os artefatos e salve o checkpoint com a linha exata da tarefa em `.reversa/state.json` pelo helper `write`. Depois marque a tarefa com ✅ em `.reversa/plan.md` pelo mesmo helper e atualize a posição com `checkpoint`.
40
45
  4. Apresente resumo breve do que foi gerado.
41
46
 
47
+ | Rótulo no plano | Pasta da skill |
48
+ |---|---|
49
+ | Scout | `reversa-scout` |
50
+ | Arqueólogo / Archaeologist | `reversa-archaeologist` |
51
+ | Detetive / Detective | `reversa-detective` |
52
+ | Arquiteto / Architect | `reversa-architect` |
53
+ | Redator / Writer | `reversa-writer` |
54
+ | Revisor / Reviewer | `reversa-reviewer` |
55
+ | Visor | `reversa-visor` |
56
+ | Data Master | `reversa-data-master` |
57
+ | Design System | `reversa-design-system` |
58
+ | Soul Extractor | `reversa-extract-soul` |
59
+
42
60
  **Ação especial após o Scout:**
43
61
 
44
- 1. Leia `.reversa/context/surface.json` e atualize a Fase 2 de `.reversa/plan.md` substituindo o item genérico por uma tarefa por módulo identificado. Exemplo:
62
+ 1. Leia `.reversa/context/surface.json` e atualize pelo helper `write` a Fase 2 de `.reversa/plan.md` substituindo o item genérico por uma tarefa por módulo identificado. Exemplo:
45
63
  ```
46
64
  - [ ] **Archaeologist** — Análise do módulo `auth`
47
65
  - [ ] **Archaeologist** — Análise do módulo `orders`
@@ -49,11 +67,15 @@ Execute as tarefas do plano **sequencialmente, uma por vez**:
49
67
  ```
50
68
 
51
69
  Se `ui_surface.present` for verdadeiro, inclua na Fase 2 uma tarefa de Arqueólogo para cada raiz de interface ainda não coberta por um módulo.
52
- Mova a tarefa opcional do Visor para antes do Arquiteto se já houver evidência de interface disponível.
70
+ Mova a tarefa opcional do Visor para antes do Arquiteto se já houver evidência de interface disponível. Grave essas mudanças em `.reversa/plan.md` pelo helper `write` antes da próxima etapa.
53
71
  Não aguarde screenshots ou gravações para continuar a extração.
54
72
 
73
+ No modo guiado, ofereça extrair a alma do projeto antes da escavação. Só com aceite explícito, insira a tarefa `**Soul Extractor**` antes da Fase 2 e execute-a pela tabela. Se o usuário recusar, preserve o plano e siga para o checkpoint abaixo. No modo autônomo, não apresente esta oferta.
74
+
55
75
  2. **🛑 Checkpoint bloqueante — não prossiga para o Archaeologist sem a resposta do usuário.**
56
76
 
77
+ Se o estado já tiver um `doc_level` válido e `doc_level_confirmed` não for `false`, conserve o nível e pule este menu. A ausência do campo de confirmação em estados antigos não invalida um nível válido. Para uma instalação nova (`doc_level_confirmed: false`), faça o menu mesmo se `doc_level` já contiver `essencial`.
78
+
57
79
  Apresente ao usuário um resumo do que o Scout encontrou e as três opções de nível de documentação. Use exatamente este formato:
58
80
 
59
81
  > "[Nome], o Scout concluiu o mapeamento. Aqui está o que encontrei:
@@ -77,13 +99,13 @@ Apresente ao usuário um resumo do que o Scout encontrou e as três opções de
77
99
 
78
100
  Aguarde a resposta do usuário. Se o usuário pressionar Enter sem digitar nada (resposta vazia ou apenas espaços), assuma `essencial` como valor. Aceite também o nome por extenso: `essencial`/`completo`/`detalhado`.
79
101
 
80
- Após receber a resposta, salve em `.reversa/state.json` → campo `doc_level`.
102
+ Após receber a resposta, grave `doc_level` e `doc_level_confirmed: true` em `.reversa/state.json` pelo helper `write`.
81
103
 
82
104
  **Em seguida, antes de ativar o Archaeologist, execute o passo de organização das specs.** Leia e siga `references/step-03-specs-organization.md`. Esse passo apresenta um menu com 6 opções de organização (módulo, caso de uso, endpoint, híbrida, por features, customizada), aceita a escolha do usuário e persiste em `.reversa/config.toml`, seção `[specs]`. Em re-execuções com a seção já decidida, o passo é pulado automaticamente.
83
105
 
84
106
  Só ative o Archaeologist depois que a decisão de organização estiver persistida.
85
107
 
86
- **Sobre paralelismo:** executar etapas do plano sequencialmente é orquestração normal — não requer autorização. O que **não** deve ocorrer sem pedido explícito do usuário: execução simultânea de múltiplos agentes, spawn de subagentes em background, ou desvio da sequência do plano aprovado.
108
+
87
109
 
88
110
  ## Verificação de versão
89
111
 
@@ -92,11 +114,9 @@ Compare `.reversa/version` com `https://registry.npmjs.org/<package_name>/latest
92
114
  Se houver versão mais nova, informe discretamente após a saudação:
93
115
  > "💡 Nova versão disponível. Execute `npx <package_name>@latest update` quando quiser atualizar."
94
116
 
95
- ## Estouro de contexto
117
+ ## Retomada após compactação
96
118
 
97
- Se o contexto estiver se esgotando:
98
- 1. Salve checkpoint em `.reversa/state.json` imediatamente
99
- 2. Diga: "[Nome], vou pausar aqui. Tudo está salvo. Digite `/reversa` em uma nova sessão para continuar."
119
+ Após resumo, compactação ou retomada, releia o checkpoint, os artefatos da etapa e o `SKILL.md` instalado em sua íntegra. Verifique a posse conforme `reversa/references/modo-de-execucao.md`. Nunca tente prever a perda de contexto.
100
120
 
101
121
  ## Checkpoint preventivo entre etapas
102
122
 
@@ -1,13 +1,13 @@
1
1
  # Guia de Checkpoints — .reversa/state.json
2
2
 
3
- O Reversa é o único agente que **escreve** no state.json. Os demais agentes apenas leem.
3
+ Somente a sessão dona persiste o estado pelo helper descrito em `modo-de-execucao.md`. Cada agente propõe seu progresso; o orquestrador verifica os artefatos e o persiste.
4
4
 
5
5
  ## Regras absolutas
6
6
 
7
7
  1. **Nunca remova campos existentes.** Apenas adicione ou atualize.
8
- 2. **Sempre leia o arquivo antes de escrever** — outro agente pode ter atualizado `checkpoints`.
8
+ 2. Use `inspect` mais `write` com o hash esperado e a geração do dono; não edite diretamente.
9
9
  3. **Salve após cada fase concluída**, não apenas no final.
10
- 4. **Em caso de estouro de contexto**, salve imediatamente antes de pausar.
10
+ 4. Salve antes de cada pausa humana. Em retomada ou após resumo, releia do disco a etapa e seu gate.
11
11
 
12
12
  ## O que salvar a cada fase
13
13
 
@@ -44,6 +44,8 @@ O Reversa é o único agente que **escreve** no state.json. Os demais agentes ap
44
44
  ```
45
45
 
46
46
  ### Ao marcar uma tarefa parcial do Archaeologist
47
+
48
+ Receba a proposta do agente após cada módulo. Verifique os arquivos, grave o checkpoint e só então passe ao próximo.
47
49
  ```json
48
50
  {
49
51
  "checkpoints": {
@@ -99,8 +101,6 @@ Ao mover de fase:
99
101
  }
100
102
  ```
101
103
 
102
- ## Mensagem de pausa por estouro de contexto
103
-
104
- Se o contexto estiver se esgotando, salve o checkpoint atual e diga:
104
+ ## Retomada
105
105
 
106
- > "[Nome], vou pausar aqui para preservar o contexto. Tudo está salvo em `.reversa/state.json`. Digite `reversa` em uma nova sessão para continuar de onde paramos."
106
+ Releia os checkpoints e os artefatos da fase antes de prosseguir. Use `release` apenas no término ou quando o usuário pedir para liberar o fluxo.
@@ -0,0 +1,89 @@
1
+ # Reversa execution and recovery
2
+
3
+ ## Enter or resume a phase
4
+
5
+ 1. Resolve `reversa/` from the parent directory of the current installed skill. Read this reference and locate its `scripts/session-state.mjs` there. If the artifact or Node.js 18.20.2+ is missing, report the expected path and stop before writing. Do not fall back to a different skill tree.
6
+ Read sibling skills from the discovered root, whether it contains copies or directory links. Use the physical `realpath` of the selected `SKILL.md` for `position.skill_path`.
7
+ 2. Identify this session independently. Use a verified native session ID with its harness (`claude-code`, `codex`, or `omp`). In OMP with the optional recovery extension, use the `reversa_session_identity` tool. In a launch that supplies `REVERSA_SESSION_ID`, use it only when the operator set it to the verified native ID. Without native identity, generate a UUID once and keep it in this session's resume context. Never copy `active.owner` from disk as proof of identity. If the identity was lost, use the transfer procedure.
8
+ 3. Inspect the checkout before starting or resuming. If there is another owner, show its position and wait. Never claim or write when only previewing a route. At the start of authorized work, use `claim` with the resolved flow and position. A standalone phase uses its current session as orchestrator; a phase read by an orchestrator keeps that same owner. A delegated phase has no owner authority.
9
+ 4. After compaction, a summary, a resume, or uncertain position, reread the position, workflow evidence, and full installed phase instructions. If the skill moved, resolve the same literal phase ID in the current installation. Stop if it is missing or the evidence disagrees about progress or approval. Do not rely on a past `CONTINUAR` as authorization.
10
+ 5. Run phases inline, one at a time, unless the user explicitly authorized the exact delegation. Treat autonomous mode as inline with its existing gate rules, not as permission to delegate. Before continuing after a tool batch or a return, confirm this session still owns the same generation. Stop on conflict.
11
+
12
+ | Flow ID | Evidence to reread before work |
13
+ |---|---|
14
+ | `discovery` | `.reversa/plan.md`, `phase`, `checkpoints`, and `redator_progress` |
15
+ | `forward` | `active-requirements.json`, physical `requirements.md`/`roadmap.md`/`actions.md`, addendum, and `forward-autonomous.json` for a queue |
16
+ | `new` | `newproject_progress` and current phase outputs; retain this flow during its internal express Forward sequence |
17
+ | `migration` | `<output_folder>/migration/.state.json` and the decision artifacts for the current gate |
18
+ | `docs` | `_reversa_docs/.state.json` and verified pages |
19
+ | `brainstorm` | `active-ideation.json` and the selected session's artifacts |
20
+ | `pricing` | The profile, size, estimate, and other artifacts in the phase's stage detection |
21
+ | `refactor` / `debugger` | The selected opportunity or bug record and its pending approval |
22
+ | `reconstruction` | `<output_folder>/reconstruction-plan.md` and the prerequisites of the current task |
23
+ | `n8n` | Registered source workflows and generated outputs |
24
+
25
+ When `active` is absent or null, use the evidence above without resetting it. If more than one flow can resume, ask which one. If an output exists without its checkpoint, apply the workflow's existing preserve/reuse rules; do not regenerate it by default.
26
+
27
+ Start each active response with `🧭 Reversa › <flow> › <agent> › <step> (i/n)`. Omit the count when unavailable. Append ` · aguardando sua resposta` at a user gate, or ` · delegado <id> → <target>` while delegated. A foreign session says `🧭 Reversa › fluxo ativo em outra sessão (<session>)`. A delegate says `🧭 Reversa › delegação <id> › <agent> › <step>`, not the owner's header. Do not include approval text, input details, or tokens in the header.
28
+
29
+ ## Run the control-state helper
30
+
31
+ Send one JSON request on standard input to `node "<installed-reversa>/scripts/session-state.mjs" "<absolute-checkout>"`. Use the actual installed path and project root. JSON requests have `op` at the top level. Use this command from the owner session; it is not a tool for a delegate.
32
+
33
+ ```json
34
+ {"op":"inspect","identity":{"harness":"omp","session":"<verified-id>"},"paths":[".reversa/state.json",".reversa/plan.md"]}
35
+ ```
36
+
37
+ | Operation | Additional fields |
38
+ |---|---|
39
+ | `inspect` | Optional `identity`, `paths`; returns current `active` and the SHA-256 of each requested file's exact bytes (`null` if absent) |
40
+ | `claim` | `identity`, `position`; returns `generation` for this owner, or refuses a foreign owner or different flow |
41
+ | `checkpoint` | `identity`, `generation`, `position`; update the step and refresh the heartbeat |
42
+ | `write` | `identity`, `generation`, `path`, `expectedHash`, `content`; compare against the inspected bytes under the lock |
43
+ | `release` | `identity`, `generation`; clears `active` only, without clearing work or approvals |
44
+ | `transfer` | `identity`, `expectedOwnerRevision`, `confirmed:true`, `priorSessionQuiescent:true`; see transfer rules below |
45
+
46
+ `position` is `{flow,orchestrator,agent,skill_path,step,step_index,step_total,status}`. The IDs are literal skill directory names. The path is the real installed absolute path of the phase `SKILL.md`. Use `null` for both counts if there is no fixed count. Use `ready`, `working`, or `waiting_user`; only the helper sets `waiting_delegate`. Take `generation` from a successful claim/transfer, or from an inspect that matches the separately authenticated session identity. Do not share the generation with delegates.
47
+
48
+ For managed JSON paths, pass an object as `content`. For `state.json`, send the changed top-level keys only (do not include `active`); preserve other subfields when updating a nested object. Other JSON control files take a complete object. Managed Markdown and TOML take a literal string. Use the inspected hash as `expectedHash`, or `null` when creating. Use `write` instead of direct `Write`/`Edit`, shell redirects, and tempfile renames for all managed paths:
49
+
50
+ - `.reversa/state.json`, `plan.md`, `config.toml`, `active-requirements.json`, `forward-autonomous.json`, and `active-ideation.json`.
51
+ - `_reversa_docs/.state.json` and `_reversa_docs/.config.json`.
52
+ - `<output_folder>/migration/.state.json` and `<output_folder>/reconstruction-plan.md`.
53
+ - Feature `actions.md` under the configured Forward root or the active feature.
54
+ - Bug `bug.md` and refactor opportunity and transformation status records.
55
+
56
+ Commit validated flow progress first. Then checkpoint the next position. For Discovery, record the exact completed plan line and evidence paths in the item checkpoint before marking the plan. If an interruption leaves an unchecked line, repair that mark only when the saved checkpoint identifies it and its files still support completion. Preserve gates and decisions in their existing files. Never write `.reversa/reversa-config.json` through this helper.
57
+
58
+ If the helper returns `busy`, stop mutation; it will not steal the lock. If it returns `stale_content`, reread the evidence and reconsider the planned update. If ownership or generation changed, report that conflict and stop. If the lock remains after a crash, the operator must first stop every Reversa writer and installer command for this checkout, verify the last saved checkpoint, and remove only `.reversa/session.lock` before retrying. Do not delete state or bypass the lock. This is a coordination protocol for P5 writers, not a sandbox for unrelated tools or older clients.
59
+
60
+ ## Transfer or end ownership
61
+
62
+ An ordinary pause at `CONTINUAR` retains ownership. On normal completion or an explicit pause-and-release, save progress and use `release`. For a P4 handoff to a different flow, verify the old checkpoint and delegate status, release it, then claim the authorized destination. Stop if another session claims between those operations. A route preview never transfers ownership.
63
+
64
+ For a foreign owner, display its identity, current step, and last heartbeat. Treat activity within 30 minutes as recent. A stale or missing heartbeat is not consent. Ask the user to confirm both the transfer and that the prior writer is stopped or at a safe boundary. Send `transfer` with the `ownerRevision` from inspect as `expectedOwnerRevision`; a new revision requires a new decision. Never interpret `CONTINUAR` as transfer approval.
65
+
66
+ An in-flight delegate blocks release and transfer. If dispatch ended without a valid return, verify cancellation or termination. The current owner can use `delegate-finish` with `stopped:true,result:null`. For an authorized transfer after confirmed termination, include `stoppedDelegationId` for the exact in-flight attempt. Do not retry an uncertain dispatch before reconciling it.
67
+
68
+ ## Delegate a phase only on request
69
+
70
+ 1. Confirm the exact target, requested capability, phase, authorized inputs, and write scope. Do not dispatch to a different harness by default. For read-only work use an enforceable read-only route. For write work require a sandbox that enforces the allowed paths, or an isolated checkout with disposable outputs and an enforced sandbox. If unavailable, report it and offer inline execution.
71
+ 2. Resolve known human decisions before dispatch. Keep new questions, destructive action, legacy edits, `[DÚVIDA]`, and P3 approvals with the owner. Permit only the input paths authorized for that delegate. The helper does not copy or share data.
72
+ 3. Use `delegate-start` with `identity`, `generation`, `target`, the target's absolute `checkout`, and `inputs`/`outputs` arrays of `{path,required}`. List files, not globs. Do not list the same path as input and output. For an edit, list the file as an output; the helper records its prior hash. The helper verifies required files in both checkouts before returning the dispatch ID. In a separate worktree, Git does not carry ignored specs; stop on missing paths. No implicit copy, merge, or import.
73
+ 4. Dispatch once with the complete brief. Use the returned phase and file lists; include only already authorized decisions. Native subagents get the full brief even if they inherit context. A named Codex review must use an authorized read-only route and return findings, not modify specs. For Orca use the installed guide for its version: load `orca skills get orchestration`, send the brief using its `--spec-file` route, and receive questions and `worker_done` through that protocol. Do not identify a pane by its title or silently replace it with a local subagent.
74
+
75
+ A dispatch brief is the header `REVERSA-DELEGAÇÃO v1` followed by one JSON object:
76
+
77
+ ```json
78
+ {"id":"D-<uuid>","flow":"discovery","agent":"reversa-writer","skill_path":"<installed absolute SKILL.md>","checkout":"<target root>","inputs":[{"path":"specs/model.md","required":true,"sourceHash":"<sha256>","targetHash":"<sha256>"}],"decisions":[],"outputs":[]}
79
+ ```
80
+
81
+ Delegate: read that skill in full; only write the allowed outputs. Never edit control state, choose for the user, or launch another phase. Stop at a decision not in the brief. Return the header `REVERSA-RETORNO v1` followed by one JSON object:
82
+
83
+ ```json
84
+ {"id":"D-<uuid>","status":"bloqueado","arquivos_escritos":[],"checkpoint_proposto":{},"perguntas_pendentes":[{"pergunta":"<pending question>","opcoes":["<option>"],"onde_parou":"<step>"}],"lacunas":[],"avisos":[]}
85
+ ```
86
+
87
+ Allowed result statuses: `concluido`, `parcial`, `bloqueado`. List actual writes as `{path,sha256}`. Do not mark a result complete with unanswered questions or missing required outputs.
88
+
89
+ Owner: call `delegate-finish` with `identity`, `generation`, `id`, `stopped:true` from the transport's terminal outcome, and the parsed JSON `result`. The helper checks inputs, hashes, write scope and the current attempt; it does not apply the proposed checkpoint. For a separate checkout, review each accepted artifact. Confirm the current project policy and approvals before `delegate-import` with `identity`, `generation`, `id` and `path`; it refuses a changed source or destination. Import before advancing. Ask the user any returned questions; `CONTINUAR` cannot answer them. Apply only verified partial progress or verified completion. Report a missing, stale, invalid, failed, or blocked result rather than repeating or marking the phase complete.
@@ -0,0 +1,81 @@
1
+ # Project stack record
2
+
3
+ ## Resolve the record and work target
4
+
5
+ Read `.reversa/state.json` in the checkout and resolve `output_folder`, defaulting to `_reversa_sdd`.
6
+ The project record is `<output_folder>/stack.md`.
7
+ Keep `Current stack` separate from `Migration target`.
8
+ For a greenfield project, use `Current stack` for the active design even before code exists.
9
+
10
+ Use the explicit work target first, then the target recorded for this work in its requirements, roadmap, or reconstruction plan.
11
+ If only one target is viable for this work, select that target.
12
+ If both are viable and none was selected, ask which one to use before proceeding with dependent work.
13
+ Record `Stack target: current` or `Stack target: migration` in the work artifact.
14
+ On resume or after compaction, reread the selected section and the work artifact from disk.
15
+ Do not fill missing decisions from the other target or infer permission from a prior `CONTINUAR`.
16
+
17
+ ## Maintain scoped decisions
18
+
19
+ Copy the record template below when a flow first writes the record.
20
+ Key each row by its layer and scope within the selected section.
21
+ Use separate scopes for components or modules that do not share a single implementation.
22
+ Leave unaffected rows and existing approvals intact.
23
+ If evidence conflicts with the applicable row, mark `[DÚVIDA]` and stop the dependent action instead of changing the row silently.
24
+ A missing record is not a reason to repeat discovery; first consult configured `dependencies.md`, manifests, and the nearest relevant code.
25
+ For greenfield, also read the affected specs and PRD constraints; `PRODUCT.md` `## Stack` is input evidence, not a second record or proof of approval.
26
+
27
+ | Status | Use |
28
+ |---|---|
29
+ | `detected` | Cite a source file, manifest entry, or other observed evidence. This status does not authorize changing it. |
30
+ | `approved` | Cite the recorded explicit choice or approval, including its scope and date. |
31
+ | `delegated` | Cite the explicit delegation and date. Record the selected value, rationale, and alternatives before dependent work. A blank value is not a selection. |
32
+ | `unknown` | No applicable decision or sufficient evidence yet. |
33
+ | `not applicable` | The layer does not apply to this scope. Record why. |
34
+
35
+ Use `—` for unavailable values, sources, dates, and alternatives.
36
+ Keep feature-only choices in the feature roadmap under `D-*`; do not promote them to the project record without a project-wide decision.
37
+ For form/state, cite the applicable P3 `IC-*` entry or record the observed persistence trigger and its source.
38
+ P3 defines the behavior, scope, and exceptions even when the stack changes.
39
+ The P5 owner writes decisions within the flow's existing write scope; delegates return proposed rows and evidence to that owner.
40
+
41
+ ## Before planning or implementing an affected action
42
+
43
+ 1. Read the applicable rows, the feature `roadmap.md`, and configured `dependencies.md` when present.
44
+ 2. In legacy work, inspect the nearest relevant implementation and apply the existing P3 fidelity rules.
45
+ 3. Reuse an established compatible technology or dependency when it meets the requirement.
46
+ 4. If a necessary choice has no reusable option, request an explicit decision or use an existing delegation that covers it.
47
+ 5. Before adding a dependency, record the alternatives checked and the approval or delegation reference in the roadmap decision.
48
+
49
+ For an unresolved choice, offer the owner three options: specify the value, approve a recommendation, or delegate the decision.
50
+ A blank answer, example, or autonomous mode is not permission.
51
+ In autonomous work, mark only the affected work as blocked, report the unresolved choice, and continue unrelated authorized work.
52
+ Report delegated choices separately from assumptions; do not treat delegation as authority to change behavior, spend money, or widen write scope.
53
+
54
+ ## Record template
55
+
56
+ ```markdown
57
+ # Project stack
58
+
59
+ ## Current stack
60
+
61
+ | Layer | Scope | Value | Status | Source | Rationale | Alternatives | Date |
62
+ |---|---|---|---|---|---|---|---|
63
+ | Language/runtime | Project | — | unknown | — | — | — | — |
64
+ | Backend | Project | — | unknown | — | — | — | — |
65
+ | Database | Project | — | unknown | — | — | — | — |
66
+ | Data access | Project | — | unknown | — | — | — | — |
67
+ | Frontend | Project | — | unknown | — | — | — | — |
68
+ | Component library | Project | — | unknown | — | — | — | — |
69
+ | Styling | Project | — | unknown | — | — | — | — |
70
+ | Form/state | Project | — | unknown | — | — | — | — |
71
+ | Testing | Project | — | unknown | — | — | — | — |
72
+ | Build/deploy | Project | — | unknown | — | — | — | — |
73
+
74
+ ## Migration target
75
+
76
+ | Layer | Scope | Value | Status | Source | Rationale | Alternatives | Date |
77
+ |---|---|---|---|---|---|---|---|
78
+ ```
79
+
80
+ Add messaging and observability rows when they apply.
81
+ Keep the migration section empty until migration work defines a target.
@@ -13,7 +13,9 @@ Este arquivo persiste o estado completo da análise entre sessões. O Reversa l
13
13
  "chat_language": "pt-br",
14
14
  "doc_language": "Português",
15
15
  "answer_mode": "chat",
16
- "doc_level": null,
16
+ "doc_level": "essencial",
17
+ "doc_level_confirmed": false,
18
+ "active": null,
17
19
  "output_folder": "_reversa_sdd",
18
20
  "phase": "reconhecimento",
19
21
  "completed": ["reconhecimento"],
@@ -59,8 +61,11 @@ Este arquivo persiste o estado completo da análise entre sessões. O Reversa l
59
61
  | `chat_language` | string | Idioma das interações (ex: pt-br, en-us) |
60
62
  | `doc_language` | string | Idioma das specs geradas (ex: Português, English) |
61
63
  | `answer_mode` | string | Como o usuário responde às lacunas: `chat` ou `file` |
62
- | `doc_level` | string \| null | Volume de documentação gerada: `essencial`, `completo` ou `detalhado`. Começa `null` — obrigatório preencher via escolha do usuário após o Scout. |
64
+ | `doc_level` | string \| null | Volume de documentação gerada: `essencial`, `completo` ou `detalhado`. Valor inicial: `essencial`. O valor inicial não confirma a escolha. |
63
65
  | `output_folder` | string | Pasta de saída das specs (padrão: `_reversa_sdd`) |
66
+ | `doc_level_confirmed` | booleano | `false` na instalação nova. Marque `true` só após a resposta ao menu. Estados antigos com nível válido sem este campo preservam o nível. |
67
+ | `active` | objeto \| null | Posição e posse da sessão. Ausente em instalações antigas. Veja o contrato em `modo-de-execucao.md`. |
68
+ | `redator_progress` | objeto opcional | Plano de arquivos e último progresso verificado do Writer, mantidos pelo orquestrador. |
64
69
  | `phase` | string \| null | Fase atual. `null` = não iniciado |
65
70
  | `completed` | string[] | Fases concluídas |
66
71
  | `pending` | string[] | Fases pendentes |
@@ -21,7 +21,7 @@ Se `user_name` estiver em branco, pergunte uma de cada vez:
21
21
  - "Em qual idioma as especificações devem ser geradas? (ex: Português, English)"
22
22
  - "Qual é o nome deste projeto?"
23
23
 
24
- Salve as respostas em `.reversa/state.json` nos campos `user_name`, `chat_language`, `doc_language` e `project`.
24
+ Grave as respostas pelo helper `write` em `.reversa/state.json`, nos campos `user_name`, `chat_language`, `doc_language` e `project`.
25
25
  Consulte `references/state-schema.md` para o schema completo.
26
26
 
27
27
  ## 4. Saudação personalizada
@@ -46,12 +46,12 @@ Verifique se `.reversa/plan.md` já existe:
46
46
  **Se o arquivo não existe** (instalação manual):
47
47
  1. Analise rapidamente a estrutura de pastas raiz (exclua: `node_modules`, `.git`, `.reversa`, `_reversa_sdd`, `dist`, `build`, `coverage`, `__pycache__`)
48
48
  2. Identifique os módulos e componentes principais
49
- 3. Crie `.reversa/plan.md` com as tarefas estruturadas por fase (use o template do plano padrão, adaptando a fase 2 com os módulos reais identificados)
49
+ 3. Crie `.reversa/plan.md` pelo helper `write` com as tarefas estruturadas por fase (use o template do plano padrão, adaptando a fase 2 com os módulos reais identificados)
50
50
  4. Apresente o plano e pergunte: "O plano está aprovado ou quer ajustar algo?"
51
51
 
52
52
  ## 6. Atualização do estado
53
53
 
54
- Após aprovação do plano, atualize `.reversa/state.json`:
54
+ Após aprovação do plano, grave em `.reversa/state.json` pelo helper `write`:
55
55
  - `phase`: `"reconhecimento"`
56
56
  - Salve qualquer informação coletada nesta etapa que ainda não esteja no arquivo
57
57
 
@@ -1,6 +1,8 @@
1
1
  # Passo 2 — Retomada de sessão
2
2
 
3
- ## 0. Verificação de migração em andamento
3
+ ## 0. Posse e verificação de migração em andamento
4
+
5
+ Antes de retomar, leia `modo-de-execucao.md` nesta pasta e inspecione a posse. Se não for desta sessão, mostre a posição e aplique a transferência explícita antes de agir. Se for desta sessão, releia o `SKILL.md` da etapa instalada e confira os artefatos antes de oferecer continuação.
4
6
 
5
7
  Antes de tudo, leia `.reversa/state.json` apenas para resolver `output_folder` (padrão `_reversa_sdd`).
6
8
 
@@ -82,7 +84,7 @@ Se `answer_mode` for `"chat"` (padrão):
82
84
 
83
85
  Pergunte apenas: "Continuamos de onde paramos? (CONTINUAR para seguir)"
84
86
 
85
- Após confirmação, retome a próxima tarefa pendente no plano (`.reversa/plan.md`).
87
+ Após confirmação, retome o primeiro item ainda pendente segundo o plano, o checkpoint e os artefatos existentes. Se o checkpoint verificável de um item concluído existir sem o marcador no plano, corrija o marcador pelo helper antes de continuar. Não suponha aceite por `CONTINUAR`.
86
88
 
87
89
  **🚫 Não ofereça `/clear` + `/reversa` neste momento.** O usuário acabou de retomar a sessão; pedir para limpar e reabrir agora é redundante. O prompt de pausa entre etapas (descrito em `SKILL.md`, seção "Checkpoint preventivo entre etapas") só vale **depois** que um agente concluir trabalho dentro desta sessão, nunca na própria saudação de retomada.
88
90
 
@@ -112,7 +112,7 @@ decided_at = "<timestamp ISO 8601 UTC, exemplo 2026-05-03T14:32:00Z>"
112
112
 
113
113
  Regras:
114
114
 
115
- - **Atomic write:** escreva em um arquivo temporário no mesmo diretório (`config.toml.tmp`) e faça rename atômico para `config.toml`. Falha durante a escrita não pode deixar `config.toml` corrompido.
115
+ - **Persistência:** use `write` com o hash atual de `.reversa/config.toml` e o TOML preservado fora de `[specs]`.
116
116
  - **scout_suggestion é imutável** (RF-14): se a seção `[specs]` já existia mas estava com `granularity` vazia e `scout_suggestion` preenchida, preserve `scout_suggestion`. Em primeira execução, copie o valor atual de `organization_suggestion.granularity` do `surface.json`.
117
117
  - **Non-destructive:** preserve qualquer chave/seção que você não esteja explicitamente atualizando. Não toque em `[project]`, `[user]`, `[output]`, `[agents]`, `[engines]`, `[analysis]` ou outras seções.
118
118
  - **Não mexa em `.reversa/config.user.toml`.** Esse arquivo pertence ao usuário.