@orkastery/cli 0.6.1 → 0.6.2

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 (69) hide show
  1. package/adapters/claude-code/agents/ork-check.md +1 -1
  2. package/adapters/claude-code/agents/ork-go.md +1 -1
  3. package/adapters/claude-code/agents/ork-goal.md +1 -1
  4. package/adapters/claude-code/agents/ork-master.md +1 -1
  5. package/adapters/claude-code/agents/ork-plan.md +1 -1
  6. package/adapters/claude-code/agents/ork-ship.md +1 -1
  7. package/adapters/claude-code/commands/ork.md +1 -1
  8. package/adapters/claude-code/mods/ork-torre/hooks/frases.ts +2 -0
  9. package/adapters/codex/skills/ork/SKILL.md +1 -1
  10. package/adapters/openclaw/openclaw.plugin.json +1 -1
  11. package/adapters/openclaw/package.json +1 -1
  12. package/assets/adapters-en/claude-code/agents/ork-check.md +1 -1
  13. package/assets/adapters-en/claude-code/agents/ork-go.md +1 -1
  14. package/assets/adapters-en/claude-code/agents/ork-goal.md +1 -1
  15. package/assets/adapters-en/claude-code/agents/ork-master.md +1 -1
  16. package/assets/adapters-en/claude-code/agents/ork-plan.md +1 -1
  17. package/assets/adapters-en/claude-code/agents/ork-ship.md +1 -1
  18. package/assets/adapters-en/claude-code/commands/ork.md +1 -1
  19. package/assets/adapters-en/codex/skills/ork/SKILL.md +1 -1
  20. package/assets/orkmind_fixture.py +4 -1
  21. package/assets/skills-en/core/orkastery-bootstrap/SKILL.md +1 -1
  22. package/assets/skills-en/phases/check-quality/SKILL.md +1 -1
  23. package/assets/skills-en/phases/go-implementation/SKILL.md +1 -1
  24. package/dist/adapters/claude-bg.js +3 -1
  25. package/dist/adapters/grok-mcp-servidor.js +22 -12
  26. package/dist/adapters/grok.js +1 -1
  27. package/dist/changelog-check.js +217 -0
  28. package/dist/check-agil.js +241 -5
  29. package/dist/ci.js +3 -2
  30. package/dist/claim-lint.js +29 -0
  31. package/dist/claims.js +4 -0
  32. package/dist/docs.js +7 -0
  33. package/dist/fila-pesada.js +121 -11
  34. package/dist/hitl-classificacao.js +1 -0
  35. package/dist/index.js +43 -25
  36. package/dist/intelligence-graph-cli.js +27 -9
  37. package/dist/locale-claims.js +16 -2
  38. package/dist/locale-grafo.js +56 -1
  39. package/dist/locale-maestro.js +38 -0
  40. package/dist/locale-network.js +8 -6
  41. package/dist/locale-onboarding.js +14 -0
  42. package/dist/locale-preflight.js +80 -0
  43. package/dist/locale-projetos.js +6 -0
  44. package/dist/locale-prompts.js +8 -8
  45. package/dist/locale-pulse.js +4 -0
  46. package/dist/locale-retry.js +16 -0
  47. package/dist/locale-security-scan.js +35 -1
  48. package/dist/locale-verify.js +15 -0
  49. package/dist/locale.js +24 -7
  50. package/dist/maestro-cli.js +12 -17
  51. package/dist/mcp-install.js +2 -1
  52. package/dist/mcp-server.js +20 -17
  53. package/dist/mcp-verify-async.js +353 -0
  54. package/dist/mcp-verify-worker.js +17 -0
  55. package/dist/mcp-verify.js +10 -1
  56. package/dist/pedido-conducao.js +51 -0
  57. package/dist/preflight.js +25 -26
  58. package/dist/prompts.js +4 -2
  59. package/dist/pulse.js +4 -2
  60. package/dist/rede.js +24 -12
  61. package/dist/retry.js +12 -0
  62. package/dist/security-scan/cli.js +2 -2
  63. package/dist/security-scan/report.js +1 -1
  64. package/dist/session-watcher.js +33 -7
  65. package/dist/verify.js +166 -34
  66. package/package.json +1 -1
  67. package/skills/core/orkastery-bootstrap/SKILL.md +1 -1
  68. package/skills/phases/check-quality/SKILL.md +1 -1
  69. package/skills/phases/go-implementation/SKILL.md +1 -1
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - O modo de conducao afrouxa a PAUSA, nunca a VERIFICACAO.
29
29
  - Nada de self-report: toda alegacao vem com o comando que a comprova e a saida real.
30
- - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
30
+ - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; prefira `ork_verify` assíncrono e consulte `ork_verify_status` a cada 30–60 s; sem essa ferramenta, rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
31
31
  - Passo irreversivel (push, merge, delecao) so acontece quando o modo autoriza, e a autorizacao
32
32
  fica registrada no ledger.
33
33
  - Termine dizendo, em uma linha, em que ponto a thread esta e o que acontece agora.
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - O modo de conducao afrouxa a PAUSA, nunca a VERIFICACAO.
29
29
  - Nada de self-report: toda alegacao vem com o comando que a comprova e a saida real.
