@wooojin/forgen 0.6.8 → 0.6.9
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 +17 -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 +143 -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 +176 -0
- package/dist/hooks/shared/hook-response.d.ts +6 -0
- package/dist/hooks/shared/hook-response.js +12 -0
- 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
package/dist/core/block-cli.js
CHANGED
|
@@ -10,23 +10,27 @@ export async function handleBlock(args) {
|
|
|
10
10
|
const reasonIdx = args.indexOf('--reason');
|
|
11
11
|
const reason = reasonIdx >= 0 ? args[reasonIdx + 1] : undefined;
|
|
12
12
|
if (!id || (!ok && !fp) || (ok && fp)) {
|
|
13
|
+
process.exitCode = 1;
|
|
13
14
|
console.log('usage: forgen block <violation_id|prefix> --ok | --fp [--reason "..."]');
|
|
14
15
|
console.log(' --ok 이 차단은 맞다(정탐) --fp 이 차단은 틀렸다(오탐). 자동 판정을 덮어씁니다.');
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
if (!/^[A-Za-z0-9-]{8,}$/.test(id)) {
|
|
18
|
-
console.
|
|
19
|
+
console.error(`invalid id: ${id}`);
|
|
20
|
+
process.exitCode = 1;
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
const all = readViolationsWindow(ROTATED_KEEP_DAYS);
|
|
22
24
|
const matches = all.filter((v) => typeof v.violation_id === 'string' && v.violation_id.startsWith(id));
|
|
23
25
|
if (matches.length === 0) {
|
|
24
|
-
console.
|
|
26
|
+
console.error(`no block with id ${id}. See: forgen status --blocks 5`);
|
|
27
|
+
process.exitCode = 1;
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
27
30
|
const ids = new Set(matches.map((v) => v.violation_id));
|
|
28
31
|
if (ids.size > 1) {
|
|
29
|
-
console.
|
|
32
|
+
console.error(`ambiguous prefix ${id} → ${[...ids].join(', ')}`);
|
|
33
|
+
process.exitCode = 1;
|
|
30
34
|
return;
|
|
31
35
|
}
|
|
32
36
|
const v = matches[matches.length - 1];
|
|
@@ -13,3 +13,21 @@ export declare function getHaikuConsentState(): ConsentState;
|
|
|
13
13
|
export declare function isHaikuCompoundEnabled(): boolean;
|
|
14
14
|
/** 동의 저장(config.json 병합). env override 는 건드리지 않음. */
|
|
15
15
|
export declare function setHaikuCompoundConsent(enabled: boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* 전송 범위 문구의 단일 소스 (ADR-019). 안내·`consent status`·README 가 같은 사실을 말한다:
|
|
18
|
+
* 사용자 발화와 어시스턴트 발화가 들어가고(어시스턴트 발화에는 읽은 파일 내용의 일부가 섞일 수 있다),
|
|
19
|
+
* 비밀키는 마스킹하고 <private> 구간은 제외한다. 내 계정의 Claude Haiku 로만 보낸다.
|
|
20
|
+
*/
|
|
21
|
+
export declare const HAIKU_SCOPE_TEXT: string;
|
|
22
|
+
export declare const HAIKU_OFF_HOWTO = "\uB044\uAE30: forgen compound consent off (\uB610\uB294 FORGEN_NO_AUTO_COMPOUND=1)";
|
|
23
|
+
/** ANTHROPIC_API_KEY 가 있으면 claude 는 구독이 아니라 API 키로 과금한다. */
|
|
24
|
+
export declare function apiBillingNote(env?: NodeJS.ProcessEnv): string | null;
|
|
25
|
+
export declare const HAIKU_FIRST_NOTICE = "[Forgen] \uC138\uC158 \uD559\uC2B5\uC774 \uCF1C\uC838 \uC788\uC2B5\uB2C8\uB2E4. \uC138\uC158\uC774 \uB05D\uB098\uBA74 \uB300\uD654 \uC694\uC57D(\uB0B4 \uBC1C\uD654\uC640 \uC5B4\uC2DC\uC2A4\uD134\uD2B8 \uBC1C\uD654 \u2014 \uC5B4\uC2DC\uC2A4\uD134\uD2B8\uAC00 \uC77D\uC740 \uD30C\uC77C \uB0B4\uC6A9\uC758 \uC77C\uBD80\uAC00 \uC11E\uC77C \uC218 \uC788\uC74C; \uBE44\uBC00\uD0A4\uB294 \uB9C8\uC2A4\uD0B9, <private> \uAD6C\uAC04\uC740 \uC81C\uC678)\uC744 \uB0B4 \uACC4\uC815\uC758 Claude Haiku \uB85C \uBCF4\uB0B4 \uC7AC\uC0AC\uC6A9 \uD328\uD134\uC744 \uBF51\uC2B5\uB2C8\uB2E4. \uB2E4\uB978 \uC11C\uBC84\uB85C\uB294 \uBCF4\uB0B4\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uB044\uAE30: forgen compound consent off (\uB610\uB294 FORGEN_NO_AUTO_COMPOUND=1)";
|
|
26
|
+
/** 모델 호출 없이 PATH 만 훑는 값싼 확인 (SessionStart 는 지연에 민감하다). */
|
|
27
|
+
export declare function claudeOnPathSync(pathEnv?: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 세션 시작 때 사용자에게 보일 한 줄(없으면 null).
|
|
30
|
+
* 1) 기본값으로 켜진 채 처음 맞는 세션: 무엇이 전송되는지·끄는 법 (1회)
|
|
31
|
+
* 2) 켜져 있지만 직전 호출/판정이 "호출 불가"였다면 사유 (하루 1회) — 결정론 경로는 계속 동작
|
|
32
|
+
*/
|
|
33
|
+
export declare function takeSessionStartNotice(now?: Date): Promise<string | null>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* auto-compound Haiku 추출
|
|
2
|
+
* auto-compound Haiku 추출 설정 (ADR-019, ADR-012 D 대체).
|
|
3
3
|
*
|
|
4
|
-
* 결정론 경로(교정→룰
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 결정론 경로(교정→룰 승급·인덱싱, egress 0)는 항상 동작한다. **Haiku 로 transcript 요약을 보내는
|
|
5
|
+
* 추출**은 기본 ON 이다(2026-11-04 결정: opt-in 은 실사용자 0 으로 추출 경로가 죽어 있었다).
|
|
6
|
+
* 대신 "몰래 보내지 않는다"를 지킨다: 최초 1회 사용자에게 보이는 안내(무엇이 전송되는지·끄는 법),
|
|
7
|
+
* 명시적 OFF(config false / FORGEN_NO_AUTO_COMPOUND=1) 존중, 비밀 마스킹·<private> 제거.
|
|
7
8
|
*
|
|
8
9
|
* 우선순위: FORGEN_NO_AUTO_COMPOUND(강제 off) > FORGEN_AUTO_COMPOUND(강제 on) >
|
|
9
|
-
* config(~/.forgen/config.json.autoCompoundHaiku) > default(
|
|
10
|
+
* config(~/.forgen/config.json.autoCompoundHaiku) > default(true).
|
|
10
11
|
*/
|
|
11
12
|
import * as fs from 'node:fs';
|
|
12
13
|
import * as path from 'node:path';
|
|
@@ -19,7 +20,7 @@ export function resolveHaikuConsent(env, configValue) {
|
|
|
19
20
|
return { enabled: true, source: 'env-on' };
|
|
20
21
|
if (typeof configValue === 'boolean')
|
|
21
22
|
return { enabled: configValue, source: 'config' };
|
|
22
|
-
return { enabled:
|
|
23
|
+
return { enabled: true, source: 'default' }; // ADR-019: 기본 ON, 최초 1회 안내
|
|
23
24
|
}
|
|
24
25
|
const CONFIG_PATH = path.join(FORGEN_HOME, 'config.json');
|
|
25
26
|
function readConfig() {
|
|
@@ -46,3 +47,97 @@ export function setHaikuCompoundConsent(enabled) {
|
|
|
46
47
|
fs.mkdirSync(FORGEN_HOME, { recursive: true });
|
|
47
48
|
fs.writeFileSync(CONFIG_PATH, `${JSON.stringify(cfg, null, 2)}\n`);
|
|
48
49
|
}
|
|
50
|
+
// ── 사용자에게 보이는 안내 (SessionStart / 래퍼 시작) ──
|
|
51
|
+
/**
|
|
52
|
+
* 전송 범위 문구의 단일 소스 (ADR-019). 안내·`consent status`·README 가 같은 사실을 말한다:
|
|
53
|
+
* 사용자 발화와 어시스턴트 발화가 들어가고(어시스턴트 발화에는 읽은 파일 내용의 일부가 섞일 수 있다),
|
|
54
|
+
* 비밀키는 마스킹하고 <private> 구간은 제외한다. 내 계정의 Claude Haiku 로만 보낸다.
|
|
55
|
+
*/
|
|
56
|
+
export const HAIKU_SCOPE_TEXT = '세션이 끝나면 대화 요약(내 발화와 어시스턴트 발화 — 어시스턴트가 읽은 파일 내용의 일부가 섞일 수 있음; ' +
|
|
57
|
+
'비밀키는 마스킹, <private> 구간은 제외)을 내 계정의 Claude Haiku 로 보내 재사용 패턴을 뽑습니다. 다른 서버로는 보내지 않습니다.';
|
|
58
|
+
export const HAIKU_OFF_HOWTO = '끄기: forgen compound consent off (또는 FORGEN_NO_AUTO_COMPOUND=1)';
|
|
59
|
+
/** ANTHROPIC_API_KEY 가 있으면 claude 는 구독이 아니라 API 키로 과금한다. */
|
|
60
|
+
export function apiBillingNote(env = process.env) {
|
|
61
|
+
if (!env.ANTHROPIC_API_KEY)
|
|
62
|
+
return null;
|
|
63
|
+
return 'ANTHROPIC_API_KEY 가 설정돼 있어 추출 호출이 API 과금 계정으로 청구됩니다(호출당 과금, 구독 한도가 아님). ' +
|
|
64
|
+
'끄기: forgen compound consent off (또는 FORGEN_NO_AUTO_COMPOUND=1)';
|
|
65
|
+
}
|
|
66
|
+
export const HAIKU_FIRST_NOTICE = `[Forgen] 세션 학습이 켜져 있습니다. ${HAIKU_SCOPE_TEXT} ${HAIKU_OFF_HOWTO}`;
|
|
67
|
+
const NOTICE_PATH = path.join(FORGEN_HOME, 'state', 'haiku-consent-notice.json');
|
|
68
|
+
function readNotice() {
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(fs.readFileSync(NOTICE_PATH, 'utf-8'));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function writeNotice(n) {
|
|
77
|
+
try {
|
|
78
|
+
fs.mkdirSync(path.dirname(NOTICE_PATH), { recursive: true });
|
|
79
|
+
fs.writeFileSync(NOTICE_PATH, JSON.stringify(n));
|
|
80
|
+
}
|
|
81
|
+
catch { /* 안내 기록 실패는 무시 */ }
|
|
82
|
+
}
|
|
83
|
+
/** 모델 호출 없이 PATH 만 훑는 값싼 확인 (SessionStart 는 지연에 민감하다). */
|
|
84
|
+
export function claudeOnPathSync(pathEnv = process.env.PATH ?? '') {
|
|
85
|
+
const exts = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
86
|
+
for (const dir of pathEnv.split(path.delimiter)) {
|
|
87
|
+
if (!dir)
|
|
88
|
+
continue;
|
|
89
|
+
for (const e of exts) {
|
|
90
|
+
try {
|
|
91
|
+
fs.accessSync(path.join(dir, `claude${e}`), fs.constants.X_OK);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
catch { /* next */ }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 세션 시작 때 사용자에게 보일 한 줄(없으면 null).
|
|
101
|
+
* 1) 기본값으로 켜진 채 처음 맞는 세션: 무엇이 전송되는지·끄는 법 (1회)
|
|
102
|
+
* 2) 켜져 있지만 직전 호출/판정이 "호출 불가"였다면 사유 (하루 1회) — 결정론 경로는 계속 동작
|
|
103
|
+
*/
|
|
104
|
+
export async function takeSessionStartNotice(now = new Date()) {
|
|
105
|
+
const c = getHaikuConsentState();
|
|
106
|
+
if (!c.enabled)
|
|
107
|
+
return null;
|
|
108
|
+
const n = readNotice();
|
|
109
|
+
const parts = [];
|
|
110
|
+
const billing = apiBillingNote();
|
|
111
|
+
if (c.source === 'default' && !n.firstShown) {
|
|
112
|
+
parts.push(HAIKU_FIRST_NOTICE);
|
|
113
|
+
n.firstShown = now.toISOString();
|
|
114
|
+
if (billing) {
|
|
115
|
+
parts.push(`[Forgen] ${billing}`);
|
|
116
|
+
n.billingShown = now.toISOString();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (billing && !n.billingShown) {
|
|
120
|
+
// 처음 안내 뒤에 API 키가 생긴 경우도 한 번은 알린다.
|
|
121
|
+
parts.push(`[Forgen] ${billing}`);
|
|
122
|
+
n.billingShown = now.toISOString();
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const { readHaikuStatus } = await import('./extraction-haiku.js');
|
|
126
|
+
const st = readHaikuStatus();
|
|
127
|
+
const day = now.toISOString().slice(0, 10);
|
|
128
|
+
let reason;
|
|
129
|
+
if (!claudeOnPathSync())
|
|
130
|
+
reason = 'claude CLI 를 PATH 에서 찾지 못함';
|
|
131
|
+
else if (st && !st.ok && st.outcome === 'unavailable')
|
|
132
|
+
reason = st.reason ?? '원인 미상';
|
|
133
|
+
if (reason && n.unavailableShownOn !== day) {
|
|
134
|
+
parts.push(`[Forgen] Haiku 추출 불가: ${reason}. 교정→룰 승급과 세션 검색은 계속 동작합니다.`);
|
|
135
|
+
n.unavailableShownOn = day;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch { /* 상태 파일 없음 */ }
|
|
139
|
+
if (parts.length === 0)
|
|
140
|
+
return null;
|
|
141
|
+
writeNotice(n);
|
|
142
|
+
return parts.join('\n');
|
|
143
|
+
}
|
|
@@ -43,6 +43,22 @@ export declare function runCompoundSweep(opts?: {
|
|
|
43
43
|
} & Partial<Omit<SweepOpts, 'nowMs'>>): SweepResult;
|
|
44
44
|
/** crontab 라인 구성 (순수 — 테스트 가능). 경로는 shell-quote(리뷰 SEV-2). */
|
|
45
45
|
export declare function buildCronLine(nodePath: string, cliPath: string, logPath: string, schedule?: string): string;
|
|
46
|
+
/** shim 경유 라인. 패키지 경로·node 버전이 바뀌어도 cron 을 다시 고칠 필요가 없다. */
|
|
47
|
+
export declare function buildShimCronLine(shimPath: string, logPath: string, schedule?: string, sweepArgs?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* 이미 등록된 forgen 라인만 shim 경유로 바꾼다. 일정·sweep 옵션·로그 경로는 유지한다.
|
|
50
|
+
* 등록이 없으면 추가하지 않고, 형식을 알 수 없는 라인(사용자가 고친 라인)은 건드리지 않는다.
|
|
51
|
+
*/
|
|
52
|
+
export declare function refreshCronText(existing: string, shimPath: string): {
|
|
53
|
+
text: string;
|
|
54
|
+
changed: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* 업그레이드 때 호출. 옛 라인은 사라질 수 있는 패키지 경로를 직접 가리킨다.
|
|
58
|
+
* crontab 은 HOME·FORGEN_HOME 으로 격리되지 않으므로, 실제 계정 홈의 기본 설치일 때만 건드린다.
|
|
59
|
+
* cron 갱신 실패가 설치를 실패로 만들지 않는다. 옛 라인은 그대로 남고 다음 설치 때 다시 시도한다.
|
|
60
|
+
*/
|
|
61
|
+
export declare function refreshCronAfterUpgrade(homeDir?: string): 'updated' | 'unchanged' | 'skipped' | 'failed';
|
|
46
62
|
/** 기존 crontab 에서 forgen 라인을 upsert/제거 (순수 — 테스트 가능). */
|
|
47
63
|
export declare function upsertCronText(existing: string, line: string | null): string;
|
|
48
64
|
export interface CronOpResult {
|
|
@@ -15,6 +15,7 @@ import * as os from 'node:os';
|
|
|
15
15
|
import * as path from 'node:path';
|
|
16
16
|
import { fileURLToPath } from 'node:url';
|
|
17
17
|
import { STATE_DIR } from './paths.js';
|
|
18
|
+
import { forgenRunShimPath } from '../host/claude-shim.js';
|
|
18
19
|
import { runAutoCompound } from './spawn.js';
|
|
19
20
|
import { createLogger } from './logger.js';
|
|
20
21
|
import { pruneRemovedRules } from '../store/rule-store.js';
|
|
@@ -22,7 +23,7 @@ const log = createLogger('compound-sweep');
|
|
|
22
23
|
export const DEFAULT_SWEEP_OPTS = {
|
|
23
24
|
windowMs: 24 * 60 * 60 * 1000,
|
|
24
25
|
staleMs: 2 * 60 * 60 * 1000,
|
|
25
|
-
minPrompts:
|
|
26
|
+
minPrompts: 1, // D9: 짧은 세션도 승급·인덱싱 대상
|
|
26
27
|
maxPerRun: 5,
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
@@ -191,7 +192,7 @@ export function runCompoundSweep(opts = {}) {
|
|
|
191
192
|
continue;
|
|
192
193
|
}
|
|
193
194
|
// 실제 spawn 된 경우만 sweptAt 기록 (리뷰 SEV-2: dedup-skip/실패를 완료로 오기록 금지).
|
|
194
|
-
const status = runAutoCompound(c.cwd, c.transcriptPath, c.sessionId, c.promptCount);
|
|
195
|
+
const status = runAutoCompound(c.cwd, c.transcriptPath, c.sessionId, c.promptCount, true); // 끝난 세션 — 조금 남은 구간도 처리
|
|
195
196
|
if (status === 'spawned') {
|
|
196
197
|
state[c.sessionId] = { sweptAt: nowMs };
|
|
197
198
|
swept.push(c.sessionId);
|
|
@@ -224,6 +225,66 @@ function shq(s) {
|
|
|
224
225
|
export function buildCronLine(nodePath, cliPath, logPath, schedule = CRON_SCHEDULE) {
|
|
225
226
|
return `${schedule} ${shq(nodePath)} ${shq(cliPath)} compound sweep >> ${shq(logPath)} 2>&1 ${CRON_MARKER}`;
|
|
226
227
|
}
|
|
228
|
+
/** shim 경유 라인. 패키지 경로·node 버전이 바뀌어도 cron 을 다시 고칠 필요가 없다. */
|
|
229
|
+
export function buildShimCronLine(shimPath, logPath, schedule = CRON_SCHEDULE, sweepArgs = '') {
|
|
230
|
+
return `${schedule} ${shq(shimPath)} 'cli.js' compound sweep${sweepArgs} >> ${shq(logPath)} 2>&1 ${CRON_MARKER}`;
|
|
231
|
+
}
|
|
232
|
+
const SWEEP_LINE = /^\s*(@\w+|\S+\s+\S+\s+\S+\s+\S+\s+\S+)\s+.*?\bcompound sweep(.*?)\s*>>\s*(.+?)\s+2>&1\s+#/;
|
|
233
|
+
/**
|
|
234
|
+
* 이미 등록된 forgen 라인만 shim 경유로 바꾼다. 일정·sweep 옵션·로그 경로는 유지한다.
|
|
235
|
+
* 등록이 없으면 추가하지 않고, 형식을 알 수 없는 라인(사용자가 고친 라인)은 건드리지 않는다.
|
|
236
|
+
*/
|
|
237
|
+
export function refreshCronText(existing, shimPath) {
|
|
238
|
+
let changed = false;
|
|
239
|
+
const lines = existing.split('\n').map((l) => {
|
|
240
|
+
if (!l.includes(CRON_MARKER))
|
|
241
|
+
return l;
|
|
242
|
+
const m = SWEEP_LINE.exec(l);
|
|
243
|
+
if (!m)
|
|
244
|
+
return l;
|
|
245
|
+
const next = `${m[1]} ${shq(shimPath)} 'cli.js' compound sweep${m[2]} >> ${m[3]} 2>&1 ${CRON_MARKER}`;
|
|
246
|
+
if (next !== l)
|
|
247
|
+
changed = true;
|
|
248
|
+
return next;
|
|
249
|
+
});
|
|
250
|
+
return { text: lines.join('\n'), changed };
|
|
251
|
+
}
|
|
252
|
+
function realPath(p) {
|
|
253
|
+
try {
|
|
254
|
+
return fs.realpathSync(p);
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
return path.resolve(p);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* 업그레이드 때 호출. 옛 라인은 사라질 수 있는 패키지 경로를 직접 가리킨다.
|
|
262
|
+
* crontab 은 HOME·FORGEN_HOME 으로 격리되지 않으므로, 실제 계정 홈의 기본 설치일 때만 건드린다.
|
|
263
|
+
* cron 갱신 실패가 설치를 실패로 만들지 않는다. 옛 라인은 그대로 남고 다음 설치 때 다시 시도한다.
|
|
264
|
+
*/
|
|
265
|
+
export function refreshCronAfterUpgrade(homeDir = os.homedir()) {
|
|
266
|
+
if (process.platform === 'win32' || process.env.FORGEN_HOME)
|
|
267
|
+
return 'skipped';
|
|
268
|
+
if (realPath(homeDir) !== realPath(os.userInfo().homedir))
|
|
269
|
+
return 'skipped';
|
|
270
|
+
let existing;
|
|
271
|
+
try {
|
|
272
|
+
existing = readCrontab();
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
return 'skipped';
|
|
276
|
+
}
|
|
277
|
+
const { text, changed } = refreshCronText(existing, forgenRunShimPath(homeDir));
|
|
278
|
+
if (!changed)
|
|
279
|
+
return 'unchanged';
|
|
280
|
+
try {
|
|
281
|
+
execFileSync('crontab', ['-'], { input: text, encoding: 'utf-8', stdio: ['pipe', 'ignore', 'ignore'] });
|
|
282
|
+
return 'updated';
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
return 'failed';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
227
288
|
/** 기존 crontab 에서 forgen 라인을 upsert/제거 (순수 — 테스트 가능). */
|
|
228
289
|
export function upsertCronText(existing, line) {
|
|
229
290
|
const kept = existing
|
|
@@ -260,7 +321,8 @@ export function installCron() {
|
|
|
260
321
|
const nodePath = process.execPath;
|
|
261
322
|
const cliPath = distCliPath();
|
|
262
323
|
const logPath = path.join(STATE_DIR, 'compound-sweep.log');
|
|
263
|
-
const
|
|
324
|
+
const shim = forgenRunShimPath();
|
|
325
|
+
const line = process.platform !== 'win32' && fs.existsSync(shim) ? buildShimCronLine(shim, logPath) : buildCronLine(nodePath, cliPath, logPath);
|
|
264
326
|
if (process.platform === 'win32') {
|
|
265
327
|
return {
|
|
266
328
|
ok: false,
|
|
@@ -353,8 +415,8 @@ export function compoundSweepCli(args) {
|
|
|
353
415
|
});
|
|
354
416
|
console.log(`[forgen compound sweep --prune-removed] candidates=${r.candidates.length} ` +
|
|
355
417
|
(apply
|
|
356
|
-
? `
|
|
357
|
-
: `(dry-run — add --apply to
|
|
418
|
+
? `archived=${r.deleted.length}`
|
|
419
|
+
: `(dry-run — add --apply to archive)${r.candidates.length ? ` [${r.candidates.map((id) => id.slice(0, 8)).join(', ')}]` : ''}`));
|
|
358
420
|
return;
|
|
359
421
|
}
|
|
360
422
|
const dryRun = args.includes('--dry-run');
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* `forgen config hooks` 명령 구현.
|
|
5
5
|
* 훅 상태, 감지된 플러그인, 컨텍스트 버짓을 ANSI 컬러로 출력합니다.
|
|
6
6
|
*/
|
|
7
|
+
import * as os from 'node:os';
|
|
7
8
|
import * as path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { readSettingsHooks } from './doctor-verify.js';
|
|
8
11
|
import { HOOK_REGISTRY } from '../hooks/hook-registry.js';
|
|
9
12
|
import { FORGEN_HOME } from './paths.js';
|
|
10
13
|
import { detectInstalledPlugins } from './plugin-detector.js';
|
|
@@ -52,13 +55,27 @@ export async function displayHookStatus(cwd) {
|
|
|
52
55
|
console.log();
|
|
53
56
|
}
|
|
54
57
|
// ── 훅 상태 ──
|
|
55
|
-
//
|
|
58
|
+
// 실제 ~/.claude/settings.json 에 등록된 상태를 읽는다 (패키지 매니페스트가 아니라).
|
|
59
|
+
const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
60
|
+
const reg = readSettingsHooks(os.homedir(), pkgRoot);
|
|
61
|
+
// shim 설치(`"<shim>" "hooks/x.js"`)와 shim 없는 절대경로 설치(`node "/pkg/dist/hooks/x.js"`) 둘 다 인식한다.
|
|
62
|
+
const norm = (c) => c.replace(/"/g, '').replace(/\\/g, '/');
|
|
63
|
+
const isRegistered = (h) => reg.entries.some((e) => {
|
|
64
|
+
const c = norm(e.command);
|
|
65
|
+
return e.event === h.event && (c.endsWith(` ${h.script}`) || c.endsWith(`/${h.script}`));
|
|
66
|
+
});
|
|
67
|
+
const hasPlugins = plugins.length > 0;
|
|
68
|
+
// 켜짐 = settings 에 등록됨 + hook-config·플러그인 충돌로 꺼지지 않음.
|
|
69
|
+
const isOn = (h) => isRegistered(h) && isEffectivelyEnabled(h.name, h.tier, hookConflicts, hasPlugins);
|
|
56
70
|
let activeCount = 0;
|
|
57
|
-
for (const h of HOOK_REGISTRY)
|
|
58
|
-
if (
|
|
71
|
+
for (const h of HOOK_REGISTRY)
|
|
72
|
+
if (isOn(h))
|
|
59
73
|
activeCount++;
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
if (reg.error)
|
|
75
|
+
console.log(` ${red('✗')} ${reg.error} — 등록된 hook 을 확인할 수 없음 (forgen install claude)\n`);
|
|
76
|
+
if (reg.disableAll)
|
|
77
|
+
console.log(` ${red('✗')} settings.json 에 disableAllHooks:true — 모든 hook 이 꺼져 있음\n`);
|
|
78
|
+
console.log(` Hook Status (settings.json 등록·켜짐 ${activeCount}/${HOOK_REGISTRY.length}):`);
|
|
62
79
|
for (const tier of TIER_ORDER) {
|
|
63
80
|
const tierHooks = HOOK_REGISTRY.filter(h => h.tier === tier);
|
|
64
81
|
if (tierHooks.length === 0)
|
|
@@ -72,12 +89,14 @@ export async function displayHookStatus(cwd) {
|
|
|
72
89
|
: TIER_LABELS[tier];
|
|
73
90
|
console.log(` ${dim(tierLabel)}:`);
|
|
74
91
|
for (const hook of tierHooks) {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
92
|
+
const registered = isRegistered(hook);
|
|
93
|
+
const enabled = registered && isEffectivelyEnabled(hook.name, hook.tier, hookConflicts, hasPlugins);
|
|
94
|
+
const mark = enabled ? green('✓') : registered ? yellow('○') : red('✗');
|
|
77
95
|
const nameCol = hook.name.padEnd(26);
|
|
78
96
|
const eventCol = hook.event.padEnd(20);
|
|
79
97
|
const timeoutStr = dim(`${hook.timeout}s`);
|
|
80
|
-
|
|
98
|
+
const note = registered && !enabled ? ` ${yellow('(hook-config 로 꺼짐)')}` : '';
|
|
99
|
+
console.log(` ${mark} ${nameCol} ${dim(eventCol)} ${timeoutStr}${note}`);
|
|
81
100
|
}
|
|
82
101
|
console.log();
|
|
83
102
|
}
|
|
@@ -91,9 +110,8 @@ export async function displayHookStatus(cwd) {
|
|
|
91
110
|
console.log(` Notepad cap: ${budget.notepadMax} chars ${dim(`(default: ${INJECTION_CAPS.notepadMax})`)}`);
|
|
92
111
|
console.log();
|
|
93
112
|
// ── 경로 ──
|
|
94
|
-
const hooksJson = path.join(process.cwd(), 'hooks', 'hooks.json');
|
|
95
113
|
const configPath = path.join(FORGEN_HOME, 'hook-config.json');
|
|
96
|
-
console.log(`
|
|
114
|
+
console.log(` settings: ${dim(path.join(os.homedir(), '.claude', 'settings.json'))} ${dim('(실제 상태의 기준)')}`);
|
|
97
115
|
console.log(` Config: ${dim(configPath)}`);
|
|
98
116
|
console.log();
|
|
99
117
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 사용자 메시지가 어시스턴트 행동에 대한 교정일 가능성 점수 (순수, 결정론).
|
|
3
|
+
*
|
|
4
|
+
* 쓰임: transcript 요약에서 교정 메시지와 그 앞뒤를 우선 보존한다(D3). 추출 프롬프트가 다루는
|
|
5
|
+
* 교정 유형(명시 마커 / 반사실 / 완곡 / 부정·반박)과 같은 기준. 0 = 교정 신호 없음.
|
|
6
|
+
* 감사 기준선(2026-11-04)이 쓴 정규식을 포함하는 상위 집합이다.
|
|
7
|
+
*/
|
|
8
|
+
export declare function correctionScore(text: string): number;
|
|
9
|
+
export declare function isCorrectionCandidate(text: string): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 사용자 메시지가 어시스턴트 행동에 대한 교정일 가능성 점수 (순수, 결정론).
|
|
3
|
+
*
|
|
4
|
+
* 쓰임: transcript 요약에서 교정 메시지와 그 앞뒤를 우선 보존한다(D3). 추출 프롬프트가 다루는
|
|
5
|
+
* 교정 유형(명시 마커 / 반사실 / 완곡 / 부정·반박)과 같은 기준. 0 = 교정 신호 없음.
|
|
6
|
+
* 감사 기준선(2026-11-04)이 쓴 정규식을 포함하는 상위 집합이다.
|
|
7
|
+
*/
|
|
8
|
+
const STRONG = [
|
|
9
|
+
/하지\s*마/, /하지\s*말/, /말고(?![가-힣])/, /그게\s*아니라/, /아니\s*그게/, /틀렸/, /잘못/, /앞으로/, /절대/, /금지/,
|
|
10
|
+
/\bdon'?t\b/i, /\bdo not\b/i, /\bnever\b/i, /\bstop (doing|adding|using)\b/i, /\binstead of\b/i,
|
|
11
|
+
/\bthat'?s (not|wrong)\b/i, /\bwrong\b/i, /\bnot what i\b/i,
|
|
12
|
+
];
|
|
13
|
+
const MEDIUM = [
|
|
14
|
+
/아니(야|요|고|,|\.|\s)/, /아니/, /왜\s/, /않았/, /안\s*했/, /안\s*돼/, /하지\s*않/, /했어야/, /해야지/, /굳이/, /필요\s*(없|하지)/,
|
|
15
|
+
/다시/, /항상/, /\balways\b/i, /\bactually\b/i, /\bshould(n'?t| not| have)\b/i, /\bwhy did\b/i, /^\s*no[,.\s]/i,
|
|
16
|
+
];
|
|
17
|
+
export function correctionScore(text) {
|
|
18
|
+
if (!text)
|
|
19
|
+
return 0;
|
|
20
|
+
const head = text.slice(0, 600);
|
|
21
|
+
let s = 0;
|
|
22
|
+
for (const re of STRONG)
|
|
23
|
+
if (re.test(head)) {
|
|
24
|
+
s = 3;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
if (s === 0)
|
|
28
|
+
for (const re of MEDIUM)
|
|
29
|
+
if (re.test(head)) {
|
|
30
|
+
s = 2;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return s;
|
|
34
|
+
}
|
|
35
|
+
export function isCorrectionCandidate(text) {
|
|
36
|
+
return correctionScore(text) > 0;
|
|
37
|
+
}
|
package/dist/core/dev-cli.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* forgen dev — 개발/유지보수 명령 네임스페이스 (Wave 1 W1-3, feature-audit 2026-07-21).
|
|
3
3
|
*
|
|
4
|
-
* probe-workflow /
|
|
4
|
+
* probe-workflow / migrate / regress-map 은 개발·CI·스키마 유지보수용으로,
|
|
5
5
|
* 일반 사용자 표면(top-level)을 어지럽혔다. `forgen dev <sub>` 하나로 모아 사용자
|
|
6
6
|
* 명령 표면을 정리한다. 각 핸들러는 기존 것을 재사용.
|
|
7
7
|
*
|
|
8
8
|
* forgen dev probe-workflow arm|report|status ADR-009 §1 훅 발화 측정
|
|
9
|
-
* forgen dev parity codex [--dry-run] host parity (source 체크아웃 전용)
|
|
10
9
|
* forgen dev migrate [implicit-feedback|...] one-shot 스키마 마이그레이션
|
|
11
10
|
* forgen dev regress-map [--days N --top N] 최근 fix 집중 파일
|
|
12
11
|
*/
|
package/dist/core/dev-cli.js
CHANGED
|
@@ -1,47 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* forgen dev — 개발/유지보수 명령 네임스페이스 (Wave 1 W1-3, feature-audit 2026-07-21).
|
|
3
3
|
*
|
|
4
|
-
* probe-workflow /
|
|
4
|
+
* probe-workflow / migrate / regress-map 은 개발·CI·스키마 유지보수용으로,
|
|
5
5
|
* 일반 사용자 표면(top-level)을 어지럽혔다. `forgen dev <sub>` 하나로 모아 사용자
|
|
6
6
|
* 명령 표면을 정리한다. 각 핸들러는 기존 것을 재사용.
|
|
7
7
|
*
|
|
8
8
|
* forgen dev probe-workflow arm|report|status ADR-009 §1 훅 발화 측정
|
|
9
|
-
* forgen dev parity codex [--dry-run] host parity (source 체크아웃 전용)
|
|
10
9
|
* forgen dev migrate [implicit-feedback|...] one-shot 스키마 마이그레이션
|
|
11
10
|
* forgen dev regress-map [--days N --top N] 최근 fix 집중 파일
|
|
12
11
|
*/
|
|
13
|
-
import * as fs from 'node:fs';
|
|
14
|
-
import * as path from 'node:path';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
12
|
function printDevHelp() {
|
|
17
13
|
console.log(`
|
|
18
14
|
forgen dev — developer / maintenance utilities
|
|
19
15
|
|
|
20
16
|
forgen dev probe-workflow arm|report|status Measure hook firing in dynamic-workflow subagents (ADR-009 §1)
|
|
21
|
-
forgen dev parity codex [--dry-run] Host parity checks (source checkout only)
|
|
22
17
|
forgen dev migrate [target] One-shot schema migration
|
|
23
18
|
forgen dev regress-map [--days N --top N] Top fix-touched files
|
|
24
19
|
`);
|
|
25
20
|
}
|
|
26
|
-
async function runParity(args) {
|
|
27
|
-
const sub = args[0];
|
|
28
|
-
if (sub !== 'codex') {
|
|
29
|
-
console.log('Usage:\n forgen dev parity codex [--dry-run]\n\nNotes:\n - source 체크아웃에서만 작동합니다 (tests/ 디렉토리 필요).\n - npm install 로 설치된 패키지에서는 run-parity.sh 가 없습니다.');
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const here = path.dirname(fileURLToPath(import.meta.url)); // dist/core
|
|
33
|
-
const scriptPath = path.resolve(here, '..', '..', 'tests', 'e2e', 'codex', 'run-parity.sh');
|
|
34
|
-
if (!fs.existsSync(scriptPath)) {
|
|
35
|
-
console.error('[forgen] run-parity.sh 는 source 체크아웃에서만 작동. 직접 git clone 후 실행하세요.');
|
|
36
|
-
console.error(` expected: ${scriptPath}`);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
const { spawnSync } = await import('node:child_process');
|
|
40
|
-
const dryRun = args.includes('--dry-run');
|
|
41
|
-
const result = spawnSync('bash', [scriptPath, ...(dryRun ? ['--dry-run'] : [])], { stdio: 'inherit' });
|
|
42
|
-
if (result.status !== 0)
|
|
43
|
-
process.exit(result.status ?? 1);
|
|
44
|
-
}
|
|
45
21
|
export async function handleDev(args) {
|
|
46
22
|
const sub = args[0];
|
|
47
23
|
const rest = args.slice(1);
|
|
@@ -51,9 +27,6 @@ export async function handleDev(args) {
|
|
|
51
27
|
await handleProbeWorkflow(rest);
|
|
52
28
|
return;
|
|
53
29
|
}
|
|
54
|
-
case 'parity':
|
|
55
|
-
await runParity(rest);
|
|
56
|
-
return;
|
|
57
30
|
case 'migrate': {
|
|
58
31
|
const { handleMigrate } = await import('./migrate-cli.js');
|
|
59
32
|
await handleMigrate(rest);
|
|
@@ -64,7 +37,15 @@ export async function handleDev(args) {
|
|
|
64
37
|
await handleRegressMap(rest);
|
|
65
38
|
return;
|
|
66
39
|
}
|
|
40
|
+
case undefined:
|
|
41
|
+
case 'help':
|
|
42
|
+
case '--help':
|
|
43
|
+
case '-h':
|
|
44
|
+
printDevHelp();
|
|
45
|
+
return;
|
|
67
46
|
default:
|
|
47
|
+
console.error(`[forgen] Unknown dev subcommand: ${sub}`);
|
|
68
48
|
printDevHelp();
|
|
49
|
+
process.exitCode = 1;
|
|
69
50
|
}
|
|
70
51
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface Probe {
|
|
2
|
+
section: string;
|
|
3
|
+
label: string;
|
|
4
|
+
ok: boolean;
|
|
5
|
+
hint?: string;
|
|
6
|
+
/** true 면 실패로 세지 않는 정보 표시 (△) */
|
|
7
|
+
info?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** `forgen config hooks` 용: 실제 settings.json 에 등록된 forgen hook 과 disableAllHooks 상태. */
|
|
10
|
+
export declare function readSettingsHooks(homeDir: string, pkgRoot: string): {
|
|
11
|
+
error?: string;
|
|
12
|
+
disableAll: boolean;
|
|
13
|
+
entries: Array<{
|
|
14
|
+
event: string;
|
|
15
|
+
command: string;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
export interface VerifyOptions {
|
|
19
|
+
homeDir: string;
|
|
20
|
+
forgenHome: string;
|
|
21
|
+
/** 실행 중인 forgen 패키지 루트 (shim 이 없을 때의 절대경로 비교용) */
|
|
22
|
+
pkgRoot: string;
|
|
23
|
+
/** 느린 실행 프로브 생략 (--quick): hook·MCP·statusLine 은 실행하지 않고 설정·파일만 본다. */
|
|
24
|
+
skipExec?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** 플랫폼별 셸 인용. POSIX 는 단일 인용, Windows(cmd) 는 큰따옴표. */
|
|
27
|
+
export declare function quoteShellArg(s: string, platform?: NodeJS.Platform): string;
|
|
28
|
+
export interface HostPresence {
|
|
29
|
+
claude: boolean;
|
|
30
|
+
codex: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** forgen 이 설치된 호스트. 파일 하나가 아니라 설치 흔적(shim·hook·MCP·명령·statusLine) 중 하나라도 있으면 설치된 것으로 본다. */
|
|
33
|
+
export declare function detectHosts(homeDir: string, pkgRoot: string): HostPresence;
|
|
34
|
+
/** settings·shim·hook·MCP·statusLine·데이터 파일 전체 검증. 순서는 출력 순서. */
|
|
35
|
+
export declare function collectProbes(opts: VerifyOptions): Promise<Probe[]>;
|