@vyuhlabs/dxkit 2.4.8 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/CHANGELOG.md +312 -0
  2. package/README.md +360 -439
  3. package/dist/analyzers/security/aggregator.d.ts.map +1 -1
  4. package/dist/analyzers/security/aggregator.js +4 -46
  5. package/dist/analyzers/security/aggregator.js.map +1 -1
  6. package/dist/analyzers/tools/fingerprint.d.ts +91 -26
  7. package/dist/analyzers/tools/fingerprint.d.ts.map +1 -1
  8. package/dist/analyzers/tools/fingerprint.js +111 -22
  9. package/dist/analyzers/tools/fingerprint.js.map +1 -1
  10. package/dist/analyzers/tools/generic.d.ts.map +1 -1
  11. package/dist/analyzers/tools/generic.js +6 -1
  12. package/dist/analyzers/tools/generic.js.map +1 -1
  13. package/dist/analyzers/tools/gitleaks.d.ts +24 -1
  14. package/dist/analyzers/tools/gitleaks.d.ts.map +1 -1
  15. package/dist/analyzers/tools/gitleaks.js +20 -11
  16. package/dist/analyzers/tools/gitleaks.js.map +1 -1
  17. package/dist/analyzers/tools/graphify.d.ts.map +1 -1
  18. package/dist/analyzers/tools/graphify.js +9 -5
  19. package/dist/analyzers/tools/graphify.js.map +1 -1
  20. package/dist/analyzers/tools/tool-registry.d.ts +19 -1
  21. package/dist/analyzers/tools/tool-registry.d.ts.map +1 -1
  22. package/dist/analyzers/tools/tool-registry.js +25 -0
  23. package/dist/analyzers/tools/tool-registry.js.map +1 -1
  24. package/dist/analyzers/types.d.ts +6 -4
  25. package/dist/analyzers/types.d.ts.map +1 -1
  26. package/dist/baseline/baseline-file.d.ts +104 -0
  27. package/dist/baseline/baseline-file.d.ts.map +1 -0
  28. package/dist/baseline/baseline-file.js +110 -0
  29. package/dist/baseline/baseline-file.js.map +1 -0
  30. package/dist/baseline/check-renderers.d.ts +108 -0
  31. package/dist/baseline/check-renderers.d.ts.map +1 -0
  32. package/dist/baseline/check-renderers.js +379 -0
  33. package/dist/baseline/check-renderers.js.map +1 -0
  34. package/dist/baseline/check.d.ts +127 -0
  35. package/dist/baseline/check.d.ts.map +1 -0
  36. package/dist/baseline/check.js +462 -0
  37. package/dist/baseline/check.js.map +1 -0
  38. package/dist/baseline/content-hash.d.ts +83 -0
  39. package/dist/baseline/content-hash.d.ts.map +1 -0
  40. package/dist/baseline/content-hash.js +131 -0
  41. package/dist/baseline/content-hash.js.map +1 -0
  42. package/dist/baseline/create.d.ts +96 -0
  43. package/dist/baseline/create.d.ts.map +1 -0
  44. package/dist/baseline/create.js +339 -0
  45. package/dist/baseline/create.js.map +1 -0
  46. package/dist/baseline/entry-to-located.d.ts +35 -0
  47. package/dist/baseline/entry-to-located.d.ts.map +1 -0
  48. package/dist/baseline/entry-to-located.js +72 -0
  49. package/dist/baseline/entry-to-located.js.map +1 -0
  50. package/dist/baseline/finding-identity.d.ts +47 -0
  51. package/dist/baseline/finding-identity.d.ts.map +1 -0
  52. package/dist/baseline/finding-identity.js +292 -0
  53. package/dist/baseline/finding-identity.js.map +1 -0
  54. package/dist/baseline/git-aware-match.d.ts +146 -0
  55. package/dist/baseline/git-aware-match.d.ts.map +1 -0
  56. package/dist/baseline/git-aware-match.js +439 -0
  57. package/dist/baseline/git-aware-match.js.map +1 -0
  58. package/dist/baseline/policy.d.ts +171 -0
  59. package/dist/baseline/policy.d.ts.map +1 -0
  60. package/dist/baseline/policy.js +206 -0
  61. package/dist/baseline/policy.js.map +1 -0
  62. package/dist/baseline/producers/health.d.ts +30 -0
  63. package/dist/baseline/producers/health.d.ts.map +1 -0
  64. package/dist/baseline/producers/health.js +42 -0
  65. package/dist/baseline/producers/health.js.map +1 -0
  66. package/dist/baseline/producers/index.d.ts +164 -0
  67. package/dist/baseline/producers/index.d.ts.map +1 -0
  68. package/dist/baseline/producers/index.js +200 -0
  69. package/dist/baseline/producers/index.js.map +1 -0
  70. package/dist/baseline/producers/licenses.d.ts +23 -0
  71. package/dist/baseline/producers/licenses.d.ts.map +1 -0
  72. package/dist/baseline/producers/licenses.js +46 -0
  73. package/dist/baseline/producers/licenses.js.map +1 -0
  74. package/dist/baseline/producers/quality.d.ts +39 -0
  75. package/dist/baseline/producers/quality.d.ts.map +1 -0
  76. package/dist/baseline/producers/quality.js +84 -0
  77. package/dist/baseline/producers/quality.js.map +1 -0
  78. package/dist/baseline/producers/secret-hmac.d.ts +45 -0
  79. package/dist/baseline/producers/secret-hmac.d.ts.map +1 -0
  80. package/dist/baseline/producers/secret-hmac.js +70 -0
  81. package/dist/baseline/producers/secret-hmac.js.map +1 -0
  82. package/dist/baseline/producers/security.d.ts +59 -0
  83. package/dist/baseline/producers/security.d.ts.map +1 -0
  84. package/dist/baseline/producers/security.js +135 -0
  85. package/dist/baseline/producers/security.js.map +1 -0
  86. package/dist/baseline/producers/tests.d.ts +36 -0
  87. package/dist/baseline/producers/tests.d.ts.map +1 -0
  88. package/dist/baseline/producers/tests.js +69 -0
  89. package/dist/baseline/producers/tests.js.map +1 -0
  90. package/dist/baseline/salt.d.ts +45 -0
  91. package/dist/baseline/salt.d.ts.map +1 -0
  92. package/dist/baseline/salt.js +113 -0
  93. package/dist/baseline/salt.js.map +1 -0
  94. package/dist/baseline/show.d.ts +79 -0
  95. package/dist/baseline/show.d.ts.map +1 -0
  96. package/dist/baseline/show.js +233 -0
  97. package/dist/baseline/show.js.map +1 -0
  98. package/dist/baseline/types.d.ts +482 -0
  99. package/dist/baseline/types.d.ts.map +1 -0
  100. package/dist/baseline/types.js +53 -0
  101. package/dist/baseline/types.js.map +1 -0
  102. package/dist/cli.d.ts.map +1 -1
  103. package/dist/cli.js +398 -82
  104. package/dist/cli.js.map +1 -1
  105. package/dist/constants.d.ts.map +1 -1
  106. package/dist/constants.js +0 -4
  107. package/dist/constants.js.map +1 -1
  108. package/dist/doctor.d.ts.map +1 -1
  109. package/dist/doctor.js +39 -35
  110. package/dist/doctor.js.map +1 -1
  111. package/dist/fail-on.d.ts +84 -0
  112. package/dist/fail-on.d.ts.map +1 -0
  113. package/dist/fail-on.js +128 -0
  114. package/dist/fail-on.js.map +1 -0
  115. package/dist/generator.d.ts +1 -1
  116. package/dist/generator.d.ts.map +1 -1
  117. package/dist/generator.js +81 -274
  118. package/dist/generator.js.map +1 -1
  119. package/dist/hooks-cli.d.ts +20 -0
  120. package/dist/hooks-cli.d.ts.map +1 -0
  121. package/dist/hooks-cli.js +145 -0
  122. package/dist/hooks-cli.js.map +1 -0
  123. package/dist/languages/csharp.d.ts.map +1 -1
  124. package/dist/languages/csharp.js +4 -9
  125. package/dist/languages/csharp.js.map +1 -1
  126. package/dist/languages/go.d.ts.map +1 -1
  127. package/dist/languages/go.js +3 -14
  128. package/dist/languages/go.js.map +1 -1
  129. package/dist/languages/index.d.ts +19 -1
  130. package/dist/languages/index.d.ts.map +1 -1
  131. package/dist/languages/index.js +32 -0
  132. package/dist/languages/index.js.map +1 -1
  133. package/dist/languages/java.d.ts.map +1 -1
  134. package/dist/languages/java.js +4 -6
  135. package/dist/languages/java.js.map +1 -1
  136. package/dist/languages/kotlin.d.ts.map +1 -1
  137. package/dist/languages/kotlin.js +9 -11
  138. package/dist/languages/kotlin.js.map +1 -1
  139. package/dist/languages/python.d.ts.map +1 -1
  140. package/dist/languages/python.js +4 -15
  141. package/dist/languages/python.js.map +1 -1
  142. package/dist/languages/ruby.d.ts.map +1 -1
  143. package/dist/languages/ruby.js +4 -6
  144. package/dist/languages/ruby.js.map +1 -1
  145. package/dist/languages/rust.d.ts.map +1 -1
  146. package/dist/languages/rust.js +4 -4
  147. package/dist/languages/rust.js.map +1 -1
  148. package/dist/languages/types.d.ts +29 -28
  149. package/dist/languages/types.d.ts.map +1 -1
  150. package/dist/languages/typescript.d.ts.map +1 -1
  151. package/dist/languages/typescript.js +31 -4
  152. package/dist/languages/typescript.js.map +1 -1
  153. package/dist/lib.d.ts +2 -3
  154. package/dist/lib.d.ts.map +1 -1
  155. package/dist/lib.js +3 -6
  156. package/dist/lib.js.map +1 -1
  157. package/dist/prompts.d.ts.map +1 -1
  158. package/dist/prompts.js +0 -10
  159. package/dist/prompts.js.map +1 -1
  160. package/dist/report-schema.d.ts +42 -0
  161. package/dist/report-schema.d.ts.map +1 -0
  162. package/dist/report-schema.js +54 -0
  163. package/dist/report-schema.js.map +1 -0
  164. package/dist/ship-installers.d.ts +112 -0
  165. package/dist/ship-installers.d.ts.map +1 -0
  166. package/dist/ship-installers.js +530 -0
  167. package/dist/ship-installers.js.map +1 -0
  168. package/dist/tools-cli.d.ts.map +1 -1
  169. package/dist/tools-cli.js +45 -9
  170. package/dist/tools-cli.js.map +1 -1
  171. package/dist/types.d.ts +0 -4
  172. package/dist/types.d.ts.map +1 -1
  173. package/dist/update.d.ts.map +1 -1
  174. package/dist/update.js +0 -4
  175. package/dist/update.js.map +1 -1
  176. package/package.json +17 -11
  177. package/templates/.claude/skills/dxkit-action/SKILL.md +150 -0
  178. package/templates/.claude/skills/dxkit-config/SKILL.md +124 -0
  179. package/templates/.claude/skills/dxkit-hooks/SKILL.md +109 -0
  180. package/templates/.claude/skills/dxkit-init/SKILL.md +93 -0
  181. package/templates/.claude/skills/dxkit-learn/SKILL.md +84 -0
  182. package/templates/.claude/skills/dxkit-reports/SKILL.md +111 -0
  183. package/templates/.devcontainer/devcontainer.json +55 -0
  184. package/templates/.devcontainer/install-agent-clis.sh +42 -0
  185. package/templates/.devcontainer/post-create.sh +81 -0
  186. package/templates/.githooks/pre-commit +55 -0
  187. package/templates/.githooks/pre-push +63 -0
  188. package/templates/.github/workflows/dxkit-baseline-refresh.yml +78 -0
  189. package/templates/.github/workflows/dxkit-guardrails.yml +98 -0
  190. package/templates/AGENTS.md.template +137 -0
  191. package/templates/CLAUDE.md.template +16 -245
  192. package/dist/codebase-scanner.d.ts +0 -36
  193. package/dist/codebase-scanner.d.ts.map +0 -1
  194. package/dist/codebase-scanner.js +0 -688
  195. package/dist/codebase-scanner.js.map +0 -1
  196. package/dist/project-yaml.d.ts +0 -13
  197. package/dist/project-yaml.d.ts.map +0 -1
  198. package/dist/project-yaml.js +0 -188
  199. package/dist/project-yaml.js.map +0 -1
  200. package/templates/.ai/README.md +0 -117
  201. package/templates/.ai/prompts/execution-prompt.md +0 -9
  202. package/templates/.ai/prompts/planning-prompt.md +0 -18
  203. package/templates/.ai/prompts/session-end-template.md +0 -182
  204. package/templates/.ai/prompts/session-end.md +0 -132
  205. package/templates/.ai/prompts/session-start.md +0 -109
  206. package/templates/.ai/prompts/step-by-step.md +0 -113
  207. package/templates/.ai/sessions/.gitkeep +0 -0
  208. package/templates/.claude/agents/doc-writer.md +0 -107
  209. package/templates/.claude/agents/knowledge-bot.md +0 -64
  210. package/templates/.claude/agents/onboarding.md +0 -61
  211. package/templates/.claude/agents/quality-reviewer.md +0 -85
  212. package/templates/.claude/agents-available/code-reviewer.md +0 -29
  213. package/templates/.claude/agents-available/codebase-explorer.md +0 -100
  214. package/templates/.claude/agents-available/dashboard-builder.md +0 -433
  215. package/templates/.claude/agents-available/debugger.md +0 -29
  216. package/templates/.claude/agents-available/dependency-mapper.md +0 -80
  217. package/templates/.claude/agents-available/dev-report.md +0 -108
  218. package/templates/.claude/agents-available/doc-writer.md +0 -107
  219. package/templates/.claude/agents-available/feature-builder.md +0 -163
  220. package/templates/.claude/agents-available/feature-planner.md +0 -185
  221. package/templates/.claude/agents-available/health-auditor.md +0 -95
  222. package/templates/.claude/agents-available/hooks-configurator.md +0 -211
  223. package/templates/.claude/agents-available/knowledge-bot.md +0 -62
  224. package/templates/.claude/agents-available/plan-executor.md +0 -133
  225. package/templates/.claude/agents-available/strategic-planner.md +0 -141
  226. package/templates/.claude/agents-available/test-gap-finder.md +0 -67
  227. package/templates/.claude/agents-available/test-writer.md +0 -34
  228. package/templates/.claude/agents-available/vulnerability-scanner.md +0 -173
  229. package/templates/.claude/commands/ask.md +0 -7
  230. package/templates/.claude/commands/build-feature.md +0 -26
  231. package/templates/.claude/commands/build.md.template +0 -30
  232. package/templates/.claude/commands/check.md.template +0 -43
  233. package/templates/.claude/commands/dashboard.md +0 -28
  234. package/templates/.claude/commands/deps.md +0 -15
  235. package/templates/.claude/commands/dev-report.md +0 -50
  236. package/templates/.claude/commands/docs.md +0 -21
  237. package/templates/.claude/commands/doctor.md +0 -21
  238. package/templates/.claude/commands/enable-agent.md +0 -12
  239. package/templates/.claude/commands/execute-plan.md +0 -25
  240. package/templates/.claude/commands/explore-codebase.md +0 -12
  241. package/templates/.claude/commands/export-pdf.md +0 -30
  242. package/templates/.claude/commands/feature.md +0 -25
  243. package/templates/.claude/commands/fix-issue.md +0 -12
  244. package/templates/.claude/commands/fix.md.template +0 -32
  245. package/templates/.claude/commands/health.md +0 -58
  246. package/templates/.claude/commands/help.md +0 -36
  247. package/templates/.claude/commands/learn.md +0 -48
  248. package/templates/.claude/commands/onboarding.md +0 -21
  249. package/templates/.claude/commands/plan.md +0 -20
  250. package/templates/.claude/commands/quality.md.template +0 -65
  251. package/templates/.claude/commands/session-end.md +0 -40
  252. package/templates/.claude/commands/session-start.md +0 -30
  253. package/templates/.claude/commands/setup-hooks.md +0 -18
  254. package/templates/.claude/commands/setup-pr-review.md +0 -72
  255. package/templates/.claude/commands/stealth-mode.md +0 -17
  256. package/templates/.claude/commands/test-gaps.md +0 -49
  257. package/templates/.claude/commands/test.md.template +0 -40
  258. package/templates/.claude/commands/vulnerabilities.md +0 -49
  259. package/templates/.claude/skills/build/SKILL.md.template +0 -98
  260. package/templates/.claude/skills/deploy/SKILL.md.template +0 -131
  261. package/templates/.claude/skills/deploy/references/gotchas.md +0 -5
  262. package/templates/.claude/skills/doctor/SKILL.md +0 -54
  263. package/templates/.claude/skills/gcloud/SKILL.md +0 -66
  264. package/templates/.claude/skills/gcloud/references/gotchas.md +0 -5
  265. package/templates/.claude/skills/learned/SKILL.md +0 -55
  266. package/templates/.claude/skills/learned/references/conventions.md +0 -11
  267. package/templates/.claude/skills/learned/references/deny-recommendations.md +0 -18
  268. package/templates/.claude/skills/learned/references/gotchas.md +0 -11
  269. package/templates/.claude/skills/pulumi/SKILL.md +0 -73
  270. package/templates/.claude/skills/quality/SKILL.md.template +0 -108
  271. package/templates/.claude/skills/quality/references/gotchas.md +0 -5
  272. package/templates/.claude/skills/review/SKILL.md.template +0 -73
  273. package/templates/.claude/skills/scaffold/SKILL.md.template +0 -123
  274. package/templates/.claude/skills/secrets/SKILL.md +0 -52
  275. package/templates/.claude/skills/session/SKILL.md +0 -43
  276. package/templates/.claude/skills/test/SKILL.md.template +0 -122
  277. package/templates/.claude/skills/test/references/gotchas.md +0 -5
  278. package/templates/.devcontainer/Dockerfile.dev.template +0 -89
  279. package/templates/.devcontainer/devcontainer.json.template +0 -184
  280. package/templates/.devcontainer/docker-compose.yml.template +0 -105
  281. package/templates/.devcontainer/init-scripts/01-init.sql.template +0 -12
  282. package/templates/.devcontainer/post-create.sh.template +0 -298
  283. package/templates/.github/workflows/ci.yml.template +0 -399
  284. package/templates/.github/workflows/quality.yml.template +0 -376
  285. package/templates/.pre-commit-config.yaml.template +0 -106
  286. package/templates/.project/config/edit_config.py +0 -275
  287. package/templates/.project/config/project_config.py +0 -894
  288. package/templates/.project/scripts/codegen/generate-all.sh +0 -20
  289. package/templates/.project/scripts/codegen/validate-all.sh +0 -17
  290. package/templates/.project/scripts/docs/generate-all.sh +0 -30
  291. package/templates/.project/scripts/docs/serve.sh +0 -20
  292. package/templates/.project/scripts/quality/fix-all.sh +0 -138
  293. package/templates/.project/scripts/quality/lint-go.sh +0 -34
  294. package/templates/.project/scripts/quality/lint-python.sh +0 -54
  295. package/templates/.project/scripts/quality/run-all.sh +0 -497
  296. package/templates/.project/scripts/session/commit.sh +0 -70
  297. package/templates/.project/scripts/session/create-pr.sh +0 -165
  298. package/templates/.project/scripts/session/end.sh +0 -207
  299. package/templates/.project/scripts/session/start.sh +0 -233
  300. package/templates/.project/scripts/setup/doctor.sh +0 -404
  301. package/templates/.project/scripts/setup/interactive-setup.sh +0 -585
  302. package/templates/.project/scripts/sync/sync-template.sh +0 -328
  303. package/templates/.project/scripts/test/run-all.sh +0 -179
  304. package/templates/.project/scripts/test/run-quick.sh +0 -25
  305. package/templates/Makefile +0 -514
  306. package/templates/config/versions.yaml +0 -57
  307. package/templates/configs/go/.golangci.yml.template +0 -172
  308. package/templates/configs/go/go.mod.template +0 -15
  309. package/templates/configs/java/README.md +0 -6
  310. package/templates/configs/kotlin/README.md +0 -6
  311. package/templates/configs/node/package.json.template +0 -67
  312. package/templates/configs/node/tsconfig.json.template +0 -53
  313. package/templates/configs/python/pyproject.toml.template +0 -92
  314. package/templates/configs/python/pytest.ini.template +0 -64
  315. package/templates/configs/python/ruff.toml.template +0 -79
  316. package/templates/configs/ruby/README.md +0 -6
  317. package/templates/configs/rust/Cargo.toml.template +0 -51
  318. package/templates/configs/shared/.editorconfig +0 -67
  319. package/templates/scripts/validate-templates.sh +0 -449
