triflux 10.63.0 → 10.64.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.
@@ -33,6 +33,8 @@ macOS의 iTerm2에서 로컬 tmux 세션을 `start`하면 리드가 있는 창
33
33
 
34
34
  새 세션 이름은 `<월>.<일> <주제>`로 짓는다. `start --name`을 생략하면 자동으로 만들고 `nameGenerated: true`를 보고한다. `--resume` 또는 `--resume-last`는 `--name`을 명시한 경우에만 이름을 적용한다. 승계 세션에는 기존 이름 뒤에 ` 2`, 이후 ` 3`을 붙인다. 이름 적용을 요청한 경우 결과의 `nameApplied: false`는 미적용을 뜻한다. agy의 `namePending: true`는 첫 일반 ask에서 적용할 이름이 보류됐다는 뜻이다. Codex `start`는 `/rename` 제출을 입력창이 빌 때까지 확인하고, 이름으로 찾은 thread UUID를 `threadId`로 돌려주며 tmux 세션 옵션 `@tfx_codex_thread`에 남긴다. 로컬 Codex `--resume-last`는 Codex가 고른 thread를 사후에 찾는다. 띄운 뒤 공유 app-server daemon에 로드된 같은 cwd의 thread 중 rollout에 그 시각 이후의 resume 기록(`thread_settings_applied`)이 생긴 것이 정확히 하나이고 1.5초 뒤에도 같을 때만 `threadId`로 쓴다. 이 확인은 5초 안에 끝난다. TUI가 daemon을 쓰지 않거나 같은 cwd에서 동시에 resume이 일어나면 `null`이다. 기존 Codex UDS thread는 `tfx-live rename --cli codex --transport uds --thread ID --name "<이름>"`으로 이름을 바꾼다.
35
35
 
36
+ Codex 폴더 신뢰 화면이나 Claude 프로젝트 MCP 승인 화면이 뜨면 `start`는 화면에 답하지 않고 `ready: false`, `blockedBy`(`codex-trust-folder` 또는 `claude-mcp-approval`), 할 일을 적은 `warning`을 반환한다. 세션은 남아 있으므로 tmux 세션에 붙어 직접 고른 뒤 지시를 보낸다.
37
+
36
38
  ## agy 세션
37
39
 
