@wooojin/forgen 0.1.0 → 0.1.1

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.
@@ -1,4 +1,5 @@
1
1
  import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
2
3
  import { GLOBAL_CONFIG, V1_GLOBAL_CONFIG } from './paths.js';
3
4
  /** v1 config 로드 (~/.forgen/config.json 우선, 레거시 폴백) */
4
5
  export function loadGlobalConfig() {
@@ -20,6 +21,6 @@ export function loadGlobalConfig() {
20
21
  }
21
22
  /** v1 config 저장 (~/.forgen/config.json) */
22
23
  export function saveGlobalConfig(config) {
23
- fs.mkdirSync(require('node:path').dirname(V1_GLOBAL_CONFIG), { recursive: true });
24
+ fs.mkdirSync(path.dirname(V1_GLOBAL_CONFIG), { recursive: true });
24
25
  fs.writeFileSync(V1_GLOBAL_CONFIG, JSON.stringify(config, null, 2));
25
26
  }
@@ -13,6 +13,7 @@
13
13
  * 5. Rule Renderer가 자연어 규칙 세트 생성
14
14
  */
15
15
  import * as fs from 'node:fs';
16
+ import * as path from 'node:path';
16
17
  import * as crypto from 'node:crypto';
17
18
  import { FORGEN_HOME, V1_ME_DIR, V1_RULES_DIR, V1_EVIDENCE_DIR, V1_RECOMMENDATIONS_DIR, V1_SESSIONS_DIR, V1_STATE_DIR, V1_RAW_LOGS_DIR, V1_SOLUTIONS_DIR } from './paths.js';
18
19
  import { checkLegacyProfile, runLegacyCutover } from './legacy-detector.js';
@@ -116,7 +117,7 @@ export function bootstrapV1Session() {
116
117
  // 8. Raw Log 기록 + TTL sweep (7일)
117
118
  try {
118
119
  // 세션 시작 로그
119
- const rawLogPath = require('node:path').join(V1_RAW_LOGS_DIR, `${sessionId}.jsonl`);
120
+ const rawLogPath = path.join(V1_RAW_LOGS_DIR, `${sessionId}.jsonl`);
120
121
  fs.appendFileSync(rawLogPath, JSON.stringify({
121
122
  event: 'session-started',
122
123
  session_id: sessionId,
@@ -131,7 +132,7 @@ export function bootstrapV1Session() {
131
132
  const TTL_MS = 7 * 24 * 60 * 60 * 1000;
132
133
  const now = Date.now();
133
134
  for (const file of fs.readdirSync(V1_RAW_LOGS_DIR)) {
134
- const filePath = require('node:path').join(V1_RAW_LOGS_DIR, file);
135
+ const filePath = path.join(V1_RAW_LOGS_DIR, file);
135
136
  try {
136
137
  const stat = fs.statSync(filePath);
137
138
  if (now - stat.mtimeMs > TTL_MS) {
@@ -28,14 +28,6 @@ export interface HookEntry {
28
28
  /** compound 피드백 루프에 필수인 훅인지 */
29
29
  compoundCritical: boolean;
30
30
  }
31
- /**
32
- * 단일 소스 오브 트루스: hooks/hook-registry.json
33
- *
34
- * 순서가 중요함:
35
- * - pre-tool-use는 db-guard/rate-limiter보다 앞에 위치
36
- * (Code Reflection + permission hints 주입 타이밍)
37
- * - 같은 이벤트 내 훅은 배열 순서대로 실행됨
38
- */
39
31
  export declare const HOOK_REGISTRY: HookEntry[];
40
32
  /** 티어별 훅 목록 조회 */
41
33
  export declare function getHooksByTier(tier: HookTier): HookEntry[];
@@ -20,7 +20,8 @@ const require = createRequire(import.meta.url);
20
20
  * (Code Reflection + permission hints 주입 타이밍)
21
21
  * - 같은 이벤트 내 훅은 배열 순서대로 실행됨
22
22
  */
23
- export const HOOK_REGISTRY = require('../../hooks/hook-registry.json');
23
+ import registryData from '../../hooks/hook-registry.json' with { type: 'json' };
24
+ export const HOOK_REGISTRY = registryData;
24
25
  /** 티어별 훅 목록 조회 */
25
26
  export function getHooksByTier(tier) {
26
27
  return HOOK_REGISTRY.filter(h => h.tier === tier);
@@ -4,6 +4,9 @@
4
4
  * 내부 타입은 한글 유지 (QualityPack = '보수형' | ...).
5
5
  * 사용자 대면 출력만 로케일에 따라 전환.
6
6
  */
7
+ import * as fs from 'node:fs';
8
+ import * as path from 'node:path';
9
+ import * as os from 'node:os';
7
10
  // ── Pack Display Names ──
8
11
  const QUALITY_NAMES = {
9
12
  ko: { '보수형': '보수형', '균형형': '균형형', '속도형': '속도형' },
@@ -212,8 +215,10 @@ export function getLocale() { return _currentLocale; }
212
215
  /** GlobalConfig에서 locale을 읽어 설정. 없으면 'en' 기본값. */
213
216
  export function initLocaleFromConfig() {
214
217
  try {
215
- const { loadGlobalConfig } = require('../core/global-config.js');
216
- const config = loadGlobalConfig();
218
+ const configPath = path.join(os.homedir(), '.forgen', 'config.json');
219
+ if (!fs.existsSync(configPath))
220
+ return;
221
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
217
222
  if (config.locale === 'ko' || config.locale === 'en') {
218
223
  _currentLocale = config.locale;
219
224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooojin/forgen",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "dist/lib.js",
5
5
  "types": "./dist/lib.d.ts",
6
6
  "exports": {