claude-code-kr 0.3.16 โ 0.3.17
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/bin/cc-kr.js +5 -23
- package/lib/findClaude.js +44 -0
- package/lib/hooks.js +1 -1
- package/lib/patcher.js +7 -6
- package/package.json +1 -1
package/bin/cc-kr.js
CHANGED
|
@@ -60,29 +60,12 @@ switch (cmd) {
|
|
|
60
60
|
console.log(`๐ฆ cckr ๋ฒ์ : ${pkg.version}`);
|
|
61
61
|
console.log(`๐ท CC ๋ฒ์ : ${s.ccVersion || '์ ์ ์์'}`);
|
|
62
62
|
|
|
63
|
-
// ํ์ฌ ์ธ์
์ in-memory ๋ฒ์
|
|
64
|
-
// !cckr status: claude (C) โ bash (PPID=C) โ node (PPID=bash)
|
|
65
|
-
// ์ธ์
ํ์ผ์ claude PID๋ก ์ ์ฅ๋๋ฏ๋ก grandparent๋ฅผ ์ฐพ์์ผ ํจ
|
|
66
|
-
function getGrandparentPid(pid) {
|
|
67
|
-
try {
|
|
68
|
-
if (process.platform === 'linux') {
|
|
69
|
-
const stat = fs.readFileSync(`/proc/${pid}/status`, 'utf8');
|
|
70
|
-
const m = stat.match(/^PPid:\s*(\d+)/m);
|
|
71
|
-
return m ? m[1] : null;
|
|
72
|
-
} else if (process.platform === 'darwin') {
|
|
73
|
-
return execSync(`ps -o ppid= -p ${pid}`, { encoding: 'utf8' }).trim();
|
|
74
|
-
}
|
|
75
|
-
} catch {}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
63
|
+
// ํ์ฌ ์ธ์
์ in-memory ๋ฒ์ โ ancestor ์ฒด์ธ์์ claude ์ฐพ๊ธฐ
|
|
78
64
|
try {
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
for (const pid of candidates) {
|
|
85
|
-
const sessionFile = `/tmp/cckr-session-${pid}.json`;
|
|
65
|
+
const { findClaudePid } = require('../lib/findClaude');
|
|
66
|
+
const claudePid = findClaudePid();
|
|
67
|
+
if (claudePid) {
|
|
68
|
+
const sessionFile = `/tmp/cckr-session-${claudePid}.json`;
|
|
86
69
|
if (fs.existsSync(sessionFile)) {
|
|
87
70
|
const session = JSON.parse(fs.readFileSync(sessionFile, 'utf8'));
|
|
88
71
|
const inSession = session.sessionCckrVersion;
|
|
@@ -92,7 +75,6 @@ switch (cmd) {
|
|
|
92
75
|
} else {
|
|
93
76
|
console.log(`๐ฏ ์ด ์ธ์
: cckr ${inSession} โ ๏ธ (๋์คํฌ: ${installed} โ ์ ์ธ์
์์ ์ ๋ณ๊ฒฝ ์ ์ฉ)`);
|
|
94
77
|
}
|
|
95
|
-
break;
|
|
96
78
|
}
|
|
97
79
|
}
|
|
98
80
|
} catch {}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// ์๊ธฐ ancestor ํ๋ก์ธ์ค ์ฒด์ธ์์ 'claude' ํ๋ก์ธ์ค๋ฅผ ์ฐพ์ PID ๋ฐํ.
|
|
2
|
+
// hook์ด๋ !cckr status๋ , ๋ ๋ค ํธ์ถ ์์ ์ ancestor์ claude๊ฐ ์์.
|
|
3
|
+
// ๊ฐ์ ํจ์๋ฅผ ์์ชฝ์ด ์ฌ์ฉํ๋ฉด ๊ฐ์ PID๋ฅผ ์ป์ โ ์ธ์
ํ์ผ ๋งค์นญ ๊ฐ๋ฅ.
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
function getParentPid(pid) {
|
|
8
|
+
try {
|
|
9
|
+
if (process.platform === 'linux') {
|
|
10
|
+
const stat = fs.readFileSync(`/proc/${pid}/status`, 'utf8');
|
|
11
|
+
const m = stat.match(/^PPid:\s*(\d+)/m);
|
|
12
|
+
return m ? parseInt(m[1], 10) : null;
|
|
13
|
+
} else if (process.platform === 'darwin') {
|
|
14
|
+
const out = execSync(`ps -o ppid= -p ${pid}`, { encoding: 'utf8' }).trim();
|
|
15
|
+
return out ? parseInt(out, 10) : null;
|
|
16
|
+
}
|
|
17
|
+
} catch {}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getProcessName(pid) {
|
|
22
|
+
try {
|
|
23
|
+
if (process.platform === 'linux') {
|
|
24
|
+
return fs.readFileSync(`/proc/${pid}/comm`, 'utf8').trim();
|
|
25
|
+
} else if (process.platform === 'darwin') {
|
|
26
|
+
return execSync(`ps -o comm= -p ${pid}`, { encoding: 'utf8' }).trim().split('/').pop();
|
|
27
|
+
}
|
|
28
|
+
} catch {}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ์๊ธฐ ancestor ์ฒด์ธ์์ 'claude' ํ๋ก์ธ์ค PID ์ฐพ๊ธฐ
|
|
33
|
+
// ๋ชป ์ฐพ์ผ๋ฉด null
|
|
34
|
+
function findClaudePid(startPid = process.ppid) {
|
|
35
|
+
let pid = startPid;
|
|
36
|
+
for (let i = 0; i < 12 && pid && pid > 1; i++) {
|
|
37
|
+
const name = getProcessName(pid);
|
|
38
|
+
if (name === 'claude') return pid;
|
|
39
|
+
pid = getParentPid(pid);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = { findClaudePid, getParentPid, getProcessName };
|
package/lib/hooks.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const os = require('os');
|
|
4
4
|
|
|
5
5
|
const SETTINGS_PATH = path.join(os.homedir(), '.claude', 'settings.json');
|
|
6
|
-
const HOOK_COMMAND = '
|
|
6
|
+
const HOOK_COMMAND = 'cckr apply 2>/dev/null || true';
|
|
7
7
|
const HOOK_ID = 'cckr-auto-patch';
|
|
8
8
|
|
|
9
9
|
function readSettings() {
|
package/lib/patcher.js
CHANGED
|
@@ -121,17 +121,18 @@ function apply(cliJs, { force = false } = {}) {
|
|
|
121
121
|
const ccVersion = getCliVersion(cliJs);
|
|
122
122
|
|
|
123
123
|
// ์ธ์
์์ ์์ ์บก์ฒ โ ๋ง์ปค ์คํต๋ณด๋ค ๋จผ์ (์คํต๋ผ๋ ์ธ์
์ ๋ณด๋ ํญ์ ๊ธฐ๋ก)
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
const
|
|
127
|
-
|
|
124
|
+
// ancestor ์ฒด์ธ์์ claude ํ๋ก์ธ์ค PID ์ฐพ๊ธฐ
|
|
125
|
+
// ๊ฐ์ PID๋ฅผ cckr status๊ฐ ์ฌ์ฉํ๋ฏ๋ก ๋งค์นญ๋จ
|
|
126
|
+
const { findClaudePid } = require('./findClaude');
|
|
127
|
+
const claudePid = findClaudePid();
|
|
128
|
+
if (claudePid) {
|
|
128
129
|
let preMarker = null;
|
|
129
130
|
try {
|
|
130
131
|
preMarker = JSON.parse(fs.readFileSync(markerPath, 'utf8'));
|
|
131
132
|
} catch {}
|
|
132
133
|
const sessionInfo = {
|
|
133
134
|
capturedAt: new Date().toISOString(),
|
|
134
|
-
claudePid:
|
|
135
|
+
claudePid: String(claudePid),
|
|
135
136
|
ccVersion: ccVersion,
|
|
136
137
|
// ์ด ์ธ์
์ด ๋ก๋ํ cli.js์ cckr ๋ฒ์ (ํจ์น ์ง์ )
|
|
137
138
|
// marker ์์ผ๋ฉด cli.js๊ฐ unpatched ์ํ์์
|
|
@@ -139,7 +140,7 @@ function apply(cliJs, { force = false } = {}) {
|
|
|
139
140
|
installedCckrVersion: pkg.version,
|
|
140
141
|
};
|
|
141
142
|
try {
|
|
142
|
-
fs.writeFileSync(`/tmp/cckr-session-${
|
|
143
|
+
fs.writeFileSync(`/tmp/cckr-session-${claudePid}.json`, JSON.stringify(sessionInfo, null, 2));
|
|
143
144
|
// 7์ผ ์ด์ ๋ ์ธ์
ํ์ผ ์ ๋ฆฌ
|
|
144
145
|
const tmpFiles = fs.readdirSync('/tmp').filter(f => /^cckr-session-\d+\.json$/.test(f));
|
|
145
146
|
const sevenDaysAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;
|