38
40
  ```bash
@@ -105,19 +107,20 @@ Claude와 Codex는 네이티브 goal을 우선 쓰고, goal-driven은 agy처럼
105
107
 
106
108
  ### 컨텍스트 판단
107
109
 
108
- 분모는 공식 모델 창이고 실행 한도가 더 작으면 그 한도 아래에서 운영한다. 아래 비율은 공식 권고가 아닌 **[추론] 운영값**이다. 모델 문서가 바뀌면 한도도 갱신한다.
110
+ Claude의 분모는 공식 모델 창과 실행 한도 중 작은 값이다. Codex의 분모는 rollout이 보고한 실행 창이고, 없을 때만 공식 창이다. 아래 비율은 공식 권고가 아닌 **[추론] 운영값**이다. 모델 문서가 바뀌면 한도도 갱신한다.
109
111
 
110
112
  | CLI | 준비와 경고 | compact | 신규 배정 중지·handoff | 전송 거부 |
111
113
  | --- | ---: | ---: | ---: | ---: |
112
114
  | Claude Code 1M 모델 | 60% | 75% | 85% | 90% |
113
- | Codex | 15% | 18% | 20% | 22% |
115
+ | Codex rollout 실행 창 | 60% | - | - | 85% |
116
+ | Codex 실행 창 없음(1.05M 분모) | 15% | 18% | 20% | 22% |
114
117
  | agy | 12% | 없음 | 15% | 18% |
115
118
 
116
- Claude는 85% 도달 시 바로 handoff를 지시한다. agy 행은 운영 지침이며 agy도 `tfx-live` 전송 대상이지만 컨텍스트 비율은 자동으로 읽지 못해 `null`로 보고하고 가드를 건너뛴다. `model_context_window`와 `model_auto_compact_token_limit`은 올리지 않는다.
119
+ Claude는 85% 도달 시 바로 handoff를 지시한다. Codex 실행 창 행의 compact와 handoff 비율은 아직 정하지 않았다. agy 행은 운영 지침이며 agy도 `tfx-live` 전송 대상이지만 컨텍스트 비율은 자동으로 읽지 못해 `null`로 보고하고 가드를 건너뛴다. `model_context_window`와 `model_auto_compact_token_limit`은 올리지 않는다.
117
120
 
118
- 결과에는 `estimatedContextTokens`, `contextLimitTokens`, `contextLimitSource`, `contextPct`가 포함된다. Claude 실행 한도는 `executionContextLimitTokens`로 별도 보고하며 `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`이면 200,000이다. 판정에는 공식 창과 실행 한도 중 작은 값을 쓴다. 한도를 모르면 비율은 `null`로 두고 경고만 한다. 사용량이 없는 `probe`는 `context: null`이다. 컨텍스트를 확인하려면 직접 `tfx-live probe`를 실행한다. `interrupt`, 자동 `ask`의 daemon probe, `stop --short`는 transcript를 읽지 않는다.
121
+ 결과에는 `estimatedContextTokens`, `contextLimitTokens`, `contextLimitSource`, `contextPct`가 포함된다. Claude 실행 한도는 `executionContextLimitTokens`로 별도 보고하며 `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`이면 200,000이다. Codex는 rollout `token_count`의 `model_context_window`를 `executionContextLimitTokens`로 보고한다. 이 값이 있으면 모델 표에 없는 모델이라도 그 창으로 판정하고, 없으면 1,050,000 표 값을 분모로 쓴다. 한도를 모르면 비율은 `null`로 두고 경고만 한다. 사용량이 없는 `probe`는 `context: null`이다. 컨텍스트를 확인하려면 직접 `tfx-live probe`를 실행한다. `interrupt`, 자동 `ask`의 daemon probe, `stop --short`는 transcript를 읽지 않는다.
119
122
 
120
- `ask`의 `--warn-context-pct`와 `--max-context-pct`는 경고·거부 비율을 덮어쓰며 0이면 해당 가드를 끈다. 기본값은 표의 경고·전송 거부 열이다. 거부 결과는 `status: "failed"`, `done: false`, `context-limit`와 컨텍스트 필드를 돌려준다. 자세한 근거와 실측은 [컨텍스트 정책 연구](../../docs/research/tfx-live-context-policy-2026-10.md)에 둔다.
123
+ `ask`의 `--warn-context-pct`와 `--max-context-pct`는 경고·거부 비율을 덮어쓰며 0이면 해당 가드를 끈다. 기본값은 표의 경고·전송 거부 열이다. Codex는 `executionContextLimitTokens`가 있으면 실행 창 행을, 없으면 1.05M 분모 행을 쓴다. 거부 결과는 `status: "failed"`, `done: false`, `context-limit`, 컨텍스트 필드와 적용한 거부 비율 `thresholdPct`를 돌려준다. 경고의 `thresholdPct`는 적용한 경고 비율이다. 자세한 근거와 실측은 [컨텍스트 정책 연구](../../docs/research/tfx-live-context-policy-2026-10.md)에 둔다.
121
124
 
122
125
  ### 수동 compact와 종료
123
126
 
package/bin/tfx-live.mjs CHANGED
@@ -53,7 +53,6 @@ import {
53
53
  validateHost as validateRemoteHost,
54
54
  } from "../hub/team/remote-session.mjs";
55
55
  import {
56
- CONTEXT_THRESHOLDS,
57
56
  contextGuard,
58
57
  findCodexRollout,
59
58
  modelContext,
@@ -107,7 +106,7 @@ function usage(command) {
107
106
  " Codex ask defaults to the app-server queue (thread/queue/add, `codex queue --message` only when add is unavailable; delivered when the TUI picks it up); tmux paste is the reported fallback and the path for slash commands.",
108
107
  " tfx-live ask --cli codex --transport uds --thread ID|auto --prompt TEXT [--codex-socket PATH|default] [--cwd DIR] [--if-busy wait|fail|steer] [--busy-timeout 60] [--timeout 60] [--max-turn SECONDS]",
109
108
  " tfx-live ask --transport uds|auto (--short SHORT | --session-id ID) --prompt TEXT [--config-dir DIR] [--bridge ABS] [--session NAME (auto fallback)] [--timeout 60]",
110
- " ask options: --no-wait --no-relay-tag --warn-context-pct N --max-context-pct N (0 disables; Claude 60/90, Codex 15/22).",
109
+ " ask options: --no-wait --no-relay-tag --warn-context-pct N --max-context-pct N (0 disables; Claude 60/90, Codex 60/85 of rollout window or 15/22 of 1.05M).",
111
110
  " tfx-live compact --session NAME [--cli claude|codex] [--instructions TEXT] [--then PROMPT] [--no-wait] [--if-busy fail|wait] [--timeout 60]",
112
111
  " tfx-live goal set --session NAME [--cli claude|codex] --condition TEXT [--budget N]",
113
112
  " tfx-live goal status --session NAME [--cli claude|codex]",
@@ -220,8 +219,10 @@ function integerFlag(flags, name, defaultValue) {
220
219
  return value;
221
220
  }
222
221
 
223
- function contextPctFlag(flags, name, defaultValue) {
224
- const value = flags[name] === undefined ? defaultValue : Number(flags[name]);
222
+ // 기본값은 contextGuard 가 읽은 실행 창에 맞춰 고른다.
223
+ function contextPctFlag(flags, name) {
224
+ if (flags[name] === undefined) return undefined;
225
+ const value = Number(flags[name]);
225
226
  if (!Number.isFinite(value) || value < 0 || value > 100)
226
227
  throw new Error(`--${name} must be between 0 and 100`);
227
228
  return value;
@@ -230,16 +231,8 @@ function contextPctFlag(flags, name, defaultValue) {
230
231
  function contextOpts(flags, cli) {
231
232
  if (cli === "agy") return {};
232
233
  return {
233
- warnContextPct: contextPctFlag(
234
- flags,
235
- "warn-context-pct",
236
- CONTEXT_THRESHOLDS[cli].warnContextPct,
237
- ),
238
- maxContextPct: contextPctFlag(
239
- flags,
240
- "max-context-pct",
241
- CONTEXT_THRESHOLDS[cli].maxContextPct,
242
- ),
234
+ warnContextPct: contextPctFlag(flags, "warn-context-pct"),
235
+ maxContextPct: contextPctFlag(flags, "max-context-pct"),
243
236
  };
244
237
  }
245
238
 
@@ -1770,6 +1763,49 @@ function isClaudeExternalImportsPrompt(text) {
1770
1763
  );
1771
1764
  }
1772
1765
 
1766
+ // 승인 화면에서는 마지막 선택 글리프 줄이 메뉴 항목이다. 문구를 인용한 대화라면
1767
+ // 그 아래 입력창이 마지막 글리프 줄이 되므로 걸러진다. 위쪽 문구는 테두리와
1768
+ // 줄바꿈이 끊어도 맞도록 공백 하나로 접는다.
1769
+ function splitAtLastSelector(text, glyph) {
1770
+ const lines = stripAnsi(text)
1771
+ .split("\n")
1772
+ .map((line) => line.replace(/^[\s│┃]+/, ""));
1773
+ const index = lines.findLastIndex((line) => line.startsWith(glyph));
1774
+ if (index < 0) return null;
1775
+ const isRule = (line = "") => /^─{3,}/.test(line);
1776
+ return {
1777
+ above: lines.slice(0, index).join(" ").replace(/\s+/g, " "),
1778
+ selected: lines[index],
1779
+ // Claude 입력창은 위아래 가로줄 상자다. 여러 줄 입력이면 아래 가로줄이 몇 줄 뒤에 온다.
1780
+ inComposerBox:
1781
+ isRule(lines[index - 1]) && lines.slice(index + 1).some(isRule),
1782
+ };
1783
+ }
1784
+
1785
+ function isCodexTrustFolderPrompt(text) {
1786
+ const menu = splitAtLastSelector(text, "›");
1787
+ return (
1788
+ Boolean(menu) &&
1789
+ /trust this folder\?/i.test(menu.above) &&
1790
+ /^›\s*(?:\d+\.\s*)?(?:trust and continue|open restricted)/i.test(
1791
+ menu.selected,
1792
+ )
1793
+ );
1794
+ }
1795
+
1796
+ // 다중 선택 항목은 한 글자 체크박스로 그린다. 바이너리 상수: [ ] [×] [✔] [√] ☐ ☒, 라디오 ( ) (*) ◯ ◉.
1797
+ function isClaudeMcpApprovalPrompt(text) {
1798
+ const menu = splitAtLastSelector(text, "❯");
1799
+ return (
1800
+ Boolean(menu) &&
1801
+ !menu.inComposerBox &&
1802
+ /new MCP servers? found in this project/i.test(menu.above) &&
1803
+ /^❯\s*(?:\d+\.\s*)?(?:use this|continue without using this MCP server|enable selected|\[.\]|\(.\)|[☐☒◯◉])/iu.test(
1804
+ menu.selected,
1805
+ )
1806
+ );
1807
+ }
1808
+
1773
1809
  function isClaudeTourPrompt(text) {
1774
1810
  // Claude's post-update welcome/tour screen ("Take the tour" / "Skip for now").
1775
1811
  // Claude has no codex-style "Update available / Skip until next version" menu
@@ -2024,6 +2060,15 @@ const ADAPTERS = {
2024
2060
  dismiss: dismissCodexDaemonSettingsPrompt,
2025
2061
  },
2026
2062
  ],
2063
+ // 사람의 보안 판단이 필요한 화면이라 고르지 않고 start 를 ready:false 로 끝낸다.
2064
+ blockingScreens: [
2065
+ {
2066
+ name: "codex-trust-folder",
2067
+ isPresent: isCodexTrustFolderPrompt,
2068
+ warning:
2069
+ "Codex is asking whether to trust this folder; attach to the tmux session and answer it yourself",
2070
+ },
2071
+ ],
2027
2072
  },
2028
2073
  claude: {
2029
2074
  cli: "claude",
@@ -2081,6 +2126,14 @@ const ADAPTERS = {
2081
2126
  dismiss: dismissClaudeTourPrompt,
2082
2127
  },
2083
2128
  ],
2129
+ blockingScreens: [
2130
+ {
2131
+ name: "claude-mcp-approval",
2132
+ isPresent: isClaudeMcpApprovalPrompt,
2133
+ warning:
2134
+ "Claude is asking to approve project MCP servers; attach to the tmux session and answer it yourself",
2135
+ },
2136
+ ],
2084
2137
  },
2085
2138
  agy: {
2086
2139
  cli: "agy",
@@ -2204,6 +2257,17 @@ async function waitForReady(
2204
2257
 
2205
2258
  while (Date.now() - startedAt < timeoutMs) {
2206
2259
  raw = await captureVisible(remote, session);
2260
+ const blocking = adapter.blockingScreens?.find((screen) =>
2261
+ screen.isPresent(raw),
2262
+ );
2263
+ if (blocking) {
2264
+ return {
2265
+ ready: false,
2266
+ raw,
2267
+ blockedBy: blocking.name,
2268
+ warning: blocking.warning,
2269
+ };
2270
+ }
2207
2271
  if (isStartupScreen(adapter, raw)) {
2208
2272
  await dismissStartupScreens(adapter, remote, session);
2209
2273
  await sleep(pollIntervalMs);
@@ -2706,7 +2770,7 @@ async function doStart(adapter, opts) {
2706
2770
  await runTmux(remote, ["send-keys", "-t", session, ...launchKeys]);
2707
2771
  await dismissStartupScreens(adapter, remote, session);
2708
2772
 
2709
- const { ready, raw } = await waitForReady(
2773
+ const { ready, raw, blockedBy, warning } = await waitForReady(
2710
2774
  adapter,
2711
2775
  remote,
2712
2776
  session,
@@ -2886,6 +2950,7 @@ end tell`;
2886
2950
  resumed,
