@orkastery/cli 0.5.6 → 0.6.1

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 (396) hide show
  1. package/adapters/README.md +18 -0
  2. package/adapters/claude-code/.claude-plugin/plugin.json +1 -0
  3. package/adapters/claude-code/README.md +37 -5
  4. package/adapters/claude-code/agents/ork-check.md +1 -0
  5. package/adapters/claude-code/agents/ork-go.md +1 -0
  6. package/adapters/claude-code/agents/ork-goal.md +1 -0
  7. package/adapters/claude-code/agents/ork-master.md +1 -0
  8. package/adapters/claude-code/agents/ork-plan.md +1 -0
  9. package/adapters/claude-code/agents/ork-ship.md +1 -0
  10. package/adapters/claude-code/hooks/hooks.json +2 -1
  11. package/adapters/claude-code/hooks/ork-guard.js +15 -1
  12. package/adapters/claude-code/hooks/ork-resposta.js +91 -0
  13. package/adapters/claude-code/hooks/ork-sensor.js +18 -2
  14. package/adapters/claude-code/hooks/quota-signal.js +14 -0
  15. package/adapters/claude-code/mods/ork-mensageiro/.claude-plugin/plugin.json +14 -0
  16. package/adapters/claude-code/mods/ork-mensageiro/hooks/caixa.ts +215 -0
  17. package/adapters/claude-code/mods/ork-mensageiro/hooks/hooks.json +3 -0
  18. package/adapters/claude-code/mods/ork-mensageiro/hooks/painel.tsx +165 -0
  19. package/adapters/claude-code/mods/ork-mensageiro/hooks/recepcao.ts +256 -0
  20. package/adapters/claude-code/mods/ork-mensageiro/hooks/register.tsx +481 -0
  21. package/adapters/claude-code/mods/ork-mensageiro/orkastery-mod.json +5 -0
  22. package/adapters/claude-code/mods/ork-mensageiro/types/index.d.ts +85 -0
  23. package/adapters/claude-code/mods/ork-pista/hooks/ci.ts +9 -5
  24. package/adapters/claude-code/mods/ork-ritual/.claude-plugin/plugin.json +14 -0
  25. package/adapters/claude-code/mods/ork-ritual/hooks/hooks.json +3 -0
  26. package/adapters/claude-code/mods/ork-ritual/hooks/nota.ts +88 -0
  27. package/adapters/claude-code/mods/ork-ritual/hooks/register.tsx +494 -0
  28. package/adapters/claude-code/mods/ork-ritual/hooks/replay.tsx +271 -0
  29. package/adapters/claude-code/mods/ork-ritual/hooks/ritual.ts +218 -0
  30. package/adapters/claude-code/mods/ork-ritual/orkastery-mod.json +5 -0
  31. package/adapters/claude-code/mods/ork-ritual/types/index.d.ts +106 -0
  32. package/adapters/claude-code/mods/ork-sentinela/hooks/vigia.ts +1 -1
  33. package/adapters/codex/skills/ork/SKILL.md +2 -0
  34. package/adapters/hermes/README.md +64 -1
  35. package/adapters/hermes/bin/ork-conhecimento-colecoes.sh +14 -0
  36. package/adapters/hermes/bin/ork-conhecimento-listar.sh +15 -0
  37. package/adapters/hermes/bin/ork-conhecimento-mostrar.sh +16 -0
  38. package/adapters/hermes/bin/ork-conhecimento-verificar.sh +15 -0
  39. package/adapters/hermes/bin/ork-vigia-batida.py +127 -0
  40. package/adapters/hermes/hermes.plugin.json +4 -0
  41. package/adapters/hermes/hitl-ingress/__init__.py +101 -8
  42. package/adapters/hermes/skills/orkastery-devmaster/SKILL.md +2 -2
  43. package/adapters/openclaw/README.md +81 -9
  44. package/adapters/openclaw/bin/ork-vigia-batida.js +86 -0
  45. package/adapters/openclaw/dist/hitl-ingress.js +106 -9
  46. package/adapters/openclaw/dist/index.js +86 -0
  47. package/adapters/openclaw/openclaw.plugin.json +34 -4
  48. package/adapters/openclaw/package.json +2 -2
  49. package/adapters/openclaw/src/hitl-ingress.ts +103 -9
  50. package/adapters/openclaw/src/index.ts +94 -0
  51. package/assets/adapters-en/claude-code/README.md +403 -0
  52. package/assets/adapters-en/claude-code/agents/ork-check.md +33 -0
  53. package/assets/adapters-en/claude-code/agents/ork-go.md +33 -0
  54. package/assets/adapters-en/claude-code/agents/ork-goal.md +34 -0
  55. package/assets/adapters-en/claude-code/agents/ork-master.md +35 -0
  56. package/assets/adapters-en/claude-code/agents/ork-plan.md +33 -0
  57. package/assets/adapters-en/claude-code/agents/ork-ship.md +33 -0
  58. package/assets/adapters-en/claude-code/commands/check.md +46 -0
  59. package/assets/adapters-en/claude-code/commands/go.md +46 -0
  60. package/assets/adapters-en/claude-code/commands/goal.md +55 -0
  61. package/assets/adapters-en/claude-code/commands/master.md +54 -0
  62. package/assets/adapters-en/claude-code/commands/onboarding.md +22 -0
  63. package/assets/adapters-en/claude-code/commands/ork.md +126 -0
  64. package/assets/adapters-en/claude-code/commands/plan.md +47 -0
  65. package/assets/adapters-en/claude-code/commands/ship.md +45 -0
  66. package/assets/adapters-en/codex/skills/ork/SKILL.md +85 -0
  67. package/assets/adapters-en/hermes/README.md +273 -0
  68. package/assets/adapters-en/hermes/skills/orkastery-devmaster/SKILL.md +169 -0
  69. package/assets/references-en/README.md +25 -0
  70. package/assets/references-en/code-review-axes.md +82 -0
  71. package/assets/references-en/definition-of-done.md +74 -0
  72. package/assets/references-en/performance-checklist.md +53 -0
  73. package/assets/references-en/security-checklist.md +101 -0
  74. package/assets/references-en/testing-patterns.md +51 -0
  75. package/assets/security-scan/defaults/.golangci.yml +2 -0
  76. package/assets/security-scan/defaults/eslint.config.mjs +11 -0
  77. package/assets/security-scan/defaults/gitleaks.toml +3 -0
  78. package/assets/security-scan/defaults/ruff.toml +1 -0
  79. package/assets/security-scan/tools-agil.json +87 -0
  80. package/assets/security-scan/tools.json +625 -0
  81. package/assets/skills-en/core/onboarding/SKILL.md +58 -0
  82. package/assets/skills-en/core/orkastery-bootstrap/SKILL.md +119 -0
  83. package/assets/skills-en/core/thread-state/SKILL.md +88 -0
  84. package/assets/skills-en/governance/decision-triage/SKILL.md +65 -0
  85. package/assets/skills-en/governance/narrative-guardian/SKILL.md +66 -0
  86. package/assets/skills-en/governance/roadmap-keeper/SKILL.md +60 -0
  87. package/assets/skills-en/governance/scope-check-capability-map/SKILL.md +71 -0
  88. package/assets/skills-en/observability/thread-tracing/SKILL.md +63 -0
  89. package/assets/skills-en/phases/check-quality/SKILL.md +103 -0
  90. package/assets/skills-en/phases/go-implementation/SKILL.md +78 -0
  91. package/assets/skills-en/phases/goal-definition/SKILL.md +69 -0
  92. package/assets/skills-en/phases/master-metrics/SKILL.md +72 -0
  93. package/assets/skills-en/phases/plan-specification/SKILL.md +67 -0
  94. package/assets/skills-en/phases/security-remediation/SKILL.md +70 -0
  95. package/assets/skills-en/phases/ship-release/SKILL.md +71 -0
  96. package/assets/skills-en/reviewers/code-reviewer/SKILL.md +61 -0
  97. package/assets/skills-en/reviewers/security-auditor/SKILL.md +93 -0
  98. package/assets/skills-en/reviewers/test-engineer/SKILL.md +66 -0
  99. package/assets/skills-en/reviewers/web-performance-auditor/SKILL.md +63 -0
  100. package/dist/adapters/claude-bg.js +123 -9
  101. package/dist/adapters/codex-controller-worker.js +12 -5
  102. package/dist/adapters/codex-events.js +16 -4
  103. package/dist/adapters/codex.js +3 -1
  104. package/dist/adapters/grok-events.js +227 -0
  105. package/dist/adapters/grok-mcp-servidor.js +612 -0
  106. package/dist/adapters/grok-mcp.js +178 -0
  107. package/dist/adapters/grok.js +686 -0
  108. package/dist/agendador-cpu.js +92 -0
  109. package/dist/atualizar-branch.js +245 -0
  110. package/dist/auditoria.js +13 -11
  111. package/dist/auditrun.js +51 -46
  112. package/dist/autorizacao-duravel.js +327 -0
  113. package/dist/board.js +94 -40
  114. package/dist/branch-de-estado.js +23 -10
  115. package/dist/busca-semantica.js +7 -5
  116. package/dist/catalogo.js +2 -1
  117. package/dist/changelog-reconciliacao.js +290 -0
  118. package/dist/check-agil.js +528 -0
  119. package/dist/check-modo.js +41 -0
  120. package/dist/check-paralelo.js +238 -0
  121. package/dist/ci.js +248 -45
  122. package/dist/ciclos.js +8 -6
  123. package/dist/claim-lint.js +12 -8
  124. package/dist/claims-conferir.js +47 -39
  125. package/dist/claims.js +10 -9
  126. package/dist/company-brain-client.js +10 -3
  127. package/dist/company-brain-migration.js +11 -5
  128. package/dist/conducao-batida.js +759 -0
  129. package/dist/conducao-sentinela.js +25 -8
  130. package/dist/conducao.js +89 -29
  131. package/dist/conhecimento-consulta.js +270 -0
  132. package/dist/conhecimento.js +111 -87
  133. package/dist/conta-esgotada.js +127 -0
  134. package/dist/dado-privado.js +816 -0
  135. package/dist/decisao-autonoma.js +5 -4
  136. package/dist/demo.js +14 -12
  137. package/dist/dependencias-da-worktree.js +25 -0
  138. package/dist/divida.js +38 -36
  139. package/dist/docs.js +89 -89
  140. package/dist/doctor-forja.js +343 -0
  141. package/dist/doctor-pulse-cron.js +113 -1
  142. package/dist/doctor.js +164 -6
  143. package/dist/dsn-da-memoria.js +417 -0
  144. package/dist/entrega-por-mod.js +503 -0
  145. package/dist/entrega-pr.js +154 -54
  146. package/dist/esgotamentos.js +13 -11
  147. package/dist/estado-thread.js +21 -18
  148. package/dist/evalrunner.js +35 -32
  149. package/dist/fabrica-batida.js +34 -21
  150. package/dist/fabrica-estado.js +33 -21
  151. package/dist/fix.js +21 -19
  152. package/dist/forja/adaptador.js +6 -0
  153. package/dist/forja/ambiente-de-ci.js +27 -0
  154. package/dist/forja/api.js +256 -0
  155. package/dist/forja/cache.js +89 -0
  156. package/dist/forja/cli.js +60 -0
  157. package/dist/forja/contrato.js +9 -0
  158. package/dist/forja/endereco.js +43 -0
  159. package/dist/forja/estado.js +22 -0
  160. package/dist/forja/executor.js +73 -0
  161. package/dist/forja/github/ci.js +95 -0
  162. package/dist/forja/github/dono-da-rede.js +18 -0
  163. package/dist/forja/github/metadados.js +15 -0
  164. package/dist/forja/github/pedidos.js +200 -0
  165. package/dist/forja/gitlab/ci.js +141 -0
  166. package/dist/forja/gitlab/consultas.js +59 -0
  167. package/dist/forja/gitlab/dono-da-rede.js +43 -0
  168. package/dist/forja/gitlab/metadados.js +15 -0
  169. package/dist/forja/gitlab/pedidos-abertos.js +158 -0
  170. package/dist/forja/gitlab/pedidos.js +141 -0
  171. package/dist/forja/produtor.js +32 -0
  172. package/dist/forja/registro.js +31 -0
  173. package/dist/forja/resolver.js +121 -0
  174. package/dist/forja/texto.js +13 -0
  175. package/dist/forja/versao.js +71 -0
  176. package/dist/forja.js +123 -80
  177. package/dist/handoff.js +23 -13
  178. package/dist/hitl-contract.js +46 -43
  179. package/dist/hitl-curto.js +37 -25
  180. package/dist/hitl-gates.js +13 -11
  181. package/dist/hitl-local-receipt.js +51 -0
  182. package/dist/hitl-local.js +11 -2
  183. package/dist/hitl-lock.js +5 -11
  184. package/dist/hitl-public-receipt.js +11 -0
  185. package/dist/hitl-resumo.js +44 -1
  186. package/dist/hitl-sessions.js +62 -9
  187. package/dist/hitl-texto-livre.js +7 -4
  188. package/dist/hitl.js +34 -31
  189. package/dist/horario.js +20 -1
  190. package/dist/hosts.js +104 -134
  191. package/dist/index.js +864 -554
  192. package/dist/indice-vetorial.js +14 -12
  193. package/dist/init.js +11 -2
  194. package/dist/integracoes-locais.js +4 -0
  195. package/dist/intelligence-graph-cli.js +123 -69
  196. package/dist/intelligence-graph-query.js +37 -22
  197. package/dist/leases.js +19 -18
  198. package/dist/ledger-stats.js +17 -16
  199. package/dist/ledger.js +31 -1
  200. package/dist/licoes.js +12 -11
  201. package/dist/locale-accounts.js +228 -0
  202. package/dist/locale-adapter.js +291 -0
  203. package/dist/locale-ajuda.js +86 -10
  204. package/dist/locale-audit.js +199 -0
  205. package/dist/locale-claims.js +213 -0
  206. package/dist/locale-conducao.js +138 -0
  207. package/dist/locale-conhecimento.js +181 -0
  208. package/dist/locale-decisao.js +205 -0
  209. package/dist/locale-docs.js +230 -0
  210. package/dist/locale-estado.js +101 -0
  211. package/dist/locale-forja.js +288 -0
  212. package/dist/locale-gerados.js +5 -0
  213. package/dist/locale-grafo.js +129 -0
  214. package/dist/locale-master.js +83 -0
  215. package/dist/locale-network.js +524 -0
  216. package/dist/locale-operacao-restante.js +931 -0
  217. package/dist/locale-projetos.js +100 -0
  218. package/dist/locale-prompts.js +194 -0
  219. package/dist/locale-pulse.js +140 -2
  220. package/dist/locale-reservas.js +87 -0
  221. package/dist/locale-retry.js +183 -6
  222. package/dist/locale-security-scan.js +69 -0
  223. package/dist/locale-setup.js +192 -0
  224. package/dist/locale-ship.js +177 -66
  225. package/dist/locale-thread.js +149 -5
  226. package/dist/locale-verify.js +80 -4
  227. package/dist/locale-worktree.js +246 -0
  228. package/dist/locale.js +553 -9
  229. package/dist/maestro-runtime.js +22 -3
  230. package/dist/manifest.js +293 -12
  231. package/dist/maquina-ociosa.js +211 -0
  232. package/dist/maquina.js +10 -5
  233. package/dist/master-nota-local.js +200 -0
  234. package/dist/master-nota.js +10 -2
  235. package/dist/master.js +118 -41
  236. package/dist/mcp-conhecimento.js +52 -0
  237. package/dist/mcp-experiencia.js +26 -5
  238. package/dist/mcp-install.js +90 -15
  239. package/dist/mcp-noctum.js +101 -0
  240. package/dist/mcp-server.js +116 -22
  241. package/dist/mcp-ship-transporte.js +977 -0
  242. package/dist/mcp-ship.js +68 -24
  243. package/dist/mcp-transportes.js +17 -0
  244. package/dist/memoria.js +63 -58
  245. package/dist/merge-da-entrega.js +85 -0
  246. package/dist/modos-migracao.js +8 -6
  247. package/dist/modos.js +17 -18
  248. package/dist/network-roadmap.js +94 -54
  249. package/dist/noctum-aceite.js +929 -0
  250. package/dist/noctum-arco.js +540 -33
  251. package/dist/noctum-capacidade.js +3 -3
  252. package/dist/noctum-changelog.js +399 -0
  253. package/dist/noctum-cli.js +539 -0
  254. package/dist/noctum-coordenacao.js +1225 -0
  255. package/dist/noctum-entrega.js +1217 -0
  256. package/dist/noctum-envelope.js +253 -17
  257. package/dist/noctum-execucao.js +100 -24
  258. package/dist/noctum-fechamento.js +416 -0
  259. package/dist/noctum-fila.js +49 -10
  260. package/dist/noctum-guarda.js +333 -0
  261. package/dist/noctum-integracao.js +507 -0
  262. package/dist/noctum-maquinas.js +387 -0
  263. package/dist/noctum-medicao.js +450 -0
  264. package/dist/noctum-modo.js +390 -0
  265. package/dist/noctum-pergunta-canal.js +96 -0
  266. package/dist/noctum-pergunta.js +115 -0
  267. package/dist/noctum-provas.js +838 -0
  268. package/dist/noctum-reconciliacao.js +594 -0
  269. package/dist/noctum-rede.js +102 -0
  270. package/dist/noctum-registro.js +215 -0
  271. package/dist/noctum-relatorio.js +861 -0
  272. package/dist/noctum-resposta.js +207 -0
  273. package/dist/noctum-retomada-rede.js +71 -0
  274. package/dist/noctum-sessoes-em-voo.js +93 -0
  275. package/dist/noctum-supervisao.js +649 -0
  276. package/dist/noctum-terminal.js +459 -0
  277. package/dist/noctum-transporte.js +655 -0
  278. package/dist/noctum-vigia.js +679 -0
  279. package/dist/ocupacao.js +3 -1
  280. package/dist/onboarding.js +16 -5
  281. package/dist/orkmind.js +39 -23
  282. package/dist/orquestracao.js +31 -35
  283. package/dist/parado-no-condutor.js +160 -139
  284. package/dist/phase.js +96 -42
  285. package/dist/policies.js +33 -0
  286. package/dist/postura-local.js +11 -6
  287. package/dist/preflight.js +2 -1
  288. package/dist/procedencia.js +9 -14
  289. package/dist/projeto-alvo.js +59 -20
  290. package/dist/prompts.js +136 -42
  291. package/dist/prova-minima.js +5 -6
  292. package/dist/pulse-cadencia.js +5 -4
  293. package/dist/pulse-consentimento.js +53 -1
  294. package/dist/pulse-delivery.js +143 -27
  295. package/dist/pulse-resposta.js +368 -4
  296. package/dist/pulse.js +136 -3
  297. package/dist/ratelimit.js +13 -4
  298. package/dist/recall.js +14 -13
  299. package/dist/rede-adesao.js +13 -8
  300. package/dist/rede-forja.js +108 -24
  301. package/dist/rede-status.js +63 -45
  302. package/dist/rede.js +86 -46
  303. package/dist/retomada-checkpoint.js +101 -0
  304. package/dist/retry.js +326 -78
  305. package/dist/roadmap-reservas.js +32 -32
  306. package/dist/runtime-ambiente.js +5 -0
  307. package/dist/runtime-context.js +279 -85
  308. package/dist/runtime-escada.js +429 -0
  309. package/dist/runtime-profiles.js +130 -63
  310. package/dist/runtimes.js +42 -5
  311. package/dist/saida-segura.js +3 -2
  312. package/dist/security-scan/agil.js +366 -0
  313. package/dist/security-scan/cli.js +76 -0
  314. package/dist/security-scan/compare.js +149 -0
  315. package/dist/security-scan/config.js +93 -0
  316. package/dist/security-scan/detect.js +97 -0
  317. package/dist/security-scan/executor.js +196 -0
  318. package/dist/security-scan/guard.js +180 -0
  319. package/dist/security-scan/imagem-de-lint.js +96 -0
  320. package/dist/security-scan/normalize/actionlint.js +12 -0
  321. package/dist/security-scan/normalize/eslint.js +12 -0
  322. package/dist/security-scan/normalize/gitleaks.js +13 -0
  323. package/dist/security-scan/normalize/golangci-lint.js +13 -0
  324. package/dist/security-scan/normalize/govulncheck.js +36 -0
  325. package/dist/security-scan/normalize/index.js +25 -0
  326. package/dist/security-scan/normalize/npm-audit.js +30 -0
  327. package/dist/security-scan/normalize/osv-scanner.js +32 -0
  328. package/dist/security-scan/normalize/oxlint.js +51 -0
  329. package/dist/security-scan/normalize/pip-audit.js +16 -0
  330. package/dist/security-scan/normalize/ruff.js +12 -0
  331. package/dist/security-scan/normalize/semgrep.js +20 -0
  332. package/dist/security-scan/normalize/trivy.js +33 -0
  333. package/dist/security-scan/normalize/util.js +204 -0
  334. package/dist/security-scan/normalize/zizmor.js +19 -0
  335. package/dist/security-scan/report.js +156 -0
  336. package/dist/security-scan/run.js +448 -0
  337. package/dist/security-scan/tools.js +62 -0
  338. package/dist/security-scan/trabalhador.js +74 -0
  339. package/dist/security-scan/types.js +15 -0
  340. package/dist/session-events.js +19 -2
  341. package/dist/session-watcher-claude.js +74 -19
  342. package/dist/session-watcher-grok.js +425 -0
  343. package/dist/session-watcher.js +174 -13
  344. package/dist/sessoes-contas.js +42 -5
  345. package/dist/sessoes-inventario.js +1 -1
  346. package/dist/sessoes.js +25 -23
  347. package/dist/setup.js +67 -66
  348. package/dist/ship-publicar.js +263 -92
  349. package/dist/ship.js +160 -17
  350. package/dist/superficie.js +14 -11
  351. package/dist/thread-close.js +9 -9
  352. package/dist/thread.js +121 -18
  353. package/dist/tokens.js +15 -11
  354. package/dist/trabalho-thread.js +297 -0
  355. package/dist/transporte-do-canal.js +189 -0
  356. package/dist/types.js +12 -1
  357. package/dist/util.js +5 -2
  358. package/dist/varredura-acoes.js +500 -0
  359. package/dist/verify.js +491 -32
  360. package/dist/worktree-local.js +12 -10
  361. package/dist/worktree.js +81 -85
  362. package/eval/casos/check-quality.json +77 -0
  363. package/eval/casos/security-auditor.json +148 -0
  364. package/eval/casos/security-remediation.json +161 -0
  365. package/eval/fixtures/security-scan/README.md +8 -0
  366. package/eval/fixtures/security-scan/go/.github/workflows/ci.yml +12 -0
  367. package/eval/fixtures/security-scan/go/Dockerfile +4 -0
  368. package/eval/fixtures/security-scan/go/README.md +4 -0
  369. package/eval/fixtures/security-scan/go/config.go +4 -0
  370. package/eval/fixtures/security-scan/go/go.mod +5 -0
  371. package/eval/fixtures/security-scan/go/go.sum +2 -0
  372. package/eval/fixtures/security-scan/go/main.go +31 -0
  373. package/eval/fixtures/security-scan/js/.github/workflows/ci.yml +12 -0
  374. package/eval/fixtures/security-scan/js/Dockerfile +3 -0
  375. package/eval/fixtures/security-scan/js/README.md +4 -0
  376. package/eval/fixtures/security-scan/js/package-lock.json +844 -0
  377. package/eval/fixtures/security-scan/js/package.json +10 -0
  378. package/eval/fixtures/security-scan/js/src/config.js +4 -0
  379. package/eval/fixtures/security-scan/js/src/server.js +17 -0
  380. package/eval/fixtures/security-scan/js/src/util.ts +4 -0
  381. package/eval/fixtures/security-scan/js/tsconfig.json +4 -0
  382. package/eval/fixtures/security-scan/python/.github/workflows/ci.yml +12 -0
  383. package/eval/fixtures/security-scan/python/Dockerfile +3 -0
  384. package/eval/fixtures/security-scan/python/README.md +4 -0
  385. package/eval/fixtures/security-scan/python/app/__init__.py +0 -0
  386. package/eval/fixtures/security-scan/python/app/config.py +2 -0
  387. package/eval/fixtures/security-scan/python/app/main.py +19 -0
  388. package/eval/fixtures/security-scan/python/requirements.txt +1 -0
  389. package/package.json +10 -5
  390. package/references/security-checklist.md +3 -3
  391. package/skills/README.md +1 -0
  392. package/skills/core/orkastery-bootstrap/SKILL.md +2 -2
  393. package/skills/phases/check-quality/SKILL.md +16 -0
  394. package/skills/phases/go-implementation/SKILL.md +6 -0
  395. package/skills/phases/security-remediation/SKILL.md +70 -0
  396. package/skills/reviewers/security-auditor/SKILL.md +25 -0
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: security-auditor
3
+ description: "Security auditor for CHECK: goes through security-checklist.md on the diff, the branch history and the thread artifacts, with the hard condition of zero blockers. Never prints the secret it finds."
4
+ bucket: reviewers
5
+ roteia: "ork verify <thread> | references/security-checklist.md"
6
+ license: MIT
7
+ ---
8
+
9
+ # Security Auditor
10
+
11
+ ## What this skill is
12
+
13
+ A thin router that applies [security-checklist.md](../../../references/security-checklist.md) to the
14
+ thread's scope. The pass condition is hard: **zero security blockers, in any conduction
15
+ mode, including `#Auto`.**
16
+
17
+ ## How to route
18
+
19
+ ```bash
20
+ git diff <base>...HEAD # a arvore de trabalho
21
+ git log -p <base>..HEAD # o historico atras da branch
22
+ ork phase list <thread> # policies e gates ja registrados
23
+ ork doctor # provider e ambiente da maquina
24
+ ```
25
+
26
+ ## Scope and conduct
27
+
28
+ 1. **The scope is declared before the findings:** which directories, which history range,
29
+ which artifacts. An audit without a declared scope does not count as evidence.
30
+ 2. **Test fixtures and example configs are in scope.** A credential in a test is a leaked
31
+ credential, made worse by the fact that nobody looks there; `SEC 1` includes `.env`, fixtures and examples.
32
+ 3. **History is in scope.** A secret committed and then deleted is still leaked; the audit
33
+ reads the range, not only the tree.
34
+ 4. **The report does not print credentials.** The finding names the pattern, the file and the line, in redacted
35
+ form. **A leak report that prints the secret is a second leak.**
36
+ 5. **Absence is asserted as a result**, with what was examined: "nothing found" without a scope is
37
+ different from "audited and clean", and the difference is written down.
38
+
39
+ ## With `verify.security_scan` declared
40
+
41
+ Without `verify.security_scan`, this skill does what it always did: the whole checklist by reading, and the manual pass remains valid. With the key declared, the scan report (`.orkastery/security-scan/<sha>/report.json`, in the main tree) is the evidence for `SEC 1`, `SEC 2` and `SEC 10`, and the triage below applies.
42
+
43
+ 1. **Declare the scan scope:** `base`, `head`, the stacks and each tool with its state (`ran`, `failed` or `unavailable`) and the `reason`.
44
+ 2. **A tool `unavailable` or `failed` never counts as clean.** Declare it as such; its `SEC` items fall back to manual reading, marked as such. The manual pass is only valid with the scan declared `unavailable`.
45
+ 3. **Triage: one verdict per `new` finding of the loop** (`loop`), none without a verdict:
46
+ - **real:** type B correction, with the rule, `arquivo:linha`, the real output **redacted (never the secret value; only the rule, `arquivo:linha` and `fingerprint`)**, the `SEC n` and the reach (`reachable` from govulncheck); the way back is the `security-remediation` skill;
47
+ - **false positive:** type A correction, `acrescentar <fingerprint> ao .ork-security/dismissals.json, motivo <m>`, plus `ork decisao registrar`;
48
+ - **inconclusive:** no correction; the short question goes into the report, the verdict is not PASSOU and the finding stays open until the owner answers through `ork gate request` (the path is in the `check-quality` skill).
49
+ 4. **The verdict reaches GO-FIX as a CHECK claim, one per finding.** `ork fix open` derives the GO-FIX spec only from `ork verify`, and verify re-runs the claims: each failed claim becomes a correction carrying its text.
50
+ - real: `ork claims add <thread> <arquivo> --fase CHECK --claim "<veredito>" --verificar "<comando de verify.security_scan>"`; the command fails on HEAD and the correction is born type B (`claims.failed`). The claim fails and passes with the whole scan, not with this finding (the `fingerprint` stays in the text), costs one extra HEAD scan per claim at every verify and goes into the `.ork-ci` bundle with the other claims;
51
+ - false positive: `ork claims add <thread> .ork-security/dismissals.json --fase CHECK --claim "<veredito>"`, without `--verificar`; the claim with no command is born type A (`claims.unverifiable`). A claim the core reads as negative fails with no command and becomes type B without warning: `ehAlegacaoNegativa` in `core/src/claims.ts` looks, without accents and even inside words, for `nenhum`, `nenhuma`, `nunca`, `sempre`, `zero`, `todos`, `todas`, `nao ha`, `nao existe`, `nao resta`, `sem nenhum`, `100%`, `totalmente`, `completamente` (`metodos` contains `todos`). Check the `ork claims add` output: the false positive only holds with the `negativa` line at `nao` and the `estado` line at `nao-verificavel` (pt-BR output; in the `en` locale, the `negative` line at `no` and the `state` line at `unverifiable`); otherwise, `ork claims retirar <thread> <claim> --motivo "<motivo>"` and register it again with neutral wording;
52
+ - the `<veredito>` carries the finding id, the tool, the rule, `arquivo:linha`, the `fingerprint`, the type and the correction, and for a false positive the reason and the `eventId` of `ork decisao registrar`;
53
+ - the owner's answer to an inconclusive finding becomes a claim the same way, registered by whoever conducts or by a new CHECK, before `ork fix open`.
54
+ 5. **The auditor does not edit:** neither code nor `.ork-security/dismissals.json`. It returns the verdict, and whoever writes the fix is GO.
55
+ 6. **Secret material never goes to the session output.** With a `new` Gitleaks finding, the finding's line and the content of the commit that brought it do not go to the output through any tool: Read, `sed`, `head`, `grep -n`, editor, `git log -p`, `git show`, `cat`, diff. The output goes to the transcript and to the provider, and it is a second leak. **A `secret` finding gets no context reading at all:** not the line, not its neighbours, not the file, because a multi-line secret (a PEM key) gets past any single-line mask. Its verdict uses only the report's `rule`, `arquivo:linha` and `fingerprint`, and comparing the value with another is done by hash (`sha256sum`), printing neither. Context without the finding's line (`awk -v n=<linha> 'NR>=n-5 && NR<=n+5 && NR!=n' <arquivo>`) applies only to the other categories (`sast`, `dependency`, `iac`, `workflow`).
56
+ 7. `existing` and `dismissed` go in the report as declared debt, never as a new blocker.
57
+
58
+ ## What the core checks for you
59
+
60
+ The `segredo_em_prompt` policy runs at the `phase.dispatch` gate **before the prompt is written to
61
+ disk**: a rejected prompt never comes to exist as a file. The `provider` policy blocks dispatch
62
+ through a paid provider under `subscription-only`, and `push_direto_na_base` blocks a delivery without a thread
63
+ branch. All three reject in any mode.
64
+
65
+ ## Racionalizacoes comuns (Common rationalizations)
66
+
67
+ | Excuse | Reality |
68
+ |---|---|
69
+ | "The key is only in the test fixture" | Fixtures are in the scope of `SEC 1`. A credential in a test is a leaked credential, made worse by the fact that nobody looks there. |
70
+ | "I deleted the commit that had the token" | Deleting from the tree does not delete from history. A blocker until the credential is rotated and the rotation verified, not promised. |
71
+ | "I will paste the snippet in the report so the team can see it" | A leak report that prints the secret is a second leak. Name the pattern and the line, redacted. |
72
+ | "This blocker is theoretical, nobody would exploit it" | Zero blockers is a hard condition, not negotiable by a probability estimated by eye. |
73
+ | "The thread is `#Auto`, the audit can be lighter" | The mode loosens the pause, never the verification. The list is the same; what changes is who waits for the verdict. |
74
+ | "Since I found it, I will fix it right here" | The auditor does not edit. An auditor who fixes ends up auditing its own work; the verdict goes to GO and the fix comes back through CHECK. |
75
+
76
+ ## Bandeiras vermelhas (Red flags)
77
+
78
+ - A security report with no scope and no history range.
79
+ - A real secret pasted into the report or the ledger.
80
+ - A finding without the `SEC n` it violates.
81
+ - "Nothing found" without saying what was examined.
82
+ - A new dependency without justification in the PLAN.
83
+ - A Gitleaks secret value pasted in the correction, the verdict or the ledger.
84
+ - A `new` loop finding without a verdict, or a `failed` tool counted as clean.
85
+ - The line or commit of a `new` Gitleaks finding in the session output, through any tool (Read, `sed`, `grep -n`, `git log -p`, `git show`, `cat`, diff).
86
+ - File context read for a `secret` finding, even without the finding's line.
87
+ - A verdict on a `new` scan finding only in the report, without the CHECK claim that carries it to `ork fix open`.
88
+
89
+ ## Verification before leaving the audit
90
+
91
+ Scope declared, tree and history scanned, thread artifacts read, each finding with a category
92
+ and `SEC n`, no credential printed, and zero blockers for the PASSOU (passed) verdict. See `SEC 15` to
93
+ `SEC 17` and `DoD 9`.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: test-engineer
3
+ description: "Test reviewer for CHECK: applies testing-patterns.md to the thread's suite, confirms that the green suite was earned and not loosened, and reports coverage with a declared source."
4
+ bucket: reviewers
5
+ roteia: "ork verify <thread> | ork verify <thread> --baseline | references/testing-patterns.md"
6
+ license: MIT
7
+ ---
8
+
9
+ # Test Engineer
10
+
11
+ ## What this skill is
12
+
13
+ A thin router that applies [testing-patterns.md](../../../references/testing-patterns.md) to the
14
+ thread's suite. It does not write the missing test: it shows which one is missing and why, and that becomes a
15
+ GO task. **A green suite must be earned, not declared.**
16
+
17
+ ## How to route
18
+
19
+ ```bash
20
+ ork verify <thread> --baseline # gravada ANTES do GO
21
+ ork verify <thread> # reexecucao no HEAD real, comparada com a baseline
22
+ git diff <base>...HEAD -- '*test*' # o que aconteceu com os testes no caminho
23
+ ```
24
+
25
+ ## Scope and conduct
26
+
27
+ 1. **Compare against the baseline.** Without a baseline, a failure cannot tell a regression from
28
+ pre-existing debt, and the report turns into an argument about blame.
29
+ 2. **Look for the loosening**, not only the red: a removed test, a test marked to skip,
30
+ an assertion swapped for the value the code produces today. **Adjusting the expected to the observed is the
31
+ most common way to turn a defect into a contract.**
32
+ 3. **Require the test that reproduces the defect** in every fix request, and require that it failed
33
+ before the fix.
34
+ 4. **Report numbers with their source:** `runtime_reported`, `estimated` or `unavailable`. A gap is
35
+ published as a gap, never as zero.
36
+
37
+ ## What the core checks for you
38
+
39
+ `ork verify` re-runs the manifest commands and the claims on the real HEAD and stamps the commit.
40
+ A command that passed in the baseline and fails now comes out as `verify.regression`; what already failed comes out
41
+ as declared debt, with the command name.
42
+
43
+ ## Racionalizacoes comuns (Common rationalizations)
44
+
45
+ | Excuse | Reality |
46
+ |---|---|
47
+ | "That test was flaky, I marked it to skip" | Skipping a test is a recorded scope change. Without a record, it is the defect slipping out the back door. |
48
+ | "I adjusted the assertion to the right value" | Right according to whom? If the expected value changed, the reason is in the PLAN. Adjusting the expected to the observed turns a defect into a contract. |
49
+ | "The bug is obvious, the reproduction test is redundant" | A fix whose defect was never reproduced does not prove it fixed anything. |
50
+ | "Coverage is at about 80 percent" | A number without a source does not go in. Without a tool, coverage comes out `unavailable`, with the reason. |
51
+ | "The happy path alone is enough, the rest is unlikely" | A suite that only exercises success measures optimism. The failure path is where the user meets the product. |
52
+ | "I ran it locally and it passed" | A reported pass is not a pass. What counts is the real output of the re-run on HEAD. |
53
+
54
+ ## Bandeiras vermelhas (Red flags)
55
+
56
+ - A test removed in the same commit as the fix.
57
+ - A new `skip` without a record.
58
+ - An assertion changed without a written reason.
59
+ - Coverage reported as a round number with no tool on the machine.
60
+ - No baseline recorded before GO.
61
+
62
+ ## Verification before leaving the review
63
+
64
+ Baseline in place, suite re-run on the real HEAD, test diff read in search of loosening,
65
+ a reproduction test present in the fixes, and every number with a declared source. See `TEST 1` to
66
+ `TEST 12` and `DoD 7`.
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: web-performance-auditor
3
+ description: "Performance auditor for CHECK: a conditional audit that runs when the target has a latency-sensitive surface and, when it does not, is waived by a written contract. Does not assert performance without measurement."
4
+ bucket: reviewers
5
+ roteia: "references/performance-checklist.md | ork verify <thread>"
6
+ license: MIT
7
+ ---
8
+
9
+ # Web Performance Auditor
10
+
11
+ ## What this skill is
12
+
13
+ A thin router that applies
14
+ [performance-checklist.md](../../../references/performance-checklist.md) to the thread's target. It is
15
+ **conditional and never absent**: when the target has no latency-sensitive surface, the section
16
+ exists and contains the written waiver, with the reason.
17
+
18
+ ## How to route
19
+
20
+ ```bash
21
+ ork verify <thread> # a suite, e o tempo real que ela leva
22
+ git diff <base>...HEAD # os lacos e o I/O que o diff introduziu
23
+ ```
24
+
25
+ ## Scope and conduct
26
+
27
+ 1. **Decide and record applicability.** A written waiver is a result; a missing audit with no
28
+ line at all is a gap.
29
+ 2. **Measure before asserting.** Every performance statement carries a number, a unit and how the number
30
+ was obtained. **"It got faster" without a measurement is opinion, and opinion does not pass a gate.**
31
+ 3. **Compare on the same machine and under the same conditions**, with enough repetition to separate signal from
32
+ noise. A single run becomes `estimated`, never `runtime_reported`.
33
+ 4. **Measure the user's path**, not the convenient microbenchmark.
34
+ 5. **Declare the source of every number**, and what was not measured comes out `unavailable` with the reason, never
35
+ as zero.
36
+
37
+ ## What the core checks for you
38
+
39
+ The same discipline as the `ork` token gate, which would rather say "not measurable" than invent a
40
+ window occupancy: `runtime_reported`, `estimated`, `informada`, `unavailable`. The source is part
41
+ of the data, not decoration on the report.
42
+
43
+ ## Racionalizacoes comuns (Common rationalizations)
44
+
45
+ | Excuse | Reality |
46
+ |---|---|
47
+ | "It got visibly faster" | Without a number, a unit and a method, it is opinion. Opinion does not pass a performance gate. |
48
+ | "I measured on my machine, it came out better than on CI" | Comparing different machines compares machines, not code. Same hardware, same conditions, or no comparison. |
49
+ | "I ran it once and could already see it" | One run becomes `estimated`. Without repetition there is no way to separate gain from noise. |
50
+ | "There is no web interface, so I skip the section" | The section always exists. With no sensitive surface, it contains the waiver and the reason. |
51
+ | "I put zero where I could not measure" | Zero is a data point, and a false one. What was not measured comes out `unavailable` with the reason. |
52
+
53
+ ## Bandeiras vermelhas (Red flags)
54
+
55
+ - A CHECK report with no performance section, not even with the waiver.
56
+ - A gain asserted with no number and no method.
57
+ - A number without a declared source.
58
+ - A comparison across different machines or conditions presented as before and after.
59
+
60
+ ## Verification before leaving the audit
61
+
62
+ Applicability decided and written down, measurements with method and repetition when there is something to measure, the user's
63
+ path covered, and every number with its source. See `PERF 1` to `PERF 10` and `DoD 9`.
@@ -42,13 +42,14 @@ var __importStar = (this && this.__importStar) || (function () {
42
42
  };
43
43
  })();
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.JANELA_CURTA_MAX_MS = exports.MOD_DOS_TETOS = exports.MINIMO_DA_API_DE_MODS = exports.NOME_ADAPTER = void 0;
45
+ exports.DAEMON_DO_CLAUDE = exports.PRAZO_DO_DAEMON_MS = exports.JANELA_CURTA_MAX_MS = exports.MOD_DA_ENTREGA = exports.MOD_DOS_TETOS = exports.MINIMO_DA_API_DE_MODS = exports.MUTACOES_WORKTREE = exports.CONSULTAS_MCP = exports.NOME_ADAPTER = void 0;
46
46
  exports.ambienteDoPerfil = ambienteDoPerfil;
