@wooojin/forgen 0.6.5 → 0.6.6
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 +26 -0
- package/README.ja.md +1 -1
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/dist/cli.js +2 -2
- package/dist/core/block-cli.js +2 -4
- package/dist/core/dashboard.js +1 -1
- package/dist/core/explain-cli.js +3 -28
- package/dist/core/rate-limit-forecast.js +7 -1
- package/dist/core/state-gc.d.ts +14 -0
- package/dist/core/state-gc.js +47 -4
- package/dist/core/stats-cli.js +5 -5
- package/dist/core/statusline-cli.d.ts +24 -2
- package/dist/core/statusline-cli.js +125 -23
- package/dist/core/statusline-install.d.ts +8 -1
- package/dist/core/statusline-install.js +34 -3
- package/dist/engine/block-judge.js +4 -5
- package/dist/engine/context-signals.d.ts +20 -0
- package/dist/engine/context-signals.js +102 -0
- package/dist/engine/correction-cluster-runner.d.ts +3 -3
- package/dist/engine/correction-cluster-runner.js +48 -12
- package/dist/engine/correction-clustering.d.ts +27 -0
- package/dist/engine/correction-clustering.js +79 -3
- package/dist/engine/ko-colloquial.d.ts +13 -0
- package/dist/engine/ko-colloquial.js +45 -0
- package/dist/engine/lifecycle/lifecycle-cli.js +25 -5
- package/dist/engine/lifecycle/meta-reclassifier.d.ts +1 -0
- package/dist/engine/lifecycle/meta-reclassifier.js +3 -21
- package/dist/engine/lifecycle/rotated-logs.d.ts +18 -0
- package/dist/engine/lifecycle/rotated-logs.js +67 -0
- package/dist/engine/lifecycle/signals.d.ts +27 -1
- package/dist/engine/lifecycle/signals.js +55 -32
- package/dist/engine/lifecycle/types.d.ts +5 -0
- package/dist/engine/match-eval-log.d.ts +2 -0
- package/dist/engine/match-eval-log.js +1 -0
- package/dist/engine/ranking-pipeline.d.ts +9 -1
- package/dist/engine/ranking-pipeline.js +24 -2
- package/dist/engine/solution-format.d.ts +2 -0
- package/dist/engine/solution-format.js +6 -2
- package/dist/engine/solution-matcher.d.ts +5 -1
- package/dist/engine/solution-matcher.js +4 -2
- package/dist/hooks/solution-injector.js +7 -2
- package/dist/store/rule-store.d.ts +10 -0
- package/dist/store/rule-store.js +26 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/postinstall.js +6 -2
|
@@ -35,6 +35,7 @@ import { appendImplicitFeedback } from '../store/implicit-feedback-store.js';
|
|
|
35
35
|
import { emitSolutionEvent, querySurfacedWithin } from '../core/observability-store.js';
|
|
36
36
|
import { parseSolutionV3 } from '../engine/solution-format.js';
|
|
37
37
|
import { ME_SOLUTIONS } from '../core/paths.js';
|
|
38
|
+
import { buildContextTokens } from '../engine/context-signals.js';
|
|
38
39
|
const MAX_SOLUTIONS_PER_SESSION = 10;
|
|
39
40
|
/**
|
|
40
41
|
* Minimum relevance thresholds by fitness state (2026-04-21 gate sweep).
|
|
@@ -471,7 +472,8 @@ async function main() {
|
|
|
471
472
|
// allMatched는 backfill 용도로 보존: 이미 injected된 entry라도 같은 솔루션이
|
|
472
473
|
// 다시 매칭되면 그 정보로 cache의 missing tags를 채울 수 있다.
|
|
473
474
|
// matches는 새 주입 후보 (이미 injected는 제외).
|
|
474
|
-
const
|
|
475
|
+
const contextTokens = buildContextTokens(cwd, input.session_id);
|
|
476
|
+
const allMatched = matchSolutions(input.prompt, scope, cwd, contextTokens);
|
|
475
477
|
// Observability P1: matched emit — top-5 후보 각각 기록
|
|
476
478
|
try {
|
|
477
479
|
for (const candidate of allMatched.slice(0, 5)) {
|
|
@@ -571,10 +573,13 @@ async function main() {
|
|
|
571
573
|
for (const sol of matches) {
|
|
572
574
|
if (injected.has(sol.name))
|
|
573
575
|
continue;
|
|
574
|
-
|
|
576
|
+
// 맥락 가산은 순위에만 — relevance 하한 게이트는 가산 전 값으로 비교한다(맥락만으로 게이트 통과 금지).
|
|
577
|
+
if (sol.relevance - (sol.contextBonus ?? 0) < minRelevanceFor(sol.name))
|
|
575
578
|
continue;
|
|
576
579
|
const idMatches = sol.matchedIdentifiers?.length ?? 0;
|
|
577
580
|
const tagMatches = Math.max(0, sol.matchedTags.length - idMatches);
|
|
581
|
+
// 맥락 토큰(cwd/최근 편집 파일)은 relevance 가산에만 쓰고 이 게이트의 태그 수에는 넣지 않는다.
|
|
582
|
+
// 실측(S16): 범용 프롬프트 토큰 1개 + 맥락 3개를 0.5 가중으로 합산하면 무관한 솔루션이 통과했다.
|
|
578
583
|
if (idMatches < 1 && tagMatches < 2)
|
|
579
584
|
continue;
|
|
580
585
|
if (sol.status === 'experiment') {
|
|
@@ -57,6 +57,16 @@ export declare function findRuleByRenderKey(renderKey: string, source?: RuleSour
|
|
|
57
57
|
* Meta promotion (B→A) 의 rolling window 집계가 이 카운터를 소비한다.
|
|
58
58
|
*/
|
|
59
59
|
export declare function markRulesInjected(ruleIds: string[], nowIso?: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* lifecycle-scan --apply 가 signals(위반 로그)에서 재계산한 카운터를 저장한다.
|
|
62
|
+
* markRulesInjected 와 같이 updated_at 을 건드리지 않는다 — 카운터 동기화가 T4 decay 의
|
|
63
|
+
* "마지막 갱신" 신호를 리셋하면 안 된다. 값이 같으면 쓰지 않고 false 반환.
|
|
64
|
+
*/
|
|
65
|
+
export declare function syncRuleCounters(ruleId: string, counters: {
|
|
66
|
+
violation_count: number;
|
|
67
|
+
bypass_count: number;
|
|
68
|
+
last_violation_at?: string;
|
|
69
|
+
}): boolean;
|
|
60
70
|
export declare function updateRuleStatus(ruleId: string, status: RuleStatus): boolean;
|
|
61
71
|
/**
|
|
62
72
|
* 현재 세션 ID와 다른 scope:'session' 규칙을 비활성화.
|
package/dist/store/rule-store.js
CHANGED
|
@@ -125,8 +125,12 @@ export function loadAllRules() {
|
|
|
125
125
|
if (!rule || !isCompatibleSchema(rule, file))
|
|
126
126
|
continue;
|
|
127
127
|
const existingIdx = rules.findIndex((r) => r.rule_id === rule.rule_id);
|
|
128
|
-
if (existingIdx >= 0)
|
|
129
|
-
|
|
128
|
+
if (existingIdx >= 0) {
|
|
129
|
+
// project override 는 정책 본문만 — lifecycle(주입/위반 카운터·phase)은 사용자 로컬 상태라 me 쪽을 유지한다.
|
|
130
|
+
// 안 그러면 repo 에 commit 된 룰의 lifecycle(0)이 saveRule 로 me 파일을 덮어써 inject_count 가 리셋된다.
|
|
131
|
+
const meLifecycle = rules[existingIdx].lifecycle;
|
|
132
|
+
rules[existingIdx] = meLifecycle ? { ...rule, lifecycle: meLifecycle } : rule;
|
|
133
|
+
}
|
|
130
134
|
else
|
|
131
135
|
rules.push(rule);
|
|
132
136
|
}
|
|
@@ -211,6 +215,26 @@ export function markRulesInjected(ruleIds, nowIso = new Date().toISOString()) {
|
|
|
211
215
|
atomicWriteJSON(rulePath(rule.rule_id), updated, { pretty: true });
|
|
212
216
|
}
|
|
213
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* lifecycle-scan --apply 가 signals(위반 로그)에서 재계산한 카운터를 저장한다.
|
|
220
|
+
* markRulesInjected 와 같이 updated_at 을 건드리지 않는다 — 카운터 동기화가 T4 decay 의
|
|
221
|
+
* "마지막 갱신" 신호를 리셋하면 안 된다. 값이 같으면 쓰지 않고 false 반환.
|
|
222
|
+
*/
|
|
223
|
+
export function syncRuleCounters(ruleId, counters) {
|
|
224
|
+
const rule = loadRule(ruleId);
|
|
225
|
+
if (!rule)
|
|
226
|
+
return false;
|
|
227
|
+
const lifecycle = initLifecycle(rule);
|
|
228
|
+
const lastViolation = counters.last_violation_at ?? lifecycle.last_violation_at;
|
|
229
|
+
if (lifecycle.violation_count === counters.violation_count && lifecycle.bypass_count === counters.bypass_count && lifecycle.last_violation_at === lastViolation)
|
|
230
|
+
return false;
|
|
231
|
+
const updated = {
|
|
232
|
+
...rule,
|
|
233
|
+
lifecycle: { ...lifecycle, violation_count: counters.violation_count, bypass_count: counters.bypass_count, last_violation_at: lastViolation },
|
|
234
|
+
};
|
|
235
|
+
atomicWriteJSON(rulePath(rule.rule_id), updated, { pretty: true });
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
214
238
|
export function updateRuleStatus(ruleId, status) {
|
|
215
239
|
const rule = loadRule(ruleId);
|
|
216
240
|
if (!rule)
|
package/package.json
CHANGED
package/plugin.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -272,8 +272,11 @@ function applyStatusLineAuto(settings) {
|
|
|
272
272
|
const existing = settings.statusLine && settings.statusLine.command;
|
|
273
273
|
const owned = !existing || /^forgen(\s|$)/.test(String(existing).trim()) || /[\\/]dist[\\/]cli\.js"?\s+statusline(\s|$)/.test(String(existing));
|
|
274
274
|
if (!owned) return 'custom';
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
// 체인(`… statusline --after '<원본>'`)이면 forgen 경로만 갱신하고 --after 이후는 보존한다.
|
|
276
|
+
const chainAt = existing ? String(existing).search(/\sstatusline\s+--after\s/) : -1;
|
|
277
|
+
const next = chainAt >= 0 ? `${cmd}${String(existing).slice(chainAt + ' statusline'.length)}` : cmd;
|
|
278
|
+
if (existing === next) return 'unchanged';
|
|
279
|
+
settings.statusLine = { type: 'command', command: next };
|
|
277
280
|
return existing ? 'updated' : 'installed';
|
|
278
281
|
}
|
|
279
282
|
|
|
@@ -1185,6 +1188,7 @@ async function main() {
|
|
|
1185
1188
|
} else if (statusLineResult === 'custom') {
|
|
1186
1189
|
console.log('[forgen] statusLine is set to another command (e.g. claude-hud) — left untouched.');
|
|
1187
1190
|
console.log('[forgen] To switch to forgen (backup kept in statusLine_backup): forgen statusline install --force');
|
|
1191
|
+
console.log('[forgen] To keep it AND show forgen\'s line after it (chain, original kept in statusLine_backup): forgen statusline install --chain');
|
|
1188
1192
|
}
|
|
1189
1193
|
|
|
1190
1194
|
// First-run banner (신규 사용자 안내) — feat/codex-support P1-6
|