@wooojin/forgen 0.5.0 → 0.5.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.
Files changed (67) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +236 -0
  3. package/README.ja.md +16 -8
  4. package/README.ko.md +17 -9
  5. package/README.md +6 -1
  6. package/README.zh.md +16 -8
  7. package/assets/claude/skills/verify/SKILL.md +66 -0
  8. package/assets/shared/hook-registry.json +217 -22
  9. package/dist/cli.js +7 -3
  10. package/dist/core/auto-compound-runner.js +73 -14
  11. package/dist/core/changelog-cli.d.ts +4 -1
  12. package/dist/core/changelog-cli.js +8 -7
  13. package/dist/core/compound-sweep-cli.d.ts +4 -1
  14. package/dist/core/compound-sweep-cli.js +25 -5
  15. package/dist/core/doctor.js +37 -0
  16. package/dist/core/spawn.d.ts +26 -0
  17. package/dist/core/spawn.js +38 -3
  18. package/dist/core/uninstall.d.ts +7 -0
  19. package/dist/core/uninstall.js +46 -1
  20. package/dist/engine/compound-loop.js +20 -1
  21. package/dist/hooks/context-guard.d.ts +3 -0
  22. package/dist/hooks/context-guard.js +16 -8
  23. package/dist/hooks/hook-config.js +5 -0
  24. package/dist/hooks/hook-registry.d.ts +17 -1
  25. package/dist/hooks/hooks-generator.d.ts +2 -0
  26. package/dist/hooks/hooks-generator.js +8 -1
  27. package/dist/hooks/session-end.d.ts +41 -0
  28. package/dist/hooks/session-end.js +113 -0
  29. package/dist/hooks/session-recovery.js +18 -1
  30. package/dist/hooks/shared/hook-timing.js +6 -1
  31. package/dist/host/codex-adapter.js +5 -0
  32. package/dist/host/codex-hook-alive.d.ts +23 -0
  33. package/dist/host/codex-hook-alive.js +51 -0
  34. package/dist/host/codex-notify.d.ts +55 -0
  35. package/dist/host/codex-notify.js +153 -0
  36. package/dist/host/codex-rollout.d.ts +21 -0
  37. package/dist/host/codex-rollout.js +82 -0
  38. package/dist/host/codex-rules-context.d.ts +25 -0
  39. package/dist/host/codex-rules-context.js +62 -0
  40. package/dist/host/exec-host.d.ts +10 -0
  41. package/dist/host/exec-host.js +18 -3
  42. package/dist/host/install-claude.d.ts +14 -0
  43. package/dist/host/install-claude.js +53 -0
  44. package/dist/host/install-codex.d.ts +120 -0
  45. package/dist/host/install-codex.js +560 -52
  46. package/dist/host/install-orchestrator.d.ts +4 -0
  47. package/dist/host/install-orchestrator.js +32 -2
  48. package/dist/host/invoke-agent.js +1 -0
  49. package/dist/host/parity-harness.js +7 -3
  50. package/dist/host/projection.d.ts +37 -3
  51. package/dist/host/projection.js +93 -42
  52. package/dist/store/evidence-store.js +121 -57
  53. package/dist/store/rule-store.d.ts +41 -0
  54. package/dist/store/rule-store.js +77 -2
  55. package/hooks/hooks.json +13 -1
  56. package/package.json +1 -1
  57. package/plugin.json +1 -1
  58. package/skills/architecture-decision/SKILL.md +18 -0
  59. package/skills/calibrate/SKILL.md +18 -0
  60. package/skills/code-review/SKILL.md +17 -0
  61. package/skills/compound/SKILL.md +17 -0
  62. package/skills/deep-interview/SKILL.md +7 -0
  63. package/skills/docker/SKILL.md +18 -0
  64. package/skills/forge-loop/SKILL.md +23 -0
  65. package/skills/learn/SKILL.md +15 -0
  66. package/skills/retro/SKILL.md +16 -0
  67. package/skills/ship/SKILL.md +18 -0
