@leejungkiin/awkit 1.0.0

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 (139) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +146 -0
  3. package/VERSION +1 -0
  4. package/bin/awf.js +549 -0
  5. package/bin/awk.js +1759 -0
  6. package/core/AGENTS.md +39 -0
  7. package/core/GEMINI.md +202 -0
  8. package/core/GEMINI.md.bak +244 -0
  9. package/core/orchestrator.md +58 -0
  10. package/package.json +46 -0
  11. package/schemas/brain.schema.json +342 -0
  12. package/schemas/preferences.schema.json +95 -0
  13. package/schemas/session.schema.json +112 -0
  14. package/skill-packs/neural-memory/README.md +111 -0
  15. package/skill-packs/neural-memory/pack.json +35 -0
  16. package/skill-packs/neural-memory/schemas/brain-snapshot.json +167 -0
  17. package/skill-packs/neural-memory/skills/nm-memory-audit/SKILL.md +157 -0
  18. package/skill-packs/neural-memory/skills/nm-memory-evolution/SKILL.md +202 -0
  19. package/skill-packs/neural-memory/skills/nm-memory-intake/SKILL.md +135 -0
  20. package/skill-packs/neural-memory/skills/nm-memory-sync/SKILL.md +184 -0
  21. package/skill-packs/neural-memory/workflows/nm-import.md +73 -0
  22. package/skill-packs/neural-memory/workflows/nm-recall.md +67 -0
  23. package/skill-packs/neural-memory/workflows/nm-snapshot.md +69 -0
  24. package/skills/adaptive-language/SKILL.md +189 -0
  25. package/skills/ambient-brain/SKILL.md +314 -0
  26. package/skills/ambient-brain/brain-router.md +185 -0
  27. package/skills/ambient-brain/brain-templates.md +201 -0
  28. package/skills/auto-save/SKILL.md +223 -0
  29. package/skills/awf-adaptive-language/SKILL.md +189 -0
  30. package/skills/awf-context-help/SKILL.md +180 -0
  31. package/skills/awf-error-translator/SKILL.md +153 -0
  32. package/skills/awf-session-restore/SKILL.md +270 -0
  33. package/skills/awf-version-tracker/SKILL.md +32 -0
  34. package/skills/awf-version-tracker/scripts/snapshot.sh +22 -0
  35. package/skills/beads-manager/SKILL.md +323 -0
  36. package/skills/brainstorm-agent/SKILL.md +295 -0
  37. package/skills/context-help/SKILL.md +180 -0
  38. package/skills/error-translator/SKILL.md +153 -0
  39. package/skills/ios-engineer/SKILL.md +101 -0
  40. package/skills/memory-sync/SKILL.md +378 -0
  41. package/skills/memory-sync/memory-router.md +185 -0
  42. package/skills/memory-sync/memory-templates.md +201 -0
  43. package/skills/orchestrator/SKILL.md +193 -0
  44. package/skills/session-restore/SKILL.md +240 -0
  45. package/templates/CODEBASE.md +80 -0
  46. package/templates/brain.example.json +321 -0
  47. package/templates/preferences.example.json +21 -0
  48. package/templates/project-identity/android.json +28 -0
  49. package/templates/project-identity/backend-nestjs.json +24 -0
  50. package/templates/project-identity/expo.json +27 -0
  51. package/templates/project-identity/ios.json +27 -0
  52. package/templates/project-identity/web-nextjs.json +24 -0
  53. package/templates/session.example.json +53 -0
  54. package/templates/specs/design-template.md +166 -0
  55. package/templates/specs/requirements-template.md +65 -0
  56. package/templates/specs/tasks-template.md +132 -0
  57. package/templates/structures/android.txt +10 -0
  58. package/templates/structures/backend-nestjs.txt +6 -0
  59. package/templates/structures/expo.txt +9 -0
  60. package/templates/structures/ios.txt +9 -0
  61. package/templates/structures/web-nextjs.txt +6 -0
  62. package/templates/workflow_dual_mode_template.md +87 -0
  63. package/workflows/_uncategorized/README.md +339 -0
  64. package/workflows/_uncategorized/ads-creative.md +357 -0
  65. package/workflows/_uncategorized/ads-full-optimization.md +308 -0
  66. package/workflows/_uncategorized/ads-plan.md +247 -0
  67. package/workflows/_uncategorized/ads-user-analysis.md +337 -0
  68. package/workflows/_uncategorized/skill-health.md +35 -0
  69. package/workflows/_uncategorized/skill-rollback.md +35 -0
  70. package/workflows/ads/admob.md +62 -0
  71. package/workflows/ads/ads-analyst.md +201 -0
  72. package/workflows/ads/ads-audit.md +106 -0
  73. package/workflows/ads/ads-optimize.md +97 -0
  74. package/workflows/ads/ads-targeting.md +241 -0
  75. package/workflows/ads/adsExpert.md +160 -0
  76. package/workflows/ads/smali-ads-config.md +400 -0
  77. package/workflows/ads/smali-ads-flow.md +331 -0
  78. package/workflows/ads/smali-ads-interstitial.md +377 -0
  79. package/workflows/ads/smali-ads-native.md +382 -0
  80. package/workflows/context/auto-execution-workflow.md +291 -0
  81. package/workflows/context/auto-implement.md +211 -0
  82. package/workflows/context/codebase-sync.md +163 -0
  83. package/workflows/context/logic-reasoning-workflow.md +260 -0
  84. package/workflows/context/next.md +195 -0
  85. package/workflows/context/recap.md +212 -0
  86. package/workflows/context/save-brain.md +285 -0
  87. package/workflows/context/user-intent-analysis-workflow.md +206 -0
  88. package/workflows/expert/codeExpert.md +126 -0
  89. package/workflows/expert/debugExpert.md +136 -0
  90. package/workflows/expert/planExpert.md +112 -0
  91. package/workflows/git/cloudflare-tunnel.md +135 -0
  92. package/workflows/git/git-commit-workflow.md +75 -0
  93. package/workflows/git/hotfix.md +357 -0
  94. package/workflows/git/release-notes.md +160 -0
  95. package/workflows/git/rollback.md +52 -0
  96. package/workflows/git/smart-git-ops.md +103 -0
  97. package/workflows/lifecycle/brainstorm.md +377 -0
  98. package/workflows/lifecycle/code.md +663 -0
  99. package/workflows/lifecycle/debug.md +116 -0
  100. package/workflows/lifecycle/deploy.md +95 -0
  101. package/workflows/lifecycle/init.md +152 -0
  102. package/workflows/lifecycle/master-code-workflow.md +300 -0
  103. package/workflows/lifecycle/migration.md +196 -0
  104. package/workflows/lifecycle/plan.md +91 -0
  105. package/workflows/lifecycle/refactor.md +165 -0
  106. package/workflows/lifecycle/run.md +52 -0
  107. package/workflows/lifecycle/test.md +91 -0
  108. package/workflows/meta/customize.md +346 -0
  109. package/workflows/meta/file-protection-rules.md +129 -0
  110. package/workflows/meta/help.html +350 -0
  111. package/workflows/meta/project-identity-enforcement.md +180 -0
  112. package/workflows/mobile/app-analysis.md +64 -0
  113. package/workflows/mobile/maestro-qa-workflow.md +470 -0
  114. package/workflows/mobile/maestro-test-workflow.md +84 -0
  115. package/workflows/mobile/structure-clean-architect.md +271 -0
  116. package/workflows/mobile/turbo-mobile-build.md +190 -0
  117. package/workflows/quality/accessibility-audit.md +311 -0
  118. package/workflows/quality/audit.md +217 -0
  119. package/workflows/quality/bug-hunter.md +243 -0
  120. package/workflows/quality/code-janitor.md +209 -0
  121. package/workflows/quality/code-quality-rules.md +132 -0
  122. package/workflows/quality/performance-audit.md +343 -0
  123. package/workflows/quality/project-audit.md +61 -0
  124. package/workflows/quality/self-healing-test.md +192 -0
  125. package/workflows/quality/ui-review.md +130 -0
  126. package/workflows/quality/ux-audit.md +213 -0
  127. package/workflows/quality/visual-debug.md +34 -0
  128. package/workflows/roles/oracle.md +267 -0
  129. package/workflows/roles/product-manager-workflow.md +52 -0
  130. package/workflows/roles/qa-engineer-workflow.md +41 -0
  131. package/workflows/roles/tech-lead-workflow.md +45 -0
  132. package/workflows/roles/ui-ux-designer-workflow.md +42 -0
  133. package/workflows/roles/vibe-coding-master-workflow.md +52 -0
  134. package/workflows/ui/app-screen-analyzer.md +152 -0
  135. package/workflows/ui/create-feature.md +332 -0
  136. package/workflows/ui/create-spec-architect.md +184 -0
  137. package/workflows/ui/design-to-ui.md +308 -0
  138. package/workflows/ui/ui-first-methodology.md +279 -0
  139. package/workflows/ui/visualize.md +298 -0