47
47
  exports.semContextoDeDespacho = semContextoDeDespacho;
48
48
  exports.disponivel = disponivel;
49
49
  exports.versao = versao;
50
50
  exports.modsParaOClaude = modsParaOClaude;
51
51
  exports.agentTeamsDoDespacho = agentTeamsDoDespacho;
52
+ exports.entradaDoDespacho = entradaDoDespacho;
52
53
  exports.montarComando = montarComando;
53
54
  exports.extrairSessionId = extrairSessionId;
54
55
  exports.listarSessoes = listarSessoes;
@@ -59,6 +60,7 @@ exports.despachar = despachar;
59
60
  exports.parseRateLimit = parseRateLimit;
60
61
  exports.naturezaDoLimite = naturezaDoLimite;
61
62
  exports.parseFalhaDeConta = parseFalhaDeConta;
63
+ exports.cotaExpostaDoAuth = cotaExpostaDoAuth;
62
64
  exports.conferirAuth = conferirAuth;
63
65
  exports.comandoAttach = comandoAttach;
64
66
  exports.limparAnsi = limparAnsi;
@@ -68,6 +70,9 @@ exports.parar = parar;
68
70
  exports.pararAchada = pararAchada;
69
71
  exports.acharSessaoNasContas = acharSessaoNasContas;
