predators-protocol 0.5.0-beta.0 → 0.5.3-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.
- package/bin/predators-cli.js +726 -637
- package/lib/access-token-client.js +284 -0
- package/lib/gen-token-client.js +210 -0
- package/lib/heartbeat-animation.js +147 -0
- package/lib/splash.js +117 -114
- package/package.json +3 -3
package/bin/predators-cli.js
CHANGED
|
@@ -1,637 +1,726 @@
|
|
|
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.
|
|
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.4.0-beta.0 (Lei #14 PERFEITO OU FIX-GERAL)
|
|
70
|
-
|
|
71
|
-
USO:
|
|
72
|
-
npx predators-protocol <comando>
|
|
73
|
-
|
|
74
|
-
COMANDOS canon vigentes (
|
|
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
|
|
91
|
-
config Preferências user (theme · audio · splash · telemetry)
|
|
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
|
-
tour Cinematic walkthrough · 5 atos canon (camadas · leis · diretrizes · comandos · próximos passos)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
console.log(
|
|
136
|
-
console.log(`
|
|
137
|
-
console.log(`
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
console.log(
|
|
142
|
-
console.log(
|
|
143
|
-
console.log(
|
|
144
|
-
console.log(
|
|
145
|
-
console.log(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
console.log("
|
|
150
|
-
console.log("
|
|
151
|
-
console.log("
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
console.log("
|
|
156
|
-
console.log("
|
|
157
|
-
console.log("
|
|
158
|
-
console.log("
|
|
159
|
-
console.log(" -
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function
|
|
163
|
-
console.log("
|
|
164
|
-
console.log("
|
|
165
|
-
console.log("
|
|
166
|
-
console.log("
|
|
167
|
-
console.log("
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
console.log("
|
|
172
|
-
console.log(" PENDING
|
|
173
|
-
console.log("
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
console.log("");
|
|
199
|
-
console.log("L0
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
console.log("
|
|
204
|
-
console.log("");
|
|
205
|
-
console.log("
|
|
206
|
-
console.log("
|
|
207
|
-
console.log("
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.log("
|
|
212
|
-
console.log("");
|
|
213
|
-
console.log("
|
|
214
|
-
console.log("
|
|
215
|
-
console.log("
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
console.log("");
|
|
234
|
-
console.log("
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
console.log(`
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
console.
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
483
|
-
|
|
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
|
-
"Lei #
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
console.log("
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
console.log("
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
console.log("");
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
console.
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
console.
|
|
636
|
-
|
|
637
|
-
|
|
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.5.3-beta.0-fix-public-introspection-2026-05-27";
|
|
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.4.0-beta.0 (Lei #14 PERFEITO OU FIX-GERAL)
|
|
70
|
+
|
|
71
|
+
USO:
|
|
72
|
+
npx predators-protocol <comando>
|
|
73
|
+
|
|
74
|
+
COMANDOS canon vigentes (16 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
|
+
config Preferências user (theme · audio · splash · telemetry)
|
|
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
|
+
tour Cinematic walkthrough · 5 atos canon (camadas · leis · diretrizes · comandos · próximos passos)
|
|
95
|
+
|
|
96
|
+
-- fase R2 (onboarding · 2026-05-26 · Polvo · 1 comando novo) --
|
|
97
|
+
install Alias semântico para 'sync --force' · UX onboarding clearer
|
|
98
|
+
|
|
99
|
+
-- fase TOKEN-COLABORADOR (2026-05-27 · Borboleta + Jaguar · 2 comandos novos) --
|
|
100
|
+
unlock <TOKEN> Ativa acesso colaborador via token (canon access-token-client)
|
|
101
|
+
gen-token Apex T7 gera token via CLI (PREDATORS_OWNER_KEY_BACKEND env)
|
|
102
|
+
Usage: gen-token --name "Nome" [--email x] [--list]
|
|
103
|
+
|
|
104
|
+
help Exibe esta mensagem
|
|
105
|
+
|
|
106
|
+
Lei #11 honest UPFRONT 0.4.0-beta.0 cumulativa:
|
|
107
|
+
· Bundle slim · 143 files · 64 predadores + canon docs + 7 skills · ZERO infra leak audit (Lei #1 reign)
|
|
108
|
+
· sync command requer CWD contendo predators/ OU --force flag · pattern canon partner-bundle
|
|
109
|
+
· Baleia-cantora F4 audio designer · 5 signature canon specs cravadas · .mp3 byte pendente produção externa
|
|
110
|
+
· Telemetry opt-in default-off · anonymous_id UUID · zero PII · endpoint future (config telemetry --enable)
|
|
111
|
+
`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function printVersionCanon() {
|
|
115
|
+
console.log(CLI_VERSION_CANON);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function printStatusCanon() {
|
|
119
|
+
const synapseMd = bundlePath("docs/SYNAPSE.md");
|
|
120
|
+
const encarnacaoMd = bundlePath("docs/ENCARNACAO.md");
|
|
121
|
+
const claudeMd = bundlePath("CLAUDE.md");
|
|
122
|
+
const predatorsDir = bundlePath("predators");
|
|
123
|
+
const skillsDir = bundlePath(".claude/commands");
|
|
124
|
+
let predatorCount = 0;
|
|
125
|
+
if (fs.existsSync(predatorsDir)) {
|
|
126
|
+
const walk = (dir) => {
|
|
127
|
+
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
128
|
+
const p = path.join(dir, e.name);
|
|
129
|
+
if (e.isDirectory()) walk(p);
|
|
130
|
+
else if (e.name === "predator.json") predatorCount++;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
walk(predatorsDir);
|
|
134
|
+
}
|
|
135
|
+
console.log("canon Predators status:");
|
|
136
|
+
console.log(` CLI version: ${CLI_VERSION_CANON}`);
|
|
137
|
+
console.log(` bundle root: ${BUNDLE_DIR}`);
|
|
138
|
+
console.log(` CLAUDE.md: ${fs.existsSync(claudeMd) ? "PRESENT" : "MISSING"}`);
|
|
139
|
+
console.log(` SYNAPSE.md: ${fs.existsSync(synapseMd) ? "PRESENT" : "MISSING"}`);
|
|
140
|
+
console.log(` ENCARNACAO.md: ${fs.existsSync(encarnacaoMd) ? "PRESENT" : "MISSING"}`);
|
|
141
|
+
console.log(` predators canon: ${predatorCount}/63 byte-presente`);
|
|
142
|
+
console.log(` .claude/commands/: ${fs.existsSync(skillsDir) ? "PRESENT" : "MISSING"}`);
|
|
143
|
+
console.log(` Lei #14 canon: PERFEITO OU FIX-GERAL ratificada constitucional`);
|
|
144
|
+
console.log(` Lei #1 reign: bundle slim · ZERO infra leak audit (0.3.0-beta.0)`);
|
|
145
|
+
console.log(` Diretrizes 4 (2026-05-24): Lei do Tom · Autonomia Sequencial · PASSO 0 EVERY · Separação canon-doc/comunicação`);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function listPredatorsCanon() {
|
|
149
|
+
console.log("64 predadores frota canon vigente pós-F4 Baleia-cantora:");
|
|
150
|
+
console.log(" apex: 4 (Águia + Leão + Orca + Tigre-siberiano)");
|
|
151
|
+
console.log(" hunter: 5 (Tubarão-branco JUIZ FINAL Art. 14 + Escorpião + Hiena + Crocodilo + Piranha)");
|
|
152
|
+
console.log(" builder: 9 (Jaguar + Tatu-bola + Coruja + Pirarucu + Lince + Polvo + 3)");
|
|
153
|
+
console.log(" designer: 8 (Borboleta-azul + Tucano-toco + Baleia-cantora + 5)");
|
|
154
|
+
console.log(" copy: 6 (Serpente-coral + 5)");
|
|
155
|
+
console.log(" intel: 8 (Lobo-solitário + Tarântula + Jiboia + 5)");
|
|
156
|
+
console.log(" governance: 6");
|
|
157
|
+
console.log(" growth: 6");
|
|
158
|
+
console.log(" web3: 6 (Medusa + 5)");
|
|
159
|
+
console.log(" meta: 6 (Dragão-ancestral + Elefante + Fênix + Camaleão + Serpente + 1)");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function listWorkflowsCanon() {
|
|
163
|
+
console.log("4 workflows canon Predators (Lei #13 Pureza):");
|
|
164
|
+
console.log(" - caca-sistematica");
|
|
165
|
+
console.log(" - pacto-cyber-squad");
|
|
166
|
+
console.log(" - pipeline-fenix");
|
|
167
|
+
console.log(" - saneamento-brownfield");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function listWorkflowStatesCanon() {
|
|
171
|
+
console.log("6 WorkflowStateCanon canon Predators (D2 ETAPA 2 state machine):");
|
|
172
|
+
console.log(" PENDING · workflow definição cravada · zero execução");
|
|
173
|
+
console.log(" SCHEDULED · próxima execução planejada · cron canon");
|
|
174
|
+
console.log(" RUNNING · steps em execução runtime");
|
|
175
|
+
console.log(" COMPLETED · todos steps OK · success path");
|
|
176
|
+
console.log(" FAILED · step falhou · rollback canon");
|
|
177
|
+
console.log(" PAUSED · humano interrompeu · retomar manual");
|
|
178
|
+
console.log("");
|
|
179
|
+
console.log("7 transições válidas canon (Lei #4 reign state machine):");
|
|
180
|
+
console.log(" PENDING → SCHEDULED · SCHEDULED → RUNNING · RUNNING → COMPLETED");
|
|
181
|
+
console.log(" RUNNING → FAILED · RUNNING → PAUSED · PAUSED → RUNNING · FAILED → PENDING");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function listStoryStatesCanon() {
|
|
185
|
+
console.log("5 StoryStateCanon canon Predators (D3 ETAPA 3 state machine):");
|
|
186
|
+
console.log(" DRAFT · criação inicial · briefing parcial");
|
|
187
|
+
console.log(" REFINEMENT · briefing completo · Águia preside refinamento");
|
|
188
|
+
console.log(" READY · predator owner identificado · scope clear");
|
|
189
|
+
console.log(" IN_PROGRESS · predator encarnado executando");
|
|
190
|
+
console.log(" DONE · 5 garantias entregues · audit Tubarão PASS");
|
|
191
|
+
console.log("");
|
|
192
|
+
console.log("7 transições válidas canon:");
|
|
193
|
+
console.log(" DRAFT → REFINEMENT → READY → IN_PROGRESS → DONE (caminho canônico)");
|
|
194
|
+
console.log(" REFINEMENT/READY/IN_PROGRESS → DRAFT (rejeição com feedback)");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function listLayersCanon() {
|
|
198
|
+
console.log("7 ContextLayerCanon L0-L6 canon Predators (D5 ETAPA 1 runtime middleware):");
|
|
199
|
+
console.log(" L0 LEI_DO_SANGUE_ART_1 · CRITICAL_imutavel priority 1000");
|
|
200
|
+
console.log(" L1 LEI_4_SYNAPSE_5_GARANTIAS · CRITICAL_reign priority 900");
|
|
201
|
+
console.log(" L2 5_IMUTAVEIS_BYTE_PRESERVED · CRITICAL_byte_preserved priority 800");
|
|
202
|
+
console.log(" L3 14_LEIS_CANON_VIGENTES · ALTA_vigente priority 600");
|
|
203
|
+
console.log(" L4 PREDATOR_ENCARNADO_CONSTITUTION · ALTA_encarnacao priority 500");
|
|
204
|
+
console.log(" L5 TASK_ESPECIFICA_CONTEXTO · MEDIA_task priority 300");
|
|
205
|
+
console.log(" L6 USER_PROMPT_INPUT · INFO_user_input priority 100");
|
|
206
|
+
console.log("");
|
|
207
|
+
console.log("L0+L1+L2 CRITICAL mandatory · Lei #14 BINARY FIX-GERAL trigger se ausentes");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function showBenchmarkInfoCanon() {
|
|
211
|
+
console.log("Benchmark canon Predators · scipy.stats N=180 p<0.05 protocol:");
|
|
212
|
+
console.log("");
|
|
213
|
+
console.log(" dimensions canon (6):");
|
|
214
|
+
console.log(" D5_context_layers_L0_L6");
|
|
215
|
+
console.log(" D2_workflows_engine");
|
|
216
|
+
console.log(" D3_stories_lifecycle");
|
|
217
|
+
console.log(" D4_multi_project_filesystem");
|
|
218
|
+
console.log(" D1_mcp_consuming");
|
|
219
|
+
console.log(" D6_dispatcher_integration");
|
|
220
|
+
console.log("");
|
|
221
|
+
console.log(" parâmetros estatísticos canon:");
|
|
222
|
+
console.log(" sample size per dimension: 30");
|
|
223
|
+
console.log(" total samples N: 180");
|
|
224
|
+
console.log(" p-value threshold: < 0.05");
|
|
225
|
+
console.log(" confidence interval: 95%");
|
|
226
|
+
console.log("");
|
|
227
|
+
console.log(" ttest_ind canon próprio Lei #13 Pureza (sem scipy hard-dep)");
|
|
228
|
+
console.log("");
|
|
229
|
+
console.log("Lei #11 honest UPFRONT: execução real depende provisioning Apex T7");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function listGoldenSignalsCanon() {
|
|
233
|
+
console.log("4 Golden Signals canon M1 APM Predators (B2 ONDA PRIORIDADES):");
|
|
234
|
+
console.log(" latency_milliseconds · CanonMetricHistogram (p50/p95/p99 via percentile_canon)");
|
|
235
|
+
console.log(" traffic_total · CanonMetricCounter");
|
|
236
|
+
console.log(" errors_total · CanonMetricCounter");
|
|
237
|
+
console.log(" saturation_active · CanonMetricGauge");
|
|
238
|
+
console.log("");
|
|
239
|
+
console.log("5 dimensões instrumentadas canon:");
|
|
240
|
+
console.log(" D1_mcp_consuming · D2_workflows_engine · D3_stories_lifecycle · D4_multi_project_filesystem · D5_context_layers_middleware");
|
|
241
|
+
console.log("");
|
|
242
|
+
console.log("Lei #13 Pureza: metrics canon próprio · duck-type prometheus_client (sem hard-dep externa)");
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
246
|
+
// UX layer commands (additive · Lei #4 byte-canon preserve)
|
|
247
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
248
|
+
|
|
249
|
+
async function runInitCommand() {
|
|
250
|
+
const args = process.argv.slice(3);
|
|
251
|
+
const positionalArgs = args.filter(a => !a.startsWith("-"));
|
|
252
|
+
const projectName = positionalArgs[0] || null;
|
|
253
|
+
|
|
254
|
+
// Polymorphic init (R2 onda · 2026-05-26 · Polvo Builder)
|
|
255
|
+
// - no positional arg → splash UX (backward compat byte-preserved)
|
|
256
|
+
// - positional arg → project scaffolding (mkdir + sync inside)
|
|
257
|
+
if (projectName) {
|
|
258
|
+
return runInitProjectMode(projectName, args);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const ux = loadUxLib();
|
|
262
|
+
if (!ux) {
|
|
263
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
264
|
+
process.exit(1);
|
|
265
|
+
}
|
|
266
|
+
const forceFlag = args.includes("--force") || args.includes("-f");
|
|
267
|
+
const minimalFlag = args.includes("--minimal") || args.includes("-m");
|
|
268
|
+
await ux.splash.runInitSplash({ force: forceFlag, minimal: minimalFlag });
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function runInitProjectMode(projectName, args) {
|
|
272
|
+
const cwd = process.cwd();
|
|
273
|
+
const targetDir = path.resolve(cwd, projectName);
|
|
274
|
+
const force = args.includes("--force") || args.includes("-f");
|
|
275
|
+
|
|
276
|
+
if (fs.existsSync(targetDir)) {
|
|
277
|
+
const contents = fs.readdirSync(targetDir);
|
|
278
|
+
if (contents.length > 0 && !force) {
|
|
279
|
+
console.error(`init · diretório ${projectName} já existe e não está vazio.`);
|
|
280
|
+
console.error(" · Use diretório vazio · OU passe --force para sobrescrever (cuidado)");
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
console.log("Predators Protocol · init project canon (R2 onda 2026-05-26 · Polvo)");
|
|
288
|
+
console.log(` projeto: ${projectName}`);
|
|
289
|
+
console.log(` path: ${targetDir}`);
|
|
290
|
+
console.log("");
|
|
291
|
+
|
|
292
|
+
process.chdir(targetDir);
|
|
293
|
+
if (!process.argv.includes("--force")) {
|
|
294
|
+
process.argv.push("--force");
|
|
295
|
+
}
|
|
296
|
+
runSyncCommand();
|
|
297
|
+
|
|
298
|
+
console.log("");
|
|
299
|
+
console.log("Próximos passos:");
|
|
300
|
+
console.log(` cd ${projectName}`);
|
|
301
|
+
console.log(" npx predators-protocol tour # tour cinematográfico");
|
|
302
|
+
console.log(" npx predators-protocol show eye # logo canon");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function runInstallCommand() {
|
|
306
|
+
// Alias semântico canon para `sync --force` (UX onboarding clearer)
|
|
307
|
+
// R2 onda · 2026-05-26 · Polvo · LMAS parity sem violar Lei #13 (canon próprio)
|
|
308
|
+
console.log("install · alias canon para `sync --force` · instala canon files no CWD");
|
|
309
|
+
console.log("");
|
|
310
|
+
if (!process.argv.includes("--force")) {
|
|
311
|
+
process.argv.push("--force");
|
|
312
|
+
}
|
|
313
|
+
runSyncCommand();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function runConfigCommand() {
|
|
317
|
+
const ux = loadUxLib();
|
|
318
|
+
if (!ux) {
|
|
319
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
320
|
+
process.exit(1);
|
|
321
|
+
}
|
|
322
|
+
const subcommand = process.argv[3] || "show";
|
|
323
|
+
const arg = process.argv[4];
|
|
324
|
+
|
|
325
|
+
if (subcommand === "show" || subcommand === "status") {
|
|
326
|
+
const cfg = ux.config.readConfig();
|
|
327
|
+
console.log("Predators Protocol · user config");
|
|
328
|
+
console.log(` path: ${ux.config.getConfigPath()}`);
|
|
329
|
+
console.log(` theme: ${cfg.theme}`);
|
|
330
|
+
console.log(` splash.enabled: ${cfg.splash.enabled}`);
|
|
331
|
+
console.log(` audio.enabled: ${cfg.audio.enabled}`);
|
|
332
|
+
console.log(` firstConnectionAt: ${cfg.firstConnectionAt || "(never)"}`);
|
|
333
|
+
console.log(` lastConnectionAt: ${cfg.lastConnectionAt || "(never)"}`);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (subcommand === "theme") {
|
|
337
|
+
if (!arg) {
|
|
338
|
+
console.log(`Current theme: ${ux.config.getTheme()}`);
|
|
339
|
+
console.log("Available: default, dark, light, monochrome");
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const result = ux.config.setTheme(arg);
|
|
343
|
+
if (result) {
|
|
344
|
+
console.log(`Theme set: ${arg}`);
|
|
345
|
+
} else {
|
|
346
|
+
console.error(`Invalid theme: ${arg} · available: default, dark, light, monochrome`);
|
|
347
|
+
process.exit(1);
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (subcommand === "audio") {
|
|
352
|
+
if (arg === "--enable" || arg === "on") {
|
|
353
|
+
ux.config.setAudioEnabled(true);
|
|
354
|
+
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/)");
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (arg === "--disable" || arg === "off") {
|
|
358
|
+
ux.config.setAudioEnabled(false);
|
|
359
|
+
console.log("Audio: disabled");
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (arg === "--status" || !arg) {
|
|
363
|
+
const status = ux.audio.getStatusReport();
|
|
364
|
+
console.log("Audio status canon:");
|
|
365
|
+
console.log(` enabled: ${status.enabled}`);
|
|
366
|
+
console.log(` platform: ${status.platform} (WSL: ${status.is_wsl})`);
|
|
367
|
+
console.log(` player_available: ${status.player_available} (${status.player_cmd || "none"})`);
|
|
368
|
+
console.log(` ${status.canon_note}`);
|
|
369
|
+
console.log(" signatures Baleia-cantora F4 Fase 2:");
|
|
370
|
+
for (const s of status.sounds) {
|
|
371
|
+
console.log(` · ${s.name} - ${s.description} (file: ${s.file_present ? "PRESENT" : "PENDENTE"})`);
|
|
372
|
+
}
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (subcommand === "telemetry") {
|
|
377
|
+
if (arg === "--enable" || arg === "on") {
|
|
378
|
+
ux.config.setTelemetryEnabled(true);
|
|
379
|
+
const status = ux.config.getTelemetryStatus();
|
|
380
|
+
console.log("Telemetry: enabled");
|
|
381
|
+
console.log(` anonymous_id: ${status.anonymous_id} (gerado runtime · zero PII)`);
|
|
382
|
+
console.log(` endpoint: ${status.endpoint || "local-only (future network endpoint TBD Apex T7)"}`);
|
|
383
|
+
console.log(" Lei #1 reign: zero PII · zero IP capture · zero hostname · só sync events anônimos");
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (arg === "--disable" || arg === "off") {
|
|
387
|
+
ux.config.setTelemetryEnabled(false);
|
|
388
|
+
console.log("Telemetry: disabled · zero coleta");
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (arg === "--status" || !arg) {
|
|
392
|
+
const status = ux.config.getTelemetryStatus();
|
|
393
|
+
console.log("Telemetry status canon:");
|
|
394
|
+
console.log(` enabled: ${status.enabled}`);
|
|
395
|
+
console.log(` anonymous_id: ${status.anonymous_id || "(não gerado · opt-in pendente)"}`);
|
|
396
|
+
console.log(` sync_count: ${status.sync_count}`);
|
|
397
|
+
console.log(` last_sync_at: ${status.last_sync_at || "(nunca)"}`);
|
|
398
|
+
console.log(` endpoint: ${status.endpoint || "local-only (null)"}`);
|
|
399
|
+
console.log(` ${status.canon_note}`);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
console.error(`Config subcommand desconhecido: ${subcommand}`);
|
|
404
|
+
console.error("Available: show · theme [default|dark|light|monochrome] · audio [--enable|--disable|--status] · telemetry [--enable|--disable|--status]");
|
|
405
|
+
process.exit(1);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function runShowCommand() {
|
|
409
|
+
const ux = loadUxLib();
|
|
410
|
+
if (!ux) {
|
|
411
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
412
|
+
process.exit(1);
|
|
413
|
+
}
|
|
414
|
+
const target = process.argv[3] || "eye";
|
|
415
|
+
const theme = ux.config.getTheme();
|
|
416
|
+
|
|
417
|
+
if (target === "eye" || target === "logo") {
|
|
418
|
+
console.log(ux.asciiArt.renderEye(theme));
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (target === "banner") {
|
|
422
|
+
console.log(ux.asciiArt.renderHeroBanner(theme));
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (target === "list") {
|
|
426
|
+
console.log("Predator cards canon vigentes:");
|
|
427
|
+
for (const id of ux.asciiArt.listPredatorsWithCards()) {
|
|
428
|
+
console.log(` · ${id}`);
|
|
429
|
+
}
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const card = ux.asciiArt.renderPredatorCard(target, theme);
|
|
433
|
+
if (!card) {
|
|
434
|
+
console.error(`Predator card não-disponível: ${target}`);
|
|
435
|
+
console.error("Disponíveis: " + ux.asciiArt.listPredatorsWithCards().join(", "));
|
|
436
|
+
console.error("Outros targets: eye | logo | banner | list");
|
|
437
|
+
process.exit(1);
|
|
438
|
+
}
|
|
439
|
+
console.log(card);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
443
|
+
// sync command · canon files refresh CWD from bundle (0.3.0-beta.0)
|
|
444
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
445
|
+
|
|
446
|
+
function copyDirRecursive(src, dst) {
|
|
447
|
+
if (!fs.existsSync(src)) return { copied: 0, skipped: 0 };
|
|
448
|
+
fs.mkdirSync(dst, { recursive: true });
|
|
449
|
+
let copied = 0;
|
|
450
|
+
let skipped = 0;
|
|
451
|
+
for (const e of fs.readdirSync(src, { withFileTypes: true })) {
|
|
452
|
+
const s = path.join(src, e.name);
|
|
453
|
+
const d = path.join(dst, e.name);
|
|
454
|
+
if (e.isDirectory()) {
|
|
455
|
+
const r = copyDirRecursive(s, d);
|
|
456
|
+
copied += r.copied;
|
|
457
|
+
skipped += r.skipped;
|
|
458
|
+
} else {
|
|
459
|
+
fs.copyFileSync(s, d);
|
|
460
|
+
copied++;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return { copied, skipped };
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function backupExistingPath(target) {
|
|
467
|
+
if (!fs.existsSync(target)) return null;
|
|
468
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-");
|
|
469
|
+
const backup = `${target}.backup-${ts}`;
|
|
470
|
+
fs.renameSync(target, backup);
|
|
471
|
+
return backup;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function runSyncCommand() {
|
|
475
|
+
const args = process.argv.slice(3);
|
|
476
|
+
const dryRun = args.includes("--dry-run");
|
|
477
|
+
const force = args.includes("--force") || args.includes("-f");
|
|
478
|
+
const cwd = process.cwd();
|
|
479
|
+
|
|
480
|
+
// Refuse to overwrite a non-Predators directory unless --force passed.
|
|
481
|
+
const looksLikePredatorsCwd =
|
|
482
|
+
fs.existsSync(path.join(cwd, "predators")) ||
|
|
483
|
+
fs.existsSync(path.join(cwd, "CLAUDE.md")) ||
|
|
484
|
+
fs.existsSync(path.join(cwd, ".claude")) ||
|
|
485
|
+
fs.existsSync(path.join(cwd, "QUICKSTART-SOCIO.md"));
|
|
486
|
+
|
|
487
|
+
if (!looksLikePredatorsCwd && !force) {
|
|
488
|
+
console.error("sync · CWD não parece ser pasta Predators (sem predators/ · CLAUDE.md · .claude/).");
|
|
489
|
+
console.error(` CWD: ${cwd}`);
|
|
490
|
+
console.error(" · Para sync inicial em pasta vazia · use: npx predators-protocol sync --force");
|
|
491
|
+
console.error(" · Para sync em pasta Predators existente · CWD precisa conter CLAUDE.md ou predators/");
|
|
492
|
+
process.exit(1);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const SYNC_TARGETS = [
|
|
496
|
+
{ rel: "predators", type: "dir" },
|
|
497
|
+
{ rel: "docs", type: "dir" },
|
|
498
|
+
{ rel: ".claude/commands", type: "dir" },
|
|
499
|
+
{ rel: "CLAUDE.md", type: "file" },
|
|
500
|
+
{ rel: "QUICKSTART-SOCIO.md", type: "file" },
|
|
501
|
+
];
|
|
502
|
+
|
|
503
|
+
console.log("Predators Protocol · sync canon files do bundle NPX para CWD");
|
|
504
|
+
console.log(` bundle: ${BUNDLE_DIR}`);
|
|
505
|
+
console.log(` target: ${cwd}`);
|
|
506
|
+
if (dryRun) console.log(" mode: DRY-RUN (zero writes)");
|
|
507
|
+
console.log("");
|
|
508
|
+
|
|
509
|
+
let totalCopied = 0;
|
|
510
|
+
for (const { rel, type } of SYNC_TARGETS) {
|
|
511
|
+
const src = path.join(BUNDLE_DIR, rel);
|
|
512
|
+
const dst = path.join(cwd, rel);
|
|
513
|
+
|
|
514
|
+
if (!fs.existsSync(src)) {
|
|
515
|
+
console.log(` skip: ${rel} (não-presente no bundle)`);
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (dryRun) {
|
|
520
|
+
console.log(` preview: ${rel} (${type}) · would sync from bundle`);
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const backup = backupExistingPath(dst);
|
|
525
|
+
if (backup) {
|
|
526
|
+
console.log(` backup: ${path.basename(backup)}`);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (type === "dir") {
|
|
530
|
+
const r = copyDirRecursive(src, dst);
|
|
531
|
+
console.log(` sync: ${rel}/ (${r.copied} files)`);
|
|
532
|
+
totalCopied += r.copied;
|
|
533
|
+
} else {
|
|
534
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
535
|
+
fs.copyFileSync(src, dst);
|
|
536
|
+
console.log(` sync: ${rel}`);
|
|
537
|
+
totalCopied++;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (dryRun) {
|
|
542
|
+
console.log("\nDRY-RUN complete · use sem --dry-run para aplicar.");
|
|
543
|
+
} else {
|
|
544
|
+
// Record sync event canon (local always · network telemetry if opt-in + endpoint configured)
|
|
545
|
+
const ux = loadUxLib();
|
|
546
|
+
if (ux && ux.config && ux.config.recordSyncEvent) {
|
|
547
|
+
try { ux.config.recordSyncEvent(); } catch (e) { /* graceful · sync continua */ }
|
|
548
|
+
}
|
|
549
|
+
console.log(`\nsync complete · ${totalCopied} files canon writados · backups com sufixo .backup-<timestamp>`);
|
|
550
|
+
console.log("Lei #1 reign: bundle slim · ZERO infra leak (0.4.0-beta.0)");
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
555
|
+
// tour command · cinematic walkthrough canon vigente (0.4.0-beta.0)
|
|
556
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
557
|
+
|
|
558
|
+
function sleep(ms) {
|
|
559
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
async function runTourCommand() {
|
|
563
|
+
const ux = loadUxLib();
|
|
564
|
+
if (!ux) {
|
|
565
|
+
console.error("UX layer não-disponível neste pacote.");
|
|
566
|
+
process.exit(1);
|
|
567
|
+
}
|
|
568
|
+
const args = process.argv.slice(3);
|
|
569
|
+
const fast = args.includes("--fast");
|
|
570
|
+
const beat = fast ? 200 : 800;
|
|
571
|
+
|
|
572
|
+
const theme = ux.config.getTheme();
|
|
573
|
+
console.log("");
|
|
574
|
+
console.log(ux.asciiArt.renderEye(theme));
|
|
575
|
+
await sleep(beat);
|
|
576
|
+
|
|
577
|
+
console.log("");
|
|
578
|
+
console.log("PREDADORES PROTOCOL · tour canon vigente (0.4.0-beta.0)");
|
|
579
|
+
console.log("64 predadores · 10 camadas · 14 leis · 5 garantias Synapse");
|
|
580
|
+
await sleep(beat);
|
|
581
|
+
|
|
582
|
+
console.log("");
|
|
583
|
+
console.log("─── 1/5 · 10 camadas trofic ───");
|
|
584
|
+
await sleep(beat / 2);
|
|
585
|
+
const layers = [
|
|
586
|
+
["apex", "4 predators", "T5", "Águia + Leão + Orca + Tigre"],
|
|
587
|
+
["hunter", "5 predators", "T4-T5", "Tubarão JUIZ + Cyber Squad"],
|
|
588
|
+
["builder", "9 predators", "T3", "Polvo + Tatu + Jaguar + 6"],
|
|
589
|
+
["designer", "8 predators", "T3-T4", "Borboleta + Tucano + Baleia-cantora F4"],
|
|
590
|
+
["copy", "6 predators", "T3", "Serpente-coral + 5"],
|
|
591
|
+
["intel", "8 predators", "T3", "Lobo-solitário + Tarântula + 6"],
|
|
592
|
+
["governance", "6 predators", "T3", "Tigre + Gorila + Lince + 3"],
|
|
593
|
+
["growth", "6 predators", "T2-T3", "Leão push + Formiga + 4"],
|
|
594
|
+
["web3", "6 predators", "T3", "Medusa veto + 5"],
|
|
595
|
+
["meta", "6 predators", "T1-T2", "Dragão + Fênix + Elefante + 3"],
|
|
596
|
+
];
|
|
597
|
+
for (const [layer, count, trophic, examples] of layers) {
|
|
598
|
+
console.log(` · ${layer.padEnd(11)} ${count.padEnd(12)} ${trophic.padEnd(6)} ${examples}`);
|
|
599
|
+
await sleep(beat / 4);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
console.log("");
|
|
603
|
+
console.log("─── 2/5 · 14 leis canon vigentes ───");
|
|
604
|
+
await sleep(beat / 2);
|
|
605
|
+
const laws = [
|
|
606
|
+
"Lei #1 Lei do Sangue (ABSOLUTO · Tubarão Art. 1 imutável)",
|
|
607
|
+
"Lei #2 Lei dos Predadores (Fênix Protocol exclusive)",
|
|
608
|
+
"Lei #3 Lei da Melhoria Disciplinada",
|
|
609
|
+
"Lei #4 Lei da Synapse (5 garantias canon)",
|
|
610
|
+
"Lei #5 Canon dos 3 Vetos (Sangue · Operacional · Constitucional)",
|
|
611
|
+
"Lei #6 Lei dos Predadores Reais (zero demo)",
|
|
612
|
+
"Lei #7 Lei da Matilha Paralela",
|
|
613
|
+
"Lei #8 Verificação Empírica (ABSOLUTO)",
|
|
614
|
+
"Lei #9 Análise antes de Execução",
|
|
615
|
+
"Lei #10 Skill canon estrito",
|
|
616
|
+
"Lei #11 NUNCA MINTA JAMAIS (ABSOLUTO)",
|
|
617
|
+
"Lei #12 O melhor dos melhores",
|
|
618
|
+
"Lei #13 Pureza Predators (ABSOLUTO)",
|
|
619
|
+
"Lei #14 PERFEITO OU FIX-GERAL (BINARY)",
|
|
620
|
+
];
|
|
621
|
+
for (const law of laws) {
|
|
622
|
+
console.log(` · ${law}`);
|
|
623
|
+
await sleep(beat / 5);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
console.log("");
|
|
627
|
+
console.log("─── 3/5 · 4 Diretrizes Comunicação ───");
|
|
628
|
+
await sleep(beat / 2);
|
|
629
|
+
console.log(" 1. Lei do Tom Conversacional (Apex T7 direct)");
|
|
630
|
+
console.log(" 2. Autonomia Sequencial (Lei #9)");
|
|
631
|
+
console.log(" 3. PASSO 0 EVERY ONDA (Lei #8 baseline)");
|
|
632
|
+
console.log(" 4. Separação canon-doc vs comunicação direta");
|
|
633
|
+
await sleep(beat);
|
|
634
|
+
|
|
635
|
+
console.log("");
|
|
636
|
+
console.log("─── 4/5 · 13 comandos NPX vigentes ───");
|
|
637
|
+
await sleep(beat / 2);
|
|
638
|
+
console.log(" introspecção: version · status · list-predators · list-workflows");
|
|
639
|
+
console.log(" state machines: workflow-states · story-states · layers-list · benchmark-info · metrics-list");
|
|
640
|
+
console.log(" experiência UX: init · config · show · sync · tour");
|
|
641
|
+
await sleep(beat);
|
|
642
|
+
|
|
643
|
+
console.log("");
|
|
644
|
+
console.log("─── 5/5 · Comando canon para sócios ───");
|
|
645
|
+
await sleep(beat / 2);
|
|
646
|
+
console.log("");
|
|
647
|
+
console.log(" mkdir predators-protocol && cd predators-protocol");
|
|
648
|
+
console.log(" npx predators-protocol@beta sync --force");
|
|
649
|
+
console.log("");
|
|
650
|
+
console.log(" → 143 files canon na pasta (64 predadores + docs + skills + CLAUDE.md)");
|
|
651
|
+
console.log(" → abre no VS Code · ativa extensão Claude Code");
|
|
652
|
+
console.log(" → /encarnar tubarao-branco (ou qualquer dos 64 IDs)");
|
|
653
|
+
await sleep(beat);
|
|
654
|
+
|
|
655
|
+
console.log("");
|
|
656
|
+
console.log("─── fim do tour ───");
|
|
657
|
+
console.log("");
|
|
658
|
+
console.log("Próximos passos sugeridos:");
|
|
659
|
+
console.log(" · npx predators-protocol@beta sync --force (instala canon na pasta atual)");
|
|
660
|
+
console.log(" · npx predators-protocol@beta show eye (logo cinematográfico)");
|
|
661
|
+
console.log(" · npx predators-protocol@beta show list (lista predator cards disponíveis)");
|
|
662
|
+
console.log(" · npx predators-protocol@beta help (todos os 13 comandos)");
|
|
663
|
+
console.log("");
|
|
664
|
+
console.log("🦈🐋 Predators Protocol · proprietário · Alex Gonzaga (Tubarão-Apex) · 2026-05-24");
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
668
|
+
|
|
669
|
+
const command = process.argv[2] || "help";
|
|
670
|
+
|
|
671
|
+
// Lei #1 [a-m] gates · access-token middleware canon 2026-05-27
|
|
672
|
+
// Sócios bypass via PREDATORS_OWNER_KEY env var · colaboradores via `unlock <TOKEN>`
|
|
673
|
+
const { runUnlock, requireValidAccess } = require("../lib/access-token-client.js");
|
|
674
|
+
// Lei #1 [ok1-ok4] gates · gen-token CLI canon 2026-05-27
|
|
675
|
+
const { runGenToken } = require("../lib/gen-token-client.js");
|
|
676
|
+
|
|
677
|
+
async function runUnlockCommand() {
|
|
678
|
+
const token = process.argv[3];
|
|
679
|
+
await runUnlock(token);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
async function runGenTokenCommand() {
|
|
683
|
+
await runGenToken();
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const commandsCanon = {
|
|
687
|
+
version: printVersionCanon,
|
|
688
|
+
status: printStatusCanon,
|
|
689
|
+
"list-predators": listPredatorsCanon,
|
|
690
|
+
"list-workflows": listWorkflowsCanon,
|
|
691
|
+
"workflow-states": listWorkflowStatesCanon,
|
|
692
|
+
"story-states": listStoryStatesCanon,
|
|
693
|
+
"layers-list": listLayersCanon,
|
|
694
|
+
"benchmark-info": showBenchmarkInfoCanon,
|
|
695
|
+
"metrics-list": listGoldenSignalsCanon,
|
|
696
|
+
init: runInitCommand,
|
|
697
|
+
config: runConfigCommand,
|
|
698
|
+
show: runShowCommand,
|
|
699
|
+
sync: runSyncCommand,
|
|
700
|
+
install: runInstallCommand,
|
|
701
|
+
tour: runTourCommand,
|
|
702
|
+
unlock: runUnlockCommand,
|
|
703
|
+
"gen-token": runGenTokenCommand,
|
|
704
|
+
help: printHelpCanon,
|
|
705
|
+
"--help": printHelpCanon,
|
|
706
|
+
"-h": printHelpCanon,
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
const handler = commandsCanon[command];
|
|
710
|
+
if (!handler) {
|
|
711
|
+
console.error(`Comando canon NÃO vigente: ${command}`);
|
|
712
|
+
printHelpCanon();
|
|
713
|
+
process.exit(1);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// Lei #1 middleware · valida acesso ANTES de executar comando sensível
|
|
717
|
+
// (PUBLIC_COMMANDS · owner bypass · cache local 5min · phone-home revalidação)
|
|
718
|
+
(async () => {
|
|
719
|
+
try {
|
|
720
|
+
await requireValidAccess(command);
|
|
721
|
+
await handler();
|
|
722
|
+
} catch (err) {
|
|
723
|
+
console.error(`Falha runtime canon: ${err && err.message ? err.message : err}`);
|
|
724
|
+
process.exit(1);
|
|
725
|
+
}
|
|
726
|
+
})();
|