predators-protocol 0.3.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +104 -0
  3. package/bin/predators-cli.js +490 -0
  4. package/bundle/.claude/commands/auditoria-tubarao.md +104 -0
  5. package/bundle/.claude/commands/briefing.md +84 -0
  6. package/bundle/.claude/commands/cyber-squad.md +71 -0
  7. package/bundle/.claude/commands/encarnar.md +63 -0
  8. package/bundle/.claude/commands/onda-fenix.md +71 -0
  9. package/bundle/.claude/commands/predador.md +67 -0
  10. package/bundle/.claude/commands/synapse-trace.md +92 -0
  11. package/bundle/CLAUDE.md +373 -0
  12. package/bundle/QUICKSTART-SOCIO.md +45 -0
  13. package/bundle/docs/CANON/DIRETRIZ-1-LEI-DO-TOM-CONVERSACIONAL.md +77 -0
  14. package/bundle/docs/CANON/DIRETRIZ-2-AUTONOMIA-SEQUENCIAL-LEI-9.md +85 -0
  15. package/bundle/docs/CANON/DIRETRIZ-3-LEI-8-PASSO-0-EVERY-ONDA.md +69 -0
  16. package/bundle/docs/CANON/DIRETRIZ-4-SEPARACAO-CANON-DOC-COMUNICACAO-DIRETA.md +69 -0
  17. package/bundle/docs/CANON/LEI-14-PERFEITO-OU-FIX-GERAL.md +113 -0
  18. package/bundle/docs/CYBER_SQUAD.md +367 -0
  19. package/bundle/docs/ENCARNACAO.md +291 -0
  20. package/bundle/docs/SYNAPSE.md +241 -0
  21. package/bundle/predators/apex/aguia-real/constitution.md +330 -0
  22. package/bundle/predators/apex/aguia-real/predator.json +28 -0
  23. package/bundle/predators/apex/leao/constitution.md +283 -0
  24. package/bundle/predators/apex/leao/predator.json +34 -0
  25. package/bundle/predators/apex/orca/constitution.md +279 -0
  26. package/bundle/predators/apex/orca/predator.json +43 -0
  27. package/bundle/predators/apex/tigre-siberiano/constitution.md +276 -0
  28. package/bundle/predators/apex/tigre-siberiano/predator.json +37 -0
  29. package/bundle/predators/builder/camaleao/constitution.md +171 -0
  30. package/bundle/predators/builder/camaleao/predator.json +36 -0
  31. package/bundle/predators/builder/coruja/constitution.md +169 -0
  32. package/bundle/predators/builder/coruja/predator.json +38 -0
  33. package/bundle/predators/builder/falcao-peregrino/constitution.md +171 -0
  34. package/bundle/predators/builder/falcao-peregrino/predator.json +37 -0
  35. package/bundle/predators/builder/gaviao/constitution.md +169 -0
  36. package/bundle/predators/builder/gaviao/predator.json +38 -0
  37. package/bundle/predators/builder/jaguar/constitution.md +181 -0
  38. package/bundle/predators/builder/jaguar/predator.json +51 -0
  39. package/bundle/predators/builder/onca-pintada/constitution.md +175 -0
  40. package/bundle/predators/builder/onca-pintada/predator.json +38 -0
  41. package/bundle/predators/builder/pantera-negra/constitution.md +307 -0
  42. package/bundle/predators/builder/pantera-negra/predator.json +23 -0
  43. package/bundle/predators/builder/polvo/constitution.md +182 -0
  44. package/bundle/predators/builder/polvo/predator.json +37 -0
  45. package/bundle/predators/builder/tatu-bola/constitution.md +299 -0
  46. package/bundle/predators/builder/tatu-bola/predator.json +43 -0
  47. package/bundle/predators/copy/corvo/constitution.md +156 -0
  48. package/bundle/predators/copy/corvo/predator.json +40 -0
  49. package/bundle/predators/copy/golfinho/constitution.md +199 -0
  50. package/bundle/predators/copy/golfinho/predator.json +38 -0
  51. package/bundle/predators/copy/lobo-cinzento/constitution.md +209 -0
  52. package/bundle/predators/copy/lobo-cinzento/predator.json +37 -0
  53. package/bundle/predators/copy/papagaio/constitution.md +194 -0
  54. package/bundle/predators/copy/papagaio/predator.json +38 -0
  55. package/bundle/predators/copy/rouxinol/constitution.md +196 -0
  56. package/bundle/predators/copy/rouxinol/predator.json +37 -0
  57. package/bundle/predators/copy/serpente-coral/constitution.md +210 -0
  58. package/bundle/predators/copy/serpente-coral/predator.json +37 -0
  59. package/bundle/predators/designer/aguia-harpia/constitution.md +199 -0
  60. package/bundle/predators/designer/aguia-harpia/predator.json +45 -0
  61. package/bundle/predators/designer/aranha-tecela/constitution.md +173 -0
  62. package/bundle/predators/designer/aranha-tecela/predator.json +37 -0
  63. package/bundle/predators/designer/borboleta-azul/constitution.md +171 -0
  64. package/bundle/predators/designer/borboleta-azul/predator.json +35 -0
  65. package/bundle/predators/designer/cisne-negro/constitution.md +172 -0
  66. package/bundle/predators/designer/cisne-negro/predator.json +36 -0
  67. package/bundle/predators/designer/mantis/constitution.md +182 -0
  68. package/bundle/predators/designer/mantis/predator.json +37 -0
  69. package/bundle/predators/designer/pavao/constitution.md +167 -0
  70. package/bundle/predators/designer/pavao/predator.json +23 -0
  71. package/bundle/predators/designer/tucano-toco/constitution.md +357 -0
  72. package/bundle/predators/designer/tucano-toco/predator.json +51 -0
  73. package/bundle/predators/governance/cavalo-marinho/constitution.md +216 -0
  74. package/bundle/predators/governance/cavalo-marinho/predator.json +35 -0
  75. package/bundle/predators/governance/elefante/constitution.md +236 -0
  76. package/bundle/predators/governance/elefante/predator.json +23 -0
  77. package/bundle/predators/governance/gorila-prata/constitution.md +225 -0
  78. package/bundle/predators/governance/gorila-prata/predator.json +43 -0
  79. package/bundle/predators/governance/lince/constitution.md +224 -0
  80. package/bundle/predators/governance/lince/predator.json +35 -0
  81. package/bundle/predators/governance/raposa/constitution.md +213 -0
  82. package/bundle/predators/governance/raposa/predator.json +35 -0
  83. package/bundle/predators/governance/tartaruga-gigante/constitution.md +218 -0
  84. package/bundle/predators/governance/tartaruga-gigante/predator.json +35 -0
  85. package/bundle/predators/growth/abelha-rainha/constitution.md +222 -0
  86. package/bundle/predators/growth/abelha-rainha/predator.json +36 -0
  87. package/bundle/predators/growth/albatroz/constitution.md +218 -0
  88. package/bundle/predators/growth/albatroz/predator.json +36 -0
  89. package/bundle/predators/growth/condor/constitution.md +203 -0
  90. package/bundle/predators/growth/condor/predator.json +23 -0
  91. package/bundle/predators/growth/coruja-de-igreja/constitution.md +236 -0
  92. package/bundle/predators/growth/coruja-de-igreja/predator.json +36 -0
  93. package/bundle/predators/growth/formiga-sauva/constitution.md +243 -0
  94. package/bundle/predators/growth/formiga-sauva/predator.json +45 -0
  95. package/bundle/predators/growth/lobo-do-artico/constitution.md +229 -0
  96. package/bundle/predators/growth/lobo-do-artico/predator.json +36 -0
  97. package/bundle/predators/hunter/crocodilo/constitution.md +293 -0
  98. package/bundle/predators/hunter/crocodilo/predator.json +39 -0
  99. package/bundle/predators/hunter/escorpiao/constitution.md +327 -0
  100. package/bundle/predators/hunter/escorpiao/predator.json +34 -0
  101. package/bundle/predators/hunter/hiena/constitution.md +343 -0
  102. package/bundle/predators/hunter/hiena/predator.json +34 -0
  103. package/bundle/predators/hunter/piranha/constitution.md +283 -0
  104. package/bundle/predators/hunter/piranha/predator.json +35 -0
  105. package/bundle/predators/hunter/tubarao-branco/constitution.md +527 -0
  106. package/bundle/predators/hunter/tubarao-branco/predator.json +36 -0
  107. package/bundle/predators/intel/alcateia/constitution.md +217 -0
  108. package/bundle/predators/intel/alcateia/predator.json +35 -0
  109. package/bundle/predators/intel/guepardo/constitution.md +201 -0
  110. package/bundle/predators/intel/guepardo/predator.json +36 -0
  111. package/bundle/predators/intel/jiboia/constitution.md +243 -0
  112. package/bundle/predators/intel/jiboia/predator.json +38 -0
  113. package/bundle/predators/intel/lobo-solitario/constitution.md +275 -0
  114. package/bundle/predators/intel/lobo-solitario/predator.json +23 -0
  115. package/bundle/predators/intel/morcego/constitution.md +217 -0
  116. package/bundle/predators/intel/morcego/predator.json +35 -0
  117. package/bundle/predators/intel/pirarucu/constitution.md +309 -0
  118. package/bundle/predators/intel/pirarucu/predator.json +40 -0
  119. package/bundle/predators/intel/polvo-mimico/constitution.md +220 -0
  120. package/bundle/predators/intel/polvo-mimico/predator.json +35 -0
  121. package/bundle/predators/intel/tarantula/constitution.md +222 -0
  122. package/bundle/predators/intel/tarantula/predator.json +37 -0
  123. package/bundle/predators/meta/aranha-d-agua/constitution.md +264 -0
  124. package/bundle/predators/meta/aranha-d-agua/predator.json +37 -0
  125. package/bundle/predators/meta/camaleao-real/constitution.md +245 -0
  126. package/bundle/predators/meta/camaleao-real/predator.json +36 -0
  127. package/bundle/predators/meta/coruja-real/constitution.md +255 -0
  128. package/bundle/predators/meta/coruja-real/predator.json +36 -0
  129. package/bundle/predators/meta/dragao-ancestral/constitution.md +297 -0
  130. package/bundle/predators/meta/dragao-ancestral/predator.json +23 -0
  131. package/bundle/predators/meta/fenix/constitution.md +282 -0
  132. package/bundle/predators/meta/fenix/predator.json +35 -0
  133. package/bundle/predators/meta/lince-das-neves/constitution.md +252 -0
  134. package/bundle/predators/meta/lince-das-neves/predator.json +35 -0
  135. package/bundle/predators/web3/caranguejo-ferradura/constitution.md +245 -0
  136. package/bundle/predators/web3/caranguejo-ferradura/predator.json +36 -0
  137. package/bundle/predators/web3/medusa/constitution.md +236 -0
  138. package/bundle/predators/web3/medusa/predator.json +39 -0
  139. package/bundle/predators/web3/orca-alfa/constitution.md +227 -0
  140. package/bundle/predators/web3/orca-alfa/predator.json +23 -0
  141. package/bundle/predators/web3/polvo-gigante/constitution.md +240 -0
  142. package/bundle/predators/web3/polvo-gigante/predator.json +36 -0
  143. package/bundle/predators/web3/raia-eletrica/constitution.md +236 -0
  144. package/bundle/predators/web3/raia-eletrica/predator.json +36 -0
  145. package/bundle/predators/web3/tubarao-martelo/constitution.md +236 -0
  146. package/bundle/predators/web3/tubarao-martelo/predator.json +36 -0
  147. package/lib/ascii-art.js +224 -0
  148. package/lib/audio.js +137 -0
  149. package/lib/colors.js +168 -0
  150. package/lib/config.js +114 -0
  151. package/lib/spinners.js +146 -0
  152. package/lib/splash.js +114 -0
  153. package/package.json +51 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ PREDATORS PROTOCOL · PROPRIETARY LICENSE