70
72
  exports.ocupacaoDeContexto = ocupacaoDeContexto;
73
+ exports.lerStatusDoDaemon = lerStatusDoDaemon;
74
+ exports.sondarDaemon = sondarDaemon;
75
+ exports.derrubarDaemon = derrubarDaemon;
71
76
  const horario_1 = require("../horario");
72
77
  const util_1 = require("../util");
73
78
  const runtime_ambiente_1 = require("../runtime-ambiente");
@@ -98,8 +103,8 @@ function semContextoDeDespacho(base, contexto) {
98
103
  delete env[chave];
99
104
  return env;
100
105
  }
101
- /** Consultas do perfil interactive; gates e respostas humanas nunca recebem grant. */
102
- const CONSULTAS_MCP = [
106
+ /** Consultas do perfil interactive; gates e respostas humanas nunca recebem grant. RM-067 (F4b): o grok usa as mesmas. */
107
+ exports.CONSULTAS_MCP = [
103
108
  'mcp__orkastery__ork_thread_status',
104
109
  'mcp__orkastery__ork_phase_list',
105
110
  'mcp__orkastery__ork_hitl_pending',
@@ -108,7 +113,7 @@ const CONSULTAS_MCP = [
108
113
  'mcp__orkastery__ork_claims_list',
109
114
  ];
110
115
  // RM-037 (defeito 1): a decisao autonoma pelo MCP tem o mesmo grant nos dois runtimes.
111
- const MUTACOES_WORKTREE = [
116
+ exports.MUTACOES_WORKTREE = [
112
117
  'mcp__orkastery__ork_artifact_write', 'mcp__orkastery__ork_claim_add', 'mcp__orkastery__ork_decision_record',
113
118
  'mcp__orkastery__ork_git_commit', 'mcp__orkastery__ork_verify', 'mcp__orkastery__ork_ship',
114
119
  ];
@@ -128,7 +133,7 @@ function permissoesDaWorktree(cwd, permiteEditarProduto, consultas) {
128
133
  for (const prefixo of [`${absoluto}/${nome}`, `${absoluto}/**/${nome}`])
129
134
  deny.push(`Edit(${prefixo})`, `Edit(${prefixo}/**)`);
130
135
  }
131
- return { allow: [...consultas, 'mcp__orkastery__ork_git_status', ...MUTACOES_WORKTREE, ...(permiteEditarProduto ? [`Edit(${absoluto}/**)`] : [])], deny };
136
+ return { allow: [...consultas, 'mcp__orkastery__ork_git_status', ...exports.MUTACOES_WORKTREE, ...(permiteEditarProduto ? [`Edit(${absoluto}/**)`] : [])], deny };
132
137
  }
133
138
  /** O runtime esta disponivel nesta maquina? */
134
139
  function disponivel() {
@@ -198,6 +203,21 @@ function agentTeamsDoDespacho(tetos, mods) {
198
203
  teammateMode: 'in-process',
199
204
  };
200
205
  }
206
+ /** RM-059 (fatia F9): o mod que confere, na sessao de fase, a resposta do dono que chega de outra sessao. */
207
+ exports.MOD_DA_ENTREGA = 'ork-mensageiro';
208
+ /**
209
+ * RM-059 (T9.4, D14 da thread ork-rm059mensag): o que o despacho acrescenta ao `--settings` para a sessao de fase
210
+ * receber a resposta do dono pelo Mensageiro de Sessoes. `crossSessionInbound: accept` entrega a mensagem de outra
211
+ * sessao do mesmo usuario sem a paridade de modo, que numa sessao sem pessoa vence o prazo e descarta; por isso so
212
+ * vai com o Mensageiro entre os mods que vao de fato a sessao (sem ele, ninguem confere o que chega) e so na sessao
213
+ * despachada (`ORK_DISPATCH_ID` no env do despacho). Sem um dos dois, o `--settings` sai como antes.
214
+ */
215
+ function entradaDoDespacho(mods, env) {
216
+ if (!mods.some((m) => m.nome === exports.MOD_DA_ENTREGA))
217
+ return null;
218
+ const despacho = env?.[runtime_ambiente_1.ENV_IDENTIDADE_DE_DESPACHO];
219
+ return typeof despacho === 'string' && despacho.trim() !== '' ? { crossSessionInbound: 'accept' } : null;
220
+ }
201
221
  /** Monta a linha de comando exata do despacho (usada tambem pelo `--dry-run`). */
202
222
  function montarComando(pedido) {
203
223
  const args = ['--bg', pedido.prompt, '--name', pedido.nome];
@@ -219,12 +239,14 @@ function montarComando(pedido) {
219
239
  : modsParaOClaude(contexto.modsDeFase, pedido.versaoClaude !== undefined ? pedido.versaoClaude : versao());
220
240
  // RM-059 (T10.4): agent teams so no piloto, com os tetos no env e o Portao na sessao; sem eles, o --settings de antes.
221
241
  const teams = agentTeamsDoDespacho(contexto?.agentTeams, mods);
242
+ // RM-059 (T9.4): a resposta do dono pelo Mensageiro so na sessao despachada e com ele na sessao.
243
+ const entrada = entradaDoDespacho(mods, pedido.ambienteExtra);
222
244
  const doDespacho = { ...(pedido.ambienteExtra ?? {}), ...(teams ? teams.env : {}) };
223
245
  if (Object.keys(doDespacho).length) {
224
- args.push('--settings', JSON.stringify(teams ? { env: doDespacho, teammateMode: teams.teammateMode } : { env: doDespacho }));
246
+ args.push('--settings', JSON.stringify({ env: doDespacho, ...(teams ? { teammateMode: teams.teammateMode } : {}), ...(entrada ?? {}) }));
225
247
  }
226
248
  if (contexto) {
227
- const consultas = [...CONSULTAS_MCP, ...(contexto.grafoMcp ? consultasDoGrafoMcp() : [])];
249
+ const consultas = [...exports.CONSULTAS_MCP, ...(contexto.grafoMcp ? consultasDoGrafoMcp() : [])];
228
250
  // Somente o servidor gerado: nao mesclar MCP de outros escopos nesta sessao filha.
229
251
  const permissoes = contexto.permissoesFilho === 'worktree'
230
252
  ? permissoesDaWorktree(pedido.cwd, contexto.permiteEditarProduto && !plano, consultas) : null;
@@ -665,6 +687,7 @@ exports.JANELA_CURTA_MAX_MS = 15 * 60 * 1000;
665
687
  const FRASES_DE_ESGOTAMENTO = [
666
688
  /\busage_limit_exceeded\b/i,
667
689
  /\busage_limit_reached\b/i,
690
+ /seu limite de uso foi atingido/i,
668
691
  /\bout of credits\b/i,
669
692
  /\binsufficient_quota\b/i,
670
693
  /exceeded your current quota/i,
@@ -748,6 +771,37 @@ function parseFalhaDeConta(saida, agoraMs = Date.now()) {
748
771
  const ampla = FRASES_AMPLAS_DE_AUTH.find((r) => r.test(texto));
749
772
  return ampla ? { motivo: 'runtime.auth-missing', resetEm: null, fonte: 'sem-horario', trecho: trechoDa(texto, ampla) } : null;
750
773
  }
774
+ const objeto = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
775
+ const numeroFinito = (v) => typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : null;
776
+ /** Formatos estruturados aceitos quando `auth status --json` traz uso; chaves alheias não viram medida. */
777
+ function cotaExpostaDoAuth(dados) {
778
+ if (!objeto(dados))
779
+ return null;
780
+ const candidato = ['quota', 'usage', 'rateLimit'].map((k) => dados[k]).find(objeto);
781
+ if (!candidato)
782
+ return null;
783
+ let limite = numeroFinito(candidato.limit ?? candidato.total ?? candidato.max);
784
+ let usada = numeroFinito(candidato.used ?? candidato.consumed ?? candidato.current);
785
+ const restanteInformada = numeroFinito(candidato.remaining);
786
+ const percentual = numeroFinito(candidato.percentUsed ?? candidato.utilization);
787
+ let emPercentual = false;
788
+ if (limite === null && percentual !== null && percentual <= 100) {
789
+ limite = 100;
790
+ usada = percentual;
791
+ emPercentual = true;
792
+ }
793
+ if (limite !== null && usada === null && restanteInformada !== null)
794
+ usada = Math.max(0, limite - restanteInformada);
795
+ if (limite === null || usada === null || limite <= 0 || usada > limite)
796
+ return null;
797
+ const unidadeBruta = candidato.unit ?? candidato.unidade;
798
+ // O nome da unidade que o runtime não informa é texto de quem lê: sai do catálogo, não daqui.
799
+ const informada = typeof unidadeBruta === 'string' ? unidadeBruta.replace(/[^a-zA-Z0-9%._-]/g, '').slice(0, 24) : '';
800
+ const unidade = informada || (emPercentual ? '%' : null);
801
+ const resetBruto = candidato.resetsAt ?? candidato.resetAt ?? candidato.resetEm;
802
+ const resetEm = typeof resetBruto === 'string' && Number.isFinite(Date.parse(resetBruto)) ? resetBruto : null;
803
+ return { usada, limite, restante: Math.max(0, limite - usada), unidade, resetEm, fonte: 'runtime' };
804
+ }
751
805
  /** Campo textual do `auth status`, sem controle e curto, para o detalhe legivel. */
752
806
  const campoDeAuth = (v) => typeof v === 'string' ? v.replace(/[^a-zA-Z0-9_.-]/g, '').slice(0, 32) : '';
753
807
  /**
@@ -759,11 +813,12 @@ const campoDeAuth = (v) => typeof v === 'string' ? v.replace(/[^a-zA-Z0-9_.-]/g,
759
813
  */
760
814
  function conferirAuth(perfil) {
761
815
  let ambiente;
816
+ // RM-061 (F3b, GO-FIX 1): o erro do catalogo fica registrado, e a impressao o remonta.
762
817
  try {
763
818
  ambiente = ambienteDoPerfil(perfil);
764
819
  }
765
820
  catch (e) {
766
- return { ok: false, detalhe: e.message };
821
+ return { ok: false, detalhe: (0, locale_1.textoDoErro)(e) };
767
822
  }
768
823
  const r = exec('claude', ['auth', 'status', '--json'], undefined, 30000, ambiente);
769
824
  // A14: sem codigo de saida (timeout, sinal ou binario ausente) ou sem JSON, a conferencia e inconclusiva.
@@ -788,7 +843,8 @@ function conferirAuth(perfil) {
788
843
  ...(provedor && provedor !== 'firstParty' ? [`apiProvider ${provedor}`] : [])];
789
844
  return { ok: false, pago: true, detalhe: `claude auth status: provider pago (${partes.join(', ')}); so a assinatura claude.ai despacha` };
790
845
  }
791
- return { ok: true, detalhe: `claude auth status: loggedIn (${metodo})` };
846
+ const cota = cotaExpostaDoAuth(dados);
847
+ return { ok: true, detalhe: `claude auth status: loggedIn (${metodo})`, ...(cota ? { cota } : {}) };
792
848
  }
793
849
  /**
794
850
  * Comando de anexar a sessao (precisa de TTY, entao o CLI imprime em vez de executar). RM-037
@@ -946,3 +1002,61 @@ function ocupacaoDeContexto(chave) {
946
1002
  void chave;
947
1003
  return null;
948
1004
  }
1005
+ /** O `status` e o `stop` do daemon nao esperam um daemon travado por minutos. */
1006
+ exports.PRAZO_DO_DAEMON_MS = 20_000;
1007
+ const linhaCurta = (texto) => texto.replace(/\p{Cc}/gu, ' ').replace(/\s+/g, ' ').trim().slice(0, 160);
1008
+ /**
1009
+ * A saida do `claude daemon status` (medida em 12/10/2026 na 2.1.296): `pid:` com o daemon de pe ou `not running`,
1010
+ * e a linha `control.sock: reachable` ou `control.sock: unreachable (...)`. O daemon de pe com o socket que nao
1011
+ * responde e o travado do incidente; sem daemon, o `claude --bg` sobe um sob demanda. Saida fora dessa forma e
1012
+ * `nao-lido`: sem prova, nada e derrubado.
1013
+ */
1014
+ function lerStatusDoDaemon(saida, codigo) {
1015
+ const texto = String(saida ?? '').replace(/\r/g, '');
1016
+ const sock = /^\s*control\.sock:\s*(.+)$/m.exec(texto)?.[1]?.trim() ?? '';
1017
+ const dePe = /^\s*pid:\s*\d+/m.test(texto);
1018
+ const parado = /^\s*not running\b/im.test(texto);
1019
+ const detalhe = sock ? linhaCurta(`control.sock: ${sock}`) : linhaCurta(texto.split('\n').find((l) => l.trim()) ?? '');
1020
+ if (codigo !== 0 || !sock || dePe === parado) {
1021
+ return { estado: 'nao-lido', detalhe: `claude daemon status sem a forma conhecida (codigo ${codigo ?? '?'})${detalhe ? `: ${detalhe}` : ''}` };
1022
+ }
1023
+ if (/^reachable\b/i.test(sock))
1024
+ return dePe ? { estado: 'responde', detalhe } : { estado: 'nao-lido', detalhe };
1025
+ if (/^unreachable\b/i.test(sock))
1026
+ return { estado: dePe ? 'nao-responde' : 'parado', detalhe };
1027
+ return { estado: 'nao-lido', detalhe };
1028
+ }
1029
+ /** `claude daemon status` com o ambiente do perfil do despacho: a conta certa, o daemon certo. */
1030
+ function sondarDaemon(perfil) {
1031
+ let ambiente;
1032
+ try {
1033
+ ambiente = ambienteDoPerfil(perfil);
1034
+ }
1035
+ catch (e) {
1036
+ return { estado: 'nao-lido', detalhe: linhaCurta(e.message) };
1037
+ }
1038
+ const r = exec('claude', ['daemon', 'status'], undefined, exports.PRAZO_DO_DAEMON_MS, ambiente);
1039
+ if (r.error === 'ENOENT')
1040
+ return { estado: 'nao-lido', detalhe: 'binario `claude` nao encontrado no PATH' };
1041
+ if (r.error || r.signal)
1042
+ return { estado: 'nao-lido', detalhe: `claude daemon status nao terminou em ${exports.PRAZO_DO_DAEMON_MS / 1000} s` };
1043
+ return lerStatusDoDaemon(`${r.stdout}\n${r.stderr}`, r.code);
1044
+ }
1045
+ /**
1046
+ * `claude daemon stop --any --keep-workers`: derruba o supervisor transitorio da conta (o que o `claude --bg` subiu
1047
+ * sob demanda) e deixa as sessoes destacadas rodando. O proximo `claude --bg` sobe outro.
1048
+ */
1049
+ function derrubarDaemon(perfil) {
1050
+ let ambiente;
1051
+ try {
1052
+ ambiente = ambienteDoPerfil(perfil);
1053
+ }
1054
+ catch (e) {
1055
+ return { ok: false, detalhe: linhaCurta(e.message) };
1056
+ }
1057
+ const r = exec('claude', ['daemon', 'stop', '--any', '--keep-workers'], undefined, exports.PRAZO_DO_DAEMON_MS, ambiente);
1058
+ const primeira = linhaCurta(`${r.stdout}\n${r.stderr}`.split('\n').find((l) => l.trim()) ?? '');
1059
+ return { ok: r.ok, detalhe: r.ok ? primeira || 'daemon parado' : `saiu ${r.error ?? r.code}${primeira ? `: ${primeira}` : ''}` };
1060
+ }
1061
+ /** O daemon do claude-bg que a escada usa quando ninguem injeta outro. */
1062
+ exports.DAEMON_DO_CLAUDE = { sondar: sondarDaemon, derrubar: derrubarDaemon };
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.interromperTurnoAtivo = interromperTurnoAtivo;
36
37
  /** Dono exclusivo do stdin app-server. IPC local autenticado pelo uid/diretório 0700. */
37
38
  const fs = __importStar(require("node:fs"));
38
39
  const net = __importStar(require("node:net"));
@@ -42,6 +43,16 @@ const node_crypto_1 = require("node:crypto");
42
43
  const codex_question_1 = require("./codex-question");
43
44
  const runtime_context_1 = require("../runtime-context");
44
45
  const codex_controller_1 = require("./codex-controller");
46
+ /** RM-064: interrupção nativa testável sem descobrir PID, sessão ou turno fora do controller vinculado. */
47
+ async function interromperTurnoAtivo(state, sessao, perguntaAtiva, enviar, esperar) {
48
+ const bloqueioDivergente = state.estado === 'blocked' && (!perguntaAtiva || sessao.bloqueio !== state.bloqueio);
49
+ if (!['working', 'blocked'].includes(state.estado) || sessao.estado !== state.estado || !state.turno ||
50
+ sessao.sessionId !== state.sessionId || sessao.instancia !== state.instancia || sessao.cwd !== state.cwd ||
51
+ bloqueioDivergente)
52
+ throw new Error('runtime.unavailable: sessão não está ativa nesta instância');
53
+ await enviar('turn/interrupt', { threadId: state.sessionId, turnId: state.turno });
54
+ await esperar(() => state.estado === 'stopped');
55
+ }
45
56
  function gravar(nome, valor) {
46
57
  const tmp = `${nome}.${(0, node_crypto_1.randomUUID)()}.tmp`;
47
58
  fs.writeFileSync(tmp, JSON.stringify(valor), { flag: 'wx', mode: 0o600 });
@@ -246,11 +257,7 @@ async function servidor() {
246
257
  }
247
258
  else if (r.operacao === 'parar') {
248
259
  const s = r.dados;
249
- if (!pergunta || state.estado !== 'blocked' || s.sessionId !== state.sessionId || s.instancia !== state.instancia ||
250
- s.cwd !== state.cwd || s.bloqueio !== state.bloqueio)
251
- throw new Error('runtime.unavailable: sessão não está bloqueada nesta instância');
252
- await rpc('turn/interrupt', { threadId: state.sessionId, turnId: state.turno });
253
- await aguardar(() => state.estado === 'stopped');
260
+ await interromperTurnoAtivo(state, s, !!pergunta, rpc, aguardar);
254
261
  resultado = true;
255
262
  }
256
263
  else
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParserCodex = exports.LIMITE_LINHA_CODEX = void 0;
3
+ exports.ParserCodex = exports.LIMITE_RESPOSTA_CODEX = exports.LIMITE_LINHA_CODEX = void 0;
4
4
  exports.falhaDeContaDoErroCodex = falhaDeContaDoErroCodex;
5
5
  exports.classificarMensagem = classificarMensagem;
6
6
  /** D4/D5: stream e rollout são observações de turno, nunca aprovação de CHECK. */
@@ -84,6 +84,15 @@ function tokens(v, fonte, escopo) {
84
84
  output: Number(output), total: Number(total), unidade: 'tokens', escopo, fonte };
85
85
  }
86
86
  exports.LIMITE_LINHA_CODEX = 1024 * 1024;
87
+ exports.LIMITE_RESPOSTA_CODEX = 256 * 1024;
88
+ function limitarResposta(texto) {
89
+ if (typeof texto !== 'string' || !texto.trim())
90
+ return null;
91
+ const bruto = Buffer.from(texto, 'utf8');
92
+ if (bruto.byteLength <= exports.LIMITE_RESPOSTA_CODEX)
93
+ return texto;
94
+ return bruto.subarray(0, exports.LIMITE_RESPOSTA_CODEX).toString('utf8').replace(/\uFFFD$/, '');
95
+ }
87
96
  class ParserCodex {
88
97
  pendente = Buffer.alloc(0);
89
98
  descartando = false;
@@ -154,6 +163,7 @@ class ParserCodex {
154
163
  this.estado.turnId = daFonte ?? `stream-${this.estado.turnos}`;
155
164
  this.estado.turnIdOrigem = daFonte === null ? 'gerado' : 'explicito';
156
165
  this.estado.mensagem = null;
166
+ this.estado.mensagemTexto = null;
157
167
  this.estado.tokens = indisponivel();
158
168
  this.eventosValidos++;
159
169
  return null;
@@ -177,6 +187,7 @@ class ParserCodex {
177
187
  p.type === 'agent_message' ? p.message : undefined);
178
188
  if (mensagem !== undefined) {
179
189
  this.estado.mensagem = classificarMensagem(mensagem);
190
+ this.estado.mensagemTexto = limitarResposta(mensagem);
180
191
  this.eventosValidos++;
181
192
  return null;
182
193
  }
@@ -189,8 +200,8 @@ class ParserCodex {
189
200
  const falhou = p.type === 'turn.failed' || p.type === 'task_failed' || comErro;
190
201
  const conta = comErro ? falhaDeContaDoErroCodex(p.error, agoraMs) : null;
191
202
  const explicito = motivo(p.motivo ?? p.reason);
192
- const mensagemFinal = typeof p.last_agent_message === 'string' && p.last_agent_message.trim()
193
- ? classificarMensagem(p.last_agent_message) : this.estado.mensagem ?? sucesso();
203
+ const textoFinal = limitarResposta(p.last_agent_message) ?? this.estado.mensagemTexto ?? null;
204
+ const mensagemFinal = textoFinal !== null ? classificarMensagem(textoFinal) : this.estado.mensagem ?? sucesso();
194
205
  const classificacao = this.estado.invalido ? falha()
195
206
  : conta ? { classificacao: 'gate_blocked', motivo: conta.motivo } : explicito ??
196
207
  (mensagemFinal.classificacao !== 'fase_concluida' ? mensagemFinal : falhou ? falha() : sucesso());
@@ -201,7 +212,8 @@ class ParserCodex {
201
212
  numeroTurno: this.estado.turnos, timestampFonte: e.timestamp ? 'evento' : 'observacao',
202
213
  fonte: e.type === 'event_msg' ? `rollout.${p.type}` : `stream.${p.type}`,
203
214
  tokens: structuredClone(this.estado.tokens),
204
- duracaoMs: Number.isFinite(p.duration_ms) && p.duration_ms >= 0 ? p.duration_ms : null };
215
+ duracaoMs: Number.isFinite(p.duration_ms) && p.duration_ms >= 0 ? p.duration_ms : null,
216
+ ...(textoFinal !== null ? { respostaFinal: textoFinal } : {}) };
205
217
  }
206
218
  }
207
219
  exports.ParserCodex = ParserCodex;
@@ -59,6 +59,7 @@ const util_1 = require("../util");
59
59
  const runtime_ambiente_1 = require("../runtime-ambiente");
60
60
  const claude_bg_1 = require("./claude-bg");
61
61
  const runtime_profiles_1 = require("../runtime-profiles");
62
+ const locale_1 = require("../locale");
62
63
  exports.NOME_ADAPTER = 'codex';
63
64
  /**
64
65
  * Variaveis que REDIRECIONAM o codex para um provider pago por token.
@@ -114,11 +115,12 @@ function casaDoCodex(perfil) {
114
115
  */
115
116
  function conferirAuth(perfil) {
116
117
  let ambiente;
118
+ // RM-061 (F3b, GO-FIX 1): o erro do catalogo fica registrado, e a impressao o remonta.
117
119
  try {
118
120
  ambiente = ambienteDoDespacho(process.env, perfil);
119
121
  }
120
122
  catch (e) {
121
- return { ok: false, detalhe: e.message };
123
+ return { ok: false, detalhe: (0, locale_1.textoDoErro)(e) };
122
124
  }
123
125
  const r = exec('codex', ['login', 'status'], undefined, 30000, ambiente);
124
126
  // A14: sem codigo de saida (timeout, sinal ou binario ausente), a conferencia e inconclusiva.