@orkastery/cli 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/README.md +18 -0
- package/adapters/claude-code/.claude-plugin/plugin.json +1 -0
- package/adapters/claude-code/README.md +37 -5
- package/adapters/claude-code/agents/ork-check.md +1 -0
- package/adapters/claude-code/agents/ork-go.md +1 -0
- package/adapters/claude-code/agents/ork-goal.md +1 -0
- package/adapters/claude-code/agents/ork-master.md +1 -0
- package/adapters/claude-code/agents/ork-plan.md +1 -0
- package/adapters/claude-code/agents/ork-ship.md +1 -0
- package/adapters/claude-code/hooks/hooks.json +2 -1
- package/adapters/claude-code/hooks/ork-guard.js +15 -1
- package/adapters/claude-code/hooks/ork-resposta.js +91 -0
- package/adapters/claude-code/hooks/ork-sensor.js +18 -2
- package/adapters/claude-code/hooks/quota-signal.js +14 -0
- package/adapters/claude-code/mods/ork-mensageiro/.claude-plugin/plugin.json +14 -0
- package/adapters/claude-code/mods/ork-mensageiro/hooks/caixa.ts +215 -0
- package/adapters/claude-code/mods/ork-mensageiro/hooks/hooks.json +3 -0
- package/adapters/claude-code/mods/ork-mensageiro/hooks/painel.tsx +165 -0
- package/adapters/claude-code/mods/ork-mensageiro/hooks/recepcao.ts +256 -0
- package/adapters/claude-code/mods/ork-mensageiro/hooks/register.tsx +481 -0
- package/adapters/claude-code/mods/ork-mensageiro/orkastery-mod.json +5 -0
- package/adapters/claude-code/mods/ork-mensageiro/types/index.d.ts +85 -0
- package/adapters/claude-code/mods/ork-pista/hooks/ci.ts +9 -5
- package/adapters/claude-code/mods/ork-ritual/.claude-plugin/plugin.json +14 -0
- package/adapters/claude-code/mods/ork-ritual/hooks/hooks.json +3 -0
- package/adapters/claude-code/mods/ork-ritual/hooks/nota.ts +88 -0
- package/adapters/claude-code/mods/ork-ritual/hooks/register.tsx +494 -0
- package/adapters/claude-code/mods/ork-ritual/hooks/replay.tsx +271 -0
- package/adapters/claude-code/mods/ork-ritual/hooks/ritual.ts +218 -0
- package/adapters/claude-code/mods/ork-ritual/orkastery-mod.json +5 -0
- package/adapters/claude-code/mods/ork-ritual/types/index.d.ts +106 -0
- package/adapters/claude-code/mods/ork-sentinela/hooks/vigia.ts +1 -1
- package/adapters/codex/skills/ork/SKILL.md +2 -0
- package/adapters/hermes/README.md +64 -1
- package/adapters/hermes/bin/ork-conhecimento-colecoes.sh +14 -0
- package/adapters/hermes/bin/ork-conhecimento-listar.sh +15 -0
- package/adapters/hermes/bin/ork-conhecimento-mostrar.sh +16 -0
- package/adapters/hermes/bin/ork-conhecimento-verificar.sh +15 -0
- package/adapters/hermes/bin/ork-vigia-batida.py +127 -0
- package/adapters/hermes/hermes.plugin.json +4 -0
- package/adapters/hermes/hitl-ingress/__init__.py +101 -8
- package/adapters/hermes/skills/orkastery-devmaster/SKILL.md +2 -2
- package/adapters/openclaw/README.md +81 -9
- package/adapters/openclaw/bin/ork-vigia-batida.js +86 -0
- package/adapters/openclaw/dist/hitl-ingress.js +106 -9
- package/adapters/openclaw/dist/index.js +86 -0
- package/adapters/openclaw/openclaw.plugin.json +34 -4
- package/adapters/openclaw/package.json +2 -2
- package/adapters/openclaw/src/hitl-ingress.ts +103 -9
- package/adapters/openclaw/src/index.ts +94 -0
- package/assets/adapters-en/claude-code/README.md +403 -0
- package/assets/adapters-en/claude-code/agents/ork-check.md +33 -0
- package/assets/adapters-en/claude-code/agents/ork-go.md +33 -0
- package/assets/adapters-en/claude-code/agents/ork-goal.md +34 -0
- package/assets/adapters-en/claude-code/agents/ork-master.md +35 -0
- package/assets/adapters-en/claude-code/agents/ork-plan.md +33 -0
- package/assets/adapters-en/claude-code/agents/ork-ship.md +33 -0
- package/assets/adapters-en/claude-code/commands/check.md +46 -0
- package/assets/adapters-en/claude-code/commands/go.md +46 -0
- package/assets/adapters-en/claude-code/commands/goal.md +55 -0
- package/assets/adapters-en/claude-code/commands/master.md +54 -0
- package/assets/adapters-en/claude-code/commands/onboarding.md +22 -0
- package/assets/adapters-en/claude-code/commands/ork.md +126 -0
- package/assets/adapters-en/claude-code/commands/plan.md +47 -0
- package/assets/adapters-en/claude-code/commands/ship.md +45 -0
- package/assets/adapters-en/codex/skills/ork/SKILL.md +85 -0
- package/assets/adapters-en/hermes/README.md +273 -0
- package/assets/adapters-en/hermes/skills/orkastery-devmaster/SKILL.md +169 -0
- package/assets/references-en/README.md +25 -0
- package/assets/references-en/code-review-axes.md +82 -0
- package/assets/references-en/definition-of-done.md +74 -0
- package/assets/references-en/performance-checklist.md +53 -0
- package/assets/references-en/security-checklist.md +101 -0
- package/assets/references-en/testing-patterns.md +51 -0
- package/assets/security-scan/defaults/.golangci.yml +2 -0
- package/assets/security-scan/defaults/eslint.config.mjs +11 -0
- package/assets/security-scan/defaults/gitleaks.toml +3 -0
- package/assets/security-scan/defaults/ruff.toml +1 -0
- package/assets/security-scan/tools-agil.json +87 -0
- package/assets/security-scan/tools.json +625 -0
- package/assets/skills-en/core/onboarding/SKILL.md +58 -0
- package/assets/skills-en/core/orkastery-bootstrap/SKILL.md +119 -0
- package/assets/skills-en/core/thread-state/SKILL.md +88 -0
- package/assets/skills-en/governance/decision-triage/SKILL.md +65 -0
- package/assets/skills-en/governance/narrative-guardian/SKILL.md +66 -0
- package/assets/skills-en/governance/roadmap-keeper/SKILL.md +60 -0
- package/assets/skills-en/governance/scope-check-capability-map/SKILL.md +71 -0
- package/assets/skills-en/observability/thread-tracing/SKILL.md +63 -0
- package/assets/skills-en/phases/check-quality/SKILL.md +103 -0
- package/assets/skills-en/phases/go-implementation/SKILL.md +78 -0
- package/assets/skills-en/phases/goal-definition/SKILL.md +69 -0
- package/assets/skills-en/phases/master-metrics/SKILL.md +72 -0
- package/assets/skills-en/phases/plan-specification/SKILL.md +67 -0
- package/assets/skills-en/phases/security-remediation/SKILL.md +70 -0
- package/assets/skills-en/phases/ship-release/SKILL.md +71 -0
- package/assets/skills-en/reviewers/code-reviewer/SKILL.md +61 -0
- package/assets/skills-en/reviewers/security-auditor/SKILL.md +93 -0
- package/assets/skills-en/reviewers/test-engineer/SKILL.md +66 -0
- package/assets/skills-en/reviewers/web-performance-auditor/SKILL.md +63 -0
- package/dist/adapters/claude-bg.js +118 -4
- package/dist/adapters/codex-controller-worker.js +12 -5
- package/dist/adapters/codex-events.js +16 -4
- package/dist/adapters/codex.js +3 -1
- package/dist/atualizar-branch.js +245 -0
- package/dist/auditoria.js +13 -11
- package/dist/auditrun.js +51 -46
- package/dist/autorizacao-duravel.js +327 -0
- package/dist/board.js +94 -40
- package/dist/branch-de-estado.js +16 -8
- package/dist/busca-semantica.js +7 -5
- package/dist/catalogo.js +2 -1
- package/dist/changelog-reconciliacao.js +290 -0
- package/dist/check-agil.js +500 -0
- package/dist/check-modo.js +41 -0
- package/dist/check-paralelo.js +183 -0
- package/dist/ci.js +248 -45
- package/dist/ciclos.js +8 -6
- package/dist/claim-lint.js +12 -8
- package/dist/claims-conferir.js +47 -39
- package/dist/claims.js +10 -9
- package/dist/company-brain-client.js +10 -3
- package/dist/company-brain-migration.js +11 -5
- package/dist/conducao-batida.js +759 -0
- package/dist/conducao-sentinela.js +25 -8
- package/dist/conducao.js +84 -29
- package/dist/conhecimento-consulta.js +270 -0
- package/dist/conhecimento.js +111 -87
- package/dist/conta-esgotada.js +127 -0
- package/dist/dado-privado.js +816 -0
- package/dist/decisao-autonoma.js +5 -4
- package/dist/demo.js +14 -12
- package/dist/dependencias-da-worktree.js +25 -0
- package/dist/divida.js +38 -36
- package/dist/docs.js +81 -74
- package/dist/doctor-forja.js +345 -0
- package/dist/doctor-pulse-cron.js +113 -1
- package/dist/doctor.js +164 -6
- package/dist/dsn-da-memoria.js +417 -0
- package/dist/entrega-por-mod.js +503 -0
- package/dist/entrega-pr.js +143 -43
- package/dist/esgotamentos.js +13 -11
- package/dist/estado-thread.js +21 -18
- package/dist/evalrunner.js +35 -32
- package/dist/fabrica-batida.js +34 -21
- package/dist/fabrica-estado.js +13 -10
- package/dist/fix.js +21 -19
- package/dist/forja/adaptador.js +6 -0
- package/dist/forja/ambiente-de-ci.js +27 -0
- package/dist/forja/api.js +256 -0
- package/dist/forja/cache.js +89 -0
- package/dist/forja/cli.js +60 -0
- package/dist/forja/contrato.js +9 -0
- package/dist/forja/endereco.js +43 -0
- package/dist/forja/estado.js +22 -0
- package/dist/forja/executor.js +73 -0
- package/dist/forja/github/ci.js +95 -0
- package/dist/forja/github/dono-da-rede.js +18 -0
- package/dist/forja/github/metadados.js +15 -0
- package/dist/forja/github/pedidos.js +200 -0
- package/dist/forja/gitlab/ci.js +141 -0
- package/dist/forja/gitlab/consultas.js +59 -0
- package/dist/forja/gitlab/dono-da-rede.js +43 -0
- package/dist/forja/gitlab/metadados.js +15 -0
- package/dist/forja/gitlab/pedidos-abertos.js +158 -0
- package/dist/forja/gitlab/pedidos.js +141 -0
- package/dist/forja/produtor.js +32 -0
- package/dist/forja/registro.js +31 -0
- package/dist/forja/resolver.js +121 -0
- package/dist/forja/texto.js +13 -0
- package/dist/forja/versao.js +71 -0
- package/dist/forja.js +123 -80
- package/dist/handoff.js +23 -13
- package/dist/hitl-contract.js +46 -43
- package/dist/hitl-curto.js +37 -25
- package/dist/hitl-gates.js +13 -11
- package/dist/hitl-local-receipt.js +51 -0
- package/dist/hitl-local.js +11 -2
- package/dist/hitl-lock.js +5 -11
- package/dist/hitl-public-receipt.js +11 -0
- package/dist/hitl-resumo.js +44 -1
- package/dist/hitl-sessions.js +62 -9
- package/dist/hitl-texto-livre.js +7 -4
- package/dist/hitl.js +34 -31
- package/dist/horario.js +16 -0
- package/dist/hosts.js +104 -134
- package/dist/index.js +848 -548
- package/dist/indice-vetorial.js +14 -12
- package/dist/init.js +11 -2
- package/dist/integracoes-locais.js +2 -0
- package/dist/intelligence-graph-cli.js +123 -69
- package/dist/intelligence-graph-query.js +37 -22
- package/dist/leases.js +19 -18
- package/dist/ledger-stats.js +17 -16
- package/dist/ledger.js +31 -1
- package/dist/licoes.js +12 -11
- package/dist/locale-accounts.js +220 -0
- package/dist/locale-adapter.js +291 -0
- package/dist/locale-ajuda.js +76 -4
- package/dist/locale-audit.js +199 -0
- package/dist/locale-claims.js +213 -0
- package/dist/locale-conducao.js +138 -0
- package/dist/locale-conhecimento.js +181 -0
- package/dist/locale-decisao.js +205 -0
- package/dist/locale-docs.js +230 -0
- package/dist/locale-estado.js +101 -0
- package/dist/locale-forja.js +290 -0
- package/dist/locale-gerados.js +5 -0
- package/dist/locale-grafo.js +129 -0
- package/dist/locale-master.js +83 -0
- package/dist/locale-network.js +524 -0
- package/dist/locale-operacao-restante.js +931 -0
- package/dist/locale-projetos.js +100 -0
- package/dist/locale-prompts.js +194 -0
- package/dist/locale-pulse.js +140 -2
- package/dist/locale-reservas.js +87 -0
- package/dist/locale-retry.js +145 -6
- package/dist/locale-security-scan.js +69 -0
- package/dist/locale-setup.js +192 -0
- package/dist/locale-ship.js +169 -66
- package/dist/locale-thread.js +149 -5
- package/dist/locale-verify.js +80 -4
- package/dist/locale-worktree.js +246 -0
- package/dist/locale.js +553 -9
- package/dist/maestro-runtime.js +22 -3
- package/dist/manifest.js +287 -11
- package/dist/maquina-ociosa.js +211 -0
- package/dist/maquina.js +10 -5
- package/dist/master-nota-local.js +200 -0
- package/dist/master-nota.js +10 -2
- package/dist/master.js +118 -41
- package/dist/mcp-conhecimento.js +52 -0
- package/dist/mcp-experiencia.js +26 -5
- package/dist/mcp-install.js +73 -8
- package/dist/mcp-noctum.js +101 -0
- package/dist/mcp-server.js +82 -14
- package/dist/mcp-ship-transporte.js +977 -0
- package/dist/mcp-ship.js +68 -24
- package/dist/mcp-transportes.js +17 -0
- package/dist/memoria.js +63 -58
- package/dist/modos-migracao.js +8 -6
- package/dist/modos.js +17 -18
- package/dist/network-roadmap.js +85 -49
- package/dist/noctum-aceite.js +789 -0
- package/dist/noctum-arco.js +540 -33
- package/dist/noctum-capacidade.js +3 -3
- package/dist/noctum-changelog.js +399 -0
- package/dist/noctum-cli.js +482 -0
- package/dist/noctum-coordenacao.js +1225 -0
- package/dist/noctum-entrega.js +1169 -0
- package/dist/noctum-envelope.js +252 -16
- package/dist/noctum-execucao.js +95 -23
- package/dist/noctum-fechamento.js +405 -0
- package/dist/noctum-fila.js +43 -9
- package/dist/noctum-guarda.js +256 -0
- package/dist/noctum-integracao.js +507 -0
- package/dist/noctum-maquinas.js +383 -0
- package/dist/noctum-medicao.js +450 -0
- package/dist/noctum-modo.js +362 -0
- package/dist/noctum-pergunta-canal.js +96 -0
- package/dist/noctum-pergunta.js +115 -0
- package/dist/noctum-provas.js +838 -0
- package/dist/noctum-reconciliacao.js +591 -0
- package/dist/noctum-registro.js +215 -0
- package/dist/noctum-relatorio.js +827 -0
- package/dist/noctum-resposta.js +207 -0
- package/dist/noctum-sessoes-em-voo.js +93 -0
- package/dist/noctum-supervisao.js +649 -0
- package/dist/noctum-terminal.js +459 -0
- package/dist/noctum-transporte.js +655 -0
- package/dist/noctum-vigia.js +639 -0
- package/dist/ocupacao.js +3 -1
- package/dist/onboarding.js +16 -5
- package/dist/orkmind.js +39 -23
- package/dist/orquestracao.js +31 -35
- package/dist/parado-no-condutor.js +146 -124
- package/dist/phase.js +53 -27
- package/dist/policies.js +33 -0
- package/dist/postura-local.js +4 -3
- package/dist/procedencia.js +9 -14
- package/dist/projeto-alvo.js +59 -20
- package/dist/prompts.js +136 -42
- package/dist/prova-minima.js +5 -6
- package/dist/pulse-cadencia.js +5 -4
- package/dist/pulse-consentimento.js +53 -1
- package/dist/pulse-delivery.js +143 -27
- package/dist/pulse-resposta.js +368 -4
- package/dist/pulse.js +136 -3
- package/dist/ratelimit.js +12 -4
- package/dist/recall.js +14 -13
- package/dist/rede-adesao.js +13 -8
- package/dist/rede-forja.js +108 -24
- package/dist/rede-status.js +63 -45
- package/dist/rede.js +86 -46
- package/dist/retomada-checkpoint.js +101 -0
- package/dist/retry.js +228 -73
- package/dist/roadmap-reservas.js +32 -32
- package/dist/runtime-ambiente.js +5 -0
- package/dist/runtime-context.js +117 -43
- package/dist/runtime-escada.js +423 -0
- package/dist/runtime-profiles.js +103 -46
- package/dist/saida-segura.js +3 -2
- package/dist/security-scan/agil.js +355 -0
- package/dist/security-scan/cli.js +76 -0
- package/dist/security-scan/compare.js +149 -0
- package/dist/security-scan/config.js +93 -0
- package/dist/security-scan/detect.js +97 -0
- package/dist/security-scan/executor.js +188 -0
- package/dist/security-scan/guard.js +180 -0
- package/dist/security-scan/imagem-de-lint.js +96 -0
- package/dist/security-scan/normalize/actionlint.js +12 -0
- package/dist/security-scan/normalize/eslint.js +12 -0
- package/dist/security-scan/normalize/gitleaks.js +13 -0
- package/dist/security-scan/normalize/golangci-lint.js +13 -0
- package/dist/security-scan/normalize/govulncheck.js +36 -0
- package/dist/security-scan/normalize/index.js +25 -0
- package/dist/security-scan/normalize/npm-audit.js +30 -0
- package/dist/security-scan/normalize/osv-scanner.js +32 -0
- package/dist/security-scan/normalize/oxlint.js +51 -0
- package/dist/security-scan/normalize/pip-audit.js +16 -0
- package/dist/security-scan/normalize/ruff.js +12 -0
- package/dist/security-scan/normalize/semgrep.js +20 -0
- package/dist/security-scan/normalize/trivy.js +33 -0
- package/dist/security-scan/normalize/util.js +204 -0
- package/dist/security-scan/normalize/zizmor.js +19 -0
- package/dist/security-scan/report.js +156 -0
- package/dist/security-scan/run.js +448 -0
- package/dist/security-scan/tools.js +62 -0
- package/dist/security-scan/trabalhador.js +74 -0
- package/dist/security-scan/types.js +15 -0
- package/dist/session-events.js +19 -2
- package/dist/session-watcher-claude.js +74 -19
- package/dist/session-watcher.js +156 -10
- package/dist/sessoes-contas.js +9 -0
- package/dist/sessoes-inventario.js +1 -1
- package/dist/sessoes.js +25 -23
- package/dist/setup.js +59 -58
- package/dist/ship-publicar.js +263 -92
- package/dist/ship.js +160 -17
- package/dist/superficie.js +14 -11
- package/dist/thread-close.js +9 -9
- package/dist/thread.js +121 -18
- package/dist/tokens.js +15 -11
- package/dist/trabalho-thread.js +297 -0
- package/dist/transporte-do-canal.js +189 -0
- package/dist/types.js +12 -1
- package/dist/util.js +5 -2
- package/dist/varredura-acoes.js +507 -0
- package/dist/verify.js +472 -29
- package/dist/worktree-local.js +12 -10
- package/dist/worktree.js +81 -85
- package/eval/casos/check-quality.json +77 -0
- package/eval/casos/security-auditor.json +148 -0
- package/eval/casos/security-remediation.json +161 -0
- package/eval/fixtures/security-scan/README.md +8 -0
- package/eval/fixtures/security-scan/go/.github/workflows/ci.yml +12 -0
- package/eval/fixtures/security-scan/go/Dockerfile +4 -0
- package/eval/fixtures/security-scan/go/README.md +4 -0
- package/eval/fixtures/security-scan/go/config.go +4 -0
- package/eval/fixtures/security-scan/go/go.mod +5 -0
- package/eval/fixtures/security-scan/go/go.sum +2 -0
- package/eval/fixtures/security-scan/go/main.go +31 -0
- package/eval/fixtures/security-scan/js/.github/workflows/ci.yml +12 -0
- package/eval/fixtures/security-scan/js/Dockerfile +3 -0
- package/eval/fixtures/security-scan/js/README.md +4 -0
- package/eval/fixtures/security-scan/js/package-lock.json +844 -0
- package/eval/fixtures/security-scan/js/package.json +10 -0
- package/eval/fixtures/security-scan/js/src/config.js +4 -0
- package/eval/fixtures/security-scan/js/src/server.js +17 -0
- package/eval/fixtures/security-scan/js/src/util.ts +4 -0
- package/eval/fixtures/security-scan/js/tsconfig.json +4 -0
- package/eval/fixtures/security-scan/python/.github/workflows/ci.yml +12 -0
- package/eval/fixtures/security-scan/python/Dockerfile +3 -0
- package/eval/fixtures/security-scan/python/README.md +4 -0
- package/eval/fixtures/security-scan/python/app/__init__.py +0 -0
- package/eval/fixtures/security-scan/python/app/config.py +2 -0
- package/eval/fixtures/security-scan/python/app/main.py +19 -0
- package/eval/fixtures/security-scan/python/requirements.txt +1 -0
- package/package.json +9 -4
- package/references/security-checklist.md +3 -3
- package/skills/README.md +1 -0
- package/skills/core/orkastery-bootstrap/SKILL.md +2 -2
- package/skills/phases/check-quality/SKILL.md +16 -0
- package/skills/phases/go-implementation/SKILL.md +6 -0
- package/skills/phases/security-remediation/SKILL.md +70 -0
- package/skills/reviewers/security-auditor/SKILL.md +25 -0
package/dist/claim-lint.js
CHANGED
|
@@ -19,12 +19,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.analisarComando = analisarComando;
|
|
20
20
|
exports.analisarComandos = analisarComandos;
|
|
21
21
|
exports.linhaDoLintDeClaim = linhaDoLintDeClaim;
|
|
22
|
+
const locale_1 = require("./locale");
|
|
23
|
+
/**
|
|
24
|
+
* A correcao que vai ao `claims.jsonl` com o achado: dado gravado, sempre em pt-BR. Fatia 2 do ensaio da 0.5.0 (P6): ela
|
|
25
|
+
* vale para qualquer projeto. RM-061 (F3b): o texto mora no catalogo (`claims.correcoesDoLint`), e a impressao do
|
|
26
|
+
* `claims add` a mostra no locale do comando, pela regra.
|
|
27
|
+
*/
|
|
22
28
|
const CORRECAO = {
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
|
|
26
|
-
'sha-intermediario': 'ancore na base (`git diff "$(git merge-base origin/main HEAD)" HEAD`) ou prove ancestralidade com `git merge-base --is-ancestor <sha> HEAD`',
|
|
27
|
-
'contagem-de-commits': 'use `git merge-base --is-ancestor <commit> HEAD`: contagem de commits quebra com rebase e merge',
|
|
29
|
+
'suite-inteira': (0, locale_1.msg)('pt-BR').claims.correcoesDoLint['suite-inteira'],
|
|
30
|
+
'sha-intermediario': (0, locale_1.msg)('pt-BR').claims.correcoesDoLint['sha-intermediario'],
|
|
31
|
+
'contagem-de-commits': (0, locale_1.msg)('pt-BR').claims.correcoesDoLint['contagem-de-commits'],
|
|
28
32
|
};
|
|
29
33
|
/**
|
|
30
34
|
* (a) `npm [--prefix <dir>] [run] test` sem subcomando (`test:ci` nao casa) e sem arquivos
|
|
@@ -60,7 +64,7 @@ function analisarComandos(comandos) {
|
|
|
60
64
|
}
|
|
61
65
|
/** Uma linha por achado, para o terminal e para o ledger. */
|
|
62
66
|
function linhaDoLintDeClaim(claimId, a) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
67
|
+
// RM-061 (F3b): nome e correcao pela regra, no locale ativo. F3d (GO-FIX 1): o montador fica registrado, e o `ci prepare`,
|
|
68
|
+
// que grava a linha no ledger no escopo pt-BR, a remonta no locale do comando ao imprimir.
|
|
69
|
+
return (0, locale_1.textoDoCatalogo)((m) => m.claims.linhaDoLint(claimId, m.claims.nomesDoLint[a.regra] ?? a.regra, a.trecho, m.claims.correcoesDoLint[a.regra] ?? a.correcao));
|
|
66
70
|
}
|
package/dist/claims-conferir.js
CHANGED
|
@@ -65,6 +65,7 @@ const thread_1 = require("./thread");
|
|
|
65
65
|
const verify_1 = require("./verify");
|
|
66
66
|
const verify_sandbox_1 = require("./verify-sandbox");
|
|
67
67
|
const worktree_1 = require("./worktree");
|
|
68
|
+
const locale_1 = require("./locale");
|
|
68
69
|
exports.FORMATO_DA_CONFERENCIA = 'ork.claims-conferencia/v1';
|
|
69
70
|
/** O prazo total do `ork_verify` pelo MCP: a conferencia e pontual e nao deve demorar mais que ele. */
|
|
70
71
|
exports.PRAZO_PADRAO_MS = 180_000;
|
|
@@ -74,21 +75,22 @@ const PRAZO_MINIMO_MS = 10_000;
|
|
|
74
75
|
/** Folga para fechar o sandbox e responder dentro do prazo pedido. */
|
|
75
76
|
const RESERVA_MS = 5_000;
|
|
76
77
|
/** Erro de uso tipado: o CLI sai 2 com ele. */
|
|
77
|
-
class ErroDeConferencia extends
|
|
78
|
+
class ErroDeConferencia extends locale_1.ErroDoCatalogo {
|
|
78
79
|
}
|
|
79
80
|
exports.ErroDeConferencia = ErroDeConferencia;
|
|
80
|
-
|
|
81
|
+
/** RM-061 (F3b): a recusa nasce do catalogo; o `--json` a leva como nasceu e o texto a remonta no locale do comando. */
|
|
82
|
+
const recusa = (motivo, detalhe) => new ErroDeConferencia((m) => m.claims.recusa(motivo, detalhe(m.claims)));
|
|
81
83
|
/** `C3,C7, c9` vira `['C3', 'C7', 'C9']`, sem repeticao e na ordem pedida. */
|
|
82
84
|
function idsDeClaims(bruto) {
|
|
83
85
|
const ids = bruto.split(',').map((s) => s.trim().toUpperCase()).filter(Boolean);
|
|
84
86
|
if (!ids.length)
|
|
85
|
-
throw recusa('uso',
|
|
87
|
+
throw recusa('uso', (m) => m.semClaims);
|
|
86
88
|
const invalido = ids.find((id) => !/^C\d+$/.test(id));
|
|
87
89
|
if (invalido)
|
|
88
|
-
throw recusa('uso',
|
|
90
|
+
throw recusa('uso', (m) => m.idInvalido(invalido));
|
|
89
91
|
const repetido = ids.find((id, i) => ids.indexOf(id) !== i);
|
|
90
92
|
if (repetido)
|
|
91
|
-
throw recusa('repetida',
|
|
93
|
+
throw recusa('repetida', (m) => m.repetida(repetido));
|
|
92
94
|
return ids;
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
@@ -131,7 +133,7 @@ function itemDoVerify(bloco, k, inicio) {
|
|
|
131
133
|
function verifyDaTarefa(plano, tarefaBruta) {
|
|
132
134
|
const id = tarefaBruta.trim().replace(/^T/i, '');
|
|
133
135
|
if (!/^\d+(?:\.\d+)*$/.test(id))
|
|
134
|
-
throw recusa('uso',
|
|
136
|
+
throw recusa('uso', (m) => m.tarefaInvalida(tarefaBruta));
|
|
135
137
|
const tarefa = `T${id}`;
|
|
136
138
|
const linhas = plano.replace(/\r\n/g, '\n').split('\n');
|
|
137
139
|
const cabecalho = /^(#{2,6})\s+T(\d+(?:\.\d+)*)(?=[\s.:)]|$)/;
|
|
@@ -140,9 +142,9 @@ function verifyDaTarefa(plano, tarefaBruta) {
|
|
|
140
142
|
return m && m[2] === id ? [{ i, nivel: m[1].length }] : [];
|
|
141
143
|
});
|
|
142
144
|
if (inicios.length === 0)
|
|
143
|
-
throw recusa('tarefa-ausente',
|
|
145
|
+
throw recusa('tarefa-ausente', (m) => m.tarefaAusente(tarefa));
|
|
144
146
|
if (inicios.length > 1)
|
|
145
|
-
throw recusa('tarefa-repetida',
|
|
147
|
+
throw recusa('tarefa-repetida', (m) => m.tarefaRepetida(inicios.length, tarefa));
|
|
146
148
|
const { i, nivel } = inicios[0];
|
|
147
149
|
const fimDoBloco = linhas.findIndex((l, j) => j > i && new RegExp(`^#{1,${nivel}}\\s`).test(l));
|
|
148
150
|
const bloco = linhas.slice(i + 1, fimDoBloco < 0 ? undefined : fimDoBloco);
|
|
@@ -151,17 +153,16 @@ function verifyDaTarefa(plano, tarefaBruta) {
|
|
|
151
153
|
return m ? [itemDoVerify(bloco, k, m[1].trim())] : [];
|
|
152
154
|
});
|
|
153
155
|
if (verifies.length === 0)
|
|
154
|
-
throw recusa('tarefa-sem-verify',
|
|
156
|
+
throw recusa('tarefa-sem-verify', (m) => m.tarefaSemVerify(tarefa));
|
|
155
157
|
if (verifies.length > 1)
|
|
156
|
-
throw recusa('tarefa-ambigua',
|
|
158
|
+
throw recusa('tarefa-ambigua', (m) => m.tarefaAmbigua(tarefa, verifies.length));
|
|
157
159
|
const resto = verifies[0];
|
|
158
160
|
const trechos = [...resto.matchAll(/`([^`]+)`/g)].length;
|
|
159
161
|
if (trechos === 0)
|
|
160
|
-
throw recusa('tarefa-sem-comando',
|
|
162
|
+
throw recusa('tarefa-sem-comando', (m) => m.tarefaSemComando(tarefa, resto.slice(0, 120)));
|
|
161
163
|
const unico = /^`([^`]+)`\s*\.?$/.exec(resto);
|
|
162
164
|
if (!unico || !unico[1].trim()) {
|
|
163
|
-
throw recusa('tarefa-ambigua',
|
|
164
|
-
`(${resto.slice(0, 120)}); a conferencia nao escolhe qual pedaco rodar`);
|
|
165
|
+
throw recusa('tarefa-ambigua', (m) => m.tarefaVariosTrechos(tarefa, trechos, resto.slice(0, 120)));
|
|
165
166
|
}
|
|
166
167
|
return { tarefa, comando: unico[1].trim() };
|
|
167
168
|
}
|
|
@@ -180,12 +181,12 @@ function lerPlano(raiz, threadId) {
|
|
|
180
181
|
catch (e) {
|
|
181
182
|
if (e.code === 'ENOENT')
|
|
182
183
|
return null;
|
|
183
|
-
throw recusa('plano-inseguro',
|
|
184
|
+
throw recusa('plano-inseguro', (m) => m.planoNaoAbre);
|
|
184
185
|
}
|
|
185
186
|
try {
|
|
186
187
|
const st = fs.fstatSync(fd);
|
|
187
188
|
if (!st.isFile() || st.size > LIMITE_DO_PLANO)
|
|
188
|
-
throw recusa('plano-inseguro',
|
|
189
|
+
throw recusa('plano-inseguro', (m) => m.planoGrande);
|
|
189
190
|
const bytes = fs.readFileSync(fd);
|
|
190
191
|
return { arquivo: 'docs/plan.md', sha256: (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex'), conteudo: bytes.toString('utf8') };
|
|
191
192
|
}
|
|
@@ -201,20 +202,20 @@ function lerPlano(raiz, threadId) {
|
|
|
201
202
|
*/
|
|
202
203
|
function worktreeConferida(raiz, thread) {
|
|
203
204
|
if (!thread.worktree)
|
|
204
|
-
throw recusa('sem-worktree',
|
|
205
|
+
throw recusa('sem-worktree', (m) => m.semWorktree(thread.id));
|
|
205
206
|
let dir;
|
|
206
207
|
try {
|
|
207
208
|
dir = fs.realpathSync(thread.worktree);
|
|
208
209
|
}
|
|
209
210
|
catch {
|
|
210
|
-
throw recusa('worktree-ausente',
|
|
211
|
+
throw recusa('worktree-ausente', (m) => m.worktreeAusente(thread.id));
|
|
211
212
|
}
|
|
212
213
|
const projeto = fs.realpathSync((0, estado_thread_1.raizDoEstado)(raiz));
|
|
213
214
|
if (!dir.startsWith(projeto + path.sep))
|
|
214
|
-
throw recusa('worktree-fora-do-projeto',
|
|
215
|
+
throw recusa('worktree-fora-do-projeto', (m) => m.worktreeFora(thread.id));
|
|
215
216
|
const branch = (0, worktree_1.branchDaWorktree)(thread);
|
|
216
217
|
if (!(0, worktree_1.worktreesDoGit)(projeto).some((w) => w.dir === dir && w.branch === branch))
|
|
217
|
-
throw recusa('worktree-nao-registrada',
|
|
218
|
+
throw recusa('worktree-nao-registrada', (m) => m.worktreeNaoRegistrada(thread.id, branch));
|
|
218
219
|
return dir;
|
|
219
220
|
}
|
|
220
221
|
/** A fabrica padrao: o sandbox do codex, um por comando, como o `ork_verify`. */
|
|
@@ -225,7 +226,9 @@ function confinado(fabrica, worktree, timeoutMs) {
|
|
|
225
226
|
return fabrica(worktree, timeoutMs);
|
|
226
227
|
}
|
|
227
228
|
catch (e) {
|
|
228
|
-
|
|
229
|
+
// RM-061 (F3b, GO-FIX 1): o erro do catalogo guarda o montador; o do executor sai traduzido pela frase exata.
|
|
230
|
+
const erro = e instanceof locale_1.ErroDoCatalogo ? e.montar : (m) => m.claims.erroDoSandbox(e.message);
|
|
231
|
+
throw new ErroDeConferencia((m) => m.claims.recusa('sandbox-indisponivel', m.claims.sandboxIndisponivel(erro(m))));
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
function conferida(r) {
|
|
@@ -241,15 +244,15 @@ function conferida(r) {
|
|
|
241
244
|
function conferirClaims(carregado, threadId, pedido) {
|
|
242
245
|
const { raiz, manifesto } = carregado;
|
|
243
246
|
if (!pedido.claims === !pedido.tarefa)
|
|
244
|
-
throw recusa('uso',
|
|
247
|
+
throw recusa('uso', (m) => m.claimsOuTarefa);
|
|
245
248
|
const prazoTotalMs = pedido.prazoMs ?? exports.PRAZO_PADRAO_MS;
|
|
246
249
|
if (!Number.isInteger(prazoTotalMs) || prazoTotalMs < PRAZO_MINIMO_MS || prazoTotalMs > exports.PRAZO_MAXIMO_MS)
|
|
247
|
-
throw recusa('prazo',
|
|
250
|
+
throw recusa('prazo', (m) => m.prazo(PRAZO_MINIMO_MS / 1000, exports.PRAZO_MAXIMO_MS / 1000));
|
|
248
251
|
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/.test(threadId) || !fs.existsSync((0, thread_1.caminhoThread)(raiz, threadId)))
|
|
249
|
-
throw recusa('thread-ausente',
|
|
252
|
+
throw recusa('thread-ausente', (m) => m.threadAusente(threadId));
|
|
250
253
|
const thread = (0, thread_1.lerThread)(raiz, threadId);
|
|
251
254
|
if (thread.status === 'fechada')
|
|
252
|
-
throw recusa('thread-fechada',
|
|
255
|
+
throw recusa('thread-fechada', (m) => m.threadFechada(threadId));
|
|
253
256
|
const cwd = worktreeConferida(raiz, thread);
|
|
254
257
|
// O que vai rodar, inteiro resolvido antes de tomar a conducao: recusa de uso nao toca a worktree.
|
|
255
258
|
let alvo;
|
|
@@ -260,9 +263,11 @@ function conferirClaims(carregado, threadId, pedido) {
|
|
|
260
263
|
selecionadas = ids.map((id) => {
|
|
261
264
|
const claim = todas.find((c) => c.id === id);
|
|
262
265
|
if (!claim)
|
|
263
|
-
throw recusa('desconhecida',
|
|
264
|
-
if (claim.estado === 'retirada')
|
|
265
|
-
|
|
266
|
+
throw recusa('desconhecida', (m) => m.desconhecida(id, threadId));
|
|
267
|
+
if (claim.estado === 'retirada') {
|
|
268
|
+
const motivo = claim.motivoDaRetirada;
|
|
269
|
+
throw recusa('retirada', (m) => m.retiradaNaConferencia(id, motivo));
|
|
270
|
+
}
|
|
266
271
|
return claim;
|
|
267
272
|
});
|
|
268
273
|
alvo = { tipo: 'claims', ids };
|
|
@@ -270,9 +275,10 @@ function conferirClaims(carregado, threadId, pedido) {
|
|
|
270
275
|
else {
|
|
271
276
|
const plano = lerPlano(raiz, threadId);
|
|
272
277
|
if (!plano)
|
|
273
|
-
throw recusa('plano-ausente',
|
|
278
|
+
throw recusa('plano-ausente', (m) => m.planoAusente(threadId));
|
|
274
279
|
const { tarefa, comando } = verifyDaTarefa(plano.conteudo, pedido.tarefa);
|
|
275
|
-
|
|
280
|
+
// RM-061 (F3b, GO-FIX 1): a alegacao sintetica nasce pelo catalogo (pt-BR no `--json`) e o texto a remonta.
|
|
281
|
+
selecionadas = [{ id: tarefa, thread: threadId, fase: null, arquivo: plano.arquivo, alegacao: (0, locale_1.textoDoCatalogo)((m) => m.claims.verifyDaTarefa(tarefa)),
|
|
276
282
|
negativa: false, verificar: [comando], criadoEm: '', estado: 'pendente' }];
|
|
277
283
|
alvo = { tipo: 'tarefa', tarefa, plano: { arquivo: plano.arquivo, sha256: plano.sha256 }, comando };
|
|
278
284
|
}
|
|
@@ -291,7 +297,7 @@ function conferirClaims(carregado, threadId, pedido) {
|
|
|
291
297
|
const executor = (nome, comando, dir) => {
|
|
292
298
|
const restante = prazoFinal - Date.now() - RESERVA_MS;
|
|
293
299
|
if (restante < 100) {
|
|
294
|
-
return { nome, comando, ok: false, code: -1, executado: false, resumo:
|
|
300
|
+
return { nome, comando, ok: false, code: -1, executado: false, resumo: (0, locale_1.textoDoCatalogo)((m) => m.claims.prazoEsgotado) };
|
|
295
301
|
}
|
|
296
302
|
const prazoMs = Math.min((0, verify_1.prazoDoComando)(manifesto, nome), restante);
|
|
297
303
|
tomada.renovar(prazoMs);
|
|
@@ -320,23 +326,25 @@ function conferirClaims(carregado, threadId, pedido) {
|
|
|
320
326
|
}
|
|
321
327
|
/** Texto de `ork claims conferir`, para quem roda no terminal. */
|
|
322
328
|
function textoDaConferencia(r) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
linhas
|
|
329
|
+
// RM-061 (F3b): a moldura pelo catalogo; o detalhe de cada claim (montado em pt-BR, como o --json o leva) remontado.
|
|
330
|
+
const m = (0, locale_1.msg)().claims;
|
|
331
|
+
const linhas = [m.conferencia(r.thread)];
|
|
332
|
+
linhas.push(m.headReal(r.commit));
|
|
333
|
+
linhas.push(m.executor(r.executor, Math.round(r.prazoTotalMs / 1000)));
|
|
326
334
|
linhas.push(r.alvo.tipo === 'claims'
|
|
327
|
-
?
|
|
328
|
-
:
|
|
335
|
+
? m.alvoClaims(r.alvo.ids.join(', '))
|
|
336
|
+
: m.alvoTarefa(r.alvo.tarefa, r.alvo.plano.sha256.slice(0, 12), r.alvo.comando));
|
|
329
337
|
linhas.push('');
|
|
330
338
|
for (const i of r.itens) {
|
|
331
|
-
linhas.push(
|
|
339
|
+
linhas.push(m.item(i.id, i.verificado, i.motivo, (0, locale_1.remontar)(i.alegacao)));
|
|
332
340
|
if (!i.verificado) {
|
|
333
|
-
linhas.push(` ${i.detalhe}`);
|
|
341
|
+
linhas.push(` ${(0, locale_1.remontar)(i.detalhe)}`);
|
|
334
342
|
const falhou = i.execucoes.find((e) => !e.ok);
|
|
335
343
|
if (falhou?.fim)
|
|
336
|
-
linhas.push(...falhou.fim.split('\n').map((l) => ` | ${l}`));
|
|
344
|
+
linhas.push(...(0, locale_1.remontar)(falhou.fim).split('\n').map((l) => ` | ${l}`));
|
|
337
345
|
}
|
|
338
346
|
}
|
|
339
347
|
linhas.push('');
|
|
340
|
-
linhas.push(r.ok ?
|
|
348
|
+
linhas.push(r.ok ? m.tudoPassou : m.naoPassou(r.motivos.join(', ')));
|
|
341
349
|
return linhas.join('\n');
|
|
342
350
|
}
|
package/dist/claims.js
CHANGED
|
@@ -68,6 +68,7 @@ const policies_1 = require("./policies");
|
|
|
68
68
|
const verify_1 = require("./verify");
|
|
69
69
|
const util_1 = require("./util");
|
|
70
70
|
const claim_lint_1 = require("./claim-lint");
|
|
71
|
+
const locale_1 = require("./locale");
|
|
71
72
|
/** Caminho do `claims.jsonl` da thread (append-only, como o ledger). */
|
|
72
73
|
function caminhoClaims(raiz, threadId) {
|
|
73
74
|
return path.join((0, thread_1.dirThread)(raiz, threadId), 'claims.jsonl');
|
|
@@ -250,7 +251,7 @@ function registrarCriteriosDePronto(raiz, threadId) {
|
|
|
250
251
|
function exigirClaim(raiz, threadId, claimId) {
|
|
251
252
|
const claim = lerClaims(raiz, threadId).find((c) => c.id === claimId);
|
|
252
253
|
if (!claim) {
|
|
253
|
-
throw new
|
|
254
|
+
throw new locale_1.ErroDoCatalogo((m) => m.claims.naoExiste(claimId, threadId));
|
|
254
255
|
}
|
|
255
256
|
return claim;
|
|
256
257
|
}
|
|
@@ -309,18 +310,18 @@ function carimbarEstado(raiz, claim, estado) {
|
|
|
309
310
|
/** Tabela de `ork claims list`. */
|
|
310
311
|
function tabelaDeClaims(raiz, threadId) {
|
|
311
312
|
const claims = lerClaims(raiz, threadId);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
313
|
+
// RM-061 (F3b): o texto pelo catalogo; o estado (dado do `claims.jsonl`) so se traduz aqui, pelo id.
|
|
314
|
+
const m = (0, locale_1.msg)().claims;
|
|
315
|
+
if (claims.length === 0)
|
|
316
|
+
return m.listaVazia(threadId);
|
|
316
317
|
const linhas = claims.map((c) => [
|
|
317
318
|
c.id,
|
|
318
319
|
c.fase ?? '-',
|
|
319
|
-
c.estado,
|
|
320
|
-
c.negativa ?
|
|
320
|
+
m.estado(c.estado),
|
|
321
|
+
c.negativa ? m.sim : m.nao,
|
|
321
322
|
c.arquivo,
|
|
322
|
-
c.verificar.join(' && ') ||
|
|
323
|
+
c.verificar.join(' && ') || m.semComando,
|
|
323
324
|
c.alegacao,
|
|
324
325
|
]);
|
|
325
|
-
return (0, util_1.tabela)([
|
|
326
|
+
return (0, util_1.tabela)([...m.colunas], linhas);
|
|
326
327
|
}
|
|
@@ -40,6 +40,7 @@ const os = __importStar(require("node:os"));
|
|
|
40
40
|
const node_child_process_1 = require("node:child_process");
|
|
41
41
|
const project_state_1 = require("./project-state");
|
|
42
42
|
const company_brain_contract_1 = require("./company-brain-contract");
|
|
43
|
+
const dsn_da_memoria_1 = require("./dsn-da-memoria");
|
|
43
44
|
exports.BRAIN_API = 'orkmind.company-brain-api/v1';
|
|
44
45
|
function validateRequest(value) {
|
|
45
46
|
if (!value || typeof value !== 'object' || Array.isArray(value) || value.schema !== exports.BRAIN_API ||
|
|
@@ -64,21 +65,27 @@ function brainClient(loaded, execute = node_child_process_1.spawnSync) {
|
|
|
64
65
|
return raw => {
|
|
65
66
|
const request = validateRequest(raw);
|
|
66
67
|
const unavailable = (error) => ({ schema: exports.BRAIN_API, state: 'unavailable', error });
|
|
67
|
-
|
|
68
|
+
// RM-069: a DSN pelo resolvedor unico, no momento do pedido (a variavel ou o arquivo da pasta de segredos).
|
|
69
|
+
const dsn = (0, dsn_da_memoria_1.resolverDsn)(config).dsn;
|
|
68
70
|
if (config.mode !== 'orkmind' || (!dsn && request.operation !== 'capabilities'))
|
|
69
71
|
return unavailable('brain.configuration.missing');
|
|
70
72
|
const payload = request.payload;
|
|
71
73
|
if (payload?.tenant_id !== undefined && payload.tenant_id !== config.tenant)
|
|
72
74
|
return { schema: exports.BRAIN_API, state: 'forbidden', error: 'brain.tenant.mismatch' };
|
|
73
75
|
// RM-047: cwd fora do clone; um nome de interpretador em memory.cli não acha arquivo do repositório.
|
|
74
|
-
|
|
76
|
+
// RM-026 K7 (fatia 2, CHECK): timeout_ms fora da faixa (0, negativo, fração) vale o padrão de 15 s, nunca espera sem prazo.
|
|
77
|
+
const prazo = Number.isFinite(config.timeout_ms) && config.timeout_ms >= 1 ? Math.min(Math.floor(config.timeout_ms), 15000) : 15000;
|
|
78
|
+
const result = execute(config.cli, ['brain', 'request'], { cwd: os.homedir(), encoding: 'utf8', timeout: prazo,
|
|
75
79
|
maxBuffer: 2 * 1024 * 1024, input: JSON.stringify(request), shell: false,
|
|
76
80
|
env: { PATH: process.env.PATH ?? '/usr/bin:/bin', PYTHONDONTWRITEBYTECODE: '1',
|
|
77
|
-
ORKMIND_DATABASE_URL: dsn
|
|
81
|
+
ORKMIND_DATABASE_URL: dsn, ORKMIND_BRAIN_TENANT: config.tenant } });
|
|
78
82
|
if (result.error || result.signal)
|
|
79
83
|
return unavailable('brain.transport.unavailable');
|
|
80
84
|
try {
|
|
81
85
|
const response = JSON.parse(String(result.stdout));
|
|
86
|
+
// RM-069 (D21): a resposta que repete a DSN ou a senha dela nunca sai do cliente; recusada inteira, sem o valor.
|
|
87
|
+
if ((0, dsn_da_memoria_1.contemFragmentoDaDsn)(response, dsn))
|
|
88
|
+
return unavailable('brain.transport.secret');
|
|
82
89
|
if (response.schema !== exports.BRAIN_API || !['ok', 'empty', 'unknown', 'unavailable', 'withheld', 'forbidden', 'conflict'].includes(response.state))
|
|
83
90
|
throw Error();
|
|
84
91
|
if (response.state === 'ok' && result.status !== 0)
|
|
@@ -43,25 +43,31 @@ const portfolio_1 = require("./portfolio");
|
|
|
43
43
|
const company_brain_source_1 = require("./company-brain-source");
|
|
44
44
|
const company_brain_journal_1 = require("./company-brain-journal");
|
|
45
45
|
const company_brain_contract_1 = require("./company-brain-contract");
|
|
46
|
+
const dsn_da_memoria_1 = require("./dsn-da-memoria");
|
|
46
47
|
function brainAdmin(c) {
|
|
47
48
|
const config = (0, project_state_1.memoryState)(c).loaded.manifesto.memory;
|
|
48
49
|
return (operation, payload) => {
|
|
49
|
-
|
|
50
|
+
// RM-069: a DSN pelo resolvedor unico (a variavel ou o arquivo da pasta de segredos).
|
|
51
|
+
const dsn = (0, dsn_da_memoria_1.resolverDsn)(config).dsn;
|
|
50
52
|
if (config.mode !== 'orkmind' || !dsn)
|
|
51
53
|
throw Error('brain.configuration.missing');
|
|
52
54
|
// RM-047: cwd fora do clone; um nome de interpretador em memory.cli não acha arquivo do repositório.
|
|
53
55
|
const r = (0, node_child_process_1.spawnSync)(config.cli, ['brain', 'migration'], { cwd: os.homedir(), shell: false, encoding: 'utf8', timeout: Math.min(config.timeout_ms, 15000), maxBuffer: 2 * 1024 * 1024,
|
|
54
56
|
input: JSON.stringify({ schema: 'orkmind.company-brain-admin/v1', operation, payload }),
|
|
55
57
|
env: { PATH: process.env.PATH ?? '/usr/bin:/bin', PYTHONDONTWRITEBYTECODE: '1', ORKMIND_DATABASE_URL: dsn, ORKMIND_BRAIN_TENANT: config.tenant } });
|
|
58
|
+
let response;
|
|
56
59
|
try {
|
|
57
|
-
|
|
58
|
-
if (r.status !== 0 || response.state !== 'ok')
|
|
59
|
-
throw Error();
|
|
60
|
-
return response.result;
|
|
60
|
+
response = JSON.parse(r.stdout);
|
|
61
61
|
}
|
|
62
62
|
catch {
|
|
63
63
|
throw Error('brain.migration.unconfirmed');
|
|
64
64
|
}
|
|
65
|
+
// RM-069 (D21): a resposta que repete a DSN ou a senha dela nunca sai da migracao; recusada inteira, sem o valor.
|
|
66
|
+
if ((0, dsn_da_memoria_1.contemFragmentoDaDsn)(response, dsn))
|
|
67
|
+
throw Error('brain.migration.secret');
|
|
68
|
+
if (r.status !== 0 || response?.state !== 'ok')
|
|
69
|
+
throw Error('brain.migration.unconfirmed');
|
|
70
|
+
return response.result;
|
|
65
71
|
};
|
|
66
72
|
}
|
|
67
73
|
function reconcileBrain(c, scope, batch, transport = brainAdmin(c)) {
|