compact-agent 1.1.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 (324) hide show
  1. package/README.md +394 -0
  2. package/bin/anycode.js +2 -0
  3. package/bin/crowcoder.js +19 -0
  4. package/bin/ecc-hooks.cjs +138 -0
  5. package/dist/agents.d.ts +17 -0
  6. package/dist/agents.js +1603 -0
  7. package/dist/agents.js.map +1 -0
  8. package/dist/api.d.ts +16 -0
  9. package/dist/api.js +115 -0
  10. package/dist/api.js.map +1 -0
  11. package/dist/autonomous-loops.d.ts +108 -0
  12. package/dist/autonomous-loops.js +526 -0
  13. package/dist/autonomous-loops.js.map +1 -0
  14. package/dist/codemaps.d.ts +53 -0
  15. package/dist/codemaps.js +325 -0
  16. package/dist/codemaps.js.map +1 -0
  17. package/dist/compaction.d.ts +30 -0
  18. package/dist/compaction.js +125 -0
  19. package/dist/compaction.js.map +1 -0
  20. package/dist/config.d.ts +5 -0
  21. package/dist/config.js +79 -0
  22. package/dist/config.js.map +1 -0
  23. package/dist/content-engine.d.ts +97 -0
  24. package/dist/content-engine.js +721 -0
  25. package/dist/content-engine.js.map +1 -0
  26. package/dist/cost-tracker.d.ts +49 -0
  27. package/dist/cost-tracker.js +150 -0
  28. package/dist/cost-tracker.js.map +1 -0
  29. package/dist/counter-button.d.ts +35 -0
  30. package/dist/counter-button.js +48 -0
  31. package/dist/counter-button.js.map +1 -0
  32. package/dist/counter.d.ts +21 -0
  33. package/dist/counter.js +31 -0
  34. package/dist/counter.js.map +1 -0
  35. package/dist/coverage.d.ts +23 -0
  36. package/dist/coverage.js +215 -0
  37. package/dist/coverage.js.map +1 -0
  38. package/dist/docs-sync.d.ts +23 -0
  39. package/dist/docs-sync.js +266 -0
  40. package/dist/docs-sync.js.map +1 -0
  41. package/dist/ecc.d.ts +41 -0
  42. package/dist/ecc.js +644 -0
  43. package/dist/ecc.js.map +1 -0
  44. package/dist/evaluation.d.ts +24 -0
  45. package/dist/evaluation.js +412 -0
  46. package/dist/evaluation.js.map +1 -0
  47. package/dist/export.d.ts +22 -0
  48. package/dist/export.js +109 -0
  49. package/dist/export.js.map +1 -0
  50. package/dist/git-workflow.d.ts +22 -0
  51. package/dist/git-workflow.js +197 -0
  52. package/dist/git-workflow.js.map +1 -0
  53. package/dist/hook-controls.d.ts +34 -0
  54. package/dist/hook-controls.js +90 -0
  55. package/dist/hook-controls.js.map +1 -0
  56. package/dist/hooks.d.ts +30 -0
  57. package/dist/hooks.js +130 -0
  58. package/dist/hooks.js.map +1 -0
  59. package/dist/html-parser.d.ts +18 -0
  60. package/dist/html-parser.js +101 -0
  61. package/dist/html-parser.js.map +1 -0
  62. package/dist/index.d.ts +12 -0
  63. package/dist/index.js +1230 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/learning.d.ts +35 -0
  66. package/dist/learning.js +238 -0
  67. package/dist/learning.js.map +1 -0
  68. package/dist/login.d.ts +37 -0
  69. package/dist/login.js +191 -0
  70. package/dist/login.js.map +1 -0
  71. package/dist/memory.d.ts +39 -0
  72. package/dist/memory.js +183 -0
  73. package/dist/memory.js.map +1 -0
  74. package/dist/model-router.d.ts +23 -0
  75. package/dist/model-router.js +145 -0
  76. package/dist/model-router.js.map +1 -0
  77. package/dist/modes.d.ts +17 -0
  78. package/dist/modes.js +217 -0
  79. package/dist/modes.js.map +1 -0
  80. package/dist/orchestration.d.ts +37 -0
  81. package/dist/orchestration.js +139 -0
  82. package/dist/orchestration.js.map +1 -0
  83. package/dist/package-detect.d.ts +36 -0
  84. package/dist/package-detect.js +529 -0
  85. package/dist/package-detect.js.map +1 -0
  86. package/dist/permissions.d.ts +25 -0
  87. package/dist/permissions.js +50 -0
  88. package/dist/permissions.js.map +1 -0
  89. package/dist/pm2-manager.d.ts +40 -0
  90. package/dist/pm2-manager.js +127 -0
  91. package/dist/pm2-manager.js.map +1 -0
  92. package/dist/query.d.ts +15 -0
  93. package/dist/query.js +278 -0
  94. package/dist/query.js.map +1 -0
  95. package/dist/refactor.d.ts +22 -0
  96. package/dist/refactor.js +226 -0
  97. package/dist/refactor.js.map +1 -0
  98. package/dist/retry.d.ts +20 -0
  99. package/dist/retry.js +88 -0
  100. package/dist/retry.js.map +1 -0
  101. package/dist/rules.d.ts +34 -0
  102. package/dist/rules.js +942 -0
  103. package/dist/rules.js.map +1 -0
  104. package/dist/schema.d.ts +23 -0
  105. package/dist/schema.js +12 -0
  106. package/dist/schema.js.map +1 -0
  107. package/dist/search-first.d.ts +17 -0
  108. package/dist/search-first.js +301 -0
  109. package/dist/search-first.js.map +1 -0
  110. package/dist/security.d.ts +10 -0
  111. package/dist/security.js +145 -0
  112. package/dist/security.js.map +1 -0
  113. package/dist/sessions.d.ts +21 -0
  114. package/dist/sessions.js +112 -0
  115. package/dist/sessions.js.map +1 -0
  116. package/dist/skill-create.d.ts +38 -0
  117. package/dist/skill-create.js +389 -0
  118. package/dist/skill-create.js.map +1 -0
  119. package/dist/skills.d.ts +34 -0
  120. package/dist/skills.js +161 -0
  121. package/dist/skills.js.map +1 -0
  122. package/dist/strategic-compaction.d.ts +24 -0
  123. package/dist/strategic-compaction.js +144 -0
  124. package/dist/strategic-compaction.js.map +1 -0
  125. package/dist/system-prompt.d.ts +3 -0
  126. package/dist/system-prompt.js +101 -0
  127. package/dist/system-prompt.js.map +1 -0
  128. package/dist/theme.d.ts +60 -0
  129. package/dist/theme.js +220 -0
  130. package/dist/theme.js.map +1 -0
  131. package/dist/tools/bash.d.ts +2 -0
  132. package/dist/tools/bash.js +49 -0
  133. package/dist/tools/bash.js.map +1 -0
  134. package/dist/tools/edit.d.ts +2 -0
  135. package/dist/tools/edit.js +76 -0
  136. package/dist/tools/edit.js.map +1 -0
  137. package/dist/tools/glob.d.ts +2 -0
  138. package/dist/tools/glob.js +54 -0
  139. package/dist/tools/glob.js.map +1 -0
  140. package/dist/tools/grep.d.ts +2 -0
  141. package/dist/tools/grep.js +64 -0
  142. package/dist/tools/grep.js.map +1 -0
  143. package/dist/tools/index.d.ts +5 -0
  144. package/dist/tools/index.js +27 -0
  145. package/dist/tools/index.js.map +1 -0
  146. package/dist/tools/list-dir.d.ts +2 -0
  147. package/dist/tools/list-dir.js +51 -0
  148. package/dist/tools/list-dir.js.map +1 -0
  149. package/dist/tools/read.d.ts +2 -0
  150. package/dist/tools/read.js +56 -0
  151. package/dist/tools/read.js.map +1 -0
  152. package/dist/tools/types.d.ts +45 -0
  153. package/dist/tools/types.js +2 -0
  154. package/dist/tools/types.js.map +1 -0
  155. package/dist/tools/web-fetch.d.ts +2 -0
  156. package/dist/tools/web-fetch.js +41 -0
  157. package/dist/tools/web-fetch.js.map +1 -0
  158. package/dist/tools/web-search.d.ts +27 -0
  159. package/dist/tools/web-search.js +139 -0
  160. package/dist/tools/web-search.js.map +1 -0
  161. package/dist/tools/write.d.ts +2 -0
  162. package/dist/tools/write.js +36 -0
  163. package/dist/tools/write.js.map +1 -0
  164. package/dist/types.d.ts +28 -0
  165. package/dist/types.js +57 -0
  166. package/dist/types.js.map +1 -0
  167. package/dist/users.d.ts +51 -0
  168. package/dist/users.js +193 -0
  169. package/dist/users.js.map +1 -0
  170. package/dist/verification.d.ts +73 -0
  171. package/dist/verification.js +269 -0
  172. package/dist/verification.js.map +1 -0
  173. package/dist/walkthrough.d.ts +10 -0
  174. package/dist/walkthrough.js +121 -0
  175. package/dist/walkthrough.js.map +1 -0
  176. package/package.json +58 -0
  177. package/resources/ecc/agents/architect.json +16 -0
  178. package/resources/ecc/agents/architect.md +212 -0
  179. package/resources/ecc/agents/build-error-resolver.json +17 -0
  180. package/resources/ecc/agents/build-error-resolver.md +116 -0
  181. package/resources/ecc/agents/chief-of-staff.json +17 -0
  182. package/resources/ecc/agents/chief-of-staff.md +153 -0
  183. package/resources/ecc/agents/code-reviewer.json +16 -0
  184. package/resources/ecc/agents/code-reviewer.md +238 -0
  185. package/resources/ecc/agents/database-reviewer.json +16 -0
  186. package/resources/ecc/agents/database-reviewer.md +92 -0
  187. package/resources/ecc/agents/doc-updater.json +16 -0
  188. package/resources/ecc/agents/doc-updater.md +108 -0
  189. package/resources/ecc/agents/e2e-runner.json +17 -0
  190. package/resources/ecc/agents/e2e-runner.md +109 -0
  191. package/resources/ecc/agents/go-build-resolver.json +17 -0
  192. package/resources/ecc/agents/go-build-resolver.md +96 -0
  193. package/resources/ecc/agents/go-reviewer.json +16 -0
  194. package/resources/ecc/agents/go-reviewer.md +77 -0
  195. package/resources/ecc/agents/harness-optimizer.json +15 -0
  196. package/resources/ecc/agents/harness-optimizer.md +34 -0
  197. package/resources/ecc/agents/loop-operator.json +16 -0
  198. package/resources/ecc/agents/loop-operator.md +36 -0
  199. package/resources/ecc/agents/planner.json +15 -0
  200. package/resources/ecc/agents/planner.md +212 -0
  201. package/resources/ecc/agents/python-reviewer.json +16 -0
  202. package/resources/ecc/agents/python-reviewer.md +99 -0
  203. package/resources/ecc/agents/refactor-cleaner.json +17 -0
  204. package/resources/ecc/agents/refactor-cleaner.md +87 -0
  205. package/resources/ecc/agents/security-reviewer.json +16 -0
  206. package/resources/ecc/agents/security-reviewer.md +109 -0
  207. package/resources/ecc/agents/tdd-guide.json +17 -0
  208. package/resources/ecc/agents/tdd-guide.md +93 -0
  209. package/resources/ecc/commands/add-language-rules.md +39 -0
  210. package/resources/ecc/commands/database-migration.md +36 -0
  211. package/resources/ecc/commands/feature-development.md +38 -0
  212. package/resources/ecc/prompts/build-fix.prompt.md +47 -0
  213. package/resources/ecc/prompts/code-review.prompt.md +56 -0
  214. package/resources/ecc/prompts/plan.prompt.md +52 -0
  215. package/resources/ecc/prompts/refactor.prompt.md +50 -0
  216. package/resources/ecc/prompts/security-review.prompt.md +70 -0
  217. package/resources/ecc/prompts/tdd.prompt.md +47 -0
  218. package/resources/ecc/rules/common-agents.md +53 -0
  219. package/resources/ecc/rules/common-coding-style.md +52 -0
  220. package/resources/ecc/rules/common-development-workflow.md +33 -0
  221. package/resources/ecc/rules/common-git-workflow.md +28 -0
  222. package/resources/ecc/rules/common-hooks.md +34 -0
  223. package/resources/ecc/rules/common-patterns.md +35 -0
  224. package/resources/ecc/rules/common-performance.md +59 -0
  225. package/resources/ecc/rules/common-security.md +33 -0
  226. package/resources/ecc/rules/common-testing.md +33 -0
  227. package/resources/ecc/rules/golang-coding-style.md +31 -0
  228. package/resources/ecc/rules/golang-hooks.md +16 -0
  229. package/resources/ecc/rules/golang-patterns.md +44 -0
  230. package/resources/ecc/rules/golang-security.md +33 -0
  231. package/resources/ecc/rules/golang-testing.md +30 -0
  232. package/resources/ecc/rules/kotlin-coding-style.md +39 -0
  233. package/resources/ecc/rules/kotlin-hooks.md +16 -0
  234. package/resources/ecc/rules/kotlin-patterns.md +50 -0
  235. package/resources/ecc/rules/kotlin-security.md +58 -0
  236. package/resources/ecc/rules/kotlin-testing.md +38 -0
  237. package/resources/ecc/rules/php-coding-style.md +25 -0
  238. package/resources/ecc/rules/php-hooks.md +21 -0
  239. package/resources/ecc/rules/php-patterns.md +23 -0
  240. package/resources/ecc/rules/php-security.md +24 -0
  241. package/resources/ecc/rules/php-testing.md +26 -0
  242. package/resources/ecc/rules/python-coding-style.md +42 -0
  243. package/resources/ecc/rules/python-hooks.md +19 -0
  244. package/resources/ecc/rules/python-patterns.md +39 -0
  245. package/resources/ecc/rules/python-security.md +30 -0
  246. package/resources/ecc/rules/python-testing.md +38 -0
  247. package/resources/ecc/rules/swift-coding-style.md +47 -0
  248. package/resources/ecc/rules/swift-hooks.md +20 -0
  249. package/resources/ecc/rules/swift-patterns.md +66 -0
  250. package/resources/ecc/rules/swift-security.md +33 -0
  251. package/resources/ecc/rules/swift-testing.md +45 -0
  252. package/resources/ecc/rules/typescript-coding-style.md +63 -0
  253. package/resources/ecc/rules/typescript-hooks.md +20 -0
  254. package/resources/ecc/rules/typescript-patterns.md +50 -0
  255. package/resources/ecc/rules/typescript-security.md +26 -0
  256. package/resources/ecc/rules/typescript-testing.md +16 -0
  257. package/resources/ecc/skills/agent-introspection-debugging/SKILL.md +152 -0
  258. package/resources/ecc/skills/agent-introspection-debugging/agents/openai.yaml +7 -0
  259. package/resources/ecc/skills/agent-sort/SKILL.md +214 -0
  260. package/resources/ecc/skills/agent-sort/agents/openai.yaml +7 -0
  261. package/resources/ecc/skills/api-design/SKILL.md +522 -0
  262. package/resources/ecc/skills/api-design/agents/openai.yaml +7 -0
  263. package/resources/ecc/skills/article-writing/SKILL.md +78 -0
  264. package/resources/ecc/skills/article-writing/agents/openai.yaml +7 -0
  265. package/resources/ecc/skills/backend-patterns/SKILL.md +597 -0
  266. package/resources/ecc/skills/backend-patterns/agents/openai.yaml +7 -0
  267. package/resources/ecc/skills/brand-voice/SKILL.md +96 -0
  268. package/resources/ecc/skills/brand-voice/agents/openai.yaml +7 -0
  269. package/resources/ecc/skills/brand-voice/references/voice-profile-schema.md +55 -0
  270. package/resources/ecc/skills/bun-runtime/SKILL.md +83 -0
  271. package/resources/ecc/skills/bun-runtime/agents/openai.yaml +7 -0
  272. package/resources/ecc/skills/coding-standards/SKILL.md +548 -0
  273. package/resources/ecc/skills/coding-standards/agents/openai.yaml +7 -0
  274. package/resources/ecc/skills/content-engine/SKILL.md +130 -0
  275. package/resources/ecc/skills/content-engine/agents/openai.yaml +7 -0
  276. package/resources/ecc/skills/crosspost/SKILL.md +110 -0
  277. package/resources/ecc/skills/crosspost/agents/openai.yaml +7 -0
  278. package/resources/ecc/skills/deep-research/SKILL.md +154 -0
  279. package/resources/ecc/skills/deep-research/agents/openai.yaml +7 -0
  280. package/resources/ecc/skills/dmux-workflows/SKILL.md +143 -0
  281. package/resources/ecc/skills/dmux-workflows/agents/openai.yaml +7 -0
  282. package/resources/ecc/skills/documentation-lookup/SKILL.md +89 -0
  283. package/resources/ecc/skills/documentation-lookup/agents/openai.yaml +7 -0
  284. package/resources/ecc/skills/e2e-testing/SKILL.md +325 -0
  285. package/resources/ecc/skills/e2e-testing/agents/openai.yaml +7 -0
  286. package/resources/ecc/skills/eval-harness/SKILL.md +235 -0
  287. package/resources/ecc/skills/eval-harness/agents/openai.yaml +7 -0
  288. package/resources/ecc/skills/everything-claude-code/SKILL.md +442 -0
  289. package/resources/ecc/skills/everything-claude-code/agents/openai.yaml +7 -0
  290. package/resources/ecc/skills/exa-search/SKILL.md +169 -0
  291. package/resources/ecc/skills/exa-search/agents/openai.yaml +7 -0
  292. package/resources/ecc/skills/fal-ai-media/SKILL.md +276 -0
  293. package/resources/ecc/skills/fal-ai-media/agents/openai.yaml +7 -0
  294. package/resources/ecc/skills/frontend-patterns/SKILL.md +647 -0
  295. package/resources/ecc/skills/frontend-patterns/agents/openai.yaml +7 -0
  296. package/resources/ecc/skills/frontend-slides/SKILL.md +183 -0
  297. package/resources/ecc/skills/frontend-slides/STYLE_PRESETS.md +330 -0
  298. package/resources/ecc/skills/frontend-slides/agents/openai.yaml +7 -0
  299. package/resources/ecc/skills/investor-materials/SKILL.md +95 -0
  300. package/resources/ecc/skills/investor-materials/agents/openai.yaml +7 -0
  301. package/resources/ecc/skills/investor-outreach/SKILL.md +90 -0
  302. package/resources/ecc/skills/investor-outreach/agents/openai.yaml +7 -0
  303. package/resources/ecc/skills/market-research/SKILL.md +74 -0
  304. package/resources/ecc/skills/market-research/agents/openai.yaml +7 -0
  305. package/resources/ecc/skills/mcp-server-patterns/SKILL.md +66 -0
  306. package/resources/ecc/skills/mcp-server-patterns/agents/openai.yaml +7 -0
  307. package/resources/ecc/skills/mle-workflow/SKILL.md +346 -0
  308. package/resources/ecc/skills/mle-workflow/agents/openai.yaml +7 -0
  309. package/resources/ecc/skills/nextjs-turbopack/SKILL.md +43 -0
  310. package/resources/ecc/skills/nextjs-turbopack/agents/openai.yaml +7 -0
  311. package/resources/ecc/skills/product-capability/SKILL.md +140 -0
  312. package/resources/ecc/skills/product-capability/agents/openai.yaml +7 -0
  313. package/resources/ecc/skills/security-review/SKILL.md +494 -0
  314. package/resources/ecc/skills/security-review/agents/openai.yaml +7 -0
  315. package/resources/ecc/skills/strategic-compact/SKILL.md +102 -0
  316. package/resources/ecc/skills/strategic-compact/agents/openai.yaml +7 -0
  317. package/resources/ecc/skills/tdd-workflow/SKILL.md +409 -0
  318. package/resources/ecc/skills/tdd-workflow/agents/openai.yaml +7 -0
  319. package/resources/ecc/skills/verification-loop/SKILL.md +125 -0
  320. package/resources/ecc/skills/verification-loop/agents/openai.yaml +7 -0
  321. package/resources/ecc/skills/video-editing/SKILL.md +307 -0
  322. package/resources/ecc/skills/video-editing/agents/openai.yaml +7 -0
  323. package/resources/ecc/skills/x-api/SKILL.md +229 -0
  324. package/resources/ecc/skills/x-api/agents/openai.yaml +7 -0
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Dead Code Detection & Cleanup — find unused code, duplicates, and refactoring opportunities.
3
+ * Suggests safe refactorings while ensuring tests still pass.
4
+ */
5
+ import chalk from 'chalk';
6
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import { getProjectLanguage } from './docs-sync.js';
9
+ // ── Helper: Find source files ──────────────────────────────────────
10
+ function findSourceFiles(cwd, language) {
11
+ const files = [];
12
+ const srcDir = join(cwd, 'src');
13
+ if (!existsSync(srcDir))
14
+ return files;
15
+ const extensions = {
16
+ typescript: ['.ts', '.tsx'],
17
+ javascript: ['.js', '.jsx'],
18
+ python: ['.py'],
19
+ rust: ['.rs'],
20
+ };
21
+ const exts = extensions[language] || [];
22
+ const recurse = (dir) => {
23
+ try {
24
+ const entries = readdirSync(dir, { withFileTypes: true });
25
+ for (const entry of entries) {
26
+ if (entry.isDirectory() && !entry.name.startsWith('.')) {
27
+ recurse(join(dir, entry.name));
28
+ }
29
+ else if (entry.isFile() && exts.some((ext) => entry.name.endsWith(ext))) {
30
+ files.push(join(dir, entry.name));
31
+ }
32
+ }
33
+ }
34
+ catch {
35
+ // Ignore read errors
36
+ }
37
+ };
38
+ recurse(srcDir);
39
+ return files;
40
+ }
41
+ // ── Helper: Check if test command exists ──────────────────────────
42
+ function hasTestCommand(cwd) {
43
+ try {
44
+ const pkgPath = join(cwd, 'package.json');
45
+ if (existsSync(pkgPath)) {
46
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
47
+ return !!(pkg.scripts && (pkg.scripts.test || pkg.scripts['test:unit']));
48
+ }
49
+ }
50
+ catch {
51
+ // Continue
52
+ }
53
+ return false;
54
+ }
55
+ // ── Main Functions ──────────────────────────────────────────────
56
+ /**
57
+ * Build a comprehensive prompt for AI to detect dead code and duplicates.
58
+ * Optionally targets a specific file or pattern.
59
+ */
60
+ export function buildRefactorPrompt(cwd, target) {
61
+ const language = getProjectLanguage(cwd);
62
+ const sourceFiles = findSourceFiles(cwd, language);
63
+ const testAvailable = hasTestCommand(cwd);
64
+ const targetInfo = target
65
+ ? `\n## Target for Refactoring\nFocus on: \`${target}\``
66
+ : `\n## Project Structure\nFound ${sourceFiles.length} source files`;
67
+ return `Analyze this project for dead code, duplication, and refactoring opportunities.
68
+
69
+ ## Current Working Directory
70
+ \`\`\`
71
+ ${cwd}
72
+ \`\`\`
73
+
74
+ ## Detected Language
75
+ ${language}
76
+
77
+ ${targetInfo}
78
+
79
+ ## Instructions
80
+ 1. Scan for dead code:
81
+ - Unused exports (functions, classes, constants declared but never imported)
82
+ - Unreachable code (after returns, in dead branches)
83
+ - Unused variables and function parameters
84
+ - Unused imports
85
+
86
+ 2. Find code duplication:
87
+ - Similar logic repeated in multiple functions
88
+ - Duplicated error handling patterns
89
+ - Identical conditional branches
90
+ - Extract common patterns into shared utilities
91
+
92
+ 3. Identify complexity issues:
93
+ - Functions with high cyclomatic complexity (>10)
94
+ - Long parameter lists (>4 params)
95
+ - Deep nesting levels (>3 levels)
96
+ - Overly long files (>300 lines)
97
+
98
+ 4. Suggest refactorings:
99
+ - Inline unused variables
100
+ - Consolidate duplicated logic
101
+ - Extract helper functions
102
+ - Break apart complex functions
103
+ - Reorganize imports
104
+
105
+ 5. Ensure test coverage${testAvailable ? ': Run tests after each change' : ' (note: no test script detected)'}
106
+
107
+ ## Refactoring Strategy
108
+ ${testAvailable ? '- Before refactoring: run `npm test` to establish baseline\n- After each change: verify tests still pass\n- Only apply changes if tests pass' : '- Document each change clearly\n- Preserve public API signatures'}
109
+
110
+ ## Expected Output Format
111
+ For each finding, provide:
112
+ 1. **Type**: (unused export / unreachable code / duplication / complexity)
113
+ 2. **Location**: File path and line range
114
+ 3. **Current Code**: Snippet showing the issue
115
+ 4. **Suggested Fix**: Concrete refactoring steps
116
+ 5. **Risk Level**: Low / Medium / High
117
+ 6. **Test Impact**: How to verify the change is safe
118
+
119
+ ## Priority Order
120
+ 1. Remove unused exports (safest)
121
+ 2. Consolidate duplication (high impact)
122
+ 3. Simplify complex functions (medium risk)
123
+ 4. Reorganize code structure (larger refactors)`;
124
+ }
125
+ /**
126
+ * Build a more focused prompt for dead code cleanup only.
127
+ */
128
+ export function buildCleanupPrompt(cwd) {
129
+ const language = getProjectLanguage(cwd);
130
+ return `Clean up dead code in this project.
131
+
132
+ ## Current Working Directory
133
+ \`\`\`
134
+ ${cwd}
135
+ \`\`\`
136
+
137
+ ## Language
138
+ ${language}
139
+
140
+ ## Focus Areas
141
+ 1. Remove unused imports
142
+ 2. Delete unused variables and constants
143
+ 3. Remove commented-out code
144
+ 4. Clean up unused function parameters
145
+ 5. Delete unused exports
146
+
147
+ ## Instructions
148
+ - Go through each source file
149
+ - Identify lines/blocks that serve no purpose
150
+ - Remove them one at a time
151
+ - Keep the code compiling/running
152
+ - Remove trailing whitespace and fix formatting
153
+
154
+ ## Output Format
155
+ For each cleanup action:
156
+ - **File**: Path to the file
157
+ - **Action**: What was removed or cleaned
158
+ - **Before/After**: Show the change
159
+ - **Reason**: Why it's safe to remove
160
+
161
+ Focus on speed and confidence over perfection.`;
162
+ }
163
+ /**
164
+ * Print a summary of dead code analysis.
165
+ */
166
+ export function printDeadCodeAnalysis(analysis) {
167
+ const isEmpty = analysis.unusedExports.length === 0 &&
168
+ analysis.unreachableCode.length === 0 &&
169
+ analysis.unusedVariables.length === 0 &&
170
+ analysis.duplicatedLogic.length === 0 &&
171
+ analysis.highComplexityFunctions.length === 0;
172
+ console.log(chalk.cyan('\n Dead Code Analysis:'));
173
+ if (isEmpty) {
174
+ console.log(chalk.green(' ✓ No obvious dead code detected'));
175
+ console.log();
176
+ return;
177
+ }
178
+ if (analysis.unusedExports.length > 0) {
179
+ console.log(chalk.yellow(` Unused Exports (${analysis.unusedExports.length}):`));
180
+ analysis.unusedExports.slice(0, 5).forEach((item) => {
181
+ console.log(chalk.dim(` - ${item}`));
182
+ });
183
+ if (analysis.unusedExports.length > 5) {
184
+ console.log(chalk.dim(` ... and ${analysis.unusedExports.length - 5} more`));
185
+ }
186
+ }
187
+ if (analysis.unreachableCode.length > 0) {
188
+ console.log(chalk.red(` Unreachable Code (${analysis.unreachableCode.length}):`));
189
+ analysis.unreachableCode.slice(0, 5).forEach((item) => {
190
+ console.log(chalk.dim(` - ${item}`));
191
+ });
192
+ if (analysis.unreachableCode.length > 5) {
193
+ console.log(chalk.dim(` ... and ${analysis.unreachableCode.length - 5} more`));
194
+ }
195
+ }
196
+ if (analysis.duplicatedLogic.length > 0) {
197
+ console.log(chalk.yellow(` Duplicated Logic (${analysis.duplicatedLogic.length}):`));
198
+ analysis.duplicatedLogic.slice(0, 5).forEach((item) => {
199
+ console.log(chalk.dim(` - ${item}`));
200
+ });
201
+ if (analysis.duplicatedLogic.length > 5) {
202
+ console.log(chalk.dim(` ... and ${analysis.duplicatedLogic.length - 5} more`));
203
+ }
204
+ }
205
+ if (analysis.highComplexityFunctions.length > 0) {
206
+ console.log(chalk.yellow(` High Complexity Functions (${analysis.highComplexityFunctions.length}):`));
207
+ analysis.highComplexityFunctions.slice(0, 5).forEach((item) => {
208
+ console.log(chalk.dim(` - ${item}`));
209
+ });
210
+ if (analysis.highComplexityFunctions.length > 5) {
211
+ console.log(chalk.dim(` ... and ${analysis.highComplexityFunctions.length - 5} more`));
212
+ }
213
+ }
214
+ console.log();
215
+ }
216
+ // ── Exports ──────────────────────────────────────────────
217
+ // `getProjectLanguage` is exported from docs-sync.ts (imported above) — don't
218
+ // re-export the same identifier here, it collides at the ESM module level.
219
+ export function getSourceFiles(cwd) {
220
+ const language = getProjectLanguage(cwd);
221
+ return findSourceFiles(cwd, language);
222
+ }
223
+ export function projectHasTests(cwd) {
224
+ return hasTestCommand(cwd);
225
+ }
226
+ //# sourceMappingURL=refactor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refactor.js","sourceRoot":"","sources":["../src/refactor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAWpD,sEAAsE;AACtE,SAAS,eAAe,CAAC,GAAW,EAAE,QAAgB;IACpD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAEhC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAEtC,MAAM,UAAU,GAA6B;QAC3C,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;QAC3B,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;QAC3B,MAAM,EAAE,CAAC,KAAK,CAAC;QACf,IAAI,EAAE,CAAC,KAAK,CAAC;KACd,CAAC;IAEF,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1D,KAAK,MAAM,KAAK,IAAI,OA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AAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,QAAQ,CAAC,uBAAuB,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AAED,4DAA4D;AAC5D,8EAA8E;AAC9E,2EAA2E;AAE3E,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACzC,OAAO,eAAe,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Configuration for retry behavior.
3
+ */
4
+ export interface RetryConfig {
5
+ /** Maximum number of retry attempts (default: 3) */
6
+ maxRetries?: number;
7
+ /** Base delay in ms before first retry (default: 1000) */
8
+ baseDelay?: number;
9
+ /** Maximum delay in ms between retries (default: 30000) */
10
+ maxDelay?: number;
11
+ }
12
+ /**
13
+ * Wraps an async operation with retry logic
14
+ *
15
+ * @param operation - The async function to execute
16
+ * @param config - Retry configuration
17
+ * @returns The result of the operation
18
+ * @throws The last error if all retries are exhausted
19
+ */
20
+ export declare function withRetry<T>(operation: () => Promise<T>, config?: RetryConfig): Promise<T>;
package/dist/retry.js ADDED
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Retry utility — exponential backoff for API calls.
3
+ * Retries on rate limits (429), server errors (500/502/503), and network failures.
4
+ */
5
+ import chalk from 'chalk';
6
+ /**
7
+ * Determines if an error is retryable.
8
+ * Retries on: HTTP 429 (rate limit), 500/502/503 (server errors),
9
+ * and common network errors (ECONNREFUSED, ETIMEDOUT, etc.).
10
+ *
11
+ * @param error - The error to evaluate
12
+ * @returns True if the error is transient and the request should be retried
13
+ */
14
+ function isRetryableError(error) {
15
+ // Handle OpenAI APIError and similar error objects
16
+ if (typeof error === 'object' && error !== null) {
17
+ const err = error;
18
+ const status = err.status;
19
+ // Rate limit errors (429)
20
+ if (status === 429)
21
+ return true;
22
+ // Server errors (500, 502, 503)
23
+ if (status === 500 || status === 502 || status === 503)
24
+ return true;
25
+ }
26
+ // Handle network errors
27
+ if (error instanceof Error) {
28
+ const message = error.message.toLowerCase();
29
+ // Common network error patterns
30
+ if (message.includes('econnrefused') ||
31
+ message.includes('econnreset') ||
32
+ message.includes('etimedout') ||
33
+ message.includes('ehostunreach') ||
34
+ message.includes('enetunreach') ||
35
+ message.includes('getaddrinfo') ||
36
+ message.includes('socket') ||
37
+ message.includes('timeout')) {
38
+ return true;
39
+ }
40
+ }
41
+ return false;
42
+ }
43
+ /**
44
+ * Calculate delay with exponential backoff and jitter
45
+ */
46
+ function calculateDelay(attempt, baseDelay, maxDelay) {
47
+ // Exponential backoff: baseDelay * (2 ^ attempt)
48
+ const exponentialDelay = baseDelay * Math.pow(2, attempt);
49
+ // Cap at maxDelay
50
+ const cappedDelay = Math.min(exponentialDelay, maxDelay);
51
+ // Add jitter: ±10% of the calculated delay
52
+ const jitter = cappedDelay * (0.9 + Math.random() * 0.2);
53
+ return Math.floor(jitter);
54
+ }
55
+ /**
56
+ * Wraps an async operation with retry logic
57
+ *
58
+ * @param operation - The async function to execute
59
+ * @param config - Retry configuration
60
+ * @returns The result of the operation
61
+ * @throws The last error if all retries are exhausted
62
+ */
63
+ export async function withRetry(operation, config = {}) {
64
+ const maxRetries = config.maxRetries ?? 3;
65
+ const baseDelay = config.baseDelay ?? 1000;
66
+ const maxDelay = config.maxDelay ?? 30000;
67
+ let lastError;
68
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
69
+ try {
70
+ return await operation();
71
+ }
72
+ catch (error) {
73
+ lastError = error;
74
+ // If not retryable or out of retries, throw immediately
75
+ if (!isRetryableError(error) || attempt === maxRetries) {
76
+ throw error;
77
+ }
78
+ const delay = calculateDelay(attempt, baseDelay, maxDelay);
79
+ const errorMsg = error instanceof Error ? error.message : String(error);
80
+ console.log(chalk.yellow(`Retry attempt ${attempt + 1}/${maxRetries} after ${delay}ms (${errorMsg})`));
81
+ // Wait before retrying
82
+ await new Promise((resolve) => setTimeout(resolve, delay));
83
+ }
84
+ }
85
+ // This should never be reached, but throw the last error just in case
86
+ throw lastError;
87
+ }
88
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B;;;;;;;GAOG;AACH,SAAS,gBAAgB,CAAC,KAAc;IACtC,mDAAmD;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,KAAgC,CAAC;QAC7C,MAAM,MAAM,GAAG,GAAG,CAAC,MAA4B,CAAC;QAEhD,0BAA0B;QAC1B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAEhC,gCAAgC;QAChC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;IACtE,CAAC;IAED,wBAAwB;IACxB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC5C,gCAAgC;QAChC,IACE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;YAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;YAChC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC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AC,gBAAgB,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;gBACvD,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC3D,MAAM,QAAQ,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAExE,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CACV,iBAAiB,OAAO,GAAG,CAAC,IAAI,UAAU,UAAU,KAAK,OAAO,QAAQ,GAAG,CAC5E,CACF,CAAC;YAEF,uBAAuB;YACvB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,MAAM,SAAS,CAAC;AAClB,CAAC"}
@@ -0,0 +1,34 @@
1
+ export interface RuleSet {
2
+ language: string;
3
+ rules: string;
4
+ }
5
+ /**
6
+ * Load rules for a specific language.
7
+ * Checks user rules first, falls back to built-in.
8
+ */
9
+ export declare function loadRules(language: string): string | null;
10
+ /**
11
+ * Save custom rules for a language.
12
+ */
13
+ export declare function saveRules(language: string, rules: string): void;
14
+ /**
15
+ * List all available rule sets (built-in + custom).
16
+ */
17
+ export declare function listRuleSets(): {
18
+ language: string;
19
+ source: 'builtin' | 'custom';
20
+ }[];
21
+ /**
22
+ * Auto-detect languages in the project by file extensions.
23
+ */
24
+ export declare function detectLanguages(cwd: string): string[];
25
+ /**
26
+ * Build rules section for system prompt based on detected languages.
27
+ */
28
+ export declare function buildRulesPrompt(cwd: string): string;
29
+ /**
30
+ * Get detailed coding rules for a specific language.
31
+ * Loads custom rules if available, falls back to comprehensive built-in rules.
32
+ */
33
+ export declare function getLanguageRules(language: string): string;
34
+ export declare function printRules(): void;