triflux 10.9.11 → 10.9.12
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.
|
@@ -83,6 +83,23 @@ async function runBlocking(stdinData) {
|
|
|
83
83
|
*/
|
|
84
84
|
function runDeferred(stdinData) {
|
|
85
85
|
const tasks = [
|
|
86
|
+
{
|
|
87
|
+
name: "session-stale-cleanup",
|
|
88
|
+
fn: async () => {
|
|
89
|
+
const mod = await importMod(join(SCRIPTS, "session-stale-cleanup.mjs"));
|
|
90
|
+
if (typeof mod.main === "function") mod.main();
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "claude-login-detect",
|
|
95
|
+
fn: async () => {
|
|
96
|
+
const mod = await importMod(join(SCRIPTS, "claude-login-detect.mjs"));
|
|
97
|
+
const result = mod.run?.();
|
|
98
|
+
if (result?.changed) {
|
|
99
|
+
return { stdout: `[claude-login] HUD 캐시 ${result.cleared}개 초기화됨\n` };
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
},
|
|
86
103
|
{
|
|
87
104
|
name: "mcp-gateway-ensure",
|
|
88
105
|
fn: async () => {
|
package/package.json
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* claude-login-detect.mjs — Claude 로그인(credentials 변경) 감지 + HUD 캐시 초기화
|
|
4
|
+
*
|
|
5
|
+
* ~/.claude/.credentials.json의 mtime을 추적하여 변경 시 HUD 관련 캐시를 삭제한다.
|
|
6
|
+
* SessionStart 훅에서 import하여 사용.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { existsSync, statSync, unlinkSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
|
|
13
|
+
const CREDS_PATH = join(homedir(), ".claude", ".credentials.json");
|
|
14
|
+
const STATE_PATH = join(homedir(), ".claude", "cache", "tfx-hub", "claude-login-mtime.json");
|
|
15
|
+
const HUD_CACHES = [
|
|
16
|
+
join(homedir(), ".claude", "cache", "claude-usage-cache.json"),
|
|
17
|
+
join(homedir(), ".claude", "cache", "codex-rate-limits-cache.json"),
|
|
18
|
+
join(homedir(), ".claude", "cache", "gemini-quota-cache.json"),
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
function readLastMtime() {
|
|
22
|
+
try {
|
|
23
|
+
if (!existsSync(STATE_PATH)) return 0;
|
|
24
|
+
return JSON.parse(readFileSync(STATE_PATH, "utf8")).mtime || 0;
|
|
25
|
+
} catch {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function writeLastMtime(mtime) {
|
|
31
|
+
try {
|
|
32
|
+
mkdirSync(dirname(STATE_PATH), { recursive: true });
|
|
33
|
+
writeFileSync(STATE_PATH, JSON.stringify({ mtime, updatedAt: Date.now() }));
|
|
34
|
+
} catch { /* best-effort */ }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function run() {
|
|
38
|
+
if (!existsSync(CREDS_PATH)) return { changed: false };
|
|
39
|
+
|
|
40
|
+
let currentMtime;
|
|
41
|
+
try {
|
|
42
|
+
currentMtime = statSync(CREDS_PATH).mtimeMs;
|
|
43
|
+
} catch {
|
|
44
|
+
return { changed: false };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const lastMtime = readLastMtime();
|
|
48
|
+
if (currentMtime === lastMtime) return { changed: false };
|
|
49
|
+
|
|
50
|
+
// credentials 변경 감지 → HUD 캐시 삭제
|
|
51
|
+
let cleared = 0;
|
|
52
|
+
for (const cachePath of HUD_CACHES) {
|
|
53
|
+
try {
|
|
54
|
+
if (existsSync(cachePath)) {
|
|
55
|
+
unlinkSync(cachePath);
|
|
56
|
+
cleared++;
|
|
57
|
+
}
|
|
58
|
+
} catch { /* ignore */ }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
writeLastMtime(currentMtime);
|
|
62
|
+
return { changed: true, cleared };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const isDirectRun =
|
|
66
|
+
process.argv[1] &&
|
|
67
|
+
import.meta.url.endsWith(
|
|
68
|
+
process.argv[1].replace(/\\/g, "/").split("/").pop(),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (isDirectRun) {
|
|
72
|
+
const result = run();
|
|
73
|
+
if (result.changed) {
|
|
74
|
+
console.error(`[claude-login-detect] credentials 변경 감지 — HUD 캐시 ${result.cleared}개 삭제`);
|
|
75
|
+
}
|
|
76
|
+
}
|