aiwf 0.3.3 → 0.3.4

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 (203) hide show
  1. package/.aiwf/config/language.json +1 -1
  2. package/.aiwf/sessions/session_1752877859489_1t7n2fhdb.json +7 -0
  3. package/.aiwf/sessions/session_1752877859515_cwdv211ry.json +7 -0
  4. package/.aiwf/sessions/session_1752877860664_huziadmbo.json +7 -0
  5. package/.aiwf/sessions/session_1752877860666_kyr5u1np6.json +7 -0
  6. package/.aiwf/sessions/session_1752877861848_9yinepw3t.json +7 -0
  7. package/.aiwf/sessions/session_1752877861874_y32sputuc.json +7 -0
  8. package/.aiwf/sessions/session_1752877862685_ivxbl5rhz.json +7 -0
  9. package/.aiwf/sessions/session_1752877862820_wnq4glvxi.json +7 -0
  10. package/.aiwf/sessions/session_1752877864632_3ebnpaelb.json +7 -0
  11. package/.aiwf/sessions/session_1752877864879_b9zgjcb7d.json +7 -0
  12. package/.aiwf/sessions/session_1752877865533_x14m1vodi.json +7 -0
  13. package/.aiwf/sessions/session_1752877865562_gkoh19n7d.json +7 -0
  14. package/.aiwf/sessions/session_1752877866333_wp8qpdcoh.json +7 -0
  15. package/.aiwf/sessions/session_1752877866509_dawntfpab.json +7 -0
  16. package/.aiwf/sessions/session_1752877866890_plc5vfucl.json +7 -0
  17. package/.aiwf/sessions/session_1752877866895_ga8hmq3oi.json +7 -0
  18. package/.aiwf/sessions/session_1752877867761_ayjp4v5f5.json +7 -0
  19. package/.aiwf/sessions/session_1752877867892_lfz6jy252.json +7 -0
  20. package/.aiwf/sessions/session_1752877868139_7bqd9ubli.json +7 -0
  21. package/.aiwf/sessions/session_1752877868162_zq3ofjbsh.json +7 -0
  22. package/.aiwf/sessions/session_1752877869054_7rlgm9jt6.json +7 -0
  23. package/.aiwf/sessions/session_1752877869477_ax3nhbxzr.json +7 -0
  24. package/.aiwf/sessions/session_1752877870095_6hgp4vl1e.json +7 -0
  25. package/.aiwf/sessions/session_1752877870381_qfcrdg4li.json +7 -0
  26. package/.aiwf/sessions/session_1752877871895_pgd5vllhz.json +7 -0
  27. package/.aiwf/sessions/session_1752877872199_jbhv2g2da.json +7 -0
  28. package/.aiwf/sessions/session_1752877872680_x04wpffu6.json +7 -0
  29. package/.aiwf/sessions/session_1752877872895_3y4vbeauo.json +7 -0
  30. package/.aiwf/sessions/session_1752877873178_3maolzc6b.json +7 -0
  31. package/.aiwf/sessions/session_1752877873180_ytm83j07f.json +7 -0
  32. package/.aiwf/sessions/session_1752877874217_dp56c9t42.json +7 -0
  33. package/.aiwf/sessions/session_1752877874415_epwp1g1og.json +7 -0
  34. package/.aiwf/sessions/session_1752877874454_heicyuryb.json +7 -0
  35. package/.aiwf/sessions/session_1752877874869_1c2illeu5.json +7 -0
  36. package/.aiwf/sessions/session_1752877874879_k1vo4vxyx.json +7 -0
  37. package/.aiwf/sessions/session_1752877874913_bwgyiz9bp.json +7 -0
  38. package/.aiwf/sessions/session_1752877876218_44807kztz.json +7 -0
  39. package/.aiwf/sessions/session_1752877876515_qkhjv5kpw.json +7 -0
  40. package/.aiwf/sessions/session_1752877876543_p605aud1m.json +7 -0
  41. package/.aiwf/sessions/session_1752877876819_l65w7ifck.json +7 -0
  42. package/.aiwf/sessions/session_1752877876867_xrhzss4we.json +7 -0
  43. package/.aiwf/sessions/session_1752877876872_u7aso54qb.json +7 -0
  44. package/.aiwf/sessions/session_1752877877705_telnfg4o6.json +7 -0
  45. package/.aiwf/sessions/session_1752877878285_6s45im2ib.json +7 -0
  46. package/.aiwf/sessions/session_1752877878506_v0dvguqhz.json +7 -0
  47. package/.aiwf/sessions/session_1752877878581_3ri3yc66a.json +7 -0
  48. package/.aiwf/sessions/session_1752877878756_a82x9s2pd.json +7 -0
  49. package/.aiwf/sessions/session_1752877878886_20pjsfour.json +7 -0
  50. package/.aiwf/sessions/session_1752877880266_fm1ydjw0g.json +7 -0
  51. package/.aiwf/sessions/session_1752877881149_xbat4z03d.json +7 -0
  52. package/.aiwf/sessions/session_1752877881551_qy5sic9qs.json +7 -0
  53. package/.aiwf/sessions/session_1752877881554_24ugd96wu.json +7 -0
  54. package/.aiwf/sessions/session_1752877881797_e9mm25uh0.json +7 -0
  55. package/.aiwf/sessions/session_1752877881822_bxvjj8c9g.json +7 -0
  56. package/.aiwf/sessions/session_1752877881890_jv7l6jve3.json +7 -0
  57. package/.aiwf/sessions/session_1752877881991_f0qugdtcq.json +7 -0
  58. package/.aiwf/sessions/session_1752877883387_0bvw9rvnx.json +7 -0
  59. package/.aiwf/sessions/session_1752877883820_q6g2md2up.json +7 -0
  60. package/.aiwf/sessions/session_1752877884393_sqr7trvjl.json +7 -0
  61. package/.aiwf/sessions/session_1752877884500_whtypmzlf.json +7 -0
  62. package/.aiwf/sessions/session_1752877884645_y9mvvxli1.json +7 -0
  63. package/.aiwf/sessions/session_1752877884733_hk46eenel.json +7 -0
  64. package/.aiwf/sessions/session_1752877884738_c62j6214r.json +7 -0
  65. package/.aiwf/sessions/session_1752877884771_temhxehoz.json +7 -0
  66. package/.aiwf/sessions/session_1752877885643_6v5fcktc7.json +7 -0
  67. package/.aiwf/sessions/session_1752877886426_ee8di2fqh.json +7 -0
  68. package/.aiwf/sessions/session_1752877886549_3xj6tdoew.json +7 -0
  69. package/.aiwf/sessions/session_1752877886604_aj80yyfco.json +7 -0
  70. package/.aiwf/sessions/session_1752877886702_2b8841vyg.json +7 -0
  71. package/.aiwf/sessions/session_1752877886712_ntqc8b8bz.json +7 -0
  72. package/.aiwf/sessions/session_1752877886968_946m8tbw6.json +7 -0
  73. package/.aiwf/sessions/session_1752877887008_wg6zfg8dn.json +7 -0
  74. package/.aiwf/sessions/session_1752877888479_ciiu2qiqs.json +7 -0
  75. package/.aiwf/sessions/session_1752877889330_ravg8l66k.json +7 -0
  76. package/.aiwf/sessions/session_1752877889542_7zepkhjkc.json +7 -0
  77. package/.aiwf/sessions/session_1752877889638_ev4htqiu0.json +7 -0
  78. package/.aiwf/sessions/session_1752877889956_szphy2qma.json +7 -0
  79. package/.aiwf/sessions/session_1752877890220_o6aaa57tt.json +7 -0
  80. package/.aiwf/sessions/session_1752877890527_v2loy5vu1.json +7 -0
  81. package/.aiwf/sessions/session_1752877890572_cwq8fiuma.json +7 -0
  82. package/.aiwf/sessions/session_1752877892200_sgcwq1alt.json +7 -0
  83. package/.aiwf/sessions/session_1752877892268_v8kexpbc5.json +7 -0
  84. package/.aiwf/sessions/session_1752877892384_1gbbgrp4y.json +7 -0
  85. package/.aiwf/sessions/session_1752877893568_9p2n5p31a.json +7 -0
  86. package/.aiwf/sessions/session_1752877893727_un34a5tvp.json +7 -0
  87. package/.aiwf/sessions/session_1752877893778_01j79sw9i.json +7 -0
  88. package/.aiwf/sessions/session_1752877894053_jrhba6wko.json +7 -0
  89. package/.aiwf/sessions/session_1752877894082_x3bghawox.json +7 -0
  90. package/.aiwf/sessions/session_1752877894500_iytiav2ku.json +7 -0
  91. package/.aiwf/sessions/session_1752877894667_ucn0gc2ge.json +7 -0
  92. package/.aiwf/test-results-s02.json +4 -4
  93. package/.claude/commands/aiwf/aiwf_changelog.md +82 -0
  94. package/.claude/commands/aiwf/aiwf_code_review.md +88 -0
  95. package/.claude/commands/aiwf/aiwf_commit.md +160 -0
  96. package/.claude/commands/aiwf/aiwf_compress_aggressive_persona.md +53 -0
  97. package/.claude/commands/aiwf/aiwf_compress_context.md +116 -0
  98. package/.claude/commands/aiwf/aiwf_compress_minimal_persona.md +48 -0
  99. package/.claude/commands/aiwf/aiwf_compress_stats.md +79 -0
  100. package/.claude/commands/aiwf/aiwf_compress_with_persona.md +51 -0
  101. package/.claude/commands/aiwf/aiwf_create_feature_ledger.md +54 -0
  102. package/.claude/commands/aiwf/aiwf_create_general_task.md +147 -0
  103. package/.claude/commands/aiwf/aiwf_create_milestone_plan.md +194 -0
  104. package/.claude/commands/aiwf/aiwf_create_prd.md +280 -0
  105. package/.claude/commands/aiwf/aiwf_create_sprint_tasks.md +189 -0
  106. package/.claude/commands/aiwf/aiwf_create_sprints_from_milestone.md +121 -0
  107. package/.claude/commands/aiwf/aiwf_default_mode.md +44 -0
  108. package/.claude/commands/aiwf/aiwf_discuss_review.md +29 -0
  109. package/.claude/commands/aiwf/aiwf_do_task.md +109 -0
  110. package/.claude/commands/aiwf/aiwf_docs.md +225 -0
  111. package/.claude/commands/aiwf/aiwf_evaluate.md +92 -0
  112. package/.claude/commands/aiwf/aiwf_get_feature_details.md +78 -0
  113. package/.claude/commands/aiwf/aiwf_infinite.md +202 -0
  114. package/.claude/commands/aiwf/aiwf_initialize.md +134 -0
  115. package/.claude/commands/aiwf/aiwf_issue_create.md +65 -0
  116. package/.claude/commands/aiwf/aiwf_link_feature_to_milestone.md +57 -0
  117. package/.claude/commands/aiwf/aiwf_list_features.md +54 -0
  118. package/.claude/commands/aiwf/aiwf_mermaid.md +272 -0
  119. package/.claude/commands/aiwf/aiwf_persona_architect.md +48 -0
  120. package/.claude/commands/aiwf/aiwf_persona_backend.md +37 -0
  121. package/.claude/commands/aiwf/aiwf_persona_data_analyst.md +37 -0
  122. package/.claude/commands/aiwf/aiwf_persona_frontend.md +37 -0
  123. package/.claude/commands/aiwf/aiwf_persona_security.md +48 -0
  124. package/.claude/commands/aiwf/aiwf_persona_status.md +50 -0
  125. package/.claude/commands/aiwf/aiwf_pr_create.md +76 -0
  126. package/.claude/commands/aiwf/aiwf_prime.md +9 -0
  127. package/.claude/commands/aiwf/aiwf_project_review.md +261 -0
  128. package/.claude/commands/aiwf/aiwf_switch_language.md +160 -0
  129. package/.claude/commands/aiwf/aiwf_test.md +124 -0
  130. package/.claude/commands/aiwf/aiwf_testing_review.md +198 -0
  131. package/.claude/commands/aiwf/aiwf_tm-run-all-subtask.md +210 -0
  132. package/.claude/commands/aiwf/aiwf_ultrathink_code_advanced.md +460 -0
  133. package/.claude/commands/aiwf/aiwf_ultrathink_code_basic.md +165 -0
  134. package/.claude/commands/aiwf/aiwf_ultrathink_general.md +305 -0
  135. package/.claude/commands/aiwf/aiwf_update_docs_kr.md +25 -0
  136. package/.claude/commands/aiwf/aiwf_update_feature_status.md +53 -0
  137. package/.claude/commands/aiwf/aiwf_yolo.md +300 -0
  138. package/.eslintrc.json +26 -0
  139. package/.prettierrc +10 -0
  140. package/CLAUDE.md +154 -54
  141. package/README.ko.md +25 -0
  142. package/README.md +25 -0
  143. package/TEST_RECOVERY_PLAN.md +68 -0
  144. package/docs/CLEANUP_RECOMMENDATIONS.md +86 -0
  145. package/docs/CLI_USAGE_GUIDE.md +479 -0
  146. package/package.json +9 -9
  147. package/scripts/update-feature-status.js +70 -0
  148. package/{lib → src/cli}/cache-cli.js +4 -4
  149. package/src/cli/index.js +165 -0
  150. package/{language-cli.js → src/cli/language-cli.js} +11 -4
  151. package/src/commands/cache-templates.js +209 -0
  152. package/src/commands/create-offline.js +86 -0
  153. package/src/commands/create-project.js +151 -0
  154. package/src/lib/backup-manager.js +270 -0
  155. package/src/lib/file-downloader.js +208 -0
  156. package/src/lib/installer.js +676 -0
  157. package/src/lib/rollback-manager.js +418 -0
  158. package/src/lib/validator.js +561 -0
  159. package/src/utils/git-integration.js +173 -0
  160. package/{language-utils.js → src/utils/language-utils.js} +2 -1
  161. package/src/utils/messages.js +136 -0
  162. package/src/utils/paths.js +130 -0
  163. package/tests/application.test.js +2 -2
  164. package/tests/installer.test.js +2 -2
  165. package/tests/integration/ai-persona-system.test.js +4 -4
  166. package/tests/integration/test-persona-system/docs/README.md +1 -0
  167. package/tests/integration/test-persona-system/package.json +1 -0
  168. package/tests/integration/test-persona-system/src/auth.js +1 -0
  169. package/tests/integration/test-persona-system/src/index.js +1 -0
  170. package/tests/integration/test-persona-system/test/test.js +1 -0
  171. package/tests/language-utils.test.js +1 -1
  172. package/tests/temp_invalid_json/invalid.json +1 -0
  173. package/tests/unit/ai-persona-manager.test.js +7 -7
  174. package/.aiwf/05_DOCUMENTATION/performance-report.md +0 -33
  175. package/.aiwf/test-cache/86c7f9e80251abb8bedd58953ab0d1779e46b4f43ea33b63bffdb778106373b0.json +0 -6
  176. package/.aiwf/test-cache/9e252a90b80fce0585d7ed0646e7a9b4343e109f661f42a3ae678ba1ec5e22c7.json +0 -7
  177. package/.aiwf/token-data/alerts.json +0 -293
  178. package/.aiwf/token-data/monitor-config.json +0 -12
  179. package/CHANGELOG_M02.md +0 -52
  180. package/claude-code/aiwf/ko/templates/web-app/template/package-lock.json +0 -10022
  181. package/claude-code/aiwf/ko/token-data/alerts.json +0 -293
  182. package/claude-code/aiwf/ko/token-data/monitor-config.json +0 -12
  183. package/docs/m02-dod-checklist.md +0 -125
  184. package/docs/m02-gap-analysis.md +0 -214
  185. package/docs/m02-milestone-completion-report.md +0 -186
  186. package/docs/m02-milestone-executive-summary.md +0 -68
  187. package/index.js +0 -1951
  188. package/lib/cache-integration.js +0 -401
  189. package/lib/file-batch-processor.js +0 -401
  190. package/lib/performance-benchmark.js +0 -621
  191. package/lib/template-manager.js +0 -310
  192. package/scripts/validate-commands.cjs +0 -338
  193. /package/{lib → src/lib}/ai-persona-manager.js +0 -0
  194. /package/{lib → src/lib}/cache-system.js +0 -0
  195. /package/{lib → src/lib}/context-engine.js +0 -0
  196. /package/{lib → src/lib}/memory-profiler.js +0 -0
  197. /package/{lib → src/lib}/metrics-collector.js +0 -0
  198. /package/{lib → src/lib}/offline-detector.js +0 -0
  199. /package/{lib → src/lib}/task-analyzer.js +0 -0
  200. /package/{lib → src/lib}/template-cache-system.js +0 -0
  201. /package/{lib → src/lib}/template-downloader.js +0 -0
  202. /package/{lib → src/lib}/template-version-manager.js +0 -0
  203. /package/{lib → src/lib}/token-optimizer.js +0 -0