30
- - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
30
+ - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; prefira `ork_verify` assíncrono e consulte `ork_verify_status` a cada 30–60 s; sem essa ferramenta, rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
31
31
  - Passo irreversivel (push, merge, delecao) so acontece quando o modo autoriza, e a autorizacao
32
32
  fica registrada no ledger.
33
33
  - Termine dizendo, em uma linha, em que ponto a thread esta e o que acontece agora.
@@ -28,7 +28,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
28
28
 
29
29
  - O modo de conducao afrouxa a PAUSA, nunca a VERIFICACAO.
30
30
  - Nada de self-report: toda alegacao vem com o comando que a comprova e a saida real.
31
- - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
31
+ - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; prefira `ork_verify` assíncrono e consulte `ork_verify_status` a cada 30–60 s; sem essa ferramenta, rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
32
32
  - Passo irreversivel (push, merge, delecao) so acontece quando o modo autoriza, e a autorizacao
33
33
  fica registrada no ledger.
34
34
  - Termine dizendo, em uma linha, em que ponto a thread esta e o que acontece agora.
@@ -29,7 +29,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
29
29
 
30
30
  - O modo de conducao afrouxa a PAUSA, nunca a VERIFICACAO.
31
31
  - Nada de self-report: toda alegacao vem com o comando que a comprova e a saida real.
32
- - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
32
+ - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; prefira `ork_verify` assíncrono e consulte `ork_verify_status` a cada 30–60 s; sem essa ferramenta, rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
33
33
  - Passo irreversivel (push, merge, delecao) so acontece quando o modo autoriza, e a autorizacao
34
34
  fica registrada no ledger.
35
35
  - Termine dizendo, em uma linha, em que ponto a thread esta e o que acontece agora.
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - O modo de conducao afrouxa a PAUSA, nunca a VERIFICACAO.
29
29
  - Nada de self-report: toda alegacao vem com o comando que a comprova e a saida real.
30
- - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
30
+ - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; prefira `ork_verify` assíncrono e consulte `ork_verify_status` a cada 30–60 s; sem essa ferramenta, rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
31
31
  - Passo irreversivel (push, merge, delecao) so acontece quando o modo autoriza, e a autorizacao
32
32
  fica registrada no ledger.
33
33
  - Termine dizendo, em uma linha, em que ponto a thread esta e o que acontece agora.
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - O modo de conducao afrouxa a PAUSA, nunca a VERIFICACAO.
29
29
  - Nada de self-report: toda alegacao vem com o comando que a comprova e a saida real.
30
- - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
30
+ - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; prefira `ork_verify` assíncrono e consulte `ork_verify_status` a cada 30–60 s; sem essa ferramenta, rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
31
31
  - Passo irreversivel (push, merge, delecao) so acontece quando o modo autoriza, e a autorizacao
32
32
  fica registrada no ledger.
33
33
  - Termine dizendo, em uma linha, em que ponto a thread esta e o que acontece agora.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  description: Reconhece orkastery maestro e conduz pedidos, retomadas e status na conversa com o Maestro/Builder.
3
3
  argument-hint: "[pedido em linguagem natural|thread|status|board|plan|doctor|modos]"
4
- allowed-tools: Bash(ork:*), Read, mcp__orkastery__ork_thread_status, mcp__orkastery__ork_phase_list, mcp__orkastery__ork_hitl_pending, mcp__orkastery__ork_observe, mcp__orkastery__ork_artifact_read, mcp__orkastery__ork_claims_list, mcp__orkastery__ork_git_status, mcp__orkastery__ork_thread_new, mcp__orkastery__ork_phase_run, mcp__orkastery__ork_preflight
4
+ allowed-tools: Bash(ork:*), Read, mcp__orkastery__ork_thread_status, mcp__orkastery__ork_phase_list, mcp__orkastery__ork_hitl_pending, mcp__orkastery__ork_observe, mcp__orkastery__ork_artifact_read, mcp__orkastery__ork_claims_list, mcp__orkastery__ork_verify_status, mcp__orkastery__ork_git_status, mcp__orkastery__ork_thread_new, mcp__orkastery__ork_phase_run, mcp__orkastery__ork_preflight
5
5
  ---
6
6
 
7
7
  # /orkastery:ork