2
+
3
+ Copyright (c) 2026 Alex Gonzaga (Tubarão-Apex)
4
+ All rights reserved.
5
+
6
+ This software and associated documentation files (the "Software") are the
7
+ proprietary and confidential property of Alex Gonzaga. Unauthorized copying,
8
+ distribution, modification, public display, public performance, or use of
9
+ this Software, via any medium, is strictly prohibited without the express
10
+ written permission of the copyright holder.
11
+
12
+ The receipt or possession of this Software does not convey any rights to
13
+ reproduce, disclose, or distribute its contents, or to manufacture, use,
14
+ or sell anything that it may describe, in whole or in part.
15
+
16
+ PREDATORS PROTOCOL is a trademark of Alex Gonzaga.
17
+
18
+ For licensing inquiries, contact: alex@predators-protocol.dev
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # Predators Protocol
2
+
3
+ > Multi-agent predatory framework · 63 predators in 10 layers · canon Lei #14 PERFEITO OU FIX-GERAL
4
+
5
+ **Proprietary software** · Copyright (c) 2026 Alex Gonzaga (Tubarão-Apex). See [LICENSE](./LICENSE) for terms.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ # One-off CLI invocation (no install)
11
+ npx predators-protocol help
12
+
13
+ # Global install
14
+ npm i -g predators-protocol
15
+ predators-protocol help
16
+ ```
17
+
18
+ ## Quickstart
19
+
20
+ ```bash
21
+ # Status + bundle integrity check
22
+ npx predators-protocol status
23
+
24
+ # Show 63 predators across 10 layers
25
+ npx predators-protocol list-predators
26
+
27
+ # List canon workflows
28
+ npx predators-protocol list-workflows
29
+
30
+ # State machine: 6 workflow states
31
+ npx predators-protocol workflow-states
32
+
33
+ # State machine: 5 story states
34
+ npx predators-protocol story-states
35
+
36
+ # 7 context layers L0-L6 (Lei do Sangue → user input)
37
+ npx predators-protocol layers-list
38
+
39
+ # 4 golden signals canon M1 APM
40
+ npx predators-protocol metrics-list
41
+
42
+ # Benchmark protocol scipy.stats N=180 p<0.05
43
+ npx predators-protocol benchmark-info
44
+
45
+ # Help
46
+ npx predators-protocol help
47
+ ```
48
+
49
+ ## Commands requiring Python 3.11+
50
+
51
+ Two commands invoke the bundled Python canon · install Python ≥ 3.11 and dependencies:
52
+
53
+ ```bash
54
+ # Required Python deps for pre-action
55
+ pip install structlog
56
+ ```
57
+
58
+ ```bash
59
+ # Validate canon IAC + canon-docs presence in bundle
60
+ npx predators-protocol validate
61
+
62
+ # Simulate dispatcher middleware pre-action canon
63
+ npx predators-protocol pre-action tubarao-branco
64
+ ```
65
+
66
+ The CLI auto-detects Python in this order: `PREDATORS_PYTHON` env var → repo `.venv/` (dev mode) → `python3` → `python`.
67
+
68
+ ## What's in the bundle
69
+
70
+ Each install includes:
71
+
72
+ - `docs/SYNAPSE.md` · canon do tecido nervoso (5 garantias)
73
+ - `docs/CANON/INTEGRA-PROD-*.md` · 5 canon-docs provisioning
74
+ - `core/synapse_overlay/` · 4 Python files dispatcher middleware canon
75
+ - `scripts/canon_provisioning_validation.py` · validation script
76
+ - `infra/` · IAC files (Docker compose · Terraform · SQL migrations · Infisical · Grafana)
77
+
78
+ ## Canon governance
79
+
80
+ This CLI is published under the canon laws of the Predators Protocol:
81
+
82
+ - **Lei #1 do Sangue** (immutable) · zero credentials in code · Tubarão-branco veto
83
+ - **Lei #4 Synapse** · 5 garantias (preservação contexto, integridade decisão, agent authority, rastro neural, realimentação)
84
+ - **Lei #14 PERFEITO OU FIX-GERAL** · BINARY veredict canon
85
+ - **Diretrizes Comunicação 4** (2026-05-24) · Lei do Tom · Autonomia Sequencial · PASSO 0 EVERY · Separação canon-doc/comunicação
86
+
87
+ ## Honest UPFRONT (Lei #11)
88
+
89
+ This is a **fase BETA** scope:
90
+
91
+ - Read-only query commands for canon state machines, middleware, metrics
92
+ - `pre-action` and `validate` require Python 3.11+ in the host environment
93
+ - Workflow execution + project init are roadmap (require Postgres provisioning)
94
+ - Real credential provisioning is Apex T7 direct (never via CLI)
95
+
96
+ ## Links
97
+
98
+ - Homepage: https://github.com/SharkLEx/predators-protocol
99
+ - Issues: https://github.com/SharkLEx/predators-protocol/issues
100
+ - License: SEE LICENSE IN LICENSE (Proprietary · Alex Gonzaga)
101
+
102
+ ---
103
+
104
+ *"Eu rugo no monte, mas só piso quando o terreno está limpo."* · Leão · Apex T5
@@ -0,0 +1,490 @@
1
+ #!/usr/bin/env node
2
+ // packages/predators-protocol/bin/predators-cli.js
3
+ // NPX CLI canon Predators Protocol · 11 comandos fase BETA cumulativa
4
+ // Lei #11 honest UPFRONT · Lei #14 PERFEITO OU FIX-GERAL · Lei #13 Pureza canon
5
+
6
+ "use strict";
7
+
8
+ const fs = require("fs");
9
+ const path = require("path");
10
+ const { spawnSync } = require("child_process");
11
+
12
+ const CLI_VERSION_CANON = "predators-cli-canon-0.3.0-beta.0-bundle-slim-sync-2026-05-24";
13
+
14
+ const PACKAGE_ROOT = path.resolve(__dirname, "..");
15
+ const BUNDLE_DIR = path.join(PACKAGE_ROOT, "bundle");
16
+ const LIB_DIR = path.join(PACKAGE_ROOT, "lib");
17
+
18
+ // UX layer (additive · Lei #4 byte-canon preserve · 11 comandos existentes inalterados)
19
+ let uxLib = null;
20
+ function loadUxLib() {
21
+ if (uxLib) return uxLib;
22
+ try {
23
+ uxLib = {
24
+ splash: require(path.join(LIB_DIR, "splash.js")),
25
+ config: require(path.join(LIB_DIR, "config.js")),
26
+ audio: require(path.join(LIB_DIR, "audio.js")),
27
+ colors: require(path.join(LIB_DIR, "colors.js")),
28
+ asciiArt: require(path.join(LIB_DIR, "ascii-art.js")),
29
+ spinners: require(path.join(LIB_DIR, "spinners.js")),
30
+ };
31
+ return uxLib;
32
+ } catch (err) {
33
+ return null;
34
+ }
35
+ }
36
+
37
+ function bundlePath(relPath) {
38
+ return path.join(BUNDLE_DIR, relPath);
39
+ }
40
+
41
+ function detectPythonCanon() {
42
+ // Priority: PREDATORS_PYTHON env override → repo .venv (if in dev) → python3 → python
43
+ const candidates = [];
44
+
45
+ if (process.env.PREDATORS_PYTHON && fs.existsSync(process.env.PREDATORS_PYTHON)) {
46
+ candidates.push(process.env.PREDATORS_PYTHON);
47
+ }
48
+
49
+ // Dev mode: if invoked from within Predators repo (next to .venv)
50
+ const devVenvWin = path.resolve(PACKAGE_ROOT, "..", "..", ".venv", "Scripts", "python.exe");
51
+ const devVenvUnix = path.resolve(PACKAGE_ROOT, "..", "..", ".venv", "bin", "python");
52
+ if (fs.existsSync(devVenvWin)) candidates.push(devVenvWin);
53
+ if (fs.existsSync(devVenvUnix)) candidates.push(devVenvUnix);
54
+
55
+ // System python
56
+ for (const cmd of ["python3", "python"]) {
57
+ const probe = spawnSync(cmd, ["--version"], { encoding: "utf8" });
58
+ if (probe.status === 0) {
59
+ candidates.push(cmd);
60
+ break;
61
+ }
62
+ }
63
+
64
+ return candidates.length > 0 ? candidates[0] : null;
65
+ }
66
+
67
+ function printHelpCanon() {
68
+ console.error(`
69
+ predators-cli · canon Predators NPX CLI 0.3.0-beta.0 (Lei #14 PERFEITO OU FIX-GERAL)
70
+
71
+ USO:
72
+ npx predators-protocol <comando>
73
+
74
+ COMANDOS canon vigentes (13 comandos):
75
+
76
+ -- fase 1 (introspecção · 3 comandos) --
77
+ version Exibe versão canon
78
+ status Estado atual canon · bundle integrity check
79
+ list-predators Lista 63 predadores frota canon vigente
80
+ list-workflows Lista 4 workflows canon (caca-sistematica · pacto-cyber-squad · pipeline-fenix · saneamento-brownfield)
81
+
82
+ -- fase BETA (state machines · 5 comandos) --
83
+ workflow-states Lista 6 WorkflowStateCanon (PENDING/SCHEDULED/RUNNING/COMPLETED/FAILED/PAUSED)
84
+ story-states Lista 5 StoryStateCanon (DRAFT/REFINEMENT/READY/IN_PROGRESS/DONE)
85
+ layers-list Lista 7 ContextLayerCanon L0-L6 (Lei do Sangue → user input)
86
+ benchmark-info Mostra benchmark scipy protocol canon (N=180 p<0.05)
87
+ metrics-list Lista 4 golden signals canon M1 APM (latency + traffic + errors + saturation)
88
+
89
+ -- fase UX (additive · Lei #4 byte-canon preserve · 4 comandos) --
90
+ init Splash cinematográfico primeira-conexão · welcome message
91
+ config Preferências user (theme · audio · splash)
92
+ show Renderiza ASCII art predator card OR The Eye logo
93
+ sync Sincroniza canon files (predators/ + docs/ + .claude/ + CLAUDE.md) do bundle NPX para CWD
94
+
95
+ help Exibe esta mensagem
96
+
97
+ Lei #11 honest UPFRONT 0.3.0-beta.0 cumulativa:
98
+ · Bundle slim · 143 files · 63 predadores + canon docs + 7 skills · ZERO infra leak audit (Lei #1 reign)
99
+ · sync command requer CWD contendo predators/ OU init flag · pattern canon partner-bundle
100
+ · Comandos removidos vs 0.2.0-beta.0: validate (lia infra) + pre-action (lia synapse_overlay) · ambos infra-leak
101
+ · Workflow execution + project init scope futuro (requer Postgres provisioning Apex T7)
102
+ `);
103
+ }
104
+
105
+ function printVersionCanon() {
106
+ console.log(CLI_VERSION_CANON);
107
+ }
108
+
109
+ function printStatusCanon() {
110
+ const synapseMd = bundlePath("docs/SYNAPSE.md");
111
+ const encarnacaoMd = bundlePath("docs/ENCARNACAO.md");
112
+ const claudeMd = bundlePath("CLAUDE.md");
113
+ const predatorsDir = bundlePath("predators");
114
+ const skillsDir = bundlePath(".claude/commands");
115
+ let predatorCount = 0;
116
+ if (fs.existsSync(predatorsDir)) {
117
+ const walk = (dir) => {
118
+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
119
+ const p = path.join(dir, e.name);
120
+ if (e.isDirectory()) walk(p);
121
+ else if (e.name === "predator.json") predatorCount++;
122
+ }
123
+ };
124
+ walk(predatorsDir);
125
+ }
126
+ console.log("canon Predators status:");
127
+ console.log(` CLI version: ${CLI_VERSION_CANON}`);
128
+ console.log(` bundle root: ${BUNDLE_DIR}`);
129
+ console.log(` CLAUDE.md: ${fs.existsSync(claudeMd) ? "PRESENT" : "MISSING"}`);
130
+ console.log(` SYNAPSE.md: ${fs.existsSync(synapseMd) ? "PRESENT" : "MISSING"}`);
131
+ console.log(` ENCARNACAO.md: ${fs.existsSync(encarnacaoMd) ? "PRESENT" : "MISSING"}`);
132
+ console.log(` predators canon: ${predatorCount}/63 byte-presente`);
133
+ console.log(` .claude/commands/: ${fs.existsSync(skillsDir) ? "PRESENT" : "MISSING"}`);
134
+ console.log(` Lei #14 canon: PERFEITO OU FIX-GERAL ratificada constitucional`);
135
+ console.log(` Lei #1 reign: bundle slim · ZERO infra leak audit (0.3.0-beta.0)`);
136
+ console.log(` Diretrizes 4 (2026-05-24): Lei do Tom · Autonomia Sequencial · PASSO 0 EVERY · Separação canon-doc/comunicação`);
137
+ }
138
+
139
+ function listPredatorsCanon() {
140
+ console.log("63 predadores frota canon vigente pós-F3 Tucano-toco:");
141
+ console.log(" apex: 4 (Águia + Leão + Orca + Tigre-siberiano)");
142
+ console.log(" hunter: 5 (Tubarão-branco JUIZ FINAL Art. 14 + Escorpião + Hiena + Crocodilo + Piranha)");
143
+ console.log(" builder: 9 (Jaguar + Tatu-bola + Coruja + Pirarucu + Lince + Polvo + 3)");
144
+ console.log(" designer: 7 (Borboleta-azul + Tucano-toco + 5)");
145
+ console.log(" copy: 6 (Serpente-coral + 5)");
146
+ console.log(" intel: 8 (Lobo-solitário + Tarântula + Jiboia + 5)");
147
+ console.log(" governance: 6");
148
+ console.log(" growth: 6");
149
+ console.log(" web3: 6 (Medusa + 5)");
150
+ console.log(" meta: 6 (Dragão-ancestral + Elefante + Fênix + Camaleão + Serpente + 1)");
151
+ }
152
+
153
+ function listWorkflowsCanon() {
154
+ console.log("4 workflows canon Predators (Lei #13 Pureza):");
155
+ console.log(" - caca-sistematica");
156
+ console.log(" - pacto-cyber-squad");
157
+ console.log(" - pipeline-fenix");
158
+ console.log(" - saneamento-brownfield");
159
+ }
160
+
161
+ function listWorkflowStatesCanon() {
162
+ console.log("6 WorkflowStateCanon canon Predators (D2 ETAPA 2 state machine):");
163
+ console.log(" PENDING · workflow definição cravada · zero execução");
164
+ console.log(" SCHEDULED · próxima execução planejada · cron canon");
165
+ console.log(" RUNNING · steps em execução runtime");
166
+ console.log(" COMPLETED · todos steps OK · success path");
167
+ console.log(" FAILED · step falhou · rollback canon");
168
+ console.log(" PAUSED · humano interrompeu · retomar manual");
169
+ console.log("");
170
+ console.log("7 transições válidas canon (Lei #4 reign state machine):");
171
+ console.log(" PENDING → SCHEDULED · SCHEDULED → RUNNING · RUNNING → COMPLETED");
172
+ console.log(" RUNNING → FAILED · RUNNING → PAUSED · PAUSED → RUNNING · FAILED → PENDING");
173
+ }
174
+
175
+ function listStoryStatesCanon() {
176
+ console.log("5 StoryStateCanon canon Predators (D3 ETAPA 3 state machine):");
177
+ console.log(" DRAFT · criação inicial · briefing parcial");
178
+ console.log(" REFINEMENT · briefing completo · Águia preside refinamento");
179
+ console.log(" READY · predator owner identificado · scope clear");
180
+ console.log(" IN_PROGRESS · predator encarnado executando");
181
+ console.log(" DONE · 5 garantias entregues · audit Tubarão PASS");
182
+ console.log("");
183
+ console.log("7 transições válidas canon:");
184
+ console.log(" DRAFT → REFINEMENT → READY → IN_PROGRESS → DONE (caminho canônico)");
185
+ console.log(" REFINEMENT/READY/IN_PROGRESS → DRAFT (rejeição com feedback)");
186
+ }
187
+
188
+ function listLayersCanon() {
189
+ console.log("7 ContextLayerCanon L0-L6 canon Predators (D5 ETAPA 1 runtime middleware):");
190
+ console.log(" L0 LEI_DO_SANGUE_ART_1 · CRITICAL_imutavel priority 1000");
191
+ console.log(" L1 LEI_4_SYNAPSE_5_GARANTIAS · CRITICAL_reign priority 900");
192
+ console.log(" L2 5_IMUTAVEIS_BYTE_PRESERVED · CRITICAL_byte_preserved priority 800");
193
+ console.log(" L3 14_LEIS_CANON_VIGENTES · ALTA_vigente priority 600");
194
+ console.log(" L4 PREDATOR_ENCARNADO_CONSTITUTION · ALTA_encarnacao priority 500");
195
+ console.log(" L5 TASK_ESPECIFICA_CONTEXTO · MEDIA_task priority 300");
196
+ console.log(" L6 USER_PROMPT_INPUT · INFO_user_input priority 100");
197
+ console.log("");
198
+ console.log("L0+L1+L2 CRITICAL mandatory · Lei #14 BINARY FIX-GERAL trigger se ausentes");
199
+ }
200
+
201
+ function showBenchmarkInfoCanon() {
202
+ console.log("Benchmark canon Predators · scipy.stats N=180 p<0.05 protocol:");
203
+ console.log("");
204
+ console.log(" dimensions canon (6):");
205
+ console.log(" D5_context_layers_L0_L6");
206
+ console.log(" D2_workflows_engine");
207
+ console.log(" D3_stories_lifecycle");
208
+ console.log(" D4_multi_project_filesystem");
209
+ console.log(" D1_mcp_consuming");
210
+ console.log(" D6_dispatcher_integration");
211
+ console.log("");
212
+ console.log(" parâmetros estatísticos canon:");
213
+ console.log(" sample size per dimension: 30");
214
+ console.log(" total samples N: 180");
215
+ console.log(" p-value threshold: < 0.05");
216
+ console.log(" confidence interval: 95%");
217
+ console.log("");
218
+ console.log(" ttest_ind canon próprio Lei #13 Pureza (sem scipy hard-dep)");
219
+ console.log("");
220
+ console.log("Lei #11 honest UPFRONT: execução real depende provisioning Apex T7");
221
+ }
222
+
223
+ function listGoldenSignalsCanon() {
224
+ console.log("4 Golden Signals canon M1 APM Predators (B2 ONDA PRIORIDADES):");
225
+ console.log(" latency_milliseconds · CanonMetricHistogram (p50/p95/p99 via percentile_canon)");
226
+ console.log(" traffic_total · CanonMetricCounter");
227
+ console.log(" errors_total · CanonMetricCounter");
228
+ console.log(" saturation_active · CanonMetricGauge");
229
+ console.log("");
230
+ console.log("5 dimensões instrumentadas canon:");
231
+ console.log(" D1_mcp_consuming · D2_workflows_engine · D3_stories_lifecycle · D4_multi_project_filesystem · D5_context_layers_middleware");
232
+ console.log("");
233
+ console.log("Lei #13 Pureza: metrics canon próprio · duck-type prometheus_client (sem hard-dep externa)");
234
+ }
235
+
236
+ // ──────────────────────────────────────────────────────────────────────
237
+ // UX layer commands (additive · Lei #4 byte-canon preserve)
238
+ // ──────────────────────────────────────────────────────────────────────
239
+
240
+ async function runInitCommand() {
241
+ const ux = loadUxLib();
242
+ if (!ux) {
243
+ console.error("UX layer não-disponível neste pacote.");
244
+ process.exit(1);
245
+ }
246
+ const args = process.argv.slice(3);
247
+ const forceFlag = args.includes("--force") || args.includes("-f");
248
+ const minimalFlag = args.includes("--minimal") || args.includes("-m");
249
+ await ux.splash.runInitSplash({ force: forceFlag, minimal: minimalFlag });
250
+ }
251
+
252
+ function runConfigCommand() {
253
+ const ux = loadUxLib();
254
+ if (!ux) {
255
+ console.error("UX layer não-disponível neste pacote.");
256
+ process.exit(1);
257
+ }
258
+ const subcommand = process.argv[3] || "show";
259
+ const arg = process.argv[4];
260
+
261
+ if (subcommand === "show" || subcommand === "status") {
262
+ const cfg = ux.config.readConfig();
263
+ console.log("Predators Protocol · user config");
264
+ console.log(` path: ${ux.config.getConfigPath()}`);
265
+ console.log(` theme: ${cfg.theme}`);
266
+ console.log(` splash.enabled: ${cfg.splash.enabled}`);
267
+ console.log(` audio.enabled: ${cfg.audio.enabled}`);
268
+ console.log(` firstConnectionAt: ${cfg.firstConnectionAt || "(never)"}`);
269
+ console.log(` lastConnectionAt: ${cfg.lastConnectionAt || "(never)"}`);
270
+ return;
271
+ }
272
+ if (subcommand === "theme") {
273
+ if (!arg) {
274
+ console.log(`Current theme: ${ux.config.getTheme()}`);
275
+ console.log("Available: default, dark, light, monochrome");
276
+ return;
277
+ }
278
+ const result = ux.config.setTheme(arg);
279
+ if (result) {
280
+ console.log(`Theme set: ${arg}`);
281
+ } else {
282
+ console.error(`Invalid theme: ${arg} · available: default, dark, light, monochrome`);
283
+ process.exit(1);
284
+ }
285
+ return;
286
+ }
287
+ if (subcommand === "audio") {
288
+ if (arg === "--enable" || arg === "on") {
289
+ ux.config.setAudioEnabled(true);
290
+ console.log("Audio: enabled · arquivos .mp3 pendentes Fênix audio designer (Lei #11 honest UPFRONT)");
291
+ return;
292
+ }
293
+ if (arg === "--disable" || arg === "off") {
294
+ ux.config.setAudioEnabled(false);
295
+ console.log("Audio: disabled");
296
+ return;
297
+ }
298
+ if (arg === "--status" || !arg) {
299
+ const status = ux.audio.getStatusReport();
300
+ console.log("Audio status canon:");
301
+ console.log(` enabled: ${status.enabled}`);
302
+ console.log(` platform: ${status.platform} (WSL: ${status.is_wsl})`);
303
+ console.log(` player_available: ${status.player_available} (${status.player_cmd || "none"})`);
304
+ console.log(` ${status.canon_note}`);
305
+ console.log(" signatures canon (pendentes Fênix Protocol):");
306
+ for (const s of status.sounds) {
307
+ console.log(` · ${s.name} - ${s.description} (file: ${s.file_present ? "PRESENT" : "PENDENTE"})`);
308
+ }
309
+ return;
310
+ }
311
+ }
312
+ console.error(`Config subcommand desconhecido: ${subcommand}`);
313
+ console.error("Available: show · theme [default|dark|light|monochrome] · audio [--enable|--disable|--status]");
314
+ process.exit(1);
315
+ }
316
+
317
+ function runShowCommand() {
318
+ const ux = loadUxLib();
319
+ if (!ux) {
320
+ console.error("UX layer não-disponível neste pacote.");
321
+ process.exit(1);
322
+ }
323
+ const target = process.argv[3] || "eye";
324
+ const theme = ux.config.getTheme();
325
+
326
+ if (target === "eye" || target === "logo") {
327
+ console.log(ux.asciiArt.renderEye(theme));
328
+ return;
329
+ }
330
+ if (target === "banner") {
331
+ console.log(ux.asciiArt.renderHeroBanner(theme));
332
+ return;
333
+ }
334
+ if (target === "list") {
335
+ console.log("Predator cards canon vigentes:");
336
+ for (const id of ux.asciiArt.listPredatorsWithCards()) {
337
+ console.log(` · ${id}`);
338
+ }
339
+ return;
340
+ }
341
+ const card = ux.asciiArt.renderPredatorCard(target, theme);
342
+ if (!card) {
343
+ console.error(`Predator card não-disponível: ${target}`);
344
+ console.error("Disponíveis: " + ux.asciiArt.listPredatorsWithCards().join(", "));
345
+ console.error("Outros targets: eye | logo | banner | list");
346
+ process.exit(1);
347
+ }
348
+ console.log(card);
349
+ }
350
+
351
+ // ──────────────────────────────────────────────────────────────────────
352
+ // sync command · canon files refresh CWD from bundle (0.3.0-beta.0)
353
+ // ──────────────────────────────────────────────────────────────────────
354
+
355
+ function copyDirRecursive(src, dst) {
356
+ if (!fs.existsSync(src)) return { copied: 0, skipped: 0 };
357
+ fs.mkdirSync(dst, { recursive: true });
358
+ let copied = 0;
359
+ let skipped = 0;
360
+ for (const e of fs.readdirSync(src, { withFileTypes: true })) {
361
+ const s = path.join(src, e.name);
362
+ const d = path.join(dst, e.name);
363
+ if (e.isDirectory()) {
364
+ const r = copyDirRecursive(s, d);
365
+ copied += r.copied;
366
+ skipped += r.skipped;
367
+ } else {
368
+ fs.copyFileSync(s, d);
369
+ copied++;
370
+ }
371
+ }
372
+ return { copied, skipped };
373
+ }
374
+
375
+ function backupExistingPath(target) {
376
+ if (!fs.existsSync(target)) return null;
377
+ const ts = new Date().toISOString().replace(/[:.]/g, "-");
378
+ const backup = `${target}.backup-${ts}`;
379
+ fs.renameSync(target, backup);
380
+ return backup;
381
+ }
382
+
383
+ function runSyncCommand() {
384
+ const args = process.argv.slice(3);
385
+ const dryRun = args.includes("--dry-run");
386
+ const force = args.includes("--force") || args.includes("-f");
387
+ const cwd = process.cwd();
388
+
389
+ // Refuse to overwrite a non-Predators directory unless --force passed.
390
+ const looksLikePredatorsCwd =
391
+ fs.existsSync(path.join(cwd, "predators")) ||
392
+ fs.existsSync(path.join(cwd, "CLAUDE.md")) ||
393
+ fs.existsSync(path.join(cwd, ".claude")) ||
394
+ fs.existsSync(path.join(cwd, "QUICKSTART-SOCIO.md"));
395
+
396
+ if (!looksLikePredatorsCwd && !force) {
397
+ console.error("sync · CWD não parece ser pasta Predators (sem predators/ · CLAUDE.md · .claude/).");
398
+ console.error(` CWD: ${cwd}`);
399
+ console.error(" · Para sync inicial em pasta vazia · use: npx predators-protocol sync --force");
400
+ console.error(" · Para sync em pasta Predators existente · CWD precisa conter CLAUDE.md ou predators/");
401
+ process.exit(1);
402
+ }
403
+
404
+ const SYNC_TARGETS = [
405
+ { rel: "predators", type: "dir" },
406
+ { rel: "docs", type: "dir" },
407
+ { rel: ".claude/commands", type: "dir" },
408
+ { rel: "CLAUDE.md", type: "file" },
409
+ { rel: "QUICKSTART-SOCIO.md", type: "file" },
410
+ ];
411
+
412
+ console.log("Predators Protocol · sync canon files do bundle NPX para CWD");
413
+ console.log(` bundle: ${BUNDLE_DIR}`);
414
+ console.log(` target: ${cwd}`);
415
+ if (dryRun) console.log(" mode: DRY-RUN (zero writes)");
416
+ console.log("");
417
+
418
+ let totalCopied = 0;
419
+ for (const { rel, type } of SYNC_TARGETS) {
420
+ const src = path.join(BUNDLE_DIR, rel);
421
+ const dst = path.join(cwd, rel);
422
+
423
+ if (!fs.existsSync(src)) {
424
+ console.log(` skip: ${rel} (não-presente no bundle)`);
425
+ continue;
426
+ }
427
+
428
+ if (dryRun) {
429
+ console.log(` preview: ${rel} (${type}) · would sync from bundle`);
430
+ continue;
431
+ }
432
+
433
+ const backup = backupExistingPath(dst);
434
+ if (backup) {
435
+ console.log(` backup: ${path.basename(backup)}`);
436
+ }
437
+
438
+ if (type === "dir") {
439
+ const r = copyDirRecursive(src, dst);
440
+ console.log(` sync: ${rel}/ (${r.copied} files)`);
441
+ totalCopied += r.copied;
442
+ } else {
443
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
444
+ fs.copyFileSync(src, dst);
445
+ console.log(` sync: ${rel}`);
446
+ totalCopied++;
447
+ }
448
+ }
449
+
450
+ if (dryRun) {
451
+ console.log("\nDRY-RUN complete · use sem --dry-run para aplicar.");
452
+ } else {
453
+ console.log(`\nsync complete · ${totalCopied} files canon writados · backups com sufixo .backup-<timestamp>`);
454
+ console.log("Lei #1 reign: bundle slim · ZERO infra leak (0.3.0-beta.0)");
455
+ }
456
+ }
457
+
458
+ // ──────────────────────────────────────────────────────────────────────
459
+
460
+ const command = process.argv[2] || "help";
461
+ const commandsCanon = {
462
+ version: printVersionCanon,
463
+ status: printStatusCanon,
464
+ "list-predators": listPredatorsCanon,
465
+ "list-workflows": listWorkflowsCanon,
466
+ "workflow-states": listWorkflowStatesCanon,
467
+ "story-states": listStoryStatesCanon,
468
+ "layers-list": listLayersCanon,
469
+ "benchmark-info": showBenchmarkInfoCanon,
470
+ "metrics-list": listGoldenSignalsCanon,
471
+ init: runInitCommand,
472
+ config: runConfigCommand,
473
+ show: runShowCommand,
474
+ sync: runSyncCommand,
475
+ help: printHelpCanon,
476
+ "--help": printHelpCanon,
477
+ "-h": printHelpCanon,
478
+ };
479
+
480
+ const handler = commandsCanon[command];
481
+ if (!handler) {
482
+ console.error(`Comando canon NÃO vigente: ${command}`);
483
+ printHelpCanon();
484
+ process.exit(1);
485
+ }
486
+
487
+ Promise.resolve(handler()).catch(err => {
488
+ console.error(`Falha runtime canon: ${err && err.message ? err.message : err}`);
489
+ process.exit(1);
490
+ });