@lakindu_perera/toren 1.0.7 → 1.0.9

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 (61) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +120 -31
  3. package/dist/cli/toren.d.ts +24 -0
  4. package/dist/cli/toren.js +254 -0
  5. package/dist/cli/toren.js.map +1 -0
  6. package/dist/detectors/config-detector.d.ts +3 -0
  7. package/dist/detectors/config-detector.js +58 -0
  8. package/dist/detectors/config-detector.js.map +1 -0
  9. package/dist/detectors/health-detector.d.ts +12 -0
  10. package/dist/detectors/health-detector.js +53 -0
  11. package/dist/detectors/health-detector.js.map +1 -0
  12. package/dist/detectors/important-files-detector.d.ts +51 -0
  13. package/dist/detectors/important-files-detector.js +455 -0
  14. package/dist/detectors/important-files-detector.js.map +1 -0
  15. package/dist/detectors/package-manager-detector.d.ts +7 -0
  16. package/dist/detectors/package-manager-detector.js +35 -0
  17. package/dist/detectors/package-manager-detector.js.map +1 -0
  18. package/dist/detectors/project-info-detector.d.ts +13 -0
  19. package/dist/detectors/project-info-detector.js +97 -0
  20. package/dist/detectors/project-info-detector.js.map +1 -0
  21. package/dist/detectors/script-detector.d.ts +42 -0
  22. package/dist/detectors/script-detector.js +199 -0
  23. package/dist/detectors/script-detector.js.map +1 -0
  24. package/dist/focused-output.d.ts +27 -0
  25. package/dist/focused-output.js +201 -0
  26. package/dist/focused-output.js.map +1 -0
  27. package/dist/lifecycle.d.ts +2 -0
  28. package/dist/lifecycle.js +114 -0
  29. package/dist/lifecycle.js.map +1 -0
  30. package/dist/renderers/console-renderer.d.ts +19 -0
  31. package/dist/renderers/console-renderer.js +361 -0
  32. package/dist/renderers/console-renderer.js.map +1 -0
  33. package/dist/renderers/html-renderer.d.ts +14 -0
  34. package/{src → dist}/renderers/html-renderer.js +263 -201
  35. package/dist/renderers/html-renderer.js.map +1 -0
  36. package/dist/renderers/index.d.ts +6 -0
  37. package/dist/renderers/index.js +12 -0
  38. package/dist/renderers/index.js.map +1 -0
  39. package/dist/renderers/json-renderer.d.ts +10 -0
  40. package/dist/renderers/json-renderer.js +127 -0
  41. package/dist/renderers/json-renderer.js.map +1 -0
  42. package/dist/renderers/markdown-renderer.d.ts +13 -0
  43. package/dist/renderers/markdown-renderer.js +360 -0
  44. package/dist/renderers/markdown-renderer.js.map +1 -0
  45. package/dist/scanner/scan.d.ts +2 -0
  46. package/dist/scanner/scan.js +573 -0
  47. package/dist/scanner/scan.js.map +1 -0
  48. package/dist/types/index.d.ts +85 -0
  49. package/dist/types/index.js +2 -0
  50. package/dist/types/index.js.map +1 -0
  51. package/package.json +16 -7
  52. package/bin/toren.js +0 -308
  53. package/src/detectors/config-detector.js +0 -81
  54. package/src/detectors/script-detector.js +0 -32
  55. package/src/focused-output.js +0 -146
  56. package/src/lifecycle.js +0 -124
  57. package/src/renderers/console-renderer.js +0 -350
  58. package/src/renderers/index.js +0 -41
  59. package/src/renderers/json-renderer.js +0 -154
  60. package/src/renderers/markdown-renderer.js +0 -337
  61. package/src/scanner/scan.js +0 -532
