@triflux/core 10.0.0-alpha.1 → 10.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.
Files changed (38) hide show
  1. package/hooks/hook-adaptive-collector.mjs +86 -0
  2. package/hooks/hook-manager.mjs +15 -2
  3. package/hooks/hook-registry.json +37 -4
  4. package/hooks/keyword-rules.json +2 -1
  5. package/hooks/mcp-config-watcher.mjs +2 -7
  6. package/hooks/safety-guard.mjs +37 -0
  7. package/hub/account-broker.mjs +251 -0
  8. package/hub/adaptive-diagnostic.mjs +323 -0
  9. package/hub/adaptive-inject.mjs +186 -0
  10. package/hub/adaptive-memory.mjs +163 -0
  11. package/hub/adaptive.mjs +143 -0
  12. package/hub/cli-adapter-base.mjs +89 -1
  13. package/hub/codex-adapter.mjs +12 -3
  14. package/hub/codex-compat.mjs +11 -78
  15. package/hub/codex-preflight.mjs +20 -1
  16. package/hub/gemini-adapter.mjs +1 -0
  17. package/hub/index.mjs +34 -0
  18. package/hub/lib/cache-guard.mjs +114 -0
  19. package/hub/lib/known-errors.json +72 -0
  20. package/hub/lib/memory-store.mjs +748 -0
  21. package/hub/lib/ssh-command.mjs +150 -0
  22. package/hub/lib/uuidv7.mjs +44 -0
  23. package/hub/memory-doctor.mjs +480 -0
  24. package/hub/middleware/request-logger.mjs +80 -0
  25. package/hub/router.mjs +1 -1
  26. package/hub/team-bridge.mjs +21 -19
  27. package/hud/constants.mjs +7 -0
  28. package/hud/context-monitor.mjs +403 -0
  29. package/hud/hud-qos-status.mjs +8 -4
  30. package/hud/providers/claude.mjs +5 -0
  31. package/hud/renderers.mjs +32 -14
  32. package/hud/utils.mjs +26 -0
  33. package/package.json +3 -2
  34. package/scripts/lib/claudemd-scanner.mjs +218 -0
  35. package/scripts/lib/handoff.mjs +171 -0
  36. package/scripts/lib/mcp-guard-engine.mjs +20 -6
  37. package/scripts/lib/skill-template.mjs +269 -0
  38. package/scripts/lib/claudemd-manager.mjs +0 -325
