@triflux/core 10.0.0-alpha.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.
Files changed (75) hide show
  1. package/hooks/agent-route-guard.mjs +109 -0
  2. package/hooks/cross-review-tracker.mjs +122 -0
  3. package/hooks/error-context.mjs +148 -0
  4. package/hooks/hook-manager.mjs +352 -0
  5. package/hooks/hook-orchestrator.mjs +312 -0
  6. package/hooks/hook-registry.json +213 -0
  7. package/hooks/hooks.json +89 -0
  8. package/hooks/keyword-rules.json +581 -0
  9. package/hooks/lib/resolve-root.mjs +59 -0
  10. package/hooks/mcp-config-watcher.mjs +85 -0
  11. package/hooks/pipeline-stop.mjs +76 -0
  12. package/hooks/safety-guard.mjs +106 -0
  13. package/hooks/subagent-verifier.mjs +80 -0
  14. package/hub/assign-callbacks.mjs +133 -0
  15. package/hub/bridge.mjs +799 -0
  16. package/hub/cli-adapter-base.mjs +192 -0
  17. package/hub/codex-adapter.mjs +190 -0
  18. package/hub/codex-compat.mjs +78 -0
  19. package/hub/codex-preflight.mjs +147 -0
  20. package/hub/delegator/contracts.mjs +37 -0
  21. package/hub/delegator/index.mjs +14 -0
  22. package/hub/delegator/schema/delegator-tools.schema.json +250 -0
  23. package/hub/delegator/service.mjs +307 -0
  24. package/hub/delegator/tool-definitions.mjs +35 -0
  25. package/hub/fullcycle.mjs +96 -0
  26. package/hub/gemini-adapter.mjs +179 -0
  27. package/hub/hitl.mjs +143 -0
  28. package/hub/intent.mjs +193 -0
  29. package/hub/lib/process-utils.mjs +361 -0
  30. package/hub/middleware/request-logger.mjs +81 -0
  31. package/hub/paths.mjs +30 -0
  32. package/hub/pipeline/gates/confidence.mjs +56 -0
  33. package/hub/pipeline/gates/consensus.mjs +94 -0
  34. package/hub/pipeline/gates/index.mjs +5 -0
  35. package/hub/pipeline/gates/selfcheck.mjs +82 -0
  36. package/hub/pipeline/index.mjs +318 -0
  37. package/hub/pipeline/state.mjs +191 -0
  38. package/hub/pipeline/transitions.mjs +124 -0
  39. package/hub/platform.mjs +225 -0
  40. package/hub/quality/deslop.mjs +253 -0
  41. package/hub/reflexion.mjs +372 -0
  42. package/hub/research.mjs +146 -0
  43. package/hub/router.mjs +791 -0
  44. package/hub/routing/complexity.mjs +166 -0
  45. package/hub/routing/index.mjs +117 -0
  46. package/hub/routing/q-learning.mjs +336 -0
  47. package/hub/session-fingerprint.mjs +352 -0
  48. package/hub/state.mjs +245 -0
  49. package/hub/team-bridge.mjs +25 -0
  50. package/hub/token-mode.mjs +224 -0
  51. package/hub/workers/worker-utils.mjs +104 -0
  52. package/hud/colors.mjs +88 -0
  53. package/hud/constants.mjs +81 -0
  54. package/hud/hud-qos-status.mjs +206 -0
  55. package/hud/providers/claude.mjs +309 -0
  56. package/hud/providers/codex.mjs +151 -0
  57. package/hud/providers/gemini.mjs +320 -0
  58. package/hud/renderers.mjs +424 -0
  59. package/hud/terminal.mjs +140 -0
  60. package/hud/utils.mjs +287 -0
  61. package/package.json +31 -0
  62. package/scripts/lib/claudemd-manager.mjs +325 -0
  63. package/scripts/lib/context.mjs +67 -0
  64. package/scripts/lib/cross-review-utils.mjs +51 -0
  65. package/scripts/lib/env-probe.mjs +241 -0
  66. package/scripts/lib/gemini-profiles.mjs +85 -0
  67. package/scripts/lib/hook-utils.mjs +14 -0
  68. package/scripts/lib/keyword-rules.mjs +166 -0
  69. package/scripts/lib/logger.mjs +105 -0
  70. package/scripts/lib/mcp-filter.mjs +739 -0
  71. package/scripts/lib/mcp-guard-engine.mjs +940 -0
  72. package/scripts/lib/mcp-manifest.mjs +79 -0
  73. package/scripts/lib/mcp-server-catalog.mjs +118 -0
  74. package/scripts/lib/psmux-info.mjs +119 -0
  75. package/scripts/lib/remote-spawn-transfer.mjs +196 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Logify — triflux 구조화 로깅 설정
