pi-lens 3.6.2 โ†’ 3.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/package.json +4 -4
  3. package/tsconfig.json +1 -1
  4. package/clients/__tests__/file-time.test.js +0 -216
  5. package/clients/__tests__/file-time.test.ts +0 -276
  6. package/clients/__tests__/format-service.test.js +0 -245
  7. package/clients/__tests__/format-service.test.ts +0 -339
  8. package/clients/__tests__/formatters.test.js +0 -271
  9. package/clients/__tests__/formatters.test.ts +0 -401
  10. package/clients/agent-behavior-client.js +0 -110
  11. package/clients/agent-behavior-client.test.js +0 -94
  12. package/clients/agent-behavior-client.test.ts +0 -116
  13. package/clients/amain-types.js +0 -164
  14. package/clients/architect-client.js +0 -291
  15. package/clients/ast-grep-client.js +0 -253
  16. package/clients/ast-grep-parser.js +0 -84
  17. package/clients/ast-grep-rule-manager.js +0 -89
  18. package/clients/ast-grep-types.js +0 -9
  19. package/clients/auto-loop.js +0 -131
  20. package/clients/biome-client.js +0 -420
  21. package/clients/biome-client.test.js +0 -144
  22. package/clients/biome-client.test.ts +0 -163
  23. package/clients/cache/rule-cache.js +0 -72
  24. package/clients/cache-manager.js +0 -245
  25. package/clients/cache-manager.test.js +0 -197
  26. package/clients/cache-manager.test.ts +0 -299
  27. package/clients/complexity-client.js +0 -675
  28. package/clients/complexity-client.test.js +0 -234
  29. package/clients/complexity-client.test.ts +0 -255
  30. package/clients/config-validator.js +0 -465
  31. package/clients/dependency-checker.js +0 -325
  32. package/clients/dependency-checker.test.js +0 -60
  33. package/clients/dependency-checker.test.ts +0 -71
  34. package/clients/dispatch/__tests__/autofix-integration.test.js +0 -245
  35. package/clients/dispatch/__tests__/autofix-integration.test.ts +0 -300
  36. package/clients/dispatch/__tests__/runner-registration.test.js +0 -234
  37. package/clients/dispatch/__tests__/runner-registration.test.ts +0 -286
  38. package/clients/dispatch/debug.log +0 -1
  39. package/clients/dispatch/dispatcher.edge.test.js +0 -82
  40. package/clients/dispatch/dispatcher.edge.test.ts +0 -100
  41. package/clients/dispatch/dispatcher.format.test.js +0 -46
  42. package/clients/dispatch/dispatcher.format.test.ts +0 -58
  43. package/clients/dispatch/dispatcher.inline.test.js +0 -74
  44. package/clients/dispatch/dispatcher.inline.test.ts +0 -93
  45. package/clients/dispatch/dispatcher.js +0 -381
  46. package/clients/dispatch/dispatcher.test.js +0 -116
  47. package/clients/dispatch/dispatcher.test.ts +0 -149
  48. package/clients/dispatch/integration.js +0 -108
  49. package/clients/dispatch/plan.js +0 -183
  50. package/clients/dispatch/runners/architect.js +0 -83
  51. package/clients/dispatch/runners/architect.test.js +0 -138
  52. package/clients/dispatch/runners/architect.test.ts +0 -162
  53. package/clients/dispatch/runners/ast-grep-napi.js +0 -405
  54. package/clients/dispatch/runners/ast-grep-napi.test.js +0 -107
  55. package/clients/dispatch/runners/ast-grep-napi.test.ts +0 -129
  56. package/clients/dispatch/runners/ast-grep.js +0 -157
  57. package/clients/dispatch/runners/biome.js +0 -55
  58. package/clients/dispatch/runners/config-validation.js +0 -67
  59. package/clients/dispatch/runners/go-vet.js +0 -48
  60. package/clients/dispatch/runners/index.js +0 -47
  61. package/clients/dispatch/runners/lsp.js +0 -102
  62. package/clients/dispatch/runners/oxlint.js +0 -67
  63. package/clients/dispatch/runners/oxlint.test.js +0 -230
  64. package/clients/dispatch/runners/oxlint.test.ts +0 -303
  65. package/clients/dispatch/runners/pyright.js +0 -100
  66. package/clients/dispatch/runners/pyright.test.js +0 -98
  67. package/clients/dispatch/runners/pyright.test.ts +0 -121
  68. package/clients/dispatch/runners/python-slop.js +0 -97
  69. package/clients/dispatch/runners/python-slop.test.js +0 -203
  70. package/clients/dispatch/runners/python-slop.test.ts +0 -298
  71. package/clients/dispatch/runners/ruff.js +0 -48
  72. package/clients/dispatch/runners/rust-clippy.js +0 -102
  73. package/clients/dispatch/runners/scan_codebase.test.js +0 -89
  74. package/clients/dispatch/runners/scan_codebase.test.ts +0 -105
  75. package/clients/dispatch/runners/shellcheck.js +0 -147
  76. package/clients/dispatch/runners/shellcheck.test.js +0 -98
  77. package/clients/dispatch/runners/shellcheck.test.ts +0 -129
  78. package/clients/dispatch/runners/similarity.js +0 -230
  79. package/clients/dispatch/runners/spellcheck.js +0 -106
  80. package/clients/dispatch/runners/spellcheck.test.js +0 -158
  81. package/clients/dispatch/runners/spellcheck.test.ts +0 -214
  82. package/clients/dispatch/runners/tree-sitter.js +0 -246
  83. package/clients/dispatch/runners/ts-lsp.js +0 -125
  84. package/clients/dispatch/runners/ts-slop.js +0 -113
  85. package/clients/dispatch/runners/type-safety.js +0 -142
  86. package/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -134
  87. package/clients/dispatch/runners/utils/runner-helpers.js +0 -115
  88. package/clients/dispatch/runners/utils.js +0 -51
  89. package/clients/dispatch/runners/yaml-rule-parser.js +0 -360
  90. package/clients/dispatch/types.js +0 -16
  91. package/clients/dispatch/utils/format-utils.js +0 -44
  92. package/clients/dogfood.test.js +0 -201
  93. package/clients/dogfood.test.ts +0 -269
  94. package/clients/file-kinds.js +0 -177
  95. package/clients/file-kinds.test.js +0 -169
  96. package/clients/file-kinds.test.ts +0 -210
  97. package/clients/file-time.js +0 -152
  98. package/clients/file-utils.js +0 -40
  99. package/clients/fix-scanners.js +0 -204
  100. package/clients/format-service.js +0 -184
  101. package/clients/formatters.js +0 -488
  102. package/clients/go-client.js +0 -203
  103. package/clients/go-client.test.js +0 -127
  104. package/clients/go-client.test.ts +0 -143
  105. package/clients/installer/index.js +0 -403
  106. package/clients/interviewer-templates.js +0 -75
  107. package/clients/interviewer.js +0 -173
  108. package/clients/jscpd-client.js +0 -196
  109. package/clients/jscpd-client.test.js +0 -127
  110. package/clients/jscpd-client.test.ts +0 -145
  111. package/clients/knip-client.js +0 -239
  112. package/clients/knip-client.test.js +0 -112
  113. package/clients/knip-client.test.ts +0 -128
  114. package/clients/latency-logger.js +0 -40
  115. package/clients/lsp/__tests__/client.test.js +0 -310
  116. package/clients/lsp/__tests__/client.test.ts +0 -412
  117. package/clients/lsp/__tests__/config.test.js +0 -167
  118. package/clients/lsp/__tests__/config.test.ts +0 -217
  119. package/clients/lsp/__tests__/error-recovery.test.js +0 -213
  120. package/clients/lsp/__tests__/error-recovery.test.ts +0 -279
  121. package/clients/lsp/__tests__/integration.test.js +0 -127
  122. package/clients/lsp/__tests__/integration.test.ts +0 -160
  123. package/clients/lsp/__tests__/launch.test.js +0 -313
  124. package/clients/lsp/__tests__/launch.test.ts +0 -394
  125. package/clients/lsp/__tests__/server.test.js +0 -259
  126. package/clients/lsp/__tests__/server.test.ts +0 -332
  127. package/clients/lsp/__tests__/service.test.js +0 -438
  128. package/clients/lsp/__tests__/service.test.ts +0 -530
  129. package/clients/lsp/client.js +0 -350
  130. package/clients/lsp/config.js +0 -112
  131. package/clients/lsp/index.js +0 -318
  132. package/clients/lsp/installer/index.js +0 -391
  133. package/clients/lsp/interactive-install.js +0 -221
  134. package/clients/lsp/language.js +0 -170
  135. package/clients/lsp/launch.js +0 -329
  136. package/clients/lsp/lsp/launch.js +0 -116
  137. package/clients/lsp/lsp/server.js +0 -532
  138. package/clients/lsp/lsp-index.js +0 -10
  139. package/clients/lsp/path-utils.js +0 -5
  140. package/clients/lsp/server.js +0 -725
  141. package/clients/lsp/test-py-spawn/requirements.txt +0 -1
  142. package/clients/lsp/test-py-spawn/test.py +0 -3
  143. package/clients/lsp/test-py-svc/requirements.txt +0 -1
  144. package/clients/lsp/test-py-svc/test.py +0 -3
  145. package/clients/lsp/test-python-project/requirements.txt +0 -1
  146. package/clients/lsp/test-python-project/test.py +0 -5
  147. package/clients/metrics-client.js +0 -107
  148. package/clients/metrics-client.test.js +0 -128
  149. package/clients/metrics-client.test.ts +0 -163
  150. package/clients/metrics-history.js +0 -367
  151. package/clients/path-utils.js +0 -142
  152. package/clients/pipeline.js +0 -272
  153. package/clients/production-readiness.js +0 -522
  154. package/clients/project-index.js +0 -255
  155. package/clients/project-metadata.js +0 -531
  156. package/clients/ruff-client.js +0 -325
  157. package/clients/ruff-client.test.js +0 -132
  158. package/clients/ruff-client.test.ts +0 -153
  159. package/clients/rules-scanner.js +0 -97
  160. package/clients/runner-tracker.js +0 -152
  161. package/clients/rust-client.js +0 -205
  162. package/clients/rust-client.test.js +0 -108
  163. package/clients/rust-client.test.ts +0 -130
  164. package/clients/safe-spawn-async.js +0 -163
  165. package/clients/safe-spawn.js +0 -241
  166. package/clients/sanitize.js +0 -291
  167. package/clients/sanitize.test.js +0 -177
  168. package/clients/sanitize.test.ts +0 -223
  169. package/clients/scan-architectural-debt.js +0 -167
  170. package/clients/scan-utils.js +0 -83
  171. package/clients/secrets-scanner.js +0 -119
  172. package/clients/secrets-scanner.test.js +0 -100
  173. package/clients/secrets-scanner.test.ts +0 -113
  174. package/clients/sg-runner.js +0 -292
  175. package/clients/state-matrix.js +0 -160
  176. package/clients/subprocess-client.js +0 -65
  177. package/clients/symbol-types.js +0 -5
  178. package/clients/test-runner-client.js +0 -523
  179. package/clients/test-runner-client.test.js +0 -192
  180. package/clients/test-runner-client.test.ts +0 -253
  181. package/clients/test-utils.js +0 -27
  182. package/clients/test-utils.ts +0 -36
  183. package/clients/todo-scanner.js +0 -200
  184. package/clients/todo-scanner.test.js +0 -301
  185. package/clients/todo-scanner.test.ts +0 -352
  186. package/clients/tool-availability.js +0 -207
  187. package/clients/tree-sitter-client.js +0 -601
  188. package/clients/tree-sitter-query-loader.js +0 -355
  189. package/clients/tree-sitter-symbol-extractor.js +0 -289
  190. package/clients/ts-service.js +0 -129
  191. package/clients/type-coverage-client.js +0 -127
  192. package/clients/type-coverage-client.test.js +0 -105
  193. package/clients/type-coverage-client.test.ts +0 -125
  194. package/clients/type-safety-client.js +0 -138
  195. package/clients/types.js +0 -11
  196. package/clients/typescript-client.codefix.test.js +0 -157
  197. package/clients/typescript-client.codefix.test.ts +0 -186
  198. package/clients/typescript-client.js +0 -509
  199. package/clients/typescript-client.test.js +0 -105
  200. package/clients/typescript-client.test.ts +0 -126
  201. package/commands/booboo.js +0 -1007
  202. package/commands/fix-from-booboo.js +0 -398
  203. package/commands/fix-simplified.js +0 -618
  204. package/commands/rate.js +0 -281
  205. package/commands/rate.test.js +0 -119
  206. package/commands/rate.test.ts +0 -131
  207. package/commands/refactor.js +0 -130
