triflux 5.2.0 → 6.0.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/tfx-doctor.mjs +3 -7
- package/bin/tfx-setup.mjs +3 -7
- package/bin/triflux.mjs +2470 -2463
- package/hub/team/headless.mjs +318 -16
- package/hub/team/psmux.mjs +16 -4
- package/package.json +1 -1
- package/scripts/lib/logger.mjs +4 -4
- package/skills/tfx-multi/SKILL.md +39 -15
package/bin/triflux.mjs
CHANGED
|
@@ -1,2464 +1,2471 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// triflux CLI — setup, doctor, version
|
|
3
|
-
import { copyFileSync, existsSync, readFileSync, writeFileSync, mkdirSync, chmodSync, readdirSync, unlinkSync, rmSync, statSync, openSync, closeSync } from "fs";
|
|
4
|
-
import { join, dirname } from "path";
|
|
5
|
-
import { homedir } from "os";
|
|
6
|
-
import { execSync, execFileSync, spawn } from "child_process";
|
|
7
|
-
import { fileURLToPath } from "url";
|
|
8
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
9
|
-
import { loadDelegatorSchemaBundle } from "../hub/delegator/tool-definitions.mjs";
|
|
10
|
-
import { detectMultiplexer, getSessionAttachedCount, killSession, listSessions, tmuxExec } from "../hub/team/session.mjs";
|
|
11
|
-
import { forceCleanupTeam } from "../hub/team/nativeProxy.mjs";
|
|
12
|
-
import { cleanupStaleOmcTeams, inspectStaleOmcTeams } from "../hub/team/staleState.mjs";
|
|
13
|
-
import { getPipelineStateDbPath } from "../hub/pipeline/state.mjs";
|
|
14
|
-
|
|
15
|
-
const PKG_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
16
|
-
const CLAUDE_DIR = join(homedir(), ".claude");
|
|
17
|
-
const CODEX_DIR = join(homedir(), ".codex");
|
|
18
|
-
const CODEX_CONFIG_PATH = join(CODEX_DIR, "config.toml");
|
|
19
|
-
const PKG = JSON.parse(readFileSync(join(PKG_ROOT, "package.json"), "utf8"));
|
|
20
|
-
|
|
21
|
-
const REQUIRED_CODEX_PROFILES = [
|
|
22
|
-
{
|
|
23
|
-
name: "
|
|
24
|
-
lines: [
|
|
25
|
-
'model = "gpt-5.3-codex"',
|
|
26
|
-
'model_reasoning_effort = "
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: "
|
|
31
|
-
lines: [
|
|
32
|
-
'model = "gpt-5.
|
|
33
|
-
'model_reasoning_effort = "
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
usage: "tfx
|
|
82
|
-
description: "
|
|
83
|
-
options: [
|
|
84
|
-
{ name: "--
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{ name: "--json", type: "boolean", description: "
|
|
94
|
-
],
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
usage: "tfx
|
|
98
|
-
description: "
|
|
99
|
-
options: [
|
|
100
|
-
{ name: "--json", type: "boolean", description: "
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
usage: "tfx
|
|
105
|
-
description: "
|
|
106
|
-
options: [
|
|
107
|
-
{ name: "
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
usage: "tfx
|
|
112
|
-
description: "
|
|
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
|
-
function
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (exitCode
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
if (exitCode ===
|
|
190
|
-
if (exitCode ===
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
try {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
const
|
|
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
|
-
const
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
-
|
|
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
|
-
shellResults.push({ shell, status: "
|
|
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
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
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
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
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
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
if (
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
//
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
};
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
"
|
|
889
|
-
"
|
|
890
|
-
"
|
|
891
|
-
"
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
ok(
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
} else {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
if (
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
addDoctorCheck(report, { name: "omc-stale-teams", status: "
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
const label = result.entry.scope === "root"
|
|
1342
|
-
? "root-state"
|
|
1343
|
-
: result.entry.scope === "claude_team"
|
|
1344
|
-
? (result.entry.teamName || result.entry.sessionId)
|
|
1345
|
-
: result.entry.sessionId;
|
|
1346
|
-
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
//
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
//
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
${
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
${
|
|
1869
|
-
${
|
|
1870
|
-
${WHITE_BRIGHT}tfx
|
|
1871
|
-
${
|
|
1872
|
-
${
|
|
1873
|
-
${DIM} --
|
|
1874
|
-
${WHITE_BRIGHT}tfx
|
|
1875
|
-
${
|
|
1876
|
-
${WHITE_BRIGHT}tfx
|
|
1877
|
-
${WHITE_BRIGHT}tfx
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
${
|
|
1882
|
-
${WHITE_BRIGHT}
|
|
1883
|
-
${WHITE_BRIGHT}
|
|
1884
|
-
${
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1927
|
-
const
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
// 파일
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
})
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
console.log(
|
|
2205
|
-
console.log(` ${DIM}
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
console.log(`\n ${
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
return;
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
source: "probe",
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
return;
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
}
|
|
2314
|
-
console.log(
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
if (
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
source: "stale-pid
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
return;
|
|
2373
|
-
|
|
2374
|
-
case "
|
|
2375
|
-
|
|
2376
|
-
return;
|
|
2377
|
-
case "
|
|
2378
|
-
|
|
2379
|
-
return;
|
|
2380
|
-
case "
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
const
|
|
2408
|
-
|
|
2409
|
-
process.
|
|
2410
|
-
|
|
2411
|
-
await
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
case "
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
}
|
|
2
|
+
// triflux CLI — setup, doctor, version
|
|
3
|
+
import { copyFileSync, existsSync, readFileSync, writeFileSync, mkdirSync, chmodSync, readdirSync, unlinkSync, rmSync, statSync, openSync, closeSync } from "fs";
|
|
4
|
+
import { join, dirname } from "path";
|
|
5
|
+
import { homedir } from "os";
|
|
6
|
+
import { execSync, execFileSync, spawn } from "child_process";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
9
|
+
import { loadDelegatorSchemaBundle } from "../hub/delegator/tool-definitions.mjs";
|
|
10
|
+
import { detectMultiplexer, getSessionAttachedCount, killSession, listSessions, tmuxExec } from "../hub/team/session.mjs";
|
|
11
|
+
import { forceCleanupTeam } from "../hub/team/nativeProxy.mjs";
|
|
12
|
+
import { cleanupStaleOmcTeams, inspectStaleOmcTeams } from "../hub/team/staleState.mjs";
|
|
13
|
+
import { getPipelineStateDbPath } from "../hub/pipeline/state.mjs";
|
|
14
|
+
|
|
15
|
+
const PKG_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
16
|
+
const CLAUDE_DIR = join(homedir(), ".claude");
|
|
17
|
+
const CODEX_DIR = join(homedir(), ".codex");
|
|
18
|
+
const CODEX_CONFIG_PATH = join(CODEX_DIR, "config.toml");
|
|
19
|
+
const PKG = JSON.parse(readFileSync(join(PKG_ROOT, "package.json"), "utf8"));
|
|
20
|
+
|
|
21
|
+
const REQUIRED_CODEX_PROFILES = [
|
|
22
|
+
{
|
|
23
|
+
name: "high",
|
|
24
|
+
lines: [
|
|
25
|
+
'model = "gpt-5.3-codex"',
|
|
26
|
+
'model_reasoning_effort = "high"',
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "xhigh",
|
|
31
|
+
lines: [
|
|
32
|
+
'model = "gpt-5.3-codex"',
|
|
33
|
+
'model_reasoning_effort = "xhigh"',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "spark_fast",
|
|
38
|
+
lines: [
|
|
39
|
+
'model = "gpt-5.1-codex-mini"',
|
|
40
|
+
'model_reasoning_effort = "low"',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
// ── 색상 체계 (triflux brand: amber/orange accent) ──
|
|
46
|
+
const CYAN = "\x1b[36m";
|
|
47
|
+
const GREEN = "\x1b[32m";
|
|
48
|
+
const RED = "\x1b[31m";
|
|
49
|
+
const YELLOW = "\x1b[33m";
|
|
50
|
+
const DIM = "\x1b[2m";
|
|
51
|
+
const BOLD = "\x1b[1m";
|
|
52
|
+
const RESET = "\x1b[0m";
|
|
53
|
+
const AMBER = "\x1b[38;5;214m";
|
|
54
|
+
const BLUE = "\x1b[38;5;39m";
|
|
55
|
+
const WHITE_BRIGHT = "\x1b[97m";
|
|
56
|
+
const GRAY = "\x1b[38;5;245m";
|
|
57
|
+
const GREEN_BRIGHT = "\x1b[38;5;82m";
|
|
58
|
+
const RED_BRIGHT = "\x1b[38;5;196m";
|
|
59
|
+
|
|
60
|
+
// ── 브랜드 요소 ──
|
|
61
|
+
const BRAND = `${AMBER}${BOLD}triflux${RESET}`;
|
|
62
|
+
const VER = `${DIM}v${PKG.version}${RESET}`;
|
|
63
|
+
const LINE = `${GRAY}${"─".repeat(48)}${RESET}`;
|
|
64
|
+
const DOT = `${GRAY}·${RESET}`;
|
|
65
|
+
const STALE_TEAM_MAX_AGE_SEC = 3600;
|
|
66
|
+
const ANSI_PATTERN = /\x1B\[[0-?]*[ -/]*[@-~]/g;
|
|
67
|
+
|
|
68
|
+
const EXIT_SUCCESS = 0;
|
|
69
|
+
const EXIT_ERROR = 1;
|
|
70
|
+
const EXIT_ARG_ERROR = 2;
|
|
71
|
+
const EXIT_CLI_MISSING = 3;
|
|
72
|
+
const EXIT_HUB_ERROR = 4;
|
|
73
|
+
const EXIT_CONFIG_ERROR = 5;
|
|
74
|
+
|
|
75
|
+
const RAW_ARGS = process.argv.slice(2);
|
|
76
|
+
const JSON_OUTPUT = RAW_ARGS.includes("--json");
|
|
77
|
+
const NORMALIZED_ARGS = RAW_ARGS.filter((arg) => arg !== "--json");
|
|
78
|
+
|
|
79
|
+
const CLI_COMMAND_SCHEMAS = Object.freeze({
|
|
80
|
+
setup: {
|
|
81
|
+
usage: "tfx setup [--dry-run]",
|
|
82
|
+
description: "파일 동기화 + HUD/MCP 설정",
|
|
83
|
+
options: [
|
|
84
|
+
{ name: "--dry-run", type: "boolean", description: "실제 변경 없이 예정 작업을 JSON으로 출력" },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
doctor: {
|
|
88
|
+
usage: "tfx doctor [--fix] [--reset] [--json]",
|
|
89
|
+
description: "설치 상태 진단 및 자동 복구",
|
|
90
|
+
options: [
|
|
91
|
+
{ name: "--fix", type: "boolean", description: "파일/캐시 자동 복구 후 재진단" },
|
|
92
|
+
{ name: "--reset", type: "boolean", description: "캐시 초기화 후 재생성" },
|
|
93
|
+
{ name: "--json", type: "boolean", description: "구조화된 진단 결과 JSON 출력" },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
version: {
|
|
97
|
+
usage: "tfx version [--json]",
|
|
98
|
+
description: "triflux 및 동기화된 스크립트 버전 표시",
|
|
99
|
+
options: [
|
|
100
|
+
{ name: "--json", type: "boolean", description: "버전 정보를 JSON으로 출력" },
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
list: {
|
|
104
|
+
usage: "tfx list [--json]",
|
|
105
|
+
description: "패키지 스킬과 사용자 스킬 목록 표시",
|
|
106
|
+
options: [
|
|
107
|
+
{ name: "--json", type: "boolean", description: "스킬 목록을 JSON으로 출력" },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
schema: {
|
|
111
|
+
usage: "tfx schema [command-or-tool]",
|
|
112
|
+
description: "CLI 커맨드 파라미터와 Hub delegator schema 번들 출력",
|
|
113
|
+
options: [
|
|
114
|
+
{ name: "command-or-tool", type: "string", description: "예: doctor, setup, delegate, delegate-reply, status" },
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
hub: {
|
|
118
|
+
usage: "tfx hub <start|stop|status> [--port N] [--json]",
|
|
119
|
+
description: "tfx-hub 프로세스 제어",
|
|
120
|
+
subcommands: {
|
|
121
|
+
start: { usage: "tfx hub start [--port N]" },
|
|
122
|
+
stop: { usage: "tfx hub stop" },
|
|
123
|
+
status: {
|
|
124
|
+
usage: "tfx hub status [--json]",
|
|
125
|
+
options: [{ name: "--json", type: "boolean", description: "허브 상태를 JSON으로 출력" }],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
multi: {
|
|
130
|
+
usage: "tfx multi <subcommand>",
|
|
131
|
+
description: "멀티-CLI 팀 모드",
|
|
132
|
+
subcommands: {
|
|
133
|
+
status: {
|
|
134
|
+
usage: "tfx multi status [--json]",
|
|
135
|
+
options: [{ name: "--json", type: "boolean", description: "팀 상태를 JSON으로 출력" }],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// ── 유틸리티 ──
|
|
142
|
+
|
|
143
|
+
function ok(msg) { console.log(` ${GREEN_BRIGHT}✓${RESET} ${msg}`); }
|
|
144
|
+
function warn(msg) { console.log(` ${YELLOW}⚠${RESET} ${msg}`); }
|
|
145
|
+
function fail(msg) { console.log(` ${RED_BRIGHT}✗${RESET} ${msg}`); }
|
|
146
|
+
function info(msg) { console.log(` ${GRAY}${msg}${RESET}`); }
|
|
147
|
+
function section(title) { console.log(`\n ${AMBER}▸${RESET} ${BOLD}${title}${RESET}`); }
|
|
148
|
+
function stripAnsi(value) { return String(value ?? "").replace(ANSI_PATTERN, ""); }
|
|
149
|
+
function printJson(payload) { process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`); }
|
|
150
|
+
|
|
151
|
+
function withConsoleSilenced(enabled, fn) {
|
|
152
|
+
if (!enabled) return fn();
|
|
153
|
+
const originalLog = console.log;
|
|
154
|
+
const originalError = console.error;
|
|
155
|
+
console.log = () => {};
|
|
156
|
+
console.error = () => {};
|
|
157
|
+
try {
|
|
158
|
+
return fn();
|
|
159
|
+
} finally {
|
|
160
|
+
console.log = originalLog;
|
|
161
|
+
console.error = originalError;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function createCliError(message, {
|
|
166
|
+
exitCode = EXIT_ERROR,
|
|
167
|
+
reason = "error",
|
|
168
|
+
fix = null,
|
|
169
|
+
cause = null,
|
|
170
|
+
} = {}) {
|
|
171
|
+
const error = new Error(message);
|
|
172
|
+
error.exitCode = exitCode;
|
|
173
|
+
error.reason = reason;
|
|
174
|
+
error.fix = fix;
|
|
175
|
+
if (cause) error.cause = cause;
|
|
176
|
+
return error;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function inferExitCode(error) {
|
|
180
|
+
if (Number.isInteger(error?.exitCode)) return error.exitCode;
|
|
181
|
+
if (error?.code === "ENOENT") return EXIT_CLI_MISSING;
|
|
182
|
+
return EXIT_ERROR;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function inferReason(error, exitCode) {
|
|
186
|
+
if (typeof error?.reason === "string" && error.reason) return error.reason;
|
|
187
|
+
if (exitCode === EXIT_ARG_ERROR) return "argError";
|
|
188
|
+
if (exitCode === EXIT_CLI_MISSING) return "cliMissing";
|
|
189
|
+
if (exitCode === EXIT_HUB_ERROR) return "hubError";
|
|
190
|
+
if (exitCode === EXIT_CONFIG_ERROR) return "configError";
|
|
191
|
+
return "error";
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function inferFix(error, exitCode) {
|
|
195
|
+
if (typeof error?.fix === "string" && error.fix) return error.fix;
|
|
196
|
+
if (exitCode === EXIT_ARG_ERROR) return "tfx --help";
|
|
197
|
+
if (exitCode === EXIT_CLI_MISSING) return "필수 CLI를 설치한 뒤 `tfx doctor`로 상태를 다시 확인하세요.";
|
|
198
|
+
if (exitCode === EXIT_HUB_ERROR) return "`tfx hub start`로 허브를 다시 시작하거나 설치 상태를 확인하세요.";
|
|
199
|
+
if (exitCode === EXIT_CONFIG_ERROR) return "설정 파일 JSON/TOML 문법을 수정한 뒤 다시 실행하세요.";
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function handleFatalError(error, { json = false } = {}) {
|
|
204
|
+
const exitCode = inferExitCode(error);
|
|
205
|
+
const message = stripAnsi(error?.message || "알 수 없는 오류");
|
|
206
|
+
const reason = inferReason(error, exitCode);
|
|
207
|
+
const fix = inferFix(error, exitCode);
|
|
208
|
+
|
|
209
|
+
if (json) {
|
|
210
|
+
printJson({
|
|
211
|
+
error: {
|
|
212
|
+
code: exitCode,
|
|
213
|
+
message,
|
|
214
|
+
reason,
|
|
215
|
+
...(fix ? { fix } : {}),
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
console.error(message);
|
|
220
|
+
if (fix) console.error(`fix: ${fix}`);
|
|
221
|
+
}
|
|
222
|
+
process.exit(exitCode);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function which(cmd) {
|
|
226
|
+
try {
|
|
227
|
+
const result = process.platform === "win32"
|
|
228
|
+
? execFileSync("where", [cmd], { encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "ignore"], windowsHide: true })
|
|
229
|
+
: execFileSync("which", [cmd], { encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "ignore"] });
|
|
230
|
+
return result.trim().split(/\r?\n/)[0] || null;
|
|
231
|
+
} catch { return null; }
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function whichInShell(cmd, shell) {
|
|
235
|
+
const shellArgs = {
|
|
236
|
+
bash: ["bash", ["-c", `source ~/.bashrc 2>/dev/null && command -v "${cmd}" 2>/dev/null`]],
|
|
237
|
+
cmd: ["cmd", ["/c", "where", cmd]],
|
|
238
|
+
pwsh: ["pwsh", ["-NoProfile", "-c", `(Get-Command '${cmd.replace(/'/g, "''")}' -EA SilentlyContinue).Source`]],
|
|
239
|
+
};
|
|
240
|
+
const entry = shellArgs[shell];
|
|
241
|
+
if (!entry) return null;
|
|
242
|
+
try {
|
|
243
|
+
const result = execFileSync(entry[0], entry[1], {
|
|
244
|
+
encoding: "utf8",
|
|
245
|
+
timeout: 8000,
|
|
246
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
247
|
+
windowsHide: true,
|
|
248
|
+
}).trim();
|
|
249
|
+
return result.split(/\r?\n/)[0] || null;
|
|
250
|
+
} catch { return null; }
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function isDevUpdateRequested(argv = process.argv) {
|
|
254
|
+
return argv.includes("--dev") || argv.includes("@dev") || argv.includes("dev");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function checkShellAvailable(shell) {
|
|
258
|
+
const cmds = { bash: "bash --version", cmd: "cmd /c echo ok", pwsh: "pwsh -NoProfile -c echo ok" };
|
|
259
|
+
try {
|
|
260
|
+
execSync(cmds[shell], { encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "ignore"], windowsHide: true });
|
|
261
|
+
return true;
|
|
262
|
+
} catch { return false; }
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function getVersion(filePath) {
|
|
266
|
+
try {
|
|
267
|
+
const content = readFileSync(filePath, "utf8");
|
|
268
|
+
const match = content.match(/VERSION\s*=\s*"([^"]+)"/);
|
|
269
|
+
return match ? match[1] : null;
|
|
270
|
+
} catch { return null; }
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function parseSessionCreated(rawValue) {
|
|
274
|
+
const value = String(rawValue || "").trim();
|
|
275
|
+
if (!value) return null;
|
|
276
|
+
|
|
277
|
+
const numeric = Number(value);
|
|
278
|
+
if (Number.isFinite(numeric) && numeric > 0) {
|
|
279
|
+
return numeric > 1e12 ? Math.floor(numeric / 1000) : Math.floor(numeric);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const parsed = Date.parse(value);
|
|
283
|
+
if (Number.isFinite(parsed)) {
|
|
284
|
+
return Math.floor(parsed / 1000);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const normalized = value.replace(/^(\d{2})-(\d{2})-(\d{2})(\s+)/, "20$1-$2-$3$4");
|
|
288
|
+
const reparsed = Date.parse(normalized);
|
|
289
|
+
if (Number.isFinite(reparsed)) {
|
|
290
|
+
return Math.floor(reparsed / 1000);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function formatElapsedAge(ageSec) {
|
|
297
|
+
if (!Number.isFinite(ageSec) || ageSec < 0) return "알 수 없음";
|
|
298
|
+
if (ageSec < 60) return `${ageSec}초`;
|
|
299
|
+
if (ageSec < 3600) return `${Math.floor(ageSec / 60)}분`;
|
|
300
|
+
if (ageSec < 86400) return `${Math.floor(ageSec / 3600)}시간`;
|
|
301
|
+
return `${Math.floor(ageSec / 86400)}일`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function readTeamSessionCreatedMap() {
|
|
305
|
+
const createdMap = new Map();
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
const output = tmuxExec('list-sessions -F "#{session_name} #{session_created}"');
|
|
309
|
+
for (const line of output.split(/\r?\n/)) {
|
|
310
|
+
const trimmed = line.trim();
|
|
311
|
+
if (!trimmed) continue;
|
|
312
|
+
|
|
313
|
+
const firstSpace = trimmed.indexOf(" ");
|
|
314
|
+
if (firstSpace === -1) continue;
|
|
315
|
+
|
|
316
|
+
const sessionName = trimmed.slice(0, firstSpace);
|
|
317
|
+
const createdRaw = trimmed.slice(firstSpace + 1).trim();
|
|
318
|
+
const createdAt = parseSessionCreated(createdRaw);
|
|
319
|
+
createdMap.set(sessionName, {
|
|
320
|
+
createdAt,
|
|
321
|
+
createdRaw,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
} catch {
|
|
325
|
+
// session_created 포맷을 읽지 못하면 stale 판정만 완화한다.
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return createdMap;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function inspectTeamSessions() {
|
|
332
|
+
const mux = detectMultiplexer();
|
|
333
|
+
if (!mux) {
|
|
334
|
+
return { mux: null, sessions: [] };
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const sessionNames = listSessions();
|
|
338
|
+
if (sessionNames.length === 0) {
|
|
339
|
+
return { mux, sessions: [] };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const createdMap = readTeamSessionCreatedMap();
|
|
343
|
+
const nowSec = Math.floor(Date.now() / 1000);
|
|
344
|
+
const sessions = sessionNames.map((sessionName) => {
|
|
345
|
+
const createdInfo = createdMap.get(sessionName) || { createdAt: null, createdRaw: "" };
|
|
346
|
+
const attachedCount = getSessionAttachedCount(sessionName);
|
|
347
|
+
const ageSec = createdInfo.createdAt == null ? null : Math.max(0, nowSec - createdInfo.createdAt);
|
|
348
|
+
const stale = ageSec != null && ageSec >= STALE_TEAM_MAX_AGE_SEC && attachedCount === 0;
|
|
349
|
+
|
|
350
|
+
return {
|
|
351
|
+
sessionName,
|
|
352
|
+
attachedCount,
|
|
353
|
+
ageSec,
|
|
354
|
+
createdAt: createdInfo.createdAt,
|
|
355
|
+
createdRaw: createdInfo.createdRaw,
|
|
356
|
+
stale,
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
return { mux, sessions };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
async function cleanupStaleTeamSessions(staleSessions) {
|
|
364
|
+
let cleaned = 0;
|
|
365
|
+
let failed = 0;
|
|
366
|
+
|
|
367
|
+
for (const session of staleSessions) {
|
|
368
|
+
let removed = false;
|
|
369
|
+
|
|
370
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
371
|
+
killSession(session.sessionName);
|
|
372
|
+
const stillAlive = listSessions().includes(session.sessionName);
|
|
373
|
+
if (!stillAlive) {
|
|
374
|
+
removed = true;
|
|
375
|
+
cleaned++;
|
|
376
|
+
ok(`stale 세션 정리: ${session.sessionName}`);
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (attempt < 3) {
|
|
381
|
+
await delay(1000);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (!removed) {
|
|
386
|
+
failed++;
|
|
387
|
+
fail(`세션 정리 실패: ${session.sessionName} — 수동 정리 필요`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
info(`${cleaned}개 stale 세션 정리 완료`);
|
|
392
|
+
|
|
393
|
+
return { cleaned, failed };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function escapeRegExp(value) {
|
|
397
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function hasProfileSection(tomlContent, profileName) {
|
|
401
|
+
const section = `^\\[profiles\\.${escapeRegExp(profileName)}\\]\\s*$`;
|
|
402
|
+
return new RegExp(section, "m").test(tomlContent);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function ensureCodexProfiles() {
|
|
406
|
+
try {
|
|
407
|
+
if (!existsSync(CODEX_DIR)) mkdirSync(CODEX_DIR, { recursive: true });
|
|
408
|
+
|
|
409
|
+
const original = existsSync(CODEX_CONFIG_PATH)
|
|
410
|
+
? readFileSync(CODEX_CONFIG_PATH, "utf8")
|
|
411
|
+
: "";
|
|
412
|
+
|
|
413
|
+
let updated = original;
|
|
414
|
+
let added = 0;
|
|
415
|
+
|
|
416
|
+
for (const profile of REQUIRED_CODEX_PROFILES) {
|
|
417
|
+
if (hasProfileSection(updated, profile.name)) continue;
|
|
418
|
+
|
|
419
|
+
if (updated.length > 0 && !updated.endsWith("\n")) updated += "\n";
|
|
420
|
+
if (updated.trim().length > 0) updated += "\n";
|
|
421
|
+
updated += `[profiles.${profile.name}]\n${profile.lines.join("\n")}\n`;
|
|
422
|
+
added++;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (added > 0) {
|
|
426
|
+
writeFileSync(CODEX_CONFIG_PATH, updated, "utf8");
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return { ok: true, added };
|
|
430
|
+
} catch (e) {
|
|
431
|
+
return { ok: false, added: 0, message: e.message };
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function previewCodexProfiles() {
|
|
436
|
+
const original = existsSync(CODEX_CONFIG_PATH)
|
|
437
|
+
? readFileSync(CODEX_CONFIG_PATH, "utf8")
|
|
438
|
+
: "";
|
|
439
|
+
const missingProfiles = REQUIRED_CODEX_PROFILES
|
|
440
|
+
.filter((profile) => !hasProfileSection(original, profile.name))
|
|
441
|
+
.map((profile) => profile.name);
|
|
442
|
+
|
|
443
|
+
return {
|
|
444
|
+
path: CODEX_CONFIG_PATH,
|
|
445
|
+
missingProfiles,
|
|
446
|
+
change: missingProfiles.length > 0 ? (original ? "update" : "create") : "noop",
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function syncFile(src, dst, label) {
|
|
451
|
+
const dstDir = dirname(dst);
|
|
452
|
+
if (!existsSync(dstDir)) mkdirSync(dstDir, { recursive: true });
|
|
453
|
+
|
|
454
|
+
if (!existsSync(src)) {
|
|
455
|
+
fail(`${label}: 소스 파일 없음 (${src})`);
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const srcVer = getVersion(src);
|
|
460
|
+
const dstVer = existsSync(dst) ? getVersion(dst) : null;
|
|
461
|
+
|
|
462
|
+
if (!existsSync(dst)) {
|
|
463
|
+
copyFileSync(src, dst);
|
|
464
|
+
try { chmodSync(dst, 0o755); } catch {}
|
|
465
|
+
ok(`${label}: 설치됨 ${srcVer ? `(v${srcVer})` : ""}`);
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const srcContent = readFileSync(src, "utf8");
|
|
470
|
+
const dstContent = readFileSync(dst, "utf8");
|
|
471
|
+
if (srcContent !== dstContent) {
|
|
472
|
+
copyFileSync(src, dst);
|
|
473
|
+
try { chmodSync(dst, 0o755); } catch {}
|
|
474
|
+
const verInfo = (srcVer && dstVer && srcVer !== dstVer)
|
|
475
|
+
? `(v${dstVer} → v${srcVer})`
|
|
476
|
+
: srcVer ? `(v${srcVer}, 내용 변경)` : "(내용 변경)";
|
|
477
|
+
ok(`${label}: 업데이트됨 ${verInfo}`);
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
ok(`${label}: 최신 상태 ${srcVer ? `(v${srcVer})` : ""}`);
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function describeSyncAction(src, dst, label) {
|
|
486
|
+
if (!existsSync(src)) {
|
|
487
|
+
throw createCliError(`${label}: 소스 파일 없음 (${src})`, {
|
|
488
|
+
exitCode: EXIT_CONFIG_ERROR,
|
|
489
|
+
reason: "configError",
|
|
490
|
+
fix: "패키지 파일이 손상되지 않았는지 확인한 뒤 triflux를 다시 설치하세요.",
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const srcVer = getVersion(src);
|
|
495
|
+
const dstExists = existsSync(dst);
|
|
496
|
+
const change = !dstExists
|
|
497
|
+
? "create"
|
|
498
|
+
: readFileSync(src, "utf8") !== readFileSync(dst, "utf8")
|
|
499
|
+
? "update"
|
|
500
|
+
: "noop";
|
|
501
|
+
|
|
502
|
+
return {
|
|
503
|
+
type: "sync",
|
|
504
|
+
label,
|
|
505
|
+
from: src,
|
|
506
|
+
to: dst,
|
|
507
|
+
change,
|
|
508
|
+
version: srcVer,
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// ── 크로스 셸 진단 ──
|
|
513
|
+
|
|
514
|
+
function checkCliCrossShell(cmd, installHint) {
|
|
515
|
+
const shells = process.platform === "win32" ? ["bash", "cmd", "pwsh"] : ["bash"];
|
|
516
|
+
let anyFound = false;
|
|
517
|
+
let bashMissing = false;
|
|
518
|
+
const shellResults = [];
|
|
519
|
+
|
|
520
|
+
for (const shell of shells) {
|
|
521
|
+
if (!checkShellAvailable(shell)) {
|
|
522
|
+
info(`${shell}: ${DIM}셸 없음 (건너뜀)${RESET}`);
|
|
523
|
+
shellResults.push({ shell, status: "unavailable", path: null });
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
const p = whichInShell(cmd, shell);
|
|
527
|
+
if (p) {
|
|
528
|
+
ok(`${shell}: ${p}`);
|
|
529
|
+
anyFound = true;
|
|
530
|
+
shellResults.push({ shell, status: "ok", path: p });
|
|
531
|
+
} else {
|
|
532
|
+
fail(`${shell}: 미발견`);
|
|
533
|
+
if (shell === "bash") bashMissing = true;
|
|
534
|
+
shellResults.push({ shell, status: "missing", path: null, fix: installHint });
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (!anyFound) {
|
|
539
|
+
info(`미설치 (선택사항) — ${installHint}`);
|
|
540
|
+
info("없으면 Claude 네이티브 에이전트로 fallback");
|
|
541
|
+
return {
|
|
542
|
+
issues: 1,
|
|
543
|
+
anyFound,
|
|
544
|
+
bashMissing,
|
|
545
|
+
shells: shellResults,
|
|
546
|
+
status: "missing",
|
|
547
|
+
fix: installHint,
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
if (bashMissing) {
|
|
551
|
+
warn("bash에서 미발견 — tfx-route.sh 실행 불가");
|
|
552
|
+
info('→ ~/.bashrc에 추가: export PATH="$PATH:$APPDATA/npm"');
|
|
553
|
+
return {
|
|
554
|
+
issues: 1,
|
|
555
|
+
anyFound,
|
|
556
|
+
bashMissing,
|
|
557
|
+
shells: shellResults,
|
|
558
|
+
status: "degraded",
|
|
559
|
+
fix: 'bash PATH를 정리한 뒤 `tfx doctor`를 다시 실행하세요.',
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
return {
|
|
563
|
+
issues: 0,
|
|
564
|
+
anyFound,
|
|
565
|
+
bashMissing,
|
|
566
|
+
shells: shellResults,
|
|
567
|
+
status: "ok",
|
|
568
|
+
fix: null,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// ── 명령어 ──
|
|
573
|
+
|
|
574
|
+
function getSetupSyncTargets() {
|
|
575
|
+
return [
|
|
576
|
+
{
|
|
577
|
+
src: join(PKG_ROOT, "scripts", "tfx-route.sh"),
|
|
578
|
+
dst: join(CLAUDE_DIR, "scripts", "tfx-route.sh"),
|
|
579
|
+
label: "tfx-route.sh",
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
src: join(PKG_ROOT, "hud", "hud-qos-status.mjs"),
|
|
583
|
+
dst: join(CLAUDE_DIR, "hud", "hud-qos-status.mjs"),
|
|
584
|
+
label: "hud-qos-status.mjs",
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
src: join(PKG_ROOT, "scripts", "notion-read.mjs"),
|
|
588
|
+
dst: join(CLAUDE_DIR, "scripts", "notion-read.mjs"),
|
|
589
|
+
label: "notion-read.mjs",
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
src: join(PKG_ROOT, "scripts", "tfx-route-post.mjs"),
|
|
593
|
+
dst: join(CLAUDE_DIR, "scripts", "tfx-route-post.mjs"),
|
|
594
|
+
label: "tfx-route-post.mjs",
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
src: join(PKG_ROOT, "scripts", "tfx-batch-stats.mjs"),
|
|
598
|
+
dst: join(CLAUDE_DIR, "scripts", "tfx-batch-stats.mjs"),
|
|
599
|
+
label: "tfx-batch-stats.mjs",
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
src: join(PKG_ROOT, "scripts", "lib", "mcp-filter.mjs"),
|
|
603
|
+
dst: join(CLAUDE_DIR, "scripts", "lib", "mcp-filter.mjs"),
|
|
604
|
+
label: "lib/mcp-filter.mjs",
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
src: join(PKG_ROOT, "scripts", "lib", "mcp-server-catalog.mjs"),
|
|
608
|
+
dst: join(CLAUDE_DIR, "scripts", "lib", "mcp-server-catalog.mjs"),
|
|
609
|
+
label: "lib/mcp-server-catalog.mjs",
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
src: join(PKG_ROOT, "scripts", "lib", "keyword-rules.mjs"),
|
|
613
|
+
dst: join(CLAUDE_DIR, "scripts", "lib", "keyword-rules.mjs"),
|
|
614
|
+
label: "lib/keyword-rules.mjs",
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
src: join(PKG_ROOT, "scripts", "tfx-route-worker.mjs"),
|
|
618
|
+
dst: join(CLAUDE_DIR, "scripts", "tfx-route-worker.mjs"),
|
|
619
|
+
label: "tfx-route-worker.mjs",
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
src: join(PKG_ROOT, "hub", "workers", "codex-mcp.mjs"),
|
|
623
|
+
dst: join(CLAUDE_DIR, "scripts", "hub", "workers", "codex-mcp.mjs"),
|
|
624
|
+
label: "hub/workers/codex-mcp.mjs",
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
src: join(PKG_ROOT, "hub", "workers", "delegator-mcp.mjs"),
|
|
628
|
+
dst: join(CLAUDE_DIR, "scripts", "hub", "workers", "delegator-mcp.mjs"),
|
|
629
|
+
label: "hub/workers/delegator-mcp.mjs",
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
src: join(PKG_ROOT, "hub", "workers", "interface.mjs"),
|
|
633
|
+
dst: join(CLAUDE_DIR, "scripts", "hub", "workers", "interface.mjs"),
|
|
634
|
+
label: "hub/workers/interface.mjs",
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
src: join(PKG_ROOT, "hub", "workers", "gemini-worker.mjs"),
|
|
638
|
+
dst: join(CLAUDE_DIR, "scripts", "hub", "workers", "gemini-worker.mjs"),
|
|
639
|
+
label: "hub/workers/gemini-worker.mjs",
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
src: join(PKG_ROOT, "hub", "workers", "claude-worker.mjs"),
|
|
643
|
+
dst: join(CLAUDE_DIR, "scripts", "hub", "workers", "claude-worker.mjs"),
|
|
644
|
+
label: "hub/workers/claude-worker.mjs",
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
src: join(PKG_ROOT, "hub", "workers", "factory.mjs"),
|
|
648
|
+
dst: join(CLAUDE_DIR, "scripts", "hub", "workers", "factory.mjs"),
|
|
649
|
+
label: "hub/workers/factory.mjs",
|
|
650
|
+
},
|
|
651
|
+
];
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function listSkillSyncActions() {
|
|
655
|
+
const skillsSrc = join(PKG_ROOT, "skills");
|
|
656
|
+
if (!existsSync(skillsSrc)) return [];
|
|
657
|
+
|
|
658
|
+
const actions = [];
|
|
659
|
+
for (const name of readdirSync(skillsSrc).sort()) {
|
|
660
|
+
const src = join(skillsSrc, name, "SKILL.md");
|
|
661
|
+
const dst = join(CLAUDE_DIR, "skills", name, "SKILL.md");
|
|
662
|
+
if (!existsSync(src)) continue;
|
|
663
|
+
actions.push(describeSyncAction(src, dst, `skill:${name}`));
|
|
664
|
+
}
|
|
665
|
+
return actions;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function previewStatusLineAction() {
|
|
669
|
+
const settingsPath = join(CLAUDE_DIR, "settings.json");
|
|
670
|
+
const hudPath = join(CLAUDE_DIR, "hud", "hud-qos-status.mjs");
|
|
671
|
+
|
|
672
|
+
let settings = {};
|
|
673
|
+
if (existsSync(settingsPath)) {
|
|
674
|
+
try {
|
|
675
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
676
|
+
} catch (error) {
|
|
677
|
+
throw createCliError(`settings.json 처리 실패: ${error.message}`, {
|
|
678
|
+
exitCode: EXIT_CONFIG_ERROR,
|
|
679
|
+
reason: "configError",
|
|
680
|
+
fix: `${settingsPath}의 JSON 문법을 수정하세요.`,
|
|
681
|
+
cause: error,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const currentCmd = settings.statusLine?.command || "";
|
|
687
|
+
return {
|
|
688
|
+
type: "statusLine",
|
|
689
|
+
path: settingsPath,
|
|
690
|
+
change: currentCmd.includes("hud-qos-status.mjs") ? "noop" : (currentCmd ? "update" : "create"),
|
|
691
|
+
current: currentCmd || null,
|
|
692
|
+
target: hudPath,
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function previewMcpRegistrationActions(mcpUrl) {
|
|
697
|
+
const actions = [];
|
|
698
|
+
|
|
699
|
+
if (which("codex")) {
|
|
700
|
+
actions.push({
|
|
701
|
+
type: "mcp-register",
|
|
702
|
+
cli: "codex",
|
|
703
|
+
target: "tfx-hub",
|
|
704
|
+
url: mcpUrl,
|
|
705
|
+
change: "check",
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
if (which("gemini")) {
|
|
709
|
+
actions.push({
|
|
710
|
+
type: "mcp-register",
|
|
711
|
+
cli: "gemini",
|
|
712
|
+
target: "tfx-hub",
|
|
713
|
+
url: mcpUrl,
|
|
714
|
+
change: "check",
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
actions.push({
|
|
719
|
+
type: "mcp-register",
|
|
720
|
+
cli: "claude",
|
|
721
|
+
target: "tfx-hub",
|
|
722
|
+
path: join(PKG_ROOT, ".mcp.json"),
|
|
723
|
+
url: mcpUrl,
|
|
724
|
+
change: "check",
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
return actions;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function buildSetupDryRunPlan() {
|
|
731
|
+
const actions = [
|
|
732
|
+
...getSetupSyncTargets().map(({ src, dst, label }) => describeSyncAction(src, dst, label)),
|
|
733
|
+
...listSkillSyncActions(),
|
|
734
|
+
];
|
|
735
|
+
const codexProfiles = previewCodexProfiles();
|
|
736
|
+
actions.push({
|
|
737
|
+
type: "codex-profiles",
|
|
738
|
+
path: codexProfiles.path,
|
|
739
|
+
change: codexProfiles.change,
|
|
740
|
+
profiles: codexProfiles.missingProfiles,
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
const defaultHubUrl = `http://127.0.0.1:${process.env.TFX_HUB_PORT || "27888"}/mcp`;
|
|
744
|
+
actions.push(...previewMcpRegistrationActions(defaultHubUrl));
|
|
745
|
+
actions.push(previewStatusLineAction());
|
|
746
|
+
|
|
747
|
+
return {
|
|
748
|
+
dry_run: true,
|
|
749
|
+
actions,
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function cmdSetup(options = {}) {
|
|
754
|
+
const { dryRun = false } = options;
|
|
755
|
+
if (dryRun) {
|
|
756
|
+
printJson(buildSetupDryRunPlan());
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
console.log(`\n${BOLD}triflux setup${RESET}\n`);
|
|
761
|
+
|
|
762
|
+
for (const target of getSetupSyncTargets()) {
|
|
763
|
+
syncFile(target.src, target.dst, target.label);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// 스킬 동기화 (~/.claude/skills/{name}/SKILL.md)
|
|
767
|
+
const skillsSrc = join(PKG_ROOT, "skills");
|
|
768
|
+
const skillsDst = join(CLAUDE_DIR, "skills");
|
|
769
|
+
if (existsSync(skillsSrc)) {
|
|
770
|
+
let skillCount = 0;
|
|
771
|
+
let skillTotal = 0;
|
|
772
|
+
for (const name of readdirSync(skillsSrc)) {
|
|
773
|
+
const src = join(skillsSrc, name, "SKILL.md");
|
|
774
|
+
const dst = join(skillsDst, name, "SKILL.md");
|
|
775
|
+
if (!existsSync(src)) continue;
|
|
776
|
+
skillTotal++;
|
|
777
|
+
|
|
778
|
+
const dstDir = dirname(dst);
|
|
779
|
+
if (!existsSync(dstDir)) mkdirSync(dstDir, { recursive: true });
|
|
780
|
+
|
|
781
|
+
if (!existsSync(dst)) {
|
|
782
|
+
copyFileSync(src, dst);
|
|
783
|
+
skillCount++;
|
|
784
|
+
} else {
|
|
785
|
+
const srcContent = readFileSync(src, "utf8");
|
|
786
|
+
const dstContent = readFileSync(dst, "utf8");
|
|
787
|
+
if (srcContent !== dstContent) {
|
|
788
|
+
copyFileSync(src, dst);
|
|
789
|
+
skillCount++;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
if (skillCount > 0) {
|
|
794
|
+
ok(`스킬: ${skillCount}/${skillTotal}개 업데이트됨`);
|
|
795
|
+
} else {
|
|
796
|
+
ok(`스킬: ${skillTotal}개 최신 상태`);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
const codexProfileResult = ensureCodexProfiles();
|
|
801
|
+
if (!codexProfileResult.ok) {
|
|
802
|
+
warn(`Codex profiles 설정 실패: ${codexProfileResult.message}`);
|
|
803
|
+
} else if (codexProfileResult.added > 0) {
|
|
804
|
+
ok(`Codex profiles: ${codexProfileResult.added}개 추가됨 (~/.codex/config.toml)`);
|
|
805
|
+
} else {
|
|
806
|
+
ok("Codex profiles: 이미 준비됨");
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// hub MCP 사전 등록 (서버 미실행이어도 설정만 등록 — hub start 시 즉시 사용 가능)
|
|
810
|
+
if (existsSync(join(PKG_ROOT, "hub", "server.mjs"))) {
|
|
811
|
+
const defaultHubUrl = `http://127.0.0.1:${process.env.TFX_HUB_PORT || "27888"}/mcp`;
|
|
812
|
+
autoRegisterMcp(defaultHubUrl);
|
|
813
|
+
console.log("");
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// HUD statusLine 설정
|
|
817
|
+
console.log(`${CYAN}[HUD 설정]${RESET}`);
|
|
818
|
+
const settingsPath = join(CLAUDE_DIR, "settings.json");
|
|
819
|
+
const hudPath = join(CLAUDE_DIR, "hud", "hud-qos-status.mjs");
|
|
820
|
+
|
|
821
|
+
if (existsSync(hudPath)) {
|
|
822
|
+
try {
|
|
823
|
+
let settings = {};
|
|
824
|
+
if (existsSync(settingsPath)) {
|
|
825
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
const currentCmd = settings.statusLine?.command || "";
|
|
829
|
+
if (currentCmd.includes("hud-qos-status.mjs")) {
|
|
830
|
+
ok("statusLine 이미 설정됨");
|
|
831
|
+
} else {
|
|
832
|
+
const nodePath = process.execPath.replace(/\\/g, "/");
|
|
833
|
+
const hudForward = hudPath.replace(/\\/g, "/");
|
|
834
|
+
const nodeRef = nodePath.includes(" ") ? `"${nodePath}"` : nodePath;
|
|
835
|
+
const hudRef = hudForward.includes(" ") ? `"${hudForward}"` : hudForward;
|
|
836
|
+
|
|
837
|
+
if (currentCmd) {
|
|
838
|
+
warn(`기존 statusLine 덮어쓰기: ${currentCmd}`);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
settings.statusLine = {
|
|
842
|
+
type: "command",
|
|
843
|
+
command: `${nodeRef} ${hudRef}`,
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
847
|
+
ok("statusLine 설정 완료 — 세션 재시작 후 HUD 표시");
|
|
848
|
+
}
|
|
849
|
+
} catch (e) {
|
|
850
|
+
throw createCliError(`settings.json 처리 실패: ${e.message}`, {
|
|
851
|
+
exitCode: EXIT_CONFIG_ERROR,
|
|
852
|
+
reason: "configError",
|
|
853
|
+
fix: `${settingsPath}의 JSON 문법을 수정하세요.`,
|
|
854
|
+
cause: e,
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
} else {
|
|
858
|
+
warn("HUD 파일 없음 — 먼저 파일 동기화 필요");
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
console.log(`\n${DIM}설치 위치: ${CLAUDE_DIR}${RESET}\n`);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function addDoctorCheck(report, entry) {
|
|
865
|
+
report.checks.push(entry);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
async function cmdDoctor(options = {}) {
|
|
869
|
+
const { fix = false, reset = false, json = false } = options;
|
|
870
|
+
const report = {
|
|
871
|
+
status: "ok",
|
|
872
|
+
mode: reset ? "reset" : fix ? "fix" : "check",
|
|
873
|
+
checks: [],
|
|
874
|
+
actions: [],
|
|
875
|
+
issue_count: 0,
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
return await withConsoleSilenced(json, async () => {
|
|
879
|
+
const modeLabel = reset ? ` ${RED}--reset${RESET}` : fix ? ` ${YELLOW}--fix${RESET}` : "";
|
|
880
|
+
console.log(`\n ${AMBER}${BOLD}⬡ triflux doctor${RESET} ${VER}${modeLabel}\n`);
|
|
881
|
+
console.log(` ${LINE}`);
|
|
882
|
+
|
|
883
|
+
// ── reset 모드: 캐시 전체 초기화 ──
|
|
884
|
+
if (reset) {
|
|
885
|
+
section("Cache Reset");
|
|
886
|
+
const cacheDir = join(CLAUDE_DIR, "cache");
|
|
887
|
+
const resetFiles = [
|
|
888
|
+
"claude-usage-cache.json",
|
|
889
|
+
".claude-refresh-lock",
|
|
890
|
+
"codex-rate-limits-cache.json",
|
|
891
|
+
"gemini-quota-cache.json",
|
|
892
|
+
"gemini-project-id.json",
|
|
893
|
+
"gemini-session-cache.json",
|
|
894
|
+
"gemini-rpm-tracker.json",
|
|
895
|
+
"sv-accumulator.json",
|
|
896
|
+
"mcp-inventory.json",
|
|
897
|
+
"cli-issues.jsonl",
|
|
898
|
+
"triflux-update-check.json",
|
|
899
|
+
];
|
|
900
|
+
let cleared = 0;
|
|
901
|
+
for (const name of resetFiles) {
|
|
902
|
+
const fp = join(cacheDir, name);
|
|
903
|
+
if (existsSync(fp)) {
|
|
904
|
+
try {
|
|
905
|
+
unlinkSync(fp);
|
|
906
|
+
cleared++;
|
|
907
|
+
report.actions.push({ type: "delete", path: fp, status: "ok" });
|
|
908
|
+
ok(`삭제됨: ${name}`);
|
|
909
|
+
} catch (e) {
|
|
910
|
+
report.actions.push({ type: "delete", path: fp, status: "failed", message: e.message });
|
|
911
|
+
fail(`삭제 실패: ${name} — ${e.message}`);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
if (cleared === 0) {
|
|
916
|
+
ok("삭제할 캐시 파일 없음 (이미 깨끗함)");
|
|
917
|
+
} else {
|
|
918
|
+
console.log("");
|
|
919
|
+
ok(`${BOLD}${cleared}개${RESET} 캐시 파일 초기화 완료`);
|
|
920
|
+
}
|
|
921
|
+
console.log("");
|
|
922
|
+
section("Cache Rebuild");
|
|
923
|
+
const mcpCheck = join(PKG_ROOT, "scripts", "mcp-check.mjs");
|
|
924
|
+
if (existsSync(mcpCheck)) {
|
|
925
|
+
try {
|
|
926
|
+
execFileSync(process.execPath, [mcpCheck], { timeout: 15000, stdio: "ignore", windowsHide: true });
|
|
927
|
+
report.actions.push({ type: "rebuild", name: "mcp-inventory", status: "ok" });
|
|
928
|
+
ok("MCP 인벤토리 재생성됨");
|
|
929
|
+
} catch {
|
|
930
|
+
report.actions.push({ type: "rebuild", name: "mcp-inventory", status: "failed" });
|
|
931
|
+
warn("MCP 인벤토리 재생성 실패 — 다음 세션에서 자동 재시도");
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
const hudScript = join(CLAUDE_DIR, "hud", "hud-qos-status.mjs");
|
|
935
|
+
if (existsSync(hudScript)) {
|
|
936
|
+
try {
|
|
937
|
+
execFileSync(process.execPath, [hudScript, "--refresh-claude-usage"], { timeout: 20000, stdio: "ignore", windowsHide: true });
|
|
938
|
+
report.actions.push({ type: "rebuild", name: "claude-usage-cache", status: "ok" });
|
|
939
|
+
ok("Claude 사용량 캐시 재생성됨");
|
|
940
|
+
} catch {
|
|
941
|
+
report.actions.push({ type: "rebuild", name: "claude-usage-cache", status: "failed" });
|
|
942
|
+
warn("Claude 사용량 캐시 재생성 실패 — 다음 API 호출 시 자동 생성");
|
|
943
|
+
}
|
|
944
|
+
try {
|
|
945
|
+
execFileSync(process.execPath, [hudScript, "--refresh-codex-rate-limits"], { timeout: 15000, stdio: "ignore", windowsHide: true });
|
|
946
|
+
report.actions.push({ type: "rebuild", name: "codex-rate-limits-cache", status: "ok" });
|
|
947
|
+
ok("Codex 레이트 리밋 캐시 재생성됨");
|
|
948
|
+
} catch {
|
|
949
|
+
report.actions.push({ type: "rebuild", name: "codex-rate-limits-cache", status: "failed" });
|
|
950
|
+
warn("Codex 레이트 리밋 캐시 재생성 실패");
|
|
951
|
+
}
|
|
952
|
+
try {
|
|
953
|
+
execFileSync(process.execPath, [hudScript, "--refresh-gemini-quota"], { timeout: 15000, stdio: "ignore", windowsHide: true });
|
|
954
|
+
report.actions.push({ type: "rebuild", name: "gemini-quota-cache", status: "ok" });
|
|
955
|
+
ok("Gemini 쿼터 캐시 재생성됨");
|
|
956
|
+
} catch {
|
|
957
|
+
report.actions.push({ type: "rebuild", name: "gemini-quota-cache", status: "failed" });
|
|
958
|
+
warn("Gemini 쿼터 캐시 재생성 실패");
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
console.log(`\n ${LINE}`);
|
|
962
|
+
console.log(` ${GREEN_BRIGHT}${BOLD}✓ 캐시 초기화 + 재생성 완료${RESET}\n`);
|
|
963
|
+
report.status = report.actions.some((action) => action.status === "failed") ? "issues" : "ok";
|
|
964
|
+
report.issue_count = report.actions.filter((action) => action.status === "failed").length;
|
|
965
|
+
if (json) printJson(report);
|
|
966
|
+
return report;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// ── fix 모드: 파일 동기화 + 캐시 정리 후 진단 ──
|
|
970
|
+
if (fix) {
|
|
971
|
+
section("Auto Fix");
|
|
972
|
+
for (const target of getSetupSyncTargets()) {
|
|
973
|
+
syncFile(target.src, target.dst, target.label);
|
|
974
|
+
}
|
|
975
|
+
// 스킬 동기화
|
|
976
|
+
const fSkillsSrc = join(PKG_ROOT, "skills");
|
|
977
|
+
const fSkillsDst = join(CLAUDE_DIR, "skills");
|
|
978
|
+
if (existsSync(fSkillsSrc)) {
|
|
979
|
+
let sc = 0, st = 0;
|
|
980
|
+
for (const name of readdirSync(fSkillsSrc)) {
|
|
981
|
+
const src = join(fSkillsSrc, name, "SKILL.md");
|
|
982
|
+
const dst = join(fSkillsDst, name, "SKILL.md");
|
|
983
|
+
if (!existsSync(src)) continue;
|
|
984
|
+
st++;
|
|
985
|
+
const dstDir = dirname(dst);
|
|
986
|
+
if (!existsSync(dstDir)) mkdirSync(dstDir, { recursive: true });
|
|
987
|
+
if (!existsSync(dst)) { copyFileSync(src, dst); sc++; }
|
|
988
|
+
else if (readFileSync(src, "utf8") !== readFileSync(dst, "utf8")) { copyFileSync(src, dst); sc++; }
|
|
989
|
+
}
|
|
990
|
+
if (sc > 0) ok(`스킬: ${sc}/${st}개 업데이트됨`);
|
|
991
|
+
else ok(`스킬: ${st}개 최신 상태`);
|
|
992
|
+
}
|
|
993
|
+
const profileFix = ensureCodexProfiles();
|
|
994
|
+
if (!profileFix.ok) {
|
|
995
|
+
warn(`Codex Profiles 자동 복구 실패: ${profileFix.message}`);
|
|
996
|
+
} else if (profileFix.added > 0) {
|
|
997
|
+
ok(`Codex Profiles: ${profileFix.added}개 추가됨`);
|
|
998
|
+
} else {
|
|
999
|
+
info("Codex Profiles: 이미 최신 상태");
|
|
1000
|
+
}
|
|
1001
|
+
// 에러/스테일 캐시 정리
|
|
1002
|
+
const fCacheDir = join(CLAUDE_DIR, "cache");
|
|
1003
|
+
const staleNames = ["claude-usage-cache.json", ".claude-refresh-lock", "codex-rate-limits-cache.json"];
|
|
1004
|
+
let cleaned = 0;
|
|
1005
|
+
for (const name of staleNames) {
|
|
1006
|
+
const fp = join(fCacheDir, name);
|
|
1007
|
+
if (!existsSync(fp)) continue;
|
|
1008
|
+
try {
|
|
1009
|
+
const parsed = JSON.parse(readFileSync(fp, "utf8"));
|
|
1010
|
+
if (parsed.error || name.startsWith(".")) { unlinkSync(fp); cleaned++; ok(`에러 캐시 정리: ${name}`); }
|
|
1011
|
+
} catch { try { unlinkSync(fp); cleaned++; ok(`손상된 캐시 정리: ${name}`); } catch {} }
|
|
1012
|
+
}
|
|
1013
|
+
if (cleaned === 0) info("에러 캐시 없음");
|
|
1014
|
+
console.log(`\n ${LINE}`);
|
|
1015
|
+
info("수정 완료 — 아래 진단 결과를 확인하세요");
|
|
1016
|
+
console.log("");
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
let issues = 0;
|
|
1020
|
+
|
|
1021
|
+
// 1. tfx-route.sh
|
|
1022
|
+
section("tfx-route.sh");
|
|
1023
|
+
const routeSh = join(CLAUDE_DIR, "scripts", "tfx-route.sh");
|
|
1024
|
+
if (existsSync(routeSh)) {
|
|
1025
|
+
const ver = getVersion(routeSh);
|
|
1026
|
+
addDoctorCheck(report, { name: "tfx-route.sh", status: "ok", path: routeSh, version: ver });
|
|
1027
|
+
ok(`설치됨 ${ver ? `${DIM}v${ver}${RESET}` : ""}`);
|
|
1028
|
+
} else {
|
|
1029
|
+
addDoctorCheck(report, { name: "tfx-route.sh", status: "missing", path: routeSh, fix: "tfx setup" });
|
|
1030
|
+
fail("미설치 — tfx setup 실행 필요");
|
|
1031
|
+
issues++;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// 2. HUD
|
|
1035
|
+
section("HUD");
|
|
1036
|
+
const hud = join(CLAUDE_DIR, "hud", "hud-qos-status.mjs");
|
|
1037
|
+
if (existsSync(hud)) {
|
|
1038
|
+
addDoctorCheck(report, { name: "hud-qos-status.mjs", status: "ok", path: hud });
|
|
1039
|
+
ok("설치됨");
|
|
1040
|
+
} else {
|
|
1041
|
+
addDoctorCheck(report, { name: "hud-qos-status.mjs", status: "missing", path: hud, optional: true, fix: "tfx setup" });
|
|
1042
|
+
warn("미설치 ${GRAY}(선택사항)${RESET}");
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// 3. Codex CLI
|
|
1046
|
+
section(`Codex CLI ${WHITE_BRIGHT}●${RESET}`);
|
|
1047
|
+
const codexCli = checkCliCrossShell("codex", "npm install -g @openai/codex");
|
|
1048
|
+
issues += codexCli.issues;
|
|
1049
|
+
addDoctorCheck(report, {
|
|
1050
|
+
name: "codex",
|
|
1051
|
+
status: codexCli.status,
|
|
1052
|
+
shells: codexCli.shells,
|
|
1053
|
+
...(codexCli.fix ? { fix: codexCli.fix } : {}),
|
|
1054
|
+
});
|
|
1055
|
+
// API 키 검사 제거 — bash exec 기반이므로 API 키 불필요
|
|
1056
|
+
|
|
1057
|
+
// 4. Codex Profiles
|
|
1058
|
+
section("Codex Profiles");
|
|
1059
|
+
if (existsSync(CODEX_CONFIG_PATH)) {
|
|
1060
|
+
const codexConfig = readFileSync(CODEX_CONFIG_PATH, "utf8");
|
|
1061
|
+
const missingProfiles = [];
|
|
1062
|
+
for (const profile of REQUIRED_CODEX_PROFILES) {
|
|
1063
|
+
if (hasProfileSection(codexConfig, profile.name)) {
|
|
1064
|
+
ok(`${profile.name}: 정상`);
|
|
1065
|
+
} else {
|
|
1066
|
+
missingProfiles.push(profile.name);
|
|
1067
|
+
warn(`${profile.name}: 미설정`);
|
|
1068
|
+
issues++;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
addDoctorCheck(report, {
|
|
1072
|
+
name: "codex-profiles",
|
|
1073
|
+
status: missingProfiles.length === 0 ? "ok" : "missing",
|
|
1074
|
+
path: CODEX_CONFIG_PATH,
|
|
1075
|
+
missing_profiles: missingProfiles,
|
|
1076
|
+
...(missingProfiles.length > 0 ? { fix: "tfx setup" } : {}),
|
|
1077
|
+
});
|
|
1078
|
+
} else {
|
|
1079
|
+
addDoctorCheck(report, { name: "codex-profiles", status: "missing", path: CODEX_CONFIG_PATH, fix: "tfx setup" });
|
|
1080
|
+
warn("config.toml 미존재");
|
|
1081
|
+
issues++;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// 5. Gemini CLI
|
|
1085
|
+
section(`Gemini CLI ${BLUE}●${RESET}`);
|
|
1086
|
+
const geminiCli = checkCliCrossShell("gemini", "npm install -g @google/gemini-cli");
|
|
1087
|
+
issues += geminiCli.issues;
|
|
1088
|
+
addDoctorCheck(report, {
|
|
1089
|
+
name: "gemini",
|
|
1090
|
+
status: geminiCli.status,
|
|
1091
|
+
shells: geminiCli.shells,
|
|
1092
|
+
...(geminiCli.fix ? { fix: geminiCli.fix } : {}),
|
|
1093
|
+
});
|
|
1094
|
+
// API 키 검사 제거 — bash exec 기반이므로 API 키 불필요
|
|
1095
|
+
|
|
1096
|
+
// 6. Claude Code
|
|
1097
|
+
section(`Claude Code ${AMBER}●${RESET}`);
|
|
1098
|
+
const claudePath = which("claude");
|
|
1099
|
+
if (claudePath) {
|
|
1100
|
+
addDoctorCheck(report, { name: "claude", status: "ok", path: claudePath });
|
|
1101
|
+
ok("설치됨");
|
|
1102
|
+
} else {
|
|
1103
|
+
addDoctorCheck(report, { name: "claude", status: "missing", fix: "Claude Code를 설치한 뒤 `tfx doctor`를 다시 실행하세요." });
|
|
1104
|
+
fail("미설치 (필수)");
|
|
1105
|
+
issues++;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// 7. 스킬 설치 상태
|
|
1109
|
+
section("Skills");
|
|
1110
|
+
const skillsSrc = join(PKG_ROOT, "skills");
|
|
1111
|
+
const skillsDst = join(CLAUDE_DIR, "skills");
|
|
1112
|
+
if (existsSync(skillsSrc)) {
|
|
1113
|
+
let installed = 0;
|
|
1114
|
+
let total = 0;
|
|
1115
|
+
const missing = [];
|
|
1116
|
+
for (const name of readdirSync(skillsSrc)) {
|
|
1117
|
+
if (!existsSync(join(skillsSrc, name, "SKILL.md"))) continue;
|
|
1118
|
+
total++;
|
|
1119
|
+
if (existsSync(join(skillsDst, name, "SKILL.md"))) {
|
|
1120
|
+
installed++;
|
|
1121
|
+
} else {
|
|
1122
|
+
missing.push(name);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
if (installed === total) {
|
|
1126
|
+
addDoctorCheck(report, { name: "skills", status: "ok", installed, total });
|
|
1127
|
+
ok(`${installed}/${total}개 설치됨`);
|
|
1128
|
+
} else {
|
|
1129
|
+
addDoctorCheck(report, { name: "skills", status: "missing", installed, total, missing, fix: "tfx setup" });
|
|
1130
|
+
warn(`${installed}/${total}개 설치됨 — 미설치: ${missing.join(", ")}`);
|
|
1131
|
+
info("triflux setup으로 동기화 가능");
|
|
1132
|
+
issues++;
|
|
1133
|
+
}
|
|
1134
|
+
} else {
|
|
1135
|
+
addDoctorCheck(report, { name: "skills", status: "missing", installed: 0, total: 0, fix: "패키지 skills 디렉토리를 확인하세요." });
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// 8. 플러그인 등록
|
|
1139
|
+
section("Plugin");
|
|
1140
|
+
const pluginsFile = join(CLAUDE_DIR, "plugins", "installed_plugins.json");
|
|
1141
|
+
if (existsSync(pluginsFile)) {
|
|
1142
|
+
const content = readFileSync(pluginsFile, "utf8");
|
|
1143
|
+
if (content.includes("triflux")) {
|
|
1144
|
+
addDoctorCheck(report, { name: "plugin", status: "ok", path: pluginsFile });
|
|
1145
|
+
ok("triflux 플러그인 등록됨");
|
|
1146
|
+
} else {
|
|
1147
|
+
addDoctorCheck(report, { name: "plugin", status: "missing", path: pluginsFile, optional: true, fix: "/plugin marketplace add <repo-url>" });
|
|
1148
|
+
warn("triflux 플러그인 미등록 — npm 단독 사용 중");
|
|
1149
|
+
info("플러그인 등록: /plugin marketplace add <repo-url>");
|
|
1150
|
+
}
|
|
1151
|
+
} else {
|
|
1152
|
+
addDoctorCheck(report, { name: "plugin", status: "unavailable", optional: true });
|
|
1153
|
+
info("플러그인 시스템 감지 안 됨 — npm 단독 사용");
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
// 9. MCP 인벤토리
|
|
1157
|
+
section("MCP Inventory");
|
|
1158
|
+
const mcpCache = join(CLAUDE_DIR, "cache", "mcp-inventory.json");
|
|
1159
|
+
if (existsSync(mcpCache)) {
|
|
1160
|
+
try {
|
|
1161
|
+
const inv = JSON.parse(readFileSync(mcpCache, "utf8"));
|
|
1162
|
+
addDoctorCheck(report, {
|
|
1163
|
+
name: "mcp-inventory",
|
|
1164
|
+
status: "ok",
|
|
1165
|
+
path: mcpCache,
|
|
1166
|
+
codex_servers: inv.codex?.servers?.length || 0,
|
|
1167
|
+
gemini_servers: inv.gemini?.servers?.length || 0,
|
|
1168
|
+
});
|
|
1169
|
+
ok(`캐시 존재 (${inv.timestamp})`);
|
|
1170
|
+
if (inv.codex?.servers?.length) {
|
|
1171
|
+
const names = inv.codex.servers.map(s => s.name).join(", ");
|
|
1172
|
+
info(`Codex: ${inv.codex.servers.length}개 서버 (${names})`);
|
|
1173
|
+
}
|
|
1174
|
+
if (inv.gemini?.servers?.length) {
|
|
1175
|
+
const names = inv.gemini.servers.map(s => s.name).join(", ");
|
|
1176
|
+
info(`Gemini: ${inv.gemini.servers.length}개 서버 (${names})`);
|
|
1177
|
+
}
|
|
1178
|
+
} catch {
|
|
1179
|
+
addDoctorCheck(report, { name: "mcp-inventory", status: "invalid", path: mcpCache, fix: `node ${join(PKG_ROOT, "scripts", "mcp-check.mjs")}` });
|
|
1180
|
+
warn("캐시 파일 파싱 실패");
|
|
1181
|
+
}
|
|
1182
|
+
} else {
|
|
1183
|
+
addDoctorCheck(report, { name: "mcp-inventory", status: "missing", path: mcpCache, fix: `node ${join(PKG_ROOT, "scripts", "mcp-check.mjs")}` });
|
|
1184
|
+
warn("캐시 없음 — 다음 세션 시작 시 자동 생성");
|
|
1185
|
+
info(`수동: node ${join(PKG_ROOT, "scripts", "mcp-check.mjs")}`);
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
// 10. CLI 이슈 트래커
|
|
1189
|
+
section("CLI Issues");
|
|
1190
|
+
const issuesFile = join(CLAUDE_DIR, "cache", "cli-issues.jsonl");
|
|
1191
|
+
if (existsSync(issuesFile)) {
|
|
1192
|
+
try {
|
|
1193
|
+
const lines = readFileSync(issuesFile, "utf8").trim().split("\n").filter(Boolean);
|
|
1194
|
+
const entries = lines.map(l => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean);
|
|
1195
|
+
const unresolved = entries.filter(e => !e.resolved);
|
|
1196
|
+
|
|
1197
|
+
if (unresolved.length === 0) {
|
|
1198
|
+
addDoctorCheck(report, { name: "cli-issues", status: "ok", path: issuesFile, unresolved: 0 });
|
|
1199
|
+
ok("미해결 이슈 없음");
|
|
1200
|
+
} else {
|
|
1201
|
+
// 패턴별 그룹핑
|
|
1202
|
+
const groups = {};
|
|
1203
|
+
for (const e of unresolved) {
|
|
1204
|
+
const key = `${e.cli}:${e.pattern}`;
|
|
1205
|
+
if (!groups[key]) groups[key] = { ...e, count: 0 };
|
|
1206
|
+
groups[key].count++;
|
|
1207
|
+
if (e.ts > groups[key].ts) { groups[key].ts = e.ts; groups[key].snippet = e.snippet; }
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// 알려진 해결 버전 (패턴별 수정된 triflux 버전)
|
|
1211
|
+
const KNOWN_FIXES = {
|
|
1212
|
+
"gemini:deprecated_flag": "1.8.9", // -p → --prompt
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
const currentVer = JSON.parse(readFileSync(join(PKG_ROOT, "package.json"), "utf8")).version;
|
|
1216
|
+
let cleaned = 0;
|
|
1217
|
+
|
|
1218
|
+
for (const [key, g] of Object.entries(groups)) {
|
|
1219
|
+
const fixVer = KNOWN_FIXES[key];
|
|
1220
|
+
if (fixVer && currentVer >= fixVer) {
|
|
1221
|
+
// 해결된 이슈 — 자동 정리
|
|
1222
|
+
cleaned += g.count;
|
|
1223
|
+
continue;
|
|
1224
|
+
}
|
|
1225
|
+
const age = Date.now() - g.ts;
|
|
1226
|
+
const ago = age < 3600000 ? `${Math.round(age / 60000)}분 전` :
|
|
1227
|
+
age < 86400000 ? `${Math.round(age / 3600000)}시간 전` :
|
|
1228
|
+
`${Math.round(age / 86400000)}일 전`;
|
|
1229
|
+
const sev = g.severity === "error" ? `${RED}ERROR${RESET}` : `${YELLOW}WARN${RESET}`;
|
|
1230
|
+
warn(`[${sev}] ${g.cli}/${g.pattern} x${g.count} (최근: ${ago})`);
|
|
1231
|
+
if (g.snippet) info(` ${g.snippet.substring(0, 120)}`);
|
|
1232
|
+
if (fixVer) info(` 해결: triflux >= v${fixVer} (npm update -g triflux)`);
|
|
1233
|
+
issues++;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// 해결된 이슈 자동 정리
|
|
1237
|
+
if (cleaned > 0) {
|
|
1238
|
+
const remaining = entries.filter(e => {
|
|
1239
|
+
const key = `${e.cli}:${e.pattern}`;
|
|
1240
|
+
const fixVer = KNOWN_FIXES[key];
|
|
1241
|
+
return !(fixVer && currentVer >= fixVer);
|
|
1242
|
+
});
|
|
1243
|
+
writeFileSync(issuesFile, remaining.map(e => JSON.stringify(e)).join("\n") + (remaining.length ? "\n" : ""));
|
|
1244
|
+
ok(`${cleaned}개 해결된 이슈 자동 정리됨`);
|
|
1245
|
+
}
|
|
1246
|
+
addDoctorCheck(report, { name: "cli-issues", status: unresolved.length === 0 ? "ok" : "issues", path: issuesFile, unresolved: unresolved.length });
|
|
1247
|
+
}
|
|
1248
|
+
} catch (e) {
|
|
1249
|
+
addDoctorCheck(report, { name: "cli-issues", status: "invalid", path: issuesFile, fix: "cli-issues.jsonl 형식을 확인하세요." });
|
|
1250
|
+
warn(`이슈 파일 읽기 실패: ${e.message}`);
|
|
1251
|
+
}
|
|
1252
|
+
} else {
|
|
1253
|
+
addDoctorCheck(report, { name: "cli-issues", status: "ok", path: issuesFile, unresolved: 0 });
|
|
1254
|
+
ok("이슈 로그 없음 (정상)");
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// 11. Team Sessions
|
|
1258
|
+
section("Team Sessions");
|
|
1259
|
+
const teamSessionReport = inspectTeamSessions();
|
|
1260
|
+
if (!teamSessionReport.mux) {
|
|
1261
|
+
addDoctorCheck(report, { name: "team-sessions", status: "skipped", detail: "tmux/psmux unavailable" });
|
|
1262
|
+
info("tmux/psmux 미감지 — 팀 세션 검사 건너뜀");
|
|
1263
|
+
} else if (teamSessionReport.sessions.length === 0) {
|
|
1264
|
+
addDoctorCheck(report, { name: "team-sessions", status: "ok", multiplexer: teamSessionReport.mux, sessions: 0 });
|
|
1265
|
+
ok(`활성 팀 세션 없음 ${DIM}(${teamSessionReport.mux})${RESET}`);
|
|
1266
|
+
} else {
|
|
1267
|
+
addDoctorCheck(report, {
|
|
1268
|
+
name: "team-sessions",
|
|
1269
|
+
status: teamSessionReport.sessions.some((session) => session.stale) ? "issues" : "ok",
|
|
1270
|
+
multiplexer: teamSessionReport.mux,
|
|
1271
|
+
sessions: teamSessionReport.sessions.map((session) => ({
|
|
1272
|
+
name: session.sessionName,
|
|
1273
|
+
attached: session.attachedCount,
|
|
1274
|
+
age_sec: session.ageSec,
|
|
1275
|
+
stale: session.stale,
|
|
1276
|
+
})),
|
|
1277
|
+
});
|
|
1278
|
+
info(`multiplexer: ${teamSessionReport.mux}`);
|
|
1279
|
+
|
|
1280
|
+
for (const session of teamSessionReport.sessions) {
|
|
1281
|
+
const attachedLabel = session.attachedCount == null ? "?" : `${session.attachedCount}`;
|
|
1282
|
+
const ageLabel = formatElapsedAge(session.ageSec);
|
|
1283
|
+
|
|
1284
|
+
if (session.stale) {
|
|
1285
|
+
warn(`${session.sessionName}: stale 추정 (attach=${attachedLabel}, 경과=${ageLabel})`);
|
|
1286
|
+
} else {
|
|
1287
|
+
ok(`${session.sessionName}: 정상 (attach=${attachedLabel}, 경과=${ageLabel})`);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
if (session.createdAt == null) {
|
|
1291
|
+
info(`${session.sessionName}: session_created 파싱 실패${session.createdRaw ? ` (${session.createdRaw})` : ""}`);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
const staleSessions = teamSessionReport.sessions.filter((session) => session.stale);
|
|
1296
|
+
if (staleSessions.length > 0) {
|
|
1297
|
+
if (fix) {
|
|
1298
|
+
const cleanupResult = await cleanupStaleTeamSessions(staleSessions);
|
|
1299
|
+
issues += cleanupResult.failed;
|
|
1300
|
+
} else {
|
|
1301
|
+
info("정리: tfx doctor --fix");
|
|
1302
|
+
issues += staleSessions.length;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// 12. OMC stale team 상태
|
|
1308
|
+
section("OMC Stale Teams");
|
|
1309
|
+
const omcTeamReport = inspectStaleOmcTeams({
|
|
1310
|
+
startDir: process.cwd(),
|
|
1311
|
+
maxAgeMs: STALE_TEAM_MAX_AGE_SEC * 1000,
|
|
1312
|
+
liveSessionNames: teamSessionReport.sessions.map((session) => session.sessionName),
|
|
1313
|
+
});
|
|
1314
|
+
if (!omcTeamReport.stateRoot && !omcTeamReport.teamsRoot) {
|
|
1315
|
+
addDoctorCheck(report, { name: "omc-stale-teams", status: "skipped" });
|
|
1316
|
+
info(".omc/state 및 ~/.claude/teams 없음 — 검사 건너뜀");
|
|
1317
|
+
} else if (omcTeamReport.entries.length === 0) {
|
|
1318
|
+
addDoctorCheck(report, { name: "omc-stale-teams", status: "ok", entries: 0 });
|
|
1319
|
+
const roots = [omcTeamReport.stateRoot, omcTeamReport.teamsRoot].filter(Boolean).join(", ");
|
|
1320
|
+
ok(`stale team 없음 ${DIM}(${roots})${RESET}`);
|
|
1321
|
+
} else {
|
|
1322
|
+
addDoctorCheck(report, { name: "omc-stale-teams", status: "issues", entries: omcTeamReport.entries.length, fix: "tfx doctor --fix" });
|
|
1323
|
+
warn(`${omcTeamReport.entries.length}개 stale team 발견`);
|
|
1324
|
+
|
|
1325
|
+
for (const entry of omcTeamReport.entries) {
|
|
1326
|
+
const ageLabel = formatElapsedAge(entry.ageSec);
|
|
1327
|
+
const scopeLabel = entry.scope === "root"
|
|
1328
|
+
? "root-state"
|
|
1329
|
+
: entry.scope === "claude_team"
|
|
1330
|
+
? `claude-team:${entry.teamName || entry.sessionId}`
|
|
1331
|
+
: entry.sessionId;
|
|
1332
|
+
warn(`${scopeLabel}: stale team (경과=${ageLabel}, 프로세스 없음)`);
|
|
1333
|
+
if (entry.teamName) info(`팀: ${entry.teamName}`);
|
|
1334
|
+
info(`파일: ${entry.stateFile || entry.cleanupPath}`);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
if (fix) {
|
|
1338
|
+
const cleanupResult = await cleanupStaleOmcTeams(omcTeamReport.entries);
|
|
1339
|
+
for (const result of cleanupResult.results) {
|
|
1340
|
+
if (result.ok) {
|
|
1341
|
+
const label = result.entry.scope === "root"
|
|
1342
|
+
? "root-state"
|
|
1343
|
+
: result.entry.scope === "claude_team"
|
|
1344
|
+
? (result.entry.teamName || result.entry.sessionId)
|
|
1345
|
+
: result.entry.sessionId;
|
|
1346
|
+
ok(`stale team 정리: ${label}`);
|
|
1347
|
+
} else {
|
|
1348
|
+
const label = result.entry.scope === "root"
|
|
1349
|
+
? "root-state"
|
|
1350
|
+
: result.entry.scope === "claude_team"
|
|
1351
|
+
? (result.entry.teamName || result.entry.sessionId)
|
|
1352
|
+
: result.entry.sessionId;
|
|
1353
|
+
fail(`stale team 정리 실패: ${label} — ${result.error.message}`);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
issues += cleanupResult.failed;
|
|
1357
|
+
} else {
|
|
1358
|
+
info("정리: tfx doctor --fix");
|
|
1359
|
+
issues += omcTeamReport.entries.length;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// 13. Stale Teams (Claude teams/ + tasks/ 자동 감지)
|
|
1364
|
+
section("Stale Teams");
|
|
1365
|
+
const teamsDir = join(CLAUDE_DIR, "teams");
|
|
1366
|
+
const tasksDir = join(CLAUDE_DIR, "tasks");
|
|
1367
|
+
if (existsSync(teamsDir)) {
|
|
1368
|
+
try {
|
|
1369
|
+
const teamDirs = readdirSync(teamsDir).filter(d => {
|
|
1370
|
+
try { return statSync(join(teamsDir, d)).isDirectory(); } catch { return false; }
|
|
1371
|
+
});
|
|
1372
|
+
if (teamDirs.length === 0) {
|
|
1373
|
+
addDoctorCheck(report, { name: "stale-teams", status: "ok", entries: 0 });
|
|
1374
|
+
ok("잔존 팀 없음");
|
|
1375
|
+
} else {
|
|
1376
|
+
const nowMs = Date.now();
|
|
1377
|
+
const staleMaxAgeMs = STALE_TEAM_MAX_AGE_SEC * 1000;
|
|
1378
|
+
const staleTeams = [];
|
|
1379
|
+
const activeTeams = [];
|
|
1380
|
+
|
|
1381
|
+
for (const d of teamDirs) {
|
|
1382
|
+
const teamPath = join(teamsDir, d);
|
|
1383
|
+
const configPath = join(teamPath, "config.json");
|
|
1384
|
+
let teamConfig = null;
|
|
1385
|
+
let configMtimeMs = null;
|
|
1386
|
+
let missingConfig = false;
|
|
1387
|
+
|
|
1388
|
+
// config.json 읽기 — createdAt 또는 mtime으로 나이 판정
|
|
1389
|
+
try {
|
|
1390
|
+
const configStat = statSync(configPath);
|
|
1391
|
+
configMtimeMs = configStat.mtimeMs;
|
|
1392
|
+
teamConfig = JSON.parse(readFileSync(configPath, "utf8"));
|
|
1393
|
+
} catch {
|
|
1394
|
+
missingConfig = true;
|
|
1395
|
+
// config.json 없으면 표시용 경과 시간만 디렉토리 기준으로 계산
|
|
1396
|
+
try { configMtimeMs = statSync(teamPath).mtimeMs; } catch {}
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
const createdAtMs = teamConfig?.createdAt ?? configMtimeMs;
|
|
1400
|
+
const ageMs = createdAtMs != null ? Math.max(0, nowMs - createdAtMs) : null;
|
|
1401
|
+
const ageSec = ageMs != null ? Math.floor(ageMs / 1000) : null;
|
|
1402
|
+
const aged = ageMs != null && ageMs >= staleMaxAgeMs;
|
|
1403
|
+
|
|
1404
|
+
// 활성 멤버 확인 — leadSessionId 또는 멤버 agentId로 프로세스 검색
|
|
1405
|
+
let hasActiveMember = false;
|
|
1406
|
+
if (teamConfig?.members?.length > 0) {
|
|
1407
|
+
const searchTokens = [];
|
|
1408
|
+
if (teamConfig.leadSessionId) searchTokens.push(teamConfig.leadSessionId.toLowerCase());
|
|
1409
|
+
if (teamConfig.name) searchTokens.push(teamConfig.name.toLowerCase());
|
|
1410
|
+
for (const member of teamConfig.members) {
|
|
1411
|
+
if (member.agentId) searchTokens.push(member.agentId.split("@")[0].toLowerCase());
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// tmux 세션 이름과 매칭
|
|
1415
|
+
const liveSessionNames = teamSessionReport.sessions.map(s => s.sessionName.toLowerCase());
|
|
1416
|
+
hasActiveMember = searchTokens.some(token =>
|
|
1417
|
+
liveSessionNames.some(name => name.includes(token))
|
|
1418
|
+
);
|
|
1419
|
+
|
|
1420
|
+
// 프로세스 명령줄에서 세션 ID 매칭 (tmux 없는 in-process 팀 지원)
|
|
1421
|
+
if (!hasActiveMember && teamConfig.leadSessionId) {
|
|
1422
|
+
try {
|
|
1423
|
+
const sessionToken = teamConfig.leadSessionId.toLowerCase();
|
|
1424
|
+
// Claude Code 프로세스에서 세션 ID 검색
|
|
1425
|
+
if (process.platform === "win32") {
|
|
1426
|
+
const psOut = execSync(
|
|
1427
|
+
`powershell -NoProfile -Command "$ErrorActionPreference='SilentlyContinue'; Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -match '${teamConfig.leadSessionId.slice(0, 8)}' } | Select-Object ProcessId | ConvertTo-Json -Compress"`,
|
|
1428
|
+
{ encoding: "utf8", timeout: 8000, stdio: ["ignore", "pipe", "ignore"], windowsHide: true },
|
|
1429
|
+
).trim();
|
|
1430
|
+
if (psOut && psOut !== "null") {
|
|
1431
|
+
const parsed = JSON.parse(psOut);
|
|
1432
|
+
const procs = Array.isArray(parsed) ? parsed : [parsed];
|
|
1433
|
+
hasActiveMember = procs.some(p => p.ProcessId > 0);
|
|
1434
|
+
}
|
|
1435
|
+
} else {
|
|
1436
|
+
const psOut = execSync(
|
|
1437
|
+
`ps -ax -o pid=,command= | grep -i '${teamConfig.leadSessionId.slice(0, 8)}' | grep -v grep`,
|
|
1438
|
+
{ encoding: "utf8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] },
|
|
1439
|
+
).trim();
|
|
1440
|
+
hasActiveMember = psOut.length > 0;
|
|
1441
|
+
}
|
|
1442
|
+
} catch {
|
|
1443
|
+
// 프로세스 검색 실패 — stale로 간주하지 않음 (보수적)
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
const stale = missingConfig || (aged && !hasActiveMember);
|
|
1449
|
+
const teamEntry = {
|
|
1450
|
+
name: d,
|
|
1451
|
+
teamName: teamConfig?.name || d,
|
|
1452
|
+
description: teamConfig?.description || null,
|
|
1453
|
+
memberCount: teamConfig?.members?.length || 0,
|
|
1454
|
+
ageSec,
|
|
1455
|
+
stale,
|
|
1456
|
+
hasActiveMember,
|
|
1457
|
+
missingConfig,
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
if (stale) {
|
|
1461
|
+
staleTeams.push(teamEntry);
|
|
1462
|
+
} else {
|
|
1463
|
+
activeTeams.push(teamEntry);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
// 활성 팀 표시
|
|
1468
|
+
for (const t of activeTeams) {
|
|
1469
|
+
const ageLabel = formatElapsedAge(t.ageSec);
|
|
1470
|
+
const memberLabel = `${t.memberCount}명`;
|
|
1471
|
+
ok(`${t.name}: 활성 (경과=${ageLabel}, 멤버=${memberLabel})`);
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
// stale 팀 표시 및 정리
|
|
1475
|
+
if (staleTeams.length === 0 && activeTeams.length > 0) {
|
|
1476
|
+
addDoctorCheck(report, { name: "stale-teams", status: "ok", active: activeTeams.length, stale: 0 });
|
|
1477
|
+
ok("stale 팀 없음");
|
|
1478
|
+
} else if (staleTeams.length > 0) {
|
|
1479
|
+
addDoctorCheck(report, { name: "stale-teams", status: "issues", active: activeTeams.length, stale: staleTeams.length, fix: "tfx doctor --fix" });
|
|
1480
|
+
warn(`${staleTeams.length}개 stale 팀 발견`);
|
|
1481
|
+
for (const t of staleTeams) {
|
|
1482
|
+
const ageLabel = formatElapsedAge(t.ageSec);
|
|
1483
|
+
const reasonLabel = t.missingConfig ? "config.json 없음" : "활성 프로세스 없음";
|
|
1484
|
+
warn(`${t.name}: stale (경과=${ageLabel}, 멤버=${t.memberCount}명, ${reasonLabel})`);
|
|
1485
|
+
if (t.description) info(`설명: ${t.description}`);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
if (fix) {
|
|
1489
|
+
let cleaned = 0;
|
|
1490
|
+
for (const t of staleTeams) {
|
|
1491
|
+
try {
|
|
1492
|
+
await forceCleanupTeam(t.name);
|
|
1493
|
+
cleaned++;
|
|
1494
|
+
ok(`stale 팀 정리: ${t.name}`);
|
|
1495
|
+
} catch (e) {
|
|
1496
|
+
fail(`팀 정리 실패: ${t.name} — ${e.message}`);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
info(`${cleaned}/${staleTeams.length}개 stale 팀 정리 완료`);
|
|
1500
|
+
} else {
|
|
1501
|
+
info("정리: tfx doctor --fix");
|
|
1502
|
+
issues += staleTeams.length;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
} catch (e) {
|
|
1507
|
+
addDoctorCheck(report, { name: "stale-teams", status: "invalid", fix: "teams 디렉토리 구조를 확인하세요." });
|
|
1508
|
+
warn(`teams 디렉토리 읽기 실패: ${e.message}`);
|
|
1509
|
+
}
|
|
1510
|
+
} else {
|
|
1511
|
+
addDoctorCheck(report, { name: "stale-teams", status: "ok", entries: 0 });
|
|
1512
|
+
ok("잔존 팀 없음");
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// 결과
|
|
1516
|
+
console.log(`\n ${LINE}`);
|
|
1517
|
+
if (issues === 0) {
|
|
1518
|
+
console.log(` ${GREEN_BRIGHT}${BOLD}✓ 모든 검사 통과${RESET}\n`);
|
|
1519
|
+
} else {
|
|
1520
|
+
console.log(` ${YELLOW}${BOLD}⚠ ${issues}개 항목 확인 필요${RESET}\n`);
|
|
1521
|
+
}
|
|
1522
|
+
report.issue_count = issues;
|
|
1523
|
+
report.status = issues === 0 ? "ok" : "issues";
|
|
1524
|
+
if (json) printJson(report);
|
|
1525
|
+
return report;
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
function cmdUpdate() {
|
|
1530
|
+
const isDev = isDevUpdateRequested(NORMALIZED_ARGS);
|
|
1531
|
+
const tagLabel = isDev ? ` ${YELLOW}--dev${RESET}` : "";
|
|
1532
|
+
console.log(`\n${BOLD}triflux update${RESET}${tagLabel}\n`);
|
|
1533
|
+
|
|
1534
|
+
// 1. 설치 방식 감지
|
|
1535
|
+
const pluginsFile = join(CLAUDE_DIR, "plugins", "installed_plugins.json");
|
|
1536
|
+
let installMode = "unknown";
|
|
1537
|
+
let pluginPath = null;
|
|
1538
|
+
|
|
1539
|
+
// 플러그인 모드 감지
|
|
1540
|
+
if (existsSync(pluginsFile)) {
|
|
1541
|
+
try {
|
|
1542
|
+
const plugins = JSON.parse(readFileSync(pluginsFile, "utf8"));
|
|
1543
|
+
for (const [key, entries] of Object.entries(plugins.plugins || {})) {
|
|
1544
|
+
if (key.startsWith("triflux")) {
|
|
1545
|
+
pluginPath = entries[0]?.installPath;
|
|
1546
|
+
installMode = "plugin";
|
|
1547
|
+
break;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
} catch {}
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
// PKG_ROOT가 플러그인 캐시 내에 있으면 플러그인 모드
|
|
1554
|
+
if (installMode === "unknown" && PKG_ROOT.includes(join(".claude", "plugins"))) {
|
|
1555
|
+
installMode = "plugin";
|
|
1556
|
+
pluginPath = PKG_ROOT;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
// npm global 감지
|
|
1560
|
+
if (installMode === "unknown") {
|
|
1561
|
+
try {
|
|
1562
|
+
const npmList = execSync("npm list -g triflux --depth=0", {
|
|
1563
|
+
encoding: "utf8",
|
|
1564
|
+
timeout: 10000,
|
|
1565
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1566
|
+
windowsHide: true,
|
|
1567
|
+
});
|
|
1568
|
+
if (npmList.includes("triflux")) installMode = "npm-global";
|
|
1569
|
+
} catch {}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// npm local 감지
|
|
1573
|
+
if (installMode === "unknown") {
|
|
1574
|
+
const localPkg = join(process.cwd(), "node_modules", "triflux");
|
|
1575
|
+
if (existsSync(localPkg)) installMode = "npm-local";
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
// git 저장소 직접 사용
|
|
1579
|
+
if (installMode === "unknown" && existsSync(join(PKG_ROOT, ".git"))) {
|
|
1580
|
+
installMode = "git-local";
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
info(`검색: ${installMode === "plugin" ? "플러그인" : installMode === "npm-global" ? "npm global" : installMode === "npm-local" ? "npm local" : installMode === "git-local" ? "git 로컬 저장소" : "알 수 없음"} 설치 감지`);
|
|
1584
|
+
|
|
1585
|
+
// 2. 설치 방식에 따라 업데이트
|
|
1586
|
+
const oldVer = PKG.version;
|
|
1587
|
+
let updated = false;
|
|
1588
|
+
let stoppedHubInfo = null;
|
|
1589
|
+
|
|
1590
|
+
try {
|
|
1591
|
+
switch (installMode) {
|
|
1592
|
+
case "plugin": {
|
|
1593
|
+
const gitDir = pluginPath || PKG_ROOT;
|
|
1594
|
+
const result = execSync("git pull", {
|
|
1595
|
+
encoding: "utf8",
|
|
1596
|
+
timeout: 30000,
|
|
1597
|
+
cwd: gitDir,
|
|
1598
|
+
windowsHide: true,
|
|
1599
|
+
}).trim();
|
|
1600
|
+
ok(`git pull — ${result}`);
|
|
1601
|
+
updated = true;
|
|
1602
|
+
break;
|
|
1603
|
+
}
|
|
1604
|
+
case "npm-global": {
|
|
1605
|
+
stoppedHubInfo = stopHubForUpdate();
|
|
1606
|
+
if (stoppedHubInfo?.pid) {
|
|
1607
|
+
info(`실행 중 hub 정지 (PID ${stoppedHubInfo.pid})`);
|
|
1608
|
+
}
|
|
1609
|
+
const npmCmd = isDev ? "npm install -g triflux@dev" : "npm install -g triflux@latest";
|
|
1610
|
+
let result;
|
|
1611
|
+
try {
|
|
1612
|
+
result = execSync(npmCmd, {
|
|
1613
|
+
encoding: "utf8",
|
|
1614
|
+
timeout: 90000,
|
|
1615
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1616
|
+
windowsHide: true,
|
|
1617
|
+
}).trim().split(/\r?\n/)[0];
|
|
1618
|
+
} catch (retryErr) {
|
|
1619
|
+
// Windows: 자기 자신의 파일 잠금으로 첫 시도 실패 가능 → 1회 재시도
|
|
1620
|
+
info("첫 시도 실패, 재시도 중...");
|
|
1621
|
+
result = execSync(npmCmd, {
|
|
1622
|
+
encoding: "utf8",
|
|
1623
|
+
timeout: 90000,
|
|
1624
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1625
|
+
windowsHide: true,
|
|
1626
|
+
}).trim().split(/\r?\n/)[0];
|
|
1627
|
+
}
|
|
1628
|
+
ok(`${npmCmd} — ${result || "완료"}`);
|
|
1629
|
+
updated = true;
|
|
1630
|
+
break;
|
|
1631
|
+
}
|
|
1632
|
+
case "npm-local": {
|
|
1633
|
+
const npmLocalCmd = isDev ? "npm install triflux@dev" : "npm update triflux";
|
|
1634
|
+
const result = execSync(npmLocalCmd, {
|
|
1635
|
+
encoding: "utf8",
|
|
1636
|
+
timeout: 60000,
|
|
1637
|
+
cwd: process.cwd(),
|
|
1638
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1639
|
+
windowsHide: true,
|
|
1640
|
+
}).trim().split(/\r?\n/)[0];
|
|
1641
|
+
ok(`${isDev ? "npm install triflux@dev" : "npm update triflux"} — ${result || "완료"}`);
|
|
1642
|
+
updated = true;
|
|
1643
|
+
break;
|
|
1644
|
+
}
|
|
1645
|
+
case "git-local": {
|
|
1646
|
+
const result = execSync("git pull", {
|
|
1647
|
+
encoding: "utf8",
|
|
1648
|
+
timeout: 30000,
|
|
1649
|
+
cwd: PKG_ROOT,
|
|
1650
|
+
windowsHide: true,
|
|
1651
|
+
}).trim();
|
|
1652
|
+
ok(`git pull — ${result}`);
|
|
1653
|
+
updated = true;
|
|
1654
|
+
break;
|
|
1655
|
+
}
|
|
1656
|
+
default:
|
|
1657
|
+
fail("설치 방식을 감지할 수 없음");
|
|
1658
|
+
info("수동 업데이트: cd <triflux-dir> && git pull");
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
} catch (e) {
|
|
1662
|
+
if (stoppedHubInfo && startHubAfterUpdate(stoppedHubInfo)) {
|
|
1663
|
+
info("업데이트 실패 후 hub 재기동 시도");
|
|
1664
|
+
}
|
|
1665
|
+
const stderr = e.stderr?.toString().trim();
|
|
1666
|
+
fail(`업데이트 실패: ${e.message}${stderr ? `\n ${stderr.split(/\r?\n/)[0]}` : ""}`);
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
// 3. setup 재실행 (tfx-route.sh, HUD, 스킬 동기화)
|
|
1671
|
+
if (updated) {
|
|
1672
|
+
console.log("");
|
|
1673
|
+
// 업데이트 후 새 버전 읽기
|
|
1674
|
+
let newVer = oldVer;
|
|
1675
|
+
try {
|
|
1676
|
+
const newPkg = JSON.parse(readFileSync(join(PKG_ROOT, "package.json"), "utf8"));
|
|
1677
|
+
newVer = newPkg.version;
|
|
1678
|
+
} catch {}
|
|
1679
|
+
|
|
1680
|
+
if (newVer !== oldVer) {
|
|
1681
|
+
ok(`버전: v${oldVer} → v${newVer}`);
|
|
1682
|
+
} else {
|
|
1683
|
+
ok(`버전: v${oldVer} (이미 최신)`);
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
// setup 재실행
|
|
1687
|
+
console.log("");
|
|
1688
|
+
info("setup 재실행 중...");
|
|
1689
|
+
cmdSetup();
|
|
1690
|
+
|
|
1691
|
+
if (stoppedHubInfo) {
|
|
1692
|
+
if (startHubAfterUpdate(stoppedHubInfo)) info("hub 재기동 완료");
|
|
1693
|
+
else warn("hub 재기동 실패 — `tfx hub start`로 수동 시작 필요");
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
console.log(`${GREEN}${BOLD}업데이트 완료${RESET}\n`);
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
function cmdList(options = {}) {
|
|
1701
|
+
const { json = false } = options;
|
|
1702
|
+
const pluginSkills = join(PKG_ROOT, "skills");
|
|
1703
|
+
const installedSkills = join(CLAUDE_DIR, "skills");
|
|
1704
|
+
const packageSkills = [];
|
|
1705
|
+
const userSkills = [];
|
|
1706
|
+
|
|
1707
|
+
if (existsSync(pluginSkills)) {
|
|
1708
|
+
for (const name of readdirSync(pluginSkills).sort()) {
|
|
1709
|
+
const src = join(pluginSkills, name, "SKILL.md");
|
|
1710
|
+
if (!existsSync(src)) continue;
|
|
1711
|
+
const dst = join(installedSkills, name, "SKILL.md");
|
|
1712
|
+
packageSkills.push({ name, installed: existsSync(dst) });
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
const pkgNames = new Set(existsSync(pluginSkills) ? readdirSync(pluginSkills) : []);
|
|
1717
|
+
if (existsSync(installedSkills)) {
|
|
1718
|
+
for (const name of readdirSync(installedSkills).sort()) {
|
|
1719
|
+
if (pkgNames.has(name)) continue;
|
|
1720
|
+
const skill = join(installedSkills, name, "SKILL.md");
|
|
1721
|
+
if (!existsSync(skill)) continue;
|
|
1722
|
+
userSkills.push(name);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
if (json) {
|
|
1727
|
+
printJson({
|
|
1728
|
+
package_skills: packageSkills,
|
|
1729
|
+
user_skills: userSkills,
|
|
1730
|
+
install_path: installedSkills,
|
|
1731
|
+
});
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
console.log(`\n ${AMBER}${BOLD}⬡ triflux list${RESET} ${VER}\n`);
|
|
1736
|
+
console.log(` ${LINE}`);
|
|
1737
|
+
|
|
1738
|
+
section("패키지 스킬");
|
|
1739
|
+
for (const skill of packageSkills) {
|
|
1740
|
+
if (skill.installed) {
|
|
1741
|
+
console.log(` ${GREEN_BRIGHT}✓${RESET} ${BOLD}${skill.name}${RESET}`);
|
|
1742
|
+
} else {
|
|
1743
|
+
console.log(` ${RED_BRIGHT}✗${RESET} ${DIM}${skill.name}${RESET} ${GRAY}(미설치)${RESET}`);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
section("사용자 스킬");
|
|
1748
|
+
for (const name of userSkills) {
|
|
1749
|
+
console.log(` ${AMBER}◆${RESET} ${name}`);
|
|
1750
|
+
}
|
|
1751
|
+
if (userSkills.length === 0) console.log(` ${GRAY}없음${RESET}`);
|
|
1752
|
+
|
|
1753
|
+
console.log(`\n ${LINE}`);
|
|
1754
|
+
console.log(` ${GRAY}${installedSkills}${RESET}\n`);
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
function cmdVersion(options = {}) {
|
|
1758
|
+
const { json = false } = options;
|
|
1759
|
+
const routeVer = getVersion(join(CLAUDE_DIR, "scripts", "tfx-route.sh"));
|
|
1760
|
+
const hudVer = getVersion(join(CLAUDE_DIR, "hud", "hud-qos-status.mjs"));
|
|
1761
|
+
if (json) {
|
|
1762
|
+
printJson({
|
|
1763
|
+
triflux: PKG.version,
|
|
1764
|
+
tfx_route: routeVer,
|
|
1765
|
+
hud: hudVer,
|
|
1766
|
+
node: process.versions.node,
|
|
1767
|
+
});
|
|
1768
|
+
return;
|
|
1769
|
+
}
|
|
1770
|
+
console.log(`\n ${AMBER}${BOLD}⬡ triflux${RESET} ${WHITE_BRIGHT}v${PKG.version}${RESET}`);
|
|
1771
|
+
if (routeVer) console.log(` ${GRAY}tfx-route${RESET} v${routeVer}`);
|
|
1772
|
+
if (hudVer) console.log(` ${GRAY}hud${RESET} v${hudVer}`);
|
|
1773
|
+
console.log("");
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
function cmdSchema(args = []) {
|
|
1777
|
+
const bundle = loadDelegatorSchemaBundle();
|
|
1778
|
+
const selector = String(args[0] || "").trim();
|
|
1779
|
+
const toolEntry = Array.isArray(bundle["x-triflux-mcp-tools"])
|
|
1780
|
+
? bundle["x-triflux-mcp-tools"].find((tool) => tool.name === selector)
|
|
1781
|
+
: null;
|
|
1782
|
+
|
|
1783
|
+
if (!selector) {
|
|
1784
|
+
printJson({
|
|
1785
|
+
$schema: bundle.$schema,
|
|
1786
|
+
title: "Triflux CLI Schema Bundle",
|
|
1787
|
+
global_options: [
|
|
1788
|
+
{ name: "--json", type: "boolean", description: "지원 커맨드의 출력을 JSON으로 전환" },
|
|
1789
|
+
],
|
|
1790
|
+
commands: CLI_COMMAND_SCHEMAS,
|
|
1791
|
+
hub_tools: bundle,
|
|
1792
|
+
});
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
if (CLI_COMMAND_SCHEMAS[selector]) {
|
|
1797
|
+
printJson({
|
|
1798
|
+
command: selector,
|
|
1799
|
+
...CLI_COMMAND_SCHEMAS[selector],
|
|
1800
|
+
});
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
if (toolEntry) {
|
|
1805
|
+
printJson({
|
|
1806
|
+
tool: toolEntry.name,
|
|
1807
|
+
description: toolEntry.description,
|
|
1808
|
+
pipeAction: toolEntry.pipeAction,
|
|
1809
|
+
inputSchema: bundle.$defs?.[toolEntry.inputSchemaDef] || null,
|
|
1810
|
+
outputSchema: bundle.$defs?.[toolEntry.outputSchemaDef] || null,
|
|
1811
|
+
});
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
throw createCliError(`알 수 없는 schema 대상: ${selector}`, {
|
|
1816
|
+
exitCode: EXIT_ARG_ERROR,
|
|
1817
|
+
reason: "argError",
|
|
1818
|
+
fix: "tfx schema 또는 tfx schema <command>를 실행해 사용 가능한 대상을 확인하세요.",
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
function checkForUpdate() {
|
|
1823
|
+
const cacheFile = join(CLAUDE_DIR, "cache", "triflux-update-check.json");
|
|
1824
|
+
const cacheDir = dirname(cacheFile);
|
|
1825
|
+
|
|
1826
|
+
// 캐시 확인 (1시간 이내면 캐시 사용)
|
|
1827
|
+
try {
|
|
1828
|
+
if (existsSync(cacheFile)) {
|
|
1829
|
+
const cache = JSON.parse(readFileSync(cacheFile, "utf8"));
|
|
1830
|
+
if (Date.now() - cache.timestamp < 3600000) {
|
|
1831
|
+
return cache.latest !== PKG.version ? cache.latest : null;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
} catch {}
|
|
1835
|
+
|
|
1836
|
+
// npm registry 조회
|
|
1837
|
+
try {
|
|
1838
|
+
const result = execSync("npm view triflux version", {
|
|
1839
|
+
encoding: "utf8",
|
|
1840
|
+
timeout: 5000,
|
|
1841
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1842
|
+
windowsHide: true,
|
|
1843
|
+
}).trim();
|
|
1844
|
+
|
|
1845
|
+
if (!existsSync(cacheDir)) mkdirSync(cacheDir, { recursive: true });
|
|
1846
|
+
writeFileSync(cacheFile, JSON.stringify({ latest: result, timestamp: Date.now() }));
|
|
1847
|
+
|
|
1848
|
+
return result !== PKG.version ? result : null;
|
|
1849
|
+
} catch {
|
|
1850
|
+
return null;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
function cmdHelp() {
|
|
1855
|
+
const latestVer = checkForUpdate();
|
|
1856
|
+
const updateNotice = latestVer
|
|
1857
|
+
? `\n ${YELLOW}${BOLD}↑ v${latestVer} 사용 가능${RESET} ${GRAY}npm update -g triflux${RESET}\n`
|
|
1858
|
+
: "";
|
|
1859
|
+
|
|
1860
|
+
console.log(`
|
|
1861
|
+
${AMBER}${BOLD}⬡ triflux${RESET} ${DIM}v${PKG.version}${RESET}
|
|
1862
|
+
${GRAY}CLI-first multi-model orchestrator for Claude Code${RESET}
|
|
1863
|
+
${updateNotice}
|
|
1864
|
+
${LINE}
|
|
1865
|
+
|
|
1866
|
+
${BOLD}Commands${RESET}
|
|
1867
|
+
|
|
1868
|
+
${WHITE_BRIGHT}tfx setup${RESET} ${GRAY}파일 동기화 + HUD 설정${RESET}
|
|
1869
|
+
${DIM} --dry-run${RESET} ${GRAY}변경 예정 작업을 JSON으로 미리보기${RESET}
|
|
1870
|
+
${WHITE_BRIGHT}tfx doctor${RESET} ${GRAY}CLI 진단 + 이슈 확인${RESET}
|
|
1871
|
+
${DIM} --fix${RESET} ${GRAY}진단 + 자동 수정${RESET}
|
|
1872
|
+
${DIM} --reset${RESET} ${GRAY}캐시 전체 초기화${RESET}
|
|
1873
|
+
${DIM} --json${RESET} ${GRAY}구조화된 진단 결과 JSON 출력${RESET}
|
|
1874
|
+
${WHITE_BRIGHT}tfx update${RESET} ${GRAY}최신 안정 버전으로 업데이트${RESET}
|
|
1875
|
+
${DIM} --dev / dev${RESET} ${GRAY}dev 태그로 업데이트${RESET}
|
|
1876
|
+
${WHITE_BRIGHT}tfx list${RESET} ${GRAY}설치된 스킬 목록${RESET}
|
|
1877
|
+
${WHITE_BRIGHT}tfx schema${RESET} ${GRAY}CLI/Hub schema JSON 출력${RESET}
|
|
1878
|
+
${WHITE_BRIGHT}tfx hub${RESET} ${GRAY}MCP 메시지 버스 관리 (start/stop/status)${RESET}
|
|
1879
|
+
${WHITE_BRIGHT}tfx tray${RESET} ${GRAY}Windows 시스템 트레이 실행${RESET}
|
|
1880
|
+
${DIM} --detach${RESET} ${GRAY}백그라운드 트레이 프로세스로 분리${RESET}
|
|
1881
|
+
${WHITE_BRIGHT}tfx multi${RESET} ${GRAY}멀티-CLI 팀 모드 (tmux + Hub)${RESET}
|
|
1882
|
+
${WHITE_BRIGHT}tfx codex-team${RESET} ${GRAY}Codex 전용 팀 모드 (기본 lead/agents: codex)${RESET}
|
|
1883
|
+
${WHITE_BRIGHT}tfx notion-read${RESET} ${GRAY}Notion 페이지 → 마크다운 (Codex/Gemini MCP)${RESET}
|
|
1884
|
+
${WHITE_BRIGHT}tfx version${RESET} ${GRAY}버전 표시${RESET}
|
|
1885
|
+
|
|
1886
|
+
${BOLD}Skills${RESET} ${GRAY}(Claude Code 슬래시 커맨드)${RESET}
|
|
1887
|
+
|
|
1888
|
+
${AMBER}/tfx-auto${RESET} ${GRAY}자동 분류 + 병렬 실행${RESET}
|
|
1889
|
+
${WHITE_BRIGHT}/tfx-auto-codex${RESET} ${GRAY}Codex 리드 + Gemini 유지 (no-Claude-native)${RESET}
|
|
1890
|
+
${WHITE_BRIGHT}/tfx-codex${RESET} ${GRAY}Codex 전용 모드${RESET}
|
|
1891
|
+
${BLUE}/tfx-gemini${RESET} ${GRAY}Gemini 전용 모드${RESET}
|
|
1892
|
+
${AMBER}/tfx-setup${RESET} ${GRAY}HUD 설정 + 진단${RESET}
|
|
1893
|
+
${YELLOW}/tfx-doctor${RESET} ${GRAY}진단 + 수리 + 캐시 초기화${RESET}
|
|
1894
|
+
|
|
1895
|
+
${LINE}
|
|
1896
|
+
${GRAY}github.com/tellang/triflux${RESET}
|
|
1897
|
+
`);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
async function cmdCodexTeam(args = []) {
|
|
1901
|
+
const sub = String(args[0] || "").toLowerCase();
|
|
1902
|
+
const passthrough = new Set([
|
|
1903
|
+
"status", "attach", "stop", "kill", "send", "list", "help", "--help", "-h",
|
|
1904
|
+
"tasks", "task", "focus", "interrupt", "control", "debug",
|
|
1905
|
+
]);
|
|
1906
|
+
|
|
1907
|
+
if (sub === "help" || sub === "--help" || sub === "-h") {
|
|
1908
|
+
console.log(`
|
|
1909
|
+
${AMBER}${BOLD}⬡ tfx codex-team${RESET}
|
|
1910
|
+
|
|
1911
|
+
${WHITE_BRIGHT}tfx codex-team "작업"${RESET} ${GRAY}Codex 리드 + 워커 2개로 팀 시작${RESET}
|
|
1912
|
+
${WHITE_BRIGHT}tfx codex-team --layout 1xN "작업"${RESET} ${GRAY}(세로 분할 컬럼)${RESET}
|
|
1913
|
+
${WHITE_BRIGHT}tfx codex-team --layout Nx1 "작업"${RESET} ${GRAY}(가로 분할 스택)${RESET}
|
|
1914
|
+
${WHITE_BRIGHT}tfx codex-team status${RESET}
|
|
1915
|
+
${WHITE_BRIGHT}tfx codex-team debug --lines 30${RESET}
|
|
1916
|
+
${WHITE_BRIGHT}tfx codex-team send N "msg"${RESET}
|
|
1917
|
+
|
|
1918
|
+
${DIM}내부적으로 tfx multi을 호출하며, 시작 시 --lead codex --agents codex,codex를 기본 주입합니다.${RESET}
|
|
1919
|
+
`);
|
|
1920
|
+
return;
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
const hasAgents = args.includes("--agents");
|
|
1924
|
+
const hasLead = args.includes("--lead");
|
|
1925
|
+
const hasLayout = args.includes("--layout");
|
|
1926
|
+
const isControl = passthrough.has(sub);
|
|
1927
|
+
const normalizedArgs = isControl && args.length ? [sub, ...args.slice(1)] : args;
|
|
1928
|
+
const inject = [];
|
|
1929
|
+
if (!isControl && !hasLead) inject.push("--lead", "codex");
|
|
1930
|
+
if (!isControl && !hasAgents) inject.push("--agents", "codex,codex");
|
|
1931
|
+
if (!isControl && !hasLayout) inject.push("--layout", "1xN");
|
|
1932
|
+
const forwarded = isControl ? normalizedArgs : [...inject, ...args];
|
|
1933
|
+
|
|
1934
|
+
const prevArgv = process.argv;
|
|
1935
|
+
const prevProfile = process.env.TFX_TEAM_PROFILE;
|
|
1936
|
+
process.env.TFX_TEAM_PROFILE = "codex-team";
|
|
1937
|
+
const { pathToFileURL } = await import("node:url");
|
|
1938
|
+
const { cmdTeam } = await import(pathToFileURL(join(PKG_ROOT, "hub", "team", "cli", "index.mjs")).href);
|
|
1939
|
+
process.argv = [prevArgv[0], prevArgv[1], "team", ...forwarded];
|
|
1940
|
+
try {
|
|
1941
|
+
await cmdTeam();
|
|
1942
|
+
} finally {
|
|
1943
|
+
process.argv = prevArgv;
|
|
1944
|
+
if (typeof prevProfile === "string") process.env.TFX_TEAM_PROFILE = prevProfile;
|
|
1945
|
+
else delete process.env.TFX_TEAM_PROFILE;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
// ── Hub preflight 체크 (multi/auto 실행 전) ──
|
|
1950
|
+
|
|
1951
|
+
async function checkHubRunning() {
|
|
1952
|
+
const port = Number(process.env.TFX_HUB_PORT || "27888");
|
|
1953
|
+
try {
|
|
1954
|
+
const res = await fetch(`http://127.0.0.1:${port}/status`, {
|
|
1955
|
+
signal: AbortSignal.timeout(2000),
|
|
1956
|
+
});
|
|
1957
|
+
if (res.ok) return true;
|
|
1958
|
+
} catch {}
|
|
1959
|
+
console.log("");
|
|
1960
|
+
warn(`${AMBER}tfx-hub${RESET}가 실행되고 있지 않습니다.`);
|
|
1961
|
+
info(`Hub 없이 실행하면 Claude 네이티브 에이전트로 폴백되어 토큰이 소비됩니다.`);
|
|
1962
|
+
info(`Codex(무료) 위임을 활용하려면 먼저 Hub를 시작하세요:\n`);
|
|
1963
|
+
console.log(` ${WHITE_BRIGHT}tfx hub start${RESET}\n`);
|
|
1964
|
+
return false;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
// ── hub 서브커맨드 ──
|
|
1968
|
+
|
|
1969
|
+
const HUB_PID_DIR = join(homedir(), ".claude", "cache", "tfx-hub");
|
|
1970
|
+
const HUB_PID_FILE = join(HUB_PID_DIR, "hub.pid");
|
|
1971
|
+
|
|
1972
|
+
function sleepMs(ms) {
|
|
1973
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
function stopHubForUpdate() {
|
|
1977
|
+
if (!existsSync(HUB_PID_FILE)) return null;
|
|
1978
|
+
let info = null;
|
|
1979
|
+
try {
|
|
1980
|
+
info = JSON.parse(readFileSync(HUB_PID_FILE, "utf8"));
|
|
1981
|
+
process.kill(info.pid, 0);
|
|
1982
|
+
} catch {
|
|
1983
|
+
try { unlinkSync(HUB_PID_FILE); } catch {}
|
|
1984
|
+
return null;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
try {
|
|
1988
|
+
if (process.platform === "win32") {
|
|
1989
|
+
execFileSync("taskkill", ["/PID", String(info.pid), "/T", "/F"], {
|
|
1990
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1991
|
+
timeout: 10000,
|
|
1992
|
+
windowsHide: true,
|
|
1993
|
+
});
|
|
1994
|
+
} else {
|
|
1995
|
+
process.kill(info.pid, "SIGTERM");
|
|
1996
|
+
}
|
|
1997
|
+
} catch {
|
|
1998
|
+
try { process.kill(info.pid, "SIGKILL"); } catch {}
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
// Windows에서 better-sqlite3.node 파일 핸들 해제 대기
|
|
2002
|
+
// taskkill 후 프로세스 종료 + 파일 핸들 해제까지 최대 5초
|
|
2003
|
+
const sqliteNode = join(PKG_ROOT, "node_modules", "better-sqlite3", "build", "Release", "better_sqlite3.node");
|
|
2004
|
+
for (let i = 0; i < 10; i++) {
|
|
2005
|
+
sleepMs(500);
|
|
2006
|
+
try { process.kill(info.pid, 0); } catch { break; }
|
|
2007
|
+
}
|
|
2008
|
+
// 파일 잠금 해제 확인 (Windows EBUSY 방지)
|
|
2009
|
+
if (existsSync(sqliteNode)) {
|
|
2010
|
+
for (let i = 0; i < 6; i++) {
|
|
2011
|
+
try {
|
|
2012
|
+
const fd = openSync(sqliteNode, "r");
|
|
2013
|
+
closeSync(fd);
|
|
2014
|
+
break;
|
|
2015
|
+
} catch {
|
|
2016
|
+
sleepMs(500);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
try { unlinkSync(HUB_PID_FILE); } catch {}
|
|
2021
|
+
return info;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
function startHubAfterUpdate(info) {
|
|
2025
|
+
if (!info) return false;
|
|
2026
|
+
const serverPath = join(PKG_ROOT, "hub", "server.mjs");
|
|
2027
|
+
if (!existsSync(serverPath)) return false;
|
|
2028
|
+
const port = Number(info?.port) > 0 ? String(info.port) : String(process.env.TFX_HUB_PORT || "27888");
|
|
2029
|
+
|
|
2030
|
+
try {
|
|
2031
|
+
const child = spawn(process.execPath, [serverPath], {
|
|
2032
|
+
env: { ...process.env, TFX_HUB_PORT: port },
|
|
2033
|
+
stdio: "ignore",
|
|
2034
|
+
detached: true,
|
|
2035
|
+
windowsHide: true,
|
|
2036
|
+
});
|
|
2037
|
+
child.unref();
|
|
2038
|
+
return true;
|
|
2039
|
+
} catch {
|
|
2040
|
+
return false;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
// 설치된 CLI에 tfx-hub MCP 서버 자동 등록 (1회 설정, 이후 재실행 불필요)
|
|
2045
|
+
function autoRegisterMcp(mcpUrl) {
|
|
2046
|
+
section("MCP 자동 등록");
|
|
2047
|
+
|
|
2048
|
+
// Codex — codex mcp add
|
|
2049
|
+
if (which("codex")) {
|
|
2050
|
+
try {
|
|
2051
|
+
// 이미 등록됐는지 확인
|
|
2052
|
+
const list = execSync("codex mcp list 2>&1", { encoding: "utf8", timeout: 10000, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
|
|
2053
|
+
if (list.includes("tfx-hub")) {
|
|
2054
|
+
ok("Codex: 이미 등록됨");
|
|
2055
|
+
} else {
|
|
2056
|
+
execFileSync("codex", ["mcp", "add", "tfx-hub", "--url", mcpUrl], { timeout: 10000, stdio: "ignore", windowsHide: true });
|
|
2057
|
+
ok("Codex: MCP 등록 완료");
|
|
2058
|
+
}
|
|
2059
|
+
} catch {
|
|
2060
|
+
// mcp list/add 미지원 → 설정 파일 직접 수정
|
|
2061
|
+
try {
|
|
2062
|
+
const codexDir = join(homedir(), ".codex");
|
|
2063
|
+
const configFile = join(codexDir, "config.json");
|
|
2064
|
+
let config = {};
|
|
2065
|
+
if (existsSync(configFile)) config = JSON.parse(readFileSync(configFile, "utf8"));
|
|
2066
|
+
if (!config.mcpServers) config.mcpServers = {};
|
|
2067
|
+
if (!config.mcpServers["tfx-hub"]) {
|
|
2068
|
+
config.mcpServers["tfx-hub"] = { url: mcpUrl };
|
|
2069
|
+
if (!existsSync(codexDir)) mkdirSync(codexDir, { recursive: true });
|
|
2070
|
+
writeFileSync(configFile, JSON.stringify(config, null, 2) + "\n");
|
|
2071
|
+
ok("Codex: config.json에 등록 완료");
|
|
2072
|
+
} else {
|
|
2073
|
+
ok("Codex: 이미 등록됨");
|
|
2074
|
+
}
|
|
2075
|
+
} catch (e) { warn(`Codex 등록 실패: ${e.message}`); }
|
|
2076
|
+
}
|
|
2077
|
+
} else {
|
|
2078
|
+
info("Codex: 미설치 (건너뜀)");
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
// Gemini — settings.json 직접 수정
|
|
2082
|
+
if (which("gemini")) {
|
|
2083
|
+
try {
|
|
2084
|
+
const geminiDir = join(homedir(), ".gemini");
|
|
2085
|
+
const settingsFile = join(geminiDir, "settings.json");
|
|
2086
|
+
let settings = {};
|
|
2087
|
+
if (existsSync(settingsFile)) settings = JSON.parse(readFileSync(settingsFile, "utf8"));
|
|
2088
|
+
if (!settings.mcpServers) settings.mcpServers = {};
|
|
2089
|
+
if (!settings.mcpServers["tfx-hub"]) {
|
|
2090
|
+
settings.mcpServers["tfx-hub"] = { url: mcpUrl };
|
|
2091
|
+
if (!existsSync(geminiDir)) mkdirSync(geminiDir, { recursive: true });
|
|
2092
|
+
writeFileSync(settingsFile, JSON.stringify(settings, null, 2) + "\n");
|
|
2093
|
+
ok("Gemini: settings.json에 등록 완료");
|
|
2094
|
+
} else {
|
|
2095
|
+
ok("Gemini: 이미 등록됨");
|
|
2096
|
+
}
|
|
2097
|
+
} catch (e) { warn(`Gemini 등록 실패: ${e.message}`); }
|
|
2098
|
+
} else {
|
|
2099
|
+
info("Gemini: 미설치 (건너뜀)");
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
// Claude — 프로젝트 .mcp.json에 등록 (오케스트레이터용)
|
|
2103
|
+
try {
|
|
2104
|
+
const mcpJsonPath = join(PKG_ROOT, ".mcp.json");
|
|
2105
|
+
let mcpJson = {};
|
|
2106
|
+
if (existsSync(mcpJsonPath)) mcpJson = JSON.parse(readFileSync(mcpJsonPath, "utf8"));
|
|
2107
|
+
if (!mcpJson.mcpServers) mcpJson.mcpServers = {};
|
|
2108
|
+
if (!mcpJson.mcpServers["tfx-hub"]) {
|
|
2109
|
+
mcpJson.mcpServers["tfx-hub"] = { type: "url", url: mcpUrl };
|
|
2110
|
+
writeFileSync(mcpJsonPath, JSON.stringify(mcpJson, null, 2) + "\n");
|
|
2111
|
+
ok("Claude: .mcp.json에 등록 완료");
|
|
2112
|
+
} else {
|
|
2113
|
+
ok("Claude: 이미 등록됨");
|
|
2114
|
+
}
|
|
2115
|
+
} catch (e) { warn(`Claude 등록 실패: ${e.message}`); }
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
async function cmdHub(args = [], options = {}) {
|
|
2119
|
+
const { json = false } = options;
|
|
2120
|
+
const sub = args[0] || "status";
|
|
2121
|
+
const defaultPortRaw = Number(process.env.TFX_HUB_PORT || "27888");
|
|
2122
|
+
const probePort = Number.isFinite(defaultPortRaw) && defaultPortRaw > 0 ? defaultPortRaw : 27888;
|
|
2123
|
+
const formatHostForUrl = (host) => host.includes(":") ? `[${host}]` : host;
|
|
2124
|
+
const probeHubStatus = async (host = "127.0.0.1", port = probePort, timeoutMs = 3000) => {
|
|
2125
|
+
try {
|
|
2126
|
+
const res = await fetch(`http://${formatHostForUrl(host)}:${port}/status`, {
|
|
2127
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
2128
|
+
});
|
|
2129
|
+
if (!res.ok) return null;
|
|
2130
|
+
const data = await res.json();
|
|
2131
|
+
return data?.hub ? data : null;
|
|
2132
|
+
} catch {
|
|
2133
|
+
return null;
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
const recoverPidFile = (statusData, defaultHost = "127.0.0.1") => {
|
|
2137
|
+
const pid = Number(statusData?.pid);
|
|
2138
|
+
const port = Number(statusData?.port) || probePort;
|
|
2139
|
+
if (!Number.isFinite(pid) || pid <= 0) return;
|
|
2140
|
+
try {
|
|
2141
|
+
mkdirSync(HUB_PID_DIR, { recursive: true });
|
|
2142
|
+
writeFileSync(HUB_PID_FILE, JSON.stringify({
|
|
2143
|
+
pid,
|
|
2144
|
+
port,
|
|
2145
|
+
host: defaultHost,
|
|
2146
|
+
url: `http://${formatHostForUrl(defaultHost)}:${port}/mcp`,
|
|
2147
|
+
started: Date.now(),
|
|
2148
|
+
}));
|
|
2149
|
+
} catch {}
|
|
2150
|
+
};
|
|
2151
|
+
const emitHubStatus = (payload) => {
|
|
2152
|
+
if (!json) return false;
|
|
2153
|
+
printJson(payload);
|
|
2154
|
+
return true;
|
|
2155
|
+
};
|
|
2156
|
+
|
|
2157
|
+
switch (sub) {
|
|
2158
|
+
case "start": {
|
|
2159
|
+
// 이미 실행 중인지 확인
|
|
2160
|
+
if (existsSync(HUB_PID_FILE)) {
|
|
2161
|
+
try {
|
|
2162
|
+
const info = JSON.parse(readFileSync(HUB_PID_FILE, "utf8"));
|
|
2163
|
+
process.kill(info.pid, 0); // 프로세스 존재 확인
|
|
2164
|
+
console.log(`\n ${YELLOW}⚠${RESET} hub 이미 실행 중 (PID ${info.pid}, ${info.url})\n`);
|
|
2165
|
+
return;
|
|
2166
|
+
} catch {
|
|
2167
|
+
// PID 파일 있지만 프로세스 없음 — 정리
|
|
2168
|
+
try { unlinkSync(HUB_PID_FILE); } catch {}
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
const portArg = args.indexOf("--port");
|
|
2173
|
+
const port = portArg !== -1 ? args[portArg + 1] : "27888";
|
|
2174
|
+
const serverPath = join(PKG_ROOT, "hub", "server.mjs");
|
|
2175
|
+
|
|
2176
|
+
if (!existsSync(serverPath)) {
|
|
2177
|
+
throw createCliError("hub/server.mjs 없음 — hub 모듈이 설치되지 않음", {
|
|
2178
|
+
exitCode: EXIT_HUB_ERROR,
|
|
2179
|
+
reason: "hubError",
|
|
2180
|
+
fix: "hub 모듈이 포함된 triflux 설치본인지 확인한 뒤 다시 실행하세요.",
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
const child = spawn(process.execPath, [serverPath], {
|
|
2185
|
+
env: { ...process.env, TFX_HUB_PORT: port },
|
|
2186
|
+
stdio: "ignore",
|
|
2187
|
+
detached: true,
|
|
2188
|
+
windowsHide: true,
|
|
2189
|
+
});
|
|
2190
|
+
child.unref();
|
|
2191
|
+
|
|
2192
|
+
// PID 파일 확인 (최대 3초 대기, 100ms 폴링)
|
|
2193
|
+
let started = false;
|
|
2194
|
+
const deadline = Date.now() + 3000;
|
|
2195
|
+
while (Date.now() < deadline) {
|
|
2196
|
+
if (existsSync(HUB_PID_FILE)) { started = true; break; }
|
|
2197
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
if (started) {
|
|
2201
|
+
const hubInfo = JSON.parse(readFileSync(HUB_PID_FILE, "utf8"));
|
|
2202
|
+
console.log(`\n ${GREEN_BRIGHT}✓${RESET} ${BOLD}tfx-hub 시작${RESET}`);
|
|
2203
|
+
console.log(` URL: ${AMBER}${hubInfo.url}${RESET}`);
|
|
2204
|
+
console.log(` PID: ${hubInfo.pid}`);
|
|
2205
|
+
console.log(` DB: ${DIM}${getPipelineStateDbPath(PKG_ROOT)}${RESET}`);
|
|
2206
|
+
console.log("");
|
|
2207
|
+
autoRegisterMcp(hubInfo.url);
|
|
2208
|
+
console.log("");
|
|
2209
|
+
} else {
|
|
2210
|
+
// 직접 포그라운드 모드로 안내
|
|
2211
|
+
console.log(`\n ${YELLOW}⚠${RESET} 백그라운드 시작 실패 — 포그라운드로 실행:`);
|
|
2212
|
+
console.log(` ${DIM}TFX_HUB_PORT=${port} node ${serverPath}${RESET}\n`);
|
|
2213
|
+
}
|
|
2214
|
+
break;
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
case "stop": {
|
|
2218
|
+
if (!existsSync(HUB_PID_FILE)) {
|
|
2219
|
+
const probed = await probeHubStatus("127.0.0.1", probePort, 1500)
|
|
2220
|
+
|| (probePort === 27888 ? null : await probeHubStatus("127.0.0.1", 27888, 1500));
|
|
2221
|
+
if (probed && Number.isFinite(Number(probed.pid))) {
|
|
2222
|
+
try {
|
|
2223
|
+
process.kill(Number(probed.pid), "SIGTERM");
|
|
2224
|
+
console.log(`\n ${GREEN_BRIGHT}✓${RESET} hub 종료됨 (PID ${probed.pid})${DIM} (probe)${RESET}\n`);
|
|
2225
|
+
return;
|
|
2226
|
+
} catch {}
|
|
2227
|
+
}
|
|
2228
|
+
console.log(`\n ${DIM}hub 미실행${RESET}\n`);
|
|
2229
|
+
return;
|
|
2230
|
+
}
|
|
2231
|
+
try {
|
|
2232
|
+
const info = JSON.parse(readFileSync(HUB_PID_FILE, "utf8"));
|
|
2233
|
+
process.kill(info.pid, "SIGTERM");
|
|
2234
|
+
try { unlinkSync(HUB_PID_FILE); } catch {}
|
|
2235
|
+
console.log(`\n ${GREEN_BRIGHT}✓${RESET} hub 종료됨 (PID ${info.pid})\n`);
|
|
2236
|
+
} catch (e) {
|
|
2237
|
+
try { unlinkSync(HUB_PID_FILE); } catch {}
|
|
2238
|
+
console.log(`\n ${DIM}hub 프로세스 없음 — PID 파일 정리됨${RESET}\n`);
|
|
2239
|
+
}
|
|
2240
|
+
break;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
case "status": {
|
|
2244
|
+
if (!existsSync(HUB_PID_FILE)) {
|
|
2245
|
+
const probed = await probeHubStatus();
|
|
2246
|
+
if (!probed) {
|
|
2247
|
+
const fallback = probePort === 27888 ? null : await probeHubStatus("127.0.0.1", 27888, 1500);
|
|
2248
|
+
if (fallback) {
|
|
2249
|
+
recoverPidFile(fallback, "127.0.0.1");
|
|
2250
|
+
if (emitHubStatus({
|
|
2251
|
+
status: "online",
|
|
2252
|
+
source: "default-port-probe",
|
|
2253
|
+
url: `http://127.0.0.1:${fallback.port || 27888}/mcp`,
|
|
2254
|
+
pid: fallback.pid,
|
|
2255
|
+
state: fallback.hub?.state || null,
|
|
2256
|
+
sessions: fallback.sessions,
|
|
2257
|
+
})) return;
|
|
2258
|
+
console.log(`\n ${AMBER}${BOLD}⬡ tfx-hub${RESET} ${GREEN_BRIGHT}online${RESET} ${DIM}(default port probe 성공)${RESET}`);
|
|
2259
|
+
console.log(` URL: http://127.0.0.1:${fallback.port || 27888}/mcp`);
|
|
2260
|
+
if (fallback.pid !== undefined) console.log(` PID: ${fallback.pid}`);
|
|
2261
|
+
if (fallback.hub?.state) console.log(` State: ${fallback.hub.state}`);
|
|
2262
|
+
if (fallback.sessions !== undefined) console.log(` Sessions: ${fallback.sessions}`);
|
|
2263
|
+
console.log("");
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
if (emitHubStatus({ status: "offline", source: "probe", url: null, pid: null, state: null, sessions: 0 })) return;
|
|
2267
|
+
console.log(`\n ${AMBER}${BOLD}⬡ tfx-hub${RESET} ${RED}offline${RESET}\n`);
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
recoverPidFile(probed, "127.0.0.1");
|
|
2271
|
+
if (emitHubStatus({
|
|
2272
|
+
status: "online",
|
|
2273
|
+
source: "probe",
|
|
2274
|
+
url: `http://127.0.0.1:${probed.port || probePort}/mcp`,
|
|
2275
|
+
pid: probed.pid,
|
|
2276
|
+
state: probed.hub?.state || null,
|
|
2277
|
+
sessions: probed.sessions,
|
|
2278
|
+
})) return;
|
|
2279
|
+
console.log(`\n ${AMBER}${BOLD}⬡ tfx-hub${RESET} ${GREEN_BRIGHT}online${RESET} ${DIM}(pid file 없음 / probe 성공)${RESET}`);
|
|
2280
|
+
console.log(` URL: http://127.0.0.1:${probed.port || probePort}/mcp`);
|
|
2281
|
+
if (probed.pid !== undefined) console.log(` PID: ${probed.pid}`);
|
|
2282
|
+
if (probed.hub?.state) console.log(` State: ${probed.hub.state}`);
|
|
2283
|
+
if (probed.sessions !== undefined) console.log(` Sessions: ${probed.sessions}`);
|
|
2284
|
+
console.log("");
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
try {
|
|
2288
|
+
const info = JSON.parse(readFileSync(HUB_PID_FILE, "utf8"));
|
|
2289
|
+
process.kill(info.pid, 0); // 생존 확인
|
|
2290
|
+
const uptime = Date.now() - info.started;
|
|
2291
|
+
const uptimeStr = uptime < 60000 ? `${Math.round(uptime / 1000)}초`
|
|
2292
|
+
: uptime < 3600000 ? `${Math.round(uptime / 60000)}분`
|
|
2293
|
+
: `${Math.round(uptime / 3600000)}시간`;
|
|
2294
|
+
|
|
2295
|
+
let data = null;
|
|
2296
|
+
try {
|
|
2297
|
+
const host = typeof info.host === "string" ? info.host : "127.0.0.1";
|
|
2298
|
+
const port = Number(info.port) || probePort;
|
|
2299
|
+
data = await probeHubStatus(host, port, 3000);
|
|
2300
|
+
} catch {}
|
|
2301
|
+
|
|
2302
|
+
if (emitHubStatus({
|
|
2303
|
+
status: "online",
|
|
2304
|
+
source: "pid-file",
|
|
2305
|
+
url: info.url,
|
|
2306
|
+
pid: info.pid,
|
|
2307
|
+
uptime_ms: uptime,
|
|
2308
|
+
state: data?.hub?.state || null,
|
|
2309
|
+
sessions: data?.sessions,
|
|
2310
|
+
})) return;
|
|
2311
|
+
console.log(`\n ${AMBER}${BOLD}⬡ tfx-hub${RESET} ${GREEN_BRIGHT}online${RESET}`);
|
|
2312
|
+
console.log(` URL: ${info.url}`);
|
|
2313
|
+
console.log(` PID: ${info.pid}`);
|
|
2314
|
+
console.log(` Uptime: ${uptimeStr}`);
|
|
2315
|
+
if (data?.hub) {
|
|
2316
|
+
console.log(` State: ${data.hub.state}`);
|
|
2317
|
+
}
|
|
2318
|
+
if (data?.sessions !== undefined) {
|
|
2319
|
+
console.log(` Sessions: ${data.sessions}`);
|
|
2320
|
+
}
|
|
2321
|
+
console.log("");
|
|
2322
|
+
} catch {
|
|
2323
|
+
try { unlinkSync(HUB_PID_FILE); } catch {}
|
|
2324
|
+
const probed = await probeHubStatus();
|
|
2325
|
+
if (!probed) {
|
|
2326
|
+
if (emitHubStatus({ status: "offline", source: "stale-pid", url: null, pid: null, state: null, sessions: 0 })) break;
|
|
2327
|
+
console.log(`\n ${AMBER}${BOLD}⬡ tfx-hub${RESET} ${RED}offline${RESET} ${DIM}(stale PID 정리됨)${RESET}\n`);
|
|
2328
|
+
break;
|
|
2329
|
+
}
|
|
2330
|
+
recoverPidFile(probed, "127.0.0.1");
|
|
2331
|
+
if (emitHubStatus({
|
|
2332
|
+
status: "online",
|
|
2333
|
+
source: "stale-pid-probe",
|
|
2334
|
+
url: `http://127.0.0.1:${probed.port || probePort}/mcp`,
|
|
2335
|
+
pid: probed.pid,
|
|
2336
|
+
state: probed.hub?.state || null,
|
|
2337
|
+
sessions: probed.sessions,
|
|
2338
|
+
})) break;
|
|
2339
|
+
console.log(`\n ${AMBER}${BOLD}⬡ tfx-hub${RESET} ${GREEN_BRIGHT}online${RESET} ${DIM}(stale PID 정리 후 probe 성공)${RESET}`);
|
|
2340
|
+
console.log(` URL: http://127.0.0.1:${probed.port || probePort}/mcp`);
|
|
2341
|
+
if (probed.pid !== undefined) console.log(` PID: ${probed.pid}`);
|
|
2342
|
+
if (probed.hub?.state) console.log(` State: ${probed.hub.state}`);
|
|
2343
|
+
if (probed.sessions !== undefined) console.log(` Sessions: ${probed.sessions}`);
|
|
2344
|
+
console.log("");
|
|
2345
|
+
}
|
|
2346
|
+
break;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
default:
|
|
2350
|
+
console.log(`\n ${AMBER}${BOLD}⬡ tfx-hub${RESET}\n`);
|
|
2351
|
+
console.log(` ${WHITE_BRIGHT}tfx hub start${RESET} ${GRAY}허브 데몬 시작${RESET}`);
|
|
2352
|
+
console.log(` ${DIM} --port N${RESET} ${GRAY}포트 지정 (기본 27888)${RESET}`);
|
|
2353
|
+
console.log(` ${WHITE_BRIGHT}tfx hub stop${RESET} ${GRAY}허브 중지${RESET}`);
|
|
2354
|
+
console.log(` ${WHITE_BRIGHT}tfx hub status${RESET} ${GRAY}상태 확인${RESET}\n`);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
// ── 메인 ──
|
|
2359
|
+
|
|
2360
|
+
async function main() {
|
|
2361
|
+
const cmd = NORMALIZED_ARGS[0] || "help";
|
|
2362
|
+
const cmdArgs = NORMALIZED_ARGS.slice(1);
|
|
2363
|
+
|
|
2364
|
+
switch (cmd) {
|
|
2365
|
+
case "setup":
|
|
2366
|
+
cmdSetup({ dryRun: cmdArgs.includes("--dry-run") });
|
|
2367
|
+
return;
|
|
2368
|
+
case "doctor": {
|
|
2369
|
+
const fix = cmdArgs.includes("--fix");
|
|
2370
|
+
const reset = cmdArgs.includes("--reset");
|
|
2371
|
+
await cmdDoctor({ fix, reset, json: JSON_OUTPUT });
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
case "schema":
|
|
2375
|
+
cmdSchema(cmdArgs);
|
|
2376
|
+
return;
|
|
2377
|
+
case "update":
|
|
2378
|
+
cmdUpdate();
|
|
2379
|
+
return;
|
|
2380
|
+
case "list":
|
|
2381
|
+
case "ls":
|
|
2382
|
+
cmdList({ json: JSON_OUTPUT });
|
|
2383
|
+
return;
|
|
2384
|
+
case "hub":
|
|
2385
|
+
await cmdHub(cmdArgs, { json: JSON_OUTPUT && (cmdArgs[0] || "status") === "status" });
|
|
2386
|
+
return;
|
|
2387
|
+
case "tray": {
|
|
2388
|
+
const trayUrl = new URL("../hub/tray.mjs", import.meta.url);
|
|
2389
|
+
const trayPath = fileURLToPath(trayUrl);
|
|
2390
|
+
if (cmdArgs.includes("--attach")) {
|
|
2391
|
+
// --attach: 포그라운드 모드 (디버깅용)
|
|
2392
|
+
const { startTray } = await import(trayUrl.href);
|
|
2393
|
+
await startTray();
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
// 기본: detach 모드 (프리징 방지)
|
|
2397
|
+
const child = spawn(process.execPath, [trayPath], {
|
|
2398
|
+
detached: true,
|
|
2399
|
+
stdio: "ignore",
|
|
2400
|
+
windowsHide: true,
|
|
2401
|
+
});
|
|
2402
|
+
child.unref();
|
|
2403
|
+
console.log(`\n ${GREEN_BRIGHT}✓${RESET} tray 시작됨 (PID ${child.pid})\n`);
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
case "multi": {
|
|
2407
|
+
const subcommand = cmdArgs[0] || "";
|
|
2408
|
+
if (JSON_OUTPUT) process.env.TFX_OUTPUT_JSON = "1";
|
|
2409
|
+
else delete process.env.TFX_OUTPUT_JSON;
|
|
2410
|
+
if (subcommand !== "status") {
|
|
2411
|
+
await checkHubRunning();
|
|
2412
|
+
}
|
|
2413
|
+
const { pathToFileURL } = await import("node:url");
|
|
2414
|
+
const { cmdTeam } = await import(pathToFileURL(join(PKG_ROOT, "hub", "team", "cli", "index.mjs")).href);
|
|
2415
|
+
const prevArgv = process.argv;
|
|
2416
|
+
process.argv = [prevArgv[0], prevArgv[1], "team", ...cmdArgs];
|
|
2417
|
+
try {
|
|
2418
|
+
await cmdTeam();
|
|
2419
|
+
} finally {
|
|
2420
|
+
process.argv = prevArgv;
|
|
2421
|
+
delete process.env.TFX_OUTPUT_JSON;
|
|
2422
|
+
}
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2425
|
+
case "codex-team":
|
|
2426
|
+
if (JSON_OUTPUT) process.env.TFX_OUTPUT_JSON = "1";
|
|
2427
|
+
else delete process.env.TFX_OUTPUT_JSON;
|
|
2428
|
+
await checkHubRunning();
|
|
2429
|
+
try {
|
|
2430
|
+
await cmdCodexTeam(cmdArgs);
|
|
2431
|
+
} finally {
|
|
2432
|
+
delete process.env.TFX_OUTPUT_JSON;
|
|
2433
|
+
}
|
|
2434
|
+
return;
|
|
2435
|
+
case "notion-read":
|
|
2436
|
+
case "nr": {
|
|
2437
|
+
const scriptPath = join(PKG_ROOT, "scripts", "notion-read.mjs");
|
|
2438
|
+
try {
|
|
2439
|
+
execFileSync(process.execPath, [scriptPath, ...cmdArgs], { stdio: "inherit", timeout: 660000, windowsHide: true });
|
|
2440
|
+
} catch (e) {
|
|
2441
|
+
throw createCliError(e.message || "notion-read 실행 실패", {
|
|
2442
|
+
exitCode: e.status || EXIT_ERROR,
|
|
2443
|
+
reason: "error",
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2448
|
+
case "version":
|
|
2449
|
+
case "--version":
|
|
2450
|
+
case "-v":
|
|
2451
|
+
cmdVersion({ json: JSON_OUTPUT });
|
|
2452
|
+
return;
|
|
2453
|
+
case "help":
|
|
2454
|
+
case "--help":
|
|
2455
|
+
case "-h":
|
|
2456
|
+
cmdHelp();
|
|
2457
|
+
return;
|
|
2458
|
+
default:
|
|
2459
|
+
throw createCliError(`알 수 없는 명령: ${cmd}`, {
|
|
2460
|
+
exitCode: EXIT_ARG_ERROR,
|
|
2461
|
+
reason: "argError",
|
|
2462
|
+
fix: "tfx --help",
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
try {
|
|
2468
|
+
await main();
|
|
2469
|
+
} catch (error) {
|
|
2470
|
+
handleFatalError(error, { json: JSON_OUTPUT });
|
|
2471
|
+
}
|