@@ -0,0 +1,269 @@
1
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
+ import { basename, extname, join, relative } from "node:path";
3
+
4
+ const IF_TAG_RE = /{{\s*(#if\s+([A-Za-z0-9_.-]+)|\/if)\s*}}/g;
5
+ const INCLUDE_RE = /{{>\s*([A-Za-z0-9_./-]+)\s*}}/g;
6
+ const VARIABLE_RE = /{{\s*([A-Za-z0-9_.-]+)\s*}}/g;
7
+ const FRONTMATTER_RE = /^---\r?\n(?:([\s\S]*?)\r?\n)?---\r?\n?/;
8
+
9
+ function isTruthy(value) {
10
+ if (typeof value === "string") return value.trim().length > 0;
11
+ return Boolean(value);
12
+ }
13
+
14
+ function normalizeVariable(context, key) {
15
+ if (Object.prototype.hasOwnProperty.call(context, key)) return context[key];
16
+ const upper = key.toUpperCase();
17
+ if (Object.prototype.hasOwnProperty.call(context, upper)) return context[upper];
18
+ return undefined;
19
+ }
20
+
21
+ function parseBoolean(raw) {
22
+ if (typeof raw !== "string") return undefined;
23
+ if (raw === "true") return true;
24
+ if (raw === "false") return false;
25
+ return undefined;
26
+ }
27
+
28
+ function parseScalar(raw) {
29
+ if (raw == null) return "";
30
+ const value = raw.trim();
31
+ if (!value) return "";
32
+ if (
33
+ (value.startsWith('"') && value.endsWith('"')) ||
34
+ (value.startsWith("'") && value.endsWith("'"))
35
+ ) {
36
+ return value.slice(1, -1);
37
+ }
38
+ const bool = parseBoolean(value);
39
+ return bool ?? value;
40
+ }
41
+
42
+ function parseMultilineValue(lines, startIndex, marker) {
43
+ const fold = marker.startsWith(">");
44
+ const chunks = [];
45
+ let index = startIndex;
46
+
47
+ while (index + 1 < lines.length && /^\s+/.test(lines[index + 1])) {
48
+ index += 1;
49
+ chunks.push(lines[index].replace(/^\s+/, ""));
50
+ }
51
+
52
+ return {
53
+ index,
54
+ value: fold ? chunks.join(" ").trim() : chunks.join("\n").trim(),
55
+ };
56
+ }
57
+
58
+ function parseListValue(lines, startIndex) {
59
+ const items = [];
60
+ let index = startIndex;
61
+
62
+ while (index + 1 < lines.length) {
63
+ const nextLine = lines[index + 1];
64
+ const match = nextLine.match(/^\s*-\s+(.*)$/);
65
+ if (match) {
66
+ index += 1;
67
+ items.push(parseScalar(match[1]));
68
+ continue;
69
+ }
70
+ if (/^\s*$/.test(nextLine)) {
71
+ index += 1;
72
+ continue;
73
+ }
74
+ break;
75
+ }
76
+
77
+ return { index, value: items };
78
+ }
79
+
80
+ function parseFrontmatterBlock(block) {
81
+ const lines = block.split(/\r?\n/);
82
+ const data = {};
83
+
84
+ for (let i = 0; i < lines.length; i += 1) {
85
+ const line = lines[i];
86
+ const match = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
87
+ if (!match) continue;
88
+
89
+ const [, rawKey, rawValue] = match;
90
+ const key = rawKey.trim();
91
+ const value = rawValue.trim();
92
+
93
+ if (value === ">" || value === "|" || value === ">-" || value === "|-") {
94
+ const parsed = parseMultilineValue(lines, i, value);
95
+ data[key] = parsed.value;
96
+ i = parsed.index;
97
+ continue;
98
+ }
99
+
100
+ if (!value) {
101
+ const parsed = parseListValue(lines, i);
102
+ if (parsed.index !== i) {
103
+ data[key] = parsed.value;
104
+ i = parsed.index;
105
+ continue;
106
+ }
107
+ }
108
+
109
+ data[key] = parseScalar(value);
110
+ }
111
+
112
+ return data;
113
+ }
114
+
115
+ function evaluateConditionals(source, context) {
116
+ const matcher = new RegExp(IF_TAG_RE.source, "g");
117
+
118
+ function walk(startIndex, nested) {
119
+ let output = "";
120
+ let cursor = startIndex;
121
+
122
+ while (true) {
123
+ const found = matcher.exec(source);
124
+ if (!found) {
125
+ if (nested) throw new Error("Unclosed {{#if ...}} block in template");
126
+ output += source.slice(cursor);
127
+ return { output, index: source.length };
128
+ }
129
+
130
+ output += source.slice(cursor, found.index);
131
+ cursor = matcher.lastIndex;
132
+
133
+ const directive = found[1];
134
+ const flag = found[2];
135
+ if (directive.startsWith("#if")) {
136
+ const nestedResult = walk(cursor, true);
137
+ cursor = nestedResult.index;
138
+ matcher.lastIndex = cursor;
139
+ if (isTruthy(normalizeVariable(context, flag))) {
140
+ output += nestedResult.output;
141
+ }
142
+ continue;
143
+ }
144
+
145
+ if (!nested) {
146
+ throw new Error("Unexpected {{/if}} without matching {{#if ...}}");
147
+ }
148
+ return { output, index: cursor };
149
+ }
150
+ }
151
+
152
+ return walk(0, false).output;
153
+ }
154
+
155
+ function renderIncludes(source, context, partials, includeStack) {
156
+ return source.replace(INCLUDE_RE, (_full, partialName) => {
157
+ const partial = partials[partialName];
158
+ if (partial == null) {
159
+ throw new Error(`Missing partial: ${partialName}`);
160
+ }
161
+ if (includeStack.includes(partialName)) {
162
+ const chain = [...includeStack, partialName].join(" -> ");
163
+ throw new Error(`Circular partial include: ${chain}`);
164
+ }
165
+ return renderWithContext(partial, context, partials, [...includeStack, partialName]);
166
+ });
167
+ }
168
+
169
+ function renderVariables(source, context) {
170
+ return source.replace(VARIABLE_RE, (full, key) => {
171
+ const value = normalizeVariable(context, key);
172
+ if (value == null) {
173
+ throw new Error(`Missing template variable: ${key}`);
174
+ }
175
+ return String(value);
176
+ });
177
+ }
178
+
179
+ function renderWithContext(source, context, partials, includeStack = []) {
180
+ const afterIf = evaluateConditionals(source, context);
181
+ const afterInclude = renderIncludes(afterIf, context, partials, includeStack);
182
+ return renderVariables(afterInclude, context);
183
+ }
184
+
185
+ function readAllTemplateFiles(rootDir, currentDir = rootDir) {
186
+ if (!rootDir || !existsSync(rootDir)) return [];
187
+
188
+ const entries = readdirSync(currentDir, { withFileTypes: true }).sort((left, right) =>
189
+ left.name.localeCompare(right.name),
190
+ );
191
+ const files = [];
192
+
193
+ for (const entry of entries) {
194
+ const fullPath = join(currentDir, entry.name);
195
+ if (entry.isDirectory()) {
196
+ files.push(...readAllTemplateFiles(rootDir, fullPath));
197
+ continue;
198
+ }
199
+
200
+ if (!entry.isFile()) continue;
201
+ if (!entry.name.endsWith(".md") && !entry.name.endsWith(".tmpl")) continue;
202
+
203
+ const relativePath = relative(rootDir, fullPath).replace(/\\/g, "/");
204
+ const content = readFileSync(fullPath, "utf8");
205
+ files.push({ fullPath, relativePath, content });
206
+ }
207
+
208
+ return files;
209
+ }
210
+
211
+ function setPartial(partials, key, value) {
212
+ if (!key) return;
213
+ if (!Object.prototype.hasOwnProperty.call(partials, key)) {
214
+ partials[key] = value;
215
+ }
216
+ }
217
+
218
+ export function parseFrontmatter(source) {
219
+ const match = source.match(FRONTMATTER_RE);
220
+ if (!match) return { data: {}, body: source };
221
+
222
+ const data = parseFrontmatterBlock(match[1] ?? "");
223
+ const body = source.slice(match[0].length);
224
+ return { data, body };
225
+ }
226
+
227
+ export function buildSkillTemplateContext({ frontmatter = {}, skillDirName = "" } = {}) {
228
+ const context = { ...frontmatter };
229
+ const skillName = String(frontmatter.name || skillDirName || "").trim();
230
+ const skillDescription = String(frontmatter.description || "").trim();
231
+
232
+ let deep = frontmatter.DEEP ?? frontmatter.deep;
233
+ if (typeof deep === "string") {
234
+ const parsed = parseBoolean(deep.trim().toLowerCase());
235
+ deep = parsed ?? deep;
236
+ }
237
+ if (typeof deep !== "boolean") {
238
+ deep = /(^|[-_])deep($|[-_])/i.test(skillName);
239
+ }
240
+
241
+ context.SKILL_NAME = skillName;
242
+ context.SKILL_DESCRIPTION = skillDescription;
243
+ context.DEEP = deep;
244
+ return context;
245
+ }
246
+
247
+ export function loadTemplatePartials(partialsDir) {
248
+ const files = readAllTemplateFiles(partialsDir);
249
+ const partials = {};
250
+
251
+ for (const file of files) {
252
+ const extension = extname(file.relativePath);
253
+ const withoutExt = extension
254
+ ? file.relativePath.slice(0, -extension.length)
255
+ : file.relativePath;
256
+ const normalized = withoutExt.replace(/\\/g, "/");
257
+ const base = basename(normalized);
258
+
259
+ setPartial(partials, normalized, file.content);
260
+ setPartial(partials, base, file.content);
261
+ }
262
+
263
+ return partials;
264
+ }
265
+
266
+ export function renderSkillTemplate(template, context = {}, options = {}) {
267
+ const { partials = {} } = options;
268
+ return renderWithContext(template, context, partials);
269
+ }
@@ -1,325 +0,0 @@
1
- /**
2
- * claudemd-manager.mjs — TFX CLAUDE.md 섹션 관리
3
- *
4
- * OMC 패턴 차용: <!-- TFX:START --> / <!-- TFX:END --> 마커 기반.
5
- * setup/update 시 마커 사이 내용을 템플릿으로 교체.
6
- * doctor 시 stale 감지 + 직접 호출 충돌 경고.
7
- */
8
-
9
- import { readFileSync, writeFileSync, existsSync } from "node:fs";
10
- import { homedir } from "node:os";
11
- import { join, dirname } from "node:path";
12
- import { fileURLToPath } from "node:url";
13
-
14
- const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
15
- const TEMPLATE_PATH = join(SCRIPT_DIR, "..", "templates", "claudemd-tfx-section.md");
16
-
17
- const TFX_START = "<!-- TFX:START -->";
18
- const TFX_END = "<!-- TFX:END -->";
19
- const TFX_VERSION_RE = /<!-- TFX:VERSION:([\d.]+) -->/;
20
-
21
- // 직접 호출 패턴 (TFX 블록 외부에서 발견되면 충돌)
22
- const DIRECT_CALL_PATTERNS = [
23
- /codex\s+exec\s+--dangerously/,
24
- /codex\s+--profile\s+\w+\s+exec/,
25
- /gemini\s+-[yp]\s/,
26
- /codex\s+exec\s+review/,
27
- ];
28
-
29
- /**
30
- * 현재 triflux 버전을 package.json에서 읽기
31
- */
32
- export function getPackageVersion() {
33
- try {
34
- const pkgPath = join(SCRIPT_DIR, "..", "..", "package.json");
35
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
36
- return pkg.version || "0.0.0";
37
- } catch {
38
- return "0.0.0";
39
- }
40
- }
41
-
42
- /**
43
- * 템플릿 파일 읽기
44
- */
45
- export function loadTemplate() {
46
- try {
47
- return readFileSync(TEMPLATE_PATH, "utf8").trim();
48
- } catch (error) {
49
- throw new Error(`TFX 템플릿 로드 실패: ${TEMPLATE_PATH}: ${error.message}`);
50
- }
51
- }
52
-
53
- /**
54
- * CLAUDE.md에서 TFX 섹션 추출
55
- * @returns {{ found: boolean, version: string|null, content: string|null, startIdx: number, endIdx: number }}
56
- */
57
- export function readSection(filePath) {
58
- if (!existsSync(filePath)) {
59
- return { found: false, version: null, content: null, startIdx: -1, endIdx: -1 };
60
- }
61
-
62
- const raw = readFileSync(filePath, "utf8");
63
- const startIdx = raw.indexOf(TFX_START);
64
- const endIdx = raw.indexOf(TFX_END);
65
-
66
- if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx) {
67
- return { found: false, version: null, content: null, startIdx: -1, endIdx: -1 };
68
- }
69
-
70
- const section = raw.slice(startIdx, endIdx + TFX_END.length);
71
- const versionMatch = section.match(TFX_VERSION_RE);
72
- const version = versionMatch ? versionMatch[1] : null;
73
-
74
- return { found: true, version, content: section, startIdx, endIdx: endIdx + TFX_END.length };
75
- }
76
-
77
- /**
78
- * TFX 섹션 쓰기/교체
79
- * - 기존 마커가 있으면 교체
80
- * - 없으면 OMC:END 뒤에 삽입 (없으면 파일 끝)
81
- */
82
- export function writeSection(filePath, options = {}) {
83
- const version = options.version || getPackageVersion();
84
- const template = options.template || loadTemplate();
85
-
86
- const block = [
87
- TFX_START,
88
- `<!-- TFX:VERSION:${version} -->`,
89
- template,
90
- TFX_END,
91
- ].join("\n");
92
-
93
- if (!existsSync(filePath)) {
94
- writeFileSync(filePath, block + "\n", "utf8");
95
- return { action: "created", version };
96
- }
97
-
98
- const raw = readFileSync(filePath, "utf8");
99
- const existing = readSection(filePath);
100
-
101
- if (existing.found) {
102
- // 기존 TFX 블록 교체
103
- const before = raw.slice(0, existing.startIdx);
104
- const after = raw.slice(existing.endIdx);
105
- writeFileSync(filePath, before + block + after, "utf8");
106
- return { action: "updated", oldVersion: existing.version, version };
107
- }
108
-
109
- // OMC:END 뒤에 삽입
110
- const omcEndIdx = raw.indexOf("<!-- OMC:END -->");
111
- if (omcEndIdx !== -1) {
112
- const insertAt = omcEndIdx + "<!-- OMC:END -->".length;
113
- const before = raw.slice(0, insertAt);
114
- const after = raw.slice(insertAt);
115
- writeFileSync(filePath, before + "\n" + block + after, "utf8");
116
- return { action: "inserted_after_omc", version };
117
- }
118
-
119
- // 파일 끝에 추가
120
- const separator = raw.endsWith("\n") ? "" : "\n";
121
- writeFileSync(filePath, raw + separator + block + "\n", "utf8");
122
- return { action: "appended", version };
123
- }
124
-
125
- /**
126
- * TFX 섹션 제거
127
- */
128
- export function removeSection(filePath) {
129
- if (!existsSync(filePath)) return { action: "no_file" };
130
-
131
- const raw = readFileSync(filePath, "utf8");
132
- const existing = readSection(filePath);
133
-
134
- if (!existing.found) return { action: "not_found" };
135
-
136
- const before = raw.slice(0, existing.startIdx);
137
- const after = raw.slice(existing.endIdx);
138
- // 연속 빈줄 정리
139
- const cleaned = (before + after).replace(/\n{3,}/g, "\n\n");
140
- writeFileSync(filePath, cleaned, "utf8");
141
- return { action: "removed", oldVersion: existing.version };
142
- }
143
-
144
- /**
145
- * TFX 블록 외부에서 직접 CLI 호출 감지
146
- * @returns {{ conflicts: Array<{line: number, text: string, pattern: string}> }}
147
- */
148
- export function detectConflicts(filePath) {
149
- if (!existsSync(filePath)) return { conflicts: [] };
150
-
151
- const raw = readFileSync(filePath, "utf8");
152
- const existing = readSection(filePath);
153
-
154
- // TFX 블록 내부 제거 후 검사
155
- let textOutside = raw;
156
- if (existing.found) {
157
- textOutside = raw.slice(0, existing.startIdx) + raw.slice(existing.endIdx);
158
- }
159
-
160
- const lines = textOutside.split("\n");
161
- const conflicts = [];
162
-
163
- for (let i = 0; i < lines.length; i++) {
164
- const line = lines[i];
165
- // 코드블록 안은 무시
166
- if (line.trim().startsWith("```")) continue;
167
- // 주석/금지 문맥 무시
168
- if (/금지|차단|NEVER|prohibit|block/i.test(line)) continue;
169
-
170
- for (const pattern of DIRECT_CALL_PATTERNS) {
171
- if (pattern.test(line)) {
172
- conflicts.push({
173
- line: i + 1,
174
- text: line.trim(),
175
- pattern: pattern.source,
176
- });
177
- }
178
- }
179
- }
180
-
181
- return { conflicts };
182
- }
183
-
184
- /**
185
- * Doctor 진단 — 종합 검사
186
- * @returns {{ status: "ok"|"warn"|"error", issues: string[] }}
187
- */
188
- export function diagnose(filePath) {
189
- const issues = [];
190
-
191
- if (!existsSync(filePath)) {
192
- return { status: "error", issues: ["CLAUDE.md 파일 없음: " + filePath] };
193
- }
194
-
195
- const section = readSection(filePath);
196
- if (!section.found) {
197
- issues.push("TFX 섹션 없음 — `tfx setup` 또는 `/tfx-setup`으로 추가 필요");
198
- } else {
199
- const currentVersion = getPackageVersion();
200
- if (section.version !== currentVersion) {
201
- issues.push(`TFX 섹션 stale: ${section.version} → ${currentVersion} (업데이트 필요)`);
202
- }
203
- }
204
-
205
- const { conflicts } = detectConflicts(filePath);
206
- for (const c of conflicts) {
207
- issues.push(`L${c.line}: 직접 CLI 호출 감지 — "${c.text.slice(0, 60)}..."`);
208
- }
209
-
210
- if (issues.length === 0) return { status: "ok", issues: [] };
211
- if (issues.some((i) => i.includes("stale") || i.includes("없음"))) return { status: "error", issues };
212
- return { status: "warn", issues };
213
- }
214
-
215
- // ── 기존 유저 마이그레이션 ──
216
-
217
- // 레거시 <user_cli_routing> 마커 없는 섹션 감지
218
- const LEGACY_PATTERNS = [
219
- /<user_cli_routing>/,
220
- /Codex Pro 무료 기간/,
221
- /codex exec --dangerously-bypass.*skip-git-repo-check/,
222
- /OMC 에이전트 → CLI 매핑/,
223
- /Spark 가드레일/,
224
- ];
225
-
226
- /**
227
- * 레거시 CLI 라우팅 섹션 감지
228
- * @returns {{ found: boolean, startIdx: number, endIdx: number, markers: string[] }}
229
- */
230
- export function detectLegacy(filePath) {
231
- if (!existsSync(filePath)) return { found: false, startIdx: -1, endIdx: -1, markers: [] };
232
-
233
- const raw = readFileSync(filePath, "utf8");
234
- const markers = [];
235
-
236
- for (const p of LEGACY_PATTERNS) {
237
- if (p.test(raw)) markers.push(p.source);
238
- }
239
-
240
- if (markers.length === 0) return { found: false, startIdx: -1, endIdx: -1, markers: [] };
241
-
242
- // <user_cli_routing> ... </user_cli_routing> 블록 범위 찾기
243
- const startTag = raw.indexOf("<user_cli_routing>");
244
- const endTag = raw.indexOf("</user_cli_routing>");
245
-
246
- if (startTag !== -1 && endTag !== -1) {
247
- return { found: true, startIdx: startTag, endIdx: endTag + "</user_cli_routing>".length, markers };
248
- }
249
-
250
- return { found: true, startIdx: -1, endIdx: -1, markers };
251
- }
252
-
253
- /**
254
- * 레거시 섹션을 TFX 관리 블록으로 마이그레이션
255
- * 1. 레거시 <user_cli_routing> 제거
256
- * 2. TFX 마커 블록 삽입
257
- * @returns {{ action: string, removed: string[], version: string }}
258
- */
259
- export function migrate(filePath, options = {}) {
260
- const legacy = detectLegacy(filePath);
261
- const existing = readSection(filePath);
262
-
263
- // 이미 TFX 마커가 있고 레거시가 없으면 스킵
264
- if (existing.found && !legacy.found) {
265
- return { action: "already_managed", removed: [], version: existing.version };
266
- }
267
-
268
- const raw = readFileSync(filePath, "utf8");
269
- let cleaned = raw;
270
-
271
- const removed = [];
272
-
273
- // 1. 레거시 <user_cli_routing> 블록 제거
274
- if (legacy.found && legacy.startIdx !== -1) {
275
- // <!-- USER OVERRIDES --> 코멘트도 같이 제거
276
- let removeStart = legacy.startIdx;
277
- const userOverrideComment = "<!-- USER OVERRIDES";
278
- const commentIdx = cleaned.lastIndexOf(userOverrideComment, removeStart);
279
- if (commentIdx !== -1 && removeStart - commentIdx < 200) {
280
- removeStart = commentIdx;
281
- }
282
-
283
- const before = cleaned.slice(0, removeStart);
284
- const after = cleaned.slice(legacy.endIdx);
285
- cleaned = (before + after).replace(/\n{3,}/g, "\n\n");
286
- removed.push("<user_cli_routing> block");
287
- }
288
-
289
- // 2. TFX 블록이 있으면 제거 (교체 위해)
290
- if (existing.found) {
291
- const s = readSection(filePath);
292
- if (s.found) {
293
- cleaned = cleaned.slice(0, cleaned.indexOf(TFX_START)) +
294
- cleaned.slice(cleaned.indexOf(TFX_END) + TFX_END.length);
295
- cleaned = cleaned.replace(/\n{3,}/g, "\n\n");
296
- removed.push("old TFX block");
297
- }
298
- }
299
-
300
- // 3. 정리된 파일 저장
301
- writeFileSync(filePath, cleaned, "utf8");
302
-
303
- // 4. 새 TFX 블록 삽입
304
- const result = writeSection(filePath, options);
305
-
306
- return { action: "migrated", removed, version: result.version };
307
- }
308
-
309
- /**
310
- * 모든 CLAUDE.md 파일 스캔 (전역 + 프로젝트)
311
- * @returns {string[]} 경로 목록
312
- */
313
- export function findAllClaudeMdPaths() {
314
- const paths = [];
315
-
316
- // 전역
317
- const globalPath = join(homedir(), ".claude", "CLAUDE.md");
318
- if (existsSync(globalPath)) paths.push(globalPath);
319
-
320
- // 현재 프로젝트
321
- const cwdPath = join(process.cwd(), "CLAUDE.md");
322
- if (existsSync(cwdPath)) paths.push(cwdPath);
323
-
324
- return paths;
325
- }