@@ -1,688 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.scanCodebase = scanCodebase;
37
- exports.renderCodebaseSkill = renderCodebaseSkill;
38
- exports.renderArchitectureRef = renderArchitectureRef;
39
- const fs = __importStar(require("fs"));
40
- const path = __importStar(require("path"));
41
- const IGNORE_DIRS = new Set([
42
- 'node_modules',
43
- 'vendor',
44
- '.venv',
45
- 'venv',
46
- 'target',
47
- 'bin',
48
- 'obj',
49
- '.git',
50
- '.next',
51
- '__pycache__',
52
- 'dist',
53
- 'build',
54
- '.tox',
55
- '.eggs',
56
- 'htmlcov',
57
- 'coverage',
58
- '.mypy_cache',
59
- '.pytest_cache',
60
- '.ruff_cache',
61
- ]);
62
- const BINARY_EXTENSIONS = new Set([
63
- '.png',
64
- '.jpg',
65
- '.jpeg',
66
- '.gif',
67
- '.ico',
68
- '.webp',
69
- '.svg',
70
- '.woff',
71
- '.woff2',
72
- '.ttf',
73
- '.eot',
74
- '.pdf',
75
- '.zip',
76
- '.tar',
77
- '.gz',
78
- '.br',
79
- '.exe',
80
- '.dll',
81
- '.so',
82
- '.dylib',
83
- '.lock',
84
- '.sum',
85
- ]);
86
- const MAX_FILE_SIZE = 100 * 1024; // 100KB
87
- // --- File Walking ---
88
- function walkFiles(cwd, callback, maxDepth = 5) {
89
- function walk(dir, depth) {
90
- if (depth > maxDepth)
91
- return;
92
- let entries;
93
- try {
94
- entries = fs.readdirSync(dir, { withFileTypes: true });
95
- }
96
- catch {
97
- return;
98
- }
99
- for (const entry of entries) {
100
- if (entry.name.startsWith('.') && entry.name !== '.env.example')
101
- continue;
102
- const full = path.join(dir, entry.name);
103
- const rel = path.relative(cwd, full);
104
- if (entry.isDirectory()) {
105
- if (!IGNORE_DIRS.has(entry.name))
106
- walk(full, depth + 1);
107
- }
108
- else if (entry.isFile()) {
109
- const ext = path.extname(entry.name).toLowerCase();
110
- if (BINARY_EXTENSIONS.has(ext))
111
- continue;
112
- try {
113
- const stat = fs.statSync(full);
114
- if (stat.size > MAX_FILE_SIZE)
115
- continue;
116
- const content = fs.readFileSync(full, 'utf-8');
117
- callback(rel, content);
118
- }
119
- catch {
120
- /* skip unreadable */
121
- }
122
- }
123
- }
124
- }
125
- walk(cwd, 0);
126
- }
127
- // --- Entry Points ---
128
- const ENTRY_POINT_FILES = {
129
- 'main.go': 'Go entry point',
130
- 'app.py': 'Python application',
131
- 'main.py': 'Python entry point',
132
- 'manage.py': 'Django management',
133
- 'index.ts': 'Node.js entry (TypeScript)',
134
- 'index.js': 'Node.js entry',
135
- 'server.ts': 'Node.js server (TypeScript)',
136
- 'server.js': 'Node.js server',
137
- 'Program.cs': 'C# entry point',
138
- 'Startup.cs': 'C# ASP.NET startup',
139
- 'main.rs': 'Rust entry point',
140
- };
141
- function findEntryPoints(cwd) {
142
- const results = [];
143
- const seen = new Set();
144
- walkFiles(cwd, (rel, content) => {
145
- const basename = path.basename(rel);
146
- // Known entry point filenames
147
- if (ENTRY_POINT_FILES[basename] && !seen.has(rel)) {
148
- results.push({ file: rel, type: ENTRY_POINT_FILES[basename] });
149
- seen.add(rel);
150
- }
151
- // Python __main__ pattern
152
- if (basename.endsWith('.py') &&
153
- content.includes('__name__') &&
154
- content.includes('__main__') &&
155
- !seen.has(rel)) {
156
- results.push({ file: rel, type: 'Python __main__ entry' });
157
- seen.add(rel);
158
- }
159
- // Go func main pattern (for non-main.go files)
160
- if (basename.endsWith('.go') &&
161
- /^func\s+main\s*\(/m.test(content) &&
162
- basename !== 'main.go' &&
163
- !seen.has(rel)) {
164
- results.push({ file: rel, type: 'Go main function' });
165
- seen.add(rel);
166
- }
167
- }, 3); // shallow depth for entry points
168
- // Check package.json main field
169
- const pkgPath = path.join(cwd, 'package.json');
170
- if (fs.existsSync(pkgPath)) {
171
- try {
172
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
173
- if (pkg.main && !seen.has(pkg.main)) {
174
- results.push({ file: pkg.main, type: 'package.json main' });
175
- }
176
- }
177
- catch {
178
- /* ignore */
179
- }
180
- }
181
- return results;
182
- }
183
- // --- API Routes ---
184
- const ROUTE_PATTERNS = [
185
- // Python FastAPI/Flask decorators
186
- {
187
- ext: /\.py$/,
188
- regex: /@(?:app|router)\.(get|post|put|delete|patch)\s*\(\s*['"]([^'"]+)/gi,
189
- methodGroup: 1,
190
- pathGroup: 2,
191
- },
192
- // Python Flask @app.route
193
- {
194
- ext: /\.py$/,
195
- regex: /@(?:app|blueprint)\.route\s*\(\s*['"]([^'"]+)['"]/gi,
196
- methodGroup: -1,
197
- pathGroup: 1,
198
- },
199
- // Express/Node — only match when path starts with /
200
- {
201
- ext: /\.[tj]sx?$/,
202
- regex: /(?:app|router|this\.app)\.(get|post|put|delete|patch|all)\s*\(\s*['"](\/.+?)['"]/gi,
203
- methodGroup: 1,
204
- pathGroup: 2,
205
- },
206
- // LoopBack decorators — @get('/path'), @post('/path'), etc.
207
- {
208
- ext: /\.[tj]sx?$/,
209
- regex: /@(get|post|put|del|patch)\s*\(\s*['"]([^'"]+)/gi,
210
- methodGroup: 1,
211
- pathGroup: 2,
212
- },
213
- // Go standard library and popular routers
214
- { ext: /\.go$/, regex: /(?:HandleFunc|Handle)\s*\(\s*"([^"]+)"/g, methodGroup: -1, pathGroup: 1 },
215
- // Go Gin/Echo/Fiber
216
- {
217
- ext: /\.go$/,
218
- regex: /\.(GET|POST|PUT|DELETE|PATCH)\s*\(\s*"([^"]+)"/gi,
219
- methodGroup: 1,
220
- pathGroup: 2,
221
- },
222
- // C# attributes
223
- {
224
- ext: /\.cs$/,
225
- regex: /\[Http(Get|Post|Put|Delete|Patch)(?:\s*\("([^"]*)"\))?\]/g,
226
- methodGroup: 1,
227
- pathGroup: 2,
228
- },
229
- // C# minimal API
230
- {
231
- ext: /\.cs$/,
232
- regex: /app\.Map(Get|Post|Put|Delete|Patch)\s*\(\s*"([^"]+)"/gi,
233
- methodGroup: 1,
234
- pathGroup: 2,
235
- },
236
- ];
237
- function isSourceFile(rel) {
238
- // Exclude test files, docs, and generated files from API route detection
239
- const lower = rel.toLowerCase();
240
- if (lower.endsWith('_test.go') || lower.includes('test_') || lower.includes('/tests/'))
241
- return false;
242
- if (lower.endsWith('.test.ts') ||
243
- lower.endsWith('.test.js') ||
244
- lower.endsWith('.spec.ts') ||
245
- lower.endsWith('.spec.js'))
246
- return false;
247
- if (lower.includes('/docs/') || lower.includes('/documentation/'))
248
- return false;
249
- if (lower.endsWith('.md') ||
250
- lower.endsWith('.mdx') ||
251
- lower.endsWith('.txt') ||
252
- lower.endsWith('.rst'))
253
- return false;
254
- if (lower.includes('example') || lower.includes('sample') || lower.includes('fixture'))
255
- return false;
256
- return true;
257
- }
258
- function findApiRoutes(cwd) {
259
- const results = [];
260
- walkFiles(cwd, (rel, content) => {
261
- if (!isSourceFile(rel))
262
- return;
263
- for (const pattern of ROUTE_PATTERNS) {
264
- if (!pattern.ext.test(rel))
265
- continue;
266
- const regex = new RegExp(pattern.regex.source, pattern.regex.flags);
267
- let match;
268
- while ((match = regex.exec(content)) !== null) {
269
- const method = pattern.methodGroup === -1 ? 'ANY' : (match[pattern.methodGroup] || 'GET').toUpperCase();
270
- const routePath = match[pattern.pathGroup] || '/';
271
- results.push({ method, path: routePath, file: rel });
272
- }
273
- }
274
- // Next.js API routes (file-based)
275
- if (rel.includes('app/api/') || rel.includes('pages/api/')) {
276
- const routePath = '/' +
277
- rel
278
- .replace(/^.*(?:app|pages)\//, '')
279
- .replace(/\/route\.[tj]sx?$/, '')
280
- .replace(/\/index\.[tj]sx?$/, '')
281
- .replace(/\.[tj]sx?$/, '');
282
- results.push({ method: 'ANY', path: routePath, file: rel });
283
- }
284
- });
285
- return results.slice(0, 50); // cap at 50 to avoid bloat
286
- }
287
- // --- Directory Classification ---
288
- const DIR_PURPOSES = {
289
- src: 'Source code',
290
- lib: 'Library code',
291
- pkg: 'Packages',
292
- internal: 'Internal packages (Go)',
293
- cmd: 'CLI commands (Go)',
294
- tests: 'Test files',
295
- test: 'Test files',
296
- __tests__: 'Test files (Jest)',
297
- spec: 'Test specifications',
298
- docs: 'Documentation',
299
- documentation: 'Documentation',
300
- scripts: 'Utility scripts',
301
- tools: 'Development tools',
302
- config: 'Configuration',
303
- configs: 'Configuration',
304
- migrations: 'Database migrations',
305
- db: 'Database',
306
- api: 'API layer',
307
- routes: 'Route handlers',
308
- controllers: 'Controllers',
309
- handlers: 'Request handlers',
310
- models: 'Data models',
311
- services: 'Service layer',
312
- middleware: 'Middleware',
313
- components: 'UI components',
314
- pages: 'Page components',
315
- app: 'Application (Next.js App Router)',
316
- public: 'Static assets',
317
- static: 'Static files',
318
- assets: 'Assets',
319
- frontend: 'Frontend application',
320
- backend: 'Backend application',
321
- infra: 'Infrastructure code',
322
- deploy: 'Deployment configuration',
323
- '.github': 'GitHub workflows and config',
324
- };
325
- function classifyDirectories(cwd) {
326
- const results = [];
327
- try {
328
- for (const entry of fs.readdirSync(cwd, { withFileTypes: true })) {
329
- if (!entry.isDirectory())
330
- continue;
331
- if (entry.name.startsWith('.') && entry.name !== '.github')
332
- continue;
333
- if (IGNORE_DIRS.has(entry.name))
334
- continue;
335
- const purpose = DIR_PURPOSES[entry.name];
336
- if (purpose) {
337
- results.push({ path: entry.name + '/', purpose });
338
- }
339
- }
340
- // Check one level deep for common patterns (services/python/, src/api/, etc.)
341
- for (const dir of ['src', 'services', 'packages', 'apps']) {
342
- const subdir = path.join(cwd, dir);
343
- if (!fs.existsSync(subdir))
344
- continue;
345
- try {
346
- for (const sub of fs.readdirSync(subdir, { withFileTypes: true })) {
347
- if (!sub.isDirectory() || IGNORE_DIRS.has(sub.name))
348
- continue;
349
- const purpose = DIR_PURPOSES[sub.name];
350
- if (purpose) {
351
- results.push({ path: `${dir}/${sub.name}/`, purpose });
352
- }
353
- }
354
- }
355
- catch {
356
- /* skip */
357
- }
358
- }
359
- }
360
- catch {
361
- /* skip */
362
- }
363
- return results;
364
- }
365
- // --- Test Patterns ---
366
- function detectTestPatterns(cwd) {
367
- const results = [];
368
- // pytest
369
- if (fs.existsSync(path.join(cwd, 'pytest.ini')) || fs.existsSync(path.join(cwd, 'conftest.py'))) {
370
- results.push({ framework: 'pytest', location: 'tests/', pattern: 'test_*.py' });
371
- }
372
- else {
373
- try {
374
- const pyproject = fs.readFileSync(path.join(cwd, 'pyproject.toml'), 'utf-8');
375
- if (pyproject.includes('[tool.pytest')) {
376
- results.push({ framework: 'pytest', location: 'tests/', pattern: 'test_*.py' });
377
- }
378
- }
379
- catch {
380
- /* no pyproject */
381
- }
382
- }
383
- // go test
384
- let hasGoTests = false;
385
- walkFiles(cwd, (rel) => {
386
- if (rel.endsWith('_test.go'))
387
- hasGoTests = true;
388
- }, 2);
389
- if (hasGoTests) {
390
- results.push({ framework: 'go test', location: 'alongside source', pattern: '*_test.go' });
391
- }
392
- // Jest
393
- if (fs.existsSync(path.join(cwd, 'jest.config.js')) ||
394
- fs.existsSync(path.join(cwd, 'jest.config.ts'))) {
395
- results.push({
396
- framework: 'jest',
397
- location: '__tests__/ or *.test.ts',
398
- pattern: '*.test.{ts,tsx,js,jsx}',
399
- });
400
- }
401
- else {
402
- try {
403
- const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
404
- if (pkg.jest || pkg.devDependencies?.jest) {
405
- results.push({
406
- framework: 'jest',
407
- location: '__tests__/ or *.test.ts',
408
- pattern: '*.test.{ts,tsx,js,jsx}',
409
- });
410
- }
411
- }
412
- catch {
413
- /* no package.json */
414
- }
415
- }
416
- // xUnit / NUnit (C#)
417
- walkFiles(cwd, (rel, content) => {
418
- if (rel.endsWith('.csproj') &&
419
- (content.includes('xunit') || content.includes('nunit') || content.includes('MSTest'))) {
420
- const framework = content.includes('xunit')
421
- ? 'xUnit'
422
- : content.includes('nunit')
423
- ? 'NUnit'
424
- : 'MSTest';
425
- results.push({
426
- framework,
427
- location: '*.Tests projects',
428
- pattern: '*.cs with [Fact]/[Test]',
429
- });
430
- }
431
- }, 2);
432
- // cargo test
433
- if (fs.existsSync(path.join(cwd, 'Cargo.toml'))) {
434
- results.push({
435
- framework: 'cargo test',
436
- location: 'src/ (#[cfg(test)]) + tests/',
437
- pattern: '#[test] functions',
438
- });
439
- }
440
- return results;
441
- }
442
- // --- Config Files ---
443
- const CONFIG_FILES = {
444
- 'package.json': 'Node.js package manifest',
445
- 'pyproject.toml': 'Python project config',
446
- 'go.mod': 'Go module definition',
447
- 'Cargo.toml': 'Rust package manifest',
448
- Makefile: 'Build automation',
449
- 'docker-compose.yml': 'Docker services',
450
- 'docker-compose.yaml': 'Docker services',
451
- Dockerfile: 'Container build',
452
- '.env.example': 'Environment template',
453
- 'tsconfig.json': 'TypeScript config',
454
- '.eslintrc.js': 'ESLint config',
455
- '.eslintrc.json': 'ESLint config',
456
- 'ruff.toml': 'Python linter config',
457
- '.golangci.yml': 'Go linter config',
458
- 'pytest.ini': 'Python test config',
459
- '.pre-commit-config.yaml': 'Pre-commit hooks',
460
- '.editorconfig': 'Editor config',
461
- '.project.yaml': 'Project config (template)',
462
- 'Pulumi.yaml': 'Pulumi IaC config',
463
- 'appsettings.json': 'C# application config',
464
- 'global.json': '.NET SDK config',
465
- };
466
- function findConfigFiles(cwd) {
467
- const results = [];
468
- for (const [file, purpose] of Object.entries(CONFIG_FILES)) {
469
- if (fs.existsSync(path.join(cwd, file))) {
470
- results.push({ file, purpose });
471
- }
472
- }
473
- return results;
474
- }
475
- // --- Convention Detection ---
476
- function detectConventions(cwd) {
477
- const conventions = [];
478
- const fileNames = [];
479
- walkFiles(cwd, (rel) => {
480
- fileNames.push(path.basename(rel, path.extname(rel)));
481
- }, 2);
482
- // Naming convention
483
- const snakeCount = fileNames.filter((n) => n.includes('_') && !n.includes('-')).length;
484
- const kebabCount = fileNames.filter((n) => n.includes('-') && !n.includes('_')).length;
485
- const camelCount = fileNames.filter((n) => /^[a-z][a-zA-Z]+$/.test(n) && !n.includes('_') && !n.includes('-')).length;
486
- const pascalCount = fileNames.filter((n) => /^[A-Z][a-zA-Z]+$/.test(n)).length;
487
- const max = Math.max(snakeCount, kebabCount, camelCount, pascalCount);
488
- if (max > 5) {
489
- if (snakeCount === max)
490
- conventions.push({
491
- pattern: 'snake_case',
492
- description: 'File names use snake_case convention',
493
- });
494
- else if (kebabCount === max)
495
- conventions.push({
496
- pattern: 'kebab-case',
497
- description: 'File names use kebab-case convention',
498
- });
499
- else if (pascalCount === max)
500
- conventions.push({
501
- pattern: 'PascalCase',
502
- description: 'File names use PascalCase convention',
503
- });
504
- else if (camelCount === max)
505
- conventions.push({
506
- pattern: 'camelCase',
507
- description: 'File names use camelCase convention',
508
- });
509
- }
510
- // Test location
511
- if (fs.existsSync(path.join(cwd, 'tests')) || fs.existsSync(path.join(cwd, 'test'))) {
512
- conventions.push({
513
- pattern: 'Separate test directory',
514
- description: 'Tests in dedicated tests/ directory',
515
- });
516
- }
517
- return conventions;
518
- }
519
- // --- Main Scanner ---
520
- const TEST_FILE_PATTERNS = /(_test\.go$|\.test\.[tj]sx?$|\.spec\.[tj]sx?$|test_.*\.py$|Tests?\.cs$|_test\.rs$)/;
521
- const SOURCE_FILE_EXTENSIONS = /\.(ts|tsx|js|jsx|py|go|rs|cs|java)$/;
522
- function scanCodebase(cwd) {
523
- let fileCount = 0;
524
- let testFileCount = 0;
525
- let sourceFileCount = 0;
526
- const languageBreakdown = {};
527
- const EXT_TO_LANG = {
528
- '.ts': 'TypeScript',
529
- '.tsx': 'TypeScript',
530
- '.js': 'JavaScript',
531
- '.jsx': 'JavaScript',
532
- '.py': 'Python',
533
- '.go': 'Go',
534
- '.rs': 'Rust',
535
- '.cs': 'C#',
536
- '.java': 'Java',
537
- };
538
- walkFiles(cwd, (rel) => {
539
- fileCount++;
540
- if (TEST_FILE_PATTERNS.test(rel) ||
541
- rel.includes('__tests__/') ||
542
- rel.includes('/tests/') ||
543
- rel.includes('/test/')) {
544
- testFileCount++;
545
- }
546
- else if (SOURCE_FILE_EXTENSIONS.test(rel)) {
547
- sourceFileCount++;
548
- }
549
- const ext = path.extname(rel).toLowerCase();
550
- const lang = EXT_TO_LANG[ext];
551
- if (lang) {
552
- languageBreakdown[lang] = (languageBreakdown[lang] || 0) + 1;
553
- }
554
- }, 4);
555
- return {
556
- entryPoints: findEntryPoints(cwd),
557
- directories: classifyDirectories(cwd),
558
- testPatterns: detectTestPatterns(cwd),
559
- apiEndpoints: findApiRoutes(cwd),
560
- configFiles: findConfigFiles(cwd),
561
- conventions: detectConventions(cwd),
562
- fileCount,
563
- testFileCount,
564
- sourceFileCount,
565
- languageBreakdown,
566
- };
567
- }
568
- // --- Render Functions ---
569
- function renderCodebaseSkill(analysis) {
570
- const lines = [
571
- '---',
572
- 'name: codebase',
573
- 'description: Architecture overview and navigation guide for this project. Check before starting any task to understand structure, entry points, and conventions.',
574
- '---',
575
- '',
576
- '# Codebase Overview',
577
- '',
578
- `Scanned ${analysis.fileCount} files.`,
579
- '',
580
- ];
581
- // Language breakdown
582
- const langs = Object.entries(analysis.languageBreakdown).sort((a, b) => b[1] - a[1]);
583
- if (langs.length > 0) {
584
- lines.push('## Languages', '');
585
- for (const [lang, count] of langs) {
586
- lines.push(`- **${lang}**: ${count} files`);
587
- }
588
- lines.push('');
589
- }
590
- if (analysis.entryPoints.length) {
591
- lines.push('## Entry Points', '');
592
- for (const ep of analysis.entryPoints) {
593
- lines.push(`- \`${ep.file}\` — ${ep.type}`);
594
- }
595
- lines.push('');
596
- }
597
- if (analysis.directories.length) {
598
- lines.push('## Key Directories', '');
599
- for (const dir of analysis.directories) {
600
- lines.push(`- \`${dir.path}\` — ${dir.purpose}`);
601
- }
602
- lines.push('');
603
- }
604
- if (analysis.apiEndpoints.length) {
605
- lines.push('## API Surface', '');
606
- for (const ep of analysis.apiEndpoints.slice(0, 30)) {
607
- lines.push(`- ${ep.method} ${ep.path} (\`${ep.file}\`)`);
608
- }
609
- if (analysis.apiEndpoints.length > 30) {
610
- lines.push(`- ... and ${analysis.apiEndpoints.length - 30} more (see references/architecture.md)`);
611
- }
612
- lines.push('');
613
- }
614
- // Test overview
615
- lines.push('## Testing', '');
616
- lines.push(`- **${analysis.testFileCount}** test files found across **${analysis.sourceFileCount}** source files`);
617
- if (analysis.testFileCount === 0) {
618
- lines.push('- **No tests found.** This project needs test infrastructure.');
619
- }
620
- else if (analysis.sourceFileCount > 50 &&
621
- analysis.testFileCount < analysis.sourceFileCount * 0.1) {
622
- lines.push('- **Minimal test presence.** Most code paths are likely untested.');
623
- }
624
- if (analysis.testPatterns.length) {
625
- for (const tp of analysis.testPatterns) {
626
- lines.push(`- **${tp.framework}** — ${tp.location} (${tp.pattern})`);
627
- }
628
- }
629
- lines.push('');
630
- if (analysis.configFiles.length) {
631
- lines.push('## Configuration', '');
632
- for (const cf of analysis.configFiles) {
633
- lines.push(`- \`${cf.file}\` — ${cf.purpose}`);
634
- }
635
- lines.push('');
636
- }
637
- if (analysis.conventions.length) {
638
- lines.push('## Detected Conventions', '');
639
- for (const c of analysis.conventions) {
640
- lines.push(`- **${c.pattern}** — ${c.description}`);
641
- }
642
- lines.push('');
643
- }
644
- lines.push('---', '', '*Generated by [VyuhLabs DXKit](https://www.npmjs.com/package/@vyuhlabs/dxkit) codebase scanner*', '');
645
- return lines.join('\n');
646
- }
647
- function renderArchitectureRef(analysis) {
648
- const lines = [
649
- '# Architecture Reference',
650
- '',
651
- '<!-- Auto-generated by VyuhLabs DXKit codebase scanner. -->',
652
- '<!-- This file is evolving — your edits will be preserved across updates. -->',
653
- '<!-- Use `npx @vyuhlabs/dxkit update --rescan` to regenerate. -->',
654
- '',
655
- ];
656
- if (analysis.entryPoints.length) {
657
- lines.push('## Entry Points', '');
658
- for (const ep of analysis.entryPoints) {
659
- lines.push(`### \`${ep.file}\``, `- Type: ${ep.type}`, '');
660
- }
661
- }
662
- if (analysis.directories.length) {
663
- lines.push('## Directory Map', '');
664
- lines.push('```');
665
- for (const dir of analysis.directories) {
666
- lines.push(`${dir.path.padEnd(30)} # ${dir.purpose}`);
667
- }
668
- lines.push('```', '');
669
- }
670
- if (analysis.apiEndpoints.length) {
671
- lines.push('## API Endpoints', '');
672
- lines.push('| Method | Path | File |', '|--------|------|------|');
673
- for (const ep of analysis.apiEndpoints) {
674
- lines.push(`| ${ep.method} | ${ep.path} | \`${ep.file}\` |`);
675
- }
676
- lines.push('');
677
- }
678
- if (analysis.configFiles.length) {
679
- lines.push('## Config Inventory', '');
680
- for (const cf of analysis.configFiles) {
681
- lines.push(`- \`${cf.file}\` — ${cf.purpose}`);
682
- }
683
- lines.push('');
684
- }
685
- lines.push('---', '', '*Generated by [VyuhLabs DXKit](https://www.npmjs.com/package/@vyuhlabs/dxkit) codebase scanner*', '');
686
- return lines.join('\n');
687
- }
688
- //# sourceMappingURL=codebase-scanner.js.map