@@ -1,531 +0,0 @@
1
- /**
2
- * Project Metadata Detection for pi-lens
3
- *
4
- * Extracts project configuration from common config files:
5
- * - package.json (Node.js/npm/pnpm/yarn/bun)
6
- * - pyproject.toml (Python)
7
- * - Cargo.toml (Rust)
8
- * - go.mod (Go)
9
- * - composer.json (PHP)
10
- * - Gemfile (Ruby)
11
- */
12
- import * as fs from "node:fs";
13
- import * as path from "node:path";
14
- // --- Detection Functions ---
15
- /**
16
- * Detect project metadata from a target directory.
17
- * Reads common config files and extracts structured information.
18
- */
19
- export function detectProjectMetadata(targetPath) {
20
- const metadata = {
21
- type: "unknown",
22
- scripts: {},
23
- languages: [],
24
- hasTests: false,
25
- hasLinting: false,
26
- hasFormatting: false,
27
- hasTypeScript: false,
28
- configFiles: [],
29
- };
30
- // Check for Node.js project
31
- const nodeMeta = detectNodeProject(targetPath);
32
- if (nodeMeta) {
33
- Object.assign(metadata, nodeMeta);
34
- }
35
- // Check for Python project
36
- const pythonMeta = detectPythonProject(targetPath);
37
- if (pythonMeta && metadata.type === "unknown") {
38
- Object.assign(metadata, pythonMeta);
39
- }
40
- // Check for Rust project
41
- const rustMeta = detectRustProject(targetPath);
42
- if (rustMeta && metadata.type === "unknown") {
43
- Object.assign(metadata, rustMeta);
44
- }
45
- // Check for Go project
46
- const goMeta = detectGoProject(targetPath);
47
- if (goMeta && metadata.type === "unknown") {
48
- Object.assign(metadata, goMeta);
49
- }
50
- // Check for PHP project
51
- const phpMeta = detectPhpProject(targetPath);
52
- if (phpMeta && metadata.type === "unknown") {
53
- Object.assign(metadata, phpMeta);
54
- }
55
- // Check for Ruby project
56
- const rubyMeta = detectRubyProject(targetPath);
57
- if (rubyMeta && metadata.type === "unknown") {
58
- Object.assign(metadata, rubyMeta);
59
- }
60
- // Multi-project detection: if multiple types found
61
- const types = [nodeMeta, pythonMeta, rustMeta, goMeta, phpMeta, rubyMeta]
62
- .filter(Boolean)
63
- .map(m => m.type);
64
- if (types.length > 1) {
65
- metadata.type = "multi";
66
- metadata.languages = [...new Set(types)];
67
- }
68
- return metadata;
69
- }
70
- /**
71
- * Detect Node.js project from package.json and lockfiles
72
- */
73
- function detectNodeProject(targetPath) {
74
- const packageJsonPath = path.join(targetPath, "package.json");
75
- if (!fs.existsSync(packageJsonPath)) {
76
- return null;
77
- }
78
- let packageJson;
79
- try {
80
- packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
81
- }
82
- catch {
83
- return null;
84
- }
85
- const metadata = {
86
- type: "node",
87
- name: typeof packageJson.name === "string" ? packageJson.name : undefined,
88
- version: typeof packageJson.version === "string" ? packageJson.version : undefined,
89
- packageManager: detectNodePackageManager(targetPath),
90
- scripts: typeof packageJson.scripts === "object" && packageJson.scripts !== null
91
- ? packageJson.scripts
92
- : {},
93
- languages: ["javascript"],
94
- hasTests: false,
95
- hasLinting: false,
96
- hasFormatting: false,
97
- hasTypeScript: fs.existsSync(path.join(targetPath, "tsconfig.json")),
98
- configFiles: ["package.json"],
99
- };
100
- // Detect TypeScript
101
- if (metadata.hasTypeScript) {
102
- metadata.languages.push("typescript");
103
- metadata.configFiles.push("tsconfig.json");
104
- }
105
- // Detect tests from scripts or config files
106
- const scripts = Object.keys(metadata.scripts).join(" ").toLowerCase();
107
- if (scripts.includes("test") || scripts.includes("spec")) {
108
- metadata.hasTests = true;
109
- }
110
- // Detect test frameworks from dependencies
111
- const allDeps = {
112
- ...(packageJson.dependencies || {}),
113
- ...(packageJson.devDependencies || {}),
114
- };
115
- if (allDeps["vitest"]) {
116
- metadata.hasTests = true;
117
- metadata.testFramework = "vitest";
118
- }
119
- else if (allDeps["jest"]) {
120
- metadata.hasTests = true;
121
- metadata.testFramework = "jest";
122
- }
123
- else if (allDeps["mocha"]) {
124
- metadata.hasTests = true;
125
- metadata.testFramework = "mocha";
126
- }
127
- else if (allDeps["ava"]) {
128
- metadata.hasTests = true;
129
- metadata.testFramework = "ava";
130
- }
131
- else if (allDeps["tap"]) {
132
- metadata.hasTests = true;
133
- metadata.testFramework = "tap";
134
- }
135
- else if (allDeps["node:test"]) {
136
- metadata.hasTests = true;
137
- metadata.testFramework = "node:test";
138
- }
139
- // Detect linting
140
- if (allDeps["eslint"] || fs.existsSync(path.join(targetPath, ".eslintrc")) ||
141
- fs.existsSync(path.join(targetPath, ".eslintrc.js")) ||
142
- fs.existsSync(path.join(targetPath, "eslint.config.js")) ||
143
- fs.existsSync(path.join(targetPath, "eslint.config.mjs"))) {
144
- metadata.hasLinting = true;
145
- metadata.linter = "eslint";
146
- metadata.configFiles.push("eslint config");
147
- }
148
- if (allDeps["@biomejs/biome"] || fs.existsSync(path.join(targetPath, "biome.json"))) {
149
- metadata.hasLinting = true;
150
- metadata.linter = metadata.linter ? `${metadata.linter}, biome` : "biome";
151
- metadata.configFiles.push("biome.json");
152
- }
153
- // Detect formatting
154
- if (allDeps["prettier"] || fs.existsSync(path.join(targetPath, ".prettierrc")) ||
155
- fs.existsSync(path.join(targetPath, ".prettierrc.json"))) {
156
- metadata.hasFormatting = true;
157
- metadata.formatter = metadata.formatter ? `${metadata.formatter}, prettier` : "prettier";
158
- metadata.configFiles.push("prettier config");
159
- }
160
- if (allDeps["@biomejs/biome"]) {
161
- metadata.hasFormatting = true;
162
- metadata.formatter = metadata.formatter ? `${metadata.formatter}, biome` : "biome";
163
- }
164
- return metadata;
165
- }
166
- /**
167
- * Detect Node.js package manager from lockfiles
168
- */
169
- function detectNodePackageManager(targetPath) {
170
- if (fs.existsSync(path.join(targetPath, "bun.lockb")) || fs.existsSync(path.join(targetPath, "bun.lock"))) {
171
- return "bun";
172
- }
173
- if (fs.existsSync(path.join(targetPath, "pnpm-lock.yaml"))) {
174
- return "pnpm";
175
- }
176
- if (fs.existsSync(path.join(targetPath, "yarn.lock"))) {
177
- return "yarn";
178
- }
179
- if (fs.existsSync(path.join(targetPath, "package-lock.json"))) {
180
- return "npm";
181
- }
182
- return undefined;
183
- }
184
- /**
185
- * Detect Python project from pyproject.toml, setup.py, requirements.txt
186
- */
187
- function detectPythonProject(targetPath) {
188
- const pyprojectPath = path.join(targetPath, "pyproject.toml");
189
- const setupPyPath = path.join(targetPath, "setup.py");
190
- const requirementsPath = path.join(targetPath, "requirements.txt");
191
- if (!fs.existsSync(pyprojectPath) && !fs.existsSync(setupPyPath) && !fs.existsSync(requirementsPath)) {
192
- return null;
193
- }
194
- const metadata = {
195
- type: "python",
196
- packageManager: detectPythonPackageManager(targetPath),
197
- scripts: {},
198
- languages: ["python"],
199
- hasTests: false,
200
- hasLinting: false,
201
- hasFormatting: false,
202
- hasTypeScript: false,
203
- configFiles: [],
204
- };
205
- // Read pyproject.toml if available
206
- if (fs.existsSync(pyprojectPath)) {
207
- metadata.configFiles.push("pyproject.toml");
208
- try {
209
- const content = fs.readFileSync(pyprojectPath, "utf-8");
210
- // Extract project name
211
- const nameMatch = content.match(/\[project\][\s\S]*?name\s*=\s*["']([^"']+)["']/);
212
- if (nameMatch)
213
- metadata.name = nameMatch[1];
214
- // Extract version
215
- const versionMatch = content.match(/\[project\][\s\S]*?version\s*=\s*["']([^"']+)["']/);
216
- if (versionMatch)
217
- metadata.version = versionMatch[1];
218
- // Detect test framework
219
- if (content.includes("pytest") || fs.existsSync(path.join(targetPath, "pytest.ini"))) {
220
- metadata.hasTests = true;
221
- metadata.testFramework = "pytest";
222
- }
223
- // Detect linting
224
- if (content.includes("ruff") || fs.existsSync(path.join(targetPath, "ruff.toml"))) {
225
- metadata.hasLinting = true;
226
- metadata.linter = "ruff";
227
- metadata.hasFormatting = true;
228
- metadata.formatter = "ruff";
229
- }
230
- else if (content.includes("pylint") || content.includes("flake8")) {
231
- metadata.hasLinting = true;
232
- metadata.linter = content.includes("pylint") ? "pylint" : "flake8";
233
- }
234
- }
235
- catch {
236
- // Ignore parse errors
237
- }
238
- }
239
- if (fs.existsSync(setupPyPath))
240
- metadata.configFiles.push("setup.py");
241
- if (fs.existsSync(requirementsPath))
242
- metadata.configFiles.push("requirements.txt");
243
- return metadata;
244
- }
245
- /**
246
- * Detect Python package manager
247
- */
248
- function detectPythonPackageManager(targetPath) {
249
- if (fs.existsSync(path.join(targetPath, "uv.lock"))) {
250
- return "uv";
251
- }
252
- if (fs.existsSync(path.join(targetPath, "poetry.lock"))) {
253
- return "poetry";
254
- }
255
- if (fs.existsSync(path.join(targetPath, "Pipfile.lock")) || fs.existsSync(path.join(targetPath, "Pipfile"))) {
256
- return "pip"; // pipenv uses Pipfile
257
- }
258
- if (fs.existsSync(path.join(targetPath, "requirements.txt"))) {
259
- return "pip";
260
- }
261
- return undefined;
262
- }
263
- /**
264
- * Detect Rust project from Cargo.toml
265
- */
266
- function detectRustProject(targetPath) {
267
- const cargoPath = path.join(targetPath, "Cargo.toml");
268
- if (!fs.existsSync(cargoPath)) {
269
- return null;
270
- }
271
- const metadata = {
272
- type: "rust",
273
- packageManager: "cargo",
274
- scripts: {},
275
- languages: ["rust"],
276
- hasTests: true, // Cargo has built-in test support
277
- hasLinting: false,
278
- hasFormatting: false,
279
- hasTypeScript: false,
280
- configFiles: ["Cargo.toml"],
281
- };
282
- // Read Cargo.toml
283
- try {
284
- const content = fs.readFileSync(cargoPath, "utf-8");
285
- // Extract package name
286
- const nameMatch = content.match(/\[package\][\s\S]*?name\s*=\s*["']([^"']+)["']/);
287
- if (nameMatch)
288
- metadata.name = nameMatch[1];
289
- // Extract version
290
- const versionMatch = content.match(/\[package\][\s\S]*?version\s*=\s*["']([^"']+)["']/);
291
- if (versionMatch)
292
- metadata.version = versionMatch[1];
293
- }
294
- catch {
295
- // Ignore parse errors
296
- }
297
- // Check for clippy (linter)
298
- if (fs.existsSync(path.join(targetPath, ".clippy.toml")) ||
299
- fs.existsSync(path.join(targetPath, "clippy.toml"))) {
300
- metadata.hasLinting = true;
301
- metadata.linter = "clippy";
302
- }
303
- // Check for rustfmt
304
- if (fs.existsSync(path.join(targetPath, ".rustfmt.toml")) ||
305
- fs.existsSync(path.join(targetPath, "rustfmt.toml"))) {
306
- metadata.hasFormatting = true;
307
- metadata.formatter = "rustfmt";
308
- }
309
- return metadata;
310
- }
311
- /**
312
- * Detect Go project from go.mod
313
- */
314
- function detectGoProject(targetPath) {
315
- const goModPath = path.join(targetPath, "go.mod");
316
- if (!fs.existsSync(goModPath)) {
317
- return null;
318
- }
319
- const metadata = {
320
- type: "go",
321
- packageManager: "gomod",
322
- scripts: {},
323
- languages: ["go"],
324
- hasTests: true, // Go has built-in test support
325
- hasLinting: false,
326
- hasFormatting: false,
327
- hasTypeScript: false,
328
- configFiles: ["go.mod"],
329
- };
330
- // Read go.mod
331
- try {
332
- const content = fs.readFileSync(goModPath, "utf-8");
333
- // Extract module name (first line: module example.com/module)
334
- const moduleMatch = content.match(/^module\s+(\S+)/m);
335
- if (moduleMatch)
336
- metadata.name = moduleMatch[1];
337
- // Extract go version
338
- const versionMatch = content.match(/^go\s+(\S+)/m);
339
- if (versionMatch)
340
- metadata.version = versionMatch[1];
341
- }
342
- catch {
343
- // Ignore parse errors
344
- }
345
- // Check for golangci-lint
346
- if (fs.existsSync(path.join(targetPath, ".golangci.yml")) ||
347
- fs.existsSync(path.join(targetPath, ".golangci.yaml"))) {
348
- metadata.hasLinting = true;
349
- metadata.linter = "golangci-lint";
350
- }
351
- return metadata;
352
- }
353
- /**
354
- * Detect PHP project from composer.json
355
- */
356
- function detectPhpProject(targetPath) {
357
- const composerPath = path.join(targetPath, "composer.json");
358
- if (!fs.existsSync(composerPath)) {
359
- return null;
360
- }
361
- let composerJson;
362
- try {
363
- composerJson = JSON.parse(fs.readFileSync(composerPath, "utf-8"));
364
- }
365
- catch {
366
- return null;
367
- }
368
- const metadata = {
369
- type: "php",
370
- packageManager: "composer",
371
- name: typeof composerJson.name === "string" ? composerJson.name : undefined,
372
- scripts: typeof composerJson.scripts === "object" && composerJson.scripts !== null
373
- ? composerJson.scripts
374
- : {},
375
- languages: ["php"],
376
- hasTests: false,
377
- hasLinting: false,
378
- hasFormatting: false,
379
- hasTypeScript: false,
380
- configFiles: ["composer.json"],
381
- };
382
- // Detect tests from scripts
383
- const scripts = Object.keys(metadata.scripts).join(" ").toLowerCase();
384
- if (scripts.includes("test") || scripts.includes("phpunit")) {
385
- metadata.hasTests = true;
386
- metadata.testFramework = "phpunit";
387
- }
388
- return metadata;
389
- }
390
- /**
391
- * Detect Ruby project from Gemfile
392
- */
393
- function detectRubyProject(targetPath) {
394
- const gemfilePath = path.join(targetPath, "Gemfile");
395
- const gemspecPath = fs.readdirSync(targetPath).find(f => f.endsWith(".gemspec"));
396
- if (!fs.existsSync(gemfilePath) && !gemspecPath) {
397
- return null;
398
- }
399
- const metadata = {
400
- type: "ruby",
401
- packageManager: "bundler",
402
- scripts: {},
403
- languages: ["ruby"],
404
- hasTests: false,
405
- hasLinting: false,
406
- hasFormatting: false,
407
- hasTypeScript: false,
408
- configFiles: [],
409
- };
410
- if (fs.existsSync(gemfilePath))
411
- metadata.configFiles.push("Gemfile");
412
- if (gemspecPath)
413
- metadata.configFiles.push(gemspecPath);
414
- // Check for Rakefile to get tasks
415
- const rakefilePath = path.join(targetPath, "Rakefile");
416
- if (fs.existsSync(rakefilePath)) {
417
- metadata.configFiles.push("Rakefile");
418
- }
419
- // Check for test framework
420
- if (fs.existsSync(path.join(targetPath, "spec"))) {
421
- metadata.hasTests = true;
422
- metadata.testFramework = "rspec";
423
- }
424
- else if (fs.existsSync(path.join(targetPath, "test"))) {
425
- metadata.hasTests = true;
426
- metadata.testFramework = "minitest";
427
- }
428
- // Check for rubocop
429
- if (fs.existsSync(path.join(targetPath, ".rubocop.yml"))) {
430
- metadata.hasLinting = true;
431
- metadata.linter = "rubocop";
432
- metadata.configFiles.push(".rubocop.yml");
433
- }
434
- return metadata;
435
- }
436
- // --- Formatting Utilities ---
437
- /**
438
- * Format project metadata for display in reports
439
- */
440
- export function formatProjectMetadata(metadata) {
441
- const lines = [];
442
- // Header
443
- const name = metadata.name ? `**${metadata.name}**` : "Project";
444
- const type = metadata.type !== "unknown" ? `(${capitalize(metadata.type)})` : "";
445
- lines.push(`๐Ÿ“Š ${name} ${type}`.trim());
446
- // Package manager
447
- if (metadata.packageManager) {
448
- lines.push(`๐Ÿ“ฆ Package Manager: ${capitalize(metadata.packageManager)}`);
449
- }
450
- // Languages
451
- if (metadata.languages.length > 0) {
452
- lines.push(`๐Ÿ“ Languages: ${metadata.languages.map(capitalize).join(", ")}`);
453
- }
454
- // Tools
455
- const tools = [];
456
- if (metadata.hasTests) {
457
- tools.push(metadata.testFramework ? `๐Ÿงช ${metadata.testFramework}` : "๐Ÿงช tests");
458
- }
459
- if (metadata.hasLinting) {
460
- tools.push(metadata.linter ? `๐Ÿ” ${metadata.linter}` : "๐Ÿ” linting");
461
- }
462
- if (metadata.hasFormatting) {
463
- tools.push(metadata.formatter ? `โœจ ${metadata.formatter}` : "โœจ formatting");
464
- }
465
- if (tools.length > 0) {
466
- lines.push(tools.join(" | "));
467
- }
468
- // Config files (limited)
469
- if (metadata.configFiles.length > 0) {
470
- const limited = metadata.configFiles.slice(0, 5);
471
- const more = metadata.configFiles.length > 5 ? ` (+${metadata.configFiles.length - 5} more)` : "";
472
- lines.push(`โš™๏ธ Config: ${limited.join(", ")}${more}`);
473
- }
474
- return lines.join("\n");
475
- }
476
- /**
477
- * Get available commands for a project (build, test, lint, etc.)
478
- */
479
- export function getAvailableCommands(metadata) {
480
- const commands = [];
481
- // Node.js projects - use npm scripts
482
- if (metadata.type === "node" && Object.keys(metadata.scripts).length > 0) {
483
- const scriptPriority = ["test", "build", "lint", "format", "dev", "start", "typecheck"];
484
- for (const priority of scriptPriority) {
485
- const matching = Object.entries(metadata.scripts).find(([name]) => name.toLowerCase().includes(priority));
486
- if (matching) {
487
- const runCmd = metadata.packageManager === "bun" ? "bun run" :
488
- metadata.packageManager === "pnpm" ? "pnpm" :
489
- metadata.packageManager === "yarn" ? "yarn" :
490
- "npm run";
491
- commands.push({
492
- action: priority,
493
- command: `${runCmd} ${matching[0]}`,
494
- });
495
- }
496
- }
497
- }
498
- // Python projects
499
- if (metadata.type === "python") {
500
- if (metadata.hasTests) {
501
- const testCmd = metadata.packageManager === "poetry" ? "poetry run pytest" :
502
- metadata.packageManager === "uv" ? "uv run pytest" :
503
- "pytest";
504
- commands.push({ action: "test", command: testCmd });
505
- }
506
- if (metadata.linter?.includes("ruff")) {
507
- commands.push({ action: "lint", command: "ruff check ." });
508
- commands.push({ action: "format", command: "ruff format ." });
509
- }
510
- }
511
- // Rust projects
512
- if (metadata.type === "rust") {
513
- commands.push({ action: "build", command: "cargo build" });
514
- commands.push({ action: "test", command: "cargo test" });
515
- if (metadata.hasLinting) {
516
- commands.push({ action: "lint", command: "cargo clippy" });
517
- }
518
- }
519
- // Go projects
520
- if (metadata.type === "go") {
521
- commands.push({ action: "build", command: "go build" });
522
- commands.push({ action: "test", command: "go test ./..." });
523
- if (metadata.hasLinting) {
524
- commands.push({ action: "lint", command: "golangci-lint run" });
525
- }
526
- }
527
- return commands;
528
- }
529
- function capitalize(str) {
530
- return str.charAt(0).toUpperCase() + str.slice(1);
531
- }