predators-protocol 1.1.0 → 1.2.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.
- package/bin/predators-cli.js +888 -777
- package/bundle/.claude/commands/encarnar.md +22 -0
- package/bundle/CLAUDE.md +38 -6
- package/bundle/QUICKSTART-SOCIO.md +3 -3
- package/bundle/docs/CANON/BRAND-CANON.json +45 -0
- package/bundle/docs/CANON/SELF-HEALING-LOG-CANON.json +126 -17
- package/bundle/docs/ENCARNACAO.md +11 -0
- package/bundle/predators/apex/aguia-pescadora/constitution.md +469 -0
- package/bundle/predators/apex/aguia-pescadora/predator.json +66 -0
- package/bundle/predators/apex/aguia-real/constitution.md +358 -347
- package/bundle/predators/apex/aguia-real/predator.json +1 -1
- package/bundle/predators/apex/leao/constitution.md +283 -283
- package/bundle/predators/apex/leao/predator.json +1 -1
- package/bundle/predators/apex/orca/constitution.md +279 -279
- package/bundle/predators/apex/orca/predator.json +1 -1
- package/bundle/predators/apex/tigre-siberiano/constitution.md +276 -276
- package/bundle/predators/apex/tigre-siberiano/predator.json +1 -1
- package/bundle/predators/builder/camaleao/constitution.md +8 -0
- package/bundle/predators/builder/polvo/constitution.md +8 -0
- package/bundle/predators/builder/tatu-bola/constitution.md +8 -0
- package/bundle/predators/designer/pavao/constitution.md +37 -0
- package/bundle/predators/hunter/crocodilo/constitution.md +293 -293
- package/bundle/predators/hunter/crocodilo/predator.json +1 -1
- package/bundle/predators/hunter/escorpiao/constitution.md +327 -327
- package/bundle/predators/hunter/escorpiao/predator.json +1 -1
- package/bundle/predators/hunter/hiena/constitution.md +343 -343
- package/bundle/predators/hunter/hiena/predator.json +1 -1
- package/bundle/predators/hunter/tubarao-branco/constitution.md +527 -527
- package/bundle/predators/hunter/tubarao-branco/predator.json +1 -1
- package/bundle/predators/intel/guepardo/constitution.md +201 -201
- package/bundle/predators/intel/guepardo/predator.json +1 -1
- package/bundle/predators/intel/jiboia/constitution.md +243 -243
- package/bundle/predators/intel/jiboia/predator.json +3 -2
- package/bundle/predators/intel/lobo-solitario/constitution.md +290 -275
- package/bundle/predators/intel/lobo-solitario/predator.json +1 -1
- package/bundle/predators/intel/morcego/constitution.md +217 -217
- package/bundle/predators/intel/morcego/predator.json +1 -1
- package/bundle/predators/intel/pirarucu/constitution.md +309 -309
- package/bundle/predators/intel/pirarucu/predator.json +1 -1
- package/bundle/predators/intel/polvo-mimico/constitution.md +220 -220
- package/bundle/predators/intel/polvo-mimico/predator.json +1 -1
- package/bundle/predators/intel/tarantula/constitution.md +222 -222
- package/bundle/predators/intel/tarantula/predator.json +1 -1
- package/bundle/predators/meta/aranha-d-agua/constitution.md +264 -264
- package/bundle/predators/meta/aranha-d-agua/predator.json +1 -1
- package/bundle/predators/meta/camaleao-real/constitution.md +245 -245
- package/bundle/predators/meta/camaleao-real/predator.json +1 -1
- package/bundle/predators/meta/coruja-real/constitution.md +255 -255
- package/bundle/predators/meta/coruja-real/predator.json +1 -1
- package/bundle/predators/meta/dragao-ancestral/constitution.md +297 -297
- package/bundle/predators/meta/dragao-ancestral/predator.json +1 -1
- package/bundle/predators/meta/fenix/constitution.md +286 -286
- package/bundle/predators/meta/fenix/predator.json +1 -1
- package/bundle/predators/meta/lince-das-neves/constitution.md +252 -252
- package/bundle/predators/meta/lince-das-neves/predator.json +1 -1
- package/bundle/predators/web3/caranguejo-ferradura/constitution.md +245 -245
- package/bundle/predators/web3/caranguejo-ferradura/predator.json +1 -1
- package/bundle/predators/web3/medusa/constitution.md +236 -236
- package/bundle/predators/web3/medusa/predator.json +1 -1
- package/bundle/predators/web3/orca-alfa/constitution.md +227 -227
- package/bundle/predators/web3/orca-alfa/predator.json +1 -1
- package/bundle/predators/web3/polvo-gigante/constitution.md +240 -240
- package/bundle/predators/web3/polvo-gigante/predator.json +1 -1
- package/bundle/predators/web3/raia-eletrica/constitution.md +236 -236
- package/bundle/predators/web3/raia-eletrica/predator.json +1 -1
- package/bundle/predators/web3/tubarao-martelo/constitution.md +236 -236
- package/bundle/predators/web3/tubarao-martelo/predator.json +1 -1
- package/lib/access-token-client.js +10 -1
- package/lib/invoke-client.js +138 -0
- package/package.json +1 -1
package/bin/predators-cli.js
CHANGED
|
@@ -1,777 +1,888 @@
|
|
|
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-1.0.0-STABLE-14-leis-14-canon-docs-brain-100pct-2026-05-28";
|
|
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 1.0.0 STABLE (canon 100% · 14 leis ratificadas)
|
|
70
|
-
|
|
71
|
-
USO:
|
|
72
|
-
npx predators-protocol <comando>
|
|
73
|
-
|
|
74
|
-
COMANDOS canon vigentes (17 comandos):
|
|
75
|
-
|
|
76
|
-
-- fase 1 (introspecção · 4 comandos) --
|
|
77
|
-
version Exibe versão canon
|
|
78
|
-
status Estado atual canon · bundle integrity check
|
|
79
|
-
list-predators Lista 64 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 · 5 comandos) --
|
|
90
|
-
init Polimórfico · sem arg = splash cinematográfico · com <name> = scaffolda projeto novo + sync
|
|
91
|
-
Flags: --force (sempre cinemático · ignora cache) · --minimal (1-linha)
|
|
92
|
-
config Preferências user (theme · audio · splash · telemetry)
|
|
93
|
-
show Renderiza ASCII art predator card OR The Eye logo
|
|
94
|
-
sync Sincroniza canon files (predators/ + docs/ + .claude/ + CLAUDE.md) do bundle NPX para CWD
|
|
95
|
-
tour Cinematic walkthrough · 5 atos canon (camadas · leis · diretrizes · comandos · próximos passos)
|
|
96
|
-
|
|
97
|
-
-- fase R2 (onboarding · 2026-05-26 · Polvo · 1 comando novo) --
|
|
98
|
-
install Alias semântico para 'sync --force' · UX onboarding clearer
|
|
99
|
-
|
|
100
|
-
-- fase TOKEN-COLABORADOR (2026-05-27 · Borboleta + Jaguar · 2 comandos novos) --
|
|
101
|
-
unlock <TOKEN> Ativa acesso colaborador via token (canon access-token-client)
|
|
102
|
-
gen-token Apex T7 gera token via CLI (PREDATORS_OWNER_KEY_BACKEND env)
|
|
103
|
-
Usage: gen-token --name "Nome" [--email x] [--list]
|
|
104
|
-
|
|
105
|
-
-- fase
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
console.log(
|
|
150
|
-
console.log(`
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
console.log(
|
|
155
|
-
console.log(
|
|
156
|
-
console.log(
|
|
157
|
-
console.log(
|
|
158
|
-
console.log(
|
|
159
|
-
console.log(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
console.log("
|
|
164
|
-
console.log("
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
console.log("
|
|
169
|
-
console.log(" -
|
|
170
|
-
console.log("
|
|
171
|
-
console.log("
|
|
172
|
-
console.log("
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log("
|
|
178
|
-
console.log("
|
|
179
|
-
console.log("
|
|
180
|
-
console.log("
|
|
181
|
-
console.log("
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
console.log("
|
|
186
|
-
console.log("
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
console.log("
|
|
191
|
-
console.log("
|
|
192
|
-
console.log("
|
|
193
|
-
console.log("
|
|
194
|
-
console.log("
|
|
195
|
-
console.log("
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
console.log("
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
console.log("
|
|
204
|
-
console.log("
|
|
205
|
-
console.log("
|
|
206
|
-
console.log("
|
|
207
|
-
console.log("
|
|
208
|
-
console.log("
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
console.log("
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
console.log("
|
|
217
|
-
console.log("");
|
|
218
|
-
console.log("
|
|
219
|
-
console.log("
|
|
220
|
-
console.log("
|
|
221
|
-
console.log("
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
console.log("");
|
|
226
|
-
console.log("
|
|
227
|
-
console.log("
|
|
228
|
-
console.log("
|
|
229
|
-
console.log("
|
|
230
|
-
console.log("
|
|
231
|
-
console.log("");
|
|
232
|
-
console.log("
|
|
233
|
-
console.log("");
|
|
234
|
-
console.log("
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
console.log("
|
|
239
|
-
console.log("
|
|
240
|
-
console.log("
|
|
241
|
-
console.log("
|
|
242
|
-
console.log("
|
|
243
|
-
console.log("");
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
console.log("
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
console.log(
|
|
304
|
-
console.log("
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
console.log("
|
|
314
|
-
console.log(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
process.
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
console.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
console.log(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (arg === "--
|
|
392
|
-
ux.config.setTelemetryEnabled(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
console.log(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
console.
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
console.log("");
|
|
588
|
-
console.log(
|
|
589
|
-
await sleep(beat
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
["
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
"Lei #
|
|
621
|
-
"Lei #
|
|
622
|
-
"Lei #
|
|
623
|
-
"Lei #
|
|
624
|
-
"Lei #
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
console.log("");
|
|
641
|
-
console.log("───
|
|
642
|
-
await sleep(beat / 2);
|
|
643
|
-
console.log("
|
|
644
|
-
console.log("
|
|
645
|
-
console.log("
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
console.log("
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
console.log("
|
|
653
|
-
console.log("
|
|
654
|
-
console.log("");
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
console.log("
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
console.log("");
|
|
661
|
-
console.log("
|
|
662
|
-
console.log("");
|
|
663
|
-
console.log("
|
|
664
|
-
console.log("
|
|
665
|
-
console.log(" ·
|
|
666
|
-
console.log("
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
console.log("
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
async function
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
const
|
|
761
|
-
if (!
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
(
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
})
|
|
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-1.0.0-STABLE-14-leis-14-canon-docs-brain-100pct-2026-05-28";
|
|
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 1.0.0 STABLE (canon 100% · 14 leis ratificadas)
|
|
70
|
+
|
|
71
|
+
USO:
|
|
72
|
+
npx predators-protocol <comando>
|
|
73
|
+
|
|
74
|
+
COMANDOS canon vigentes (17 comandos):
|
|
75
|
+
|
|
76
|
+
-- fase 1 (introspecção · 4 comandos) --
|
|
77
|
+
version Exibe versão canon
|
|
78
|
+
status Estado atual canon · bundle integrity check
|
|
79
|
+
list-predators Lista 64 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 · 5 comandos) --
|
|
90
|
+
init Polimórfico · sem arg = splash cinematográfico · com <name> = scaffolda projeto novo + sync
|
|
91
|
+
Flags: --force (sempre cinemático · ignora cache) · --minimal (1-linha)
|
|
92
|
+
config Preferências user (theme · audio · splash · telemetry)
|
|
93
|
+
show Renderiza ASCII art predator card OR The Eye logo
|
|
94
|
+
sync Sincroniza canon files (predators/ + docs/ + .claude/ + CLAUDE.md) do bundle NPX para CWD
|
|
95
|
+
tour Cinematic walkthrough · 5 atos canon (camadas · leis · diretrizes · comandos · próximos passos)
|
|
96
|
+
|
|
97
|
+
-- fase R2 (onboarding · 2026-05-26 · Polvo · 1 comando novo) --
|
|
98
|
+
install Alias semântico para 'sync --force' · UX onboarding clearer
|
|
99
|
+
|
|
100
|
+
-- fase TOKEN-COLABORADOR (2026-05-27 · Borboleta + Jaguar · 2 comandos novos) --
|
|
101
|
+
unlock <TOKEN> Ativa acesso colaborador via token (canon access-token-client)
|
|
102
|
+
gen-token Apex T7 gera token via CLI (PREDATORS_OWNER_KEY_BACKEND env)
|
|
103
|
+
Usage: gen-token --name "Nome" [--email x] [--list]
|
|
104
|
+
|
|
105
|
+
-- fase PRODUTO-DEV (2026-06-05 · Onda 4b · 1 comando novo) --
|
|
106
|
+
invoke <id> "..." Invoca um predador via API usando a sua chave Bearer (PREDATORS_API_KEY)
|
|
107
|
+
Crie a chave em https://predadores.online/settings (planos PRO/APEX)
|
|
108
|
+
Usage: invoke tubarao-branco "audite este contrato"
|
|
109
|
+
|
|
110
|
+
-- fase BRAIN (2026-05-28 · 1.0.0 STABLE · 1 comando novo) --
|
|
111
|
+
brain-status Snapshot canon estrutura cerebral · 11 daemons + 6 flags + Elefante (READ-only)
|
|
112
|
+
Runtime real exige Python + clonar repo + brain-on.cmd · ver caminho em docs
|
|
113
|
+
|
|
114
|
+
-- fase BRAND (2026-05-29 · BrandBook v2 OBSIDIANA · 1 comando novo) --
|
|
115
|
+
brand-status Snapshot canon paleta v2 + tipografia + cadeia de ratificacao (READ-only)
|
|
116
|
+
13 hex byte-canon · Archivo/Inter/JetBrains Mono · Pavao Art. 4 v2 + Dragao Art. 3
|
|
117
|
+
|
|
118
|
+
help Exibe esta mensagem
|
|
119
|
+
|
|
120
|
+
Lei #11 honest UPFRONT 1.0.0 STABLE cumulativa:
|
|
121
|
+
· Bundle 163 files · 64 predadores + 14 LEI canon-docs + AUDIT-FIRM + SH-CATALOG + BRAND-CANON + 7 skills · ZERO infra leak
|
|
122
|
+
· sync command requer CWD contendo predators/ OU --force flag · pattern canon partner-bundle
|
|
123
|
+
· NPX = portal READ canon · scaffold projeto novo + token unlock. Encarnação real exige Claude Code CLI + repo + chave LLM
|
|
124
|
+
· brain-status = snapshot canon (não-live) · runtime real exige Python 3.11+ + brain-on.cmd · ver QUICKSTART-SOCIO.md
|
|
125
|
+
`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function printVersionCanon() {
|
|
129
|
+
console.log(CLI_VERSION_CANON);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function printStatusCanon() {
|
|
133
|
+
const synapseMd = bundlePath("docs/SYNAPSE.md");
|
|
134
|
+
const encarnacaoMd = bundlePath("docs/ENCARNACAO.md");
|
|
135
|
+
const claudeMd = bundlePath("CLAUDE.md");
|
|
136
|
+
const predatorsDir = bundlePath("predators");
|
|
137
|
+
const skillsDir = bundlePath(".claude/commands");
|
|
138
|
+
let predatorCount = 0;
|
|
139
|
+
if (fs.existsSync(predatorsDir)) {
|
|
140
|
+
const walk = (dir) => {
|
|
141
|
+
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
142
|
+
const p = path.join(dir, e.name);
|
|
143
|
+
if (e.isDirectory()) walk(p);
|
|
144
|
+
else if (e.name === "predator.json") predatorCount++;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
walk(predatorsDir);
|
|
148
|
+
}
|
|
149
|
+
console.log("canon Predators status:");
|
|
150
|
+
console.log(` CLI version: ${CLI_VERSION_CANON}`);
|
|
151
|
+
console.log(` bundle root: ${BUNDLE_DIR}`);
|
|
152
|
+
console.log(` CLAUDE.md: ${fs.existsSync(claudeMd) ? "PRESENT" : "MISSING"}`);
|
|
153
|
+
console.log(` SYNAPSE.md: ${fs.existsSync(synapseMd) ? "PRESENT" : "MISSING"}`);
|
|
154
|
+
console.log(` ENCARNACAO.md: ${fs.existsSync(encarnacaoMd) ? "PRESENT" : "MISSING"}`);
|
|
155
|
+
console.log(` predators canon: ${predatorCount}/63 byte-presente`);
|
|
156
|
+
console.log(` .claude/commands/: ${fs.existsSync(skillsDir) ? "PRESENT" : "MISSING"}`);
|
|
157
|
+
console.log(` Lei #14 canon: PERFEITO OU FIX-GERAL ratificada constitucional`);
|
|
158
|
+
console.log(` Lei #1 reign: bundle slim · ZERO infra leak audit (0.3.0-beta.0)`);
|
|
159
|
+
console.log(` Diretrizes 4 (2026-05-24): Lei do Tom · Autonomia Sequencial · PASSO 0 EVERY · Separação canon-doc/comunicação`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function listPredatorsCanon() {
|
|
163
|
+
console.log("64 predadores frota canon vigente pós-F4 Baleia-cantora:");
|
|
164
|
+
console.log(" apex: 4 (Águia + Leão + Orca + Tigre-siberiano)");
|
|
165
|
+
console.log(" hunter: 5 (Tubarão-branco JUIZ FINAL Art. 14 + Escorpião + Hiena + Crocodilo + Piranha)");
|
|
166
|
+
console.log(" builder: 9 (Jaguar + Tatu-bola + Coruja + Pirarucu + Lince + Polvo + 3)");
|
|
167
|
+
console.log(" designer: 8 (Borboleta-azul + Tucano-toco + Baleia-cantora + 5)");
|
|
168
|
+
console.log(" copy: 6 (Serpente-coral + 5)");
|
|
169
|
+
console.log(" intel: 8 (Lobo-solitário + Tarântula + Jiboia + 5)");
|
|
170
|
+
console.log(" governance: 6");
|
|
171
|
+
console.log(" growth: 6");
|
|
172
|
+
console.log(" web3: 6 (Medusa + 5)");
|
|
173
|
+
console.log(" meta: 6 (Dragão-ancestral + Elefante + Fênix + Camaleão + Serpente + 1)");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function listWorkflowsCanon() {
|
|
177
|
+
console.log("4 workflows canon Predators (Lei #13 Pureza):");
|
|
178
|
+
console.log(" - caca-sistematica");
|
|
179
|
+
console.log(" - pacto-cyber-squad");
|
|
180
|
+
console.log(" - pipeline-fenix");
|
|
181
|
+
console.log(" - saneamento-brownfield");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function listWorkflowStatesCanon() {
|
|
185
|
+
console.log("6 WorkflowStateCanon canon Predators (D2 ETAPA 2 state machine):");
|
|
186
|
+
console.log(" PENDING · workflow definição cravada · zero execução");
|
|
187
|
+
console.log(" SCHEDULED · próxima execução planejada · cron canon");
|
|
188
|
+
console.log(" RUNNING · steps em execução runtime");
|
|
189
|
+
console.log(" COMPLETED · todos steps OK · success path");
|
|
190
|
+
console.log(" FAILED · step falhou · rollback canon");
|
|
191
|
+
console.log(" PAUSED · humano interrompeu · retomar manual");
|
|
192
|
+
console.log("");
|
|
193
|
+
console.log("7 transições válidas canon (Lei #4 reign state machine):");
|
|
194
|
+
console.log(" PENDING → SCHEDULED · SCHEDULED → RUNNING · RUNNING → COMPLETED");
|
|
195
|
+
console.log(" RUNNING → FAILED · RUNNING → PAUSED · PAUSED → RUNNING · FAILED → PENDING");
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function listStoryStatesCanon() {
|
|
199
|
+
console.log("5 StoryStateCanon canon Predators (D3 ETAPA 3 state machine):");
|
|
200
|
+
console.log(" DRAFT · criação inicial · briefing parcial");
|
|
201
|
+
console.log(" REFINEMENT · briefing completo · Águia preside refinamento");
|
|
202
|
+
console.log(" READY · predator owner identificado · scope clear");
|
|
203
|
+
console.log(" IN_PROGRESS · predator encarnado executando");
|
|
204
|
+
console.log(" DONE · 5 garantias entregues · audit Tubarão PASS");
|
|
205
|
+
console.log("");
|
|
206
|
+
console.log("7 transições válidas canon:");
|
|
207
|
+
console.log(" DRAFT → REFINEMENT → READY → IN_PROGRESS → DONE (caminho canônico)");
|
|
208
|
+
console.log(" REFINEMENT/READY/IN_PROGRESS → DRAFT (rejeição com feedback)");
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function listLayersCanon() {
|
|
212
|
+
console.log("7 ContextLayerCanon L0-L6 canon Predators (D5 ETAPA 1 runtime middleware):");
|
|
213
|
+
console.log(" L0 LEI_DO_SANGUE_ART_1 · CRITICAL_imutavel priority 1000");
|
|
214
|
+
console.log(" L1 LEI_4_SYNAPSE_5_GARANTIAS · CRITICAL_reign priority 900");
|
|
215
|
+
console.log(" L2 5_IMUTAVEIS_BYTE_PRESERVED · CRITICAL_byte_preserved priority 800");
|
|
216
|
+
console.log(" L3 14_LEIS_CANON_VIGENTES · ALTA_vigente priority 600");
|
|
217
|
+
console.log(" L4 PREDATOR_ENCARNADO_CONSTITUTION · ALTA_encarnacao priority 500");
|
|
218
|
+
console.log(" L5 TASK_ESPECIFICA_CONTEXTO · MEDIA_task priority 300");
|
|
219
|
+
console.log(" L6 USER_PROMPT_INPUT · INFO_user_input priority 100");
|
|
220
|
+
console.log("");
|
|
221
|
+
console.log("L0+L1+L2 CRITICAL mandatory · Lei #14 BINARY FIX-GERAL trigger se ausentes");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function showBenchmarkInfoCanon() {
|
|
225
|
+
console.log("Benchmark canon Predators · scipy.stats N=180 p<0.05 protocol:");
|
|
226
|
+
console.log("");
|
|
227
|
+
console.log(" dimensions canon (6):");
|
|
228
|
+
console.log(" D5_context_layers_L0_L6");
|
|
229
|
+
console.log(" D2_workflows_engine");
|
|
230
|
+
console.log(" D3_stories_lifecycle");
|
|
231
|
+
console.log(" D4_multi_project_filesystem");
|
|
232
|
+
console.log(" D1_mcp_consuming");
|
|
233
|
+
console.log(" D6_dispatcher_integration");
|
|
234
|
+
console.log("");
|
|
235
|
+
console.log(" parâmetros estatísticos canon:");
|
|
236
|
+
console.log(" sample size per dimension: 30");
|
|
237
|
+
console.log(" total samples N: 180");
|
|
238
|
+
console.log(" p-value threshold: < 0.05");
|
|
239
|
+
console.log(" confidence interval: 95%");
|
|
240
|
+
console.log("");
|
|
241
|
+
console.log(" ttest_ind canon próprio Lei #13 Pureza (sem scipy hard-dep)");
|
|
242
|
+
console.log("");
|
|
243
|
+
console.log("Lei #11 honest UPFRONT: execução real depende provisioning Apex T7");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function listGoldenSignalsCanon() {
|
|
247
|
+
console.log("4 Golden Signals canon M1 APM Predators (B2 ONDA PRIORIDADES):");
|
|
248
|
+
console.log(" latency_milliseconds · CanonMetricHistogram (p50/p95/p99 via percentile_canon)");
|
|
249
|
+
console.log(" traffic_total · CanonMetricCounter");
|
|
250
|
+
console.log(" errors_total · CanonMetricCounter");
|
|
251
|
+
console.log(" saturation_active · CanonMetricGauge");
|
|
252
|
+
console.log("");
|
|
253
|
+
console.log("5 dimensões instrumentadas canon:");
|
|
254
|
+
console.log(" D1_mcp_consuming · D2_workflows_engine · D3_stories_lifecycle · D4_multi_project_filesystem · D5_context_layers_middleware");
|
|
255
|
+
console.log("");
|
|
256
|
+
console.log("Lei #13 Pureza: metrics canon próprio · duck-type prometheus_client (sem hard-dep externa)");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
260
|
+
// UX layer commands (additive · Lei #4 byte-canon preserve)
|
|
261
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
262
|
+
|
|
263
|
+
async function runInitCommand() {
|
|
264
|
+
const args = process.argv.slice(3);
|
|
265
|
+
const positionalArgs = args.filter(a => !a.startsWith("-"));
|
|
266
|
+
const projectName = positionalArgs[0] || null;
|
|
267
|
+
|
|
268
|
+
// Polymorphic init (R2 onda · 2026-05-26 · Polvo Builder)
|
|
269
|
+
// - no positional arg → splash UX (backward compat byte-preserved)
|
|
270
|
+
// - positional arg → project scaffolding (mkdir + sync inside)
|
|
271
|
+
if (projectName) {
|
|
272
|
+
return runInitProjectMode(projectName, args);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const ux = loadUxLib();
|
|
276
|
+
if (!ux) {
|
|
277
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
278
|
+
process.exit(1);
|
|
279
|
+
}
|
|
280
|
+
const forceFlag = args.includes("--force") || args.includes("-f");
|
|
281
|
+
const minimalFlag = args.includes("--minimal") || args.includes("-m");
|
|
282
|
+
await ux.splash.runInitSplash({ force: forceFlag, minimal: minimalFlag });
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function runInitProjectMode(projectName, args) {
|
|
286
|
+
const cwd = process.cwd();
|
|
287
|
+
const targetDir = path.resolve(cwd, projectName);
|
|
288
|
+
const force = args.includes("--force") || args.includes("-f");
|
|
289
|
+
|
|
290
|
+
if (fs.existsSync(targetDir)) {
|
|
291
|
+
const contents = fs.readdirSync(targetDir);
|
|
292
|
+
if (contents.length > 0 && !force) {
|
|
293
|
+
console.error(`init · diretório ${projectName} já existe e não está vazio.`);
|
|
294
|
+
console.error(" · Use diretório vazio · OU passe --force para sobrescrever (cuidado)");
|
|
295
|
+
process.exit(1);
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
console.log("Predators Protocol · init project canon (R2 onda 2026-05-26 · Polvo)");
|
|
302
|
+
console.log(` projeto: ${projectName}`);
|
|
303
|
+
console.log(` path: ${targetDir}`);
|
|
304
|
+
console.log("");
|
|
305
|
+
|
|
306
|
+
process.chdir(targetDir);
|
|
307
|
+
if (!process.argv.includes("--force")) {
|
|
308
|
+
process.argv.push("--force");
|
|
309
|
+
}
|
|
310
|
+
runSyncCommand();
|
|
311
|
+
|
|
312
|
+
console.log("");
|
|
313
|
+
console.log("Próximos passos:");
|
|
314
|
+
console.log(` cd ${projectName}`);
|
|
315
|
+
console.log(" npx predators-protocol tour # tour cinematográfico");
|
|
316
|
+
console.log(" npx predators-protocol show eye # logo canon");
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function runInstallCommand() {
|
|
320
|
+
// Alias semântico canon para `sync --force` (UX onboarding clearer)
|
|
321
|
+
// R2 onda · 2026-05-26 · Polvo · LMAS parity sem violar Lei #13 (canon próprio)
|
|
322
|
+
console.log("install · alias canon para `sync --force` · instala canon files no CWD");
|
|
323
|
+
console.log("");
|
|
324
|
+
if (!process.argv.includes("--force")) {
|
|
325
|
+
process.argv.push("--force");
|
|
326
|
+
}
|
|
327
|
+
runSyncCommand();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function runConfigCommand() {
|
|
331
|
+
const ux = loadUxLib();
|
|
332
|
+
if (!ux) {
|
|
333
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
const subcommand = process.argv[3] || "show";
|
|
337
|
+
const arg = process.argv[4];
|
|
338
|
+
|
|
339
|
+
if (subcommand === "show" || subcommand === "status") {
|
|
340
|
+
const cfg = ux.config.readConfig();
|
|
341
|
+
console.log("Predators Protocol · user config");
|
|
342
|
+
console.log(` path: ${ux.config.getConfigPath()}`);
|
|
343
|
+
console.log(` theme: ${cfg.theme}`);
|
|
344
|
+
console.log(` splash.enabled: ${cfg.splash.enabled}`);
|
|
345
|
+
console.log(` audio.enabled: ${cfg.audio.enabled}`);
|
|
346
|
+
console.log(` firstConnectionAt: ${cfg.firstConnectionAt || "(never)"}`);
|
|
347
|
+
console.log(` lastConnectionAt: ${cfg.lastConnectionAt || "(never)"}`);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (subcommand === "theme") {
|
|
351
|
+
if (!arg) {
|
|
352
|
+
console.log(`Current theme: ${ux.config.getTheme()}`);
|
|
353
|
+
console.log("Available: default, dark, light, monochrome");
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const result = ux.config.setTheme(arg);
|
|
357
|
+
if (result) {
|
|
358
|
+
console.log(`Theme set: ${arg}`);
|
|
359
|
+
} else {
|
|
360
|
+
console.error(`Invalid theme: ${arg} · available: default, dark, light, monochrome`);
|
|
361
|
+
process.exit(1);
|
|
362
|
+
}
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (subcommand === "audio") {
|
|
366
|
+
if (arg === "--enable" || arg === "on") {
|
|
367
|
+
ux.config.setAudioEnabled(true);
|
|
368
|
+
console.log("Audio: enabled · .mp3 byte pendentes produção externa (Suno/ElevenLabs/Stable Audio · canon spec docs/PRDs/ONDA-BALEIA-CANTORA-FASE-2-SIGNATURES-2026-05-24/)");
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (arg === "--disable" || arg === "off") {
|
|
372
|
+
ux.config.setAudioEnabled(false);
|
|
373
|
+
console.log("Audio: disabled");
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (arg === "--status" || !arg) {
|
|
377
|
+
const status = ux.audio.getStatusReport();
|
|
378
|
+
console.log("Audio status canon:");
|
|
379
|
+
console.log(` enabled: ${status.enabled}`);
|
|
380
|
+
console.log(` platform: ${status.platform} (WSL: ${status.is_wsl})`);
|
|
381
|
+
console.log(` player_available: ${status.player_available} (${status.player_cmd || "none"})`);
|
|
382
|
+
console.log(` ${status.canon_note}`);
|
|
383
|
+
console.log(" signatures Baleia-cantora F4 Fase 2:");
|
|
384
|
+
for (const s of status.sounds) {
|
|
385
|
+
console.log(` · ${s.name} - ${s.description} (file: ${s.file_present ? "PRESENT" : "PENDENTE"})`);
|
|
386
|
+
}
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (subcommand === "telemetry") {
|
|
391
|
+
if (arg === "--enable" || arg === "on") {
|
|
392
|
+
ux.config.setTelemetryEnabled(true);
|
|
393
|
+
const status = ux.config.getTelemetryStatus();
|
|
394
|
+
console.log("Telemetry: enabled");
|
|
395
|
+
console.log(` anonymous_id: ${status.anonymous_id} (gerado runtime · zero PII)`);
|
|
396
|
+
console.log(` endpoint: ${status.endpoint || "local-only (future network endpoint TBD Apex T7)"}`);
|
|
397
|
+
console.log(" Lei #1 reign: zero PII · zero IP capture · zero hostname · só sync events anônimos");
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (arg === "--disable" || arg === "off") {
|
|
401
|
+
ux.config.setTelemetryEnabled(false);
|
|
402
|
+
console.log("Telemetry: disabled · zero coleta");
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (arg === "--status" || !arg) {
|
|
406
|
+
const status = ux.config.getTelemetryStatus();
|
|
407
|
+
console.log("Telemetry status canon:");
|
|
408
|
+
console.log(` enabled: ${status.enabled}`);
|
|
409
|
+
console.log(` anonymous_id: ${status.anonymous_id || "(não gerado · opt-in pendente)"}`);
|
|
410
|
+
console.log(` sync_count: ${status.sync_count}`);
|
|
411
|
+
console.log(` last_sync_at: ${status.last_sync_at || "(nunca)"}`);
|
|
412
|
+
console.log(` endpoint: ${status.endpoint || "local-only (null)"}`);
|
|
413
|
+
console.log(` ${status.canon_note}`);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
console.error(`Config subcommand desconhecido: ${subcommand}`);
|
|
418
|
+
console.error("Available: show · theme [default|dark|light|monochrome] · audio [--enable|--disable|--status] · telemetry [--enable|--disable|--status]");
|
|
419
|
+
process.exit(1);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function runShowCommand() {
|
|
423
|
+
const ux = loadUxLib();
|
|
424
|
+
if (!ux) {
|
|
425
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
426
|
+
process.exit(1);
|
|
427
|
+
}
|
|
428
|
+
const target = process.argv[3] || "eye";
|
|
429
|
+
const theme = ux.config.getTheme();
|
|
430
|
+
|
|
431
|
+
if (target === "eye" || target === "logo") {
|
|
432
|
+
console.log(ux.asciiArt.renderEye(theme));
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (target === "banner") {
|
|
436
|
+
console.log(ux.asciiArt.renderHeroBanner(theme));
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (target === "list") {
|
|
440
|
+
console.log("Predator cards canon vigentes:");
|
|
441
|
+
for (const id of ux.asciiArt.listPredatorsWithCards()) {
|
|
442
|
+
console.log(` · ${id}`);
|
|
443
|
+
}
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const card = ux.asciiArt.renderPredatorCard(target, theme);
|
|
447
|
+
if (!card) {
|
|
448
|
+
console.error(`Predator card não-disponível: ${target}`);
|
|
449
|
+
console.error("Disponíveis: " + ux.asciiArt.listPredatorsWithCards().join(", "));
|
|
450
|
+
console.error("Outros targets: eye | logo | banner | list");
|
|
451
|
+
process.exit(1);
|
|
452
|
+
}
|
|
453
|
+
console.log(card);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
457
|
+
// sync command · canon files refresh CWD from bundle (0.3.0-beta.0)
|
|
458
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
459
|
+
|
|
460
|
+
function copyDirRecursive(src, dst) {
|
|
461
|
+
if (!fs.existsSync(src)) return { copied: 0, skipped: 0 };
|
|
462
|
+
fs.mkdirSync(dst, { recursive: true });
|
|
463
|
+
let copied = 0;
|
|
464
|
+
let skipped = 0;
|
|
465
|
+
for (const e of fs.readdirSync(src, { withFileTypes: true })) {
|
|
466
|
+
const s = path.join(src, e.name);
|
|
467
|
+
const d = path.join(dst, e.name);
|
|
468
|
+
if (e.isDirectory()) {
|
|
469
|
+
const r = copyDirRecursive(s, d);
|
|
470
|
+
copied += r.copied;
|
|
471
|
+
skipped += r.skipped;
|
|
472
|
+
} else {
|
|
473
|
+
fs.copyFileSync(s, d);
|
|
474
|
+
copied++;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return { copied, skipped };
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function backupExistingPath(target) {
|
|
481
|
+
if (!fs.existsSync(target)) return null;
|
|
482
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-");
|
|
483
|
+
const backup = `${target}.backup-${ts}`;
|
|
484
|
+
fs.renameSync(target, backup);
|
|
485
|
+
return backup;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function runSyncCommand() {
|
|
489
|
+
const args = process.argv.slice(3);
|
|
490
|
+
const dryRun = args.includes("--dry-run");
|
|
491
|
+
const force = args.includes("--force") || args.includes("-f");
|
|
492
|
+
const cwd = process.cwd();
|
|
493
|
+
|
|
494
|
+
// Refuse to overwrite a non-Predators directory unless --force passed.
|
|
495
|
+
const looksLikePredatorsCwd =
|
|
496
|
+
fs.existsSync(path.join(cwd, "predators")) ||
|
|
497
|
+
fs.existsSync(path.join(cwd, "CLAUDE.md")) ||
|
|
498
|
+
fs.existsSync(path.join(cwd, ".claude")) ||
|
|
499
|
+
fs.existsSync(path.join(cwd, "QUICKSTART-SOCIO.md"));
|
|
500
|
+
|
|
501
|
+
if (!looksLikePredatorsCwd && !force) {
|
|
502
|
+
console.error("sync · CWD não parece ser pasta Predators (sem predators/ · CLAUDE.md · .claude/).");
|
|
503
|
+
console.error(` CWD: ${cwd}`);
|
|
504
|
+
console.error(" · Para sync inicial em pasta vazia · use: npx predators-protocol sync --force");
|
|
505
|
+
console.error(" · Para sync em pasta Predators existente · CWD precisa conter CLAUDE.md ou predators/");
|
|
506
|
+
process.exit(1);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const SYNC_TARGETS = [
|
|
510
|
+
{ rel: "predators", type: "dir" },
|
|
511
|
+
{ rel: "docs", type: "dir" },
|
|
512
|
+
{ rel: ".claude/commands", type: "dir" },
|
|
513
|
+
{ rel: "CLAUDE.md", type: "file" },
|
|
514
|
+
{ rel: "QUICKSTART-SOCIO.md", type: "file" },
|
|
515
|
+
];
|
|
516
|
+
|
|
517
|
+
console.log("Predators Protocol · sync canon files do bundle NPX para CWD");
|
|
518
|
+
console.log(` bundle: ${BUNDLE_DIR}`);
|
|
519
|
+
console.log(` target: ${cwd}`);
|
|
520
|
+
if (dryRun) console.log(" mode: DRY-RUN (zero writes)");
|
|
521
|
+
console.log("");
|
|
522
|
+
|
|
523
|
+
let totalCopied = 0;
|
|
524
|
+
for (const { rel, type } of SYNC_TARGETS) {
|
|
525
|
+
const src = path.join(BUNDLE_DIR, rel);
|
|
526
|
+
const dst = path.join(cwd, rel);
|
|
527
|
+
|
|
528
|
+
if (!fs.existsSync(src)) {
|
|
529
|
+
console.log(` skip: ${rel} (não-presente no bundle)`);
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (dryRun) {
|
|
534
|
+
console.log(` preview: ${rel} (${type}) · would sync from bundle`);
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const backup = backupExistingPath(dst);
|
|
539
|
+
if (backup) {
|
|
540
|
+
console.log(` backup: ${path.basename(backup)}`);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (type === "dir") {
|
|
544
|
+
const r = copyDirRecursive(src, dst);
|
|
545
|
+
console.log(` sync: ${rel}/ (${r.copied} files)`);
|
|
546
|
+
totalCopied += r.copied;
|
|
547
|
+
} else {
|
|
548
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
549
|
+
fs.copyFileSync(src, dst);
|
|
550
|
+
console.log(` sync: ${rel}`);
|
|
551
|
+
totalCopied++;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (dryRun) {
|
|
556
|
+
console.log("\nDRY-RUN complete · use sem --dry-run para aplicar.");
|
|
557
|
+
} else {
|
|
558
|
+
// Record sync event canon (local always · network telemetry if opt-in + endpoint configured)
|
|
559
|
+
const ux = loadUxLib();
|
|
560
|
+
if (ux && ux.config && ux.config.recordSyncEvent) {
|
|
561
|
+
try { ux.config.recordSyncEvent(); } catch (e) { /* graceful · sync continua */ }
|
|
562
|
+
}
|
|
563
|
+
console.log(`\nsync complete · ${totalCopied} files canon writados · backups com sufixo .backup-<timestamp>`);
|
|
564
|
+
console.log("Lei #1 reign: bundle slim · ZERO infra leak (1.0.0 STABLE)");
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
569
|
+
// tour command · cinematic walkthrough canon vigente (1.0.0 STABLE)
|
|
570
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
571
|
+
|
|
572
|
+
function sleep(ms) {
|
|
573
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
async function runTourCommand() {
|
|
577
|
+
const ux = loadUxLib();
|
|
578
|
+
if (!ux) {
|
|
579
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
580
|
+
process.exit(1);
|
|
581
|
+
}
|
|
582
|
+
const args = process.argv.slice(3);
|
|
583
|
+
const fast = args.includes("--fast");
|
|
584
|
+
const beat = fast ? 200 : 800;
|
|
585
|
+
|
|
586
|
+
const theme = ux.config.getTheme();
|
|
587
|
+
console.log("");
|
|
588
|
+
console.log(ux.asciiArt.renderEye(theme));
|
|
589
|
+
await sleep(beat);
|
|
590
|
+
|
|
591
|
+
console.log("");
|
|
592
|
+
console.log("PREDADORES PROTOCOL · tour canon vigente (1.0.0 STABLE)");
|
|
593
|
+
console.log("64 predadores · 10 camadas · 14 leis · 5 garantias Synapse");
|
|
594
|
+
await sleep(beat);
|
|
595
|
+
|
|
596
|
+
console.log("");
|
|
597
|
+
console.log("─── 1/5 · 10 camadas trofic ───");
|
|
598
|
+
await sleep(beat / 2);
|
|
599
|
+
const layers = [
|
|
600
|
+
["apex", "4 predators", "T5", "Águia + Leão + Orca + Tigre"],
|
|
601
|
+
["hunter", "5 predators", "T4-T5", "Tubarão JUIZ + Cyber Squad"],
|
|
602
|
+
["builder", "9 predators", "T3", "Polvo + Tatu + Jaguar + 6"],
|
|
603
|
+
["designer", "8 predators", "T3-T4", "Borboleta + Tucano + Baleia-cantora F4"],
|
|
604
|
+
["copy", "6 predators", "T3", "Serpente-coral + 5"],
|
|
605
|
+
["intel", "8 predators", "T3", "Lobo-solitário + Tarântula + 6"],
|
|
606
|
+
["governance", "6 predators", "T3", "Tigre + Gorila + Lince + 3"],
|
|
607
|
+
["growth", "6 predators", "T2-T3", "Leão push + Formiga + 4"],
|
|
608
|
+
["web3", "6 predators", "T3", "Medusa veto + 5"],
|
|
609
|
+
["meta", "6 predators", "T1-T2", "Dragão + Fênix + Elefante + 3"],
|
|
610
|
+
];
|
|
611
|
+
for (const [layer, count, trophic, examples] of layers) {
|
|
612
|
+
console.log(` · ${layer.padEnd(11)} ${count.padEnd(12)} ${trophic.padEnd(6)} ${examples}`);
|
|
613
|
+
await sleep(beat / 4);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
console.log("");
|
|
617
|
+
console.log("─── 2/5 · 14 leis canon vigentes ───");
|
|
618
|
+
await sleep(beat / 2);
|
|
619
|
+
const laws = [
|
|
620
|
+
"Lei #1 Lei do Sangue (ABSOLUTO · Tubarão Art. 1 imutável)",
|
|
621
|
+
"Lei #2 Lei dos Predadores (Fênix Protocol exclusive)",
|
|
622
|
+
"Lei #3 Lei da Melhoria Disciplinada",
|
|
623
|
+
"Lei #4 Lei da Synapse (5 garantias canon)",
|
|
624
|
+
"Lei #5 Canon dos 3 Vetos (Sangue · Operacional · Constitucional)",
|
|
625
|
+
"Lei #6 Lei dos Predadores Reais (zero demo)",
|
|
626
|
+
"Lei #7 Lei da Matilha Paralela",
|
|
627
|
+
"Lei #8 Verificação Empírica (ABSOLUTO)",
|
|
628
|
+
"Lei #9 Análise antes de Execução",
|
|
629
|
+
"Lei #10 Skill canon estrito",
|
|
630
|
+
"Lei #11 NUNCA MINTA JAMAIS (ABSOLUTO)",
|
|
631
|
+
"Lei #12 O melhor dos melhores",
|
|
632
|
+
"Lei #13 Pureza Predators (ABSOLUTO)",
|
|
633
|
+
"Lei #14 PERFEITO OU FIX-GERAL (BINARY)",
|
|
634
|
+
];
|
|
635
|
+
for (const law of laws) {
|
|
636
|
+
console.log(` · ${law}`);
|
|
637
|
+
await sleep(beat / 5);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
console.log("");
|
|
641
|
+
console.log("─── 3/5 · 4 Diretrizes Comunicação ───");
|
|
642
|
+
await sleep(beat / 2);
|
|
643
|
+
console.log(" 1. Lei do Tom Conversacional (Apex T7 direct)");
|
|
644
|
+
console.log(" 2. Autonomia Sequencial (Lei #9)");
|
|
645
|
+
console.log(" 3. PASSO 0 EVERY ONDA (Lei #8 baseline)");
|
|
646
|
+
console.log(" 4. Separação canon-doc vs comunicação direta");
|
|
647
|
+
await sleep(beat);
|
|
648
|
+
|
|
649
|
+
console.log("");
|
|
650
|
+
console.log("─── 4/5 · 13 comandos NPX vigentes ───");
|
|
651
|
+
await sleep(beat / 2);
|
|
652
|
+
console.log(" introspecção: version · status · list-predators · list-workflows");
|
|
653
|
+
console.log(" state machines: workflow-states · story-states · layers-list · benchmark-info · metrics-list");
|
|
654
|
+
console.log(" experiência UX: init · config · show · sync · tour");
|
|
655
|
+
await sleep(beat);
|
|
656
|
+
|
|
657
|
+
console.log("");
|
|
658
|
+
console.log("─── 5/5 · Comando canon para sócios ───");
|
|
659
|
+
await sleep(beat / 2);
|
|
660
|
+
console.log("");
|
|
661
|
+
console.log(" mkdir predators-protocol && cd predators-protocol");
|
|
662
|
+
console.log(" npx predators-protocol@beta sync --force");
|
|
663
|
+
console.log("");
|
|
664
|
+
console.log(" → 143 files canon na pasta (64 predadores + docs + skills + CLAUDE.md)");
|
|
665
|
+
console.log(" → abre no VS Code · ativa extensão Claude Code");
|
|
666
|
+
console.log(" → /encarnar tubarao-branco (ou qualquer dos 64 IDs)");
|
|
667
|
+
await sleep(beat);
|
|
668
|
+
|
|
669
|
+
console.log("");
|
|
670
|
+
console.log("─── fim do tour ───");
|
|
671
|
+
console.log("");
|
|
672
|
+
console.log("Próximos passos sugeridos:");
|
|
673
|
+
console.log(" · npx predators-protocol@beta sync --force (instala canon na pasta atual)");
|
|
674
|
+
console.log(" · npx predators-protocol@beta show eye (logo cinematográfico)");
|
|
675
|
+
console.log(" · npx predators-protocol@beta show list (lista predator cards disponíveis)");
|
|
676
|
+
console.log(" · npx predators-protocol@beta help (todos os 13 comandos)");
|
|
677
|
+
console.log("");
|
|
678
|
+
console.log("🦈🐋 Predators Protocol · proprietário · Alex Gonzaga (Tubarão-Apex) · 2026-05-24");
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
682
|
+
|
|
683
|
+
const command = process.argv[2] || "help";
|
|
684
|
+
|
|
685
|
+
// Lei #1 [a-m] gates · access-token middleware canon 2026-05-27
|
|
686
|
+
// Sócios bypass via PREDATORS_OWNER_KEY env var · colaboradores via `unlock <TOKEN>`
|
|
687
|
+
const { runUnlock, requireValidAccess } = require("../lib/access-token-client.js");
|
|
688
|
+
// Lei #1 [ok1-ok4] gates · gen-token CLI canon 2026-05-27
|
|
689
|
+
const { runGenToken } = require("../lib/gen-token-client.js");
|
|
690
|
+
// ONDA-SAAS Onda 4b · invoke client (CLI vira cliente de API · chave Bearer self-serve)
|
|
691
|
+
const { runInvoke } = require("../lib/invoke-client.js");
|
|
692
|
+
|
|
693
|
+
async function runUnlockCommand() {
|
|
694
|
+
const token = process.argv[3];
|
|
695
|
+
await runUnlock(token);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
async function runGenTokenCommand() {
|
|
699
|
+
await runGenToken();
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
async function runInvokeCommand() {
|
|
703
|
+
await runInvoke();
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// brain-status command · 1.2.0 · G6 (ONDA-CEREBRO-FIX-GERAL-OPCAO-A 2026-05-31)
|
|
707
|
+
// Snapshot canon + integração validate_daemon_canon runtime real (detecta FAKE-LIVE)
|
|
708
|
+
function tryLiveBrainStatus(cwd) {
|
|
709
|
+
// G6: tenta invocar validate_daemon_canon Python · canon-graceful se ausente
|
|
710
|
+
const { spawnSync } = require("child_process");
|
|
711
|
+
const repoRoot = cwd || process.cwd();
|
|
712
|
+
const helperPath = path.join(repoRoot, "scripts", "_brain_status_canon.py");
|
|
713
|
+
|
|
714
|
+
if (!fs.existsSync(helperPath)) {
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const pyCandidates = [
|
|
719
|
+
process.env.PREDATORS_PYTHON,
|
|
720
|
+
path.join(repoRoot, ".venv", "Scripts", "python.exe"),
|
|
721
|
+
"py",
|
|
722
|
+
"python",
|
|
723
|
+
].filter(Boolean);
|
|
724
|
+
|
|
725
|
+
for (const pyExe of pyCandidates) {
|
|
726
|
+
try {
|
|
727
|
+
const args = pyExe === "py" ? ["-3", helperPath] : [helperPath];
|
|
728
|
+
const result = spawnSync(pyExe, args, {
|
|
729
|
+
cwd: repoRoot,
|
|
730
|
+
encoding: "utf-8",
|
|
731
|
+
env: { ...process.env, PYTHONIOENCODING: "utf-8" },
|
|
732
|
+
timeout: 10000,
|
|
733
|
+
});
|
|
734
|
+
if (result.status === 0 && result.stdout) {
|
|
735
|
+
return result.stdout;
|
|
736
|
+
}
|
|
737
|
+
} catch (err) {
|
|
738
|
+
// try next candidate
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
async function runBrainStatusCommand() {
|
|
745
|
+
// G6: prioriza output LIVE runtime real se disponível
|
|
746
|
+
const liveOutput = tryLiveBrainStatus(process.cwd());
|
|
747
|
+
if (liveOutput && liveOutput.includes("TRULY ALIVE")) {
|
|
748
|
+
console.log("");
|
|
749
|
+
console.log("PREDADORES PROTOCOL · CEREBRO LIVE · runtime real (validate_daemon_canon)");
|
|
750
|
+
console.log("=========================================================================");
|
|
751
|
+
console.log(liveOutput);
|
|
752
|
+
console.log("Honest UPFRONT (Lei #11): output empírico runtime · NÃO snapshot");
|
|
753
|
+
console.log(" · TRULY-LIVE: heartbeat fresh + state-progresso fresh (canon-aligned)");
|
|
754
|
+
console.log(" · FAKE-LIVE: heartbeat fresh MAS state-progresso stale (daemon mente)");
|
|
755
|
+
console.log(" · DEAD: heartbeat ausente OU stale > 60s");
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// Fallback canon-graceful: snapshot bundle (NPX read-only context)
|
|
760
|
+
const snapshotPath = bundlePath("docs/CANON/BRAIN-STATUS-SNAPSHOT.json");
|
|
761
|
+
if (!fs.existsSync(snapshotPath)) {
|
|
762
|
+
console.error("brain-status snapshot ausente no bundle · re-sync canon necessário");
|
|
763
|
+
process.exit(1);
|
|
764
|
+
}
|
|
765
|
+
let snapshot;
|
|
766
|
+
try {
|
|
767
|
+
snapshot = JSON.parse(fs.readFileSync(snapshotPath, "utf-8"));
|
|
768
|
+
} catch (err) {
|
|
769
|
+
console.error(`brain-status snapshot JSON inválido: ${err.message}`);
|
|
770
|
+
process.exit(1);
|
|
771
|
+
}
|
|
772
|
+
console.log("");
|
|
773
|
+
console.log("PREDADORES PROTOCOL · ESTRUTURA CEREBRAL · snapshot canon (read-only)");
|
|
774
|
+
console.log("======================================================================");
|
|
775
|
+
console.log(`Snapshot cravado: ${snapshot.snapshot_at}`);
|
|
776
|
+
console.log(`Commit master: ${snapshot.commit_hash_short}`);
|
|
777
|
+
console.log(`Status agregado: ${snapshot.status_aggregate}`);
|
|
778
|
+
console.log("");
|
|
779
|
+
console.log("Daemons cerebrais (runtime real · não-snapshot):");
|
|
780
|
+
for (const d of snapshot.daemons) {
|
|
781
|
+
console.log(` · ${d.name.padEnd(22)} ${d.role}`);
|
|
782
|
+
}
|
|
783
|
+
console.log("");
|
|
784
|
+
console.log("Feature flags Híbrida (default canon vigente):");
|
|
785
|
+
for (const f of snapshot.feature_flags) {
|
|
786
|
+
const mark = f.default === "true" ? "LIVE" : "OPT-IN";
|
|
787
|
+
console.log(` · ${f.name.padEnd(28)} default=${f.default.padEnd(5)} ${mark}`);
|
|
788
|
+
}
|
|
789
|
+
console.log("");
|
|
790
|
+
console.log("Elefante · memória institucional Art. 6 imutável:");
|
|
791
|
+
console.log(` · pointers cumulative: ${snapshot.elefante.memory_pointers_count}`);
|
|
792
|
+
console.log(` · trace neural files: ${snapshot.elefante.trace_neural_files_count}`);
|
|
793
|
+
console.log(` · consolidation cycles: ${snapshot.elefante.consolidation_cycles_cumulative}`);
|
|
794
|
+
console.log("");
|
|
795
|
+
console.log("Honest UPFRONT (Lei #11):");
|
|
796
|
+
console.log(" · brain-status é READ-only snapshot · cravado no commit acima");
|
|
797
|
+
console.log(" · runtime real exige: clone repo + Python 3.11+ + brain-on.cmd");
|
|
798
|
+
console.log(" · LIVE detection (validate_daemon_canon) só roda em clone do repositório");
|
|
799
|
+
console.log(" · ver bundle/QUICKSTART-SOCIO.md para caminho completo");
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// brand-status command · BrandBook v2 OBSIDIANA · ONDA-BRANDBOOK-CANON-V2 Frente F
|
|
803
|
+
// Snapshot canon paleta + tipografia + cadeia de ratificacao · READ-only
|
|
804
|
+
async function runBrandStatusCommand() {
|
|
805
|
+
const snapshotPath = bundlePath("docs/CANON/BRAND-CANON.json");
|
|
806
|
+
if (!fs.existsSync(snapshotPath)) {
|
|
807
|
+
console.error("brand-status snapshot ausente no bundle · re-sync canon necessário");
|
|
808
|
+
process.exit(1);
|
|
809
|
+
}
|
|
810
|
+
let brand;
|
|
811
|
+
try {
|
|
812
|
+
brand = JSON.parse(fs.readFileSync(snapshotPath, "utf-8"));
|
|
813
|
+
} catch (err) {
|
|
814
|
+
console.error(`brand-status snapshot JSON inválido: ${err.message}`);
|
|
815
|
+
process.exit(1);
|
|
816
|
+
}
|
|
817
|
+
console.log("");
|
|
818
|
+
console.log("PREDADORES PROTOCOL · BRAND CANON · snapshot");
|
|
819
|
+
console.log("============================================");
|
|
820
|
+
console.log(`BrandBook: ${brand.brandbook_version}`);
|
|
821
|
+
console.log(`Snapshot cravado: ${brand.snapshot_at}`);
|
|
822
|
+
console.log(`Onda: ${brand.ratificacao.onda}`);
|
|
823
|
+
console.log(`Canon-doc: ${brand.ratificacao.canon_doc}`);
|
|
824
|
+
console.log(`Substitui: ${brand.ratificacao.substitui}`);
|
|
825
|
+
console.log("");
|
|
826
|
+
console.log(`Paleta · ${brand.paleta.familias} familias canon (WCAG base ${brand.paleta.wcag_base}):`);
|
|
827
|
+
for (const t of brand.paleta.tokens) {
|
|
828
|
+
const wcag = t.wcag ? ` [${t.wcag}]` : "";
|
|
829
|
+
console.log(` · ${t.token.padEnd(16)} ${t.hex.padEnd(9)} ${t.papel}${wcag}`);
|
|
830
|
+
}
|
|
831
|
+
console.log("");
|
|
832
|
+
console.log("Tipografia canon:");
|
|
833
|
+
console.log(` · display ${brand.tipografia.display.familia.padEnd(14)} ${brand.tipografia.display.papel} (${brand.tipografia.display.pesos})`);
|
|
834
|
+
console.log(` · body ${brand.tipografia.body.familia.padEnd(14)} ${brand.tipografia.body.papel}`);
|
|
835
|
+
console.log(` · mono ${brand.tipografia.mono.familia.padEnd(14)} ${brand.tipografia.mono.papel}`);
|
|
836
|
+
console.log("");
|
|
837
|
+
console.log(`Runtime source-of-truth: ${brand.runtime_source_of_truth}`);
|
|
838
|
+
console.log("");
|
|
839
|
+
console.log("Honest UPFRONT (Lei #11):");
|
|
840
|
+
for (const h of brand.honest_upfront) {
|
|
841
|
+
console.log(` · ${h}`);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
const commandsCanon = {
|
|
846
|
+
version: printVersionCanon,
|
|
847
|
+
status: printStatusCanon,
|
|
848
|
+
"list-predators": listPredatorsCanon,
|
|
849
|
+
"list-workflows": listWorkflowsCanon,
|
|
850
|
+
"workflow-states": listWorkflowStatesCanon,
|
|
851
|
+
"story-states": listStoryStatesCanon,
|
|
852
|
+
"layers-list": listLayersCanon,
|
|
853
|
+
"benchmark-info": showBenchmarkInfoCanon,
|
|
854
|
+
"metrics-list": listGoldenSignalsCanon,
|
|
855
|
+
init: runInitCommand,
|
|
856
|
+
config: runConfigCommand,
|
|
857
|
+
show: runShowCommand,
|
|
858
|
+
sync: runSyncCommand,
|
|
859
|
+
install: runInstallCommand,
|
|
860
|
+
tour: runTourCommand,
|
|
861
|
+
unlock: runUnlockCommand,
|
|
862
|
+
"gen-token": runGenTokenCommand,
|
|
863
|
+
invoke: runInvokeCommand,
|
|
864
|
+
"brain-status": runBrainStatusCommand,
|
|
865
|
+
"brand-status": runBrandStatusCommand,
|
|
866
|
+
help: printHelpCanon,
|
|
867
|
+
"--help": printHelpCanon,
|
|
868
|
+
"-h": printHelpCanon,
|
|
869
|
+
};
|
|
870
|
+
|
|
871
|
+
const handler = commandsCanon[command];
|
|
872
|
+
if (!handler) {
|
|
873
|
+
console.error(`Comando canon NÃO vigente: ${command}`);
|
|
874
|
+
printHelpCanon();
|
|
875
|
+
process.exit(1);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// Lei #1 middleware · valida acesso ANTES de executar comando sensível
|
|
879
|
+
// (PUBLIC_COMMANDS · owner bypass · cache local 5min · phone-home revalidação)
|
|
880
|
+
(async () => {
|
|
881
|
+
try {
|
|
882
|
+
await requireValidAccess(command);
|
|
883
|
+
await handler();
|
|
884
|
+
} catch (err) {
|
|
885
|
+
console.error(`Falha runtime canon: ${err && err.message ? err.message : err}`);
|
|
886
|
+
process.exit(1);
|
|
887
|
+
}
|
|
888
|
+
})();
|