@@ -1,401 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { GitHubAPICache } from './cache-system.js';
4
- import { TemplateCache } from './template-cache-system.js';
5
- import { OfflineDetector } from './offline-detector.js';
6
-
7
- /**
8
- * S02 캐시 시스템과 T16 템플릿 캐시 시스템 통합
9
- * - 통합 캐시 전략 구현
10
- * - 성능 최적화 및 공유 자원 관리
11
- * - 일관된 캐시 정책 적용
12
- */
13
- class IntegratedCacheSystem {
14
- constructor(options = {}) {
15
- this.options = {
16
- // 공통 캐시 설정
17
- cacheDir: options.cacheDir || '.aiwf/cache',
18
- maxTotalSize: options.maxTotalSize || 200 * 1024 * 1024, // 200MB
19
-
20
- // GitHub API 캐시 설정
21
- githubApiTtl: options.githubApiTtl || 300000, // 5분
22
-
23
- // 템플릿 캐시 설정
24
- templateCacheMaxSize: options.templateCacheMaxSize || 100 * 1024 * 1024, // 100MB
25
-
26
- // 오프라인 감지 설정
27
- offlineCheckInterval: options.offlineCheckInterval || 30000, // 30초
28
-
29
- // 통합 정책
30
- priorityOrder: options.priorityOrder || ['templates', 'github-api'],
31
- cleanupSchedule: options.cleanupSchedule || 60 * 60 * 1000 // 1시간
32
- };
33
-
34
- // 각 캐시 시스템 초기화
35
- this.githubCache = new GitHubAPICache(
36
- `${this.options.cacheDir}/github-api`,
37
- this.options.githubApiTtl
38
- );
39
-
40
- this.templateCache = new TemplateCache({
41
- cacheDir: this.options.cacheDir,
42
- maxCacheSize: this.options.templateCacheMaxSize
43
- });
44
-
45
- this.offlineDetector = new OfflineDetector({
46
- checkInterval: this.options.offlineCheckInterval
47
- });
48
-
49
- // 캐시 시스템 연결
50
- this.offlineDetector.setCache(this.templateCache);
51
-
52
- // 통합 상태
53
- this.stats = {
54
- totalSize: 0,
55
- githubApiSize: 0,
56
- templateCacheSize: 0,
57
- lastCleanup: null,
58
- operationCount: 0
59
- };
60
-
61
- this.cleanupTimer = null;
62
- }
63
-
64
- /**
65
- * 통합 캐시 시스템 초기화
66
- */
67
- async init() {
68
- try {
69
- // 각 캐시 시스템 초기화
70
- await this.githubCache.init();
71
- await this.templateCache.init();
72
- await this.offlineDetector.start();
73
-
74
- // 초기 통계 계산
75
- await this.calculateStats();
76
-
77
- // 정기 정리 스케줄 시작
78
- this.startCleanupSchedule();
79
-
80
- console.log('Integrated cache system initialized');
81
-
82
- } catch (error) {
83
- console.error('Failed to initialize integrated cache system:', error.message);
84
- throw error;
85
- }
86
- }
87
-
88
- /**
89
- * 통합 캐시 통계 계산
90
- */
91
- async calculateStats() {
92
- try {
93
- const githubStats = this.githubCache.getStats();
94
- const templateStats = this.templateCache.getStats();
95
-
96
- this.stats = {
97
- totalSize: templateStats.totalSize + (githubStats.memorySize * 1024), // 대략적 계산
98
- githubApiSize: githubStats.memorySize * 1024,
99
- templateCacheSize: templateStats.totalSize,
100
- lastCleanup: this.stats.lastCleanup,
101
- operationCount: this.stats.operationCount,
102
-
103
- // 세부 통계
104
- githubCache: githubStats,
105
- templateCache: templateStats,
106
- network: this.offlineDetector.getNetworkStats()
107
- };
108
-
109
- } catch (error) {
110
- console.warn('Failed to calculate cache stats:', error.message);
111
- }
112
- }
113
-
114
- /**
115
- * GitHub API 캐시 래퍼 (오프라인 감지 포함)
116
- */
117
- async getGitHubData(url, headers = {}) {
118
- this.stats.operationCount++;
119
-
120
- try {
121
- // 온라인 상태 확인
122
- const isOnline = await this.offlineDetector.isOnline();
123
-
124
- if (!isOnline) {
125
- // 오프라인 모드에서는 캐시만 사용
126
- const cachedData = await this.githubCache.get(url, headers);
127
- if (cachedData) {
128
- return cachedData;
129
- }
130
- throw new Error('Data not available offline');
131
- }
132
-
133
- // 온라인 상태에서는 정상적인 캐시 로직 사용
134
- return await this.githubCache.getOrFetch(url, async () => {
135
- const response = await fetch(url, { headers });
136
- if (!response.ok) {
137
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
138
- }
139
- return await response.json();
140
- }, headers);
141
-
142
- } catch (error) {
143
- console.error(`GitHub API cache error for ${url}:`, error.message);
144
- throw error;
145
- }
146
- }
147
-
148
- /**
149
- * 템플릿 캐시 래퍼 (통합 크기 관리)
150
- */
151
- async cacheTemplate(type, name, sourcePath, version = '1.0.0') {
152
- this.stats.operationCount++;
153
-
154
- try {
155
- // 전체 캐시 크기 확인
156
- await this.calculateStats();
157
-
158
- if (this.stats.totalSize > this.options.maxTotalSize) {
159
- console.warn('Total cache size limit exceeded, cleaning up...');
160
- await this.smartCleanup();
161
- }
162
-
163
- return await this.templateCache.cacheTemplate(type, name, sourcePath, version);
164
-
165
- } catch (error) {
166
- console.error(`Template cache error for ${type}/${name}:`, error.message);
167
- throw error;
168
- }
169
- }
170
-
171
- /**
172
- * 템플릿 가져오기 (오프라인 지원)
173
- */
174
- async getTemplate(type, name, version = '1.0.0') {
175
- this.stats.operationCount++;
176
-
177
- try {
178
- return await this.templateCache.getTemplate(type, name, version);
179
- } catch (error) {
180
- console.error(`Template retrieval error for ${type}/${name}:`, error.message);
181
- throw error;
182
- }
183
- }
184
-
185
- /**
186
- * 템플릿 추출 (오프라인 지원)
187
- */
188
- async extractTemplate(type, name, targetPath, version = '1.0.0') {
189
- this.stats.operationCount++;
190
-
191
- try {
192
- return await this.templateCache.extractToDirectory(type, name, targetPath, version);
193
- } catch (error) {
194
- console.error(`Template extraction error for ${type}/${name}:`, error.message);
195
- throw error;
196
- }
197
- }
198
-
199
- /**
200
- * 스마트 캐시 정리 (우선순위 기반)
201
- */
202
- async smartCleanup() {
203
- try {
204
- let freedSpace = 0;
205
- const cleanupResults = [];
206
-
207
- // 우선순위 순서대로 정리
208
- for (const priority of this.options.priorityOrder) {
209
- if (this.stats.totalSize <= this.options.maxTotalSize * 0.8) {
210
- break; // 80% 이하로 줄어들면 중단
211
- }
212
-
213
- if (priority === 'github-api') {
214
- const result = await this.githubCache.cleanup();
215
- cleanupResults.push({
216
- type: 'github-api',
217
- ...result
218
- });
219
- freedSpace += result.expiredMemoryKeys * 1024; // 대략적 계산
220
-
221
- } else if (priority === 'templates') {
222
- const result = await this.templateCache.cleanup();
223
- cleanupResults.push({
224
- type: 'templates',
225
- ...result
226
- });
227
- freedSpace += result.freedSpace;
228
- }
229
- }
230
-
231
- // 통계 업데이트
232
- await this.calculateStats();
233
- this.stats.lastCleanup = new Date().toISOString();
234
-
235
- console.log(`Smart cleanup completed. Freed ${this.formatBytes(freedSpace)}`);
236
-
237
- return {
238
- freedSpace,
239
- results: cleanupResults,
240
- newTotalSize: this.stats.totalSize
241
- };
242
-
243
- } catch (error) {
244
- console.error('Smart cleanup failed:', error.message);
245
- throw error;
246
- }
247
- }
248
-
249
- /**
250
- * 정기 정리 스케줄 시작
251
- */
252
- startCleanupSchedule() {
253
- if (this.cleanupTimer) {
254
- clearInterval(this.cleanupTimer);
255
- }
256
-
257
- this.cleanupTimer = setInterval(async () => {
258
- try {
259
- await this.calculateStats();
260
-
261
- if (this.stats.totalSize > this.options.maxTotalSize * 0.9) {
262
- console.log('Scheduled cleanup triggered');
263
- await this.smartCleanup();
264
- }
265
- } catch (error) {
266
- console.error('Scheduled cleanup failed:', error.message);
267
- }
268
- }, this.options.cleanupSchedule);
269
- }
270
-
271
- /**
272
- * 통합 캐시 초기화
273
- */
274
- async clearAll() {
275
- try {
276
- await this.githubCache.clear();
277
- await this.templateCache.clear();
278
- await this.calculateStats();
279
-
280
- return {
281
- success: true,
282
- message: 'All caches cleared successfully'
283
- };
284
-
285
- } catch (error) {
286
- console.error('Failed to clear all caches:', error.message);
287
- throw error;
288
- }
289
- }
290
-
291
- /**
292
- * 통합 상태 정보
293
- */
294
- async getIntegratedStats() {
295
- await this.calculateStats();
296
-
297
- return {
298
- ...this.stats,
299
- totalSizeFormatted: this.formatBytes(this.stats.totalSize),
300
- maxSizeFormatted: this.formatBytes(this.options.maxTotalSize),
301
- usagePercentage: ((this.stats.totalSize / this.options.maxTotalSize) * 100).toFixed(2) + '%',
302
-
303
- breakdown: {
304
- githubApi: {
305
- size: this.stats.githubApiSize,
306
- sizeFormatted: this.formatBytes(this.stats.githubApiSize),
307
- percentage: ((this.stats.githubApiSize / this.stats.totalSize) * 100).toFixed(2) + '%'
308
- },
309
- templates: {
310
- size: this.stats.templateCacheSize,
311
- sizeFormatted: this.formatBytes(this.stats.templateCacheSize),
312
- percentage: ((this.stats.templateCacheSize / this.stats.totalSize) * 100).toFixed(2) + '%'
313
- }
314
- }
315
- };
316
- }
317
-
318
- /**
319
- * 오프라인 사용 가능 여부 확인
320
- */
321
- async isAvailableOffline(type, resource) {
322
- try {
323
- if (type === 'template') {
324
- const [templateType, name, version] = resource.split('/');
325
- return await this.templateCache.getTemplate(templateType, name, version) !== null;
326
- }
327
-
328
- if (type === 'github-api') {
329
- return await this.githubCache.get(resource) !== null;
330
- }
331
-
332
- return false;
333
-
334
- } catch (error) {
335
- console.error(`Offline availability check failed for ${type}/${resource}:`, error.message);
336
- return false;
337
- }
338
- }
339
-
340
- /**
341
- * 캐시 동기화 (네트워크 복구 시)
342
- */
343
- async synchronize() {
344
- try {
345
- const isOnline = await this.offlineDetector.isOnline();
346
-
347
- if (!isOnline) {
348
- console.log('Cannot synchronize - offline');
349
- return { synchronized: false, reason: 'offline' };
350
- }
351
-
352
- // GitHub API 캐시 정리 (만료된 것들 제거)
353
- await this.githubCache.cleanup();
354
-
355
- // 템플릿 캐시 크기 제한 확인
356
- await this.templateCache.checkSizeLimit();
357
-
358
- // 통계 업데이트
359
- await this.calculateStats();
360
-
361
- console.log('Cache synchronization completed');
362
-
363
- return {
364
- synchronized: true,
365
- stats: this.stats
366
- };
367
-
368
- } catch (error) {
369
- console.error('Cache synchronization failed:', error.message);
370
- return { synchronized: false, reason: error.message };
371
- }
372
- }
373
-
374
- /**
375
- * 바이트 포맷팅
376
- */
377
- formatBytes(bytes) {
378
- if (bytes === 0) return '0 Bytes';
379
-
380
- const k = 1024;
381
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
382
- const i = Math.floor(Math.log(bytes) / Math.log(k));
383
-
384
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
385
- }
386
-
387
- /**
388
- * 시스템 종료
389
- */
390
- async shutdown() {
391
- if (this.cleanupTimer) {
392
- clearInterval(this.cleanupTimer);
393
- }
394
-
395
- this.offlineDetector.stop();
396
-
397
- console.log('Integrated cache system shutdown');
398
- }
399
- }
400
-
401
- export { IntegratedCacheSystem };