alp-code 0.9.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 (204) hide show
  1. package/CHANGELOG.md +770 -0
  2. package/LICENSE +21 -0
  3. package/README.md +295 -0
  4. package/alp.config.yaml +5 -0
  5. package/dist/src/agents/agent-definition.js +28 -0
  6. package/dist/src/agents/capability-catalog.js +33 -0
  7. package/dist/src/agents/compaction.js +36 -0
  8. package/dist/src/agents/errors.js +12 -0
  9. package/dist/src/agents/librarian.js +38 -0
  10. package/dist/src/agents/main.js +37 -0
  11. package/dist/src/agents/memory-grant.js +29 -0
  12. package/dist/src/agents/model-context.js +70 -0
  13. package/dist/src/agents/modes.js +134 -0
  14. package/dist/src/agents/oracle.js +36 -0
  15. package/dist/src/agents/read-thread.js +38 -0
  16. package/dist/src/agents/registry.js +238 -0
  17. package/dist/src/agents/render-identity.js +38 -0
  18. package/dist/src/agents/review.js +37 -0
  19. package/dist/src/agents/search.js +37 -0
  20. package/dist/src/agents/shared/house-rules.js +33 -0
  21. package/dist/src/agents/shared/principal.js +18 -0
  22. package/dist/src/agents/shared/voice.js +29 -0
  23. package/dist/src/agents/titling.js +32 -0
  24. package/dist/src/agents/types.js +15 -0
  25. package/dist/src/backend/execution-backend.js +2 -0
  26. package/dist/src/backend/local-execution-store.js +144 -0
  27. package/dist/src/backend/local-process-backend.js +533 -0
  28. package/dist/src/backend/local-supervisor.js +104 -0
  29. package/dist/src/cli/alp.js +380 -0
  30. package/dist/src/cli/commands/context.js +203 -0
  31. package/dist/src/cli/commands/delegate.js +136 -0
  32. package/dist/src/cli/commands/identity-sync.js +31 -0
  33. package/dist/src/cli/commands/init.js +184 -0
  34. package/dist/src/cli/commands/mode.js +22 -0
  35. package/dist/src/cli/commands/principal.js +114 -0
  36. package/dist/src/cli/commands/run-main.js +90 -0
  37. package/dist/src/cli/commands/runtime.js +21 -0
  38. package/dist/src/cli/mode-preference-store.js +62 -0
  39. package/dist/src/cli/mode-selector.js +178 -0
  40. package/dist/src/cli/update-check.js +77 -0
  41. package/dist/src/context/checkpoint.js +134 -0
  42. package/dist/src/context/compact-journal.js +153 -0
  43. package/dist/src/context/compact-payload.js +121 -0
  44. package/dist/src/context/continuity.js +70 -0
  45. package/dist/src/context/types.js +2 -0
  46. package/dist/src/delegation/backend-registry.js +40 -0
  47. package/dist/src/delegation/delegation-service.js +300 -0
  48. package/dist/src/delegation/types.js +12 -0
  49. package/dist/src/execution/execution-policy.js +96 -0
  50. package/dist/src/execution/execution-service.js +115 -0
  51. package/dist/src/execution/execution-store.js +78 -0
  52. package/dist/src/execution/identity-capsule.js +65 -0
  53. package/dist/src/execution/types.js +12 -0
  54. package/dist/src/hooks/execution-bridge.js +84 -0
  55. package/dist/src/index.js +4 -0
  56. package/dist/src/memory/adapters/markdown-file-store.js +257 -0
  57. package/dist/src/memory/adapters/memory-api-client.js +2 -0
  58. package/dist/src/memory/adapters/memory-path-mapper.js +76 -0
  59. package/dist/src/memory/adapters/remote-api-store.js +25 -0
  60. package/dist/src/memory/context-ranker.js +21 -0
  61. package/dist/src/memory/errors.js +58 -0
  62. package/dist/src/memory/memory-service.js +149 -0
  63. package/dist/src/memory/memory-store.js +2 -0
  64. package/dist/src/memory/types.js +2 -0
  65. package/dist/src/policy/capability-policy.js +29 -0
  66. package/dist/src/policy/delegation-policy.js +25 -0
  67. package/dist/src/policy/errors.js +10 -0
  68. package/dist/src/policy/invariants.js +31 -0
  69. package/dist/src/policy/memory-policy.js +22 -0
  70. package/dist/src/policy/policy-engine.js +85 -0
  71. package/dist/src/policy/types.js +8 -0
  72. package/dist/src/policy/workspace-policy.js +77 -0
  73. package/dist/src/principal/principal-profile-store.js +89 -0
  74. package/dist/src/runtime/adapter-files.js +147 -0
  75. package/dist/src/runtime/claude-adapter.js +177 -0
  76. package/dist/src/runtime/codex-adapter.js +169 -0
  77. package/dist/src/runtime/permission-rules.js +156 -0
  78. package/dist/src/runtime/render-session-context.js +124 -0
  79. package/dist/src/runtime/render-task-input.js +33 -0
  80. package/dist/src/runtime/runtime-adapter.js +2 -0
  81. package/dist/src/runtime/runtime-preference-store.js +66 -0
  82. package/dist/src/runtime/runtime-selector.js +178 -0
  83. package/dist/src/runtime/types.js +2 -0
  84. package/dist/src/runtime/windows-shim.js +57 -0
  85. package/dist/src/state-paths.js +49 -0
  86. package/dist/src/workflow/output-validator.js +27 -0
  87. package/dist/src/workflow/repair-policy.js +8 -0
  88. package/dist/src/workflow/types.js +22 -0
  89. package/dist/src/workflow/workflow-runner.js +81 -0
  90. package/hooks/compact-record.cjs +109 -0
  91. package/hooks/session-boot.cjs +112 -0
  92. package/hooks/session-end.cjs +34 -0
  93. package/package.json +48 -0
  94. package/scaffold/memory/INDEX.md +27 -0
  95. package/scaffold/memory/README.md +76 -0
  96. package/scaffold/memory/projects/INDEX.md +22 -0
  97. package/scaffold/memory/projects/PROTOCOL.md +128 -0
  98. package/scaffold/memory/projects/_template/PROJECT.md +45 -0
  99. package/scripts/alp.cjs +126 -0
  100. package/scripts/alp.ps1 +4 -0
  101. package/scripts/alp.sh +3 -0
  102. package/scripts/bootstrap.cjs +144 -0
  103. package/scripts/checkout-release.cjs +30 -0
  104. package/scripts/delegate.cjs +19 -0
  105. package/scripts/doctor.cjs +158 -0
  106. package/scripts/doctor.sh +3 -0
  107. package/scripts/ensure-state.cjs +22 -0
  108. package/scripts/lib/cli-link.cjs +375 -0
  109. package/scripts/lib/codex-role.cjs +18 -0
  110. package/scripts/lib/delegation/command-runner.cjs +108 -0
  111. package/scripts/lib/delegation/config.cjs +81 -0
  112. package/scripts/lib/install-paths.cjs +154 -0
  113. package/scripts/lib/release-manifest.cjs +42 -0
  114. package/scripts/lib/semver-lite.cjs +20 -0
  115. package/scripts/lib/state.cjs +274 -0
  116. package/scripts/lib/uninstall.cjs +252 -0
  117. package/scripts/lib/update-check-worker.cjs +21 -0
  118. package/scripts/lib/update.cjs +395 -0
  119. package/scripts/run-role.cjs +42 -0
  120. package/scripts/run-role.ps1 +4 -0
  121. package/scripts/run-role.sh +3 -0
  122. package/scripts/sync-project-index.sh +167 -0
  123. package/skills/agent-memory/SKILL.md +109 -0
  124. package/skills/alp-debug/SKILL.md +90 -0
  125. package/skills/alp-debug/references/defense-in-depth.md +118 -0
  126. package/skills/alp-debug/references/investigation-methodology.md +106 -0
  127. package/skills/alp-debug/references/log-and-ci-analysis.md +96 -0
  128. package/skills/alp-debug/references/performance-diagnostics.md +112 -0
  129. package/skills/alp-debug/references/reporting-standards.md +120 -0
  130. package/skills/alp-debug/references/root-cause-tracing.md +134 -0
  131. package/skills/alp-debug/references/systematic-debugging.md +93 -0
  132. package/skills/alp-debug/references/verification.md +86 -0
  133. package/skills/alp-debug/scripts/find-polluter.sh +63 -0
  134. package/skills/alp-debug/scripts/find-polluter.test.md +102 -0
  135. package/skills/alp-plan/SKILL.md +128 -0
  136. package/skills/alp-plan/references/archive-workflow.md +77 -0
  137. package/skills/alp-plan/references/codebase-understanding.md +55 -0
  138. package/skills/alp-plan/references/output-standards.md +96 -0
  139. package/skills/alp-plan/references/plan-organization.md +129 -0
  140. package/skills/alp-plan/references/red-team-personas.md +76 -0
  141. package/skills/alp-plan/references/red-team-workflow.md +81 -0
  142. package/skills/alp-plan/references/research-phase.md +57 -0
  143. package/skills/alp-plan/references/scope-challenge.md +82 -0
  144. package/skills/alp-plan/references/solution-design.md +76 -0
  145. package/skills/alp-plan/references/validate-question-framework.md +89 -0
  146. package/skills/alp-plan/references/validate-workflow.md +83 -0
  147. package/skills/alp-predict/SKILL.md +98 -0
  148. package/skills/alp-scenario/SKILL.md +86 -0
  149. package/skills/code-review/SKILL.md +111 -0
  150. package/skills/code-review/references/code-review-reception.md +114 -0
  151. package/skills/code-review/references/edge-case-scouting.md +78 -0
  152. package/skills/code-review/references/verification-before-completion.md +117 -0
  153. package/skills/delegation/SKILL.md +46 -0
  154. package/skills/docs-seeker/.env.example +15 -0
  155. package/skills/docs-seeker/SKILL.md +87 -0
  156. package/skills/docs-seeker/package.json +25 -0
  157. package/skills/docs-seeker/references/advanced.md +82 -0
  158. package/skills/docs-seeker/references/context7-patterns.md +68 -0
  159. package/skills/docs-seeker/references/errors.md +72 -0
  160. package/skills/docs-seeker/scripts/analyze-llms-txt.js +211 -0
  161. package/skills/docs-seeker/scripts/detect-topic.js +172 -0
  162. package/skills/docs-seeker/scripts/fetch-docs.js +213 -0
  163. package/skills/docs-seeker/scripts/tests/run-tests.js +72 -0
  164. package/skills/docs-seeker/scripts/tests/test-analyze-llms.js +119 -0
  165. package/skills/docs-seeker/scripts/tests/test-detect-topic.js +112 -0
  166. package/skills/docs-seeker/scripts/tests/test-fetch-docs.js +84 -0
  167. package/skills/docs-seeker/scripts/utils/env-loader.js +94 -0
  168. package/skills/docs-seeker/workflows/library-search.md +73 -0
  169. package/skills/docs-seeker/workflows/repo-analysis.md +90 -0
  170. package/skills/docs-seeker/workflows/topic-search.md +69 -0
  171. package/skills/git/SKILL.md +121 -0
  172. package/skills/git/references/branch-management.md +90 -0
  173. package/skills/git/references/commit-standards.md +82 -0
  174. package/skills/git/references/gh-cli-guide.md +132 -0
  175. package/skills/git/references/safety-protocols.md +86 -0
  176. package/skills/git/references/workflow-commit.md +89 -0
  177. package/skills/git/references/workflow-merge.md +63 -0
  178. package/skills/git/references/workflow-pr.md +70 -0
  179. package/skills/git/references/workflow-push.md +62 -0
  180. package/skills/gkg/SKILL.md +87 -0
  181. package/skills/gkg/references/cli-commands.md +92 -0
  182. package/skills/gkg/references/http-api.md +99 -0
  183. package/skills/gkg/references/language-support.md +54 -0
  184. package/skills/problem-solving/SKILL.md +86 -0
  185. package/skills/problem-solving/references/attribution.md +48 -0
  186. package/skills/problem-solving/references/collision-zone-thinking.md +71 -0
  187. package/skills/problem-solving/references/inversion-exercise.md +88 -0
  188. package/skills/problem-solving/references/meta-pattern-recognition.md +80 -0
  189. package/skills/problem-solving/references/scale-game.md +82 -0
  190. package/skills/problem-solving/references/simplification-cascades.md +83 -0
  191. package/skills/problem-solving/references/when-stuck.md +76 -0
  192. package/skills/repomix/SKILL.md +94 -0
  193. package/skills/repomix/references/configuration.md +134 -0
  194. package/skills/repomix/references/usage-patterns.md +106 -0
  195. package/skills/repomix/scripts/.coverage +0 -0
  196. package/skills/repomix/scripts/README.md +179 -0
  197. package/skills/repomix/scripts/repomix_batch.py +455 -0
  198. package/skills/repomix/scripts/repos.example.json +15 -0
  199. package/skills/repomix/scripts/requirements.txt +15 -0
  200. package/skills/repomix/scripts/tests/test_repomix_batch.py +531 -0
  201. package/skills/research/SKILL.md +107 -0
  202. package/skills/security-scan/SKILL.md +101 -0
  203. package/skills/security-scan/references/secret-patterns.md +75 -0
  204. package/skills/security-scan/references/vulnerability-patterns.md +136 -0
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: repomix
3
+ description: Đóng gói cả repo thành một file cho AI đọc (XML, Markdown, JSON), có đếm token và quét secret. Kích hoạt khi cần đưa nguyên một codebase lạ vào context, khi đánh giá thư viện bên thứ ba, hoặc khi cần biết token nằm tập trung ở đâu.
4
+ ---
5
+
6
+ # repomix — gói repo thành một file
7
+
8
+ **Chưa vai nào được cấp skill này** trong `compiled AgentDefinition`. Nó nằm ở `skills/` để principal
9
+ cấp khi cần — thường là khi phải đánh giá một thư viện lạ.
10
+
11
+ ## Khi nào đáng dùng
12
+
13
+ Chỉ khi **thật sự cần cả repo**: đánh giá thư viện bên thứ ba, hiểu một codebase chưa từng
14
+ đọc, chuẩn bị audit.
15
+
16
+ Khi **không** nên dùng: tìm một symbol, đọc một luồng, trả lời một câu hỏi cụ thể về code.
17
+ Việc đó giao một lượt truy xuất code — nó trả `path:line`, còn repomix đổ hàng chục nghìn
18
+ token vào context.
19
+ Dùng nhầm chỗ là phá đúng nguyên tắc "boot set ≤ 7 nguồn" của compiled policy invariants.
20
+
21
+ ## Kiểm tra trước
22
+
23
+ ```bash
24
+ repomix --version
25
+ ```
26
+
27
+ Chưa cài thì **báo principal, đừng tự cài** (HOUSE-RULES §1.2). Cài: `npm install -g repomix`
28
+ hoặc `brew install repomix`.
29
+
30
+ ## Dùng cơ bản
31
+
32
+ ```bash
33
+ repomix # gói thư mục hiện tại → repomix-output.xml
34
+ repomix --style markdown # đổi định dạng: xml | markdown | json | plain
35
+ repomix --include "src/**/*.ts" -o out.md # lọc + đặt tên file ra
36
+ npx repomix --remote owner/repo # gói repo từ xa, không cần clone
37
+ ```
38
+
39
+ **Chỉ gói repo nằm trong `workspaces.read` của loadout.** Gói một repo ngoài danh sách là
40
+ đọc thứ mình không được đọc, kể cả khi filesystem không chặn.
41
+
42
+ | Nhóm | Cờ |
43
+ |---|---|
44
+ | chọn file | `--include "<glob>"` · `-i "<glob>"` (bỏ qua thêm) · `--no-gitignore` |
45
+ | đầu ra | `--style` · `-o <file>` · `--remove-comments` · `--copy` |
46
+ | cấu hình | `-c <file>` · `--init` (tạo `repomix.config.json`) |
47
+
48
+ Đầy đủ: `repomix --help` hoặc `references/configuration.md`.
49
+
50
+ ## Đếm token — phần đáng giá nhất
51
+
52
+ ```bash
53
+ repomix --token-count-tree # cây token toàn repo
54
+ repomix --token-count-tree 1000 # chỉ hiện file/thư mục từ 1000 token trở lên
55
+ ```
56
+
57
+ ```
58
+ └── src/ (70,925 tokens)
59
+ ├── cli/ (12,714 tokens)
60
+ └── core/ (41,600 tokens)
61
+ ```
62
+
63
+ Chạy cây token **trước** khi gói. Nó cho biết nên `--include` những gì, và tránh việc gói
64
+ xong mới phát hiện vượt giới hạn context.
65
+
66
+ ## Bảo mật — đọc trước khi gói bất cứ thứ gì
67
+
68
+ repomix dùng Secretlint để bắt API key, mật khẩu, private key, AWS secret.
69
+
70
+ - **Luôn đọc lại output trước khi đưa đi đâu.** Một file gói có thể chứa credential mà
71
+ `.gitignore` che được nhưng `.repomixignore` thì chưa.
72
+ - Không gói `.env`.
73
+ - **Không tắt `--no-security-check`** trừ khi principal nói thẳng. Tắt quét secret rồi đổ
74
+ file vào context là cách lộ credential mà không ai nhìn thấy.
75
+ - File `repomix-output.*` sinh ra trong thư mục làm việc — dọn sau khi dùng, đừng để nó
76
+ lọt vào commit.
77
+
78
+ ## Quy trình
79
+
80
+ 1. Chạy `--token-count-tree`, xem token nằm ở đâu.
81
+ 2. Chốt `--include`/`-i` cho vừa ngân sách context.
82
+ 3. Gói, giữ quét secret bật.
83
+ 4. **Đọc lại output**, xác nhận không có gì nhạy cảm.
84
+ 5. Báo số token và cảnh báo nếu có.
85
+ 6. Dọn file gói khi xong.
86
+
87
+ ## Tham chiếu
88
+
89
+ | File | Nội dung |
90
+ |---|---|
91
+ | `references/configuration.md` | file config, mẫu include/exclude, định dạng ra |
92
+ | `references/usage-patterns.md` | quy trình phân tích, chuẩn bị audit, đánh giá thư viện |
93
+
94
+ Nguồn: https://github.com/yamadashy/repomix
@@ -0,0 +1,134 @@
1
+ # Cấu hình repomix
2
+
3
+ ## File cấu hình
4
+
5
+ Đặt `repomix.config.json` ở gốc project:
6
+
7
+ ```json
8
+ {
9
+ "output": {
10
+ "filePath": "repomix-output.xml",
11
+ "style": "xml",
12
+ "removeComments": false,
13
+ "showLineNumbers": true,
14
+ "copyToClipboard": false
15
+ },
16
+ "include": ["**/*"],
17
+ "ignore": {
18
+ "useGitignore": true,
19
+ "useDefaultPatterns": true,
20
+ "customPatterns": ["**/*.log", "**/tmp/**"]
21
+ },
22
+ "security": {
23
+ "enableSecurityCheck": true
24
+ }
25
+ }
26
+ ```
27
+
28
+ Tạo file config trong repo người khác là **sửa repo đó** — hỏi principal trước. Dùng một
29
+ lần thì truyền cờ ở dòng lệnh, đừng để lại file.
30
+
31
+ ### Đầu ra
32
+
33
+ | Khoá | Nghĩa | Mặc định |
34
+ |---|---|---|
35
+ | `filePath` | file kết quả | `repomix-output.xml` |
36
+ | `style` | `xml` · `markdown` · `json` · `plain` | `xml` |
37
+ | `removeComments` | bỏ comment | `false` |
38
+ | `showLineNumbers` | kèm số dòng | `true` |
39
+ | `copyToClipboard` | tự copy | `false` |
40
+
41
+ Giữ `showLineNumbers: true` khi mục đích là để trích dẫn — không có số dòng thì không dẫn
42
+ được `path:line`, mà đó là dạng bằng chứng repo này yêu cầu.
43
+
44
+ ### Lọc file
45
+
46
+ | Khoá | Nghĩa |
47
+ |---|---|
48
+ | `include` | glob các file lấy vào (mặc định `["**/*"]`) |
49
+ | `useGitignore` | tôn trọng `.gitignore` (mặc định `true`) |
50
+ | `useDefaultPatterns` | dùng bộ mẫu bỏ qua mặc định (mặc định `true`) |
51
+ | `customPatterns` | mẫu bỏ qua thêm, cú pháp như `.gitignore` |
52
+
53
+ **Không tắt `useGitignore`.** Nó là lớp bảo vệ đầu tiên chống việc gói nhầm `.env`, secret,
54
+ và dữ liệu cục bộ.
55
+
56
+ ### Bảo mật
57
+
58
+ `enableSecurityCheck` (mặc định `true`) — quét bằng Secretlint: API key, mật khẩu,
59
+ credential, private key, secret AWS, chuỗi kết nối DB.
60
+
61
+ **Không tắt.** Xem phần cuối `SKILL.md`.
62
+
63
+ ## Glob
64
+
65
+ | Ký hiệu | Khớp |
66
+ |---|---|
67
+ | `*` | mọi ký tự trừ `/` |
68
+ | `**` | mọi ký tự kể cả `/` |
69
+ | `?` | một ký tự |
70
+ | `[abc]` | một ký tự trong tập |
71
+ | `{js,ts}` | một trong các phần mở rộng |
72
+
73
+ ### Thứ tự ưu tiên
74
+
75
+ Cao xuống thấp:
76
+
77
+ 1. Cờ `-i` ở dòng lệnh
78
+ 2. File `.repomixignore`
79
+ 3. `customPatterns` trong config
80
+ 4. `.gitignore` (nếu bật)
81
+ 5. Bộ mẫu mặc định (nếu bật)
82
+
83
+ Cờ dòng lệnh thắng tất cả — tiện, nhưng cũng nghĩa là một cờ `-i` sai chỗ vô hiệu hoá cả
84
+ bộ lọc bạn đã cấu hình kỹ.
85
+
86
+ ### Mẫu theo loại project
87
+
88
+ ```json
89
+ // TypeScript
90
+ {"include": ["**/*.ts", "**/*.tsx"], "ignore": {"customPatterns": ["**/*.test.ts", "dist/"]}}
91
+
92
+ // React
93
+ {"include": ["src/**/*.{js,jsx,ts,tsx}", "*.md"], "ignore": {"customPatterns": ["build/"]}}
94
+
95
+ // Monorepo
96
+ {"include": ["packages/*/src/**"], "ignore": {"customPatterns": ["packages/*/dist/"]}}
97
+ ```
98
+
99
+ ## Định dạng ra
100
+
101
+ | Định dạng | Dùng khi |
102
+ |---|---|
103
+ | `xml` (mặc định) | đưa cho LLM đọc — có tag, phân cấp, metadata |
104
+ | `markdown` | người đọc, review, chia sẻ |
105
+ | `json` | xử lý bằng script |
106
+ | `plain` | nối đơn giản, ít overhead nhất |
107
+
108
+ Với alp-code, mục đích gần như luôn là đưa cho LLM → giữ `xml`.
109
+
110
+ ## Cờ nâng cao
111
+
112
+ ```bash
113
+ repomix --verbose # xem nó đang xử lý gì
114
+ repomix -c /đường/dẫn/config.json # config riêng
115
+ repomix --init # tạo repomix.config.json
116
+ repomix --no-line-numbers # output nhỏ hơn, nhưng mất khả năng dẫn path:line
117
+ ```
118
+
119
+ ## Giảm kích thước
120
+
121
+ Đây là phần quan trọng nhất khi dùng trong một phiên agent — output quá lớn là hỏng cả phiên.
122
+
123
+ ```bash
124
+ repomix --token-count-tree # LUÔN chạy trước
125
+ repomix -i "node_modules/**,dist/**,*.min.js" # loại thứ vô ích
126
+ repomix --include "src/**/*.ts" # chỉ lấy phần cần
127
+ repomix --remove-comments --no-line-numbers # ép nhỏ tối đa
128
+ ```
129
+
130
+ Thứ tự đúng: chạy cây token → xem token nằm ở đâu → chốt `--include` → gói. Gói trước rồi
131
+ mới đo là làm ngược.
132
+
133
+ Xử lý song song nên repo lớn vẫn nhanh (facebook/react: 123s → 4s). **Nhanh không có nghĩa
134
+ là nên gói cả repo** — giới hạn thật là ngân sách context, không phải thời gian chạy.
@@ -0,0 +1,106 @@
1
+ # Mẫu sử dụng
2
+
3
+ ## Bốn việc repomix làm tốt
4
+
5
+ ### 1. Đánh giá thư viện bên thứ ba
6
+
7
+ Việc đáng dùng repomix nhất: hiểu nhanh một thư viện lạ trước khi quyết định có dùng không.
8
+
9
+ ```bash
10
+ npx repomix --remote https://github.com/owner/repo --token-count-tree
11
+ npx repomix --remote https://github.com/owner/repo \
12
+ --include "README.md,docs/**,src/index.*" --style markdown
13
+ ```
14
+
15
+ Đọc `README`, `docs/`, và entry point là đủ để đánh giá. Không cần cả `src/`.
16
+
17
+ ### 2. Hiểu một module cụ thể
18
+
19
+ ```bash
20
+ repomix --include "src/auth/**" --remove-comments -o auth.md --style markdown
21
+ ```
22
+
23
+ Khoanh đúng module, không gói cả repo.
24
+
25
+ ### 3. Chuẩn bị audit bảo mật
26
+
27
+ ```bash
28
+ repomix --include "src/**/*.{ts,js}" -i "**/*.test.*" --style xml
29
+ ```
30
+
31
+ Giữ quét secret **bật**. Xem lại output trước khi đưa đi đâu.
32
+
33
+ ### 4. Rút bối cảnh cho tài liệu
34
+
35
+ ```bash
36
+ repomix --include "src/api/**,docs/**" --style markdown -o api-context.md
37
+ ```
38
+
39
+ ## Khi KHÔNG dùng repomix
40
+
41
+ | Việc | Dùng gì thay |
42
+ |---|---|
43
+ | tìm một symbol, một hàm | `rg` / `Grep` |
44
+ | biết đổi chỗ này thì vỡ đâu | `gkg` phân tích ảnh hưởng |
45
+ | đọc tài liệu một thư viện | `docs-seeker` |
46
+ | trả lời một câu hỏi cụ thể về code | một lượt truy xuất trả `path:line` |
47
+
48
+ repomix đổ hàng chục nghìn token vào context. Dùng nó để trả lời một câu hỏi nhỏ là phá
49
+ đúng nguyên tắc "boot set ≤ 7 nguồn" của CHARTER §2.6.
50
+
51
+ ## Xử lý sự cố
52
+
53
+ ### Output quá lớn
54
+
55
+ ```bash
56
+ repomix --token-count-tree # xem token ở đâu
57
+ repomix -i "node_modules/**,dist/**,coverage/**" \
58
+ --include "src/core/**" --remove-comments --no-line-numbers
59
+ ```
60
+
61
+ Cắt `--include` cho tới khi vừa ngân sách. Đừng gói rồi mới lo cắt sau.
62
+
63
+ ### Thiếu file mong đợi
64
+
65
+ ```bash
66
+ cat .gitignore .repomixignore # xem mẫu nào đang chặn
67
+ repomix --no-gitignore --no-default-patterns --verbose
68
+ ```
69
+
70
+ Lệnh thứ hai **chỉ để chẩn đoán**, không phải để gói thật — tắt `.gitignore` là mở đường
71
+ cho `.env` và dữ liệu cục bộ lọt vào.
72
+
73
+ ### Cảnh báo dữ liệu nhạy cảm
74
+
75
+ Đúng thứ tự: xem lại file → thêm vào `.repomixignore` → bỏ dữ liệu nhạy cảm khỏi code →
76
+ chuyển sang biến môi trường.
77
+
78
+ ```bash
79
+ repomix --no-security-check # CHỈ khi đã xác nhận là báo nhầm, và principal đã biết
80
+ ```
81
+
82
+ Tắt quét secret rồi đổ file vào context là cách lộ credential mà không ai nhìn thấy.
83
+
84
+ ### Repo từ xa
85
+
86
+ ```bash
87
+ npx repomix --remote https://github.com/owner/repo
88
+ npx repomix --remote https://github.com/owner/repo/commit/abc123 # đúng commit
89
+ ```
90
+
91
+ Repo private: clone về trước rồi chạy cục bộ — và clone là tải mã nguồn lạ, báo principal.
92
+
93
+ Ghi lại **commit hoặc tag đã gói**. Không có nó thì kết quả không tái lập được, và không
94
+ đối chiếu được khi thư viện ra bản mới.
95
+
96
+ ## Quy trình
97
+
98
+ **Trước:** khoanh phạm vi → xác định file cần → chạy `--token-count-tree` → nghĩ tới rủi ro
99
+ bảo mật.
100
+
101
+ **Trong:** bắt đầu hẹp rồi mở dần, không làm ngược → chọn định dạng đúng mục đích → giữ
102
+ quét secret bật.
103
+
104
+ **Sau:** xác nhận không có gì nhạy cảm → kiểm đã đủ chưa → **dọn file `repomix-output.*`**.
105
+
106
+ Bước dọn hay bị quên, và file gói sót lại rất dễ lọt vào commit sau đó.
Binary file
@@ -0,0 +1,179 @@
1
+ # Repomix Scripts
2
+
3
+ Utility scripts for batch processing repositories with Repomix.
4
+
5
+ ## repomix_batch.py
6
+
7
+ Batch process multiple repositories (local or remote) using the repomix CLI tool.
8
+
9
+ ### Features
10
+
11
+ - Process multiple repositories in one command
12
+ - Support local and remote repositories
13
+ - Configurable output formats (XML, Markdown, JSON, Plain)
14
+ - Environment variable loading from multiple .env file locations
15
+ - Comprehensive error handling
16
+ - Progress reporting
17
+
18
+ ### Installation
19
+
20
+ Requires Python 3.10+ and repomix CLI:
21
+
22
+ ```bash
23
+ # Install repomix
24
+ npm install -g repomix
25
+
26
+ # Install Python dependencies (if needed)
27
+ pip install pytest pytest-cov pytest-mock # For running tests
28
+ ```
29
+
30
+ ### Usage
31
+
32
+ **Process single repository:**
33
+ ```bash
34
+ python repomix_batch.py /path/to/repo
35
+ ```
36
+
37
+ **Process multiple repositories:**
38
+ ```bash
39
+ python repomix_batch.py /repo1 /repo2 /repo3
40
+ ```
41
+
42
+ **Process remote repositories:**
43
+ ```bash
44
+ python repomix_batch.py owner/repo1 owner/repo2 --remote
45
+ ```
46
+
47
+ **From JSON file:**
48
+ ```bash
49
+ python repomix_batch.py -f repos.json
50
+ ```
51
+
52
+ **With options:**
53
+ ```bash
54
+ python repomix_batch.py /repo1 /repo2 \
55
+ --style markdown \
56
+ --output-dir output \
57
+ --remove-comments \
58
+ --include "src/**/*.ts" \
59
+ --ignore "tests/**" \
60
+ --verbose
61
+ ```
62
+
63
+ ### Configuration File Format
64
+
65
+ Create `repos.json` with repository configurations:
66
+
67
+ ```json
68
+ [
69
+ {
70
+ "path": "/path/to/local/repo",
71
+ "output": "custom-output.xml"
72
+ },
73
+ {
74
+ "path": "owner/repo",
75
+ "remote": true
76
+ },
77
+ {
78
+ "path": "https://github.com/owner/repo",
79
+ "remote": true,
80
+ "output": "repo-output.md"
81
+ }
82
+ ]
83
+ ```
84
+
85
+ ### Environment Variables
86
+
87
+ Loads .env files in order of precedence:
88
+ 1. Process environment (highest priority)
89
+ 2. `./repomix/.env` (skill-specific)
90
+ 3. `./skills/.env` (skills directory)
91
+ 4. `./.claude/.env` (lowest priority)
92
+
93
+ ### Command Line Options
94
+
95
+ ```
96
+ positional arguments:
97
+ repos Repository paths or URLs to process
98
+
99
+ options:
100
+ -h, --help Show help message
101
+ -f, --file FILE JSON file containing repository configurations
102
+ --style {xml,markdown,json,plain}
103
+ Output format (default: xml)
104
+ -o, --output-dir DIR Output directory (default: repomix-output)
105
+ --remove-comments Remove comments from source files
106
+ --include PATTERN Include pattern (glob)
107
+ --ignore PATTERN Ignore pattern (glob)
108
+ --no-security-check Disable security checks
109
+ -v, --verbose Verbose output
110
+ --remote Treat all repos as remote URLs
111
+ ```
112
+
113
+ ### Examples
114
+
115
+ **Process local repositories:**
116
+ ```bash
117
+ python repomix_batch.py /path/to/repo1 /path/to/repo2 --style markdown
118
+ ```
119
+
120
+ **Process remote repositories:**
121
+ ```bash
122
+ python repomix_batch.py yamadashy/repomix facebook/react --remote
123
+ ```
124
+
125
+ **Mixed configuration:**
126
+ ```bash
127
+ python repomix_batch.py \
128
+ /local/repo \
129
+ --remote owner/remote-repo \
130
+ -f additional-repos.json \
131
+ --style json \
132
+ --remove-comments
133
+ ```
134
+
135
+ **TypeScript projects only:**
136
+ ```bash
137
+ python repomix_batch.py /repo1 /repo2 \
138
+ --include "**/*.ts,**/*.tsx" \
139
+ --ignore "**/*.test.ts,dist/" \
140
+ --remove-comments \
141
+ --style markdown
142
+ ```
143
+
144
+ ### Testing
145
+
146
+ Run tests with coverage:
147
+
148
+ ```bash
149
+ cd tests
150
+ pytest test_repomix_batch.py -v --cov=repomix_batch --cov-report=term-missing
151
+ ```
152
+
153
+ Current coverage: 99%
154
+
155
+ ### Exit Codes
156
+
157
+ - `0` - All repositories processed successfully
158
+ - `1` - One or more repositories failed or error occurred
159
+
160
+ ### Troubleshooting
161
+
162
+ **repomix not found:**
163
+ ```bash
164
+ npm install -g repomix
165
+ ```
166
+
167
+ **Permission denied:**
168
+ ```bash
169
+ chmod +x repomix_batch.py
170
+ ```
171
+
172
+ **Timeout errors:**
173
+ - Default timeout: 5 minutes per repository
174
+ - Reduce scope with `--include` patterns
175
+ - Exclude large directories with `--ignore`
176
+
177
+ **No repositories specified:**
178
+ - Provide repository paths as arguments
179
+ - Or use `-f` flag with JSON config file