triflux 6.0.18 → 6.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/setup.mjs +54 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triflux",
3
- "version": "6.0.18",
3
+ "version": "6.0.19",
4
4
  "description": "CLI-first multi-model orchestrator for Claude Code — route tasks to Codex, Gemini, and Claude",
5
5
  "type": "module",
6
6
  "bin": {
package/scripts/setup.mjs CHANGED
@@ -117,6 +117,11 @@ const SYNC_MAP = [
117
117
  dst: join(CLAUDE_DIR, "scripts", "lib", "keyword-rules.mjs"),
118
118
  label: "lib/keyword-rules.mjs",
119
119
  },
120
+ {
121
+ src: join(PLUGIN_ROOT, "scripts", "headless-guard.mjs"),
122
+ dst: join(CLAUDE_DIR, "scripts", "headless-guard.mjs"),
123
+ label: "headless-guard.mjs",
124
+ },
120
125
  ];
121
126
 
122
127
  function getVersion(filePath) {
@@ -549,6 +554,55 @@ try {
549
554
  writeFileSync(settingsPath, JSON.stringify(hookSettings, null, 2) + "\n", "utf8");
550
555
  synced++;
551
556
  }
557
+
558
+ // ── PreToolUse 훅: headless-guard (auto-route) ──
559
+ // Phase 3 headless 모드 활성 중 tfx-route.sh 개별 호출을
560
+ // headless 명령으로 자동 변환한다.
561
+ if (!Array.isArray(hookSettings.hooks.PreToolUse)) {
562
+ hookSettings.hooks.PreToolUse = [];
563
+ }
564
+
565
+ const guardScriptPath = join(CLAUDE_DIR, "scripts", "headless-guard.mjs").replace(/\\/g, "/");
566
+ const hasGuardHook = hookSettings.hooks.PreToolUse.some((entry) =>
567
+ Array.isArray(entry.hooks) &&
568
+ entry.hooks.some((h) => typeof h.command === "string" && h.command.includes("headless-guard")),
569
+ );
570
+
571
+ if (!hasGuardHook && existsSync(guardScriptPath.replace(/\//g, "\\"))) {
572
+ const nodePath = process.execPath.replace(/\\/g, "/");
573
+ const nodeRef = nodePath.includes(" ") ? `"${nodePath}"` : nodePath;
574
+
575
+ hookSettings.hooks.PreToolUse.push({
576
+ matcher: "Bash|Agent",
577
+ hooks: [
578
+ {
579
+ type: "command",
580
+ command: `${nodeRef} "${guardScriptPath}"`,
581
+ timeout: 3,
582
+ },
583
+ ],
584
+ });
585
+ writeFileSync(settingsPath, JSON.stringify(hookSettings, null, 2) + "\n", "utf8");
586
+ synced++;
587
+ } else if (hasGuardHook) {
588
+ // 기존 훅 경로를 동기화된 경로로 업데이트
589
+ let updated = false;
590
+ for (const entry of hookSettings.hooks.PreToolUse) {
591
+ if (!Array.isArray(entry.hooks)) continue;
592
+ for (const h of entry.hooks) {
593
+ if (typeof h.command === "string" && h.command.includes("headless-guard") && !h.command.includes(guardScriptPath)) {
594
+ const nodePath = process.execPath.replace(/\\/g, "/");
595
+ const nodeRef = nodePath.includes(" ") ? `"${nodePath}"` : nodePath;
596
+ h.command = `${nodeRef} "${guardScriptPath}"`;
597
+ updated = true;
598
+ }
599
+ }
600
+ }
601
+ if (updated) {
602
+ writeFileSync(settingsPath, JSON.stringify(hookSettings, null, 2) + "\n", "utf8");
603
+ synced++;
604
+ }
605
+ }
552
606
  } catch {
553
607
  // settings.json 파싱 실패 시 무시 — 기존 설정 보존
554
608
  }