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 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
- // process.ppid (bash) ์™€ grandparent (claude) ๋‘˜ ๋‹ค ์‹œ๋„
80
- const candidates = [process.ppid.toString()];
81
- const grand = getGrandparentPid(process.ppid);
82
- if (grand) candidates.push(grand);
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 = 'CCKR_SESSION_PPID=$PPID cckr apply 2>/dev/null || true';
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
- // SessionStart hook์ด CCKR_SESSION_PPID env๋กœ ํ˜ธ์ถœ
125
- // ํŒจ์น˜ ์ง์ „์˜ marker = ์ด ์„ธ์…˜์ด ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œํ•œ cli.js ๋ฒ„์ „
126
- const sessionPpid = process.env.CCKR_SESSION_PPID;
127
- if (sessionPpid && /^\d+$/.test(sessionPpid)) {
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: sessionPpid,
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-${sessionPpid}.json`, JSON.stringify(sessionInfo, null, 2));
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-kr",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "Claude Code ํ•œ๊ธ€ ํŒจ์น˜ CLI โ€” /btw โ†’ /๊ทผ๋ฐ, /help โ†’ /๋„์›€, /compact โ†’ /์••์ถ•",
5
5
  "main": "./index.js",
6
6
  "bin": {