3
+ *
4
+ * 사용법:
5
+ * import { logger, createModuleLogger } from './lib/logger.mjs';
6
+ *
7
+ * // 기본 로거
8
+ * logger.info({ taskId: 'abc' }, 'task.started');
9
+ *
10
+ * // 모듈별 로거
11
+ * const log = createModuleLogger('hub');
12
+ * log.info({ port: 27888 }, 'server.started');
13
+ * log.error({ err }, 'server.error');
14
+ *
15
+ * 이벤트 네이밍: {도메인}.{액션} 형식
16
+ * hub.started, hub.stopped, route.started, route.completed,
17
+ * worker.spawned, worker.completed, worker.timeout,
18
+ * mcp.connected, mcp.disconnected, mcp.error,
19
+ * team.created, team.deleted, task.claimed, task.completed,
20
+ * pipe.connected, pipe.message, pipe.error,
21
+ * http.request, http.response, http.error
22
+ *
23
+ * 로그 레벨 가이드:
24
+ * debug — 개발/트러블슈팅용 (변수 값, MCP 메시지, 캐시 키)
25
+ * info — 정상 흐름 상태 변경 (서버 시작, 워커 완료, 팀 생성)
26
+ * warn — 위험 신호 (재시도 발생, 쿼타 임박, 느린 워커)
27
+ * error — 작업 실패 (CLI 실행 실패, MCP 연결 끊김)
28
+ * fatal — 프로세스 위협 (DB 연결 불가, 포트 충돌)
29
+ */
30
+ import pino from 'pino';
31
+
32
+ const isDev = process.env.NODE_ENV !== 'production';
33
+
34
+ export const logger = pino({
35
+ level: process.env.LOG_LEVEL || (isDev ? 'debug' : 'info'),
36
+
37
+ // 모든 로그에 포함되는 기본 필드
38
+ base: {
39
+ service: process.env.SERVICE_NAME || 'triflux',
40
+ env: process.env.NODE_ENV || 'development',
41
+ },
42
+
43
+ // 레벨을 대문자로 출력 (AI 파싱 용이)
44
+ formatters: {
45
+ level: (label) => ({ level: label.toUpperCase() }),
46
+ },
47
+
48
+ // ISO 8601 타임스탬프
49
+ timestamp: pino.stdTimeFunctions.isoTime,
50
+
51
+ // 민감정보 자동 필터링
52
+ redact: {
53
+ paths: [
54
+ 'password',
55
+ 'token',
56
+ 'apiKey',
57
+ 'secret',
58
+ 'authorization',
59
+ '*.password',
60
+ '*.token',
61
+ '*.apiKey',
62
+ '*.secret',
63
+ 'req.headers.authorization',
64
+ 'req.headers.cookie',
65
+ 'hubToken',
66
+ ],
67
+ remove: true,
68
+ },
69
+
70
+ // 개발 환경: 컬러 콘솔 출력
71
+ transport: isDev
72
+ ? {
73
+ target: 'pino-pretty',
74
+ options: {
75
+ colorize: true,
76
+ translateTime: 'yyyy-mm-dd HH:MM:ss',
77
+ ignore: 'pid,hostname',
78
+ },
79
+ }
80
+ : undefined,
81
+ });
82
+
83
+ /**
84
+ * 모듈별 Child Logger 생성.
85
+ * 모듈 이름이 모든 로그에 자동 포함된다.
86
+ *
87
+ * @param {string} module — 모듈 이름 (hub, route, worker, mcp, team 등)
88
+ * @returns {import('pino').Logger}
89
+ */
90
+ export function createModuleLogger(module) {
91
+ return logger.child({ module });
92
+ }
93
+
94
+ // 정상 종료 시 버퍼 flush 보장
95
+ process.on('uncaughtException', (err) => {
96
+ logger.fatal({ err }, 'process.uncaught_exception');
97
+ logger.flush();
98
+ process.exit(1);
99
+ });
100
+
101
+ process.on('unhandledRejection', (reason) => {
102
+ logger.fatal({ reason: String(reason) }, 'process.unhandled_rejection');
103
+ logger.flush();
104
+ process.exit(1);
105
+ });