@wooojin/forgen 0.6.8 → 0.6.10
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 +27 -0
- package/README.ja.md +15 -10
- package/README.ko.md +15 -10
- package/README.md +19 -14
- package/README.zh.md +13 -8
- package/dist/checks/dangerous-response-pattern.d.ts +2 -1
- package/dist/checks/dangerous-response-pattern.js +27 -3
- package/dist/cli.js +133 -17
- package/dist/core/auto-compound-runner.js +502 -397
- package/dist/core/block-cli.js +7 -3
- package/dist/core/compound-consent.d.ts +18 -0
- package/dist/core/compound-consent.js +101 -6
- package/dist/core/compound-sweep-cli.d.ts +16 -0
- package/dist/core/compound-sweep-cli.js +67 -5
- package/dist/core/config-hooks.js +28 -10
- package/dist/core/correction-signals.d.ts +9 -0
- package/dist/core/correction-signals.js +37 -0
- package/dist/core/dev-cli.d.ts +1 -2
- package/dist/core/dev-cli.js +9 -28
- package/dist/core/doctor-verify.d.ts +35 -0
- package/dist/core/doctor-verify.js +502 -0
- package/dist/core/doctor.d.ts +4 -6
- package/dist/core/doctor.js +103 -184
- package/dist/core/explain-cli.js +8 -0
- package/dist/core/extraction-haiku.d.ts +64 -0
- package/dist/core/extraction-haiku.js +208 -0
- package/dist/core/extraction-queue.d.ts +68 -0
- package/dist/core/extraction-queue.js +300 -0
- package/dist/core/flow-status.d.ts +93 -0
- package/dist/core/flow-status.js +368 -0
- package/dist/core/harness.js +14 -42
- package/dist/core/inspect-cli.js +37 -13
- package/dist/core/lifecycle-classifier.d.ts +5 -1
- package/dist/core/lifecycle-classifier.js +13 -2
- package/dist/core/migrate-cli.d.ts +1 -1
- package/dist/core/migrate-cli.js +11 -11
- package/dist/core/migrate-tenetx.d.ts +1 -1
- package/dist/core/migrate-tenetx.js +2 -2
- package/dist/core/node-engine.d.ts +3 -0
- package/dist/core/node-engine.js +8 -0
- package/dist/core/observability-store.d.ts +15 -0
- package/dist/core/observability-store.js +73 -0
- package/dist/core/paths.d.ts +2 -0
- package/dist/core/paths.js +2 -0
- package/dist/core/rendered-rules-manifest.d.ts +7 -1
- package/dist/core/rendered-rules-manifest.js +45 -1
- package/dist/core/session-store.d.ts +13 -11
- package/dist/core/session-store.js +103 -119
- package/dist/core/settings-injector.d.ts +5 -2
- package/dist/core/settings-injector.js +21 -88
- package/dist/core/spawn.d.ts +9 -1
- package/dist/core/spawn.js +33 -33
- package/dist/core/stats-cli.d.ts +7 -0
- package/dist/core/stats-cli.js +66 -93
- package/dist/core/status-cli.d.ts +1 -1
- package/dist/core/status-cli.js +23 -4
- package/dist/core/statusline-cli.js +5 -0
- package/dist/core/statusline-install.d.ts +10 -2
- package/dist/core/statusline-install.js +27 -4
- package/dist/core/transcript-summary.d.ts +84 -9
- package/dist/core/transcript-summary.js +283 -49
- package/dist/core/uninstall.d.ts +4 -0
- package/dist/core/uninstall.js +68 -36
- package/dist/core/v1-bootstrap.d.ts +1 -1
- package/dist/core/v1-bootstrap.js +38 -9
- package/dist/engine/acted-on-evidence.d.ts +8 -0
- package/dist/engine/acted-on-evidence.js +38 -0
- package/dist/engine/block-judge.d.ts +3 -1
- package/dist/engine/block-judge.js +4 -3
- package/dist/engine/compound-cli.d.ts +26 -2
- package/dist/engine/compound-cli.js +143 -19
- package/dist/engine/compound-lifecycle.d.ts +36 -2
- package/dist/engine/compound-lifecycle.js +131 -11
- package/dist/engine/compound-loop.d.ts +4 -0
- package/dist/engine/compound-loop.js +93 -18
- package/dist/engine/correction-cluster-runner.d.ts +11 -1
- package/dist/engine/correction-cluster-runner.js +39 -15
- package/dist/engine/correction-clustering.d.ts +11 -0
- package/dist/engine/correction-clustering.js +20 -3
- package/dist/engine/lifecycle/lifecycle-cli.js +10 -3
- package/dist/engine/lifecycle/meta-reclassifier.d.ts +9 -0
- package/dist/engine/lifecycle/meta-reclassifier.js +15 -3
- package/dist/engine/lifecycle/orchestrator.js +3 -2
- package/dist/engine/lifecycle/signals.d.ts +19 -1
- package/dist/engine/lifecycle/signals.js +61 -2
- package/dist/engine/lifecycle/trigger-t1-correction.d.ts +1 -1
- package/dist/engine/lifecycle/trigger-t1-correction.js +9 -28
- package/dist/engine/lifecycle/trigger-t5-conflict.d.ts +8 -0
- package/dist/engine/lifecycle/trigger-t5-conflict.js +60 -2
- package/dist/engine/roi-demotion.d.ts +11 -0
- package/dist/engine/roi-demotion.js +50 -8
- package/dist/engine/rule-detectability.d.ts +39 -0
- package/dist/engine/rule-detectability.js +66 -0
- package/dist/engine/rule-project-cli.d.ts +25 -0
- package/dist/engine/rule-project-cli.js +148 -0
- package/dist/engine/rule-recovery-cli.d.ts +21 -0
- package/dist/engine/rule-recovery-cli.js +265 -0
- package/dist/engine/rule-toggle-cli.d.ts +14 -2
- package/dist/engine/rule-toggle-cli.js +94 -6
- package/dist/engine/skill-promoter.d.ts +14 -8
- package/dist/engine/skill-promoter.js +57 -85
- package/dist/engine/solution-format.d.ts +26 -1
- package/dist/engine/solution-format.js +65 -3
- package/dist/engine/solution-habit.d.ts +1 -0
- package/dist/engine/solution-habit.js +22 -0
- package/dist/engine/solution-index.d.ts +5 -0
- package/dist/engine/solution-index.js +32 -0
- package/dist/engine/solution-matcher-eval.js +4 -4
- package/dist/engine/solution-matcher.js +15 -13
- package/dist/engine/solution-scope.d.ts +11 -0
- package/dist/engine/solution-scope.js +19 -0
- package/dist/engine/solution-writer.d.ts +3 -1
- package/dist/engine/solution-writer.js +3 -2
- package/dist/engine/term-normalizer.js +49 -0
- package/dist/fgx.js +1 -1
- package/dist/forge/cli.js +51 -8
- package/dist/forge/evidence-processor.js +6 -0
- package/dist/hooks/context-guard.d.ts +0 -22
- package/dist/hooks/context-guard.js +22 -55
- package/dist/hooks/context-usage.d.ts +21 -0
- package/dist/hooks/context-usage.js +103 -0
- package/dist/hooks/dangerous-patterns.json +1 -16
- package/dist/hooks/db-guard.d.ts +1 -1
- package/dist/hooks/db-guard.js +21 -30
- package/dist/hooks/hook-config.d.ts +2 -0
- package/dist/hooks/hook-config.js +5 -1
- package/dist/hooks/hooks-generator.d.ts +4 -0
- package/dist/hooks/hooks-generator.js +10 -4
- package/dist/hooks/permission-handler.js +23 -3
- package/dist/hooks/post-tool-use.js +14 -10
- package/dist/hooks/pre-tool-use.d.ts +17 -3
- package/dist/hooks/pre-tool-use.js +145 -30
- package/dist/hooks/rate-limiter.js +12 -7
- package/dist/hooks/secret-filter.js +15 -4
- package/dist/hooks/session-end.d.ts +2 -2
- package/dist/hooks/session-end.js +13 -7
- package/dist/hooks/session-recovery.js +79 -50
- package/dist/hooks/shared/command-analyzer.d.ts +45 -0
- package/dist/hooks/shared/command-analyzer.js +972 -0
- package/dist/hooks/shared/command-parser.d.ts +5 -29
- package/dist/hooks/shared/command-parser.js +65 -35
- package/dist/hooks/shared/commit-guard.d.ts +15 -0
- package/dist/hooks/shared/commit-guard.js +177 -0
- package/dist/hooks/shared/hook-response.d.ts +12 -2
- package/dist/hooks/shared/hook-response.js +19 -3
- package/dist/hooks/shared/hook-timing.js +9 -3
- package/dist/hooks/shared/injection-caps.d.ts +32 -2
- package/dist/hooks/shared/injection-caps.js +73 -2
- package/dist/hooks/shared/is-main.d.ts +8 -0
- package/dist/hooks/shared/is-main.js +20 -0
- package/dist/hooks/shared/tool-response.d.ts +6 -0
- package/dist/hooks/shared/tool-response.js +30 -0
- package/dist/hooks/slop-detector.js +6 -3
- package/dist/hooks/solution-injector.d.ts +23 -0
- package/dist/hooks/solution-injector.js +102 -101
- package/dist/hooks/stop-guard.d.ts +11 -1
- package/dist/hooks/stop-guard.js +28 -11
- package/dist/hooks/subagent-stop-guard.js +2 -1
- package/dist/hooks/subagent-tracker.js +2 -1
- package/dist/host/capabilities-codex.js +1 -0
- package/dist/host/claude-shim.d.ts +24 -0
- package/dist/host/claude-shim.js +68 -0
- package/dist/host/codex-hook-shim.d.ts +3 -1
- package/dist/host/codex-hook-shim.js +7 -5
- package/dist/host/codex-notify.js +1 -1
- package/dist/host/codex-rules-context.d.ts +6 -4
- package/dist/host/codex-rules-context.js +11 -24
- package/dist/host/exec-host.d.ts +5 -1
- package/dist/host/exec-host.js +15 -4
- package/dist/host/install-claude.d.ts +47 -14
- package/dist/host/install-claude.js +302 -155
- package/dist/host/install-codex.d.ts +20 -0
- package/dist/host/install-codex.js +32 -1
- package/dist/host/install-opencode.d.ts +3 -1
- package/dist/host/install-opencode.js +6 -3
- package/dist/host/install-orchestrator.js +14 -1
- package/dist/host/opencode/translate.d.ts +1 -1
- package/dist/host/opencode/translate.js +5 -3
- package/dist/host/projection.d.ts +9 -1
- package/dist/host/projection.js +19 -2
- package/dist/mcp/server.js +5 -0
- package/dist/mcp/solution-reader.d.ts +5 -5
- package/dist/mcp/solution-reader.js +13 -35
- package/dist/mcp/tools.js +18 -1
- package/dist/renderer/inspect-renderer.js +4 -2
- package/dist/renderer/render-report.d.ts +22 -0
- package/dist/renderer/render-report.js +29 -0
- package/dist/renderer/rule-renderer.d.ts +28 -2
- package/dist/renderer/rule-renderer.js +91 -76
- package/dist/store/evidence-store.js +34 -6
- package/dist/store/rule-lifecycle.d.ts +3 -1
- package/dist/store/rule-lifecycle.js +10 -0
- package/dist/store/rule-scope.d.ts +7 -0
- package/dist/store/rule-scope.js +54 -0
- package/dist/store/rule-store.d.ts +29 -3
- package/dist/store/rule-store.js +110 -26
- package/dist/store/types.d.ts +22 -2
- package/dist/way/cli.d.ts +1 -0
- package/dist/way/cli.js +313 -0
- package/dist/way/compile.d.ts +22 -0
- package/dist/way/compile.js +408 -0
- package/dist/way/conflict.d.ts +2 -0
- package/dist/way/conflict.js +18 -0
- package/dist/way/draft.d.ts +43 -0
- package/dist/way/draft.js +335 -0
- package/dist/way/extract.d.ts +17 -0
- package/dist/way/extract.js +172 -0
- package/dist/way/io.d.ts +79 -0
- package/dist/way/io.js +425 -0
- package/dist/way/similar.d.ts +2 -0
- package/dist/way/similar.js +30 -0
- package/dist/way/types.d.ts +98 -0
- package/dist/way/types.js +2 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/postinstall.js +76 -899
- package/dist/core/health-cli.d.ts +0 -25
- package/dist/core/health-cli.js +0 -90
- package/dist/host/parity-harness.d.ts +0 -70
- package/dist/host/parity-harness.js +0 -287
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude 고정 shim `<FORGEN_HOME>/bin/forgen-run` (설치 일원화 D1).
|
|
3
|
+
*
|
|
4
|
+
* settings.json 의 hook·statusLine 과 ~/.claude.json 의 MCP 는 이 파일 경로만 가리킨다. 설치 시점의 node 절대경로와
|
|
5
|
+
* 패키지 경로는 shim **내용**에 있어서, Node 전환·재설치는 shim 만 다시 쓰고 settings 는 그대로다.
|
|
6
|
+
* 대상이나 node 를 못 찾으면 호출 종류별로 보이게 실패한다: hook=유효 JSON 경고 + exit 0,
|
|
7
|
+
* MCP=stderr + 비0 종료(stdout JSON 은 프로토콜을 깨뜨린다), statusLine=한 줄 안내.
|
|
8
|
+
* POSIX sh 전용. Windows 는 호출부가 기존 절대경로를 유지한다.
|
|
9
|
+
*/
|
|
10
|
+
import * as os from 'node:os';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import { shimSupported, shq, writeManagedShim } from './codex-hook-shim.js';
|
|
13
|
+
export { shimSupported };
|
|
14
|
+
export const FORGEN_RUN_MARKER = '# forgen-managed forgen-run shim';
|
|
15
|
+
export const REINSTALL_HINT = 'npm i -g @wooojin/forgen (or: forgen install claude)';
|
|
16
|
+
/** FORGEN_HOME 이 있으면 그 아래, 없으면 `<home>/.forgen/bin/forgen-run`. */
|
|
17
|
+
export function forgenRunShimPath(homeDir = os.homedir()) {
|
|
18
|
+
const base = process.env.FORGEN_HOME ? path.resolve(process.env.FORGEN_HOME) : path.join(homeDir, '.forgen');
|
|
19
|
+
return path.join(base, 'bin', 'forgen-run');
|
|
20
|
+
}
|
|
21
|
+
/** 소유 판정용 — 명령이 forgen-run shim 을 가리키는가. */
|
|
22
|
+
export function isForgenRunCommand(command) {
|
|
23
|
+
return /[\\/]forgen-run"?(\s|$)/.test(command);
|
|
24
|
+
}
|
|
25
|
+
export function renderForgenRunShim(pkgRoot, nodePath) {
|
|
26
|
+
const hookWarn = JSON.stringify({
|
|
27
|
+
continue: true,
|
|
28
|
+
systemMessage: `forgen hooks are not running (target or node not found). Reinstall: ${REINSTALL_HINT}`,
|
|
29
|
+
});
|
|
30
|
+
return [
|
|
31
|
+
'#!/bin/sh',
|
|
32
|
+
FORGEN_RUN_MARKER,
|
|
33
|
+
'# 설치·업그레이드마다 재작성된다. settings.json / ~/.claude.json 은 이 파일 경로만 가리킨다.',
|
|
34
|
+
'# usage: forgen-run <dist 기준 상대경로> [args...]',
|
|
35
|
+
`FORGEN_PKG=${shq(pkgRoot)}`,
|
|
36
|
+
`FORGEN_NODE=${shq(nodePath)}`,
|
|
37
|
+
`FORGEN_HOOK_WARN=${shq(hookWarn)}`,
|
|
38
|
+
'rel="$1"; [ $# -gt 0 ] && shift',
|
|
39
|
+
'[ -x "$FORGEN_NODE" ] || FORGEN_NODE=$(command -v node 2>/dev/null)',
|
|
40
|
+
'# 패키지가 사라졌으면(버전 디렉터리 삭제) PATH 의 forgen 이 속한 prefix 에서 찾는다.',
|
|
41
|
+
'if [ ! -f "$FORGEN_PKG/dist/$rel" ]; then',
|
|
42
|
+
' f=$(command -v forgen 2>/dev/null)',
|
|
43
|
+
' if [ -n "$f" ] && [ -f "$(dirname "$f")/../lib/node_modules/@wooojin/forgen/dist/$rel" ]; then',
|
|
44
|
+
' FORGEN_PKG="$(dirname "$f")/../lib/node_modules/@wooojin/forgen"',
|
|
45
|
+
' fi',
|
|
46
|
+
'fi',
|
|
47
|
+
'if [ -n "$FORGEN_NODE" ] && [ -f "$FORGEN_PKG/dist/$rel" ]; then',
|
|
48
|
+
' exec "$FORGEN_NODE" "$FORGEN_PKG/dist/$rel" "$@"',
|
|
49
|
+
'fi',
|
|
50
|
+
'case "$rel" in',
|
|
51
|
+
` mcp/*) echo "forgen: MCP server not found. Reinstall: ${REINSTALL_HINT}" >&2; exit 1 ;;`,
|
|
52
|
+
' hooks/*) printf \'%s\\n\' "$FORGEN_HOOK_WARN"; exit 0 ;;',
|
|
53
|
+
` *) echo "forgen: not found. Reinstall: ${REINSTALL_HINT}"; exit 0 ;;`,
|
|
54
|
+
'esac',
|
|
55
|
+
'',
|
|
56
|
+
].join('\n');
|
|
57
|
+
}
|
|
58
|
+
export function writeForgenRunShim(pkgRoot, nodePath, shimPath) {
|
|
59
|
+
return writeManagedShim(shimPath, renderForgenRunShim(pkgRoot, nodePath), FORGEN_RUN_MARKER);
|
|
60
|
+
}
|
|
61
|
+
/** shim 이 있으면 반환, 쓸 수 없으면(Windows/사용자 파일/쓰기 실패) null → 호출부가 절대경로로 폴백. */
|
|
62
|
+
export function ensureForgenRunShim(pkgRoot, homeDir = os.homedir()) {
|
|
63
|
+
if (!shimSupported())
|
|
64
|
+
return { path: null, status: 'unsupported' };
|
|
65
|
+
const shimPath = forgenRunShimPath(homeDir);
|
|
66
|
+
const status = writeForgenRunShim(pkgRoot, process.execPath, shimPath);
|
|
67
|
+
return { path: status === 'written' || status === 'unchanged' ? shimPath : null, status };
|
|
68
|
+
}
|
|
@@ -18,11 +18,13 @@ export declare function codexHookShimPath(codexHome: string): string;
|
|
|
18
18
|
/** 소유 판정용 — 명령이 forgen shim 을 가리키는가. */
|
|
19
19
|
export declare const SHIM_COMMAND_RE: RegExp;
|
|
20
20
|
export declare function shimSupported(platform?: NodeJS.Platform): boolean;
|
|
21
|
+
export declare const shq: (s: string) => string;
|
|
21
22
|
export declare function renderShim(pkgRoot: string, nodePath: string): string;
|
|
22
23
|
/**
|
|
23
|
-
* shim
|
|
24
|
+
* 마커가 있는 shim 파일을 (재)작성. 내용이 같으면 쓰지 않는다. 사용자가 마커를 지운 파일은 덮어쓰지 않는다.
|
|
24
25
|
* 반환: 'written' | 'unchanged' | 'foreign'(사용자 파일) | 'error'.
|
|
25
26
|
*/
|
|
27
|
+
export declare function writeManagedShim(shimPath: string, content: string, marker: string): 'written' | 'unchanged' | 'foreign' | 'error';
|
|
26
28
|
export declare function writeCodexHookShim(pkgRoot: string, nodePath: string, shimPath: string): 'written' | 'unchanged' | 'foreign' | 'error';
|
|
27
29
|
/**
|
|
28
30
|
* `node "<root>/host/codex-adapter.js" "<root>/<rel>" args` → `"<shim>" "<rel>" args`.
|
|
@@ -24,7 +24,7 @@ export const SHIM_COMMAND_RE = /[\\/]forgen-hook"?(?![\w-])/;
|
|
|
24
24
|
export function shimSupported(platform = process.platform) {
|
|
25
25
|
return platform !== 'win32';
|
|
26
26
|
}
|
|
27
|
-
const shq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
27
|
+
export const shq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
28
28
|
export function renderShim(pkgRoot, nodePath) {
|
|
29
29
|
return [
|
|
30
30
|
'#!/bin/sh',
|
|
@@ -40,17 +40,16 @@ export function renderShim(pkgRoot, nodePath) {
|
|
|
40
40
|
].join('\n');
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* shim
|
|
43
|
+
* 마커가 있는 shim 파일을 (재)작성. 내용이 같으면 쓰지 않는다. 사용자가 마커를 지운 파일은 덮어쓰지 않는다.
|
|
44
44
|
* 반환: 'written' | 'unchanged' | 'foreign'(사용자 파일) | 'error'.
|
|
45
45
|
*/
|
|
46
|
-
export function
|
|
46
|
+
export function writeManagedShim(shimPath, content, marker) {
|
|
47
47
|
try {
|
|
48
|
-
const content = renderShim(pkgRoot, nodePath);
|
|
49
48
|
if (fs.existsSync(shimPath)) {
|
|
50
49
|
const cur = fs.readFileSync(shimPath, 'utf-8');
|
|
51
50
|
if (cur === content)
|
|
52
51
|
return 'unchanged';
|
|
53
|
-
if (!cur.includes(
|
|
52
|
+
if (!cur.includes(marker))
|
|
54
53
|
return 'foreign';
|
|
55
54
|
}
|
|
56
55
|
fs.mkdirSync(path.dirname(shimPath), { recursive: true });
|
|
@@ -63,6 +62,9 @@ export function writeCodexHookShim(pkgRoot, nodePath, shimPath) {
|
|
|
63
62
|
return 'error';
|
|
64
63
|
}
|
|
65
64
|
}
|
|
65
|
+
export function writeCodexHookShim(pkgRoot, nodePath, shimPath) {
|
|
66
|
+
return writeManagedShim(shimPath, renderShim(pkgRoot, nodePath), SHIM_MARKER);
|
|
67
|
+
}
|
|
66
68
|
/**
|
|
67
69
|
* `node "<root>/host/codex-adapter.js" "<root>/<rel>" args` → `"<shim>" "<rel>" args`.
|
|
68
70
|
* 형태가 다르면(사용자 수정 등) 원문 그대로 반환.
|
|
@@ -32,7 +32,7 @@ export const CODEX_HOOKS_SILENT_PATH = path.join(STATE_DIR, 'codex-hooks-silent.
|
|
|
32
32
|
/** silent 플래그 유효기간 — 이보다 오래된 관측은 doctor 가 무시한다. */
|
|
33
33
|
const SILENT_TTL_MS = 24 * 60 * 60 * 1000;
|
|
34
34
|
/** Stop 훅 경로와 같은 "의미 있는 세션" 임계. */
|
|
35
|
-
const MIN_USER_PROMPTS =
|
|
35
|
+
const MIN_USER_PROMPTS = 1; // D9: 메시지 수 게이트 제거 — 짧은 세션의 교정도 승급
|
|
36
36
|
/** argv(스크립트 뒤) → 체인 프로그램 + 페이로드. 페이로드는 항상 마지막 argv. */
|
|
37
37
|
export function parseNotifyArgv(argv) {
|
|
38
38
|
if (argv.length === 0)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 개인화 룰 주입 — ADR-014 D1, 2026-11-04 Claude 까지 확장
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 모든 호스트가 SessionStart additionalContext 하나로 룰을 받는다. 파일 방식(.claude/rules/)은
|
|
5
|
+
* 래퍼 실행에서만 갱신되고 cwd 에 흔적을 남겨서, 직접 실행이면 옛 룰이 계속 주입됐다.
|
|
5
6
|
* 본 모듈은 *같은 소스* (generateClaudeRuleFiles) 를 *같은 캡* (RULE_FILE_CAPS) 으로 렌더해
|
|
6
7
|
* SessionStart additionalContext 로 넣을 블록을 만든다. hooks.json 을 바꾸지 않기 위해 새 훅이
|
|
7
8
|
* 아니라 session-recovery 내부의 codex 분기에서 호출된다.
|
|
@@ -17,9 +18,10 @@ export declare function isCodexRuntime(env?: NodeJS.ProcessEnv): boolean;
|
|
|
17
18
|
* 룰 파일 맵 → 단일 additionalContext 블록. Claude 의 injectClaudeRuleFiles 와 동일 캡:
|
|
18
19
|
* 파일당 perRuleFile, 총량 totalRuleFiles. 캡 초과 파일은 잘리고, 총량 초과 시 이후 파일은 생략.
|
|
19
20
|
*/
|
|
20
|
-
export declare function
|
|
21
|
+
export declare function renderRulesBlock(ruleFiles: Record<string, string>, host?: 'claude' | 'codex'): string | null;
|
|
21
22
|
/**
|
|
22
23
|
* cwd + 렌더된 v1 룰 → Codex 주입 블록. config-injector 는 무거워서 lazy import.
|
|
23
24
|
* 실패 시 null (fail-open — 룰 주입 실패가 세션 시작을 막으면 안 된다).
|
|
24
25
|
*/
|
|
25
|
-
export declare
|
|
26
|
+
export declare const renderCodexRulesBlock: typeof renderRulesBlock;
|
|
27
|
+
export declare function buildRulesContext(cwd: string, renderedRules: string | null, host: 'claude' | 'codex'): Promise<string | null>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 개인화 룰 주입 — ADR-014 D1, 2026-11-04 Claude 까지 확장
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 모든 호스트가 SessionStart additionalContext 하나로 룰을 받는다. 파일 방식(.claude/rules/)은
|
|
5
|
+
* 래퍼 실행에서만 갱신되고 cwd 에 흔적을 남겨서, 직접 실행이면 옛 룰이 계속 주입됐다.
|
|
5
6
|
* 본 모듈은 *같은 소스* (generateClaudeRuleFiles) 를 *같은 캡* (RULE_FILE_CAPS) 으로 렌더해
|
|
6
7
|
* SessionStart additionalContext 로 넣을 블록을 만든다. hooks.json 을 바꾸지 않기 위해 새 훅이
|
|
7
8
|
* 아니라 session-recovery 내부의 codex 분기에서 호출된다.
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
* source="compact" 로 다시 발화하므로 (Codex 공식 hooks 문서), 같은 경로가 한 번 더 돈다.
|
|
11
12
|
* (critic 리뷰 2026-10-01: PreCompact 플래그 경로는 2중 주입이라 제거.)
|
|
12
13
|
*/
|
|
13
|
-
import {
|
|
14
|
+
import { composeRuleFiles } from '../hooks/shared/injection-caps.js';
|
|
14
15
|
export const FORGEN_RULES_TAG = 'forgen-rules';
|
|
15
16
|
/** codex-adapter 가 delegate hook 에 FORGEN_RUNTIME=codex 를 주입한다 (0.4.6+). */
|
|
16
17
|
export function isCodexRuntime(env = process.env) {
|
|
@@ -20,28 +21,13 @@ export function isCodexRuntime(env = process.env) {
|
|
|
20
21
|
* 룰 파일 맵 → 단일 additionalContext 블록. Claude 의 injectClaudeRuleFiles 와 동일 캡:
|
|
21
22
|
* 파일당 perRuleFile, 총량 totalRuleFiles. 캡 초과 파일은 잘리고, 총량 초과 시 이후 파일은 생략.
|
|
22
23
|
*/
|
|
23
|
-
export function
|
|
24
|
-
const
|
|
25
|
-
if (entries.length === 0)
|
|
26
|
-
return null;
|
|
27
|
-
const PER = RULE_FILE_CAPS.perRuleFile;
|
|
28
|
-
const TOTAL = RULE_FILE_CAPS.totalRuleFiles;
|
|
29
|
-
const sections = [];
|
|
30
|
-
let total = 0;
|
|
31
|
-
for (const [filename, content] of entries) {
|
|
32
|
-
const capped = content.length > PER
|
|
33
|
-
? `${content.slice(0, PER)}\n... (capped at rule file limit)\n`
|
|
34
|
-
: content;
|
|
35
|
-
if (total + capped.length > TOTAL)
|
|
36
|
-
break;
|
|
37
|
-
total += capped.length;
|
|
38
|
-
sections.push(`<!-- ${filename} -->\n${capped.trim()}`);
|
|
39
|
-
}
|
|
24
|
+
export function renderRulesBlock(ruleFiles, host = 'codex') {
|
|
25
|
+
const sections = composeRuleFiles(ruleFiles).files.map(({ filename, content }) => `<!-- ${filename} -->\n${content.trim()}`);
|
|
40
26
|
if (sections.length === 0)
|
|
41
27
|
return null;
|
|
42
28
|
return [
|
|
43
|
-
`<${FORGEN_RULES_TAG} host="
|
|
44
|
-
'These are
|
|
29
|
+
`<${FORGEN_RULES_TAG} host="${host}">`,
|
|
30
|
+
'These are this user\'s forgen rules. They apply to this session.',
|
|
45
31
|
'',
|
|
46
32
|
sections.join('\n\n---\n\n'),
|
|
47
33
|
`</${FORGEN_RULES_TAG}>`,
|
|
@@ -51,10 +37,11 @@ export function renderCodexRulesBlock(ruleFiles) {
|
|
|
51
37
|
* cwd + 렌더된 v1 룰 → Codex 주입 블록. config-injector 는 무거워서 lazy import.
|
|
52
38
|
* 실패 시 null (fail-open — 룰 주입 실패가 세션 시작을 막으면 안 된다).
|
|
53
39
|
*/
|
|
54
|
-
export
|
|
40
|
+
export const renderCodexRulesBlock = renderRulesBlock;
|
|
41
|
+
export async function buildRulesContext(cwd, renderedRules, host) {
|
|
55
42
|
try {
|
|
56
43
|
const { generateClaudeRuleFiles } = await import('../core/config-injector.js');
|
|
57
|
-
return
|
|
44
|
+
return renderRulesBlock(generateClaudeRuleFiles(cwd, renderedRules), host);
|
|
58
45
|
}
|
|
59
46
|
catch {
|
|
60
47
|
return null;
|
package/dist/host/exec-host.d.ts
CHANGED
|
@@ -57,7 +57,11 @@ export interface ExecHostResult {
|
|
|
57
57
|
*/
|
|
58
58
|
/** ADR-015 C-G1 — forgen 이 띄우는 중첩 claude 실행의 공통 표식. hook-config.isHookEnabled 가 읽는다. */
|
|
59
59
|
export declare const NESTED_RUN_ENV: Readonly<Record<string, string>>;
|
|
60
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* `--no-session-persistence` 는 --print 전용 — 추출 run 의 transcript 를 디스크에 남기지 않는다.
|
|
62
|
+
* D12-D: `--tools ""` — 추출은 텍스트만 돌려받으면 되므로 도구를 아예 주지 않는다(안전 hook 이 유지되더라도
|
|
63
|
+
* 도구가 없는 편이 가장 안전하다).
|
|
64
|
+
*/
|
|
61
65
|
export declare const NESTED_RUN_CLAUDE_ARGS: ReadonlyArray<string>;
|
|
62
66
|
export declare function withNestedRunClaudeArgs(args: string[]): string[];
|
|
63
67
|
export declare function execHost(opts: ExecHostOptions): ExecHostResult;
|
package/dist/host/exec-host.js
CHANGED
|
@@ -36,10 +36,19 @@ export const DEFAULT_TIMEOUT_BY_HOST = {
|
|
|
36
36
|
*/
|
|
37
37
|
/** ADR-015 C-G1 — forgen 이 띄우는 중첩 claude 실행의 공통 표식. hook-config.isHookEnabled 가 읽는다. */
|
|
38
38
|
export const NESTED_RUN_ENV = { FORGEN_NESTED_RUN: '1' };
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* `--no-session-persistence` 는 --print 전용 — 추출 run 의 transcript 를 디스크에 남기지 않는다.
|
|
41
|
+
* D12-D: `--tools ""` — 추출은 텍스트만 돌려받으면 되므로 도구를 아예 주지 않는다(안전 hook 이 유지되더라도
|
|
42
|
+
* 도구가 없는 편이 가장 안전하다).
|
|
43
|
+
*/
|
|
44
|
+
export const NESTED_RUN_CLAUDE_ARGS = ['--tools', '', '--no-session-persistence'];
|
|
41
45
|
export function withNestedRunClaudeArgs(args) {
|
|
42
|
-
|
|
46
|
+
const out = [...args];
|
|
47
|
+
if (!out.includes('--tools') && !out.includes('--allowedTools') && !out.includes('--allowed-tools'))
|
|
48
|
+
out.push('--tools', '');
|
|
49
|
+
if (!out.includes('--no-session-persistence'))
|
|
50
|
+
out.push('--no-session-persistence');
|
|
51
|
+
return out;
|
|
43
52
|
}
|
|
44
53
|
export function execHost(opts) {
|
|
45
54
|
const resolved = resolveDefaultHost(opts.host);
|
|
@@ -63,9 +72,11 @@ export function execHost(opts) {
|
|
|
63
72
|
// ADR-015 C-G1: 중첩 실행 표식 + 세션 비영속 (추출 run 의 transcript 가 다음 SessionStart 의
|
|
64
73
|
// "이전 세션 auto-compound" 후보로 잡히거나 forgen 훅이 재귀 발화하지 않도록).
|
|
65
74
|
const nested = opts.nestedRun ?? true;
|
|
66
|
-
const args = ['-p', opts.prompt
|
|
75
|
+
const args = ['-p', opts.prompt];
|
|
67
76
|
if (opts.model)
|
|
68
77
|
args.push('--model', opts.model);
|
|
78
|
+
if (nested)
|
|
79
|
+
args.push(...NESTED_RUN_CLAUDE_ARGS);
|
|
69
80
|
const env = nested ? { ...(baseOpts.env ?? {}), ...NESTED_RUN_ENV } : baseOpts.env;
|
|
70
81
|
const stdout = execFileSync('claude', args, { ...baseOpts, env });
|
|
71
82
|
return { message: stdout.toString().trim(), host: 'claude', usage: null };
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Claude InstallPlan —
|
|
2
|
+
* Claude InstallPlan — `forgen install claude` 와 npm postinstall 이 공유하는 단일 설치 경로 (D1 설치 일원화).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 작업:
|
|
5
|
+
* 1. 고정 shim: <FORGEN_HOME>/bin/forgen-run 작성 (node·패키지 경로는 shim 내용에만)
|
|
6
|
+
* 2. Slash commands: ~/.claude/commands/forgen/*.md (forgen-managed marker)
|
|
7
|
+
* 3. settings.json: hook 전체 + statusLine 을 shim 경유로. 사용자 hook·statusLine 보존, 멱등, 구형 절대경로 교체,
|
|
8
|
+
* 래퍼가 남긴 FORGEN_* env 와 forgen@forgen-local 플러그인 잔재 정리
|
|
9
|
+
* 4. MCP: ~/.claude.json mcpServers.forgen-compound (shim 경유)
|
|
10
|
+
* 5. Dev-guide skills, verify skill, 전역 ch-* agents (~/.claude/agents, forgen 표식 있는 파일만 관리)
|
|
6
11
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 2. Slash commands: ~/.claude/commands/forgen/*.md 생성 (forgen-managed marker)
|
|
10
|
-
* 3. Settings hooks injection: ~/.claude/settings.json 의 hooks 머지 (forgen entry idempotent)
|
|
11
|
-
* 4. MCP register: ~/.claude.json 에 mcpServers.forgen-compound 추가
|
|
12
|
-
* 5. Dev-guide skills: ~/.claude/skills/forgen-<stack>-<skill>/ 설치 (forgen-managed only)
|
|
13
|
-
* 6. verify skill: ~/.claude/skills/verify/ 설치 (ADR-016 D3 — 사용자 소유면 보존)
|
|
14
|
-
*
|
|
15
|
-
* 사용자 비-forgen 자산 보존 + 재실행 idempotent.
|
|
12
|
+
* 플러그인 등록(캐시·installed_plugins·enabledPlugins)은 만들지 않는다 — 마켓플레이스가 없어 로드 실패하고 hook 만 겹쳤다.
|
|
13
|
+
* shim 을 못 쓰는 환경(Windows)은 기존 절대경로 유지. 한 단계가 실패해도 나머지는 진행하고 사유를 errors 로 돌려준다.
|
|
16
14
|
*/
|
|
17
15
|
export interface ClaudeInstallOptions {
|
|
18
16
|
pkgRoot: string;
|
|
@@ -35,19 +33,54 @@ export type VerifySkillStatus =
|
|
|
35
33
|
| 'skipped';
|
|
36
34
|
export interface ClaudeInstallResult {
|
|
37
35
|
homeDir: string;
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
/** 고정 shim 경로. 쓰지 못했으면 null(절대경로 폴백). */
|
|
37
|
+
shimPath: string | null;
|
|
38
|
+
shimStatus: string;
|
|
40
39
|
slashCommandsPath: string;
|
|
41
40
|
slashCommandsCount: number;
|
|
42
41
|
settingsPath: string;
|
|
43
42
|
hooksInjected: number;
|
|
43
|
+
statusLine: 'installed' | 'updated' | 'unchanged' | 'custom';
|
|
44
44
|
mcpRegistered: boolean;
|
|
45
45
|
mcpAlreadyPresent: boolean;
|
|
46
46
|
skillsPath: string;
|
|
47
47
|
skillsInstalled: number;
|
|
48
48
|
skillsRemoved: number;
|
|
49
49
|
verifySkill: VerifySkillStatus;
|
|
50
|
+
agentsPath: string;
|
|
51
|
+
agentsInstalled: number;
|
|
52
|
+
agentsRemoved: number;
|
|
53
|
+
/** forgen@forgen-local 플러그인 잔재를 정리했는가. */
|
|
54
|
+
legacyPluginCleaned: boolean;
|
|
55
|
+
/** 단계별 실패 사유. 비어 있지 않으면 설치가 일부만 됐다. */
|
|
56
|
+
errors: string[];
|
|
57
|
+
}
|
|
58
|
+
type Json = Record<string, unknown>;
|
|
59
|
+
/** settings.json hook 명령이 forgen 소유인가 — 새 shim 형식과 구형 절대경로·플러그인 변수 형식 모두. */
|
|
60
|
+
export declare function isForgenHookCommand(cmd: string, pkgRoot: string): boolean;
|
|
61
|
+
export interface SettingsApplyResult {
|
|
62
|
+
hooks: number;
|
|
63
|
+
statusLine: ClaudeInstallResult['statusLine'];
|
|
50
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* settings 객체에 forgen 설정을 제자리 반영한다(설치·래퍼 공용, 순수 함수).
|
|
67
|
+
* hook 은 forgen 것만 갈아끼우고 사용자 hook 은 그룹 안에서도 보존한다. 같은 입력이면 결과가 같아 멱등이다.
|
|
68
|
+
*/
|
|
69
|
+
export declare function removeForgenHooks(hooksConfig: Record<string, unknown[]>, pkgRoot: string): void;
|
|
70
|
+
export declare function applyForgenSettings(settings: Json, pkgRoot: string, shimPath: string | null): SettingsApplyResult;
|
|
51
71
|
/** `<skillsDir>/verify` 가 사용자 소유인가 (심링크 / 마커 없는 SKILL.md / SKILL.md 없이 다른 파일만 있음). */
|
|
52
72
|
export declare function isUserOwnedVerifySkill(skillsDir: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* assets/claude/agents/*.md → ~/.claude/agents/ch-*.md. 표식이 있는 forgen 파일만 갱신·정리하고,
|
|
75
|
+
* 사용자가 만들었거나 수정해 표식이 없는 파일, 심링크는 건드리지 않는다.
|
|
76
|
+
*/
|
|
77
|
+
export declare function installGlobalAgents(opts: {
|
|
78
|
+
pkgRoot: string;
|
|
79
|
+
agentsDir: string;
|
|
80
|
+
dryRun?: boolean;
|
|
81
|
+
}): {
|
|
82
|
+
installed: number;
|
|
83
|
+
removed: number;
|
|
84
|
+
};
|
|
53
85
|
export declare function planClaudeInstall(opts: ClaudeInstallOptions): ClaudeInstallResult;
|
|
86
|
+
export {};
|