@wooojin/forgen 0.6.4 → 0.6.5
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +9 -0
- package/dist/host/codex-hook-shim.d.ts +11 -0
- package/dist/host/codex-hook-shim.js +47 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/postinstall.js +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.5] — 2026-10-07 — Codex 훅 shim 전환을 설치 시 자동으로
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- `npm i -g @wooojin/forgen` 의 postinstall 이 `~/.codex/hooks.json` 에 이전 형식(node + 절대경로) forgen 훅이 있으면 **자동으로**
|
|
14
|
+
고정 shim 형식으로 전환한다 — `forgen install codex` 를 따로 칠 필요 없음. forgen 훅 명령만 제자리에서 바꾸고 그룹·훅 순서
|
|
15
|
+
(Codex trust 키), 사용자 훅, config.toml 은 그대로. 백업 `hooks.json.bak-pre-shim`. 실 hooks.json 복사본에서 22개 전환·실행 확인.
|
|
16
|
+
- Codex 의 trust 승인 자체는 자동화하지 않는다(사용자 승인을 대신 기록하면 Codex 보안 정책 우회). 전환 직후 `/hooks` 에서 마지막
|
|
17
|
+
1회만 승인하면 이후 업그레이드·nvm 전환은 재승인 불필요.
|
|
18
|
+
|
|
10
19
|
## [0.6.4] — 2026-10-07 — 설치·실행 편의: statusline 자동 등록 · Codex 훅 재승인 제거(고정 shim) · Node 22 함정 안내
|
|
11
20
|
|
|
12
21
|
### Added
|
|
@@ -29,3 +29,14 @@ export declare function writeCodexHookShim(pkgRoot: string, nodePath: string, sh
|
|
|
29
29
|
* 형태가 다르면(사용자 수정 등) 원문 그대로 반환.
|
|
30
30
|
*/
|
|
31
31
|
export declare function toShimCommand(command: string, shimPath: string): string;
|
|
32
|
+
export interface ShimMigrationResult {
|
|
33
|
+
status: 'migrated' | 'none' | 'no-hooks-file' | 'shim-foreign' | 'error';
|
|
34
|
+
rewritten: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* npm postinstall 용 자동 마이그레이션 (2026-10-07, 오너 피드백 "forgen install codex 도 자동으로").
|
|
38
|
+
* hooks.json 의 **이전 형식 forgen 훅 명령만** 제자리에서 shim 형식으로 바꾸고 shim 을 쓴다.
|
|
39
|
+
* 그룹/훅 순서(= Codex trust 키 `<event>:<groupIdx>:<hookIdx>`)·사용자 훅·config.toml 은 건드리지 않는다.
|
|
40
|
+
* Codex 의 trust 승인 자체는 자동화하지 않는다(보안 정책 우회가 되므로) — 전환 후 마지막 1회만 필요.
|
|
41
|
+
*/
|
|
42
|
+
export declare function migrateCodexHooksToShim(codexHome: string, pkgRoot: string, nodePath: string): ShimMigrationResult;
|
|
@@ -77,3 +77,50 @@ export function toShimCommand(command, shimPath) {
|
|
|
77
77
|
const rel = full.slice(root.length + 1);
|
|
78
78
|
return `"${shimPath}" "${rel}"${rest}`;
|
|
79
79
|
}
|
|
80
|
+
/** 이전 형식 forgen 훅 명령(`node "<…>/dist/host/codex-adapter.js" "<…>/dist/hooks/…"`)인가. */
|
|
81
|
+
const LEGACY_FORGEN_CMD_RE = /^node "[^"]*[\\/]dist[\\/]host[\\/]codex-adapter\.js" "[^"]*[\\/]dist[\\/]hooks[\\/][a-z][a-z0-9-]*\.js"/;
|
|
82
|
+
/**
|
|
83
|
+
* npm postinstall 용 자동 마이그레이션 (2026-10-07, 오너 피드백 "forgen install codex 도 자동으로").
|
|
84
|
+
* hooks.json 의 **이전 형식 forgen 훅 명령만** 제자리에서 shim 형식으로 바꾸고 shim 을 쓴다.
|
|
85
|
+
* 그룹/훅 순서(= Codex trust 키 `<event>:<groupIdx>:<hookIdx>`)·사용자 훅·config.toml 은 건드리지 않는다.
|
|
86
|
+
* Codex 의 trust 승인 자체는 자동화하지 않는다(보안 정책 우회가 되므로) — 전환 후 마지막 1회만 필요.
|
|
87
|
+
*/
|
|
88
|
+
export function migrateCodexHooksToShim(codexHome, pkgRoot, nodePath) {
|
|
89
|
+
const hooksPath = path.join(codexHome, 'hooks.json');
|
|
90
|
+
try {
|
|
91
|
+
if (!fs.existsSync(hooksPath))
|
|
92
|
+
return { status: 'no-hooks-file', rewritten: 0 };
|
|
93
|
+
const raw = fs.readFileSync(hooksPath, 'utf-8');
|
|
94
|
+
const file = JSON.parse(raw);
|
|
95
|
+
const shimPath = codexHookShimPath(codexHome);
|
|
96
|
+
let rewritten = 0;
|
|
97
|
+
for (const groups of Object.values(file.hooks ?? {})) {
|
|
98
|
+
for (const g of groups ?? []) {
|
|
99
|
+
for (const h of g.hooks ?? []) {
|
|
100
|
+
if (typeof h.command !== 'string' || !LEGACY_FORGEN_CMD_RE.test(h.command))
|
|
101
|
+
continue;
|
|
102
|
+
const next = toShimCommand(h.command, shimPath);
|
|
103
|
+
if (next !== h.command) {
|
|
104
|
+
h.command = next;
|
|
105
|
+
rewritten += 1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (rewritten === 0)
|
|
111
|
+
return { status: 'none', rewritten: 0 };
|
|
112
|
+
const w = writeCodexHookShim(pkgRoot, nodePath, shimPath);
|
|
113
|
+
if (w === 'foreign')
|
|
114
|
+
return { status: 'shim-foreign', rewritten: 0 };
|
|
115
|
+
if (w === 'error')
|
|
116
|
+
return { status: 'error', rewritten: 0 };
|
|
117
|
+
fs.copyFileSync(hooksPath, `${hooksPath}.bak-pre-shim`);
|
|
118
|
+
const tmp = `${hooksPath}.tmp-${process.pid}`;
|
|
119
|
+
fs.writeFileSync(tmp, `${JSON.stringify(file, null, 2)}\n`, 'utf-8');
|
|
120
|
+
fs.renameSync(tmp, hooksPath);
|
|
121
|
+
return { status: 'migrated', rewritten };
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return { status: 'error', rewritten: 0 };
|
|
125
|
+
}
|
|
126
|
+
}
|
package/package.json
CHANGED
package/plugin.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -1022,11 +1022,12 @@ async function main() {
|
|
|
1022
1022
|
const r = shimMod.writeCodexHookShim(PKG_ROOT, process.execPath, shimFile);
|
|
1023
1023
|
if (r === 'written') console.log('[forgen] Codex hook shim updated → no /hooks re-trust needed.');
|
|
1024
1024
|
} else {
|
|
1025
|
-
// 이전 형식(node + 절대경로) forgen
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
console.log(
|
|
1025
|
+
// 이전 형식(node + 절대경로) forgen 훅 → shim 형식으로 자동 전환 (forgen 훅 명령만, 순서·사용자 훅 보존).
|
|
1026
|
+
const codexHome = process.env.CODEX_HOME || join(HOME, '.codex');
|
|
1027
|
+
const r = shimMod.migrateCodexHooksToShim(codexHome, PKG_ROOT, process.execPath);
|
|
1028
|
+
if (r.status === 'migrated') {
|
|
1029
|
+
console.log(`[forgen] Codex: ${r.rewritten} forgen hooks switched to a stable shim (backup: hooks.json.bak-pre-shim).`);
|
|
1030
|
+
console.log('[forgen] Approve once in Codex (/hooks → trust all). Future upgrades and nvm switches keep the trust.');
|
|
1030
1031
|
}
|
|
1031
1032
|
}
|
|
1032
1033
|
} catch { /* dist 없음(dev) 또는 실패 — 다음 forgen install codex 가 처리 */ }
|