@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
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
* 2. MCP: 기존 config 파일(opencode.jsonc 우선, 없으면 opencode.json)에 mcp.forgen-compound
|
|
8
8
|
* surgical 병합. **JSONC 파서(jsonc-parser)로 주석/trailing-comma 보존**, 쓰기 전 백업
|
|
9
9
|
* (리뷰 HIGH: JSON.parse 가 공식 JSONC 를 clobber 하던 데이터 손실 수정).
|
|
10
|
-
* 3. AGENTS.md:
|
|
10
|
+
* 3. AGENTS.md: <config>/AGENTS.md 의 forgen rules block (Codex 헬퍼 재사용).
|
|
11
11
|
*/
|
|
12
12
|
import * as fs from 'node:fs';
|
|
13
13
|
import * as os from 'node:os';
|
|
14
14
|
import * as path from 'node:path';
|
|
15
15
|
import { applyEdits, modify, parse as parseJsonc } from 'jsonc-parser';
|
|
16
16
|
import { createLogger } from '../core/logger.js';
|
|
17
|
-
import {
|
|
17
|
+
import { cleanStaleAgentsMd, recordAgentsMdInstall, upsertForgenRulesInAgentsMd } from './install-codex.js';
|
|
18
18
|
const log = createLogger('install-opencode');
|
|
19
19
|
export const PLUGIN_FILENAME = 'forgen.ts';
|
|
20
20
|
export const PLUGIN_MARKER = 'forgen-managed';
|
|
@@ -142,7 +142,10 @@ export function planOpencodeInstall(opts) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
// ── 3) AGENTS.md rules (Codex 헬퍼 재사용) ──
|
|
145
|
-
|
|
145
|
+
// cwd 가 아니라 OpenCode 전역 지침 파일(<config>/AGENTS.md)에 쓴다. 예전에 cwd·홈에 남긴 블록은 걷어낸다.
|
|
146
|
+
const agentsMdPath = opts.agentsMdPath ?? path.join(configDir, 'AGENTS.md');
|
|
147
|
+
if (!opts.agentsMdPath)
|
|
148
|
+
result.staleAgentsMdCleaned = cleanStaleAgentsMd({ hostDir: configDir, targetPath: agentsMdPath, pkgRoot: opts.pkgRoot, dryRun }).cleaned;
|
|
146
149
|
const agentsResult = upsertForgenRulesInAgentsMd({ agentsMdPath, pkgRoot: opts.pkgRoot, dryRun });
|
|
147
150
|
result.agentsMdInjected = agentsResult.injected;
|
|
148
151
|
if (!dryRun)
|
|
@@ -115,7 +115,11 @@ export function renderResult(result, dryRun) {
|
|
|
115
115
|
if (result.claude) {
|
|
116
116
|
lines.push('');
|
|
117
117
|
lines.push(' Claude:');
|
|
118
|
-
lines.push(`
|
|
118
|
+
lines.push(` shim: ${result.claude.shimPath ? `${result.claude.shimPath} (${result.claude.shimStatus})` : 'not used (absolute paths)'}`);
|
|
119
|
+
lines.push(` statusLine: ${result.claude.statusLine}${result.claude.statusLine === 'custom' ? ' (another statusLine is set — left as is; `forgen statusline install --force|--chain`)' : ''}`);
|
|
120
|
+
lines.push(` agents: ${result.claude.agentsInstalled} ch-*.md → ${result.claude.agentsPath}`);
|
|
121
|
+
if (result.claude.legacyPluginCleaned)
|
|
122
|
+
lines.push(' removed leftover forgen@forgen-local plugin cache');
|
|
119
123
|
lines.push(` slash commands: ${result.claude.slashCommandsCount} → ${result.claude.slashCommandsPath}`);
|
|
120
124
|
lines.push(` settings.json hooks: ${result.claude.hooksInjected}`);
|
|
121
125
|
lines.push(` MCP: ${result.claude.mcpAlreadyPresent ? 'already present' : (result.claude.mcpRegistered ? 'registered' : 'skipped')}`);
|
|
@@ -126,6 +130,8 @@ export function renderResult(result, dryRun) {
|
|
|
126
130
|
skipped: 'skipped (--no-verify-skill)',
|
|
127
131
|
};
|
|
128
132
|
lines.push(` verify skill: ${verifyLine[result.claude.verifySkill]}`);
|
|
133
|
+
for (const e of result.claude.errors)
|
|
134
|
+
lines.push(` ✗ FAILED ${e}`);
|
|
129
135
|
}
|
|
130
136
|
if (result.codex) {
|
|
131
137
|
lines.push('');
|
|
@@ -135,6 +141,11 @@ export function renderResult(result, dryRun) {
|
|
|
135
141
|
lines.push(` MCP: ${result.codex.mcpAlreadyPresent ? 'already present' : (result.codex.mcpRegistered ? 'registered' : 'skipped')}`);
|
|
136
142
|
lines.push(` skills: ${result.codex.skillsInstalled} commands + ${result.codex.devGuideSkillsInstalled} dev-guide → ${result.codex.skillsPath}`);
|
|
137
143
|
lines.push(` agents: ${result.codex.agentsInstalled} ch-*.toml → ${result.codex.agentsPath}${result.codex.multiAgentEnabled ? '' : ' (⚠ config.toml 에 [features] multi_agent = true 가 없어 Codex 가 spawn 하지 못함 — 추가 권장)'}`);
|
|
144
|
+
lines.push(` AGENTS.md: ${result.codex.agentsMdPath}`);
|
|
145
|
+
for (const p of result.codex.staleAgentsMdCleaned)
|
|
146
|
+
lines.push(` cleaned old forgen block (your other content kept): ${p}`);
|
|
147
|
+
if (result.codex.agentsOverridePath)
|
|
148
|
+
lines.push(` ⚠ ${result.codex.agentsOverridePath} exists — Codex reads only that file at this level, so the forgen block in AGENTS.md is NOT read. Move the block there or remove the override.`);
|
|
138
149
|
lines.push(` rules: injected per session via SessionStart hook (<forgen-rules host="codex">)`);
|
|
139
150
|
const t = result.codex.hookTrust;
|
|
140
151
|
if (t.total > 0 && t.trusted === t.total) {
|
|
@@ -165,6 +176,8 @@ export function renderResult(result, dryRun) {
|
|
|
165
176
|
lines.push(` plugin: ${result.opencode.pluginInstalled ? 'installed' : 'skipped'} → ${result.opencode.pluginPath}`);
|
|
166
177
|
lines.push(` MCP: ${result.opencode.mcpAlreadyPresent ? 'already present' : (result.opencode.mcpRegistered ? 'registered' : 'skipped')}`);
|
|
167
178
|
lines.push(` AGENTS.md rules: ${result.opencode.agentsMdInjected ? 'injected' : 'skipped'}`);
|
|
179
|
+
for (const p of result.opencode.staleAgentsMdCleaned ?? [])
|
|
180
|
+
lines.push(` cleaned old forgen block (your other content kept): ${p}`);
|
|
168
181
|
lines.push(' note: 완료가드/context 주입은 후속 증분 (projection/inject 미완).');
|
|
169
182
|
}
|
|
170
183
|
lines.push('');
|
|
@@ -43,7 +43,7 @@ export declare function normalizeToolArgs(args: Record<string, unknown> | undefi
|
|
|
43
43
|
export declare function toolBeforeToClaudeInput(opencodeTool: string, opencodeArgs: Record<string, unknown> | undefined | null): ClaudePreToolInput;
|
|
44
44
|
/**
|
|
45
45
|
* forgen PreToolUse hook 의 stdout(JSON 여러 줄일 수 있음) → OpenCode 판정.
|
|
46
|
-
* permissionDecision:"deny" → block(throw). 그 외/파싱 실패 → 허용(fail-open — 가드 부재가
|
|
46
|
+
* permissionDecision:"deny"/"ask" → block(throw) (OpenCode 는 ask 를 지원하지 않음). 그 외/파싱 실패 → 허용(fail-open — 가드 부재가
|
|
47
47
|
* 도구를 막지 않는다, forgen 의 hook 실패 정책과 동일).
|
|
48
48
|
*/
|
|
49
49
|
export declare function decisionFromForgenOutput(stdout: string): OpencodeToolDecision;
|
|
@@ -60,7 +60,7 @@ export function toolBeforeToClaudeInput(opencodeTool, opencodeArgs) {
|
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* forgen PreToolUse hook 의 stdout(JSON 여러 줄일 수 있음) → OpenCode 판정.
|
|
63
|
-
* permissionDecision:"deny" → block(throw). 그 외/파싱 실패 → 허용(fail-open — 가드 부재가
|
|
63
|
+
* permissionDecision:"deny"/"ask" → block(throw) (OpenCode 는 ask 를 지원하지 않음). 그 외/파싱 실패 → 허용(fail-open — 가드 부재가
|
|
64
64
|
* 도구를 막지 않는다, forgen 의 hook 실패 정책과 동일).
|
|
65
65
|
*/
|
|
66
66
|
export function decisionFromForgenOutput(stdout) {
|
|
@@ -70,9 +70,11 @@ export function decisionFromForgenOutput(stdout) {
|
|
|
70
70
|
const hso = parsed.hookSpecificOutput;
|
|
71
71
|
if (hso && typeof hso === 'object') {
|
|
72
72
|
const decision = hso.permissionDecision;
|
|
73
|
-
if (decision === 'deny') {
|
|
73
|
+
if (decision === 'deny' || decision === 'ask') {
|
|
74
74
|
const reason = hso.permissionDecisionReason;
|
|
75
|
-
|
|
75
|
+
const base = typeof reason === 'string' ? reason : '[forgen] blocked by guard';
|
|
76
|
+
// OpenCode plugin 에는 확인 요청 경로가 없다 — ask 를 통과시키면 가드 무력화이므로 차단 + 안내.
|
|
77
|
+
return { block: true, reason: decision === 'ask' ? `${base}\n[forgen] OpenCode 는 확인 요청(ask)을 지원하지 않아 차단으로 처리했습니다. 의도한 작업이면 직접 실행하거나 FORGEN_USER_CONFIRMED=1 로 다시 실행하세요.` : base };
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
return { block: false };
|
|
@@ -55,7 +55,6 @@ interface EventOutputPolicy {
|
|
|
55
55
|
}
|
|
56
56
|
/** codex-rs/hooks/schema/generated/*.command.output.schema.json (rust-v0.153.4) 요약. */
|
|
57
57
|
export declare const CODEX_OUTPUT_SCHEMA: Readonly<Record<string, EventOutputPolicy>>;
|
|
58
|
-
export declare const projectCodexToClaude: ProjectToClaudeEvent;
|
|
59
58
|
/**
|
|
60
59
|
* Claude 어댑터의 사영. 1원칙(Claude reference) + spec §18.4 (Codex hooks.json schema 동일성)
|
|
61
60
|
* 에 따라 본 함수는 `projectCodexToClaude` 와 *같은 normalize 로직* 을 공유한다.
|
|
@@ -65,5 +64,14 @@ export declare const projectCodexToClaude: ProjectToClaudeEvent;
|
|
|
65
64
|
* 교체하면 되도록 — `getProjection(host)` 가 단일 진입점.)
|
|
66
65
|
*/
|
|
67
66
|
export declare const projectClaudeToClaude: ProjectToClaudeEvent;
|
|
67
|
+
/** ask 를 지원하지 않는 호스트에서 쓰는 안내 꼬리. */
|
|
68
|
+
export declare const ASK_UNSUPPORTED_NOTICE = "[forgen] \uC774 \uD638\uC2A4\uD2B8(Codex/OpenCode)\uB294 \uD655\uC778 \uC694\uCCAD(ask)\uC744 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC544 \uCC28\uB2E8\uC73C\uB85C \uCC98\uB9AC\uD588\uC2B5\uB2C8\uB2E4. \uC758\uB3C4\uD55C \uC791\uC5C5\uC774\uBA74 \uC0AC\uC6A9\uC790\uAC00 \uC9C1\uC811 \uC2E4\uD589\uD558\uAC70\uB098 FORGEN_USER_CONFIRMED=1 \uC744 \uC124\uC815\uD574 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.";
|
|
69
|
+
/**
|
|
70
|
+
* Codex 사영 = 공통 사영 + PreToolUse `ask` → `deny` + 안내.
|
|
71
|
+
* Codex 0.163 바이너리는 `permissionDecision:"ask"` 를 "PreToolUse hook returned unsupported permissionDecision:ask"
|
|
72
|
+
* 로 거부(훅 실패 = 가드 무력화)한다. 스키마 enum 에는 있지만 런타임이 지원하지 않으므로, 확인이 필요한 명령을
|
|
73
|
+
* 조용히 통과시키지 않고 차단 + 사유로 바꾼다.
|
|
74
|
+
*/
|
|
75
|
+
export declare const projectCodexToClaude: ProjectToClaudeEvent;
|
|
68
76
|
export declare function getProjection(host: HostId): ProjectToClaudeEvent;
|
|
69
77
|
export {};
|
package/dist/host/projection.js
CHANGED
|
@@ -81,7 +81,7 @@ function resolveEventName(raw, input) {
|
|
|
81
81
|
?? (typeof fromOutput === 'string' ? fromOutput : undefined);
|
|
82
82
|
return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
const projectCommon = (raw, input) => {
|
|
85
85
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
|
|
86
86
|
return { continue: true };
|
|
87
87
|
const payload = raw;
|
|
@@ -164,7 +164,24 @@ export const projectCodexToClaude = (raw, input) => {
|
|
|
164
164
|
* (왜 두 함수를 별도 export 하는가: 향후 schema 가 다른 host 가 추가될 때 본 binding 만
|
|
165
165
|
* 교체하면 되도록 — `getProjection(host)` 가 단일 진입점.)
|
|
166
166
|
*/
|
|
167
|
-
export const projectClaudeToClaude = (raw, input) =>
|
|
167
|
+
export const projectClaudeToClaude = (raw, input) => projectCommon(raw, input);
|
|
168
|
+
/** ask 를 지원하지 않는 호스트에서 쓰는 안내 꼬리. */
|
|
169
|
+
export const ASK_UNSUPPORTED_NOTICE = '[forgen] 이 호스트(Codex/OpenCode)는 확인 요청(ask)을 지원하지 않아 차단으로 처리했습니다. 의도한 작업이면 사용자가 직접 실행하거나 FORGEN_USER_CONFIRMED=1 을 설정해 다시 실행하세요.';
|
|
170
|
+
/**
|
|
171
|
+
* Codex 사영 = 공통 사영 + PreToolUse `ask` → `deny` + 안내.
|
|
172
|
+
* Codex 0.163 바이너리는 `permissionDecision:"ask"` 를 "PreToolUse hook returned unsupported permissionDecision:ask"
|
|
173
|
+
* 로 거부(훅 실패 = 가드 무력화)한다. 스키마 enum 에는 있지만 런타임이 지원하지 않으므로, 확인이 필요한 명령을
|
|
174
|
+
* 조용히 통과시키지 않고 차단 + 사유로 바꾼다.
|
|
175
|
+
*/
|
|
176
|
+
export const projectCodexToClaude = (raw, input) => {
|
|
177
|
+
const out = projectCommon(raw, input);
|
|
178
|
+
const hso = out.hookSpecificOutput;
|
|
179
|
+
if (hso && hso.hookEventName === 'PreToolUse' && hso.permissionDecision === 'ask') {
|
|
180
|
+
const reason = typeof hso.permissionDecisionReason === 'string' ? hso.permissionDecisionReason : '[forgen] confirmation required';
|
|
181
|
+
out.hookSpecificOutput = { ...hso, permissionDecision: 'deny', permissionDecisionReason: `${reason}\n${ASK_UNSUPPORTED_NOTICE}` };
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
};
|
|
168
185
|
/**
|
|
169
186
|
* OpenCode projection — P1 파운데이션 fail-loud 스텁.
|
|
170
187
|
* OpenCode 는 in-process plugin(throw/return)이라 subprocess stdout projection 과 형태가
|
package/dist/mcp/server.js
CHANGED
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
9
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
+
import { nodeEngineWarning } from '../core/node-engine.js';
|
|
10
11
|
import { registerTools } from './tools.js';
|
|
12
|
+
// stdout 은 MCP 프로토콜 전용 — Node 엔진 경고는 stderr 로만.
|
|
13
|
+
const nodeWarning = nodeEngineWarning();
|
|
14
|
+
if (nodeWarning)
|
|
15
|
+
process.stderr.write(`${nodeWarning}\n`);
|
|
11
16
|
if (!process.env.FORGEN_CWD && !process.env.COMPOUND_CWD) {
|
|
12
17
|
process.env.FORGEN_CWD = process.cwd();
|
|
13
18
|
process.env.COMPOUND_CWD = process.cwd(); // legacy compat
|
|
@@ -15,11 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { SolutionStatus, SolutionType } from '../engine/solution-format.js';
|
|
17
17
|
import type { SolutionDirConfig } from '../engine/solution-index.js';
|
|
18
|
+
import { defaultSolutionDirs as sharedDefaultSolutionDirs } from '../engine/solution-index.js';
|
|
18
19
|
export interface SearchOptions {
|
|
19
20
|
dirs?: SolutionDirConfig[];
|
|
20
21
|
type?: SolutionType;
|
|
21
22
|
status?: SolutionStatus;
|
|
22
23
|
limit?: number;
|
|
24
|
+
/** 프로젝트 범위 판정용 작업 디렉터리 (없으면 프로젝트 밖으로 본다). */
|
|
25
|
+
cwd?: string;
|
|
23
26
|
}
|
|
24
27
|
export interface ListOptions {
|
|
25
28
|
dirs?: SolutionDirConfig[];
|
|
@@ -59,11 +62,8 @@ export interface SolutionStats {
|
|
|
59
62
|
byType: Record<SolutionType, number>;
|
|
60
63
|
byScope: Record<'me' | 'team' | 'project' | 'universal', number>;
|
|
61
64
|
}
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
* MCP 서버에서 cwd를 전달받으면 project 스코프도 포함.
|
|
65
|
-
*/
|
|
66
|
-
export declare function defaultSolutionDirs(cwd?: string): SolutionDirConfig[];
|
|
65
|
+
/** 기본 솔루션 디렉토리 목록 — hook 매칭과 같은 함수(solution-index)를 쓴다. */
|
|
66
|
+
export declare const defaultSolutionDirs: typeof sharedDefaultSolutionDirs;
|
|
67
67
|
/**
|
|
68
68
|
* 쿼리 텍스트로 솔루션을 검색합니다.
|
|
69
69
|
* 태그 기반 Jaccard 매칭 + confidence 가중치.
|
|
@@ -15,45 +15,19 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
|
-
import { ME_SOLUTIONS, PACKS_DIR } from '../core/paths.js';
|
|
19
18
|
import { logMatchDecision } from '../engine/match-eval-log.js';
|
|
20
19
|
import { maskBlockedTokens } from '../engine/phrase-blocklist.js';
|
|
21
|
-
import { expandCompoundTags, expandQueryBigrams,
|
|
22
|
-
import { getOrBuildIndex } from '../engine/solution-index.js';
|
|
20
|
+
import { expandCompoundTags, expandQueryBigrams, expandQueryKoreanStems, extractSolutionTags, parseFrontmatterOnly, parseSolutionV3, } from '../engine/solution-format.js';
|
|
21
|
+
import { getOrBuildIndex, defaultSolutionDirs as sharedDefaultSolutionDirs } from '../engine/solution-index.js';
|
|
23
22
|
import { calculateRelevance, shouldRejectByR4T3Rules } from '../engine/solution-matcher.js';
|
|
24
23
|
import { mutateSolutionFile } from '../engine/solution-writer.js';
|
|
24
|
+
import { solutionInScope, solutionProjectWeight } from '../engine/solution-scope.js';
|
|
25
|
+
import { projectKeyFor } from '../store/rule-scope.js';
|
|
25
26
|
import { defaultNormalizer } from '../engine/term-normalizer.js';
|
|
26
27
|
import { filterSolutionContent } from '../hooks/prompt-injection-filter.js';
|
|
27
28
|
// ── 디렉토리 해석 ──
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
* MCP 서버에서 cwd를 전달받으면 project 스코프도 포함.
|
|
31
|
-
*/
|
|
32
|
-
export function defaultSolutionDirs(cwd) {
|
|
33
|
-
const dirs = [{ dir: ME_SOLUTIONS, scope: 'me' }];
|
|
34
|
-
// 팩 디렉토리 스캔 — 하위에 solutions/ 디렉토리가 있는 팩만 포함
|
|
35
|
-
// PR2c-2 (M7 fix): readdirSync 결과를 정렬해 결정적 순서 보장.
|
|
36
|
-
// 정렬 안 하면 같은 팩 집합도 파일시스템 순서에 따라 다른 cache key/precedence
|
|
37
|
-
// 가 생겨 LRU와 인덱스 결정성이 깨진다.
|
|
38
|
-
try {
|
|
39
|
-
if (fs.existsSync(PACKS_DIR)) {
|
|
40
|
-
const packEntries = fs.readdirSync(PACKS_DIR).sort();
|
|
41
|
-
for (const entry of packEntries) {
|
|
42
|
-
const solDir = path.join(PACKS_DIR, entry, 'solutions');
|
|
43
|
-
if (fs.existsSync(solDir)) {
|
|
44
|
-
dirs.push({ dir: solDir, scope: 'team' });
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
// 팩 디렉토리 접근 실패는 무시
|
|
51
|
-
}
|
|
52
|
-
if (cwd) {
|
|
53
|
-
dirs.push({ dir: path.join(cwd, '.compound', 'solutions'), scope: 'project' });
|
|
54
|
-
}
|
|
55
|
-
return dirs;
|
|
56
|
-
}
|
|
29
|
+
/** 기본 솔루션 디렉토리 목록 — hook 매칭과 같은 함수(solution-index)를 쓴다. */
|
|
30
|
+
export const defaultSolutionDirs = sharedDefaultSolutionDirs;
|
|
57
31
|
// ── 검색 ──
|
|
58
32
|
/**
|
|
59
33
|
* 쿼리 텍스트로 솔루션을 검색합니다.
|
|
@@ -67,7 +41,7 @@ export function searchSolutions(query, options) {
|
|
|
67
41
|
const dirs = options?.dirs ?? defaultSolutionDirs();
|
|
68
42
|
const limit = options?.limit ?? 10;
|
|
69
43
|
const index = getOrBuildIndex(dirs);
|
|
70
|
-
const queryTagsRaw =
|
|
44
|
+
const queryTagsRaw = extractSolutionTags(query);
|
|
71
45
|
if (queryTagsRaw.length === 0)
|
|
72
46
|
return [];
|
|
73
47
|
// R4-T2: mask query tokens that belong to blocked English compounds
|
|
@@ -89,14 +63,18 @@ export function searchSolutions(query, options) {
|
|
|
89
63
|
// `api-key`/`apikey`/`api-keys` candidates that hit hyphenated solution
|
|
90
64
|
// tags via direct intersection. This mirrors the same change in
|
|
91
65
|
// solution-matcher.rankCandidates so hook and MCP paths stay consistent.
|
|
92
|
-
|
|
66
|
+
// hook(rankCandidates)과 같은 확장 순서 — 한국어 활용형 어간 회복 포함.
|
|
67
|
+
const queryTagsWithBigrams = expandQueryKoreanStems(expandQueryBigrams(queryTags));
|
|
93
68
|
const normalizedPromptTags = defaultNormalizer.normalizeTerms(queryTagsWithBigrams);
|
|
94
69
|
const results = [];
|
|
70
|
+
const projectKey = options?.cwd ? projectKeyFor(options.cwd) : null;
|
|
95
71
|
for (const entry of index.entries) {
|
|
96
72
|
if (options?.type && entry.type !== options.type)
|
|
97
73
|
continue;
|
|
98
74
|
if (options?.status && entry.status !== options.status)
|
|
99
75
|
continue;
|
|
76
|
+
if (!solutionInScope(entry.projects, projectKey))
|
|
77
|
+
continue;
|
|
100
78
|
// R4-T1: solution-side compound expansion. See the matching block in
|
|
101
79
|
// solution-matcher.rankCandidates for the rationale (separation of
|
|
102
80
|
// matching set from Jaccard union for normalization stability).
|
|
@@ -136,7 +114,7 @@ export function searchSolutions(query, options) {
|
|
|
136
114
|
type: entry.type,
|
|
137
115
|
scope: entry.scope,
|
|
138
116
|
tags: entry.tags,
|
|
139
|
-
relevance: tagRelevance + nameBoost,
|
|
117
|
+
relevance: (tagRelevance + nameBoost) * solutionProjectWeight(entry.projects, projectKey),
|
|
140
118
|
matchedTags: [
|
|
141
119
|
...tagMatches,
|
|
142
120
|
...queryTags.filter((t) => nameWords.includes(t) && !tagMatches.includes(t)),
|
package/dist/mcp/tools.js
CHANGED
|
@@ -37,6 +37,7 @@ export function registerTools(server) {
|
|
|
37
37
|
}, async ({ query, type, status, limit }) => {
|
|
38
38
|
const results = searchSolutions(query, {
|
|
39
39
|
dirs: defaultSolutionDirs(getCwd()),
|
|
40
|
+
cwd: getCwd(),
|
|
40
41
|
type,
|
|
41
42
|
status,
|
|
42
43
|
limit,
|
|
@@ -274,8 +275,10 @@ export function registerTools(server) {
|
|
|
274
275
|
user_quote: z.string().optional().describe('The user\'s own words that prompted this correction, verbatim (not paraphrased). Shown back to the user as "what you said" when the rule later blocks or applies. Omit if you cannot quote verbatim.'),
|
|
275
276
|
axis_hint: z.enum(['quality_safety', 'autonomy', 'judgment_philosophy', 'communication_style']).nullable()
|
|
276
277
|
.describe('Which personalization axis this correction relates to (null if unclear)'),
|
|
278
|
+
this_project_only: z.boolean().optional().describe('true when the correction is specific to the current project (its domain, files, product). Omit for how-I-work preferences that apply everywhere.'),
|
|
279
|
+
rule_id: z.string().optional().describe('Full rule_id (see rule-list) ONLY when the user explicitly retires, replaces or amends that existing rule. Omit otherwise: existing rules are never changed by guessing.'),
|
|
277
280
|
},
|
|
278
|
-
}, async ({ session_id, kind, message, target, axis_hint, user_quote }) => {
|
|
281
|
+
}, async ({ session_id, kind, message, target, axis_hint, user_quote, rule_id, this_project_only }) => {
|
|
279
282
|
try {
|
|
280
283
|
// v1 session_id를 환경변수에서 가져옴 (하네스가 설정)
|
|
281
284
|
const effectiveSessionId = session_id || process.env.FORGEN_SESSION_ID || 'unknown';
|
|
@@ -296,6 +299,8 @@ export function registerTools(server) {
|
|
|
296
299
|
const cleanQuote = typeof user_quote === 'string' && user_quote.trim() && !isFullyPrivate(user_quote)
|
|
297
300
|
? stripPrivate(user_quote).cleaned.trim()
|
|
298
301
|
: '';
|
|
302
|
+
const { projectKeyFor } = await import('../store/rule-scope.js');
|
|
303
|
+
const projectKey = this_project_only ? projectKeyFor(process.env.FORGEN_CWD ?? process.cwd()) : null;
|
|
299
304
|
const result = processCorrection({
|
|
300
305
|
session_id: effectiveSessionId,
|
|
301
306
|
kind: kind,
|
|
@@ -303,6 +308,8 @@ export function registerTools(server) {
|
|
|
303
308
|
target: cleanTarget,
|
|
304
309
|
axis_hint: axis_hint,
|
|
305
310
|
...(cleanQuote ? { user_quote: cleanQuote } : {}),
|
|
311
|
+
...(rule_id ? { rule_id } : {}),
|
|
312
|
+
...(projectKey ? { projects: [projectKey] } : {}),
|
|
306
313
|
});
|
|
307
314
|
// Outcome tracking (Phase 1): attribute this correction to any
|
|
308
315
|
// pending injections in the session. Fail-open — attribution is a
|
|
@@ -322,6 +329,16 @@ export function registerTools(server) {
|
|
|
322
329
|
`${userVisibleConfirm}${axis} — kind: ${kindLabel}`,
|
|
323
330
|
`Evidence: ${result.evidence_event_id}`,
|
|
324
331
|
];
|
|
332
|
+
if (this_project_only) {
|
|
333
|
+
lines.push(projectKey ? `Project: ${projectKey} only` : 'Project: not inside a git project — recorded as global');
|
|
334
|
+
}
|
|
335
|
+
if (rule_id) {
|
|
336
|
+
const { loadRule } = await import('../store/rule-store.js');
|
|
337
|
+
const targetRule = loadRule(rule_id);
|
|
338
|
+
lines.push(targetRule
|
|
339
|
+
? `Target rule ${rule_id}: status=${targetRule.status}, phase=${targetRule.lifecycle?.phase ?? 'active'}`
|
|
340
|
+
: `Target rule ${rule_id}: not found — no rule was changed`);
|
|
341
|
+
}
|
|
325
342
|
if (result.temporary_rule) {
|
|
326
343
|
lines.push(`Temporary rule: "${result.temporary_rule.policy}" (${result.temporary_rule.strength}, scope: ${result.temporary_rule.scope})`);
|
|
327
344
|
const enforceViaCount = result.temporary_rule.enforce_via?.length ?? 0;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* forgen inspect profile/rules/evidence/session 출력 생성.
|
|
5
5
|
* Authoritative spec: docs/plans/2026-04-03-forgen-rule-renderer-spec.md §6
|
|
6
6
|
*/
|
|
7
|
+
import { enforceabilityLabel, ruleEnforced } from '../engine/rule-detectability.js';
|
|
7
8
|
import { axisDirection, AXIS_POLES } from '../store/profile-score.js';
|
|
8
9
|
import { initLocaleFromConfig, getLocale, qualityName, autonomyName, judgmentName, communicationName, trustName } from '../i18n/index.js';
|
|
9
10
|
/** 축 방향 라벨 — 팩 이름을 locale 로 변환. mid 는 "중간/mid" (미학습 아님). */
|
|
@@ -69,9 +70,10 @@ export function renderRules(rules) {
|
|
|
69
70
|
for (const r of active) {
|
|
70
71
|
// ADR-017 (critic): T2/T3 가 올린 flag 는 이전에 어디에도 안 보였다 — 여기서 가시화.
|
|
71
72
|
const flag = (r.lifecycle?.phase === 'flagged' ? ' ⚑ flagged (repeated violations/overrides — review)' : '')
|
|
72
|
-
+ (r.enforce_mode === 'advise' ? ' ⚠ advise (
|
|
73
|
+
+ (r.enforce_mode === 'advise' ? ' ⚠ advise (차단 안 함; 차단 켜기: forgen rule enforce <id>)' : '');
|
|
73
74
|
lines.push(` [${r.category}/${r.strength}] ${r.render_key} — ${r.policy}${flag}`);
|
|
74
|
-
|
|
75
|
+
// D12-C: 위반을 탐지할 수 없는 룰은 '자문'으로 표기한다 — 위반 0 이 준수를 뜻하지 않는다.
|
|
76
|
+
lines.push(` source: ${r.source} | evidence: ${r.evidence_refs.length} | ${ruleEnforced(r) ? `차단${enforceabilityLabel(r) === '자문' ? '' : ' · 탐지 가능'}` : enforceabilityLabel(r) === '자문' ? '자문 (위반 탐지 불가 — 준수로 세지 않음, 기록만)' : '탐지 가능 (기록만)'}`);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
if (suppressed.length > 0) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RenderResult } from './rule-renderer.js';
|
|
2
|
+
export interface RenderReport {
|
|
3
|
+
at: string;
|
|
4
|
+
included: string[];
|
|
5
|
+
omitted: Array<{
|
|
6
|
+
rule_id: string;
|
|
7
|
+
strength: string;
|
|
8
|
+
policy: string;
|
|
9
|
+
}>;
|
|
10
|
+
chars: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function recordRenderReport(result: RenderResult, nowIso?: string): void;
|
|
13
|
+
export declare function loadRenderReport(): RenderReport | null;
|
|
14
|
+
export interface RenderSummary {
|
|
15
|
+
at: string;
|
|
16
|
+
included: number;
|
|
17
|
+
omitted: number;
|
|
18
|
+
/** 누락된 룰의 강도별 개수 (strong 이 빠졌으면 가장 먼저 보여야 한다) */
|
|
19
|
+
omittedByStrength: Record<string, number>;
|
|
20
|
+
}
|
|
21
|
+
/** status 가 "빠진 룰 수·강도"를 보여 주기 위한 요약. 기록이 없으면 null. */
|
|
22
|
+
export declare function summarizeRenderReport(): RenderSummary | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 마지막 렌더 결과. status·doctor 가 "빠진 룰"을 보여 주는 근거이고, 실물 검증이 주입본과 대조하는 기준이다.
|
|
3
|
+
*/
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { STATE_DIR } from '../core/paths.js';
|
|
6
|
+
import { atomicWriteJSON, safeReadJSON } from '../hooks/shared/atomic-write.js';
|
|
7
|
+
const REPORT_PATH = path.join(STATE_DIR, 'render-report.json');
|
|
8
|
+
export function recordRenderReport(result, nowIso = new Date().toISOString()) {
|
|
9
|
+
const report = {
|
|
10
|
+
at: nowIso,
|
|
11
|
+
included: result.included.map((r) => r.rule_id),
|
|
12
|
+
omitted: result.omitted.map((r) => ({ rule_id: r.rule_id, strength: r.strength, policy: r.policy.slice(0, 120) })),
|
|
13
|
+
chars: result.text.length,
|
|
14
|
+
};
|
|
15
|
+
atomicWriteJSON(REPORT_PATH, report, { pretty: true });
|
|
16
|
+
}
|
|
17
|
+
export function loadRenderReport() {
|
|
18
|
+
return safeReadJSON(REPORT_PATH, null);
|
|
19
|
+
}
|
|
20
|
+
/** status 가 "빠진 룰 수·강도"를 보여 주기 위한 요약. 기록이 없으면 null. */
|
|
21
|
+
export function summarizeRenderReport() {
|
|
22
|
+
const r = loadRenderReport();
|
|
23
|
+
if (!r || !Array.isArray(r.included) || !Array.isArray(r.omitted))
|
|
24
|
+
return null;
|
|
25
|
+
const omittedByStrength = {};
|
|
26
|
+
for (const o of r.omitted)
|
|
27
|
+
omittedByStrength[o.strength] = (omittedByStrength[o.strength] ?? 0) + 1;
|
|
28
|
+
return { at: r.at, included: r.included.length, omitted: r.omitted.length, omittedByStrength };
|
|
29
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* 파이프라인: filter → dedupe(render_key) → group(category) → order → template → budget
|
|
8
8
|
*/
|
|
9
|
-
import type { Rule, SessionEffectiveState, Profile } from '../store/types.js';
|
|
9
|
+
import type { Rule, RuleStrength, RuleSource, SessionEffectiveState, Profile } from '../store/types.js';
|
|
10
10
|
export type RenderSurface = 'session_start' | 'recompose' | 'inspect';
|
|
11
11
|
export interface RenderContext {
|
|
12
12
|
surface: RenderSurface;
|
|
@@ -15,4 +15,30 @@ export interface RenderContext {
|
|
|
15
15
|
include_pack_summary: boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare const DEFAULT_CONTEXT: RenderContext;
|
|
18
|
-
|
|
18
|
+
declare const SECTION_ORDER: readonly ['Must Not', 'Working Defaults', 'When To Ask', 'How To Validate', 'How To Report'];
|
|
19
|
+
type SectionName = typeof SECTION_ORDER[number];
|
|
20
|
+
export declare const STRENGTH_RANK: Record<RuleStrength, number>;
|
|
21
|
+
/** 순위 비교(작을수록 먼저). 렌더러의 예산 우선순위·render_key 중복 제거와 forgen way 내보내기가 같은 기준을 쓴다. */
|
|
22
|
+
export interface RankKey {
|
|
23
|
+
strength: RuleStrength;
|
|
24
|
+
source: RuleSource;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
id: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function compareRank(a: RankKey, b: RankKey): number;
|
|
29
|
+
export declare const rankKeyOf: (r: Rule) => RankKey;
|
|
30
|
+
export interface FacetRule {
|
|
31
|
+
section: SectionName;
|
|
32
|
+
rule: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function facetDrivenRules(profile: Profile | null | undefined): FacetRule[];
|
|
35
|
+
export interface RenderResult {
|
|
36
|
+
text: string;
|
|
37
|
+
/** 실제 본문에 들어간 룰. 주입 카운트는 이 목록만 올린다. */
|
|
38
|
+
included: Rule[];
|
|
39
|
+
/** 예산 초과로 빠진 룰. 조용히 사라지지 않게 본문과 상태 파일에 표시한다. */
|
|
40
|
+
omitted: Rule[];
|
|
41
|
+
}
|
|
42
|
+
export declare function renderRulesDetailed(rules: Rule[], state: SessionEffectiveState, profile: Profile | null | undefined, ctx?: RenderContext): RenderResult;
|
|
43
|
+
export declare function renderRules(rules: Rule[], state: SessionEffectiveState, profile: Profile | null | undefined, ctx?: RenderContext): string;
|
|
44
|
+
export {};
|