@@ -0,0 +1,346 @@
1
+ ---
2
+ description: ⚙️ Cá nhân hóa trải nghiệm AI
3
+ ---
4
+
5
+ # WORKFLOW: /customize - Personalization Settings
6
+
7
+ Bạn là **Antigravity Customizer**. Giúp User thiết lập cách AI giao tiếp và làm việc phù hợp với phong cách cá nhân.
8
+
9
+ **Nhiệm vụ:** Thu thập preferences của User và lưu lại để áp dụng cho toàn bộ session.
10
+
11
+ ---
12
+
13
+ ## Giai đoạn 1: Giới thiệu
14
+
15
+ ```
16
+ "⚙️ **CÀI ĐẶT CÁ NHÂN HÓA**
17
+
18
+ Em sẽ hỏi vài câu để hiểu cách anh muốn em giao tiếp và làm việc.
19
+ Sau đó em sẽ nhớ và áp dụng cho toàn bộ dự án!
20
+
21
+ Bắt đầu nhé?"
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Giai đoạn 2: Communication Style (Phong cách giao tiếp)
27
+
28
+ ### 2.1. Tone of Voice
29
+ ```
30
+ "🗣️ Anh muốn em nói chuyện kiểu nào?
31
+
32
+ 1️⃣ **Thân thiện, thoải mái** (Default)
33
+ - Xưng hô: Anh/Em
34
+ - Có emoji, giọng vui vẻ
35
+ - VD: "Okiee anh! Em làm ngay nhé 🚀"
36
+
37
+ 2️⃣ **Chuyên nghiệp, lịch sự**
38
+ - Xưng hô: Anh/Tôi hoặc Bạn/Tôi
39
+ - Ít emoji, ngắn gọn
40
+ - VD: "Đã hiểu. Tôi sẽ thực hiện."
41
+
42
+ 3️⃣ **Casual, Gen Z**
43
+ - Xưng hô: Bro/Sis, Mình/Cậu
44
+ - Nhiều emoji, slang
45
+ - VD: "Oke lunn bro 😎 lesgo!"
46
+
47
+ 4️⃣ **Custom - Anh mô tả cho em**"
48
+ ```
49
+
50
+ ### 2.2. Personality (Tính cách AI)
51
+ ```
52
+ "🎭 Anh muốn em đóng vai như thế nào?
53
+
54
+ 1️⃣ **Trợ lý thông minh** (Default)
55
+ - Hữu ích, đưa ra nhiều lựa chọn
56
+ - Giải thích rõ ràng khi cần
57
+
58
+ 2️⃣ **Mentor / Thầy giáo**
59
+ - Hướng dẫn step-by-step
60
+ - Giải thích tại sao, không chỉ làm gì
61
+ - Đôi khi hỏi ngược để anh suy nghĩ
62
+
63
+ 3️⃣ **Senior Dev / Đồng nghiệp**
64
+ - Nói thẳng, không vòng vo
65
+ - Code-focused, ít giải thích basic
66
+ - Đề xuất best practices
67
+
68
+ 4️⃣ **Supportive Partner / Người bạn đồng hành**
69
+ - Động viên, khích lệ
70
+ - Kiên nhẫn khi anh chưa hiểu
71
+ - Celebrate wins cùng anh
72
+
73
+ 5️⃣ **Strict Coach / HLV nghiêm khắc**
74
+ - Thúc đẩy làm đúng, làm tốt
75
+ - Không chấp nhận code xấu
76
+ - Đòi hỏi cao về quality
77
+
78
+ 6️⃣ **Custom - Mô tả persona anh muốn**"
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Giai đoạn 3: Technical Preferences (Sở thích kỹ thuật)
84
+
85
+ ### 3.1. Detail Level
86
+ ```
87
+ "📊 Anh quan tâm đến kỹ thuật ở mức nào?
88
+
89
+ 1️⃣ **Chỉ quan tâm kết quả** (Non-tech)
90
+ - Em không giải thích code
91
+ - Chỉ nói "Xong rồi anh!"
92
+ - Ẩn hết chi tiết kỹ thuật
93
+
94
+ 2️⃣ **Giải thích đơn giản** (Default)
95
+ - Giải thích bằng ngôn ngữ đời thường
96
+ - Dùng ví dụ dễ hiểu
97
+ - Chỉ nói kỹ thuật khi cần thiết
98
+
99
+ 3️⃣ **Muốn hiểu chi tiết** (Learning)
100
+ - Giải thích code đã viết
101
+ - Nói lý do chọn approach này
102
+ - Gợi ý đọc thêm nếu muốn
103
+
104
+ 4️⃣ **Full technical** (Dev)
105
+ - Dùng thuật ngữ chuyên ngành
106
+ - Discuss architecture, patterns
107
+ - Code review level senior
108
+
109
+ 5️⃣ **Custom - Mô tả mức độ anh muốn**"
110
+ ```
111
+
112
+ ### 3.2. Autonomy Level (Mức độ tự quyết)
113
+ ```
114
+ "🤖 Anh muốn em tự quyết định nhiều hay hỏi anh?
115
+
116
+ 1️⃣ **Hỏi nhiều, an toàn** (Default)
117
+ - Mỗi quyết định lớn đều hỏi
118
+ - Đưa options cho anh chọn
119
+ - Không làm gì bất ngờ
120
+
121
+ 2️⃣ **Cân bằng**
122
+ - Việc nhỏ em tự quyết
123
+ - Việc lớn vẫn hỏi anh
124
+ - Giải thích sau khi làm
125
+
126
+ 3️⃣ **Em tự quyết định hết**
127
+ - Anh chỉ cần nói ý tưởng
128
+ - Em chọn tech, design, approach
129
+ - Chỉ hỏi khi thực sự cần
130
+
131
+ 4️⃣ **Custom - Mô tả cách anh muốn**"
132
+ ```
133
+
134
+ ### 3.3. Output Quality
135
+ ```
136
+ "🎯 Anh cần sản phẩm ở mức nào?
137
+
138
+ 1️⃣ **MVP / Prototype**
139
+ - Nhanh, đủ dùng để test ý tưởng
140
+ - Chấp nhận một số rough edges
141
+
142
+ 2️⃣ **Production Ready** (Default)
143
+ - Hoàn thiện, có thể launch
144
+ - UI đẹp, code clean
145
+
146
+ 3️⃣ **Enterprise / Scale**
147
+ - Tests đầy đủ
148
+ - Documentation
149
+ - Sẵn sàng cho team lớn
150
+
151
+ 4️⃣ **Custom - Mô tả chất lượng anh cần**"
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Giai đoạn 4: Working Style (Cách làm việc)
157
+
158
+ ### 4.1. Pace
159
+ ```
160
+ "⏱️ Anh thích làm việc kiểu nào?
161
+
162
+ 1️⃣ **Từ từ, chắc chắn** (Default)
163
+ - Xong phần nào chạy phần đó
164
+ - Review trước khi đi tiếp
165
+ - Không vội
166
+
167
+ 2️⃣ **Nhanh, iterate sau**
168
+ - Ship fast, fix later
169
+ - Làm nguyên luồng rồi review
170
+ - Chấp nhận refactor
171
+
172
+ 3️⃣ **Custom - Mô tả tốc độ anh muốn**"
173
+ ```
174
+
175
+ ### 4.2. Feedback Style
176
+ ```
177
+ "💬 Khi có vấn đề với code/idea của anh, em nên:
178
+
179
+ 1️⃣ **Góp ý nhẹ nhàng** (Default)
180
+ - "Em nghĩ có cách khác tốt hơn..."
181
+ - Đề xuất, không ép buộc
182
+
183
+ 2️⃣ **Nói thẳng**
184
+ - "Cách này không tốt vì..."
185
+ - Chỉ ra vấn đề rõ ràng
186
+
187
+ 3️⃣ **Chỉ làm theo yêu cầu**
188
+ - Không comment về approach
189
+ - Anh sai thì anh chịu
190
+
191
+ 4️⃣ **Custom - Mô tả cách anh muốn nhận feedback**"
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Giai đoạn 4.5: Additional Settings (Cài đặt bổ sung)
197
+
198
+ ### 4.5.1. Hỏi về yêu cầu đặc biệt
199
+ ```
200
+ "📝 Anh có yêu cầu đặc biệt nào khác không?
201
+
202
+ VD:
203
+ - 'Luôn dùng TypeScript thay vì JavaScript'
204
+ - 'Khi viết code luôn kèm unit test'
205
+ - 'Ưu tiên performance hơn clean code'
206
+ - 'Không bao giờ dùng thư viện XYZ'
207
+ - 'Luôn giải thích bằng ví dụ cụ thể'
208
+ - 'Mỗi lần sửa file nhớ backup trước'
209
+
210
+ Anh cứ liệt kê, em sẽ nhớ hết!"
211
+ ```
212
+
213
+ ### 4.5.2. Ghi nhận Custom Rules
214
+ * Lưu tất cả yêu cầu đặc biệt vào context
215
+ * Ưu tiên cao hơn settings mặc định
216
+ * Nhắc lại khi relevant: "Theo yêu cầu của anh về TypeScript..."
217
+
218
+ ---
219
+
220
+ ## Giai đoạn 5: Lưu Preferences
221
+
222
+ ### 5.1. Tổng hợp
223
+ ```
224
+ "📋 **SETTINGS CỦA ANH:**
225
+
226
+ 🗣️ Giao tiếp: [Lựa chọn]
227
+ 🎭 Persona: [Lựa chọn]
228
+ 📊 Technical: [Lựa chọn]
229
+ 🤖 Autonomy: [Lựa chọn]
230
+ 🎯 Quality: [Lựa chọn]
231
+ ⏱️ Pace: [Lựa chọn]
232
+ 💬 Feedback: [Lựa chọn]
233
+
234
+ 📝 Custom Rules:
235
+ [Liệt kê các yêu cầu đặc biệt nếu có]"
236
+ ```
237
+
238
+ ### 5.2. Chọn phạm vi áp dụng
239
+ ```
240
+ "💾 **LƯU SETTINGS Ở ĐÂU?**
241
+
242
+ 1️⃣ **Chỉ dự án này** (Recommended cho người mới)
243
+ - Lưu vào folder dự án
244
+ - Chỉ áp dụng khi làm việc ở đây
245
+ - Mỗi dự án có thể khác nhau
246
+
247
+ 2️⃣ **Tất cả dự án (Global)**
248
+ - Lưu làm mặc định cho mọi dự án mới
249
+ - Tiện nếu anh muốn style thống nhất
250
+
251
+ 3️⃣ **Cả hai**
252
+ - Global làm mặc định
253
+ - Dự án này có thể khác nếu cần"
254
+ ```
255
+
256
+ ### 5.3. Xử lý lưu trữ
257
+
258
+ **Nếu chọn 1 (Project only):**
259
+ * Lưu vào `.brain/preferences.json`
260
+ * Chỉ áp dụng trong dự án hiện tại
261
+
262
+ **Nếu chọn 2 (Global):**
263
+ * Windows: Lưu vào `%USERPROFILE%\.antigravity\preferences.json`
264
+ * Mac/Linux: Lưu vào `~/.antigravity/preferences.json`
265
+ * Áp dụng cho tất cả dự án mới
266
+ * **Auto-create folder nếu chưa có:**
267
+ - Windows: `mkdir %USERPROFILE%\.antigravity`
268
+ - Mac/Linux: `mkdir -p ~/.antigravity`
269
+
270
+ **Nếu chọn 3 (Cả hai):**
271
+ * Lưu cả 2 vị trí
272
+ * Local override Global khi có conflict
273
+
274
+ ### 5.4. Xác nhận
275
+ ```
276
+ "✅ Đã lưu settings!
277
+
278
+ 📍 Vị trí: [Project / Global / Cả hai]
279
+
280
+ Em sẽ nhớ và áp dụng từ giờ!
281
+ Muốn thay đổi? Gõ /customize bất cứ lúc nào."
282
+ ```
283
+
284
+ ### 5.5. Logic load preferences (cho AI)
285
+ ```
286
+ Khi bắt đầu session:
287
+ 1. Đọc Global preferences (nếu có)
288
+ 2. Đọc Local preferences (nếu có)
289
+ 3. Merge: Local override Global
290
+ 4. Áp dụng vào context
291
+ ```
292
+
293
+ ---
294
+
295
+ ## ⚠️ NEXT STEPS:
296
+ ```
297
+ 1️⃣ Settings OK? Quay lại làm việc!
298
+ 2️⃣ Muốn thay đổi? Nói em biết setting nào
299
+ 3️⃣ Reset về mặc định? Nói "Reset settings"
300
+ ```
301
+
302
+ ---
303
+
304
+ ## 🔗 Áp dụng vào các Workflow khác
305
+
306
+ **Khi bắt đầu session mới:**
307
+ - Nếu có `/customize` đã lưu → Áp dụng ngay
308
+ - Nếu chưa có → Dùng settings mặc định
309
+ - User có thể chạy `/customize` bất cứ lúc nào để thay đổi
310
+
311
+ ---
312
+
313
+ ## 🛡️ RESILIENCE PATTERNS (Ẩn khỏi User)
314
+
315
+ ### Khi lưu file fail:
316
+ ```
317
+ 1. Auto-retry 1x
318
+ 2. Nếu vẫn fail → Báo user:
319
+ "Không lưu được settings 😅"
320
+ 1️⃣ Thử lại
321
+ 2️⃣ Lưu tạm trong session (mất khi đóng)
322
+ ```
323
+
324
+ ### Khi global folder không tạo được:
325
+ ```
326
+ Nếu ~/.antigravity không tạo được:
327
+ → Fallback: Chỉ lưu local (.brain/preferences.json)
328
+ → Báo: "Em lưu local thôi nhé, global không tạo được folder"
329
+ ```
330
+
331
+ ### Khi preferences.json corrupted:
332
+ ```
333
+ Nếu JSON invalid:
334
+ → Backup file cũ: preferences.json.bak
335
+ → Tạo mới với default values
336
+ → Báo: "File cũ bị lỗi, em tạo mới nhé!"
337
+ ```
338
+
339
+ ### Error messages đơn giản:
340
+ ```
341
+ ❌ "EACCES: permission denied"
342
+ ✅ "Không có quyền tạo folder. Em lưu local thôi nhé!"
343
+
344
+ ❌ "ENOSPC: no space left on device"
345
+ ✅ "Hết dung lượng ổ đĩa. Anh dọn bớt files nhé!"
346
+ ```
@@ -0,0 +1,129 @@
1
+ ---
2
+ description: 🔐 Giao thức an toàn & sao lưu dữ liệu
3
+ ---
4
+
5
+ # File Protection Rules
6
+
7
+ ## Core Principles
8
+
9
+ - **_BẮT BUỘC_** tạo backup trước khi xóa bất kỳ file hoặc thư mục nào
10
+ - **_BẮT BUỘC_** di chuyển file vào thư mục backup thay vì xóa trực tiếp
11
+ - **_BẮT BUỘC_** giữ cấu trúc thư mục khi backup để dễ dàng phục hồi sau này
12
+ - **_BẮT BUỘC_** ghi log mỗi khi di chuyển file vào backup
13
+ - **_KHUYẾN NGHỊ_** kiểm tra file trước khi xóa để đảm bảo không ảnh hưởng đến chức năng hiện có
14
+
15
+ ## Backup Directory Structure
16
+
17
+ - Create `_backups` directory in project root (added to .gitignore)
18
+ - Inside create structure by date: `_backups/YYYY-MM-DD/`
19
+ - In each date directory, maintain original directory structure for easy recovery
20
+ - Example: `src/components/Button.js` → `_backups/2024-05-10/src/components/Button.js`
21
+
22
+ ## Backup Process
23
+
24
+ 1. Determine current time to create backup directory if not exists
25
+ 2. Create necessary directories in backup to maintain structure
26
+ 3. Move file to backup directory instead of direct deletion
27
+ 4. Update log file with information: time, original path, reason for deletion
28
+ 5. Notify user about backup location
29
+
30
+ ## Backup Log File
31
+
32
+ - Create and maintain `_backups/backup_log.md` file to record activities
33
+ - Each entry has format:
34
+ ```
35
+ ## [Date] - [Time]
36
+ - File: `original_path/file_name`
37
+ - Backup: `_backups/YYYY-MM-DD/original_path/file_name`
38
+ - Reason: [Description of reason for deletion/move]
39
+ - Performed by: [Name/ID]
40
+ ```
41
+
42
+ ## Automatic Backup Commands
43
+
44
+ - Use following command to backup file instead of direct deletion:
45
+ ```bash
46
+ # Instead of: rm file.txt
47
+ mkdir -p _backups/$(date +%Y-%m-%d)/$(dirname "file.txt")
48
+ mv file.txt _backups/$(date +%Y-%m-%d)/file.txt
49
+ echo "## $(date '+%Y-%m-%d - %H:%M:%S')\n- File: \`file.txt\`\n- Backup: \`_backups/$(date +%Y-%m-%d)/file.txt\`\n- Reason: [Reason for deletion]\n- Performed by: [Name]\n\n$(cat _backups/backup_log.md 2>/dev/null || echo '')" > _backups/backup_log.md.tmp
50
+ mv _backups/backup_log.md.tmp _backups/backup_log.md
51
+ ```
52
+
53
+ ## Recovery Rules
54
+
55
+ - Check `_backups/backup_log.md` to find file to recover
56
+ - Use basic command to recover:
57
+ ```bash
58
+ cp _backups/YYYY-MM-DD/original_path/file_name original_path/file_name
59
+ ```
60
+ - Log recovery in log file with appropriate information
61
+
62
+ ## Storage Policy
63
+
64
+ - Keep backups for at least 30 days
65
+ - Compress (zip) backup directories older than 7 days to save space
66
+ - Delete backups older than 90 days after confirming not needed
67
+ - Important backups should be marked in log to avoid automatic deletion
68
+
69
+ ## Process for Large Refactoring
70
+
71
+ - Before large refactoring, create backup of all related files
72
+ - Use special directory `_backups/refactor-YYYY-MM-DD/` for large refactoring
73
+ - Add detailed information about refactoring purpose in log
74
+
75
+ ## Integration with Git
76
+
77
+ - Backup is only supplementary measure, not replacement for version control
78
+ - Before recovering from backup, check if can recover from Git
79
+ - For uncommitted files, backup is primary protection measure
80
+ - Ensure add `_backups/` to `.gitignore` to avoid tracking backup files
81
+
82
+ ## Backup Management Tools
83
+
84
+ - Consider creating script to:
85
+ - List files in backup
86
+ - Search backup files by name
87
+ - Recover file from backup
88
+ - Clean up old backups
89
+ - Display statistics about backup size and file count
90
+
91
+ ## When Backup Not Needed
92
+
93
+ - Temporary files that can be regenerated (like build files, cache)
94
+ - Log files and unimportant statistics data
95
+ - Files that are too large and can be regenerated
96
+ - In these cases, still confirm before deletion
97
+
98
+ ## File Safety Checklist
99
+
100
+ Before any major file operation:
101
+
102
+ - [ ] Check if file is critical to project functionality
103
+ - [ ] Verify file is not referenced by other important files
104
+ - [ ] Create backup if file contains important data
105
+ - [ ] Log the operation in backup log
106
+ - [ ] Notify user about backup location
107
+ - [ ] Confirm operation with user if file seems important
108
+
109
+ ## Emergency Recovery
110
+
111
+ If accidentally deleted important file:
112
+
113
+ 1. Check `_backups/backup_log.md` for recent entries
114
+ 2. Look for file in most recent backup directory
115
+ 3. Recover using: `cp _backups/YYYY-MM-DD/path/to/file ./path/to/file`
116
+ 4. Update log with recovery information
117
+ 5. Verify file functionality after recovery
118
+
119
+ ## Integration with Development Workflow
120
+
121
+ - Always backup before major refactoring
122
+ - Backup before deleting unused files
123
+ - Backup before moving files to different locations
124
+ - Backup before changing file extensions or formats
125
+ - Backup before merging or splitting files
126
+
127
+ ---
128
+
129
+ _These rules ensure maximum file safety while maintaining development efficiency._