@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/doctor.js
CHANGED
|
@@ -3,12 +3,14 @@ import * as os from 'node:os';
|
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { execFileSync } from 'node:child_process';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { FORGEN_HOME, LAB_DIR, ME_BEHAVIOR, ME_DIR, ME_SOLUTIONS, ME_RULES,
|
|
6
|
+
import { FORGEN_HOME, LAB_DIR, ME_BEHAVIOR, ME_DIR, ME_SOLUTIONS, ME_RULES, SESSIONS_DIR, STATE_DIR, V1_SESSIONS_DIR } from './paths.js';
|
|
7
7
|
import { getTimingStats } from '../hooks/shared/hook-timing.js';
|
|
8
8
|
import { countSessionScopedFiles, pruneState } from './state-gc.js';
|
|
9
9
|
import { summarizeAllByHost } from '../store/host-mismatch.js';
|
|
10
10
|
import { readForgeLoopState } from '../hooks/shared/forge-loop-state.js';
|
|
11
11
|
import { effortAdvisory } from './effort-advisory.js';
|
|
12
|
+
import { forgenRunShimPath } from '../host/claude-shim.js';
|
|
13
|
+
import { collectProbes, detectHosts } from './doctor-verify.js';
|
|
12
14
|
/** ~/.claude/projects/ — Claude Code 세션 저장 경로 */
|
|
13
15
|
const CLAUDE_PROJECTS_DIR = path.join(os.homedir(), '.claude', 'projects');
|
|
14
16
|
let currentSection = '';
|
|
@@ -25,12 +27,16 @@ function check(label, condition, hint) {
|
|
|
25
27
|
failedChecks.push({ section: currentSection, label, hint });
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
/** 실패로 세지 않는 정보 줄 (△) */
|
|
31
|
+
function info(label, hint) {
|
|
32
|
+
console.log(` △ ${label}${hint ? ` — ${hint}` : ''}`);
|
|
33
|
+
}
|
|
34
|
+
function printProbes(probes) {
|
|
35
|
+
for (const p of probes) {
|
|
36
|
+
if (p.info)
|
|
37
|
+
info(p.label, p.hint);
|
|
38
|
+
else
|
|
39
|
+
check(p.label, p.ok, p.hint);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
function exists(p) {
|
|
@@ -46,20 +52,6 @@ function commandExists(cmd) {
|
|
|
46
52
|
return false;
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
|
-
/** parity-result.json 내용에서 경과 시간을 사람이 읽기 좋은 문자열로 변환 */
|
|
50
|
-
function relativeTime(isoString) {
|
|
51
|
-
const diffMs = Date.now() - new Date(isoString).getTime();
|
|
52
|
-
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
|
53
|
-
if (diffDays === 0) {
|
|
54
|
-
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
|
|
55
|
-
if (diffHours === 0) {
|
|
56
|
-
const diffMins = Math.floor(diffMs / (1000 * 60));
|
|
57
|
-
return `${diffMins}m ago`;
|
|
58
|
-
}
|
|
59
|
-
return `${diffHours}h ago`;
|
|
60
|
-
}
|
|
61
|
-
return `${diffDays}d ago`;
|
|
62
|
-
}
|
|
63
55
|
/** ADR-014 D4 — [Codex Hooks] 섹션: hooks.json forgen 엔트리의 Codex trust 기록 대조 */
|
|
64
56
|
async function renderCodexHookTrust() {
|
|
65
57
|
try {
|
|
@@ -95,116 +87,37 @@ async function renderCodexHookTrust() {
|
|
|
95
87
|
}
|
|
96
88
|
catch { /* fail-open */ }
|
|
97
89
|
}
|
|
98
|
-
/**
|
|
99
|
-
function
|
|
100
|
-
console.log(' [Codex Parity]');
|
|
101
|
-
const parityPath = path.join(STATE_DIR, 'parity-result.json');
|
|
102
|
-
if (!fs.existsSync(parityPath)) {
|
|
103
|
-
console.log(' △ Codex parity 미실행 — tests/e2e/codex/run-parity.sh 또는 forgen dev parity codex');
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
let data;
|
|
90
|
+
/** 고정 shim 이 가리키는 패키지가 살아 있는가 (collectProbes 의 shim 항목과 같은 판정). */
|
|
91
|
+
export function shimTargetOk(homeDir = os.homedir()) {
|
|
107
92
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
console.log(' ✗ Codex parity — parity-result.json 파싱 실패');
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (data.passed === null || data.passed === undefined) {
|
|
115
|
-
console.log(' △ Codex parity dry-run only — 실 실행 필요');
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (!data.passed) {
|
|
119
|
-
const timeStr = data.at ? relativeTime(data.at) : 'unknown';
|
|
120
|
-
const detail = data.result ?? data.note ?? 'no detail';
|
|
121
|
-
console.log(` ✗ Codex parity FAILED (at: ${timeStr}, detail: ${detail})`);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
// passed === true
|
|
125
|
-
const timeStr = data.at ? relativeTime(data.at) : 'unknown';
|
|
126
|
-
const version = data.version ? ` version ${data.version}` : '';
|
|
127
|
-
const diffMs = data.at ? Date.now() - new Date(data.at).getTime() : Infinity;
|
|
128
|
-
const sevenDaysMs = 7 * 24 * 60 * 60 * 1000;
|
|
129
|
-
if (diffMs > sevenDaysMs) {
|
|
130
|
-
console.log(` △ Codex parity green but stale (last run: ${timeStr}) — 재실행 권장`);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
console.log(` ✓ Codex parity green (last run: ${timeStr},${version})`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/** plugin cache 디렉토리에 버전 엔트리가 하나 이상 있는가 (check + repair 재검증 공용) */
|
|
137
|
-
export function pluginCacheOk() {
|
|
138
|
-
const pluginCacheBase = path.join(os.homedir(), '.claude', 'plugins', 'cache', 'forgen-local', 'forgen');
|
|
139
|
-
if (!exists(pluginCacheBase))
|
|
140
|
-
return false;
|
|
141
|
-
try {
|
|
142
|
-
return fs.readdirSync(pluginCacheBase).some(f => {
|
|
143
|
-
try {
|
|
144
|
-
const lstat = fs.lstatSync(path.join(pluginCacheBase, f));
|
|
145
|
-
return lstat.isDirectory() || lstat.isSymbolicLink();
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
93
|
+
const content = fs.readFileSync(forgenRunShimPath(homeDir), 'utf-8');
|
|
94
|
+
const pkg = content.match(/^FORGEN_PKG='(.*)'$/m)?.[1];
|
|
95
|
+
return !!pkg && exists(path.join(pkg, 'dist', 'cli.js'));
|
|
151
96
|
}
|
|
152
97
|
catch {
|
|
153
98
|
return false;
|
|
154
99
|
}
|
|
155
100
|
}
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!exists(installedPluginsPath))
|
|
160
|
-
return false;
|
|
161
|
-
try {
|
|
162
|
-
const installed = JSON.parse(fs.readFileSync(installedPluginsPath, 'utf-8'));
|
|
163
|
-
const entry = installed?.plugins?.['forgen@forgen-local'];
|
|
164
|
-
if (Array.isArray(entry) && entry.length > 0) {
|
|
165
|
-
const installPath = entry[0]?.installPath;
|
|
166
|
-
return !!installPath && exists(installPath);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
catch { /* ignore */ }
|
|
170
|
-
return false;
|
|
101
|
+
/** 실행 중인 forgen 패키지 루트 (dist/core/doctor.js 기준 두 단계 위) */
|
|
102
|
+
function currentPkgRoot() {
|
|
103
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
171
104
|
}
|
|
172
105
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* W1-4 수정 (ADR-010, 실측 2026-07-16): 이전 구현은 무조건 `npm run build` 를
|
|
177
|
-
* 먼저 실행했는데, 글로벌 설치엔 devDeps(tsc)가 없어 MODULE_NOT_FOUND 로 실패
|
|
178
|
-
* → postinstall 에 도달하지 못해 캐시가 영원히 복구되지 않았다. published
|
|
179
|
-
* 패키지는 dist 가 이미 있으므로 build 는 dist 부재(dev checkout)시에만 시도.
|
|
180
|
-
* 또한 "실행했다"가 아니라 "복구됐다"를 재검증 후 보고한다.
|
|
106
|
+
* `--repair`: 설치와 같은 경로(planClaudeInstall)로 shim·settings hook·statusLine·MCP·명령·스킬을 다시 쓴다.
|
|
107
|
+
* 실행했다는 사실이 아니라 호출부가 재검증한 결과를 보고한다.
|
|
181
108
|
*/
|
|
182
|
-
function
|
|
109
|
+
async function reinstallForRepair() {
|
|
183
110
|
try {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// dev checkout 등 dist 부재 시에만 build (devDeps 가 있는 환경)
|
|
191
|
-
execFileSync('npm', ['run', 'build'], { cwd: pkgRoot, stdio: 'inherit' });
|
|
192
|
-
}
|
|
193
|
-
execFileSync('node', ['scripts/postinstall.js'], { cwd: pkgRoot, stdio: 'inherit' });
|
|
194
|
-
// 결과 재검증 — 성공 주장은 검증된 상태에만 한다.
|
|
195
|
-
const ok = pluginCacheOk() && pluginRegisteredOk();
|
|
196
|
-
if (ok) {
|
|
197
|
-
console.log(' [Repair] ✓ 복구 확인 — plugin cache/registry 재검증 통과');
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
console.warn(' [Repair] ✗ postinstall 은 실행됐지만 재검증 실패 — 수동 확인 필요');
|
|
201
|
-
console.warn(' [Repair] 수동 복구: cd <forgen pkgRoot> && node scripts/postinstall.js');
|
|
202
|
-
}
|
|
203
|
-
return ok;
|
|
111
|
+
const { planClaudeInstall } = await import('../host/install-claude.js');
|
|
112
|
+
const r = planClaudeInstall({ pkgRoot: currentPkgRoot(), homeDir: os.homedir() });
|
|
113
|
+
console.log(`\n [Repair] 재설치 경로 실행 — hooks ${r.hooksInjected}, MCP ${r.mcpRegistered ? '재등록' : '유지'}, statusLine ${r.statusLine}`);
|
|
114
|
+
for (const e of r.errors)
|
|
115
|
+
console.warn(` [Repair] 오류: ${e}`);
|
|
116
|
+
return r.errors.length === 0;
|
|
204
117
|
}
|
|
205
118
|
catch (e) {
|
|
206
119
|
console.warn(` [Repair] 실패: ${e instanceof Error ? e.message : String(e)}`);
|
|
207
|
-
console.warn(' [Repair] 수동 복구:
|
|
120
|
+
console.warn(' [Repair] 수동 복구: npm i -g @wooojin/forgen (또는 forgen install claude)');
|
|
208
121
|
return false;
|
|
209
122
|
}
|
|
210
123
|
}
|
|
@@ -213,73 +126,84 @@ async function runReclaimScan() {
|
|
|
213
126
|
try {
|
|
214
127
|
const { runReclaim, printReclaimResult } = await import('./migrate-tenetx.js');
|
|
215
128
|
printReclaimResult(runReclaim({ cwd: process.cwd(), dryRun: true }));
|
|
216
|
-
console.log(' 실제 회수: forgen migrate tenetx [--yes] [--apply-settings]');
|
|
129
|
+
console.log(' 실제 회수: forgen dev migrate tenetx [--yes] [--apply-settings]');
|
|
217
130
|
}
|
|
218
131
|
catch (e) {
|
|
219
132
|
console.warn(` [reclaim] 스캔 실패: ${e instanceof Error ? e.message : String(e)}`);
|
|
220
133
|
}
|
|
221
134
|
console.log();
|
|
222
135
|
}
|
|
223
|
-
/** W1-4: repair 성공 시 Summary 에서 걷어내는 대상 — check() 라벨과 단일 소스 */
|
|
224
|
-
const REPAIRABLE_PLUGIN_LABELS = Object.freeze({
|
|
225
|
-
cache: 'forgen plugin cache',
|
|
226
|
-
registered: 'forgen plugin registered & installPath exists',
|
|
227
|
-
});
|
|
228
136
|
export async function runDoctor(opts = {}) {
|
|
229
137
|
failedChecks = [];
|
|
230
138
|
console.log('\n Forgen — Diagnostics');
|
|
231
139
|
// ADR-010 W2-1 경계 선언: 일반 환경 건강(컨텍스트 비용, unused skill/MCP,
|
|
232
140
|
// CLAUDE.md 정리, slow hook)은 native /doctor 의 영역. 이 명령은 forgen
|
|
233
|
-
// 자체 기계(
|
|
141
|
+
// 자체 기계(hook·MCP·statusLine 실행 체인, 데이터 파일)와 효과-측정 게이트만 본다.
|
|
234
142
|
console.log(' 환경 전반 진단은 Claude Code native /doctor 를 사용하세요.');
|
|
235
|
-
console.log(' 이 명령은 forgen 자체
|
|
143
|
+
console.log(' 이 명령은 forgen 자체 기계를 실제로 실행해 검사합니다.\n');
|
|
144
|
+
const hosts = detectHosts(os.homedir(), currentPkgRoot());
|
|
236
145
|
section('Tools');
|
|
237
|
-
|
|
238
|
-
|
|
146
|
+
// Claude 에 설치하지 않은 사용자(Codex 전용·갓 설치 전)에게 claude CLI 부재는 고장이 아니다.
|
|
147
|
+
if (hosts.claude)
|
|
148
|
+
check('claude CLI', commandExists('claude'));
|
|
149
|
+
else if (!commandExists('claude'))
|
|
150
|
+
info('claude CLI 없음', 'forgen 이 Claude Code 에 설치돼 있지 않아 필수 아님');
|
|
151
|
+
else
|
|
152
|
+
info('claude CLI 있음', 'forgen 은 아직 Claude Code 에 설치되지 않음: forgen install claude');
|
|
239
153
|
check('git', commandExists('git'));
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const forgenPluginCacheOk = pluginCacheOk();
|
|
247
|
-
check(REPAIRABLE_PLUGIN_LABELS.cache, forgenPluginCacheOk, opts.repair
|
|
248
|
-
? 'Hook execution requires plugin cache. Attempting auto-repair (--repair)…'
|
|
249
|
-
: 'Hook execution requires plugin cache. Fix: node scripts/postinstall.js in the forgen package (or rerun with --repair)');
|
|
250
|
-
const pluginRegistered = pluginRegisteredOk();
|
|
251
|
-
check(REPAIRABLE_PLUGIN_LABELS.registered, pluginRegistered, opts.repair
|
|
252
|
-
? 'Plugin registered but installPath missing on disk. Attempting auto-repair (--repair)…'
|
|
253
|
-
: 'Plugin registered but installPath missing on disk. Fix: node scripts/postinstall.js in the forgen package (or rerun with --repair)');
|
|
254
|
-
// v0.4.8 (E3) + W1-4: plugin cache 또는 installPath 가 깨졌고 --repair 가
|
|
255
|
-
// 켜져 있으면 자가복구. 재검증까지 통과하면 failedChecks 에서 해당 항목을
|
|
256
|
-
// 걷어내 Summary 가 복구된 상태를 정직하게 반영하게 한다.
|
|
257
|
-
if (opts.repair && (!forgenPluginCacheOk || !pluginRegistered)) {
|
|
258
|
-
const repaired = attemptPluginRepair();
|
|
259
|
-
if (repaired) {
|
|
260
|
-
const pluginLabels = new Set(Object.values(REPAIRABLE_PLUGIN_LABELS));
|
|
261
|
-
failedChecks = failedChecks.filter(f => !pluginLabels.has(f.label));
|
|
262
|
-
}
|
|
154
|
+
if (!commandExists('tmux'))
|
|
155
|
+
info('tmux 없음', '선택 사항 (tmux 안에서 쓰면 auto-compound 알림이 보임)');
|
|
156
|
+
if (!commandExists('gh'))
|
|
157
|
+
info('gh (GitHub CLI) 없음', '선택 사항 (팀 PR 기능에만 필요): brew install gh');
|
|
158
|
+
if (!exists(path.join(os.homedir(), '.claude', 'plugins', 'cache', 'claude-plugins-official', 'ralph-loop'))) {
|
|
159
|
+
info('ralph-loop 플러그인 없음', '선택 사항 (ralph 모드 자동 반복에만 필요): claude plugins install ralph-loop');
|
|
263
160
|
}
|
|
264
161
|
console.log();
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
162
|
+
// 설치 체인 검증 — settings hook·MCP·statusLine·shim 을 실제로 실행해 본다.
|
|
163
|
+
const verifyOpts = { homeDir: os.homedir(), forgenHome: FORGEN_HOME, pkgRoot: currentPkgRoot(), skipExec: !!opts.quick };
|
|
164
|
+
let probes = await collectProbes(verifyOpts);
|
|
165
|
+
if (opts.repair && probes.some((p) => !p.ok && !p.info)) {
|
|
166
|
+
const before = probes.filter((p) => !p.ok && !p.info).length;
|
|
167
|
+
await reinstallForRepair();
|
|
168
|
+
probes = await collectProbes(verifyOpts);
|
|
169
|
+
const after = probes.filter((p) => !p.ok && !p.info);
|
|
170
|
+
console.log(after.length === 0
|
|
171
|
+
? ` [Repair] ✓ 복구 확인 — 재검증 통과 (실패 ${before} → 0)`
|
|
172
|
+
: ` [Repair] ✗ 재검증 후에도 ${after.length}건 남음 (이전 ${before}건) — 아래 항목은 재설치로 고쳐지지 않음\n`);
|
|
173
|
+
}
|
|
174
|
+
const bySection = new Map();
|
|
175
|
+
for (const p of probes)
|
|
176
|
+
bySection.set(p.section, [...(bySection.get(p.section) ?? []), p]);
|
|
177
|
+
for (const name of ['Install', 'Execution', 'Statusline']) {
|
|
178
|
+
const list = bySection.get(name);
|
|
179
|
+
if (!list)
|
|
180
|
+
continue;
|
|
181
|
+
section(name);
|
|
182
|
+
printProbes(list);
|
|
183
|
+
console.log();
|
|
272
184
|
}
|
|
273
|
-
catch { /* fail-open */ }
|
|
274
185
|
section('Directories');
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
186
|
+
// Claude 설치(shim·데이터가 여기에 있음)가 있는데 없으면 고장. 아직 어느 호스트에도 안 썼거나 Codex 전용이면 첫 실행 때 만들어진다.
|
|
187
|
+
if (hosts.claude)
|
|
188
|
+
check('~/.forgen/', exists(FORGEN_HOME));
|
|
189
|
+
else if (exists(FORGEN_HOME))
|
|
190
|
+
check('~/.forgen/', true);
|
|
191
|
+
else
|
|
192
|
+
info('~/.forgen/ 아직 없음', '첫 세션에서 만들어짐');
|
|
193
|
+
// 하위 폴더는 첫 사용·첫 세션에 런타임이 만든다. 없다고 고장이 아니다.
|
|
194
|
+
for (const [label, dir] of [
|
|
195
|
+
['~/.forgen/me/', ME_DIR],
|
|
196
|
+
['~/.forgen/me/solutions/', ME_SOLUTIONS],
|
|
197
|
+
['~/.forgen/me/behavior/', ME_BEHAVIOR],
|
|
198
|
+
['~/.forgen/me/rules/', ME_RULES],
|
|
199
|
+
['~/.forgen/sessions/ (session logs)', SESSIONS_DIR],
|
|
200
|
+
['~/.forgen/state/sessions/ (v1 effective state)', V1_SESSIONS_DIR],
|
|
201
|
+
]) {
|
|
202
|
+
if (exists(dir))
|
|
203
|
+
check(label, true);
|
|
204
|
+
else
|
|
205
|
+
info(`${label} 아직 없음`, '첫 세션에서 만들어짐');
|
|
206
|
+
}
|
|
283
207
|
// R9-IA5: warn if a user dropped rule files at ~/.forgen/rules/ by mistake.
|
|
284
208
|
// That path is NOT loaded — personal rules live at ~/.forgen/me/rules/.
|
|
285
209
|
const legacyRulesPath = path.join(FORGEN_HOME, 'rules');
|
|
@@ -295,16 +219,12 @@ export async function runDoctor(opts = {}) {
|
|
|
295
219
|
}
|
|
296
220
|
}
|
|
297
221
|
console.log();
|
|
298
|
-
section('
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
check('Hooks wired + profile ready', false, 'Hooks are active but personalization is disabled — run `forgen` to onboard');
|
|
305
|
-
}
|
|
306
|
-
else if (hooksWired && profileOk) {
|
|
307
|
-
check('Hooks wired + profile ready', true);
|
|
222
|
+
section('Data');
|
|
223
|
+
printProbes(bySection.get('Data') ?? []);
|
|
224
|
+
const hookHealth = bySection.get('Hook Health');
|
|
225
|
+
if (hookHealth) {
|
|
226
|
+
section('Hook Health 24h');
|
|
227
|
+
printProbes(hookHealth);
|
|
308
228
|
}
|
|
309
229
|
console.log();
|
|
310
230
|
if (opts.quick) {
|
|
@@ -318,11 +238,12 @@ export async function runDoctor(opts = {}) {
|
|
|
318
238
|
else {
|
|
319
239
|
console.log(` ${failedChecks.length} issue(s) found. Run \`forgen doctor\` for full diagnostics.\n`);
|
|
320
240
|
}
|
|
321
|
-
return;
|
|
241
|
+
return failedChecks.length;
|
|
322
242
|
}
|
|
323
243
|
// 리뷰 SEV-3 (c): critic-review 룰의 트리거가 stale(skip-review 시그널 미포함)이면 발견 nudge.
|
|
324
244
|
// "고쳤는데 기존 유저에겐 안 닿는" 상태 방지 — 재-bake 명령을 안내한다.
|
|
325
245
|
section('Rules');
|
|
246
|
+
printProbes(bySection.get('Rules') ?? []);
|
|
326
247
|
try {
|
|
327
248
|
const [{ loadActiveRules }, { needsCriticTriggerMigration }] = await Promise.all([
|
|
328
249
|
import('../store/rule-store.js'),
|
|
@@ -336,14 +257,14 @@ export async function runDoctor(opts = {}) {
|
|
|
336
257
|
}
|
|
337
258
|
console.log();
|
|
338
259
|
section('Environment');
|
|
339
|
-
|
|
340
|
-
|
|
260
|
+
info(`tmux: ${process.env.TMUX ? '안에서 실행 중' : '밖에서 실행 중'}`, '정보 표시 (실패로 세지 않음)');
|
|
261
|
+
info(`FORGEN_HARNESS: ${(process.env.FORGEN_HARNESS ?? process.env.COMPOUND_HARNESS) === '1' ? '설정됨' : '미설정'}`, '`forgen` / `fgx` 런처가 설정하는 값. 이 진단 셸에서는 정상적으로 비어 있을 수 있음');
|
|
341
262
|
// ADR-012: auto-compound Haiku 추출 동의 상태 고지 (transcript 요약 API 전송 여부).
|
|
342
263
|
try {
|
|
343
264
|
const { getHaikuConsentState } = await import('./compound-consent.js');
|
|
344
265
|
const s = getHaikuConsentState();
|
|
345
266
|
console.log(` auto-compound Haiku 추출: ${s.enabled ? 'ON' : 'OFF'} (${s.source}) — ` +
|
|
346
|
-
`${s.enabled ? '세션 요약이 Haiku 로 전송됨' : '결정론 룰 승급만(
|
|
267
|
+
`${s.enabled ? '세션 요약이 내 계정의 Haiku 로 전송됨(비밀키 마스킹)' : '결정론 룰 승급만(전송 없음)'}. 변경: forgen compound consent on|off`);
|
|
347
268
|
}
|
|
348
269
|
catch { /* noop */ }
|
|
349
270
|
console.log();
|
|
@@ -592,9 +513,6 @@ export async function runDoctor(opts = {}) {
|
|
|
592
513
|
console.log();
|
|
593
514
|
// [Codex Hooks] — ADR-014 D4 trust 감사
|
|
594
515
|
await renderCodexHookTrust();
|
|
595
|
-
// [Codex Parity] — parity-result.json 신선도 검사 (v0.4.2 패턴 확장)
|
|
596
|
-
renderCodexParity();
|
|
597
|
-
console.log();
|
|
598
516
|
// [ψ-long] — within-conversation compound 효과 측정 (v0.4.10)
|
|
599
517
|
// 측정 시간이 길어 ship-gate 는 advisory. 신선도(<= 14d) + psiLong > 0 만 확인.
|
|
600
518
|
console.log(' [ψ-long compound]');
|
|
@@ -666,4 +584,5 @@ export async function runDoctor(opts = {}) {
|
|
|
666
584
|
console.log('\n Run `forgen doctor` again after applying the fixes above.');
|
|
667
585
|
}
|
|
668
586
|
console.log();
|
|
587
|
+
return failedChecks.length;
|
|
669
588
|
}
|
package/dist/core/explain-cli.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { STATE_DIR } from './paths.js';
|
|
8
|
+
import { unreadable } from './flow-status.js';
|
|
8
9
|
import { readJsonlWindow, ROTATED_KEEP_DAYS, isRealBlock, effectiveVerdicts, readReceipt } from '../engine/lifecycle/signals.js';
|
|
9
10
|
const isTTY = process.stdout.isTTY;
|
|
10
11
|
const C = {
|
|
@@ -35,6 +36,13 @@ function formatTime(iso) {
|
|
|
35
36
|
export async function handleExplain(args) {
|
|
36
37
|
// ADR-017 D1: `--blocks` 는 실세션의 실제 차단만 보여준다(테스트 유래 'default' 세션·
|
|
37
38
|
// advise(correction)·명시 우회 제외). 원시 로그는 `forgen inspect`.
|
|
39
|
+
// 읽기 실패와 진짜 0건을 구분: state 를 읽을 수 없으면 "No blocks recorded" 가 아니라 오류.
|
|
40
|
+
const readErr = unreadable(path.join(STATE_DIR, 'enforcement'));
|
|
41
|
+
if (readErr) {
|
|
42
|
+
console.error(`\n ${C.red}차단 기록을 읽을 수 없습니다${C.reset} — ${readErr}\n (0건이 아니라 읽기 실패입니다. 권한을 확인하세요: ${path.join(STATE_DIR, 'enforcement')})\n`);
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
38
46
|
const violations = readViolations().filter((v) => isRealBlock(v));
|
|
39
47
|
if (violations.length === 0) {
|
|
40
48
|
console.log(`\n ${C.green}No blocks recorded.${C.reset} forgen hasn't blocked Claude yet.\n`);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 호출당 타임아웃. 실측(재생 13회, 2026-11-04): 입력 0.9~17K자에서 응답 3~35초(최대 34.8초, 17K자 학습 단계).
|
|
3
|
+
* 최악의 3.4배 여유로 120초. 이보다 오래 걸리면 호출이 아니라 환경 문제이므로 대기열로 보낸다.
|
|
4
|
+
*/
|
|
5
|
+
export declare const HAIKU_TIMEOUT_MS = 120000;
|
|
6
|
+
export type HaikuOutcome = 'ok' | 'timeout' | 'rate-limited' | 'unavailable' | 'error';
|
|
7
|
+
export interface HaikuResult {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
outcome: HaikuOutcome;
|
|
10
|
+
output: string;
|
|
11
|
+
ms: number;
|
|
12
|
+
reason?: string;
|
|
13
|
+
/** 대기열에서 재시도할 가치가 있는가 (미설치·미로그인은 재시도해도 같다) */
|
|
14
|
+
retriable: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const NESTED_ISOLATION_ARGS: ReadonlyArray<string>;
|
|
17
|
+
/** stderr 에서 CLI 가 모른다고 한 옵션 이름을 뽑는다 (없으면 null). */
|
|
18
|
+
export declare function parseUnknownOption(text: string): string | null;
|
|
19
|
+
/** args 에서 옵션(과 값)을 제거한다. */
|
|
20
|
+
export declare function dropOption(args: ReadonlyArray<string>, opt: string): string[];
|
|
21
|
+
/**
|
|
22
|
+
* 인증이 settings 파일(apiKeyHelper·프록시 base URL/토큰)에서 오는가. 중첩 호출은 `--setting-sources ""` 로 settings 를
|
|
23
|
+
* 읽지 않으므로 이런 환경에서는 인증이 빠져 실패한다 — "로그인 필요"와 다른 원인이라 구분해 보여 준다.
|
|
24
|
+
*/
|
|
25
|
+
export declare function settingsProvidedAuth(): string | null;
|
|
26
|
+
export declare function classifyFailure(err: {
|
|
27
|
+
code?: string;
|
|
28
|
+
signal?: string | null;
|
|
29
|
+
stderr?: string;
|
|
30
|
+
stdout?: string;
|
|
31
|
+
message?: string;
|
|
32
|
+
}): {
|
|
33
|
+
outcome: HaikuOutcome;
|
|
34
|
+
reason: string;
|
|
35
|
+
retriable: boolean;
|
|
36
|
+
};
|
|
37
|
+
export declare function appendExtractionEvent(ev: Record<string, unknown>): void;
|
|
38
|
+
/** 마지막 호출 결과 — status/세션 시작이 "왜 Haiku 가 안 도는지"를 말하는 근거. */
|
|
39
|
+
export declare function writeHaikuStatus(s: {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
outcome: HaikuOutcome;
|
|
42
|
+
reason?: string;
|
|
43
|
+
}): void;
|
|
44
|
+
export declare function readHaikuStatus(): {
|
|
45
|
+
at: string;
|
|
46
|
+
ok: boolean;
|
|
47
|
+
outcome: HaikuOutcome;
|
|
48
|
+
reason?: string;
|
|
49
|
+
} | null;
|
|
50
|
+
/** 호출 없이 판정: claude 미설치 / 미로그인(`claude auth status`는 모델을 호출하지 않는다). */
|
|
51
|
+
export declare function probeClaudeAvailability(): {
|
|
52
|
+
available: boolean;
|
|
53
|
+
reason?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Haiku 한 번 호출 (동기). 러너는 detached 프로세스라 이 대기는 다른 세션을 막지 않는다.
|
|
57
|
+
* prompt 는 stdin 으로 전달한다.
|
|
58
|
+
*/
|
|
59
|
+
export declare function callHaiku(phase: string, prompt: string, opts: {
|
|
60
|
+
cwd: string;
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
attempt?: number;
|
|
63
|
+
sessionId?: string;
|
|
64
|
+
}): HaikuResult;
|