triflux 10.13.2 → 10.13.3
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/.claude-plugin/marketplace.json +34 -0
- package/.claude-plugin/plugin.json +22 -0
- package/config/mcp-registry.json +29 -0
- package/package.json +64 -21
- package/scripts/tfx-route-worker.mjs +1 -1
- package/tui/codex-profile.mjs +457 -0
- package/tui/core.mjs +266 -0
- package/tui/doctor.mjs +375 -0
- package/tui/gemini-profile.mjs +299 -0
- package/tui/monitor-data.mjs +152 -0
- package/tui/monitor.mjs +333 -0
- package/tui/setup.mjs +599 -0
- package/CLAUDE.md +0 -161
- package/references/cli-parameter-reference.md +0 -240
- package/references/codex-plugin-cc-analysis.md +0 -706
- package/references/codex-plugin-cc-code-patterns.md +0 -468
- package/references/hosts.json +0 -46
- package/skills/tfx-workspace/async-tests/run-tests.sh +0 -203
- package/skills/tfx-workspace/evals/evals.json +0 -79
- package/skills/tfx-workspace/iteration-1/benchmark.json +0 -524
- package/skills/tfx-workspace/iteration-1/codex-gemini-remap/eval_metadata.json +0 -11
- package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/grading.json +0 -25
- package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/outputs/analysis.md +0 -154
- package/skills/tfx-workspace/iteration-1/codex-gemini-remap/old_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/grading.json +0 -25
- package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/outputs/analysis.md +0 -126
- package/skills/tfx-workspace/iteration-1/codex-gemini-remap/with_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/doctor-diagnosis/eval_metadata.json +0 -11
- package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/grading.json +0 -25
- package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/outputs/analysis.md +0 -119
- package/skills/tfx-workspace/iteration-1/doctor-diagnosis/old_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/grading.json +0 -25
- package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/outputs/analysis.md +0 -115
- package/skills/tfx-workspace/iteration-1/doctor-diagnosis/with_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/hub-start-sequence/eval_metadata.json +0 -10
- package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/grading.json +0 -20
- package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/outputs/analysis.md +0 -86
- package/skills/tfx-workspace/iteration-1/hub-start-sequence/old_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/grading.json +0 -20
- package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/outputs/analysis.md +0 -81
- package/skills/tfx-workspace/iteration-1/hub-start-sequence/with_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/multi-team-creation/eval_metadata.json +0 -12
- package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/grading.json +0 -30
- package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/outputs/analysis.md +0 -316
- package/skills/tfx-workspace/iteration-1/multi-team-creation/old_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/grading.json +0 -30
- package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/outputs/analysis.md +0 -352
- package/skills/tfx-workspace/iteration-1/multi-team-creation/with_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/review.html +0 -1325
- package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/eval_metadata.json +0 -12
- package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/grading.json +0 -30
- package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/outputs/analysis.md +0 -97
- package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/old_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/grading.json +0 -30
- package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/outputs/analysis.md +0 -94
- package/skills/tfx-workspace/iteration-1/routing-implement-shortcut/with_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/eval_metadata.json +0 -12
- package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/grading.json +0 -30
- package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/outputs/analysis.md +0 -209
- package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/old_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/grading.json +0 -30
- package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/outputs/analysis.md +0 -193
- package/skills/tfx-workspace/iteration-1/routing-multi-task-triage/with_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-2/benchmark.json +0 -144
- package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/eval_metadata.json +0 -13
- package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/grading.json +0 -35
- package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/outputs/analysis.md +0 -382
- package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/old_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/grading.json +0 -35
- package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/outputs/analysis.md +0 -333
- package/skills/tfx-workspace/iteration-2/multi-team-creation-refactored/with_skill/timing.json +0 -5
- package/skills/tfx-workspace/iteration-2/review.html +0 -1325
- package/skills/tfx-workspace/skill-snapshot/tfx-auto/SKILL.md +0 -217
- package/skills/tfx-workspace/skill-snapshot/tfx-auto-codex/SKILL.md +0 -77
- package/skills/tfx-workspace/skill-snapshot/tfx-codex/SKILL.md +0 -65
- package/skills/tfx-workspace/skill-snapshot/tfx-doctor/SKILL.md +0 -94
- package/skills/tfx-workspace/skill-snapshot/tfx-gemini/SKILL.md +0 -82
- package/skills/tfx-workspace/skill-snapshot/tfx-hub/SKILL.md +0 -133
- package/skills/tfx-workspace/skill-snapshot/tfx-multi/SKILL.md +0 -426
- package/skills/tfx-workspace/skill-snapshot/tfx-setup/SKILL.md +0 -101
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
|
|
3
|
+
"name": "triflux",
|
|
4
|
+
"description": "CLI-first multi-model orchestrator — Codex/Gemini/Claude routing with DAG execution, auto-triage, and cost optimization",
|
|
5
|
+
"owner": {
|
|
6
|
+
"name": "tellang"
|
|
7
|
+
},
|
|
8
|
+
"plugins": [
|
|
9
|
+
{
|
|
10
|
+
"name": "triflux",
|
|
11
|
+
"description": "Tri-CLI orchestrator for Claude Code. Routes tasks across Claude + Codex + Gemini with consensus intelligence, natural language routing, 42 skills, and cross-model review.",
|
|
12
|
+
"version": "10.13.3",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "tellang"
|
|
15
|
+
},
|
|
16
|
+
"source": {
|
|
17
|
+
"source": "npm",
|
|
18
|
+
"package": "triflux"
|
|
19
|
+
},
|
|
20
|
+
"category": "productivity",
|
|
21
|
+
"homepage": "https://github.com/tellang/triflux",
|
|
22
|
+
"tags": [
|
|
23
|
+
"multi-model",
|
|
24
|
+
"codex",
|
|
25
|
+
"gemini",
|
|
26
|
+
"cli-routing",
|
|
27
|
+
"orchestration",
|
|
28
|
+
"cost-optimization",
|
|
29
|
+
"dag-execution"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"version": "10.13.3"
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "triflux",
|
|
3
|
+
"version": "10.13.3",
|
|
4
|
+
"description": "CLI-first multi-model orchestrator for Claude Code — route tasks to Codex, Gemini, and Claude",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "tellang"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://github.com/tellang/triflux",
|
|
9
|
+
"homepage": "https://github.com/tellang/triflux",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"claude-code",
|
|
13
|
+
"plugin",
|
|
14
|
+
"codex",
|
|
15
|
+
"gemini",
|
|
16
|
+
"cli-routing",
|
|
17
|
+
"orchestration",
|
|
18
|
+
"multi-model"
|
|
19
|
+
],
|
|
20
|
+
"skills": "./skills/",
|
|
21
|
+
"hooks": "./hooks/hooks.json"
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "mcp-registry-schema",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"description": "MCP 서버 중앙 레지스트리 — 진실의 원천",
|
|
5
|
+
"defaults": {
|
|
6
|
+
"transport": "hub-url",
|
|
7
|
+
"hub_base": "http://127.0.0.1:27888"
|
|
8
|
+
},
|
|
9
|
+
"servers": {
|
|
10
|
+
"tfx-hub": {
|
|
11
|
+
"transport": "hub-url",
|
|
12
|
+
"url": "http://127.0.0.1:27888/mcp",
|
|
13
|
+
"safe": true,
|
|
14
|
+
"targets": ["claude", "gemini", "codex"],
|
|
15
|
+
"description": "triflux Hub MCP 서버"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"policies": {
|
|
19
|
+
"stdio_action": "replace-with-hub",
|
|
20
|
+
"unknown_server_action": "warn",
|
|
21
|
+
"watched_paths": [
|
|
22
|
+
"~/.gemini/settings.json",
|
|
23
|
+
"~/.codex/config.toml",
|
|
24
|
+
"~/.claude/settings.json",
|
|
25
|
+
"~/.claude/settings.local.json",
|
|
26
|
+
".mcp.json"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triflux",
|
|
3
|
-
"version": "10.13.
|
|
3
|
+
"version": "10.13.3",
|
|
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": {
|
|
@@ -13,26 +13,77 @@
|
|
|
13
13
|
"tfx-doctor-tui": "bin/tfx-doctor-tui.mjs",
|
|
14
14
|
"tfx-setup-tui": "bin/tfx-setup-tui.mjs"
|
|
15
15
|
},
|
|
16
|
-
"engines": {
|
|
17
|
-
"node": ">=18.0.0"
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@triflux/core": "10.0.1",
|
|
21
|
-
"@triflux/remote": "^10.0.0-alpha.1"
|
|
22
|
-
},
|
|
23
16
|
"files": [
|
|
24
17
|
"bin",
|
|
18
|
+
"tui",
|
|
19
|
+
"hub",
|
|
20
|
+
"config",
|
|
25
21
|
"skills",
|
|
22
|
+
"!skills/tfx-workspace",
|
|
23
|
+
"!**/failure-reports",
|
|
24
|
+
"scripts",
|
|
26
25
|
"hooks",
|
|
27
26
|
"hud",
|
|
28
|
-
"scripts",
|
|
29
|
-
"hub",
|
|
30
27
|
"mesh",
|
|
31
|
-
"
|
|
32
|
-
"CLAUDE.md",
|
|
28
|
+
".claude-plugin",
|
|
33
29
|
"README.md",
|
|
30
|
+
"README.ko.md",
|
|
34
31
|
"LICENSE"
|
|
35
32
|
],
|
|
33
|
+
"workspaces": [
|
|
34
|
+
"packages/core",
|
|
35
|
+
"packages/remote",
|
|
36
|
+
"packages/triflux"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"pack": "node scripts/pack.mjs all",
|
|
40
|
+
"pack:core": "node scripts/pack.mjs core",
|
|
41
|
+
"pack:remote": "node scripts/pack.mjs remote",
|
|
42
|
+
"setup": "node scripts/setup.mjs",
|
|
43
|
+
"preinstall": "node scripts/preinstall.mjs",
|
|
44
|
+
"postinstall": "node scripts/setup.mjs",
|
|
45
|
+
"lint": "biome check bin config hooks hub hud mesh scripts tests .claude-plugin .github package.json package-lock.json biome.json",
|
|
46
|
+
"lint:fix": "biome check --write bin config hooks hub hud mesh scripts tests .claude-plugin .github package.json package-lock.json biome.json",
|
|
47
|
+
"health": "npm test && npm run lint",
|
|
48
|
+
"test": "node scripts/test-lock.mjs --test --test-force-exit --test-concurrency=8 \"tests/**/*.test.mjs\" \"scripts/__tests__/**/*.test.mjs\"",
|
|
49
|
+
"test:unit": "node scripts/test-lock.mjs --test --test-force-exit --test-concurrency=8 tests/unit/**/*.test.mjs",
|
|
50
|
+
"test:integration": "node scripts/test-lock.mjs --test --test-force-exit --test-concurrency=8 tests/integration/**/*.test.mjs",
|
|
51
|
+
"test:route-smoke": "node scripts/test-lock.mjs --test scripts/test-tfx-route-no-claude-native.mjs",
|
|
52
|
+
"test:contract": "node scripts/test-lock.mjs --test --test-force-exit --test-concurrency=8 tests/contract/**/*.test.mjs",
|
|
53
|
+
"test:coverage": "node --experimental-test-coverage --test-coverage-lines=60 --test-coverage-functions=60 --test --test-force-exit --test-concurrency=8 \"tests/**/*.test.mjs\"",
|
|
54
|
+
"gen:skill-docs": "node scripts/gen-skill-docs.mjs",
|
|
55
|
+
"gen:skill-manifest": "node scripts/gen-skill-manifest.mjs",
|
|
56
|
+
"release:check-sync": "node scripts/release/check-sync.mjs",
|
|
57
|
+
"release:check-sync:fix": "node scripts/release/check-sync.mjs --fix",
|
|
58
|
+
"release:check-mirror": "node scripts/release/check-packages-mirror.mjs",
|
|
59
|
+
"release:check-mirror:fix": "node scripts/release/check-packages-mirror.mjs --fix",
|
|
60
|
+
"release:bump": "node scripts/release/bump-version.mjs",
|
|
61
|
+
"release:prepare": "node scripts/release/prepare.mjs",
|
|
62
|
+
"release:publish": "node scripts/release/publish.mjs",
|
|
63
|
+
"release:verify": "node scripts/release/verify.mjs"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=18.0.0"
|
|
67
|
+
},
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/tellang/triflux.git"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://github.com/tellang/triflux#readme",
|
|
73
|
+
"author": "tellang",
|
|
74
|
+
"license": "MIT",
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
77
|
+
"better-sqlite3": "^12.6.2",
|
|
78
|
+
"pino": "^10.3.1",
|
|
79
|
+
"pino-pretty": "^13.1.3",
|
|
80
|
+
"systray2": "^2.1.4",
|
|
81
|
+
"zod": "^4.0.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@biomejs/biome": "^2.0.0",
|
|
85
|
+
"knip": "^6.3.0"
|
|
86
|
+
},
|
|
36
87
|
"keywords": [
|
|
37
88
|
"claude-code",
|
|
38
89
|
"plugin",
|
|
@@ -43,13 +94,5 @@
|
|
|
43
94
|
"multi-model",
|
|
44
95
|
"triflux",
|
|
45
96
|
"tfx"
|
|
46
|
-
]
|
|
47
|
-
"author": "tellang",
|
|
48
|
-
"license": "MIT",
|
|
49
|
-
"homepage": "https://github.com/tellang/triflux#readme",
|
|
50
|
-
"repository": {
|
|
51
|
-
"type": "git",
|
|
52
|
-
"url": "git+https://github.com/tellang/triflux.git",
|
|
53
|
-
"directory": "packages/triflux"
|
|
54
|
-
}
|
|
97
|
+
]
|
|
55
98
|
}
|
|
@@ -143,7 +143,7 @@ function resolveDefaultMcpConfig(cwd) {
|
|
|
143
143
|
const legacy = resolve(cwd, ".mcp.json");
|
|
144
144
|
if (existsSync(legacy)) return [legacy];
|
|
145
145
|
process.stderr.write(
|
|
146
|
-
"[tfx-route-worker] warning: no MCP config
|
|
146
|
+
"[tfx-route-worker] warning: no project MCP config in cwd — hub status unaffected\n",
|
|
147
147
|
);
|
|
148
148
|
return [];
|
|
149
149
|
}
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// tui/codex-profile.mjs — Interactive Codex Profile Manager
|
|
3
|
+
import {
|
|
4
|
+
copyFileSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
readFileSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import {
|
|
13
|
+
BOLD,
|
|
14
|
+
box,
|
|
15
|
+
CYAN,
|
|
16
|
+
clear,
|
|
17
|
+
confirm,
|
|
18
|
+
DIM,
|
|
19
|
+
divider,
|
|
20
|
+
fail,
|
|
21
|
+
GREEN,
|
|
22
|
+
info,
|
|
23
|
+
input,
|
|
24
|
+
label,
|
|
25
|
+
ok,
|
|
26
|
+
onExit,
|
|
27
|
+
RED,
|
|
28
|
+
RESET,
|
|
29
|
+
select,
|
|
30
|
+
showCursor,
|
|
31
|
+
table,
|
|
32
|
+
WHITE,
|
|
33
|
+
warn,
|
|
34
|
+
YELLOW,
|
|
35
|
+
} from "./core.mjs";
|
|
36
|
+
|
|
37
|
+
const CODEX_DIR = join(homedir(), ".codex");
|
|
38
|
+
const CONFIG_PATH = join(CODEX_DIR, "config.toml");
|
|
39
|
+
|
|
40
|
+
const KNOWN_MODELS = [
|
|
41
|
+
{ label: "gpt-5.4", hint: "최신 플래그십" },
|
|
42
|
+
{ label: "gpt-5.3-codex", hint: "코딩 특화" },
|
|
43
|
+
{ label: "gpt-5.1-codex-mini", hint: "경량 Spark" },
|
|
44
|
+
{ label: "o3", hint: "추론 특화" },
|
|
45
|
+
{ label: "o4-mini", hint: "추론 경량" },
|
|
46
|
+
{ label: "직접 입력", hint: "" },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const EFFORT_LEVELS = [
|
|
50
|
+
{ label: "low", hint: "빠른 응답, 최소 추론" },
|
|
51
|
+
{ label: "medium", hint: "균형 잡힌 추론" },
|
|
52
|
+
{ label: "high", hint: "깊은 추론" },
|
|
53
|
+
{ label: "xhigh", hint: "최대 추론 (느림)" },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// ── TOML Parsing ──
|
|
57
|
+
|
|
58
|
+
function readConfig() {
|
|
59
|
+
if (!existsSync(CONFIG_PATH)) return { raw: "", defaults: {}, profiles: [] };
|
|
60
|
+
const raw = readFileSync(CONFIG_PATH, "utf8");
|
|
61
|
+
return { raw, ...parseConfig(raw) };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function parseConfig(raw) {
|
|
65
|
+
const lines = raw.split("\n");
|
|
66
|
+
const defaults = {};
|
|
67
|
+
const profiles = [];
|
|
68
|
+
let currentSection = null;
|
|
69
|
+
let currentProfile = null;
|
|
70
|
+
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
const trimmed = line.trim();
|
|
73
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
74
|
+
|
|
75
|
+
const sectionMatch = trimmed.match(/^\[(.+)\]$/);
|
|
76
|
+
if (sectionMatch) {
|
|
77
|
+
const name = sectionMatch[1];
|
|
78
|
+
const profileMatch = name.match(/^profiles\.(\w+)$/);
|
|
79
|
+
if (profileMatch) {
|
|
80
|
+
currentSection = "profile";
|
|
81
|
+
currentProfile = { name: profileMatch[1] };
|
|
82
|
+
profiles.push(currentProfile);
|
|
83
|
+
} else {
|
|
84
|
+
currentSection = name;
|
|
85
|
+
currentProfile = null;
|
|
86
|
+
}
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const kvMatch = trimmed.match(/^(\w+)\s*=\s*(.+)$/);
|
|
91
|
+
if (kvMatch) {
|
|
92
|
+
const [, key, rawVal] = kvMatch;
|
|
93
|
+
const value = rawVal.replace(/^["']|["']$/g, "").trim();
|
|
94
|
+
if (currentSection === "profile" && currentProfile) {
|
|
95
|
+
currentProfile[key] = value;
|
|
96
|
+
} else if (!currentSection) {
|
|
97
|
+
defaults[key] = value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return { defaults, profiles };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function writeProfile(raw, profileName, props) {
|
|
106
|
+
const lines = raw.split("\n");
|
|
107
|
+
const sectionRe = new RegExp(`^\\[profiles\\.${escRe(profileName)}\\]\\s*$`);
|
|
108
|
+
let inSection = false;
|
|
109
|
+
let sectionStart = -1;
|
|
110
|
+
let sectionEnd = lines.length;
|
|
111
|
+
|
|
112
|
+
for (let i = 0; i < lines.length; i++) {
|
|
113
|
+
if (sectionRe.test(lines[i].trim())) {
|
|
114
|
+
inSection = true;
|
|
115
|
+
sectionStart = i;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (inSection && lines[i].trim().startsWith("[")) {
|
|
119
|
+
sectionEnd = i;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (sectionStart === -1) {
|
|
125
|
+
// Append new profile section
|
|
126
|
+
const newLines = [`[profiles.${profileName}]`];
|
|
127
|
+
for (const [k, v] of Object.entries(props)) {
|
|
128
|
+
newLines.push(`${k} = "${v}"`);
|
|
129
|
+
}
|
|
130
|
+
return raw.trimEnd() + "\n" + newLines.join("\n") + "\n";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Replace existing section body
|
|
134
|
+
const newBody = [];
|
|
135
|
+
for (const [k, v] of Object.entries(props)) {
|
|
136
|
+
newBody.push(`${k} = "${v}"`);
|
|
137
|
+
}
|
|
138
|
+
lines.splice(sectionStart + 1, sectionEnd - sectionStart - 1, ...newBody);
|
|
139
|
+
return lines.join("\n");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function deleteProfile(raw, profileName) {
|
|
143
|
+
const lines = raw.split("\n");
|
|
144
|
+
const sectionRe = new RegExp(`^\\[profiles\\.${escRe(profileName)}\\]\\s*$`);
|
|
145
|
+
let inSection = false;
|
|
146
|
+
let start = -1;
|
|
147
|
+
let end = lines.length;
|
|
148
|
+
|
|
149
|
+
for (let i = 0; i < lines.length; i++) {
|
|
150
|
+
if (sectionRe.test(lines[i].trim())) {
|
|
151
|
+
inSection = true;
|
|
152
|
+
start = i;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (inSection && lines[i].trim().startsWith("[")) {
|
|
156
|
+
end = i;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (start === -1) return raw;
|
|
162
|
+
// Remove trailing blank lines too
|
|
163
|
+
while (end < lines.length && lines[end].trim() === "") end++;
|
|
164
|
+
lines.splice(start, end - start);
|
|
165
|
+
return lines.join("\n");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function setDefault(raw, key, value) {
|
|
169
|
+
const lines = raw.split("\n");
|
|
170
|
+
const keyRe = new RegExp(`^${escRe(key)}\\s*=`);
|
|
171
|
+
|
|
172
|
+
for (let i = 0; i < lines.length; i++) {
|
|
173
|
+
if (lines[i].trim().startsWith("[")) break; // hit first section
|
|
174
|
+
if (keyRe.test(lines[i].trim())) {
|
|
175
|
+
lines[i] = `${key} = "${value}"`;
|
|
176
|
+
return lines.join("\n");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Key not found — insert before first section
|
|
181
|
+
for (let i = 0; i < lines.length; i++) {
|
|
182
|
+
if (lines[i].trim().startsWith("[")) {
|
|
183
|
+
lines.splice(i, 0, `${key} = "${value}"`);
|
|
184
|
+
return lines.join("\n");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return raw + `\n${key} = "${value}"\n`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function escRe(s) {
|
|
192
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ── UI Flows ──
|
|
196
|
+
|
|
197
|
+
function showStatus(config) {
|
|
198
|
+
const { defaults, profiles } = config;
|
|
199
|
+
|
|
200
|
+
console.log();
|
|
201
|
+
label("기본 모델", `${WHITE}${defaults.model || "미설정"}${RESET}`);
|
|
202
|
+
label(
|
|
203
|
+
"기본 Effort",
|
|
204
|
+
`${WHITE}${defaults.model_reasoning_effort || "미설정"}${RESET}`,
|
|
205
|
+
);
|
|
206
|
+
console.log();
|
|
207
|
+
|
|
208
|
+
if (profiles.length === 0) {
|
|
209
|
+
warn("등록된 프로파일이 없습니다.");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const headers = ["프로파일", "모델", "Effort", "기타"];
|
|
214
|
+
const rows = profiles.map((p) => {
|
|
215
|
+
const extras = Object.entries(p)
|
|
216
|
+
.filter(([k]) => !["name", "model", "model_reasoning_effort"].includes(k))
|
|
217
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
218
|
+
.join(", ");
|
|
219
|
+
return [
|
|
220
|
+
`${CYAN}${p.name}${RESET}`,
|
|
221
|
+
p.model || DIM + "inherit" + RESET,
|
|
222
|
+
effortColor(p.model_reasoning_effort),
|
|
223
|
+
extras ? `${DIM}${extras}${RESET}` : "",
|
|
224
|
+
];
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
table(headers, rows);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function effortColor(effort) {
|
|
231
|
+
if (!effort) return `${DIM}inherit${RESET}`;
|
|
232
|
+
const colors = { low: GREEN, medium: CYAN, high: YELLOW, xhigh: RED };
|
|
233
|
+
return `${colors[effort] || ""}${effort}${RESET}`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async function pickModel(current) {
|
|
237
|
+
const idx = KNOWN_MODELS.findIndex((m) => m.label === current);
|
|
238
|
+
const choice = await select("모델 선택", KNOWN_MODELS, {
|
|
239
|
+
initial: Math.max(0, idx),
|
|
240
|
+
});
|
|
241
|
+
if (!choice) return null;
|
|
242
|
+
if (choice.value.label === "직접 입력") {
|
|
243
|
+
return await input("모델 ID", current || "");
|
|
244
|
+
}
|
|
245
|
+
return choice.value.label;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function pickEffort(current) {
|
|
249
|
+
const idx = EFFORT_LEVELS.findIndex((e) => e.label === current);
|
|
250
|
+
const choice = await select("Reasoning Effort 선택", EFFORT_LEVELS, {
|
|
251
|
+
initial: Math.max(0, idx),
|
|
252
|
+
});
|
|
253
|
+
if (!choice) return null;
|
|
254
|
+
return choice.value.label;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async function editProfile(config) {
|
|
258
|
+
const { profiles } = config;
|
|
259
|
+
if (profiles.length === 0) {
|
|
260
|
+
warn("편집할 프로파일이 없습니다.");
|
|
261
|
+
return config;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const options = profiles.map((p) => ({
|
|
265
|
+
label: p.name,
|
|
266
|
+
hint: `${DIM}${p.model || "inherit"} / ${p.model_reasoning_effort || "inherit"}${RESET}`,
|
|
267
|
+
}));
|
|
268
|
+
|
|
269
|
+
const picked = await select("편집할 프로파일", options);
|
|
270
|
+
if (!picked) return config;
|
|
271
|
+
|
|
272
|
+
const profile = profiles[picked.index];
|
|
273
|
+
console.log();
|
|
274
|
+
info(
|
|
275
|
+
`현재: ${BOLD}${profile.name}${RESET} → ${profile.model} / ${profile.model_reasoning_effort}`,
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const newModel = await pickModel(profile.model);
|
|
279
|
+
if (newModel === null) return config;
|
|
280
|
+
|
|
281
|
+
const newEffort = await pickEffort(profile.model_reasoning_effort);
|
|
282
|
+
if (newEffort === null) return config;
|
|
283
|
+
|
|
284
|
+
console.log();
|
|
285
|
+
info(
|
|
286
|
+
`변경: ${profile.model} → ${BOLD}${newModel}${RESET}, ${profile.model_reasoning_effort} → ${BOLD}${newEffort}${RESET}`,
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
if (!(await confirm("저장하시겠습니까?"))) return config;
|
|
290
|
+
|
|
291
|
+
const props = { model: newModel, model_reasoning_effort: newEffort };
|
|
292
|
+
// Preserve extra props (like model_temperature)
|
|
293
|
+
for (const [k, v] of Object.entries(profile)) {
|
|
294
|
+
if (!["name", "model", "model_reasoning_effort"].includes(k)) props[k] = v;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const raw = writeProfile(config.raw, profile.name, props);
|
|
298
|
+
save(raw);
|
|
299
|
+
ok(`${profile.name} 프로파일 저장 완료`);
|
|
300
|
+
return readConfig();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
async function editDefault(config) {
|
|
304
|
+
const { defaults } = config;
|
|
305
|
+
info(`현재 기본 모델: ${BOLD}${defaults.model || "미설정"}${RESET}`);
|
|
306
|
+
info(
|
|
307
|
+
`현재 기본 Effort: ${BOLD}${defaults.model_reasoning_effort || "미설정"}${RESET}`,
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
const newModel = await pickModel(defaults.model);
|
|
311
|
+
if (newModel === null) return config;
|
|
312
|
+
|
|
313
|
+
const newEffort = await pickEffort(defaults.model_reasoning_effort);
|
|
314
|
+
if (newEffort === null) return config;
|
|
315
|
+
|
|
316
|
+
console.log();
|
|
317
|
+
info(
|
|
318
|
+
`변경: ${defaults.model} → ${BOLD}${newModel}${RESET}, ${defaults.model_reasoning_effort} → ${BOLD}${newEffort}${RESET}`,
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
if (!(await confirm("저장하시겠습니까?"))) return config;
|
|
322
|
+
|
|
323
|
+
let raw = setDefault(config.raw, "model", newModel);
|
|
324
|
+
raw = setDefault(raw, "model_reasoning_effort", newEffort);
|
|
325
|
+
save(raw);
|
|
326
|
+
ok("기본 설정 저장 완료");
|
|
327
|
+
return readConfig();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async function addProfile(config) {
|
|
331
|
+
const name = await input("새 프로파일 이름");
|
|
332
|
+
if (!name) return config;
|
|
333
|
+
|
|
334
|
+
if (config.profiles.some((p) => p.name === name)) {
|
|
335
|
+
fail(`'${name}' 프로파일이 이미 존재합니다.`);
|
|
336
|
+
return config;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const model = await pickModel("");
|
|
340
|
+
if (!model) return config;
|
|
341
|
+
|
|
342
|
+
const effort = await pickEffort("");
|
|
343
|
+
if (!effort) return config;
|
|
344
|
+
|
|
345
|
+
console.log();
|
|
346
|
+
info(`추가: ${BOLD}${name}${RESET} → ${model} / ${effort}`);
|
|
347
|
+
if (!(await confirm("저장하시겠습니까?"))) return config;
|
|
348
|
+
|
|
349
|
+
const raw = writeProfile(config.raw, name, {
|
|
350
|
+
model,
|
|
351
|
+
model_reasoning_effort: effort,
|
|
352
|
+
});
|
|
353
|
+
save(raw);
|
|
354
|
+
ok(`${name} 프로파일 추가 완료`);
|
|
355
|
+
return readConfig();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async function removeProfile(config) {
|
|
359
|
+
const { profiles } = config;
|
|
360
|
+
if (profiles.length === 0) {
|
|
361
|
+
warn("삭제할 프로파일이 없습니다.");
|
|
362
|
+
return config;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const options = profiles.map((p) => ({ label: p.name, hint: `${p.model}` }));
|
|
366
|
+
const picked = await select("삭제할 프로파일", options);
|
|
367
|
+
if (!picked) return config;
|
|
368
|
+
|
|
369
|
+
const name = profiles[picked.index].name;
|
|
370
|
+
if (
|
|
371
|
+
!(await confirm(
|
|
372
|
+
`${RED}${name}${RESET} 프로파일을 삭제하시겠습니까?`,
|
|
373
|
+
false,
|
|
374
|
+
))
|
|
375
|
+
) {
|
|
376
|
+
return config;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const raw = deleteProfile(config.raw, name);
|
|
380
|
+
save(raw);
|
|
381
|
+
ok(`${name} 프로파일 삭제 완료`);
|
|
382
|
+
return readConfig();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function save(content) {
|
|
386
|
+
if (!existsSync(CODEX_DIR)) mkdirSync(CODEX_DIR, { recursive: true });
|
|
387
|
+
|
|
388
|
+
// Backup before write
|
|
389
|
+
if (existsSync(CONFIG_PATH)) {
|
|
390
|
+
const backupPath = CONFIG_PATH + ".bak";
|
|
391
|
+
copyFileSync(CONFIG_PATH, backupPath);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
writeFileSync(CONFIG_PATH, content, "utf8");
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// ── Main Loop ──
|
|
398
|
+
|
|
399
|
+
const MENU = [
|
|
400
|
+
{ label: "프로파일 모델 변경", hint: "모델/effort 수정" },
|
|
401
|
+
{ label: "기본 모델 변경", hint: "top-level default" },
|
|
402
|
+
{ label: "프로파일 추가", hint: "새 프로파일 생성" },
|
|
403
|
+
{ label: "프로파일 삭제", hint: "기존 프로파일 제거" },
|
|
404
|
+
{ label: "종료", hint: "Ctrl+C" },
|
|
405
|
+
];
|
|
406
|
+
|
|
407
|
+
async function main() {
|
|
408
|
+
onExit(() => {});
|
|
409
|
+
clear();
|
|
410
|
+
|
|
411
|
+
let config = readConfig();
|
|
412
|
+
|
|
413
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
414
|
+
fail(`config.toml 미존재: ${CONFIG_PATH}`);
|
|
415
|
+
info("codex를 먼저 설치하거나 /tfx-setup을 실행하세요.");
|
|
416
|
+
process.exit(1);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
while (true) {
|
|
420
|
+
box("Codex Profile Manager", 46);
|
|
421
|
+
showStatus(config);
|
|
422
|
+
console.log();
|
|
423
|
+
|
|
424
|
+
const choice = await select("작업 선택", MENU);
|
|
425
|
+
if (!choice || choice.index === 4) {
|
|
426
|
+
console.log();
|
|
427
|
+
info("종료합니다.");
|
|
428
|
+
showCursor();
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
console.log();
|
|
433
|
+
switch (choice.index) {
|
|
434
|
+
case 0:
|
|
435
|
+
config = await editProfile(config);
|
|
436
|
+
break;
|
|
437
|
+
case 1:
|
|
438
|
+
config = await editDefault(config);
|
|
439
|
+
break;
|
|
440
|
+
case 2:
|
|
441
|
+
config = await addProfile(config);
|
|
442
|
+
break;
|
|
443
|
+
case 3:
|
|
444
|
+
config = await removeProfile(config);
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
console.log();
|
|
449
|
+
divider(46);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
main().catch((e) => {
|
|
454
|
+
showCursor();
|
|
455
|
+
console.error(e);
|
|
456
|
+
process.exit(1);
|
|
457
|
+
});
|