@@ -0,0 +1,53 @@
1
+ export function detectHealth({ flatFiles, configs, importantFiles, scripts, projectType }) {
2
+ const health = [];
3
+ const fileSet = new Set(flatFiles);
4
+ // README
5
+ if (fileSet.has('README.md') || fileSet.has('README') || fileSet.has('readme.md')) {
6
+ health.push({ id: 'readme', status: 'pass', message: 'README found' });
7
+ }
8
+ else {
9
+ health.push({ id: 'readme', status: 'warning', message: 'README not found' });
10
+ }
11
+ // LICENSE
12
+ if (fileSet.has('LICENSE') || fileSet.has('LICENSE.md') || fileSet.has('LICENSE.txt')) {
13
+ health.push({ id: 'license', status: 'pass', message: 'LICENSE found' });
14
+ }
15
+ else {
16
+ health.push({ id: 'license', status: 'warning', message: 'LICENSE not found' });
17
+ }
18
+ // ENVIRONMENT EXAMPLE
19
+ if (fileSet.has('.env.example') || fileSet.has('.env.sample')) {
20
+ health.push({ id: 'env-example', status: 'pass', message: 'Environment example found' });
21
+ }
22
+ // TESTS
23
+ const hasTestFiles = flatFiles.some(f => f.startsWith('test/') ||
24
+ f.startsWith('tests/') ||
25
+ f.startsWith('__tests__/') ||
26
+ f.includes('.test.') ||
27
+ f.includes('.spec.'));
28
+ const hasTestScripts = (scripts || []).some(s => s.category === 'testing' || s.name === 'test');
29
+ if (hasTestFiles || hasTestScripts) {
30
+ health.push({ id: 'tests', status: 'pass', message: 'Tests detected' });
31
+ }
32
+ // LINTER
33
+ const hasLinter = (configs || []).some(c => c.includes('eslint') ||
34
+ c.includes('biome') ||
35
+ c.includes('stylelint')) || (scripts || []).some(s => s.category === 'quality' || s.name === 'lint');
36
+ if (hasLinter) {
37
+ health.push({ id: 'lint', status: 'pass', message: 'Linter detected' });
38
+ }
39
+ // TYPESCRIPT
40
+ if (fileSet.has('tsconfig.json')) {
41
+ health.push({ id: 'typescript', status: 'pass', message: 'TypeScript configuration found' });
42
+ }
43
+ // GIT
44
+ if (fileSet.has('.gitignore')) {
45
+ health.push({ id: 'git', status: 'info', message: '.gitignore found' });
46
+ }
47
+ // DOCKER
48
+ if (fileSet.has('Dockerfile') || fileSet.has('docker-compose.yml') || fileSet.has('compose.yml')) {
49
+ health.push({ id: 'docker', status: 'info', message: 'Docker configuration found' });
50
+ }
51
+ return { health };
52
+ }
53
+ //# sourceMappingURL=health-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health-detector.js","sourceRoot":"","sources":["../../src/detectors/health-detector.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,YAAY,CAAC,EAC3B,SAAS,EACT,OAAO,EACP,cAAc,EACd,OAAO,EACP,WAAW,EACS;IACpB,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAEnC,SAAS;IACT,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,O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O,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,SAAS;IACT,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QACjG,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @fileoverview Toren — Important File Detector
3
+ *
4
+ * Identifies the most strategically significant files in a project, based
5
+ * on the already-scanned flat file list and detected project context.
6
+ *
7
+ * Design contract:
8
+ * - Pure function. Uses only the data already produced by scan().
9
+ * - No filesystem I/O. No directory traversal.
10
+ * - Deterministic: same input always produces the same output.
11
+ * - No duplicates: each path appears at most once (highest priority wins).
12
+ * - Sorted: highest priority first; ties broken alphabetically by path.
13
+ * - Never returns null; importantFiles is always an array.
14
+ * - Framework-specific files are only marked important when they exist.
15
+ *
16
+ * Priority anchors:
17
+ * 100 – Project manifest (package.json, pom.xml, Cargo.toml, …)
18
+ * 95 – Primary documentation (README.md)
19
+ * 90 – Primary detected entry point
20
+ * 85 – Framework configuration (next.config.*, vite.config.*, …)
21
+ * 82 – App-level framework files (root layout, root page, …)
22
+ * 80 – Environment documentation (.env.example)
23
+ * 78 – Secondary framework files (middleware, server entry)
24
+ * 75 – TypeScript / language config
25
+ * 72 – Project-specific config (routes, config/application)
26
+ * 70 – Container (Dockerfile)
27
+ * 68 – Container orchestration (docker-compose)
28
+ *
29
+ * @module detectors/important-files-detector
30
+ */
31
+ /**
32
+ * Detect strategically important files in a scanned project.
33
+ *
34
+ * Uses only data already produced by scan() — no new filesystem operations.
35
+ *
36
+ * @param {Object} params
37
+ * @param {string[]} params.flatFiles - All relative POSIX file paths from the scanner
38
+ * @param {string} params.projectType - Detected project type (e.g. 'React', 'Go')
39
+ * @param {string[]} params.entryPoints - Detected entry point paths
40
+ * @param {string[]} params.configs - Detected configuration file paths
41
+ * @returns {{ importantFiles: ImportantFile[] }}
42
+ */
43
+ import type { ImportantFile } from "../types/index.js";
44
+ export declare function detectImportantFiles({ flatFiles, projectType, entryPoints, configs }: {
45
+ flatFiles: string[];
46
+ projectType: string;
47
+ entryPoints: string[];
48
+ configs: string[];
49
+ }): {
50
+ importantFiles: ImportantFile[];
51
+ };
@@ -0,0 +1,455 @@
1
+ /**
2
+ * @fileoverview Toren — Important File Detector
3
+ *
4
+ * Identifies the most strategically significant files in a project, based
5
+ * on the already-scanned flat file list and detected project context.
6
+ *
7
+ * Design contract:
8
+ * - Pure function. Uses only the data already produced by scan().
9
+ * - No filesystem I/O. No directory traversal.
10
+ * - Deterministic: same input always produces the same output.
11
+ * - No duplicates: each path appears at most once (highest priority wins).
12
+ * - Sorted: highest priority first; ties broken alphabetically by path.
13
+ * - Never returns null; importantFiles is always an array.
14
+ * - Framework-specific files are only marked important when they exist.
15
+ *
16
+ * Priority anchors:
17
+ * 100 – Project manifest (package.json, pom.xml, Cargo.toml, …)
18
+ * 95 – Primary documentation (README.md)
19
+ * 90 – Primary detected entry point
20
+ * 85 – Framework configuration (next.config.*, vite.config.*, …)
21
+ * 82 – App-level framework files (root layout, root page, …)
22
+ * 80 – Environment documentation (.env.example)
23
+ * 78 – Secondary framework files (middleware, server entry)
24
+ * 75 – TypeScript / language config
25
+ * 72 – Project-specific config (routes, config/application)
26
+ * 70 – Container (Dockerfile)
27
+ * 68 – Container orchestration (docker-compose)
28
+ *
29
+ * @module detectors/important-files-detector
30
+ */
31
+ // ---------------------------------------------------------------------------
32
+ // Types (JSDoc — no TypeScript dependency required)
33
+ // ---------------------------------------------------------------------------
34
+ /**
35
+ * @typedef {Object} ImportantFile
36
+ * @property {string} path - POSIX relative path from the project root
37
+ * @property {string} type - Semantic role: 'manifest' | 'documentation' |
38
+ * 'entry-point' | 'configuration' | 'environment' |
39
+ * 'container' | 'utility'
40
+ * @property {string} reason - Human-readable explanation of why this file matters
41
+ * @property {number} priority - Sort weight; higher = more important
42
+ */
43
+ // ---------------------------------------------------------------------------
44
+ // Static candidate tables — files important for every project type
45
+ // ---------------------------------------------------------------------------
46
+ /**
47
+ * Files that are generically important regardless of project type.
48
+ * Each entry is included only if the file actually exists in flatFiles.
49
+ *
50
+ * @type {ImportantFile[]}
51
+ */
52
+ const GENERIC_CANDIDATES = [
53
+ // ── Package manager manifests ─────────────────────────────────────────────
54
+ {
55
+ path: 'package.json',
56
+ type: 'manifest',
57
+ reason: 'Defines dependencies, scripts, and project metadata',
58
+ priority: 100,
59
+ },
60
+ // ── Primary documentation ─────────────────────────────────────────────────
61
+ {
62
+ path: 'README.md',
63
+ type: 'documentation',
64
+ reason: 'Primary project documentation',
65
+ priority: 95,
66
+ },
67
+ {
68
+ path: 'README',
69
+ type: 'documentation',
70
+ reason: 'Primary project documentation',
71
+ priority: 95,
72
+ },
73
+ // ── Environment documentation ─────────────────────────────────────────────
74
+ {
75
+ path: '.env.example',
76
+ type: 'environment',
77
+ reason: 'Documents required environment variables',
78
+ priority: 80,
79
+ },
80
+ {
81
+ path: '.env.sample',
82
+ type: 'environment',
83
+ reason: 'Documents required environment variables',
84
+ priority: 80,
85
+ },
86
+ // ── TypeScript ────────────────────────────────────────────────────────────
87
+ {
88
+ path: 'tsconfig.json',
89
+ type: 'configuration',
90
+ reason: 'TypeScript compiler configuration',
91
+ priority: 75,
92
+ },
93
+ // ── Container ─────────────────────────────────────────────────────────────
94
+ {
95
+ path: 'Dockerfile',
96
+ type: 'container',
97
+ reason: 'Container build configuration',
98
+ priority: 70,
99
+ },
100
+ {
101
+ path: 'docker-compose.yml',
102
+ type: 'container',
103
+ reason: 'Multi-container Docker configuration',
104
+ priority: 68,
105
+ },
106
+ {
107
+ path: 'docker-compose.yaml',
108
+ type: 'container',
109
+ reason: 'Multi-container Docker configuration',
110
+ priority: 68,
111
+ },
112
+ ];
113
+ /**
114
+ * Non-JS project manifests — same role as package.json for their ecosystems.
115
+ * Checked unconditionally because they might be present in polyglot repos.
116
+ *
117
+ * @type {ImportantFile[]}
118
+ */
119
+ const ECOSYSTEM_MANIFESTS = [
120
+ {
121
+ path: 'pom.xml',
122
+ type: 'manifest',
123
+ reason: 'Maven project descriptor and dependency manifest',
124
+ priority: 100,
125
+ },
126
+ {
127
+ path: 'build.gradle',
128
+ type: 'manifest',
129
+ reason: 'Gradle build script and dependency manifest',
130
+ priority: 100,
131
+ },
132
+ {
133
+ path: 'build.gradle.kts',
134
+ type: 'manifest',
135
+ reason: 'Gradle Kotlin DSL build script',
136
+ priority: 100,
137
+ },
138
+ {
139
+ path: 'Cargo.toml',
140
+ type: 'manifest',
141
+ reason: 'Rust package manifest and dependency configuration',
142
+ priority: 100,
143
+ },
144
+ {
145
+ path: 'composer.json',
146
+ type: 'manifest',
147
+ reason: 'PHP Composer dependency manifest',
148
+ priority: 100,
149
+ },
150
+ {
151
+ path: 'Gemfile',
152
+ type: 'manifest',
153
+ reason: 'Ruby gem dependency manifest',
154
+ priority: 100,
155
+ },
156
+ {
157
+ path: 'go.mod',
158
+ type: 'manifest',
159
+ reason: 'Go module definition and dependency manifest',
160
+ priority: 100,
161
+ },
162
+ {
163
+ path: 'pyproject.toml',
164
+ type: 'manifest',
165
+ reason: 'Python project configuration and dependency manifest',
166
+ priority: 100,
167
+ },
168
+ {
169
+ path: 'requirements.txt',
170
+ type: 'manifest',
171
+ reason: 'Python runtime dependency list',
172
+ priority: 95,
173
+ },
174
+ ];
175
+ // ---------------------------------------------------------------------------
176
+ // Pattern-matching helpers (no filesystem access — operate on flatFiles array)
177
+ // ---------------------------------------------------------------------------
178
+ /**
179
+ * Push a candidate entry if the exact path exists in the file set.
180
+ *
181
+ * @param {ImportantFile[]} out
182
+ * @param {Set<string>} fileSet
183
+ * @param {string} filePath
184
+ * @param {string} type
185
+ * @param {string} reason
186
+ * @param {number} priority
187
+ */
188
+ function addExact(out, fileSet, filePath, type, reason, priority) {
189
+ if (fileSet.has(filePath)) {
190
+ out.push({ path: filePath, type, reason, priority });
191
+ }
192
+ }
193
+ /**
194
+ * Push candidates for all files whose path starts with the given prefix.
195
+ * Used for patterns like 'vite.config.' (matches vite.config.js, .ts, .mjs …).
196
+ *
197
+ * @param {ImportantFile[]} out
198
+ * @param {string[]} flatFiles
199
+ * @param {string} prefix - e.g. 'vite.config.'
200
+ * @param {string} type
201
+ * @param {string} reason
202
+ * @param {number} priority
203
+ */
204
+ function addPrefix(out, flatFiles, prefix, type, reason, priority) {
205
+ for (const f of flatFiles) {
206
+ if (f.startsWith(prefix)) {
207
+ out.push({ path: f, type, reason, priority });
208
+ }
209
+ }
210
+ }
211
+ /**
212
+ * Push candidates for all files whose path ends with the given suffix.
213
+ * Used for patterns like '*Application.java' (matches any depth).
214
+ *
215
+ * @param {ImportantFile[]} out
216
+ * @param {string[]} flatFiles
217
+ * @param {string} suffix - e.g. 'Application.java'
218
+ * @param {string} type
219
+ * @param {string} reason
220
+ * @param {number} priority
221
+ */
222
+ function addSuffix(out, flatFiles, suffix, type, reason, priority) {
223
+ for (const f of flatFiles) {
224
+ if (f.endsWith(suffix)) {
225
+ out.push({ path: f, type, reason, priority });
226
+ }
227
+ }
228
+ }
229
+ /**
230
+ * Push candidates for root-level files matching `stem.*`.
231
+ * "Root-level" means the path contains no '/' after the stem.
232
+ * Used for patterns like 'server.*', 'app.*' (root only, not src/server.*).
233
+ *
234
+ * @param {ImportantFile[]} out
235
+ * @param {string[]} flatFiles
236
+ * @param {string} stem - e.g. 'server.' (note trailing dot)
237
+ * @param {string} type
238
+ * @param {string} reason
239
+ * @param {number} priority
240
+ */
241
+ function addRootPrefix(out, flatFiles, stem, type, reason, priority) {
242
+ for (const f of flatFiles) {
243
+ // Must start with stem AND have no directory separator in the remainder
244
+ if (f.startsWith(stem) && !f.slice(stem.length).includes('/')) {
245
+ out.push({ path: f, type, reason, priority });
246
+ }
247
+ }
248
+ }
249
+ // ---------------------------------------------------------------------------
250
+ // Project-specific candidate builder
251
+ // ---------------------------------------------------------------------------
252
+ /**
253
+ * Return framework-specific candidates based on detected project type.
254
+ * Only files that exist in flatFiles are included (checked by callers via
255
+ * addExact/addPrefix/addSuffix/addRootPrefix).
256
+ *
257
+ * @param {string} projectType - From ScanResult.projectType
258
+ * @param {string[]} flatFiles - All scanned file paths
259
+ * @param {Set<string>} fileSet - flatFiles as Set for O(1) lookup
260
+ * @returns {ImportantFile[]}
261
+ */
262
+ function getProjectCandidates(projectType, flatFiles, fileSet) {
263
+ const out = [];
264
+ const pt = projectType.toLowerCase();
265
+ // ── Framework build configs (apply to many ecosystems) ───────────────────
266
+ addPrefix(out, flatFiles, 'vite.config.', 'configuration', 'Vite build and development configuration', 85);
267
+ addPrefix(out, flatFiles, 'webpack.config.', 'configuration', 'Webpack bundler configuration', 85);
268
+ // ── Next.js ───────────────────────────────────────────────────────────────
269
+ if (pt.includes('next')) {
270
+ // Framework config
271
+ for (const f of ['next.config.js', 'next.config.mjs', 'next.config.ts']) {
272
+ addExact(out, fileSet, f, 'configuration', 'Next.js framework configuration', 85);
273
+ }
274
+ // App Router
275
+ for (const ext of ['js', 'jsx', 'ts', 'tsx']) {
276
+ addExact(out, fileSet, `app/layout.${ext}`, 'entry-point', 'Root layout for the Next.js App Router', 82);
277
+ addExact(out, fileSet, `app/page.${ext}`, 'entry-point', 'Root page for the Next.js App Router', 81);
278
+ }
279
+ // Edge middleware
280
+ for (const f of ['middleware.js', 'middleware.ts']) {
281
+ addExact(out, fileSet, f, 'configuration', 'Next.js edge middleware', 78);
282
+ }
283
+ // Pages Router
284
+ addPrefix(out, flatFiles, 'pages/index.', 'entry-point', 'Home page for the Next.js Pages Router', 78);
285
+ }
286
+ // ── Nuxt.js ───────────────────────────────────────────────────────────────
287
+ else if (pt.includes('nuxt')) {
288
+ for (const f of ['nuxt.config.js', 'nuxt.config.ts', 'nuxt.config.mjs']) {
289
+ addExact(out, fileSet, f, 'configuration', 'Nuxt.js framework configuration', 85);
290
+ }
291
+ for (const ext of ['js', 'vue', 'ts']) {
292
+ addExact(out, fileSet, `app.${ext}`, 'entry-point', 'Nuxt application root', 82);
293
+ addExact(out, fileSet, `pages/index.${ext}`, 'entry-point', 'Nuxt home page (Pages Router)', 78);
294
+ }
295
+ }
296
+ // ── React (Vite / CRA) ───────────────────────────────────────────────────
297
+ else if (pt.includes('react')) {
298
+ addPrefix(out, flatFiles, 'src/main.', 'entry-point', 'Application entry point', 82);
299
+ addPrefix(out, flatFiles, 'src/App.', 'entry-point', 'Root application component', 78);
300
+ // CRA fallback
301
+ addExact(out, fileSet, 'public/index.html', 'entry-point', 'Application HTML entry point', 76);
302
+ }
303
+ // ── Vue.js ────────────────────────────────────────────────────────────────
304
+ else if (pt.includes('vue')) {
305
+ for (const f of ['vue.config.js', 'vue.config.ts']) {
306
+ addExact(out, fileSet, f, 'configuration', 'Vue CLI configuration', 85);
307
+ }
308
+ addPrefix(out, flatFiles, 'src/main.', 'entry-point', 'Application entry point', 82);
309
+ addPrefix(out, flatFiles, 'src/App.', 'entry-point', 'Root application component', 78);
310
+ }
311
+ // ── Angular ───────────────────────────────────────────────────────────────
312
+ else if (pt.includes('angular')) {
313
+ addExact(out, fileSet, 'angular.json', 'configuration', 'Angular workspace configuration', 85);
314
+ addPrefix(out, flatFiles, 'src/main.', 'entry-point', 'Angular bootstrap entry point', 82);
315
+ addExact(out, fileSet, 'src/app/app.module.ts', 'entry-point', 'Angular root module', 80);
316
+ addExact(out, fileSet, 'src/app/app.component.ts', 'entry-point', 'Angular root component', 78);
317
+ }
318
+ // ── Svelte ────────────────────────────────────────────────────────────────
319
+ else if (pt.includes('svelte')) {
320
+ for (const f of ['svelte.config.js', 'svelte.config.ts']) {
321
+ addExact(out, fileSet, f, 'configuration', 'SvelteKit / Svelte configuration', 85);
322
+ }
323
+ addPrefix(out, flatFiles, 'src/routes/+page.', 'entry-point', 'SvelteKit home page route', 82);
324
+ addPrefix(out, flatFiles, 'src/main.', 'entry-point', 'Svelte application entry point', 80);
325
+ addPrefix(out, flatFiles, 'src/App.', 'entry-point', 'Svelte root component', 78);
326
+ }
327
+ // ── Express / Fastify / Koa (Node.js server frameworks) ──────────────────
328
+ else if (pt.includes('express') || pt.includes('fastify') || pt.includes('koa')) {
329
+ addRootPrefix(out, flatFiles, 'server.', 'entry-point', 'Server application entry point', 82);
330
+ addRootPrefix(out, flatFiles, 'app.', 'entry-point', 'Application entry point', 80);
331
+ addPrefix(out, flatFiles, 'src/server.', 'entry-point', 'Server application entry point', 80);
332
+ addPrefix(out, flatFiles, 'src/app.', 'entry-point', 'Application entry point', 78);
333
+ // Common conventions
334
+ addExact(out, fileSet, 'src/index.js', 'entry-point', 'Application entry point', 76);
335
+ addExact(out, fileSet, 'src/index.ts', 'entry-point', 'Application entry point', 76);
336
+ }
337
+ // ── Python ────────────────────────────────────────────────────────────────
338
+ if (pt.includes('python')) {
339
+ addExact(out, fileSet, 'main.py', 'entry-point', 'Main Python application entry point', 82);
340
+ addExact(out, fileSet, 'manage.py', 'entry-point', 'Django project management CLI', 82);
341
+ addExact(out, fileSet, 'app.py', 'entry-point', 'Flask / web framework application', 80);
342
+ addExact(out, fileSet, 'wsgi.py', 'configuration', 'WSGI server entry point', 75);
343
+ addExact(out, fileSet, 'asgi.py', 'configuration', 'ASGI server entry point', 75);
344
+ }
345
+ // ── Java / Spring Boot ────────────────────────────────────────────────────
346
+ if (pt.includes('java') || pt.includes('spring')) {
347
+ addExact(out, fileSet, 'pom.xml', 'manifest', 'Maven project descriptor and dependency manifest', 100);
348
+ addExact(out, fileSet, 'build.gradle', 'manifest', 'Gradle build script and dependency manifest', 100);
349
+ addExact(out, fileSet, 'build.gradle.kts', 'manifest', 'Gradle Kotlin DSL build script', 100);
350
+ addSuffix(out, flatFiles, 'Application.java', 'entry-point', 'Spring Boot application entry point', 82);
351
+ addSuffix(out, flatFiles, 'Application.kt', 'entry-point', 'Spring Boot Kotlin application entry point', 82);
352
+ // Main application properties
353
+ addExact(out, fileSet, 'src/main/resources/application.properties', 'configuration', 'Spring Boot application configuration', 78);
354
+ addExact(out, fileSet, 'src/main/resources/application.yml', 'configuration', 'Spring Boot application configuration', 78);
355
+ }
356
+ // ── Go ────────────────────────────────────────────────────────────────────
357
+ if (pt === 'go') {
358
+ addExact(out, fileSet, 'go.mod', 'manifest', 'Go module definition and dependency manifest', 100);
359
+ addExact(out, fileSet, 'go.sum', 'manifest', 'Go module checksums', 92);
360
+ addExact(out, fileSet, 'main.go', 'entry-point', 'Main Go application entry point', 82);
361
+ addExact(out, fileSet, 'Makefile', 'utility', 'Build and task automation', 72);
362
+ }
363
+ // ── Rust ──────────────────────────────────────────────────────────────────
364
+ if (pt.includes('rust')) {
365
+ addExact(out, fileSet, 'Cargo.toml', 'manifest', 'Rust package manifest and dependency configuration', 100);
366
+ addExact(out, fileSet, 'Cargo.lock', 'manifest', 'Rust dependency lockfile', 92);
367
+ addExact(out, fileSet, 'src/main.rs', 'entry-point', 'Binary crate entry point', 82);
368
+ addExact(out, fileSet, 'src/lib.rs', 'entry-point', 'Library crate root', 82);
369
+ }
370
+ // ── PHP / Laravel / Composer ──────────────────────────────────────────────
371
+ if (pt.includes('php') || pt.includes('composer')) {
372
+ addExact(out, fileSet, 'composer.json', 'manifest', 'PHP Composer dependency manifest', 100);
373
+ addExact(out, fileSet, 'artisan', 'utility', 'Laravel CLI tool', 82);
374
+ addExact(out, fileSet, 'routes/web.php', 'configuration', 'Web route definitions', 78);
375
+ addExact(out, fileSet, 'routes/api.php', 'configuration', 'API route definitions', 78);
376
+ addExact(out, fileSet, 'public/index.php', 'entry-point', 'HTTP front controller (Laravel / PHP)', 76);
377
+ }
378
+ // ── Ruby / Rails ──────────────────────────────────────────────────────────
379
+ if (pt.includes('ruby') || pt.includes('rails')) {
380
+ addExact(out, fileSet, 'Gemfile', 'manifest', 'Ruby gem dependency manifest', 100);
381
+ addExact(out, fileSet, 'config/routes.rb', 'configuration', 'Rails route definitions', 78);
382
+ addExact(out, fileSet, 'config/application.rb', 'configuration', 'Rails application configuration', 76);
383
+ addExact(out, fileSet, 'config/environment.rb', 'configuration', 'Rails environment bootstrap', 74);
384
+ addExact(out, fileSet, 'app/controllers/application_controller.rb', 'entry-point', 'Rails base application controller', 72);
385
+ }
386
+ // ── Elixir / Phoenix ─────────────────────────────────────────────────────
387
+ if (pt.includes('elixir') || pt.includes('phoenix')) {
388
+ addExact(out, fileSet, 'mix.exs', 'manifest', 'Elixir Mix build and dependency manifest', 100);
389
+ addExact(out, fileSet, 'mix.lock', 'manifest', 'Elixir Mix dependency lockfile', 92);
390
+ addPrefix(out, flatFiles, 'lib/', 'entry-point', 'Elixir application module', 75);
391
+ }
392
+ return out;
393
+ }
394
+ // ---------------------------------------------------------------------------
395
+ // Deduplication and sort
396
+ // ---------------------------------------------------------------------------
397
+ /**
398
+ * Merge a list of raw candidates into a deduplicated, sorted result.
399
+ * When the same path appears with different priorities, the highest wins.
400
+ * Ties in priority are broken by ascending alphabetical path order.
401
+ *
402
+ * @param {ImportantFile[]} rawCandidates
403
+ * @returns {ImportantFile[]}
404
+ */
405
+ function deduplicateAndSort(rawCandidates) {
406
+ /** @type {Map<string, ImportantFile>} */
407
+ const best = new Map();
408
+ for (const candidate of rawCandidates) {
409
+ const existing = best.get(candidate.path);
410
+ if (!existing || candidate.priority > existing.priority) {
411
+ best.set(candidate.path, candidate);
412
+ }
413
+ }
414
+ return Array.from(best.values()).sort((a, b) => {
415
+ if (b.priority !== a.priority)
416
+ return b.priority - a.priority; // higher first
417
+ return a.path.localeCompare(b.path); // alpha on ties
418
+ });
419
+ }
420
+ export function detectImportantFiles({ flatFiles, projectType, entryPoints, configs }) {
421
+ const fileSet = new Set(flatFiles);
422
+ /** @type {ImportantFile[]} */
423
+ const raw = [];
424
+ // ── 1. Generic files (always check, any project type) ────────────────────
425
+ for (const candidate of GENERIC_CANDIDATES) {
426
+ if (fileSet.has(candidate.path)) {
427
+ raw.push({ ...candidate });
428
+ }
429
+ }
430
+ for (const candidate of ECOSYSTEM_MANIFESTS) {
431
+ if (fileSet.has(candidate.path)) {
432
+ raw.push({ ...candidate });
433
+ }
434
+ }
435
+ // ── 2. Primary entry point ────────────────────────────────────────────────
436
+ if (entryPoints.length > 0) {
437
+ const primary = entryPoints[0];
438
+ if (fileSet.has(primary)) {
439
+ raw.push({
440
+ path: primary,
441
+ type: 'entry-point',
442
+ reason: 'Primary application entry point',
443
+ priority: 90,
444
+ });
445
+ }
446
+ }
447
+ // ── 3. Project-specific candidates ───────────────────────────────────────
448
+ const projectCandidates = getProjectCandidates(projectType, flatFiles, fileSet);
449
+ for (const c of projectCandidates) {
450
+ raw.push(c);
451
+ }
452
+ // ── 4. Deduplicate, resolve priority conflicts, and sort ──────────────────
453
+ return { importantFiles: deduplicateAndSort(raw) };
454
+ }
455
+ //# sourceMappingURL=important-files-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"important-files-detector.js","sourceRoot":"","sources":["../../src/detectors/important-files-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,8EAA8E;AAC9E,oDAAoD;AACpD,8EAA8E;AAE9E;;;;;;;;GAQG;AAEH,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG;IACzB,6EAA6E;IAC7E;QACE,IAAI,EAAM,cAAc;QACxB,IAAI,EAAM,UAAU;QACpB,MAAM,EAAI,qDAAqD;QAC/D,QAAQ,EAAE,GAAG;KACd;IAED,6EAA6E;IAC7E;QACE,IAAI,EAAM,WAAW;QACrB,IAAI,EAAM,eAAe;QAC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,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,mBAAmB,EAAE,CAAC;QAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,6EAA6E;IAC7E,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,CAAC;gBACP,IAAI,EAAM,OAAO;gBACjB,IAAI,EAAM,aAAa;gBACvB,MAAM,EAAI,iCAAiC;gBAC3C,QAAQ,EAAE,EAAE;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAChF,KAAK,MAAM,CAAC,IAAI,iBAAiB,EAAE,CAAC;QAClC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IAED,6EAA6E;IAC7E,OAAO,EAAE,cAAc,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { PackageManager } from '../types/index.js';
2
+ export interface PackageManagerResult {
3
+ packageManager: PackageManager | null;
4
+ packageManagers: PackageManager[];
5
+ ambiguous: boolean;
6
+ }
7
+ export declare function detectPackageManager(flatFiles: string[]): PackageManagerResult;
@@ -0,0 +1,35 @@
1
+ const LOCKFILE_MAP = new Map([
2
+ ['package-lock.json', 'npm'],
3
+ ['pnpm-lock.yaml', 'pnpm'],
4
+ ['yarn.lock', 'yarn'],
5
+ ['bun.lock', 'bun'],
6
+ ['bun.lockb', 'bun'],
7
+ ]);
8
+ export function detectPackageManager(flatFiles) {
9
+ const detected = new Set();
10
+ for (const file of flatFiles) {
11
+ if (file.includes('/'))
12
+ continue;
13
+ const pm = LOCKFILE_MAP.get(file);
14
+ if (pm !== undefined) {
15
+ detected.add(pm);
16
+ }
17
+ }
18
+ const packageManagers = Array.from(detected).sort();
19
+ if (packageManagers.length === 0) {
20
+ return { packageManager: null, packageManagers: [], ambiguous: false };
21
+ }
22
+ if (packageManagers.length === 1) {
23
+ return {
24
+ packageManager: packageManagers[0],
25
+ packageManagers: packageManagers,
26
+ ambiguous: false,
27
+ };
28
+ }
29
+ return {
30
+ packageManager: null,
31
+ packageManagers: packageManagers,
32
+ ambiguous: true,
33
+ };
34
+ }
35
+ //# sourceMappingURL=package-manager-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-manager-detector.js","sourceRoot":"","sources":["../../src/detectors/package-manager-detector.ts"],"names":[],"mappings":"AAQA,MAAM,YAAY,GAAgC,IAAI,GAAG,CAAC;IACxD,CAAC,mBAAmB,EAAE,KAAK,CAAC;IAC5B,CAAC,gBAAgB,EAAK,MAAM,CAAC;IAC7B,CAAC,WAAW,EAAU,MAAM,CAAC;IAC7B,CAAC,UAAU,EAAW,KAAK,CAAC;IAC5B,CAAC,WAAW,EAAU,KAAK,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,SAAmB;IACtD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE3C,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,SAAS;QAEjC,MAAM,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,IAA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