@@ -160,6 +160,37 @@ function resolveProjectRulesDir() {
160
160
  export function loadActiveRules() {
161
161
  return loadAllRules().filter(r => r.status === 'active');
162
162
  }
163
+ /**
164
+ * render_key(+source, +scope)로 기존 rule을 찾는다 — status 무관(active/suppressed/removed/
165
+ * superseded 전부 포함). ADR-013 채굴 룰 재생성 결함 수정(RCA): promoteSessionCandidates가
166
+ * loadActiveRules() 로만 dedup 하다 보니 TTL/cap 로 은퇴(removed)된 render_key가 재차 채굴되면
167
+ * "없음" 으로 오판해 매번 새 rule_id + created_at=now 로 재생성 — 이게 6,701개 파일 중
168
+ * 6,525개가 removed 로 죽어 쌓인 근본 원인. 이 함수로 upsert identity 를 render_key 로
169
+ * 고정한다: 있으면 재활성화, 없을 때만 신규 생성.
170
+ *
171
+ * scope 필터가 필요한 이유: processCorrection()(evidence-processor.ts)이 fix-now/avoid-this
172
+ * 에 대해 scope:'session' 임시 rule 을 만들 때 *같은 render_key 공식*(`${axis}.${target-slug}`)
173
+ * 을 쓴다. scope 를 안 걸면 promoteSessionCandidates 가 그 임시 rule 을 "기존 me rule" 로
174
+ * 오인해 재활성화해버려 영구 승격이 아예 안 되는 회귀가 생긴다(실측: 회귀 테스트로 발견).
175
+ *
176
+ * 동일 render_key 매칭이 여럿(레거시 데이터 등 이례적 상황)이면 active 우선, 그다음
177
+ * updated_at 최신순으로 하나만 반환.
178
+ */
179
+ export function findRuleByRenderKey(renderKey, source, scope) {
180
+ const matches = loadAllRules().filter((r) => r.render_key === renderKey
181
+ && (source === undefined || r.source === source)
182
+ && (scope === undefined || r.scope === scope));
183
+ if (matches.length === 0)
184
+ return null;
185
+ matches.sort((a, b) => {
186
+ if (a.status === 'active' && b.status !== 'active')
187
+ return -1;
188
+ if (b.status === 'active' && a.status !== 'active')
189
+ return 1;
190
+ return b.updated_at.localeCompare(a.updated_at);
191
+ });
192
+ return matches[0];
193
+ }
163
194
  /**
164
195
  * ADR-002 Meta signal — rule 들이 프롬프트에 inject 되었음을 기록.
165
196
  * rule.lifecycle.inject_count +1, last_inject_at = now.
@@ -188,10 +219,54 @@ export function updateRuleStatus(ruleId, status) {
188
219
  saveRule(rule);
189
220
  return true;
190
221
  }
222
+ /** removed 룰 보관 기간 기본값 — 7일. TTL 로 은퇴된 지 이만큼 지나면 prune 대상. */
223
+ export const DEFAULT_PRUNE_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
191
224
  /**
192
- * 현재 세션 ID와 다른 scope:'session' 규칙을 비활성화.
193
- * 이전 세션의 임시 규칙이 새 세션에서 영향을 미치지 않도록 정리.
225
+ * status:'removed' 파일을 retention 기간이 지난 것만 실제 unlink.
226
+ * RCA: retire(updateRuleStatus)는 status flip만 하고 파일을 지우지 않아 6,525개 죽은
227
+ * 파일이 ~/.forgen/me/rules 에 쌓여 loadAllRules() linear scan 비용을 키우고
228
+ * cross-process race 창을 넓혔다. status 전이 시각(updated_at) 기준으로 retention을
229
+ * 재는 이유: removed 직후 즉시 지우면 (a) findRuleByRenderKey 가 재활성화할 기회를
230
+ * 없애고 (b) 오탐 은퇴를 되돌릴 유예가 사라진다.
231
+ *
232
+ * 기본 dry-run(apply=false) — 프로덕션 데이터 삭제는 호출측이 명시적으로 apply:true
233
+ * 를 넘길 때만. (compound-sweep-cli 의 `--prune-removed`는 `--apply` 없으면 dry-run.)
194
234
  */
235
+ export function pruneRemovedRules(opts = {}) {
236
+ const retentionMs = opts.retentionMs ?? DEFAULT_PRUNE_RETENTION_MS;
237
+ const apply = opts.apply ?? false;
238
+ const now = Date.now();
239
+ const candidates = [];
240
+ const deleted = [];
241
+ if (!fs.existsSync(ME_RULES))
242
+ return { candidates, deleted };
243
+ for (const file of fs.readdirSync(ME_RULES)) {
244
+ if (!file.endsWith('.json'))
245
+ continue;
246
+ const filePath = path.join(ME_RULES, file);
247
+ const rule = safeReadJSON(filePath, null);
248
+ if (rule?.status !== 'removed')
249
+ continue;
250
+ // 안전 불변식: prune 은 auto-mined advisory churn(결함1의 폭주 산출물)만 삭제한다.
251
+ // 영구·명시 룰(L1 하드룰, source:'explicit_correction')은 status:'removed' 여도
252
+ // 파일을 지우지 않는다 — 회귀 시 이력/복구 근거가 되고, 애초에 이 함수의 대상이 아니다.
253
+ const isAutoMinedChurn = rule.source === 'behavior_inference' || rule.render_key?.startsWith('auto:');
254
+ if (!isAutoMinedChurn)
255
+ continue;
256
+ const age = now - Date.parse(rule.updated_at);
257
+ if (!Number.isFinite(age) || age < retentionMs)
258
+ continue;
259
+ candidates.push(rule.rule_id);
260
+ if (apply) {
261
+ try {
262
+ fs.unlinkSync(filePath);
263
+ deleted.push(rule.rule_id);
264
+ }
265
+ catch { /* best-effort — 다음 prune 에서 재시도 */ }
266
+ }
267
+ }
268
+ return { candidates, deleted };
269
+ }
195
270
  export function cleanupStaleSessionRules(_currentSessionId) {
196
271
  if (!fs.existsSync(ME_RULES))
197
272
  return 0;
package/hooks/hooks.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Forgen harness hooks (auto-generated, 22/22 active)",
2
+ "description": "Forgen harness hooks (auto-generated, 23/23 active)",
3
3
  "hooks": {
4
4
  "UserPromptSubmit": [
5
5
  {
@@ -195,6 +195,18 @@
195
195
  }
196
196
  ]
197
197
  }
198
+ ],
199
+ "SessionEnd": [
200
+ {
201
+ "matcher": "*",
202
+ "hooks": [
203
+ {
204
+ "type": "command",
205
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/hooks/session-end.js\"",
206
+ "timeout": 3
207
+ }
208
+ ]
209
+ }
198
210
  ]
199
211
  }