@@ -7,6 +7,8 @@ export const FRASE_DO_MOTIVO: Readonly<Record<string, string>> = {
7
7
  'artifact.missing': 'falta um artefato que a fase exige',
8
8
  'claims.failed': 'uma claim reprovou no HEAD',
9
9
  'claims.unverifiable': 'há claim sem comando de verificação',
10
+ 'concurrency.lease-indeterminado': 'não foi possível provar se a vaga está livre',
11
+ 'conducao.acao-necessaria': 'a condução precisa executar uma ação',
10
12
  'policy.violation': 'uma policy de bloqueio foi violada',
11
13
  'runtime.autoconferencia': 'o CHECK caiu no mesmo runtime do GO',
12
14
  'verify.regression': 'um teste que passava na baseline caiu',
@@ -44,7 +44,7 @@ O dono conversa sobre o objetivo; voce opera o nucleo `ork` e apresenta o result
44
44
  passo. Preserve o modo e as autorizacoes da thread. Se ja recebeu uma fase do Orkastery,
45
45
  execute essa fase no escopo recebido, sem redespachar a si mesmo.
46
46
 
47
- - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
47
+ - Esperas: nunca dispare verify, build ou suite com `&` dentro do comando, porque o processo se perde e a sessao espera um aviso que nunca vem; prefira `ork_verify` assíncrono e consulte `ork_verify_status` a cada 30–60 s; sem essa ferramenta, rode o `ork verify` em primeiro plano, com `timeout` (ele espera a vez na fila de recursos pesados), ou use a execucao em segundo plano do host, que avisa quando termina; nunca espere com `pgrep -f` cujo padrao aparece no proprio comando, porque o laco acha a si mesmo e nao termina: espere pelo arquivo de saida com prazo, ou pelo PID guardado.
48
48
 
49
49
  Quando descobertas, prefira as ferramentas MCP vinculadas ao projeto pelo servidor:
50
50
  `ork_thread_status`, `ork_phase_list`, `ork_hitl_pending`, `ork_thread_new(nome, modo)`,
@@ -2,7 +2,7 @@
2
2
  "id": "orkastery",
3
3
  "name": "Orkastery",
4
4
  "description": "Conducao de looping threads em 6 fases pelo nucleo `ork`, exposta ao OpenClaw como tools `ork_*`. Zero regra de negocio no host: cada tool e uma chamada de CLI. Toda tool de projeto aceita projeto (nome do projeto pedido); o cwd do gateway nunca escolhe o projeto. O status do roadmap vem de ork_network_roadmap; as maquinas da pessoa, de ork_network_status (sem projeto).",
5
- "version": "0.6.1",
5
+ "version": "0.6.2",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "properties": {},
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orkastery/openclaw-plugin",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Plugin Orkastery para OpenClaw: 32 tools ork_* que traduzem intencao em chamada de CLI do nucleo `ork`. Zero regra de negocio no host.",
5
5
  "type": "module",
6
6
  "private": true,
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - The conduction mode loosens the PAUSE, never the VERIFICATION.
29
29
  - No self-report: every statement comes with the command that proves it and the real output.
30
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
30
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
31
31
  - An irreversible step (push, merge, deletion) only happens when the mode authorizes it, and the authorization
32
32
  is recorded in the ledger.
33
33
  - End by saying, in one line, where the thread stands and what happens now.
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - The conduction mode loosens the PAUSE, never the VERIFICATION.
29
29
  - No self-report: every statement comes with the command that proves it and the real output.
30
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
30
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
31
31
  - An irreversible step (push, merge, deletion) only happens when the mode authorizes it, and the authorization
32
32
  is recorded in the ledger.
33
33
  - End by saying, in one line, where the thread stands and what happens now.
@@ -28,7 +28,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
28
28
 
29
29
  - The conduction mode loosens the PAUSE, never the VERIFICATION.
30
30
  - No self-report: every statement comes with the command that proves it and the real output.
31
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
31
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
32
32
  - An irreversible step (push, merge, deletion) only happens when the mode authorizes it, and the authorization
33
33
  is recorded in the ledger.
34
34
  - End by saying, in one line, where the thread stands and what happens now.
@@ -29,7 +29,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
29
29
 
30
30
  - The conduction mode loosens the PAUSE, never the VERIFICATION.
31
31
  - No self-report: every statement comes with the command that proves it and the real output.
32
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
32
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
33
33
  - An irreversible step (push, merge, deletion) only happens when the mode authorizes it, and the authorization
34
34
  is recorded in the ledger.
35
35
  - End by saying, in one line, where the thread stands and what happens now.
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - The conduction mode loosens the PAUSE, never the VERIFICATION.
29
29
  - No self-report: every statement comes with the command that proves it and the real output.
30
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
30
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
31
31
  - An irreversible step (push, merge, deletion) only happens when the mode authorizes it, and the authorization
32
32
  is recorded in the ledger.
33
33
  - End by saying, in one line, where the thread stands and what happens now.
@@ -27,7 +27,7 @@ ork phase list <thread> # o que ja aconteceu, com evidencia
27
27
 
28
28
  - The conduction mode loosens the PAUSE, never the VERIFICATION.
29
29
  - No self-report: every statement comes with the command that proves it and the real output.
30
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
30
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
31
31
  - An irreversible step (push, merge, deletion) only happens when the mode authorizes it, and the authorization
32
32
  is recorded in the ledger.
33
33
  - End by saying, in one line, where the thread stands and what happens now.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  description: Recognizes orkastery maestro and conducts requests, resumptions and status in the conversation with the Maestro/Builder.
3
3
  argument-hint: "[natural-language request|thread|status|board|plan|doctor|modos]"
4
- allowed-tools: Bash(ork:*), Read, mcp__orkastery__ork_thread_status, mcp__orkastery__ork_phase_list, mcp__orkastery__ork_hitl_pending, mcp__orkastery__ork_observe, mcp__orkastery__ork_artifact_read, mcp__orkastery__ork_claims_list, mcp__orkastery__ork_git_status, mcp__orkastery__ork_thread_new, mcp__orkastery__ork_phase_run, mcp__orkastery__ork_preflight
4
+ allowed-tools: Bash(ork:*), Read, mcp__orkastery__ork_thread_status, mcp__orkastery__ork_phase_list, mcp__orkastery__ork_hitl_pending, mcp__orkastery__ork_observe, mcp__orkastery__ork_artifact_read, mcp__orkastery__ork_claims_list, mcp__orkastery__ork_verify_status, mcp__orkastery__ork_git_status, mcp__orkastery__ork_thread_new, mcp__orkastery__ork_phase_run, mcp__orkastery__ork_preflight
5
5
  ---
6
6
 
7
7
  # /orkastery:ork
@@ -44,7 +44,7 @@ The owner talks about the goal; you operate the `ork` core and present the resul
44
44
  step. Preserve the thread's mode and authorizations. If you already received an Orkastery phase,
45
45
  run that phase within the received scope, without redispatching yourself.
46
46
 
47
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
47
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
48
48
 
49
49
  When discovered, prefer the MCP tools bound to the project by the server:
50
50
  `ork_thread_status`, `ork_phase_list`, `ork_hitl_pending`, `ork_thread_new(nome, modo)`,
@@ -4,6 +4,7 @@ import os
4
4
  from pathlib import Path
5
5
  import re
6
6
  import stat
7
+ import tempfile
7
8
  import time
8
9
 
9
10
 
@@ -11,8 +12,10 @@ def receipt_file(filename):
11
12
  try:
12
13
  path = Path(filename)
13
14
  root = path.parent
15
+ temp_root = Path(tempfile.gettempdir()).resolve()
14
16
  if (not path.is_absolute() or not re.fullmatch(r'receipt(?:-[a-f0-9]+)?\.json', path.name)
15
- or not re.fullmatch(r'/tmp/ork-prospective-fixture-[a-zA-Z0-9-]+', str(root))
17
+ or root.parent != temp_root
18
+ or not re.fullmatch(r'ork-prospective-fixture-[a-zA-Z0-9-]+', root.name)
16
19
  or root.resolve() != root or root.is_symlink()):
17
20
  raise ValueError()
18
21
  st = root.stat()
@@ -21,7 +21,7 @@ Distinguish the context before acting:
21
21
  - **Conductor session:** receives the owner's request, identifies or opens the thread, dispatches through `ork` and tracks the result; never writes product code in place of the dispatched session.
22
22
  - **Already dispatched phase session:** has received the thread, phase, prompt and worktree from `ork`.
23
23
  Work within that scope through the phase skill. Do not open another thread or redispatch your own phase to do the work already assigned to you.
24
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
24
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
25
25
 
26
26
  ## Start or resume
27
27
 
@@ -23,7 +23,7 @@ ork worktree audit <thread> # a worktree confere no proprio git
23
23
  ork gate request <thread> # o pedido da pausa; o humano responde pelo canal autenticado
24
24
  ```
25
25
 
26
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
26
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
27
27
 
28
28
  When the verdict is PRECISA DE MUDANCA, the GO-FIX / CHECK-REVERIFY sub-loop of block B3 is
29
29
  what conducts the way back, and it does not depend on a human until the final verdict:
@@ -24,7 +24,7 @@ ork claims add <thread> <arquivo> --claim "<...>" --verificar "<comando>" --fase
24
24
  ork verify <thread> # reexecuta no HEAD real
25
25
  ```
26
26
 
27
- - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
27
+ - Waits: never start verify, build or the suite with `&` inside the command, because the process gets lost and the session waits for a notice that never comes; prefer asynchronous `ork_verify` and query `ork_verify_status` every 30–60 s; without it, run `ork verify` in the foreground, with `timeout` (it waits its turn in the heavy-resource queue), or use the host's background execution, which tells you when it finishes; never wait with `pgrep -f` whose pattern shows up in the command itself, because the loop finds itself and never ends: wait for the output file with a deadline, or for the saved PID.
28
28
 
29
29
  ## What GO delivers
30
30
 
@@ -111,11 +111,13 @@ exports.CONSULTAS_MCP = [
111
111
  'mcp__orkastery__ork_observe',
112
112
  'mcp__orkastery__ork_artifact_read',
113
113
  'mcp__orkastery__ork_claims_list',
114
+ 'mcp__orkastery__ork_verify_status',
114
115
  ];
115
116
  // RM-037 (defeito 1): a decisao autonoma pelo MCP tem o mesmo grant nos dois runtimes.
116
117
  exports.MUTACOES_WORKTREE = [
117
118
  'mcp__orkastery__ork_artifact_write', 'mcp__orkastery__ork_claim_add', 'mcp__orkastery__ork_decision_record',
118
- 'mcp__orkastery__ork_git_commit', 'mcp__orkastery__ork_verify', 'mcp__orkastery__ork_ship',
119
+ 'mcp__orkastery__ork_request_conduction', 'mcp__orkastery__ork_git_commit', 'mcp__orkastery__ork_verify',
120
+ 'mcp__orkastery__ork_ship',
119
121
  ];
120
122
  /**
121
123
  * RM-031 KG5 (D7): as consultas do grafo, de leitura, so com a flag do manifesto da raiz; sem ela, nada muda.
@@ -37,6 +37,7 @@ exports.LIMITE_DE_RECUSAS_NO_LOG = exports.INTERVALO_DA_VIGIA_MS = exports.PRAZO
37
37
  exports.validarPedidoServidorGrok = validarPedidoServidorGrok;
38
38
  exports.recusaDaRequisicao = recusaDaRequisicao;
39
39
  exports.conferirArvore = conferirArvore;
40
+ exports.motivoDeEncerramentoDoGrok = motivoDeEncerramentoDoGrok;
40
41
  exports.servirGrok = servirGrok;
41
42
  /**
42
43
  * RM-067 (F4c, thread ork-rm067f4cmcpd): o servidor MCP do `ork` da sessão filha do `grok`, num processo do `ork`, fora do
@@ -311,6 +312,21 @@ function lerCorpo(req, limite) {
311
312
  function existe(arquivo) {
312
313
  return fs.lstatSync(arquivo, { throwIfNoEntry: false }) !== undefined;
313
314
  }
315
+ /**
316
+ * O evento terminal que a vigia ja pode afirmar. O recibo do `close` sempre vence; a ausencia do filho so e terminal
317
+ * depois que o supervisor tambem saiu, pois ele grava esse recibo entre os dois acontecimentos.
318
+ */
319
+ function motivoDeEncerramentoDoGrok(logPath, inicio, prazoDaPartida, agora = Date.now()) {
320
+ if (existe(`${logPath}.exit.json`))
321
+ return 'recibo';
322
+ const processo = (0, grok_mcp_1.lerJsonPequeno)(`${logPath}.process.json`);
323
+ if (!processo)
324
+ return agora - inicio > prazoDaPartida ? 'sem-partida' : null;
325
+ if ((!processo.filho || (0, codex_runner_1.estadoProcesso)(processo.filho) === 'ausente') &&
326
+ (0, codex_runner_1.estadoProcesso)(processo.supervisor) === 'ausente')
327
+ return 'grok-ausente';
328
+ return null;
329
+ }
314
330
  /** Roda um passo do fecho sem deixar a exceção dele impedir os seguintes. */
315
331
  function semFalhar(passo) {
316
332
  try {
@@ -554,18 +570,12 @@ async function servirGrok(pedido, token) {
554
570
  terminar();
555
571
  };
556
572
  const vigiar = () => {
557
- if (existe(`${pedido.logPath}.exit.json`)) {
558
- fechar('recibo');
559
- return;
560
- }
561
- const processo = (0, grok_mcp_1.lerJsonPequeno)(`${pedido.logPath}.process.json`);
562
- if (!processo) {
563
- if (Date.now() - inicio > prazoDaPartida)
564
- fechar('sem-partida');
565
- return;
566
- }
567
- if (!processo.filho || (0, codex_runner_1.estadoProcesso)(processo.filho) === 'ausente')
568
- fechar('grok-ausente');
573
+ // O `close` real do filho ocorre depois que ele ja aparece ausente e, dentro dele, o supervisor grava o recibo
574
+ // atomicamente antes de sair. Enquanto o supervisor vive, a ausencia do filho e so essa janela: o evento certo ainda
575
+ // e o recibo. `grok-ausente` fica para a queda do supervisor sem recibo, comprovada pela ausencia dos dois processos.
576
+ const motivo = motivoDeEncerramentoDoGrok(pedido.logPath, inicio, prazoDaPartida);
577
+ if (motivo)
578
+ fechar(motivo);
569
579
  };
570
580
  const vigia = setInterval(vigiar, exports.INTERVALO_DA_VIGIA_MS);
571
581
  return { porta, url, fechar, fechado };
@@ -132,7 +132,7 @@ const PREFIXO_DO_CLAUDE = 'mcp__orkastery__';
132
132
  /**
133
133
  * RM-067 (F4b, G2 e D1): as ferramentas do MCP do `ork` que um despacho do `grok` libera, as mesmas do `--allowedTools` do
134
134
  * `claude-bg` no mesmo caso, sem o prefixo: no PLAN que fecha o bloco, as consultas, `ork_artifact_write` e
135
- * `ork_decision_record`, em qualquer perfil; fora dele, as consultas e, no perfil `worktree`, `ork_git_status` e as seis
135
+ * `ork_decision_record`, em qualquer perfil; fora dele, as consultas e, no perfil `worktree`, `ork_git_status` e as sete
136
136
  * mutações. As consultas do grafo entram com a flag do manifesto da raiz. Montada na chamada, como no `claude-bg`: no
137
137
  * ciclo de imports, o valor importado pode ainda não existir quando este módulo carrega.
138
138
  */
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GRUPOS_NAO_PUBLICADOS = exports.SECAO_NAO_PUBLICADO = exports.CHANGELOG = void 0;
4
+ exports.ehTeste = ehTeste;
5
+ exports.pedeLinha = pedeLinha;
6
+ exports.linhasDaSecao = linhasDaSecao;
7
+ exports.versoes = versoes;
8
+ exports.changelogAplicavel = changelogAplicavel;
9
+ exports.checarChangelog = checarChangelog;
10
+ exports.basePadrao = basePadrao;
11
+ /**
12
+ * RM-037: regra unica do CHANGELOG para o script do CI, `docs verificar --pr` e `ork verify`.
13
+ * O diff decide quais linhas a thread acrescentou; o texto do HEAD decide em que secao e grupo
14
+ * cada linha caiu; uma tag local `v<versao>` prova que a secao ja foi publicada.
15
+ */
16
+ const node_child_process_1 = require("node:child_process");
17
+ exports.CHANGELOG = 'CHANGELOG.md';
18
+ exports.SECAO_NAO_PUBLICADO = 'Não publicado';
19
+ exports.GRUPOS_NAO_PUBLICADOS = ['Adicionado', 'Alterado', 'Corrigido', 'Segurança'];
20
+ const PASTAS_DE_PRODUTO = ['core/', 'adapters/', 'marketplaces/'];
21
+ const DE_CI = [/^\.github\//, /^\.ork-ci\//, /^core\/scripts\/test-ci\.js$/, /^core\/scripts\/checar-[a-z0-9-]+\.cjs$/];
22
+ const CORRECAO = 'acrescente em "## Não publicado" do CHANGELOG.md uma linha que diga o que muda para quem usa, ' +
23
+ 'sob "### Adicionado", "### Alterado", "### Corrigido" ou "### Segurança" ' +
24
+ '(PR só de testes ou só de CI fica de fora: docs/guias/contribuir/pull-request.md)';
25
+ function git(raiz, args) {
26
+ const r = (0, node_child_process_1.spawnSync)('git', args, { cwd: raiz, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
27
+ return { ok: r.status === 0, saida: r.stdout ?? '' };
28
+ }
29
+ /** Arquivo de teste: pasta `test`, `tests` ou `__tests__`, ou nome `*.test.*`/`*.spec.*`. */
30
+ function ehTeste(arquivo) {
31
+ const partes = arquivo.split('/');
32
+ return partes.slice(0, -1).some((p) => p === 'test' || p === 'tests' || p === '__tests__')
33
+ || /\.(test|spec)\.[A-Za-z0-9]+$/.test(partes[partes.length - 1]);
34
+ }
35
+ /** Arquivo de produto que exige uma entrada no CHANGELOG. */
36
+ function pedeLinha(arquivo) {
37
+ return PASTAS_DE_PRODUTO.some((p) => arquivo.startsWith(p)) && !ehTeste(arquivo) && !DE_CI.some((re) => re.test(arquivo));
38
+ }
39
+ /** Linhas de texto de `## Não publicado`, mantida para consumidores e testes legados. */
40
+ function linhasDaSecao(texto) {
41
+ const linhas = texto.replace(/\r\n/g, '\n').split('\n');
42
+ const inicio = linhas.findIndex((linha) => linha.trim() === `## ${exports.SECAO_NAO_PUBLICADO}`);
43
+ if (inicio < 0)
44
+ return null;
45
+ const corpo = [];
46
+ for (const linha of linhas.slice(inicio + 1)) {
47
+ if (/^## /.test(linha))
48
+ break;
49
+ if (linha.trim() && !/^#/.test(linha.trim()))
50
+ corpo.push(linha.trimEnd());
51
+ }
52
+ return corpo;
53
+ }
54
+ /** Versoes nos dois formatos historicos do arquivo. */
55
+ function versoes(texto) {
56
+ return new Set([...texto.replace(/\r\n/g, '\n').matchAll(/^## \[?(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)\]?(?=\s|$)/gm)]
57
+ .map((m) => m[1]));
58
+ }
59
+ function changelogEm(raiz, ref) {
60
+ const r = git(raiz, ['show', `${ref}:${exports.CHANGELOG}`]);
61
+ return r.ok ? r.saida : '';
62
+ }
63
+ /**
64
+ * A regra protege um histórico publicado. Repositórios ainda sem versão `v*` ou sem
65
+ * CHANGELOG no HEAD não têm esse contrato para comparar e ficam fora do verificador.
66
+ */
67
+ function changelogAplicavel(raiz, head = 'HEAD') {
68
+ const arquivo = git(raiz, ['cat-file', '-e', `${head}:${exports.CHANGELOG}`]);
69
+ if (!arquivo.ok)
70
+ return false;
71
+ const tags = git(raiz, ['tag', '--merged', head, '--list', 'v*']);
72
+ return tags.ok && tags.saida.split('\n').some((tag) => tag.trim().length > 1);
73
+ }
74
+ /** Linhas acrescentadas no arquivo, com o numero que ocupam no HEAD. */
75
+ function linhasAcrescentadas(raiz, base, head) {
76
+ const d = git(raiz, ['diff', '--no-color', '--unified=0', '--no-renames', base, head, '--', exports.CHANGELOG]);
77
+ if (!d.ok)
78
+ return [];
79
+ const novas = [];
80
+ let numero = 0, emTrecho = false;
81
+ for (const linha of d.saida.replace(/\r\n/g, '\n').split('\n')) {
82
+ const hunk = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(linha);
83
+ if (hunk) {
84
+ numero = Number(hunk[1]);
85
+ emTrecho = true;
86
+ continue;
87
+ }
88
+ if (!emTrecho || linha.startsWith('\\ No newline'))
89
+ continue;
90
+ if (linha.startsWith('+')) {
91
+ novas.push({ numero, texto: linha.slice(1) });
92
+ numero++;
93
+ }
94
+ else if (!linha.startsWith('-'))
95
+ numero++;
96
+ }
97
+ return novas;
98
+ }
99
+ function contextos(texto) {
100
+ const porLinha = [{ secao: null, grupo: null, versao: null }];
101
+ let secao = null, grupo = null, versao = null;
102
+ for (const linha of texto.replace(/\r\n/g, '\n').split('\n')) {
103
+ const h2 = /^## (.+?)\s*$/.exec(linha);
104
+ if (h2) {
105
+ secao = h2[1];
106
+ grupo = null;
107
+ versao = /^\[?(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)\]?(?:\s|$)/.exec(secao)?.[1] ?? null;
108
+ }
109
+ else {
110
+ const h3 = /^### (.+?)\s*$/.exec(linha);
111
+ if (h3)
112
+ grupo = h3[1];
113
+ }
114
+ porLinha.push({ secao, grupo, versao });
115
+ }
116
+ return porLinha;
117
+ }
118
+ function tagPublicada(raiz, versao) {
119
+ return git(raiz, ['rev-parse', '--verify', '--quiet', `refs/tags/v${versao}^{commit}`]).ok;
120
+ }
121
+ /**
122
+ * Confere o diff da thread ate `head`.
123
+ *
124
+ * A referencia local da branch alvo pode estar atrasada em relacao ao commit que abriu a
125
+ * worktree. Quando a base carimbada tambem e ancestral do HEAD e vem depois da merge-base,
126
+ * ela delimita o que a thread de fato acrescentou. Se a branch alvo avancou para alem dela,
127
+ * a merge-base mais nova continua vencendo.
128
+ */
129
+ function checarChangelog(raiz, opcoes = {}) {
130
+ const head = opcoes.head ?? 'HEAD', base = opcoes.base;
131
+ const indisponivel = (detalhe) => ({ ok: false, motivo: 'changelog.base-indisponivel', detalhe,
132
+ correcao: 'rode com o histórico completo do git (fetch-depth: 0 no CI) ou passe --base <ref>', arquivos: [], linhas: [] });
133
+ if (!git(raiz, ['rev-parse', '--verify', '--quiet', `${head}^{commit}`]).ok)
134
+ return indisponivel(`o head ${head} não existe neste repositório`);
135
+ if (!changelogAplicavel(raiz, head)) {
136
+ const temArquivo = git(raiz, ['cat-file', '-e', `${head}:${exports.CHANGELOG}`]).ok;
137
+ return { ok: true, motivo: null, arquivos: [], linhas: [], detalhe: temArquivo
138
+ ? 'regra do CHANGELOG não aplicável: o repositório ainda não tem versão publicada em tag v*'
139
+ : `regra do CHANGELOG não aplicável: ${exports.CHANGELOG} não existe em ${head}` };
140
+ }
141
+ if (!base)
142
+ return indisponivel('nenhuma base para comparar');
143
+ if (!git(raiz, ['rev-parse', '--verify', '--quiet', `${base}^{commit}`]).ok)
144
+ return indisponivel(`a base ${base} não existe neste repositório`);
145
+ const mb = git(raiz, ['merge-base', base, head]);
146
+ let ancestral = mb.saida.trim();
147
+ if (!mb.ok || !ancestral)
148
+ return indisponivel(`${base} e ${head} não têm ancestral comum`);
149
+ const carimbada = opcoes.baseCarimbada?.trim();
150
+ if (carimbada
151
+ && git(raiz, ['rev-parse', '--verify', '--quiet', `${carimbada}^{commit}`]).ok
152
+ && git(raiz, ['merge-base', '--is-ancestor', carimbada, head]).ok
153
+ && git(raiz, ['merge-base', '--is-ancestor', ancestral, carimbada]).ok) {
154
+ ancestral = carimbada;
155
+ }
156
+ const mudados = git(raiz, ['diff', '--name-only', '--no-renames', '-z', ancestral, head]);
157
+ const arquivos = (mudados.ok ? mudados.saida.split('\0') : []).filter(Boolean);
158
+ const pedem = arquivos.filter(pedeLinha);
159
+ const antes = changelogEm(raiz, ancestral), depois = changelogEm(raiz, head);
160
+ const novas = linhasAcrescentadas(raiz, ancestral, head);
161
+ const porLinha = contextos(depois);
162
+ // D4: uma entrada correta em Nao publicado nunca esconde uma edicao retrospectiva.
163
+ for (const linha of novas) {
164
+ if (!linha.texto.trim())
165
+ continue;
166
+ const contexto = porLinha[linha.numero] ?? { secao: null, grupo: null, versao: null };
167
+ if (contexto.versao && tagPublicada(raiz, contexto.versao)) {
168
+ return { ok: false, motivo: 'changelog.secao-publicada', arquivos: pedem, linhas: [linha.texto], secao: contexto.secao ?? undefined,
169
+ detalhe: `a linha nova ${linha.numero} caiu em "## ${contexto.secao}", versão já publicada pela tag v${contexto.versao}`,
170
+ correcao: `mova a linha para "## ${exports.SECAO_NAO_PUBLICADO}", sob um dos grupos permitidos` };
171
+ }
172
+ }
173
+ const entradasNaoPublicadas = novas.filter((linha) => {
174
+ const t = linha.texto.trim(), contexto = porLinha[linha.numero];
175
+ return !!t && !/^#{2,3} /.test(t) && contexto?.secao === exports.SECAO_NAO_PUBLICADO;
176
+ });
177
+ for (const linha of entradasNaoPublicadas) {
178
+ const grupo = porLinha[linha.numero]?.grupo ?? null;
179
+ if (!grupo)
180
+ return { ok: false, motivo: 'changelog.grupo-ausente', arquivos: pedem, linhas: [linha.texto], grupo,
181
+ detalhe: `a linha nova ${linha.numero} de "## ${exports.SECAO_NAO_PUBLICADO}" não está sob um título ###`,
182
+ correcao: `ponha a linha sob ${exports.GRUPOS_NAO_PUBLICADOS.map((g) => `"### ${g}"`).join(', ')}` };
183
+ if (!exports.GRUPOS_NAO_PUBLICADOS.includes(grupo)) {
184
+ return { ok: false, motivo: 'changelog.grupo-invalido', arquivos: pedem, linhas: [linha.texto], grupo,
185
+ detalhe: `a linha nova ${linha.numero} está sob "### ${grupo}", grupo que não vale em "## ${exports.SECAO_NAO_PUBLICADO}"`,
186
+ correcao: `use ${exports.GRUPOS_NAO_PUBLICADOS.map((g) => `"### ${g}"`).join(', ')}` };
187
+ }
188
+ }
189
+ if (pedem.length === 0)
190
+ return { ok: true, motivo: null, arquivos: [], linhas: [],
191
+ detalhe: arquivos.length === 0 ? `nada a conferir: ${head} não muda nada desde ${base}`
192
+ : 'nada pede linha: o PR não muda core/, adapters/ nem marketplaces/ fora de teste e de CI' };
193
+ const versaoNova = [...versoes(depois)].filter((v) => !versoes(antes).has(v));
194
+ if (versaoNova.length > 0)
195
+ return { ok: true, motivo: null, arquivos: pedem, linhas: [],
196
+ detalhe: `versão nova no ${exports.CHANGELOG}: ${versaoNova.join(', ')} (o PR de versão leva as linhas para ela)` };
197
+ if (linhasDaSecao(depois) === null)
198
+ return { ok: false, motivo: 'changelog.secao-ausente', arquivos: pedem, linhas: [],
199
+ detalhe: `o ${exports.CHANGELOG} de ${head} não tem a seção "## ${exports.SECAO_NAO_PUBLICADO}"`,
200
+ correcao: `abra a seção "## ${exports.SECAO_NAO_PUBLICADO}" no alto do ${exports.CHANGELOG} e acrescente a linha da mudança` };
201
+ if (entradasNaoPublicadas.length > 0)
202
+ return { ok: true, motivo: null, arquivos: pedem,
203
+ linhas: entradasNaoPublicadas.map((linha) => linha.texto),
204
+ detalhe: `${entradasNaoPublicadas.length} linha(s) nova(s) em "## ${exports.SECAO_NAO_PUBLICADO}" sob grupo permitido` };
205
+ return { ok: false, motivo: 'changelog.linha-ausente', arquivos: pedem, linhas: [],
206
+ detalhe: `o PR muda ${pedem.length} arquivo(s) de core/, adapters/ ou marketplaces/ (${pedem.slice(0, 3).join(', ')}${pedem.length > 3 ? ', ...' : ''}) e não acrescenta linha válida em "## ${exports.SECAO_NAO_PUBLICADO}" do ${exports.CHANGELOG}`,
207
+ correcao: CORRECAO };
208
+ }
209
+ /** Base padrao do CI: alvo do PR, main remota, main local. */
210
+ function basePadrao(raiz, env = process.env) {
211
+ if (env.GITHUB_BASE_REF)
212
+ return `origin/${env.GITHUB_BASE_REF}`;
213
+ for (const ref of ['origin/main', 'main'])
214
+ if (git(raiz, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]).ok)
215
+ return ref;
216
+ return null;
217
+ }