pattyeng 1.0.1 → 1.0.2
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/lib/install.js +38 -10
- package/package.json +1 -1
package/lib/install.js
CHANGED
|
@@ -26,8 +26,24 @@ const SA_USER = 'admin';
|
|
|
26
26
|
const SA_PASS = 'pattyeng0805@';
|
|
27
27
|
|
|
28
28
|
// ─── Platform ────────────────────────────────────────────────────────────────
|
|
29
|
-
const IS_WIN
|
|
30
|
-
const HOME
|
|
29
|
+
const IS_WIN = process.platform === 'win32';
|
|
30
|
+
const HOME = os.homedir();
|
|
31
|
+
|
|
32
|
+
// Detect current shell
|
|
33
|
+
function detectShell() {
|
|
34
|
+
if (IS_WIN) {
|
|
35
|
+
const shell = (process.env.COMSPEC || '').toLowerCase();
|
|
36
|
+
if (process.env.PSModulePath) return 'powershell';
|
|
37
|
+
if (shell.includes('cmd.exe')) return 'cmd';
|
|
38
|
+
return 'powershell'; // default windows fallback
|
|
39
|
+
}
|
|
40
|
+
const shell = process.env.SHELL || '';
|
|
41
|
+
if (shell.includes('zsh')) return 'zsh';
|
|
42
|
+
if (shell.includes('bash')) return 'bash';
|
|
43
|
+
if (shell.includes('fish')) return 'fish';
|
|
44
|
+
return 'bash'; // fallback
|
|
45
|
+
}
|
|
46
|
+
const SHELL = detectShell();
|
|
31
47
|
|
|
32
48
|
// ─── Logging ─────────────────────────────────────────────────────────────────
|
|
33
49
|
function log(msg) { process.stdout.write(msg + '\n'); }
|
|
@@ -97,15 +113,20 @@ function getRcFiles() {
|
|
|
97
113
|
const ps = path.join(HOME, 'Documents', 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1');
|
|
98
114
|
return [ps];
|
|
99
115
|
}
|
|
100
|
-
const files = [];
|
|
101
116
|
const zshrc = path.join(HOME, '.zshrc');
|
|
102
117
|
const bashrc = path.join(HOME, '.bashrc');
|
|
103
118
|
const bashProfile = path.join(HOME, '.bash_profile');
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
119
|
+
const fishConfig = path.join(HOME, '.config', 'fish', 'config.fish');
|
|
120
|
+
|
|
121
|
+
// Write only to the active shell's rc file
|
|
122
|
+
if (SHELL === 'zsh') return [zshrc];
|
|
123
|
+
if (SHELL === 'fish') return [fishConfig];
|
|
124
|
+
// bash: prefer .bashrc, fallback .bash_profile
|
|
125
|
+
if (fs.existsSync(bashrc)) return [bashrc];
|
|
126
|
+
if (fs.existsSync(bashProfile)) return [bashProfile];
|
|
127
|
+
// fallback: create .bashrc
|
|
128
|
+
fs.writeFileSync(bashrc, '');
|
|
129
|
+
return [bashrc];
|
|
109
130
|
}
|
|
110
131
|
|
|
111
132
|
function appendToRc(block) {
|
|
@@ -385,6 +406,8 @@ function writeApiKeyToRc(apiKey) {
|
|
|
385
406
|
} catch (e) {
|
|
386
407
|
warn('setx 실패: ' + e.message);
|
|
387
408
|
}
|
|
409
|
+
} else if (SHELL === 'fish') {
|
|
410
|
+
appendToRc(`# pattyeng — Patty Agent API Key\nset -Ux PATTY_AGENT_API_KEY "${apiKey}"`);
|
|
388
411
|
} else {
|
|
389
412
|
appendToRc(`# pattyeng — Patty Agent API Key\nexport PATTY_AGENT_API_KEY="${apiKey}"`);
|
|
390
413
|
}
|
|
@@ -429,7 +452,10 @@ function addCodexAlias() {
|
|
|
429
452
|
fs.writeFileSync(rc, content);
|
|
430
453
|
log(` → 기존 alias에 -p patty 추가: ${rc}`);
|
|
431
454
|
} else {
|
|
432
|
-
|
|
455
|
+
const aliasLine = SHELL === 'fish'
|
|
456
|
+
? '\n# pattyeng — codex -p patty alias\nalias codex \'codex -p patty\'\n'
|
|
457
|
+
: '\n# pattyeng — codex -p patty alias\nalias codex="codex -p patty"\n';
|
|
458
|
+
fs.appendFileSync(rc, aliasLine);
|
|
433
459
|
log(` → 새 alias 추가: ${rc}`);
|
|
434
460
|
}
|
|
435
461
|
}
|
|
@@ -453,7 +479,9 @@ ${username ? ` 👤 로그인: ${username}\n` : ''}
|
|
|
453
479
|
지금 터미널에 이 명령어 하나만 실행하세요:
|
|
454
480
|
${IS_WIN
|
|
455
481
|
? '\n > 터미널을 닫고 새로 열기\n (환경변수는 setx로 이미 영구 등록되었습니다)\n'
|
|
456
|
-
:
|
|
482
|
+
: SHELL === 'zsh' ? '\n $ exec zsh\n'
|
|
483
|
+
: SHELL === 'fish' ? '\n $ exec fish\n'
|
|
484
|
+
: '\n $ exec bash\n'}
|
|
457
485
|
💡 그 다음부터는 바로 사용 가능:
|
|
458
486
|
$ codex "안녕하세요!"
|
|
459
487
|
$ codex --session xyz "작업 시작"
|