2887
2951
  resumeTarget,
2888
2952
  ready,
2953
+ ...(blockedBy ? { blockedBy, warning } : {}),
2889
2954
  name,
2890
2955
  nameGenerated: !resumed && opts.name === undefined,
2891
2956
  nameApplied,
@@ -23,14 +23,21 @@ const MODEL_CONTEXT = [
23
23
  },
24
24
  ];
25
25
 
26
- export const CONTEXT_THRESHOLDS = {
26
+ const CONTEXT_THRESHOLDS = {
27
27
  claude: { warnContextPct: 60, maxContextPct: 90 },
28
- codex: { warnContextPct: 15, maxContextPct: 22 },
28
+ codex: { warnContextPct: 60, maxContextPct: 85 },
29
29
  };
30
+ // rollout 실행 창을 못 읽으면 1.05M 표 값이 분모라 실제 창보다 비율이 작게 나온다.
31
+ const CODEX_MODEL_WINDOW_THRESHOLDS = { warnContextPct: 15, maxContextPct: 22 };
30
32
 
31
33
  const rolloutCache = new Map();
32
34
 
33
- export function modelContext(cli, model, estimatedContextTokens = null) {
35
+ export function modelContext(
36
+ cli,
37
+ model,
38
+ estimatedContextTokens = null,
39
+ rolloutContextWindow = null,
40
+ ) {
34
41
  const entry = MODEL_CONTEXT.find(
35
42
  (item) => item.cli === cli && item.model.test(model || ""),
36
43
  );
@@ -38,18 +45,20 @@ export function modelContext(cli, model, estimatedContextTokens = null) {
38
45
  const executionContextLimitTokens =
39
46
  cli === "claude" && process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT === "1"
40
47
  ? 200_000
41
- : null;
42
- const effectiveLimit = Math.min(
43
- contextLimitTokens ?? Infinity,
44
- executionContextLimitTokens ?? Infinity,
45
- );
48
+ : rolloutContextWindow;
49
+ // Codex 는 rollout 이 보고한 창이 실제 실행 한도라 표 값과 무관하게 그 창을 쓴다.
50
+ const effectiveLimit =
51
+ cli === "codex"
52
+ ? (executionContextLimitTokens ?? contextLimitTokens)
53
+ : contextLimitTokens &&
54
+ Math.min(contextLimitTokens, executionContextLimitTokens ?? Infinity);
46
55
  return {
47
56
  estimatedContextTokens,
48
57
  contextLimitTokens,
49
58
  contextLimitSource: entry?.source ?? null,
50
59
  ...(executionContextLimitTokens ? { executionContextLimitTokens } : {}),
51
60
  contextPct:
52
- contextLimitTokens && Number.isFinite(estimatedContextTokens)
61
+ effectiveLimit && Number.isFinite(estimatedContextTokens)
53
62
  ? (estimatedContextTokens / effectiveLimit) * 100
54
63
  : null,
55
64
  };
@@ -60,7 +69,10 @@ export function contextGuard(
60
69
  context,
61
70
  { warnContextPct, maxContextPct } = {},
62
71
  ) {
63
- const defaults = CONTEXT_THRESHOLDS[cli];
72
+ const defaults =
73
+ cli === "codex" && !context?.executionContextLimitTokens
74
+ ? CODEX_MODEL_WINDOW_THRESHOLDS
75
+ : CONTEXT_THRESHOLDS[cli];
64
76
  const warn = warnContextPct ?? defaults?.warnContextPct ?? 0;
65
77
  const max = maxContextPct ?? defaults?.maxContextPct ?? 0;
66
78
  const fields = {
@@ -90,6 +102,7 @@ export function contextGuard(
90
102
  inputSent: false,
91
103
  hint: "세션을 승계한 뒤 새 세션에 요청하라.",
92
104
  ...fields,
105
+ thresholdPct: max,
93
106
  };
94
107
  }
95
108
  return warn > 0 && fields.contextPct >= warn
@@ -206,7 +219,12 @@ export async function readCodexContext(rolloutPath, threadId) {
206
219
  state.mtimeMs = stat.mtimeMs;
207
220
  rolloutCache.set(rolloutPath, state);
208
221
  return {
209
- ...modelContext("codex", state.model, state.tokens),
222
+ ...modelContext(
223
+ "codex",
224
+ state.model,
225
+ state.tokens,
226
+ state.executionContextLimitTokens,
227
+ ),
210
228
  model: state.model,
211
229
  compactCount: state.compactCount,
212
230
  compact: state.compact,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triflux",
3
- "version": "10.63.0",
3
+ "version": "10.64.0",
4
4
  "description": "CLI-first multi-model orchestrator for Claude Code — route tasks to Codex, Antigravity, and Claude",
5
5
  "type": "module",
6
6
  "bin": {
package/scripts/pack.mjs CHANGED
@@ -120,42 +120,54 @@ function buildFileSet(baseDir) {
120
120
  }
121
121
 
122
122
  /**
123
- * remote 패키지 내 .mjs 파일에서 core 모듈을 참조하는 상대 import를
124
- * @triflux/core 패키지 경로로 리라이팅한다.
123
+ * remote 패키지 내 .mjs 파일 하나에서 core 모듈을 참조하는 상대 import를
124
+ * @triflux/core 패키지 경로로 리라이팅한다. release:check-mirror 도 이 함수로 기대본을 만든다.
125
125
  */
126
+ export function rewriteRemoteSource(
127
+ content,
128
+ filePath,
129
+ remotePkgDir,
130
+ corePkgDir,
131
+ coreFiles = buildFileSet(corePkgDir),
132
+ ) {
133
+ let rewrites = 0;
134
+ const rewriteRelativeSpecifier = (match, pre, importPath, post) => {
135
+ const resolved = normalize(join(dirname(filePath), importPath));
136
+ // import 대상이 remote 패키지 내에 있으면 그대로 유지
137
+ if (existsSync(resolved)) return match;
138
+ // core 패키지에 동일 상대경로로 존재하는지 확인
139
+ const relToRemote = relative(remotePkgDir, resolved).replace(/\\/g, "/");
140
+ const coreEquiv = normalize(join(corePkgDir, relToRemote));
141
+ if (coreFiles.has(coreEquiv)) {
142
+ rewrites++;
143
+ return `${pre}@triflux/core/${relToRemote}${post}`;
144
+ }
145
+ return match;
146
+ };
147
+
148
+ const rewritten = content
149
+ .replace(/(from\s+['"])(\.[^'"]+)(['"])/g, rewriteRelativeSpecifier)
150
+ .replace(
151
+ /(import\(\s*['"])(\.[^'"]+)(['"]\s*\))/g,
152
+ rewriteRelativeSpecifier,
153
+ );
154
+ return { content: rewritten, rewrites };
155
+ }
156
+
126
157
  function rewriteRemoteImports(remotePkgDir, corePkgDir) {
127
158
  const coreFiles = buildFileSet(corePkgDir);
128
159
  let totalRewrites = 0;
129
160
 
130
161
  for (const filePath of walkMjs(remotePkgDir)) {
131
- let content = readFileSync(filePath, "utf8");
132
- let changed = false;
133
-
134
- const rewriteRelativeSpecifier = (match, pre, importPath, post) => {
135
- const resolved = normalize(join(dirname(filePath), importPath));
136
- // import 대상이 remote 패키지 내에 있으면 그대로 유지
137
- if (existsSync(resolved)) return match;
138
- // core 패키지에 동일 상대경로로 존재하는지 확인
139
- const relToRemote = relative(remotePkgDir, resolved).replace(/\\/g, "/");
140
- const coreEquiv = normalize(join(corePkgDir, relToRemote));
141
- if (coreFiles.has(coreEquiv)) {
142
- changed = true;
143
- totalRewrites++;
144
- return `${pre}@triflux/core/${relToRemote}${post}`;
145
- }
146
- return match;
147
- };
148
-
149
- content = content.replace(
150
- /(from\s+['"])(\.[^'"]+)(['"])/g,
151
- rewriteRelativeSpecifier,
162
+ const { content, rewrites } = rewriteRemoteSource(
163
+ readFileSync(filePath, "utf8"),
164
+ filePath,
165
+ remotePkgDir,
166
+ corePkgDir,
167
+ coreFiles,
152
168
  );
153
- content = content.replace(
154
- /(import\(\s*['"])(\.[^'"]+)(['"]\s*\))/g,
155
- rewriteRelativeSpecifier,
156
- );
157
-
158
- if (changed) writeFileSync(filePath, content);
169
+ if (rewrites > 0) writeFileSync(filePath, content);
170
+ totalRewrites += rewrites;
159
171
  }
160
172
 
161
173
  return totalRewrites;
@@ -19,7 +19,7 @@ import {
19
19
  } from "node:fs";
20
20
  import { dirname, join } from "node:path";
21
21
  import { fileURLToPath } from "node:url";
22
- import { CORE_ENTRIES } from "../pack.mjs";
22
+ import { CORE_ENTRIES, rewriteRemoteSource } from "../pack.mjs";
23
23
 
24
24
  const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
25
25
  const DEFAULT_REPO_ROOT = join(SCRIPT_DIR, "..", "..");
@@ -77,6 +77,7 @@ function walkRelFiles(root, skipRels = new Set()) {
77
77
  // the two drift classes that shipped silently in v10.33.0: a broken remote
78
78
  // import (relative specifier to a core-only module) and a stale non-JS asset
79
79
  // (the tray UI), neither of which the triflux/core byte-mirror check can see.
80
+ // .mjs 본문도 pack:remote 리라이트를 거친 root 와 비교한다. 해석만 보면 옛 구현이 남아도 OK 였다.
80
81
  const REMOTE_NON_MIRROR = new Set([
81
82
  "package.json",
82
83
  "package-lock.json",
@@ -99,16 +100,12 @@ function extractImportSpecifiers(content) {
99
100
  return specs;
100
101
  }
101
102
 
102
- function restoreRemoteCoreHubImports(content) {
103
- return content
104
- .replace(
105
- /(from\s+["'])@triflux\/core\/hub\/([^"']+)(["'])/g,
106
- "$1../../hub/$2$3",
107
- )
108
- .replace(
109
- /(import\(\s*["'])@triflux\/core\/hub\/([^"']+)(["']\s*\))/g,
110
- "$1../../hub/$2$3",
111
- );
103
+ function firstDiffLine(expected, actual) {
104
+ const a = expected.split("\n");
105
+ const b = actual.split("\n");
106
+ let i = 0;
107
+ while (a[i] === b[i]) i++;
108
+ return `line ${i + 1}: root ${JSON.stringify(a[i] ?? "<EOF>")} / remote ${JSON.stringify(b[i] ?? "<EOF>")}`;
112
109
  }
113
110
 
114
111
  function checkRemoteMirror(repoRoot) {
@@ -140,15 +137,21 @@ function checkRemoteMirror(repoRoot) {
140
137
  });
141
138
  }
142
139
  }
143
- if (rel.startsWith("scripts/lib/")) {
144
- const rootPath = join(repoRoot, rel);
145
- if (
146
- existsSync(rootPath) &&
147
- !readFileSync(rootPath).equals(
148
- Buffer.from(restoreRemoteCoreHubImports(content)),
149
- )
150
- ) {
151
- issues.push({ path: displayPath, kind: "remote-content-diff" });
140
+ const rootPath = join(repoRoot, rel);
141
+ if (existsSync(rootPath)) {
142
+ // pack:remote 와 같은 리라이트를 root 원본에 적용한 기대본과 비교한다.
143
+ const { content: expected } = rewriteRemoteSource(
144
+ readFileSync(rootPath, "utf8"),
145
+ remotePath,
146
+ remoteRoot,
147
+ coreRoot,
148
+ );
149
+ if (content !== expected) {
150
+ issues.push({
151
+ path: displayPath,
152
+ kind: "remote-content-diff",
153
+ detail: firstDiffLine(expected, content),
154
+ });
152
155
  }
153
156
  }
154
157
  } else {
@@ -329,13 +332,14 @@ function main() {
329
332
  }
330
333
  } else {
331
334
  console.log(
332
- "Mirror OK — packages/triflux + packages/core (byte) and packages/remote (imports + assets) match root",
335
+ "Mirror OK — packages/triflux + packages/core (byte) and packages/remote (import-normalized content) match root",
333
336
  );
334
337
  }
335
338
  } else {
336
339
  console.log(`Mirror mismatch (${result.issues.length} issues):`);
337
340
  for (const i of result.issues) {
338
341
  console.log(` ${i.kind.padEnd(18)} ${i.path}`);
342
+ if (i.detail) console.log(` ${i.detail}`);
339
343
  }
340
344
  if (result.fixed.length > 0) {
341
345
  console.log(`Fixed during run (${result.fixed.length}):`);
@@ -29,6 +29,8 @@ macOS의 iTerm2에서 로컬 tmux 세션을 `start`하면 리드가 있는 창
29
29
 
30
30
  새 세션 이름은 `<월>.<일> <주제>`로 짓는다. `start --name`을 생략하면 자동으로 만들고 `nameGenerated: true`를 보고한다. `--resume` 또는 `--resume-last`는 `--name`을 명시한 경우에만 이름을 적용한다. 승계 세션에는 기존 이름 뒤에 ` 2`, 이후 ` 3`을 붙인다. 이름 적용을 요청한 경우 결과의 `nameApplied: false`는 미적용을 뜻한다. agy의 `namePending: true`는 첫 일반 ask에서 적용할 이름이 보류됐다는 뜻이다. Codex `start`는 `/rename` 제출을 입력창이 빌 때까지 확인하고, 이름으로 찾은 thread UUID를 `threadId`로 돌려주며 tmux 세션 옵션 `@tfx_codex_thread`에 남긴다. 로컬 Codex `--resume-last`는 Codex가 고른 thread를 사후에 찾는다. 띄운 뒤 공유 app-server daemon에 로드된 같은 cwd의 thread 중 rollout에 그 시각 이후의 resume 기록(`thread_settings_applied`)이 생긴 것이 정확히 하나이고 1.5초 뒤에도 같을 때만 `threadId`로 쓴다. 이 확인은 5초 안에 끝난다. TUI가 daemon을 쓰지 않거나 같은 cwd에서 동시에 resume이 일어나면 `null`이다. 기존 Codex UDS thread는 `tfx-live rename --cli codex --transport uds --thread ID --name "<이름>"`으로 이름을 바꾼다.
31
31
 
32
+ Codex 폴더 신뢰 화면이나 Claude 프로젝트 MCP 승인 화면이 뜨면 `start`는 화면에 답하지 않고 `ready: false`, `blockedBy`(`codex-trust-folder` 또는 `claude-mcp-approval`), 할 일을 적은 `warning`을 반환한다. 세션은 남아 있으므로 tmux 세션에 붙어 직접 고른 뒤 지시를 보낸다.
33
+
32
34
  ## agy 세션
33
35
 
34
36
  ```bash
@@ -101,19 +103,20 @@ Claude와 Codex는 네이티브 goal을 우선 쓰고, goal-driven은 agy처럼
101
103
 
102
104
  ### 컨텍스트 판단
103
105
 
104
- 분모는 공식 모델 창이고 실행 한도가 더 작으면 그 한도 아래에서 운영한다. 아래 비율은 공식 권고가 아닌 **[추론] 운영값**이다. 모델 문서가 바뀌면 한도도 갱신한다.
106
+ Claude의 분모는 공식 모델 창과 실행 한도 중 작은 값이다. Codex의 분모는 rollout이 보고한 실행 창이고, 없을 때만 공식 창이다. 아래 비율은 공식 권고가 아닌 **[추론] 운영값**이다. 모델 문서가 바뀌면 한도도 갱신한다.
105
107
 
106
108
  | CLI | 준비와 경고 | compact | 신규 배정 중지·handoff | 전송 거부 |
107
109
  | --- | ---: | ---: | ---: | ---: |
108
110
  | Claude Code 1M 모델 | 60% | 75% | 85% | 90% |
109
- | Codex | 15% | 18% | 20% | 22% |
111
+ | Codex rollout 실행 창 | 60% | - | - | 85% |
112
+ | Codex 실행 창 없음(1.05M 분모) | 15% | 18% | 20% | 22% |
110
113
  | agy | 12% | 없음 | 15% | 18% |
111
114
 
112
- Claude는 85% 도달 시 바로 handoff를 지시한다. agy 행은 운영 지침이며 agy도 `tfx-live` 전송 대상이지만 컨텍스트 비율은 자동으로 읽지 못해 `null`로 보고하고 가드를 건너뛴다. `model_context_window`와 `model_auto_compact_token_limit`은 올리지 않는다.
115
+ Claude는 85% 도달 시 바로 handoff를 지시한다. Codex 실행 창 행의 compact와 handoff 비율은 아직 정하지 않았다. agy 행은 운영 지침이며 agy도 `tfx-live` 전송 대상이지만 컨텍스트 비율은 자동으로 읽지 못해 `null`로 보고하고 가드를 건너뛴다. `model_context_window`와 `model_auto_compact_token_limit`은 올리지 않는다.
113
116
 
114
- 결과에는 `estimatedContextTokens`, `contextLimitTokens`, `contextLimitSource`, `contextPct`가 포함된다. Claude 실행 한도는 `executionContextLimitTokens`로 별도 보고하며 `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`이면 200,000이다. 판정에는 공식 창과 실행 한도 중 작은 값을 쓴다. 한도를 모르면 비율은 `null`로 두고 경고만 한다. 사용량이 없는 `probe`는 `context: null`이다. 컨텍스트를 확인하려면 직접 `tfx-live probe`를 실행한다. `interrupt`, 자동 `ask`의 daemon probe, `stop --short`는 transcript를 읽지 않는다.
117
+ 결과에는 `estimatedContextTokens`, `contextLimitTokens`, `contextLimitSource`, `contextPct`가 포함된다. Claude 실행 한도는 `executionContextLimitTokens`로 별도 보고하며 `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`이면 200,000이다. Codex는 rollout `token_count`의 `model_context_window`를 `executionContextLimitTokens`로 보고한다. 이 값이 있으면 모델 표에 없는 모델이라도 그 창으로 판정하고, 없으면 1,050,000 표 값을 분모로 쓴다. 한도를 모르면 비율은 `null`로 두고 경고만 한다. 사용량이 없는 `probe`는 `context: null`이다. 컨텍스트를 확인하려면 직접 `tfx-live probe`를 실행한다. `interrupt`, 자동 `ask`의 daemon probe, `stop --short`는 transcript를 읽지 않는다.
115
118
 
116
- `ask`의 `--warn-context-pct`와 `--max-context-pct`는 경고·거부 비율을 덮어쓰며 0이면 해당 가드를 끈다. 기본값은 표의 경고·전송 거부 열이다. 거부 결과는 `status: "failed"`, `done: false`, `context-limit`와 컨텍스트 필드를 돌려준다. 자세한 근거와 실측은 [컨텍스트 정책 연구](../../docs/research/tfx-live-context-policy-2026-10.md)에 둔다.
119
+ `ask`의 `--warn-context-pct`와 `--max-context-pct`는 경고·거부 비율을 덮어쓰며 0이면 해당 가드를 끈다. 기본값은 표의 경고·전송 거부 열이다. Codex는 `executionContextLimitTokens`가 있으면 실행 창 행을, 없으면 1.05M 분모 행을 쓴다. 거부 결과는 `status: "failed"`, `done: false`, `context-limit`, 컨텍스트 필드와 적용한 거부 비율 `thresholdPct`를 돌려준다. 경고의 `thresholdPct`는 적용한 경고 비율이다. 자세한 근거와 실측은 [컨텍스트 정책 연구](../../docs/research/tfx-live-context-policy-2026-10.md)에 둔다.
117
120
 
118
121
  ### 수동 compact와 종료
119
122