200
212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooojin/forgen",
3
- "version": "0.5.0",
3
+ "version": "0.5.6",
4
4
  "preferGlobal": true,
5
5
  "main": "dist/lib.js",
6
6
  "types": "./dist/lib.d.ts",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://claude.ai/schemas/claude-plugin.json",
3
3
  "name": "forgen",
4
- "version": "0.5.0",
4
+ "version": "0.5.6",
5
5
  "description": "Claude Code harness — the more you use Claude, the better it gets",
6
6
  "author": {
7
7
  "name": "jang-ujin",
@@ -1,6 +1,24 @@
1
1
  ---
2
2
  name: architecture-decision
3
3
  description: This skill should be used when the user asks to "adr,ch-architecture decision,아키텍처 결정,설계 결정,기술 결정". ADR 생성 -- 대안 평가, 가중 트레이드오프 매트릭스, 결정 라이프사이클 관리
4
+ argument-hint: "[결정 주제]"
5
+ model: opus
6
+ allowed-tools:
7
+ - Read
8
+ - Grep
9
+ - Glob
10
+ - Bash
11
+ - Write
12
+ - Edit
13
+ - mcp__forgen-compound__compound-search
14
+ - mcp__forgen-compound__compound-read
15
+ - mcp__forgen-compound__compound-list
16
+ triggers:
17
+ - "adr"
18
+ - "ch-architecture decision"
19
+ - "아키텍처 결정"
20
+ - "설계 결정"
21
+ - "기술 결정"
4
22
  ---
5
23
 
6
24
  <Purpose>
@@ -1,6 +1,24 @@
1
1
  ---
2
2
  name: calibrate
3
3
  description: This skill should be used when the user asks to "calibrate, 캘리브레이트, 프로필 보정, 프로필 조정, 프로필 확인". 축적된 evidence(교정 기록)를 분석하여 4축 프로필 조정을 제안합니다.
4
+ argument-hint: "[기간: 7d/30d/90d]"
5
+ model: opus
6
+ allowed-tools:
7
+ - Read
8
+ - Grep
9
+ - Glob
10
+ - Bash
11
+ - mcp__forgen-compound__compound-search
12
+ - mcp__forgen-compound__compound-read
13
+ - mcp__forgen-compound__profile-read
14
+ - mcp__forgen-compound__correction-record
15
+ triggers:
16
+ - "calibrate"
17
+ - "캘리브레이트"
18
+ - "프로필 보정"
19
+ - "프로필 조정"
20
+ - "프로필 확인"
21
+ - "프로필 업데이트"
4
22
  ---
5
23
 
6
24
  <Purpose>
@@ -1,6 +1,23 @@
1
1
  ---
2
2
  name: code-review
3
3
  description: This skill should be used when the user asks to "code review,코드 리뷰,리뷰해줘,review this". 신뢰도 보정 기반 체계적 코드 리뷰 — compound 이력 연동, auto-fix, 20개 체크리스트.
4
+ argument-hint: "[file, PR number, or git range]"
5
+ model: opus
6
+ allowed-tools:
7
+ - Read
8
+ - Grep
9
+ - Glob
10
+ - Bash
11
+ - Edit
12
+ - Write
13
+ - Agent
14
+ triggers:
15
+ - "code review"
16
+ - "코드 리뷰"
17
+ - "리뷰해줘"
18
+ - "review this"
19
+ - "리뷰"
20
+ - "review"
4
21
  ---
5
22
 
6
23
  <Purpose>
@@ -1,6 +1,23 @@
1
1
  ---
2
2
  name: compound
3
3
  description: This skill should be used when the user asks to "복리화,compound,패턴 추출,솔루션 축적,what did we learn". Compound Engineering — extract reusable patterns from this session's work
4
+ argument-hint: "[solution description]"
5
+ model: inherit
6
+ allowed-tools:
7
+ - Bash
8
+ - Read
9
+ - Write
10
+ - mcp__forgen-compound__compound-search
11
+ - mcp__forgen-compound__compound-read
12
+ - mcp__forgen-compound__compound-list
13
+ - mcp__forgen-compound__compound-stats
14
+ triggers:
15
+ - "복리화"
16
+ - "compound"
17
+ - "패턴 추출"
18
+ - "솔루션 축적"
19
+ - "what did we learn"
20
+ - "배운 것 정리"
4
21
  ---
5
22
 
6
23
  <Purpose>
@@ -1,6 +1,13 @@
1
1
  ---
2
2
  name: deep-interview
3
3
  description: This skill should be used when the user asks to "deep-interview,딥인터뷰,심층인터뷰,deep interview". Deep requirement interview with weighted dimension scoring, challenge modes, and ontology tracking
4
+ argument-hint: "[project or feature description]"
5
+ triggers:
6
+ - "deep-interview"
7
+ - "딥인터뷰"
8
+ - "심층인터뷰"
9
+ - "deep interview"
10
+ - "요구사항 인터뷰"
4
11
  ---
5
12
 
6
13
  <Purpose>
@@ -1,6 +1,24 @@
1
1
  ---
2
2
  name: docker
3
3
  description: This skill should be used when the user asks to "docker,container,컨테이너,dockerfile,도커,docker-compose". Docker 컨테이너화 -- Dockerfile 최적화, Compose 구성, 보안 강화
4
+ argument-hint: "[컨테이너화 대상]"
5
+ model: sonnet
6
+ allowed-tools:
7
+ - Read
8
+ - Grep
9
+ - Glob
10
+ - Bash
11
+ - Write
12
+ - Edit
13
+ - mcp__forgen-compound__compound-search
14
+ - mcp__forgen-compound__compound-read
15
+ triggers:
16
+ - "docker"
17
+ - "container"
18
+ - "컨테이너"
19
+ - "dockerfile"
20
+ - "도커"
21
+ - "docker-compose"
4
22
  ---
5
23
 
6
24
  <Purpose>
@@ -1,6 +1,29 @@
1
1
  ---
2
2
  name: forge-loop
3
3
  description: This skill should be used when the user asks to "forge-loop, 포지루프, 끝까지, don't stop, goal, 목표, goal lock, scope lock". 작업을 PRD(User Story)로 분해 + 모든 수용 기준 충족까지 반복 실행. `--goal-only` 플래그로 PRD/수용기준 박제만 (실행 사이클 없이) 가능 — goal-locking pattern lightweight 진입점.
4
+ argument-hint: "[task description] [--goal-only]"
5
+ model: inherit
6
+ allowed-tools:
7
+ - Read
8
+ - Grep
9
+ - Glob
10
+ - Bash
11
+ - Agent
12
+ - Edit
13
+ - Write
14
+ triggers:
15
+ - "forge-loop"
16
+ - "포지루프"
17
+ - "끝까지"
18
+ - "don't stop"
19
+ - "완료될 때까지"
20
+ - "루프로 실행"
21
+ - "goal"
22
+ - "목표"
23
+ - "goal lock"
24
+ - "scope lock"
25
+ - "completion criteria"
26
+ - "수용 기준"
4
27
  ---
5
28
 
6
29
  <Purpose>
@@ -1,6 +1,21 @@
1
1
  ---
2
2
  name: learn
3
3
  description: This skill should be used when the user asks to "learn, 학습 관리, compound 정리, 솔루션 정리". Compound 지식의 관리 인터페이스 — 검색, 통계, 가지치기, 내보내기/가져오기.
4
+ argument-hint: "[search {query}|stats|prune|export|import {path}]"
5
+ model: inherit
6
+ allowed-tools:
7
+ - Read
8
+ - Grep
9
+ - Glob
10
+ - Bash
11
+ triggers:
12
+ - "learn"
13
+ - "학습 관리"
14
+ - "compound 정리"
15
+ - "솔루션 정리"
16
+ - "compound 관리"
17
+ - "솔루션 관리"
18
+ - "지식 관리"
4
19
  ---
5
20
 
6
21
  <Purpose>
@@ -1,6 +1,22 @@
1
1
  ---
2
2
  name: retro
3
3
  description: This skill should be used when the user asks to "retro, 회고, retrospective, 돌아보기". Git 메트릭 + compound 건강도 + 학습 추세를 교차 분석하는 회고 리포트.
4
+ argument-hint: "[7d|14d|30d] [compare]"
5
+ model: inherit
6
+ allowed-tools:
7
+ - Read
8
+ - Grep
9
+ - Glob
10
+ - Bash
11
+ triggers:
12
+ - "retro"
13
+ - "회고"
14
+ - "retrospective"
15
+ - "돌아보기"
16
+ - "주간 회고"
17
+ - "월간 회고"
18
+ - "주간회고"
19
+ - "월간회고"
4
20
  ---
5
21
 
6
22
  <Purpose>
@@ -1,6 +1,24 @@
1
1
  ---
2
2
  name: ship
3
3
  description: This skill should be used when the user asks to "ship, 배포, 릴리스, release". 비대화형 자동 릴리스 파이프라인 — 테스트, 리뷰, 버전, CHANGELOG, PR을 원커맨드로.
4
+ argument-hint: "[patch|minor|major]"
5
+ model: inherit
6
+ disable-model-invocation: true
7
+ allowed-tools:
8
+ - Read
9
+ - Grep
10
+ - Glob
11
+ - Bash
12
+ - Agent
13
+ - Edit
14
+ - Write
15
+ triggers:
16
+ - "ship"
17
+ - "배포"
18
+ - "릴리스"
19
+ - "release"
20
+ - "릴리즈"
21
+ - "배포해줘"
4
22
  ---
5
23
 
6
24
  <Purpose>